[m-rev.] trivial diff: clean up compiler/module_qual.m

Julien Fischer juliensf at cs.mu.OZ.AU
Wed May 25 13:45:17 AEST 2005


Estimated hour taken: 0.2
Branches: main

The diff is just a cleanup; there are no changes to any algorithms.

compiler/module_qual.m:
	Switch to four-space indentation throughout.

	Update the formatting of comments throughout.

	Use unexpected/2 in place of error/1.

	Fix a couple of typos in the comments.

Julien.

Workspace:/home/aral/juliensf/ws1
Index: compiler/module_qual.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/module_qual.m,v
retrieving revision 1.106
diff -u -b -r1.106 module_qual.m
--- compiler/module_qual.m	23 May 2005 03:15:38 -0000	1.106
+++ compiler/module_qual.m	25 May 2005 03:37:52 -0000
@@ -1,22 +1,27 @@
 %-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et
+%-----------------------------------------------------------------------------%
 % Copyright (C) 1996-2005 The University of Melbourne.
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
 %
-:- module parse_tree.module_qual.
-%	Main authors: stayl, fjh.
+% File: module_qual.m
+% Main authors: stayl, fjh
 %
-%	Module qualifies types, insts and modes within declaration items.
-%	The head of all declarations should be module qualified in prog_io.m.
-%	This module qualifies the bodies of the declarations.
-%	Checks for undefined types, insts and modes.
-%	Uses two passes over the item list, one to collect all type, mode
-%	and inst ids and a second to do the qualification and report errors.
-%	If the --warn-interface-imports option is set, warns about modules
-%	imported in the interface that do not need to be in the interface.
-%	The modes of lambda expressions are qualified in modes.m.
+% Module qualifies types, insts and modes within declaration items.  The
+% head of all declarations should be module qualified in prog_io.m.
+% This module qualifies the bodies of the declarations.  Checks for
+% undefined types, insts and modes.  Uses two passes over the item list,
+% one to collect all type, mode and inst ids and a second to do the
+% qualification and report errors.  If the --warn-interface-imports
+% option is set, warns about modules imported in the interface that do
+% not need to be in the interface.  The modes of lambda expressions are
+% qualified in modes.m.
 %
+%-----------------------------------------------------------------------------%
+
+:- module parse_tree.module_qual.
 :- interface.

 :- import_module mdbcomp.prim_data.
@@ -28,35 +33,41 @@
 :- import_module list.
 :- import_module std_util.

+%-----------------------------------------------------------------------------%
+
 	% module_qualify_items(Items0, Items, ModuleName, ReportUndefErrors,
 	%	MQ_Info, NumErrors, UndefTypes, UndefModes):
 	%
-	% Items is Items0 with all items module qualified as much
-	% as possible. If ReportUndefErrors is yes, then
-	% report undefined types, insts and modes.
-	% ReportUndefErrors should be no when module qualifying the
-	% short interface.
+    % Items is Items0 with all items module qualified as much as
+    % possible. If ReportUndefErrors is yes, then report undefined
+    % types, insts and modes.  ReportUndefErrors should be no when
+    % module qualifying the short interface.
+    %
 :- pred module_qual.module_qualify_items(item_list::in, item_list::out,
 	module_name::in, bool::in, mq_info::out, int::out, bool::out,
 	bool::out, io::di, io::uo) is det.

 	% This is called from make_hlds.m to qualify the mode of a lambda
 	% expression.
+    %
 :- pred module_qual.qualify_lambda_mode_list(list(mode)::in, list(mode)::out,
 	prog_context::in, mq_info::in, mq_info::out, io::di, io::uo) is det.

 	% This is called from make_hlds.m to qualify the modes in a
 	% clause mode annotation.
+    %
 :- pred module_qual.qualify_clause_mode_list(list(mode)::in, list(mode)::out,
 	prog_context::in, mq_info::in, mq_info::out, io::di, io::uo) is det.

 	% This is called from make_hlds.m to qualify an
 	% explicit type qualification.
+    %
 :- pred module_qual.qualify_type_qualification((type)::in, (type)::out,
 	prog_context::in, mq_info::in, mq_info::out, io::di, io::uo) is det.

 	% The type mq_info holds information needed for doing module
 	% qualification.
+    %
 :- type mq_info.

 :- pred mq_info_get_num_errors(mq_info::in, int::out) is det.
@@ -75,36 +86,39 @@

 	% The type partial_qualifier_info holds info need for computing which
 	% partial quantifiers are visible -- see get_partial_qualifiers/3.
+    %
 :- type partial_qualifier_info.

-% Suppose we are processing a definition which defines the symbol
-% foo.bar.baz.quux/1.  Then we insert the following symbols
-% into the symbol table:
-%	- if the current value of the NeedQual flag at this point
-%		is `may_be_unqualified',
-%		i.e. module `foo.bar.baz' was imported
-%		then we insert the fully unqualified symbol quux/1;
-%	- if module `foo.bar.baz' occurs in the "imported" section,
-%		i.e. if module `foo.bar' was imported,
-%		then we insert the partially qualified symbol baz.quux/1;
-%	- if module `foo.bar' occurs in the "imported" section,
-%		i.e. if module `foo' was imported,
-%		then we insert the partially qualified symbol bar.baz.quux/1;
-%	- we always insert the fully qualified symbol foo.bar.baz.quux/1.
-%
-% The predicate `get_partial_qualifiers' returns all of the
-% partial qualifiers for which we need to insert definitions,
-% i.e. all the ones which are visible.  For example,
-% given as input `foo.bar.baz', it returns a list containing
-%	(1) `baz', iff `foo.bar' is imported
-% and 	(2) `bar.baz', iff `foo' is imported.
-% Note that the caller will still need to handle the fully-qualified
-% and fully-unqualified versions separately.
-
+    % Suppose we are processing a definition which defines the symbol
+    % foo.bar.baz.quux/1.  Then we insert the following symbols
+    % into the symbol table:
+    %   - if the current value of the NeedQual flag at this point
+    %       is `may_be_unqualified',
+    %       i.e. module `foo.bar.baz' was imported
+    %       then we insert the fully unqualified symbol quux/1;
+    %   - if module `foo.bar.baz' occurs in the "imported" section,
+    %       i.e. if module `foo.bar' was imported,
+    %       then we insert the partially qualified symbol baz.quux/1;
+    %   - if module `foo.bar' occurs in the "imported" section,
+    %       i.e. if module `foo' was imported,
+    %       then we insert the partially qualified symbol bar.baz.quux/1;
+    %   - we always insert the fully qualified symbol foo.bar.baz.quux/1.
+    %
+    % The predicate `get_partial_qualifiers' returns all of the
+    % partial qualifiers for which we need to insert definitions,
+    % i.e. all the ones which are visible.  For example,
+    % given as input `foo.bar.baz', it returns a list containing
+    %   (1) `baz', iff `foo.bar' is imported
+    % and   (2) `bar.baz', iff `foo' is imported.
+    % Note that the caller will still need to handle the fully-qualified
+    % and fully-unqualified versions separately.
+    %
 :- pred get_partial_qualifiers(module_name::in, partial_qualifier_info::in,
 	list(module_name)::out) is det.

 %-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
 :- implementation.

 :- import_module libs.globals.
@@ -123,9 +137,12 @@
 :- import_module require.
 :- import_module set.
 :- import_module string.
+:- import_module svmap.
 :- import_module term.
 :- import_module varset.

+%-----------------------------------------------------------------------------%
+
 module_qual.module_qualify_items(Items0, Items, ModuleName, ReportErrors,
 		Info, NumErrors, UndefTypes, UndefModes, !IO) :-
 	globals.io_get_globals(Globals, !IO),
@@ -218,6 +235,7 @@

 	% We only need to keep track of what is exported and what isn't,
 	% so we use a simpler data type here than hlds_pred.import_status.
+    %
 :- type import_status
 	--->	exported
 	;	local
@@ -227,6 +245,7 @@
 	% Pass over the item list collecting all defined module, type, mode and
 	% inst ids, all module synonym definitions, and the names of all
 	% modules imported in the interface.
+    %
 :- pred collect_mq_info(item_list::in, mq_info::in, mq_info::out) is det.

 collect_mq_info([], !Info).
@@ -337,7 +356,7 @@
 	% - For import declarations (`:- import_module' or `:- use_module'),
 	%   if we're currently in the interface section, then add the
 	%   imported modules to the unused_interface_modules list.
-
+    %
 :- pred process_module_defn(module_defn::in, mq_info::in, mq_info::out) is det.

 process_module_defn(module(ModuleName), !Info) :-
@@ -363,7 +382,7 @@
 	mq_info_set_import_status(abstract_imported, !Info),
 	mq_info_set_need_qual_flag(must_be_qualified, !Info).
 process_module_defn(transitively_imported, !Info) :-
-	error("process_module_defn: transitively_imported item").
+    unexpected(this_file, "process_module_defn: transitively_imported item").
 process_module_defn(external(_, _), !Info).
 process_module_defn(end_module(_), !Info).
 process_module_defn(export(_), !Info).
@@ -445,20 +464,21 @@
 		true
 	).

-
-%------------------------------------------------------------------------------
+%-----------------------------------------------------------------------------%

 	% process_assert(G, SNs, B)
 	%
 	% Scan the goal, G, building the list of qualified symbols, SNs.
-	% If there exists a single unqualifed symbol in G, the bool, B,
+    % If there exists a single unqualified symbol in G, the bool, B,
 	% will be set to no.
+    %
 :- pred process_assert(goal::in, list(sym_name)::out, bool::out) is det.

 	% AAA Some more stuff to do accumulator introduction on, it
 	% would be better to rewrite using maybes and then to declare
 	% the maybe_and predicate to be associative.
 	% NB. accumulator introduction doesn't work on this case yet.
+    %
 process_assert((GA , GB) - _, Symbols, Success) :-
 	process_assert(GA, SymbolsA, SuccessA),
 	process_assert(GB, SymbolsB, SuccessB),
@@ -548,9 +568,9 @@

 	% term_qualified_symbols(T, S)
 	%
-	% Given a term, T, return the list of all the sym_names, S, in
-	% the term.  The predicate fails if any sub-term of T is
-	% unqualified.
+    % Given a term, T, return the list of all the sym_names, S, in the
+    % term.  The predicate fails if any sub-term of T is unqualified.
+    %
 :- pred term_qualified_symbols(term::in, list(sym_name)::out) is semidet.

 term_qualified_symbols(Term, Symbols) :-
@@ -572,12 +592,13 @@
 	term_qualified_symbols_list(Terms, Symbols0),
 	list.append(Symbols0, TermSymbols, Symbols).

-%------------------------------------------------------------------------------
+%-----------------------------------------------------------------------------%

 	% Iterate over the item list module qualifying all declarations.
 	% Stop when the :- imported or :- opt_imported pseudo-declaration
 	% is reached, since imported declarations should already be
 	% module qualified.
+    %
 :- pred do_module_qualify_items(item_list::in, item_list::out,
 	mq_info::in, mq_info::out, io::di, io::uo) is det.

@@ -593,11 +614,11 @@
 	).

 	% Call predicates to qualify a single item.
+    %
 :- pred module_qualify_item(item_and_context::in, item_and_context::out,
 	mq_info::in, mq_info::out, bool::out, io::di, io::uo) is det.

-module_qualify_item(clause(A,B,C,D,E) - Con, clause(A,B,C,D,E) - Con,
-		!Info, yes, !IO).
+module_qualify_item(Clause @ (clause(_,_,_,_,_) - _), Clause, !Info, yes, !IO).

 module_qualify_item(
 		type_defn(TVarSet, SymName, Params, TypeDefn0, C) - Context,
@@ -686,8 +707,10 @@
 	list.length(Types0, Arity),
 	Id = Name0 - Arity,
 	mq_info_set_error_context(instance(Id) - Context, !Info),
+    %
 		% We don't qualify the implementation yet, since that requires
 		% us to resolve overloading.
+    %
 	qualify_prog_constraint_list(Constraints0, Constraints, !Info, !IO),
 	qualify_class_name(Id, Name - _, !Info, !IO),
 	qualify_type_list(Types0, Types, !Info, !IO),
@@ -723,6 +746,7 @@
 	mq_info_set_unused_interface_modules(UnusedInterfaceModules, !Info).

 	% Qualify the constructors or other types in a type definition.
+    %
 :- pred qualify_type_defn(type_defn::in, type_defn::out,
 	mq_info::in, mq_info::out, io::di, io::uo) is det.

@@ -730,11 +754,12 @@
 		du_type(Ctors, MaybeUserEqComp),
 		!Info, !IO) :-
 	qualify_constructors(Ctors0, Ctors, !Info, !IO),
-
+    %
 	% User-defined equality pred names will be converted into
 	% predicate calls and then module-qualified after type analysis
 	% (during mode analysis).  That way they get full type overloading
 	% resolution, etc.  Thus we don't module-qualify them here.
+    %
 	MaybeUserEqComp = MaybeUserEqComp0.
 qualify_type_defn(eqv_type(Type0), eqv_type(Type), !Info, !IO) :-
 	qualify_type(Type0, Type, !Info, !IO).
@@ -763,6 +788,7 @@
 	Ctor  = ctor(ExistQVars, Constraints, SymName, Args).

 	% Qualify the inst parameters of an inst definition.
+    %
 :- pred qualify_inst_defn(inst_defn::in, inst_defn::out,
 	mq_info::in, mq_info::out, io::di, io::uo) is det.

@@ -771,6 +797,7 @@
 qualify_inst_defn(abstract_inst, abstract_inst, !Info, !IO).

 	% Qualify the mode parameter of an equivalence mode definition.
+    %
 :- pred qualify_mode_defn(mode_defn::in, mode_defn::out,
 	mq_info::in, mq_info::out, io::di, io::uo) is det.

@@ -779,6 +806,7 @@

 	% Qualify a list of items of the form Type::Mode, as in a
 	% predicate declaration.
+    %
 :- pred qualify_types_and_modes(list(type_and_mode)::in,
 	list(type_and_mode)::out, mq_info::in, mq_info::out,
 	io::di, io::uo) is det.
@@ -811,9 +839,9 @@
 :- pred qualify_mode((mode)::in, (mode)::out, mq_info::in, mq_info::out,
 	io::di, io::uo) is det.

-qualify_mode((Inst0a -> Inst1a), (Inst0 -> Inst1), !Info, !IO) :-
-	qualify_inst(Inst0a, Inst0, !Info, !IO),
-	qualify_inst(Inst1a, Inst1, !Info, !IO).
+qualify_mode((InstA0 -> InstB0), (InstA -> InstB), !Info, !IO) :-
+    qualify_inst(InstA0, InstA, !Info, !IO),
+    qualify_inst(InstB0, InstB, !Info, !IO).

 qualify_mode(user_defined_mode(SymName0, Insts0),
 		user_defined_mode(SymName, Insts), !Info, !IO) :-
@@ -832,6 +860,7 @@
 	qualify_inst_list(Insts0, Insts, !Info, !IO).

 	% Qualify a single inst.
+    %
 :- pred qualify_inst((inst)::in, (inst)::out, mq_info::in, mq_info::out,
 	io::di, io::uo) is det.

@@ -839,7 +868,7 @@
 qualify_inst(free, free, !Info, !IO).
 qualify_inst(not_reached, not_reached, !Info, !IO).
 qualify_inst(free(_), _, !Info, !IO) :-
-	error("compiler generated inst not expected").
+    unexpected(this_file, "compiler generated inst not expected").
 qualify_inst(bound(Uniq, BoundInsts0), bound(Uniq, BoundInsts), !Info, !IO) :-
 	qualify_bound_inst_list(BoundInsts0, BoundInsts, !Info, !IO).
 qualify_inst(ground(Uniq, GroundInstInfo0), ground(Uniq, GroundInstInfo),
@@ -864,6 +893,7 @@

 	% Find the unique inst_id that matches this inst, and qualify
 	% the argument insts.
+    %
 :- pred qualify_inst_name(inst_name::in, inst_name::out,
 	mq_info::in, mq_info::out, io::di, io::uo) is det.

@@ -886,23 +916,24 @@
 			InstIds, inst_id, !Info, !IO)
 	).
 qualify_inst_name(merge_inst(_, _), _, !Info, !IO) :-
-	error("compiler generated inst unexpected").
+    unexpected(this_file, "compiler generated inst unexpected").
 qualify_inst_name(unify_inst(_, _, _, _), _, !Info, !IO) :-
-	error("compiler generated inst unexpected").
+    unexpected(this_file, "compiler generated inst unexpected").
 qualify_inst_name(ground_inst(_, _, _, _), _, !Info, !IO) :-
-	error("compiler generated inst unexpected").
+    unexpected(this_file, "compiler generated inst unexpected").
 qualify_inst_name(any_inst(_, _, _, _), _, !Info, !IO) :-
-	error("compiler generated inst unexpected").
+    unexpected(this_file, "compiler generated inst unexpected").
 qualify_inst_name(shared_inst(_), _, !Info, !IO) :-
-	error("compiler generated inst unexpected").
+    unexpected(this_file, "compiler generated inst unexpected").
 qualify_inst_name(mostly_uniq_inst(_), _, !Info, !IO) :-
-	error("compiler generated inst unexpected").
+    unexpected(this_file, "compiler generated inst unexpected").
 qualify_inst_name(typed_ground(_, _), _, !Info, !IO) :-
-	error("compiler generated inst unexpected").
+    unexpected(this_file, "compiler generated inst unexpected").
 qualify_inst_name(typed_inst(_, _), _, !Info, !IO) :-
-	error("compiler generated inst unexpected").
+    unexpected(this_file, "compiler generated inst unexpected").

 	% Qualify an inst of the form bound(functor(...)).
+    %
 :- pred qualify_bound_inst_list(list(bound_inst)::in, list(bound_inst)::out,
 	mq_info::in, mq_info::out, io::di, io::uo) is det.

@@ -939,6 +970,7 @@
 	qualify_type_list(Types0, Types, !Info, !IO).

 	% Qualify a type and its argument types.
+    %
 :- pred qualify_type((type)::in, (type)::out, mq_info::in, mq_info::out,
 	io::di, io::uo) is det.

@@ -997,6 +1029,7 @@
 	).

 	% Qualify the modes in a pragma c_code(...) decl.
+    %
 :- pred qualify_pragma((pragma_type)::in, (pragma_type)::out,
 	mq_info::in, mq_info::out, io::di, io::uo) is det.

@@ -1202,10 +1235,11 @@
 	).

 	% Find the unique match in the current name space for a given id
-	% from a list of ids. If none exists, either because no match was
-	% found or multiple matches were found, report an error.
+    % from a list of ids. If none exists, either because no match
+    % was found or multiple matches were found, report an error.
 	% This predicate assumes that type_ids, inst_ids, mode_ids and
 	% class_ids have the same representation.
+    %
 :- pred find_unique_match(id::in, id::out, id_set::in, id_type::in,
 	mq_info::in, mq_info::out, io::di, io::uo) is det.

@@ -1286,7 +1320,7 @@
 convert_simple_item_type(inst_id) = (inst).
 convert_simple_item_type(class_id) = (typeclass).

-%------------------------------------------------------------------------------
+%-----------------------------------------------------------------------------%

 :- type id_type
 	--->	type_id
@@ -1316,6 +1350,7 @@
 id_to_sym_name_and_arity(SymName - Arity) = SymName / Arity.

 	% Report an undefined type, inst or mode.
+    %
 :- pred report_undefined(list(module_name)::in, mq_info::in,
 	id::in, id_type::in, io::di, io::uo) is det.

@@ -1363,8 +1398,9 @@
 	),
 	write_error_pieces(Context, 0, Pieces1 ++ Pieces2, !IO).

-	% Report an error where a type, inst or mode had multiple possible
-	% matches.
+    % Report an error where a type, inst, mode or typeclass had
+    % multiple possible matches.
+    %
 :- pred report_ambiguous_match(error_context::in, id::in, id_type::in,
 	list(module_name)::in, io::di, io::uo) is det.

@@ -1389,6 +1425,7 @@
 	io.set_exit_status(1, !IO).

 	% Give a context for the current error message.
+    %
 :- func mq_error_context_to_pieces(mq_error_context) = list(format_component).

 mq_error_context_to_pieces(type(Id)) =
@@ -1427,8 +1464,7 @@
 mq_error_context_to_pieces(class(Id)) =
 	[words("declaration of typeclass"), wrap_id(Id)].
 mq_error_context_to_pieces(instance(Id)) =
-	[words("declaration of instance of typeclass"),
-		wrap_id(Id)].
+    [words("declaration of instance of typeclass"), wrap_id(Id)].

 :- pred id_type_to_string(id_type::in, string::out) is det.

@@ -1481,8 +1517,7 @@

 :- pred is_or_are(list(T)::in, string::out) is det.

-is_or_are([], "") :-
-	error("module_qual:is_or_are").
+is_or_are([], "") :- unexpected(this_file, "module_qual:is_or_are").
 is_or_are([_], "is").
 is_or_are([_, _ | _], "are").

@@ -1517,7 +1552,7 @@

 	% is_builtin_atomic_type(TypeCtor)
 	%	is true iff 'TypeCtor' is the type_ctor of a builtin atomic type
-
+    %
 :- pred is_builtin_atomic_type(type_ctor::in) is semidet.

 is_builtin_atomic_type(unqualified("int") - 0).
@@ -1526,7 +1561,9 @@
 is_builtin_atomic_type(unqualified("character") - 0).

 %-----------------------------------------------------------------------------%
+%
 % Access and initialisation predicates.
+%

 :- pred init_mq_info(item_list::in, globals::in, bool::in, module_name::in,
 	mq_info::out) is det.
@@ -1661,10 +1698,11 @@
 mq_info_set_error_flag_2(class_id, !Info) :-
 	mq_info_set_type_error_flag(!Info).

-	% If the current item is in the interface, remove its module
-	% name from the list of modules not used in the interface
-	% (and if the module name is itself module-qualified,
-	% recursively mark its parent module as used).
+    % If the current item is in the interface, remove its module name
+    % from the list of modules not used in the interface (and if the
+    % module name is itself module-qualified, recursively mark its
+    % parent module as used).
+    %
 :- pred mq_info_set_module_used(module_name::in, mq_info::in, mq_info::out)
 	is det.

@@ -1709,11 +1747,12 @@

 	% Insert an id into an id_set, aborting with an error if the
 	% id is not module qualified.
+    %
 :- pred id_set_insert(need_qualifier::in, id::in, id_set::in, id_set::out)
 	is det.

 id_set_insert(_, unqualified(_) - _, _, _) :-
-	error("module_qual:id_set_insert - unqualified id").
+    unexpected(this_file, "module_qual.id_set_insert - unqualified id").
 id_set_insert(NeedQualifier, qualified(Module, Name) - Arity, !IdSet) :-
 	( map.search(!.IdSet, Name - Arity, ImportModules0 - UseModules0) ->
 		ImportModules1 = ImportModules0,
@@ -1731,7 +1770,7 @@
 		set.insert(ImportModules1, Module, ImportModules),
 		UseModules = UseModules1
 	),
-	map.set(!.IdSet, Name - Arity, ImportModules - UseModules, !:IdSet).
+    svmap.set(Name - Arity, ImportModules - UseModules, !IdSet).

 :- pred id_set_search_sym_arity(id_set::in, sym_name::in, int::in,
 	module_id_set::in, list(module_name)::out) is det.
@@ -1739,51 +1778,47 @@
 id_set_search_sym_arity(IdSet, Sym, Arity, Modules, MatchingModules) :-
 	unqualify_name(Sym, UnqualName),
 	(
-		map.search(IdSet, UnqualName - Arity,
-			ImportModules - UseModules)
+        map.search(IdSet, UnqualName - Arity, ImportModules - UseModules)
 	->
 		(
 			Sym = unqualified(_),
 			set.to_sorted_list(ImportModules, MatchingModules)
 		;
 			Sym = qualified(Module, _),
-
 			%
-			% first, compute the set of modules that this
-			% module specifier could possibly refer to
+            % First, compute the set of modules that this
+            % module specifier could possibly refer to.
+            %
+            % Do a recursive search to find nested modules
+            % that match the specified module name.
 			%
-
-			% do a recursive search to find nested modules
-			% which match the specified module name
 			ModuleArity = 0,
 			id_set_search_sym_arity(Modules, Module, ModuleArity,
 				Modules, MatchingParentModules),
 			unqualify_name(Module, UnqualModule),
 			AppendModuleName = (pred(X::in, Y::out) is det :-
-					Y = qualified(X, UnqualModule)),
+                    Y = qualified(X, UnqualModule)
+            ),
 			list.map(AppendModuleName,
 				MatchingParentModules,
 				MatchingNestedModules),
-
-			% add the specified module name itself, in case
+            %
+            % Add the specified module name itself, in case
 			% it refers to a top-level (unnested) module name,
 			% since top-level modules don't get inserted into
 			% the module_id_set.
+            %
 			AllMatchingModules = [Module | MatchingNestedModules],
-
 			%
-			% second, compute the set of modules that define
-			% this symbol
+            % Second, compute the set of modules that define this symbol.
 			%
 			set.union(ImportModules, UseModules, DefiningModules),
-
 			%
-			% third, take the intersection of the sets computed
-			% in the first two steps
+            % Third, take the intersection of the sets computed in
+            % the first two steps
 			%
 			FindMatch = (pred(MatchModule::out) is nondet :-
-				list.member(MatchModule,
-					AllMatchingModules),
+                list.member(MatchModule, AllMatchingModules),
 				set.member(MatchModule, DefiningModules)
 			),
 			solutions(FindMatch, MatchingModules)
@@ -1812,7 +1847,7 @@
 get_partial_qualifiers_2(ImplicitPart, ExplicitPart, ModuleIdSet,
 		!Qualifiers) :-
 	%
-	% if the ImplicitPart module was imported, rather than just being
+    % If the ImplicitPart module was imported, rather than just being
 	% used, then insert the ExplicitPart module into the list of
 	% valid partial qualifiers.
 	%
@@ -1822,7 +1857,7 @@
 		true
 	),
 	%
-	% recursively try to add the other possible partial qualifiers
+    % Recursively try to add the other possible partial qualifiers.
 	%
 	( ImplicitPart = qualified(Parent, Child) ->
 		NextImplicitPart = Parent,
@@ -1863,4 +1898,12 @@
 get_first_module_name(unqualified(ModuleName)) = ModuleName.
 get_first_module_name(qualified(Parent, _)) = get_first_module_name(Parent).

+%----------------------------------------------------------------------------%
+
+:- func this_file = string.
+
+this_file = "module_qual.m".
+
+%----------------------------------------------------------------------------%
+:- end_module module_qual.
 %----------------------------------------------------------------------------%

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list