[m-rev.] diff: cleanup module_qual and middle_rec
Zoltan Somogyi
zs at cs.mu.OZ.AU
Sun Mar 20 13:23:34 AEDT 2005
compiler/module_qual.m:
Convert this module to our current coding style. Use state variables
where appropriate. Reorder arguments as required to allow the use of
state variables. Use error_util instead of io__write_string to print
error messages. Use predmode declarations where possible. Use . as
the module name separator.
There are no algorithmic changes except for the use of error_util.
compiler/middle_rec.m:
Convert this module to our current coding style. Use predmode
declarations where possible.
compiler/make_hlds.m:
compiler/mercury_compile.m:
Conform to changed argument orders of predicates in module_qual.m.
compiler/error_util.m:
Add a new version of the utility predicate that puts commas and "and"s
between elements of a list.
Fix an old bug: when printing a symname/arity pair, put quotes around
only the symname part.
tests/invalid/*.err_exp:
tests/invalid/purity/*.err_exp:
tests/recompilation/*.err_exp.2:
tests/warning/*.exp:
Update the expected error messages to reflect the better wrapping we
get from error_util, and in some cases to reflect the fixed code for
quotes around symnames.
Zoltan.
cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/error_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/error_util.m,v
retrieving revision 1.32
diff -u -r1.32 error_util.m
--- compiler/error_util.m 19 Jan 2005 05:52:59 -0000 1.32
+++ compiler/error_util.m 18 Mar 2005 11:40:03 -0000
@@ -77,6 +77,11 @@
:- func component_lists_to_pieces(list(list(format_component))) =
list(format_component).
+ % Convert a list of format_components into a list of format_components
+ % separated by commas, with the last two elements separated by `and'.
+:- func component_list_to_pieces(list(format_component)) =
+ list(format_component).
+
% Display the given error message, without a context and with standard
% indentation.
:- pred write_error_pieces_plain(list(format_component)::in,
@@ -190,6 +195,16 @@
component_lists_to_pieces(
[Components2, Components3 | Components])).
+component_list_to_pieces([]) = [].
+component_list_to_pieces([Component]) = [Component].
+component_list_to_pieces([Component1, Component2]) =
+ [Component1, words("and"), Component2].
+component_list_to_pieces(
+ [Component1, Component2, Component3 | Components]) =
+ list__append(append_punctuation([Component1], ','),
+ component_list_to_pieces(
+ [Component2, Component3 | Components])).
+
write_error_pieces_plain(Components, !IO) :-
write_error_pieces_maybe_with_context(yes, no, 0, Components, !IO).
@@ -431,8 +446,10 @@
:- func sym_name_and_arity_to_word(sym_name_and_arity) = string.
-sym_name_and_arity_to_word(SymNameAndArity) = "`" ++ SymStr ++ "'" :-
- sym_name_and_arity_to_string(SymNameAndArity, SymStr).
+sym_name_and_arity_to_word(SymName / Arity) =
+ "`" ++ SymStr ++ "'/" ++ ArityStr :-
+ sym_name_to_string(SymName, SymStr),
+ string__int_to_string(Arity, ArityStr).
:- pred break_into_words(string::in, list(word)::in, list(word)::out) is det.
Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.502
diff -u -r1.502 make_hlds.m
--- compiler/make_hlds.m 16 Mar 2005 00:37:52 -0000 1.502
+++ compiler/make_hlds.m 17 Mar 2005 01:38:34 -0000
@@ -1041,7 +1041,7 @@
; module_defn_update_import_status(Defn, ItemStatus1) ->
ItemStatus1 = item_status(!:Status, NeedQual),
qual_info_get_mq_info(!.QualInfo, MQInfo0),
- mq_info_set_need_qual_flag(MQInfo0, NeedQual, MQInfo),
+ mq_info_set_need_qual_flag(NeedQual, MQInfo0, MQInfo),
qual_info_set_mq_info(MQInfo, !QualInfo)
;
true
@@ -8724,7 +8724,7 @@
:- pred init_qual_info(mq_info::in, eqv_map::in, qual_info::out) is det.
init_qual_info(MQInfo0, EqvMap, QualInfo) :-
- mq_info_set_need_qual_flag(MQInfo0, may_be_unqualified, MQInfo),
+ mq_info_set_need_qual_flag(may_be_unqualified, MQInfo0, MQInfo),
varset__init(TVarSet),
map__init(Renaming),
map__init(Index),
@@ -8780,7 +8780,7 @@
(
MaybeRecompInfo0 = yes(RecompInfo0),
Pred(RecompInfo0, RecompInfo),
- mq_info_set_recompilation_info(MQInfo0, yes(RecompInfo), MQInfo),
+ mq_info_set_recompilation_info(yes(RecompInfo), MQInfo0, MQInfo),
!:QualInfo = !.QualInfo ^ mq_info := MQInfo
;
MaybeRecompInfo0 = no
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.327
diff -u -r1.327 mercury_compile.m
--- compiler/mercury_compile.m 6 Mar 2005 05:17:29 -0000 1.327
+++ compiler/mercury_compile.m 16 Mar 2005 11:46:06 -0000
@@ -1744,7 +1744,7 @@
mq_info_get_recompilation_info(MQInfo0, RecompInfo0),
mercury_compile__expand_equiv_types(Module, Items2, Verbose, Stats,
Items, CircularTypes, EqvMap, RecompInfo0, RecompInfo, !IO),
- mq_info_set_recompilation_info(MQInfo0, RecompInfo, MQInfo),
+ mq_info_set_recompilation_info(RecompInfo, MQInfo0, MQInfo),
bool__or(UndefTypes0, CircularTypes, UndefTypes1),
mercury_compile__make_hlds(Module, Items, MQInfo, EqvMap,
Index: compiler/middle_rec.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/middle_rec.m,v
retrieving revision 1.102
diff -u -r1.102 middle_rec.m
--- compiler/middle_rec.m 17 Jan 2005 05:16:12 -0000 1.102
+++ compiler/middle_rec.m 17 Mar 2005 04:37:54 -0000
@@ -18,9 +18,8 @@
:- import_module ll_backend__code_info.
:- import_module ll_backend__llds.
-:- pred middle_rec__match_and_generate(hlds_goal, code_tree,
- code_info, code_info).
-:- mode middle_rec__match_and_generate(in, out, in, out) is semidet.
+:- pred middle_rec__match_and_generate(hlds_goal::in, code_tree::out,
+ code_info::in, code_info::out) is semidet.
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
@@ -42,8 +41,14 @@
:- import_module parse_tree__prog_data.
:- import_module parse_tree__prog_out.
-:- import_module bool, int, string, list, assoc_list, set, std_util.
+:- import_module assoc_list.
+:- import_module bool.
+:- import_module int.
+:- import_module list.
:- import_module require.
+:- import_module set.
+:- import_module std_util.
+:- import_module string.
%---------------------------------------------------------------------------%
@@ -297,17 +302,17 @@
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
-:- pred middle_rec__generate_downloop_test(list(instruction), label,
- list(instruction)).
-:- mode middle_rec__generate_downloop_test(in, in, out) is det.
+:- pred middle_rec__generate_downloop_test(list(instruction)::in, label::in,
+ list(instruction)::out) is det.
middle_rec__generate_downloop_test([], _, _) :-
error("middle_rec__generate_downloop_test on empty list").
middle_rec__generate_downloop_test([Instr0 | Instrs0], Target, Instrs) :-
( Instr0 = if_val(Test, _OldTarget) - _Comment ->
- ( Instrs0 = [] ->
- true
+ (
+ Instrs0 = []
;
+ Instrs0 = [_ | _],
error("middle_rec__generate_downloop_test: " ++
"if_val followed by other instructions")
),
@@ -321,9 +326,8 @@
%---------------------------------------------------------------------------%
-:- pred middle_rec__split_rec_code(list(instruction),
- list(instruction), list(instruction)).
-:- mode middle_rec__split_rec_code(in, out, out) is det.
+:- pred middle_rec__split_rec_code(list(instruction)::in,
+ list(instruction)::out, list(instruction)::out) is det.
middle_rec__split_rec_code([], _, _) :-
error("did not find call in middle_rec__split_rec_code").
@@ -351,7 +355,7 @@
list(instruction)::out) is det.
middle_rec__add_counter_to_livevals([], _Lval, []).
-middle_rec__add_counter_to_livevals([I0|Is0], Lval, [I|Is]) :-
+middle_rec__add_counter_to_livevals([I0 | Is0], Lval, [I | Is]) :-
(
I0 = livevals(Lives0) - Comment
->
@@ -443,7 +447,7 @@
middle_rec__find_used_registers_instr(fork(_, _, _), !Used).
middle_rec__find_used_registers_instr(join_and_terminate(Lval), !Used) :-
middle_rec__find_used_registers_lval(Lval, !Used).
-middle_rec__find_used_registers_instr(join_and_continue(Lval,_), !Used) :-
+middle_rec__find_used_registers_instr(join_and_continue(Lval, _), !Used) :-
middle_rec__find_used_registers_lval(Lval, !Used).
:- pred middle_rec__find_used_registers_components(
@@ -543,7 +547,7 @@
set(int)::in, set(int)::out) is det.
insert_pragma_c_input_registers([], !Used).
-insert_pragma_c_input_registers([Input|Inputs], !Used) :-
+insert_pragma_c_input_registers([Input | Inputs], !Used) :-
Input = pragma_c_input(_, _, _, Rval, _),
middle_rec__find_used_registers_rval(Rval, !Used),
insert_pragma_c_input_registers(Inputs, !Used).
@@ -552,7 +556,7 @@
set(int)::in, set(int)::out) is det.
insert_pragma_c_output_registers([], !Used).
-insert_pragma_c_output_registers([Output|Outputs], !Used) :-
+insert_pragma_c_output_registers([Output | Outputs], !Used) :-
Output = pragma_c_output(Lval, _, _, _, _),
middle_rec__find_used_registers_lval(Lval, !Used),
insert_pragma_c_output_registers(Outputs, !Used).
Index: compiler/module_qual.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/module_qual.m,v
retrieving revision 1.97
diff -u -r1.97 module_qual.m
--- compiler/module_qual.m 10 Mar 2005 02:35:58 -0000 1.97
+++ compiler/module_qual.m 18 Mar 2005 14:56:12 -0000
@@ -4,7 +4,7 @@
% Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------%
%
-:- module parse_tree__module_qual.
+:- module parse_tree.module_qual.
% Main authors: stayl, fjh.
%
% Module qualifies types, insts and modes within declaration items.
@@ -19,48 +19,38 @@
%
:- interface.
-:- import_module mdbcomp__prim_data.
-:- import_module parse_tree__prog_data.
+:- import_module mdbcomp.prim_data.
+:- import_module parse_tree.prog_data.
:- import_module recompilation.
:- import_module bool, list, std_util, io.
% module_qualify_items(Items0, Items, ModuleName, ReportUndefErrors,
- % MQ_Info, NumErrors, UndefTypes, UndefModes):
+ % 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.
-:- pred module_qual__module_qualify_items(item_list, item_list,
- module_name, bool, mq_info, int, bool, bool,
- io__state, io__state).
-:- mode module_qual__module_qualify_items(in, out, in, in,
- out, out, out, out, di, uo) is det.
+:- 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), list(mode),
- prog_context, mq_info, mq_info,
- io__state, io__state) is det.
-:- mode module_qual__qualify_lambda_mode_list(in, out,
- in, in, out, di, uo) is det.
+:- 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), list(mode),
- prog_context, mq_info, mq_info,
- io__state, io__state) is det.
-:- mode module_qual__qualify_clause_mode_list(in, out,
- in, in, out, di, uo) is det.
+:- 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, type, prog_context,
- mq_info, mq_info, io__state, io__state).
-:- mode module_qual__qualify_type_qualification(in, out, in, in,
- out, di, uo) is det.
+:- 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.
@@ -69,15 +59,16 @@
:- pred mq_info_get_num_errors(mq_info::in, int::out) is det.
:- pred mq_info_get_type_error_flag(mq_info::in, bool::out) is det.
:- pred mq_info_get_mode_error_flag(mq_info::in, bool::out) is det.
-:- pred mq_info_set_need_qual_flag(mq_info::in,
- need_qualifier::in, mq_info::out) is det.
:- pred mq_info_get_need_qual_flag(mq_info::in, need_qualifier::out) is det.
:- pred mq_info_get_partial_qualifier_info(mq_info::in,
- partial_qualifier_info::out) is det.
+ partial_qualifier_info::out) is det.
:- pred mq_info_get_recompilation_info(mq_info::in,
- maybe(recompilation_info)::out) is det.
-:- pred mq_info_set_recompilation_info(mq_info::in,
- maybe(recompilation_info)::in, mq_info::out) is det.
+ maybe(recompilation_info)::out) is det.
+
+:- pred mq_info_set_need_qual_flag(need_qualifier::in,
+ mq_info::in, mq_info::out) is det.
+:- pred mq_info_set_recompilation_info(maybe(recompilation_info)::in,
+ mq_info::in, mq_info::out) is det.
% The type partial_qualifier_info holds info need for computing which
% partial quantifiers are visible -- see get_partial_qualifiers/3.
@@ -107,102 +98,106 @@
% Note that the caller will still need to handle the fully-qualified
% and fully-unqualified versions separately.
-:- pred get_partial_qualifiers(module_name, partial_qualifier_info,
- list(module_name)).
-:- mode get_partial_qualifiers(in, in, out) is det.
+:- pred get_partial_qualifiers(module_name::in, partial_qualifier_info::in,
+ list(module_name)::out) is det.
%-----------------------------------------------------------------------------%
:- implementation.
-:- import_module libs__globals.
-:- import_module libs__options.
-:- import_module parse_tree__mercury_to_mercury.
-:- import_module parse_tree__modules.
-:- import_module parse_tree__prog_io.
-:- import_module parse_tree__prog_out.
-:- import_module parse_tree__prog_util.
-:- import_module parse_tree__prog_type.
+:- import_module libs.globals.
+:- import_module libs.options.
+:- import_module parse_tree.error_util.
+:- import_module parse_tree.mercury_to_mercury.
+:- import_module parse_tree.modules.
+:- import_module parse_tree.prog_io.
+:- import_module parse_tree.prog_out.
+:- import_module parse_tree.prog_util.
+:- import_module parse_tree.prog_type.
:- import_module int, map, require, set, string, term, varset.
:- import_module assoc_list.
-module_qual__module_qualify_items(Items0, Items, ModuleName, ReportErrors,
- Info, NumErrors, UndefTypes, UndefModes) -->
- globals__io_get_globals(Globals),
- { init_mq_info(Items0, Globals, ReportErrors, ModuleName, Info0) },
- { collect_mq_info(Items0, Info0, Info1) },
- do_module_qualify_items(Items0, Items, Info1, Info),
- { mq_info_get_type_error_flag(Info, UndefTypes) },
- { mq_info_get_mode_error_flag(Info, UndefModes) },
- ( { ReportErrors = yes } ->
- { mq_info_get_unused_interface_modules(Info, UnusedImports0) },
- { set__to_sorted_list(UnusedImports0, UnusedImports) },
- maybe_warn_unused_interface_imports(ModuleName, UnusedImports)
+module_qual.module_qualify_items(Items0, Items, ModuleName, ReportErrors,
+ Info, NumErrors, UndefTypes, UndefModes, !IO) :-
+ globals.io_get_globals(Globals, !IO),
+ init_mq_info(Items0, Globals, ReportErrors, ModuleName, Info0),
+ collect_mq_info(Items0, Info0, Info1),
+ do_module_qualify_items(Items0, Items, Info1, Info, !IO),
+ mq_info_get_type_error_flag(Info, UndefTypes),
+ mq_info_get_mode_error_flag(Info, UndefModes),
+ (
+ ReportErrors = yes,
+ mq_info_get_unused_interface_modules(Info, UnusedImports0),
+ set.to_sorted_list(UnusedImports0, UnusedImports),
+ maybe_warn_unused_interface_imports(ModuleName, UnusedImports,
+ !IO)
;
- []
+ ReportErrors = no
),
- { mq_info_get_num_errors(Info, NumErrors) }.
+ mq_info_get_num_errors(Info, NumErrors).
+
+module_qual.qualify_lambda_mode_list(Modes0, Modes, Context, !Info, !IO) :-
+ mq_info_set_error_context(lambda_expr - Context, !Info),
+ qualify_mode_list(Modes0, Modes, !Info, !IO).
+
+module_qual.qualify_clause_mode_list(Modes0, Modes, Context, !Info, !IO) :-
+ mq_info_set_error_context(clause_mode_annotation - Context, !Info),
+ qualify_mode_list(Modes0, Modes, !Info, !IO).
+
+module_qual.qualify_type_qualification(Type0, Type, Context, !Info, !IO) :-
+ mq_info_set_error_context(type_qual - Context, !Info),
+ qualify_type(Type0, Type, !Info, !IO).
+
+:- type mq_info --->
+ mq_info(
+ % Modules which have been imported or used, i.e. the ones
+ % for which there was a `:- import_module' or `:- use_module'
+ % declaration in this module.
+ imported_modules :: set(module_name),
+
+ % Modules which have been imported or used in the interface.
+ interface_visible_modules :: set(module_name),
+
+ % Sets of all modules, types, insts, modes, and typeclasses
+ % visible in this module. Impl_types is the set of all types
+ % visible from the implementation of the module.
+ modules :: module_id_set,
+ types :: type_id_set,
+ impl_types :: type_id_set,
+ insts :: inst_id_set,
+ modes :: mode_id_set,
+ classes :: class_id_set,
+
+
+ % Modules imported in the interface that are not definitely
+ % needed in the interface.
+ unused_interface_modules :: set(module_name),
+
+ % Import status of the current item.
+ import_status :: import_status,
-module_qual__qualify_lambda_mode_list(Modes0, Modes, Context, Info0, Info) -->
- { mq_info_set_error_context(Info0, lambda_expr - Context, Info1) },
- qualify_mode_list(Modes0, Modes, Info1, Info).
-
-module_qual__qualify_clause_mode_list(Modes0, Modes, Context, Info0, Info) -->
- { mq_info_set_error_context(Info0, clause_mode_annotation - Context,
- Info1) },
- qualify_mode_list(Modes0, Modes, Info1, Info).
-
-module_qual__qualify_type_qualification(Type0, Type, Context, Info0, Info) -->
- { mq_info_set_error_context(Info0, type_qual - Context, Info1) },
- qualify_type(Type0, Type, Info1, Info).
-
-:- type mq_info
- ---> mq_info(
- % Modules which have been imported or used,
- % i.e. ones for which there was a
- % `:- import_module' or `:- use_module'
- % declaration in this module.
- imported_modules::set(module_name),
- % Modules which have been imported or used
- % in the interface.
- interface_visible_modules::set(module_name),
-
- % Sets of all modules, types, insts, modes,
- % and typeclasses visible in this module.
- % impl_types is the set of all types visible
- % from the implementation of the module.
- modules::module_id_set,
- types::type_id_set,
- impl_types::type_id_set,
- insts::inst_id_set,
- modes::mode_id_set,
- classes::class_id_set,
-
-
- unused_interface_modules::set(module_name),
- % modules imported in the
- % interface that are not definitely
- % needed in the interface.
-
- % import status of the current item.
- import_status::import_status,
-
- num_errors::int,% number of errors found.
-
- % are there any undefined types or typeclasses.
- type_error_flag::bool,
- % are there any undefined insts or modes.
- mode_error_flag::bool,
- % do we want to report errors.
- report_error_flag::bool,
- % context of the current item.
- error_context::error_context,
- % name of the current module
- this_module::module_name,
- % must uses of the current item be
- % explicitly module qualified.
- need_qual_flag::need_qualifier,
- maybe_recompilation_info::maybe(recompilation_info)
+ % The number of errors found.
+ num_errors :: int,
+
+ % Are there any undefined types or typeclasses.
+ type_error_flag :: bool,
+
+ % Are there any undefined insts or modes.
+ mode_error_flag :: bool,
+
+ % Do we want to report errors.
+ report_error_flag :: bool,
+
+ % The context of the current item.
+ error_context :: error_context,
+
+ % The name of the current module
+ this_module :: module_name,
+
+ % Must uses of the current item be explicitly module qualified.
+ need_qual_flag :: need_qualifier,
+
+ maybe_recompilation_info :: maybe(recompilation_info)
).
:- type partial_qualifier_info --->
@@ -213,7 +208,7 @@
QualifierInfo = partial_qualifier_info(ModuleIdSet).
% 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.
+ % so we use a simpler data type here than hlds_pred.import_status.
:- type import_status
---> exported
; local
@@ -225,103 +220,102 @@
% modules imported in the interface.
:- pred collect_mq_info(item_list::in, mq_info::in, mq_info::out) is det.
-collect_mq_info([], Info, Info).
-collect_mq_info([Item - _ | Items], Info0, Info) :-
+collect_mq_info([], !Info).
+collect_mq_info([Item - _ | Items], !Info) :-
( Item = module_defn(_, transitively_imported) ->
% Don't process the transitively imported items (from `.int2'
% files). They can't be used in the current module.
- Info = Info0
+ true
;
- collect_mq_info_2(Item, Info0, Info1),
- collect_mq_info(Items, Info1, Info)
+ collect_mq_info_2(Item, !Info),
+ collect_mq_info(Items, !Info)
).
:- pred collect_mq_info_2(item::in, mq_info::in, mq_info::out) is det.
-collect_mq_info_2(clause(_,_,_,_,_), Info, Info).
-collect_mq_info_2(type_defn(_, SymName, Params, _, _), Info0, Info) :-
+collect_mq_info_2(clause(_, _, _, _, _), !Info).
+collect_mq_info_2(type_defn(_, SymName, Params, _, _), !Info) :-
% This item is not visible in the current module.
- ( mq_info_get_import_status(Info0, abstract_imported) ->
- Info = Info0
+ ( mq_info_get_import_status(!.Info, abstract_imported) ->
+ true
;
- list__length(Params, Arity),
- mq_info_get_types(Info0, Types0),
- mq_info_get_impl_types(Info0, ImplTypes0),
- mq_info_get_need_qual_flag(Info0, NeedQualifier),
+ list.length(Params, Arity),
+ mq_info_get_types(!.Info, Types0),
+ mq_info_get_impl_types(!.Info, ImplTypes0),
+ mq_info_get_need_qual_flag(!.Info, NeedQualifier),
id_set_insert(NeedQualifier, SymName - Arity, Types0, Types),
id_set_insert(NeedQualifier, SymName - Arity,
ImplTypes0, ImplTypes),
- mq_info_set_types(Info0, Types, Info1),
- mq_info_set_impl_types(Info1, ImplTypes, Info)
+ mq_info_set_types(Types, !Info),
+ mq_info_set_impl_types(ImplTypes, !Info)
).
-collect_mq_info_2(inst_defn(_, SymName, Params, _, _), Info0, Info) :-
+collect_mq_info_2(inst_defn(_, SymName, Params, _, _), !Info) :-
% This item is not visible in the current module.
- ( mq_info_get_import_status(Info0, abstract_imported) ->
- Info = Info0
+ ( mq_info_get_import_status(!.Info, abstract_imported) ->
+ true
;
- list__length(Params, Arity),
- mq_info_get_insts(Info0, Insts0),
- mq_info_get_need_qual_flag(Info0, NeedQualifier),
+ list.length(Params, Arity),
+ mq_info_get_insts(!.Info, Insts0),
+ mq_info_get_need_qual_flag(!.Info, NeedQualifier),
id_set_insert(NeedQualifier, SymName - Arity, Insts0, Insts),
- mq_info_set_insts(Info0, Insts, Info)
+ mq_info_set_insts(Insts, !Info)
).
-collect_mq_info_2(mode_defn(_, SymName, Params, _, _), Info0, Info) :-
+collect_mq_info_2(mode_defn(_, SymName, Params, _, _), !Info) :-
% This item is not visible in the current module.
- ( mq_info_get_import_status(Info0, abstract_imported) ->
- Info = Info0
+ ( mq_info_get_import_status(!.Info, abstract_imported) ->
+ true
;
- list__length(Params, Arity),
- mq_info_get_modes(Info0, Modes0),
- mq_info_get_need_qual_flag(Info0, NeedQualifier),
+ list.length(Params, Arity),
+ mq_info_get_modes(!.Info, Modes0),
+ mq_info_get_need_qual_flag(!.Info, NeedQualifier),
id_set_insert(NeedQualifier, SymName - Arity, Modes0, Modes),
- mq_info_set_modes(Info0, Modes, Info)
+ mq_info_set_modes(Modes, !Info)
).
-collect_mq_info_2(module_defn(_, ModuleDefn), Info0, Info) :-
- process_module_defn(ModuleDefn, Info0, Info).
-collect_mq_info_2(pred_or_func(_,_,_,_,__,_,_,_,_,_,_,_), Info, Info).
-collect_mq_info_2(pred_or_func_mode(_,_,_,_,_,_,_), Info, Info).
-collect_mq_info_2(pragma(_), Info, Info).
-collect_mq_info_2(promise(_PromiseType, Goal, _ProgVarSet, _UnivVars), Info0,
- Info) :-
+collect_mq_info_2(module_defn(_, ModuleDefn), !Info) :-
+ process_module_defn(ModuleDefn, !Info).
+collect_mq_info_2(pred_or_func(_, _, _, _, _, _, _, _, _, _, _, _), !Info).
+collect_mq_info_2(pred_or_func_mode(_, _, _, _, _, _, _), !Info).
+collect_mq_info_2(pragma(_), !Info).
+collect_mq_info_2(promise(_PromiseType, Goal, _ProgVarSet, _UnivVars),
+ !Info) :-
process_assert(Goal, SymNames, Success),
(
Success = yes,
- list__foldl((pred(SymName::in, I0::in, I::out) is det :-
- (
- SymName = qualified(ModuleName, _)
- ->
- mq_info_set_module_used(I0,
- ModuleName, I)
- ;
- error("collect_mq_info_2: SymName not qualified.")
- )
- ),
- SymNames, Info0, Info)
+ list.foldl(collect_mq_info_qualified_symname, SymNames, !Info)
;
- % Any unqualified symbol in the promise might
- % come from *any* of the imported modules.
- % There's no way for us to tell which ones. So
- % we conservatively assume that it uses all of
- % them.
+ % Any unqualified symbol in the promise might come
+ % from *any* of the imported modules. There's no way
+ % for us to tell which ones. So we conservatively
+ % assume that it uses all of them.
Success = no,
- set__init(UnusedInterfaceModules),
- mq_info_set_unused_interface_modules(Info0,
- UnusedInterfaceModules, Info)
+ set.init(UnusedInterfaceModules),
+ mq_info_set_unused_interface_modules(UnusedInterfaceModules,
+ !Info)
).
-collect_mq_info_2(nothing(_), Info, Info).
-collect_mq_info_2(typeclass(_, SymName, Params, _, _), Info0, Info) :-
+collect_mq_info_2(nothing(_), !Info).
+collect_mq_info_2(typeclass(_, SymName, Params, _, _), !Info) :-
% This item is not visible in the current module.
- ( mq_info_get_import_status(Info0, abstract_imported) ->
- Info = Info0
+ ( mq_info_get_import_status(!.Info, abstract_imported) ->
+ true
+ ;
+ list.length(Params, Arity),
+ mq_info_get_classes(!.Info, Classes0),
+ mq_info_get_need_qual_flag(!.Info, NeedQualifier),
+ id_set_insert(NeedQualifier, SymName - Arity,
+ Classes0, Classes),
+ mq_info_set_classes(Classes, !Info)
+ ).
+collect_mq_info_2(instance(_, _, _, _, _, _), !Info).
+
+:- pred collect_mq_info_qualified_symname(sym_name::in,
+ mq_info::in, mq_info::out) is det.
+
+collect_mq_info_qualified_symname(SymName, !Info) :-
+ ( SymName = qualified(ModuleName, _) ->
+ mq_info_set_module_used(ModuleName, !Info)
;
- list__length(Params, Arity),
- mq_info_get_classes(Info0, Classes0),
- mq_info_get_need_qual_flag(Info0, NeedQualifier),
- id_set_insert(NeedQualifier,
- SymName - Arity, Classes0, Classes),
- mq_info_set_classes(Info0, Classes, Info)
+ error("collect_mq_info_qualified_symname: not qualified.")
).
-collect_mq_info_2(instance(_,_,_,_,_,_), Info, Info).
% process_module_defn:
%
@@ -337,48 +331,47 @@
:- pred process_module_defn(module_defn::in, mq_info::in, mq_info::out) is det.
-process_module_defn(module(ModuleName), Info0, Info) :-
- add_module_defn(ModuleName, Info0, Info).
-process_module_defn(include_module(ModuleNameList), Info0, Info) :-
- list__foldl(add_module_defn, ModuleNameList, Info0, Info).
-process_module_defn(interface, Info0, Info) :-
- mq_info_set_import_status(Info0, exported, Info).
-process_module_defn(private_interface, Info0, Info) :-
- mq_info_set_import_status(Info0, local, Info).
-process_module_defn(implementation, Info0, Info) :-
- mq_info_set_import_status(Info0, local, Info).
-process_module_defn(imported(Locn), Info0, Info) :-
- mq_info_set_import_status(Info0, imported(Locn), Info1),
- mq_info_set_need_qual_flag(Info1, may_be_unqualified, Info).
-process_module_defn(used(Locn), Info0, Info) :-
- mq_info_set_import_status(Info0, imported(Locn), Info1),
- mq_info_set_need_qual_flag(Info1, must_be_qualified, Info).
-process_module_defn(opt_imported, Info0, Info) :-
- mq_info_set_import_status(Info0, imported(implementation), Info1),
- mq_info_set_need_qual_flag(Info1, must_be_qualified, Info).
-process_module_defn(abstract_imported, Info0, Info) :-
- mq_info_set_import_status(Info0, abstract_imported, Info1),
- mq_info_set_need_qual_flag(Info1, must_be_qualified, Info).
-process_module_defn(transitively_imported, _, _) :-
+process_module_defn(module(ModuleName), !Info) :-
+ add_module_defn(ModuleName, !Info).
+process_module_defn(include_module(ModuleNameList), !Info) :-
+ list.foldl(add_module_defn, ModuleNameList, !Info).
+process_module_defn(interface, !Info) :-
+ mq_info_set_import_status(exported, !Info).
+process_module_defn(private_interface, !Info) :-
+ mq_info_set_import_status(local, !Info).
+process_module_defn(implementation, !Info) :-
+ mq_info_set_import_status(local, !Info).
+process_module_defn(imported(Locn), !Info) :-
+ mq_info_set_import_status(imported(Locn), !Info),
+ mq_info_set_need_qual_flag(may_be_unqualified, !Info).
+process_module_defn(used(Locn), !Info) :-
+ mq_info_set_import_status(imported(Locn), !Info),
+ mq_info_set_need_qual_flag(must_be_qualified, !Info).
+process_module_defn(opt_imported, !Info) :-
+ mq_info_set_import_status(imported(implementation), !Info),
+ mq_info_set_need_qual_flag(must_be_qualified, !Info).
+process_module_defn(abstract_imported, !Info) :-
+ 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").
-process_module_defn(external(_, _), Info, Info).
-process_module_defn(end_module(_), Info, Info).
-process_module_defn(export(_), Info, Info).
-process_module_defn(import(Imports), Info0, Info) :-
- add_imports(Imports, Info0, Info).
-process_module_defn(use(Imports), Info0, Info) :-
- add_imports(Imports, Info0, Info).
-process_module_defn(version_numbers(_, _), Info, Info).
-
-:- pred add_module_defn(module_name, mq_info, mq_info).
-:- mode add_module_defn(in, in, out) is det.
-
-add_module_defn(ModuleName, Info0, Info) :-
- mq_info_get_modules(Info0, Modules0),
- mq_info_get_need_qual_flag(Info0, NeedQualifier),
+process_module_defn(external(_, _), !Info).
+process_module_defn(end_module(_), !Info).
+process_module_defn(export(_), !Info).
+process_module_defn(import(Imports), !Info) :-
+ add_imports(Imports, !Info).
+process_module_defn(use(Imports), !Info) :-
+ add_imports(Imports, !Info).
+process_module_defn(version_numbers(_, _), !Info).
+
+:- pred add_module_defn(module_name::in, mq_info::in, mq_info::out) is det.
+
+add_module_defn(ModuleName, !Info) :-
+ mq_info_get_modules(!.Info, Modules0),
+ mq_info_get_need_qual_flag(!.Info, NeedQualifier),
Arity = 0,
id_set_insert(NeedQualifier, ModuleName - Arity, Modules0, Modules),
- mq_info_set_modules(Info0, Modules, Info).
+ mq_info_set_modules(Modules, !Info).
:- pred add_imports(sym_list::in, mq_info::in, mq_info::out) is det.
@@ -406,8 +399,8 @@
)
->
mq_info_get_imported_modules(!.Info, Modules0),
- set__insert_list(Modules0, Imports, Modules),
- mq_info_set_imported_modules(!.Info, Modules, !:Info)
+ set.insert_list(Modules0, Imports, Modules),
+ mq_info_set_imported_modules(Modules, !Info)
;
true
),
@@ -421,11 +414,10 @@
->
mq_info_get_unused_interface_modules(!.Info,
UnusedIntModules0),
- set__insert_list(UnusedIntModules0, Imports, UnusedIntModules),
- mq_info_set_unused_interface_modules(!.Info,
- UnusedIntModules, !:Info)
+ set.insert_list(UnusedIntModules0, Imports, UnusedIntModules),
+ mq_info_set_unused_interface_modules(UnusedIntModules, !Info)
;
- true
+ true
),
%
@@ -438,9 +430,8 @@
)
->
mq_info_get_interface_visible_modules(!.Info, IntModules0),
- set__insert_list(IntModules0, Imports, IntModules),
- mq_info_set_interface_visible_modules(!.Info,
- IntModules, !:Info)
+ set.insert_list(IntModules0, Imports, IntModules),
+ mq_info_set_interface_visible_modules(IntModules, !Info)
;
true
).
@@ -462,19 +453,19 @@
process_assert((GA , GB) - _, Symbols, Success) :-
process_assert(GA, SymbolsA, SuccessA),
process_assert(GB, SymbolsB, SuccessB),
- list__append(SymbolsA, SymbolsB, Symbols),
- bool__and(SuccessA, SuccessB, Success).
+ list.append(SymbolsA, SymbolsB, Symbols),
+ bool.and(SuccessA, SuccessB, Success).
process_assert(true - _, [], yes).
process_assert((GA & GB) - _, Symbols, Success) :-
process_assert(GA, SymbolsA, SuccessA),
process_assert(GB, SymbolsB, SuccessB),
- list__append(SymbolsA, SymbolsB, Symbols),
- bool__and(SuccessA, SuccessB, Success).
+ list.append(SymbolsA, SymbolsB, Symbols),
+ bool.and(SuccessA, SuccessB, Success).
process_assert((GA ; GB) - _, Symbols, Success) :-
process_assert(GA, SymbolsA, SuccessA),
process_assert(GB, SymbolsB, SuccessB),
- list__append(SymbolsA, SymbolsB, Symbols),
- bool__and(SuccessA, SuccessB, Success).
+ list.append(SymbolsA, SymbolsB, Symbols),
+ bool.and(SuccessA, SuccessB, Success).
process_assert(fail - _, [], yes).
process_assert(some(_, G) - _, Symbols, Success) :-
process_assert(G, Symbols, Success).
@@ -487,33 +478,33 @@
process_assert(implies(GA, GB) - _, Symbols, Success) :-
process_assert(GA, SymbolsA, SuccessA),
process_assert(GB, SymbolsB, SuccessB),
- list__append(SymbolsA, SymbolsB, Symbols),
- bool__and(SuccessA, SuccessB, Success).
+ list.append(SymbolsA, SymbolsB, Symbols),
+ bool.and(SuccessA, SuccessB, Success).
process_assert(equivalent(GA, GB) - _, Symbols, Success) :-
process_assert(GA, SymbolsA, SuccessA),
process_assert(GB, SymbolsB, SuccessB),
- list__append(SymbolsA, SymbolsB, Symbols),
- bool__and(SuccessA, SuccessB, Success).
+ list.append(SymbolsA, SymbolsB, Symbols),
+ bool.and(SuccessA, SuccessB, Success).
process_assert(not(G) - _, Symbols, Success) :-
process_assert(G, Symbols, Success).
process_assert(if_then(_, _, GA, GB) - _, Symbols, Success) :-
process_assert(GA, SymbolsA, SuccessA),
process_assert(GB, SymbolsB, SuccessB),
- list__append(SymbolsA, SymbolsB, Symbols),
- bool__and(SuccessA, SuccessB, Success).
+ list.append(SymbolsA, SymbolsB, Symbols),
+ bool.and(SuccessA, SuccessB, Success).
process_assert(if_then_else(_, _, GA, GB, GC) - _, Symbols, Success) :-
process_assert(GA, SymbolsA, SuccessA),
process_assert(GB, SymbolsB, SuccessB),
process_assert(GC, SymbolsC, SuccessC),
- list__append(SymbolsA, SymbolsB, Symbols0),
- list__append(Symbols0, SymbolsC, Symbols),
- bool__and(SuccessA, SuccessB, Success0),
- bool__and(Success0, SuccessC, Success).
+ list.append(SymbolsA, SymbolsB, Symbols0),
+ list.append(Symbols0, SymbolsC, Symbols),
+ bool.and(SuccessA, SuccessB, Success0),
+ bool.and(Success0, SuccessC, Success).
process_assert(call(SymName, Args0, _Purity) - _, Symbols, Success) :-
(
SymName = qualified(_, _)
->
- list__map(term__coerce, Args0, Args),
+ list.map(term.coerce, Args0, Args),
(
term_qualified_symbols_list(Args, Symbols0)
->
@@ -528,13 +519,13 @@
Success = no
).
process_assert(unify(LHS0, RHS0, _Purity) - _, Symbols, Success) :-
- term__coerce(LHS0, LHS),
- term__coerce(RHS0, RHS),
+ term.coerce(LHS0, LHS),
+ term.coerce(RHS0, RHS),
(
term_qualified_symbols(LHS, SymbolsL),
term_qualified_symbols(RHS, SymbolsR)
->
- list__append(SymbolsL, SymbolsR, Symbols),
+ list.append(SymbolsL, SymbolsR, Symbols),
Success = yes
;
Symbols = [],
@@ -549,9 +540,7 @@
:- pred term_qualified_symbols(term::in, list(sym_name)::out) is semidet.
term_qualified_symbols(Term, Symbols) :-
- (
- sym_name_and_args(Term, SymName, Args)
- ->
+ ( sym_name_and_args(Term, SymName, Args) ->
SymName = qualified(_, _),
term_qualified_symbols_list(Args, Symbols0),
Symbols = [SymName | Symbols0]
@@ -559,15 +548,15 @@
Symbols = []
).
-:- pred term_qualified_symbols_list(list(term)::in,
- list(sym_name)::out) is semidet.
+:- pred term_qualified_symbols_list(list(term)::in, list(sym_name)::out)
+ is semidet.
% Yeah one more place where accumulators will be introduced!
term_qualified_symbols_list([], []).
term_qualified_symbols_list([Term | Terms], Symbols) :-
term_qualified_symbols(Term, TermSymbols),
term_qualified_symbols_list(Terms, Symbols0),
- list__append(Symbols0, TermSymbols, Symbols).
+ list.append(Symbols0, TermSymbols, Symbols).
%------------------------------------------------------------------------------
@@ -576,108 +565,102 @@
% 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__state::di, io__state::uo) is det.
+ mq_info::in, mq_info::out, io::di, io::uo) is det.
-do_module_qualify_items([], [], Info, Info) --> [].
-do_module_qualify_items([Item0 | Items0], [Item | Items], Info0, Info) -->
- module_qualify_item(Item0, Item, Info0, Info1, Continue),
- ( { Continue = yes } ->
- do_module_qualify_items(Items0, Items, Info1, Info)
+do_module_qualify_items([], [], !Info, !IO).
+do_module_qualify_items([Item0 | Items0], [Item | Items], !Info, !IO) :-
+ module_qualify_item(Item0, Item, !Info, Continue, !IO),
+ (
+ Continue = yes,
+ do_module_qualify_items(Items0, Items, !Info, !IO)
;
- { Items = Items0 },
- { Info = Info1 }
+ Continue = no,
+ Items = Items0
).
% 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__state::di, io__state::uo) is det.
+ 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, Info, yes) --> [].
+ !Info, yes, !IO).
module_qualify_item(
type_defn(TVarSet, SymName, Params, TypeDefn0, C) - Context,
type_defn(TVarSet, SymName, Params, TypeDefn, C) - Context,
- Info0, Info, yes) -->
- { list__length(Params, Arity) },
- { mq_info_set_error_context(Info0,
- type(SymName - Arity) - Context, Info1) },
- qualify_type_defn(TypeDefn0, TypeDefn, Info1, Info).
+ !Info, yes, !IO) :-
+ list.length(Params, Arity),
+ mq_info_set_error_context(type(SymName - Arity) - Context, !Info),
+ qualify_type_defn(TypeDefn0, TypeDefn, !Info, !IO).
module_qualify_item(inst_defn(A, SymName, Params, InstDefn0, C) - Context,
inst_defn(A, SymName, Params, InstDefn, C) - Context,
- Info0, Info, yes) -->
- { list__length(Params, Arity) },
- { mq_info_set_error_context(Info0,
- inst(SymName - Arity) - Context, Info1) },
- qualify_inst_defn(InstDefn0, InstDefn, Info1, Info).
+ !Info, yes, !IO) :-
+ list.length(Params, Arity),
+ mq_info_set_error_context(inst(SymName - Arity) - Context, !Info),
+ qualify_inst_defn(InstDefn0, InstDefn, !Info, !IO).
module_qualify_item(mode_defn(A, SymName, Params, ModeDefn0, C) - Context,
mode_defn(A, SymName, Params, ModeDefn, C) - Context,
- Info0, Info, yes) -->
- { list__length(Params, Arity) },
- { mq_info_set_error_context(Info0,
- mode(SymName - Arity) - Context, Info1) },
- qualify_mode_defn(ModeDefn0, ModeDefn, Info1, Info).
+ !Info, yes, !IO) :-
+ list.length(Params, Arity),
+ mq_info_set_error_context(mode(SymName - Arity) - Context, !Info),
+ qualify_mode_defn(ModeDefn0, ModeDefn, !Info, !IO).
module_qualify_item(module_defn(A, ModuleDefn) - Context,
- module_defn(A, ModuleDefn) - Context, Info0, Info, Continue) -->
- { update_import_status(ModuleDefn, Info0, Info, Continue) }.
+ module_defn(A, ModuleDefn) - Context, !Info, Continue, !IO) :-
+ update_import_status(ModuleDefn, !Info, Continue).
module_qualify_item(
pred_or_func(A, IVs, B, PredOrFunc, SymName, TypesAndModes0,
WithType0, WithInst0, C, D, E, Constraints0) - Context,
pred_or_func(A, IVs, B, PredOrFunc, SymName, TypesAndModes,
WithType, WithInst, C, D, E, Constraints) - Context,
- Info0, Info, yes) -->
- { list__length(TypesAndModes0, Arity) },
- { mq_info_set_error_context(Info0,
- pred_or_func(PredOrFunc, SymName - Arity) - Context,
- Info1) },
- qualify_types_and_modes(TypesAndModes0, TypesAndModes, Info1, Info2),
- qualify_class_constraints(Constraints0, Constraints, Info2, Info3),
- map_fold2_maybe(qualify_type, WithType0, WithType, Info3, Info4),
- map_fold2_maybe(qualify_inst, WithInst0, WithInst, Info4, Info).
+ !Info, yes, !IO) :-
+ list.length(TypesAndModes0, Arity),
+ mq_info_set_error_context(
+ pred_or_func(PredOrFunc, SymName - Arity) - Context, !Info),
+ qualify_types_and_modes(TypesAndModes0, TypesAndModes, !Info, !IO),
+ qualify_class_constraints(Constraints0, Constraints, !Info, !IO),
+ map_fold2_maybe(qualify_type, WithType0, WithType, !Info, !IO),
+ map_fold2_maybe(qualify_inst, WithInst0, WithInst, !Info, !IO).
module_qualify_item(
pred_or_func_mode(A, PredOrFunc, SymName, Modes0,
WithInst0, C, D) - Context,
pred_or_func_mode(A, PredOrFunc, SymName, Modes,
WithInst, C, D) - Context,
- Info0, Info, yes) -->
- { list__length(Modes0, Arity) },
- { mq_info_set_error_context(Info0,
- pred_or_func_mode(PredOrFunc, SymName- Arity) - Context,
- Info1) },
- qualify_mode_list(Modes0, Modes, Info1, Info2),
- map_fold2_maybe(qualify_inst, WithInst0, WithInst, Info2, Info).
+ !Info, yes, !IO) :-
+ list.length(Modes0, Arity),
+ mq_info_set_error_context(
+ pred_or_func_mode(PredOrFunc, SymName - Arity) - Context,
+ !Info),
+ qualify_mode_list(Modes0, Modes, !Info, !IO),
+ map_fold2_maybe(qualify_inst, WithInst0, WithInst, !Info, !IO).
module_qualify_item(pragma(Pragma0) - Context, pragma(Pragma) - Context,
- Info0, Info, yes) -->
- { mq_info_set_error_context(Info0, (pragma) - Context, Info1) },
- qualify_pragma(Pragma0, Pragma, Info1, Info).
+ !Info, yes, !IO) :-
+ mq_info_set_error_context((pragma) - Context, !Info),
+ qualify_pragma(Pragma0, Pragma, !Info, !IO).
module_qualify_item(promise(T, G, V, U) - Context,
- promise(T, G, V, U) - Context, Info, Info, yes) --> [].
+ promise(T, G, V, U) - Context, !Info, yes, !IO).
module_qualify_item(nothing(A) - Context, nothing(A) - Context,
- Info, Info, yes) --> [].
+ !Info, yes, !IO).
module_qualify_item(typeclass(Constraints0, Name, Vars, Interface0, VarSet) -
Context,
typeclass(Constraints, Name, Vars, Interface, VarSet) -
Context,
- Info0, Info, yes) -->
- { list__length(Vars, Arity) },
- { Id = Name - Arity },
- { mq_info_set_error_context(Info0, class(Id) - Context, Info1) },
- qualify_class_constraint_list(Constraints0, Constraints, Info1, Info2),
- (
- { Interface0 = abstract },
- { Interface = abstract },
- { Info = Info2 }
- ;
- { Interface0 = concrete(Methods0) },
- qualify_class_interface(Methods0, Methods, Info2, Info),
- { Interface = concrete(Methods) }
+ !Info, yes, !IO) :-
+ list.length(Vars, Arity),
+ mq_info_set_error_context(class(Name - Arity) - Context, !Info),
+ qualify_class_constraint_list(Constraints0, Constraints, !Info, !IO),
+ (
+ Interface0 = abstract,
+ Interface = abstract
+ ;
+ Interface0 = concrete(Methods0),
+ qualify_class_interface(Methods0, Methods, !Info, !IO),
+ Interface = concrete(Methods)
).
module_qualify_item(
@@ -685,284 +668,276 @@
ModName) - Context,
instance(Constraints, Name, Types, Body, VarSet,
ModName) - Context,
- Info0, Info, yes) -->
- { list__length(Types0, Arity) },
- { Id = Name0 - Arity },
- { mq_info_set_error_context(Info0, instance(Id) - Context, Info1) },
+ !Info, yes, !IO) :-
+ 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_class_constraint_list(Constraints0, Constraints, Info1, Info2),
- qualify_class_name(Id, Name - _, Info2, Info3),
- qualify_type_list(Types0, Types, Info3, Info),
- { qualify_instance_body(Name, Body0, Body) }.
+ qualify_class_constraint_list(Constraints0, Constraints, !Info, !IO),
+ qualify_class_name(Id, Name - _, !Info, !IO),
+ qualify_type_list(Types0, Types, !Info, !IO),
+ qualify_instance_body(Name, Body0, Body).
:- pred update_import_status(module_defn::in, mq_info::in, mq_info::out,
- bool::out) is det.
+ bool::out) is det.
-update_import_status(opt_imported, Info, Info, no).
-update_import_status(abstract_imported, Info0, Info, yes) :-
- mq_info_set_import_status(Info0, abstract_imported, Info).
-update_import_status(transitively_imported, Info, Info, no).
-update_import_status(module(_), Info, Info, yes).
-update_import_status(interface, Info0, Info, yes) :-
- mq_info_set_import_status(Info0, exported, Info).
-update_import_status(implementation, Info0, Info, yes) :-
- mq_info_set_import_status(Info0, local, Info).
-update_import_status(private_interface, Info0, Info, yes) :-
- mq_info_set_import_status(Info0, local, Info).
-update_import_status(imported(_), Info, Info, no).
-update_import_status(used(_), Info, Info, no).
-update_import_status(external(_, _), Info, Info, yes).
-update_import_status(end_module(_), Info, Info, yes).
-update_import_status(export(_), Info, Info, yes).
-update_import_status(import(_), Info, Info, yes).
-update_import_status(use(_), Info, Info, yes).
-update_import_status(version_numbers(_, _), Info, Info, yes).
-update_import_status(include_module(_), Info0, Info, yes) :-
+update_import_status(opt_imported, !Info, no).
+update_import_status(abstract_imported, !Info, yes) :-
+ mq_info_set_import_status(abstract_imported, !Info).
+update_import_status(transitively_imported, !Info, no).
+update_import_status(module(_), !Info, yes).
+update_import_status(interface, !Info, yes) :-
+ mq_info_set_import_status(exported, !Info).
+update_import_status(implementation, !Info, yes) :-
+ mq_info_set_import_status(local, !Info).
+update_import_status(private_interface, !Info, yes) :-
+ mq_info_set_import_status(local, !Info).
+update_import_status(imported(_), !Info, no).
+update_import_status(used(_), !Info, no).
+update_import_status(external(_, _), !Info, yes).
+update_import_status(end_module(_), !Info, yes).
+update_import_status(export(_), !Info, yes).
+update_import_status(import(_), !Info, yes).
+update_import_status(use(_), !Info, yes).
+update_import_status(version_numbers(_, _), !Info, yes).
+update_import_status(include_module(_), !Info, yes) :-
% The sub-module might make use of *any* of the imported modules.
% There's no way for us to tell which ones.
% So we conservatively assume that it uses all of them.
- set__init(UnusedInterfaceModules),
- mq_info_set_unused_interface_modules(Info0, UnusedInterfaceModules,
- Info).
+ set.init(UnusedInterfaceModules),
+ 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__state::di, io__state::uo) is det.
+:- pred qualify_type_defn(type_defn::in, type_defn::out,
+ mq_info::in, mq_info::out, io::di, io::uo) is det.
qualify_type_defn(du_type(Ctors0, MaybeUserEqComp0),
du_type(Ctors, MaybeUserEqComp),
- Info0, Info, !IO) :-
- qualify_constructors(Ctors0, Ctors, Info0, Info, !IO),
+ !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), Info0, Info, !IO) :-
- qualify_type(Type0, Type, Info0, Info, !IO).
-qualify_type_defn(abstract_type(_) @ Defn, Defn, Info, Info, !IO).
-qualify_type_defn(foreign_type(_, _, _) @ Defn, Defn, Info, Info, !IO).
+qualify_type_defn(eqv_type(Type0), eqv_type(Type), !Info, !IO) :-
+ qualify_type(Type0, Type, !Info, !IO).
+qualify_type_defn(abstract_type(_) @ Defn, Defn, !Info, !IO).
+qualify_type_defn(foreign_type(_, _, _) @ Defn, Defn, !Info, !IO).
qualify_type_defn(solver_type(SolverTypeDetails0, MaybeUserEqComp),
solver_type(SolverTypeDetails, MaybeUserEqComp),
- Info0, Info, !IO) :-
+ !Info, !IO) :-
SolverTypeDetails0 = solver_type_details(RepnType0, InitPred,
- GroundInst0, AnyInst0),
- qualify_type(RepnType0, RepnType, Info0, Info1, !IO),
- qualify_inst(GroundInst0, GroundInst, Info1, Info2, !IO),
- qualify_inst(AnyInst0, AnyInst, Info2, Info, !IO),
+ GroundInst0, AnyInst0),
+ qualify_type(RepnType0, RepnType, !Info, !IO),
+ qualify_inst(GroundInst0, GroundInst, !Info, !IO),
+ qualify_inst(AnyInst0, AnyInst, !Info, !IO),
SolverTypeDetails = solver_type_details(RepnType, InitPred,
- GroundInst, AnyInst).
+ GroundInst, AnyInst).
:- pred qualify_constructors(list(constructor)::in, list(constructor)::out,
- mq_info::in, mq_info::out, io__state::di, io__state::uo) is det.
+ mq_info::in, mq_info::out, io::di, io::uo) is det.
-qualify_constructors([], [], Info, Info) --> [].
-qualify_constructors([Ctor0 | Ctors0], [Ctor | Ctors], Info0, Info) -->
- { Ctor0 = ctor(ExistQVars, Constraints0, SymName, Args0) },
- { Ctor = ctor(ExistQVars, Constraints, SymName, Args) },
- qualify_constructor_arg_list(Args0, Args, Info0, Info1),
- qualify_constructors(Ctors0, Ctors, Info1, Info2),
- qualify_class_constraint_list(Constraints0, Constraints, Info2, Info).
+qualify_constructors([], [], !Info, !IO).
+qualify_constructors([Ctor0 | Ctors0], [Ctor | Ctors], !Info, !IO) :-
+ Ctor0 = ctor(ExistQVars, Constraints0, SymName, Args0),
+ qualify_constructor_arg_list(Args0, Args, !Info, !IO),
+ qualify_constructors(Ctors0, Ctors, !Info, !IO),
+ qualify_class_constraint_list(Constraints0, Constraints, !Info, !IO),
+ 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__state::di, io__state::uo) is det.
+:- pred qualify_inst_defn(inst_defn::in, inst_defn::out,
+ mq_info::in, mq_info::out, io::di, io::uo) is det.
-qualify_inst_defn(eqv_inst(Inst0), eqv_inst(Inst), Info0, Info) -->
- qualify_inst(Inst0, Inst, Info0, Info).
-qualify_inst_defn(abstract_inst, abstract_inst, Info, Info) --> [].
+qualify_inst_defn(eqv_inst(Inst0), eqv_inst(Inst), !Info, !IO) :-
+ qualify_inst(Inst0, Inst, !Info, !IO).
+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__state::di, io__state::uo) is det.
+:- pred qualify_mode_defn(mode_defn::in, mode_defn::out,
+ mq_info::in, mq_info::out, io::di, io::uo) is det.
-qualify_mode_defn(eqv_mode(Mode0), eqv_mode(Mode), Info0, Info) -->
- qualify_mode(Mode0, Mode, Info0, Info).
+qualify_mode_defn(eqv_mode(Mode0), eqv_mode(Mode), !Info, !IO) :-
+ qualify_mode(Mode0, Mode, !Info, !IO).
% 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__state::di, io__state::uo) is det.
+ list(type_and_mode)::out, mq_info::in, mq_info::out,
+ io::di, io::uo) is det.
-qualify_types_and_modes([], [], Info, Info) --> [].
+qualify_types_and_modes([], [], !Info, !IO).
qualify_types_and_modes([TypeAndMode0 | TypesAndModes0],
- [TypeAndMode | TypesAndModes], Info0, Info) -->
- qualify_type_and_mode(TypeAndMode0, TypeAndMode, Info0, Info1),
- qualify_types_and_modes(TypesAndModes0, TypesAndModes, Info1, Info).
+ [TypeAndMode | TypesAndModes], !Info, !IO) :-
+ qualify_type_and_mode(TypeAndMode0, TypeAndMode, !Info, !IO),
+ qualify_types_and_modes(TypesAndModes0, TypesAndModes, !Info, !IO).
:- pred qualify_type_and_mode(type_and_mode::in, type_and_mode::out,
- mq_info::in, mq_info::out, io__state::di, io__state::uo) is det.
+ mq_info::in, mq_info::out, io::di, io::uo) is det.
-qualify_type_and_mode(type_only(Type0), type_only(Type), Info0, Info) -->
- qualify_type(Type0, Type, Info0, Info).
+qualify_type_and_mode(type_only(Type0), type_only(Type), !Info, !IO) :-
+ qualify_type(Type0, Type, !Info, !IO).
qualify_type_and_mode(type_and_mode(Type0, Mode0), type_and_mode(Type, Mode),
- Info0, Info) -->
- qualify_type(Type0, Type, Info0, Info1),
- qualify_mode(Mode0, Mode, Info1, Info).
-
-:- pred qualify_mode_list(list(mode)::in, list(mode)::out, mq_info::in,
- mq_info::out, io__state::di, io__state::uo) is det.
-
-qualify_mode_list([], [], Info, Info) --> [].
-qualify_mode_list([Mode0 | Modes0], [Mode | Modes], Info0, Info) -->
- qualify_mode(Mode0, Mode, Info0, Info1),
- qualify_mode_list(Modes0, Modes, Info1, Info).
+ !Info, !IO) :-
+ qualify_type(Type0, Type, !Info, !IO),
+ qualify_mode(Mode0, Mode, !Info, !IO).
+
+:- pred qualify_mode_list(list(mode)::in, list(mode)::out,
+ mq_info::in, mq_info::out, io::di, io::uo) is det.
+
+qualify_mode_list([], [], !Info, !IO).
+qualify_mode_list([Mode0 | Modes0], [Mode | Modes], !Info, !IO) :-
+ qualify_mode(Mode0, Mode, !Info, !IO),
+ qualify_mode_list(Modes0, Modes, !Info, !IO).
:- pred qualify_mode((mode)::in, (mode)::out, mq_info::in, mq_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
-qualify_mode((Inst0a -> Inst1a), (Inst0 -> Inst1), Info0, Info) -->
- qualify_inst(Inst0a, Inst0, Info0, Info1),
- qualify_inst(Inst1a, Inst1, Info1, Info).
+qualify_mode((Inst0a -> Inst1a), (Inst0 -> Inst1), !Info, !IO) :-
+ qualify_inst(Inst0a, Inst0, !Info, !IO),
+ qualify_inst(Inst1a, Inst1, !Info, !IO).
qualify_mode(user_defined_mode(SymName0, Insts0),
- user_defined_mode(SymName, Insts), Info0, Info) -->
- qualify_inst_list(Insts0, Insts, Info0, Info1),
- { list__length(Insts, Arity) },
- { mq_info_get_modes(Info1, Modes) },
- find_unique_match(SymName0 - Arity, SymName - _, Modes,
- mode_id, Info1, Info).
-
-:- pred qualify_inst_list(list(inst)::in, list(inst)::out, mq_info::in,
- mq_info::out, io__state::di, io__state::uo) is det.
-
-qualify_inst_list([], [], Info, Info) --> [].
-qualify_inst_list([Inst0 | Insts0], [Inst | Insts], Info0, Info) -->
- qualify_inst(Inst0, Inst, Info0, Info1),
- qualify_inst_list(Insts0, Insts, Info1, Info).
+ user_defined_mode(SymName, Insts), !Info, !IO) :-
+ qualify_inst_list(Insts0, Insts, !Info, !IO),
+ list.length(Insts, Arity),
+ mq_info_get_modes(!.Info, Modes),
+ find_unique_match(SymName0 - Arity, SymName - _, Modes, mode_id,
+ !Info, !IO).
+
+:- pred qualify_inst_list(list(inst)::in, list(inst)::out,
+ mq_info::in, mq_info::out, io::di, io::uo) is det.
+
+qualify_inst_list([], [], !Info, !IO).
+qualify_inst_list([Inst0 | Insts0], [Inst | Insts], !Info, !IO) :-
+ qualify_inst(Inst0, Inst, !Info, !IO),
+ 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__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
-qualify_inst(any(A), any(A), Info, Info) --> [].
-qualify_inst(free, free, Info, Info) --> [].
-qualify_inst(not_reached, not_reached, Info, Info) --> [].
-qualify_inst(free(_), _, _, _) -->
- { error("compiler generated inst not expected") }.
-qualify_inst(bound(Uniq, BoundInsts0), bound(Uniq, BoundInsts),
- Info0, Info) -->
- qualify_bound_inst_list(BoundInsts0, BoundInsts, Info0, Info).
+qualify_inst(any(A), any(A), !Info, !IO).
+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").
+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),
- Info0, Info) -->
+ !Info, !IO) :-
(
- { GroundInstInfo0 = higher_order(pred_inst_info(A, Modes0,
- Det)) },
- qualify_mode_list(Modes0, Modes, Info0, Info),
- { GroundInstInfo = higher_order(pred_inst_info(A, Modes, Det)) }
- ;
- { GroundInstInfo0 = none },
- { GroundInstInfo = none },
- { Info = Info0 }
+ GroundInstInfo0 = higher_order(pred_inst_info(A, Modes0, Det)),
+ qualify_mode_list(Modes0, Modes, !Info, !IO),
+ GroundInstInfo = higher_order(pred_inst_info(A, Modes, Det))
+ ;
+ GroundInstInfo0 = none,
+ GroundInstInfo = none
).
-qualify_inst(inst_var(Var), inst_var(Var), Info, Info) --> [].
+qualify_inst(inst_var(Var), inst_var(Var), !Info, !IO).
qualify_inst(constrained_inst_vars(Vars, Inst0),
- constrained_inst_vars(Vars, Inst), Info0, Info) -->
- qualify_inst(Inst0, Inst, Info0, Info).
-qualify_inst(defined_inst(InstName0), defined_inst(InstName), Info0, Info) -->
- qualify_inst_name(InstName0, InstName, Info0, Info).
-qualify_inst(abstract_inst(Name, Args0), abstract_inst(Name, Args),
- Info0, Info) -->
- qualify_inst_list(Args0, Args, Info0, Info).
+ constrained_inst_vars(Vars, Inst), !Info, !IO) :-
+ qualify_inst(Inst0, Inst, !Info, !IO).
+qualify_inst(defined_inst(InstName0), defined_inst(InstName), !Info, !IO) :-
+ qualify_inst_name(InstName0, InstName, !Info, !IO).
+qualify_inst(abstract_inst(Name, Args0), abstract_inst(Name, Args), !Info,
+ !IO) :-
+ qualify_inst_list(Args0, Args, !Info, !IO).
% 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__state::di, io__state::uo) is det.
+:- pred qualify_inst_name(inst_name::in, inst_name::out,
+ mq_info::in, mq_info::out, io::di, io::uo) is det.
qualify_inst_name(user_inst(SymName0, Insts0), user_inst(SymName, Insts),
- Info0, Info) -->
- qualify_inst_list(Insts0, Insts, Info0, Info1),
- { mq_info_get_insts(Info1, InstIds) },
- { list__length(Insts0, Arity) },
+ !Info, !IO) :-
+ qualify_inst_list(Insts0, Insts, !Info, !IO),
+ mq_info_get_insts(!.Info, InstIds),
+ list.length(Insts0, Arity),
find_unique_match(SymName0 - Arity, SymName - _,
- InstIds, inst_id, Info1, Info).
-qualify_inst_name(merge_inst(_, _), _, _, _) -->
- { error("compiler generated inst unexpected") }.
-qualify_inst_name(unify_inst(_, _, _, _), _, _, _) -->
- { error("compiler generated inst unexpected") }.
-qualify_inst_name(ground_inst(_, _, _, _), _, _, _) -->
- { error("compiler generated inst unexpected") }.
-qualify_inst_name(any_inst(_, _, _, _), _, _, _) -->
- { error("compiler generated inst unexpected") }.
-qualify_inst_name(shared_inst(_), _, _, _) -->
- { error("compiler generated inst unexpected") }.
-qualify_inst_name(mostly_uniq_inst(_), _, _, _) -->
- { error("compiler generated inst unexpected") }.
-qualify_inst_name(typed_ground(_, _), _, _, _) -->
- { error("compiler generated inst unexpected") }.
-qualify_inst_name(typed_inst(_, _), _, _, _) -->
- { error("compiler generated inst unexpected") }.
+ InstIds, inst_id, !Info, !IO).
+qualify_inst_name(merge_inst(_, _), _, !Info, !IO) :-
+ error("compiler generated inst unexpected").
+qualify_inst_name(unify_inst(_, _, _, _), _, !Info, !IO) :-
+ error("compiler generated inst unexpected").
+qualify_inst_name(ground_inst(_, _, _, _), _, !Info, !IO) :-
+ error("compiler generated inst unexpected").
+qualify_inst_name(any_inst(_, _, _, _), _, !Info, !IO) :-
+ error("compiler generated inst unexpected").
+qualify_inst_name(shared_inst(_), _, !Info, !IO) :-
+ error("compiler generated inst unexpected").
+qualify_inst_name(mostly_uniq_inst(_), _, !Info, !IO) :-
+ error("compiler generated inst unexpected").
+qualify_inst_name(typed_ground(_, _), _, !Info, !IO) :-
+ error("compiler generated inst unexpected").
+qualify_inst_name(typed_inst(_, _), _, !Info, !IO) :-
+ error("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__state::di, io__state::uo) is det.
+ mq_info::in, mq_info::out, io::di, io::uo) is det.
-qualify_bound_inst_list([], [], Info, Info) --> [].
+qualify_bound_inst_list([], [], !Info, !IO).
qualify_bound_inst_list([functor(ConsId, Insts0) | BoundInsts0],
- [functor(ConsId, Insts) | BoundInsts], Info0, Info) -->
- { ConsId = cons(Name, Arity) ->
+ [functor(ConsId, Insts) | BoundInsts], !Info, !IO) :-
+ ( ConsId = cons(Name, Arity) ->
Id = Name - Arity,
update_recompilation_info(
- recompilation__record_used_item(functor, Id, Id),
- Info0, Info1)
+ recompilation.record_used_item(functor, Id, Id),
+ !Info)
;
- Info1 = Info0
- },
- qualify_inst_list(Insts0, Insts, Info1, Info2),
- qualify_bound_inst_list(BoundInsts0, BoundInsts, Info2, Info).
+ true
+ ),
+ qualify_inst_list(Insts0, Insts, !Info, !IO),
+ qualify_bound_inst_list(BoundInsts0, BoundInsts, !Info, !IO).
:- pred qualify_constructor_arg_list(list(constructor_arg)::in,
list(constructor_arg)::out, mq_info::in, mq_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
-qualify_constructor_arg_list([], [], Info, Info) --> [].
+qualify_constructor_arg_list([], [], !Info, !IO).
qualify_constructor_arg_list([Name - Type0 | Args0], [Name - Type | Args],
- Info0, Info) -->
- qualify_type(Type0, Type, Info0, Info1),
- qualify_constructor_arg_list(Args0, Args, Info1, Info).
-
-:- pred qualify_type_list(list(type)::in, list(type)::out, mq_info::in,
- mq_info::out, io__state::di, io__state::uo) is det.
-
-qualify_type_list([], [], Info, Info) --> [].
-qualify_type_list([Type0 | Types0], [Type | Types], Info0, Info) -->
- qualify_type(Type0, Type, Info0, Info1),
- qualify_type_list(Types0, Types, Info1, Info).
+ !Info, !IO) :-
+ qualify_type(Type0, Type, !Info, !IO),
+ qualify_constructor_arg_list(Args0, Args, !Info, !IO).
+
+:- pred qualify_type_list(list(type)::in, list(type)::out,
+ mq_info::in, mq_info::out, io::di, io::uo) is det.
+
+qualify_type_list([], [], !Info, !IO).
+qualify_type_list([Type0 | Types0], [Type | Types], !Info, !IO) :-
+ qualify_type(Type0, Type, !Info, !IO),
+ 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__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
-qualify_type(term__variable(Var), term__variable(Var), Info, Info) --> [].
-qualify_type(Type0, Type, Info0, Info) -->
- { Type0 = term__functor(_, _, _) },
- ( { type_to_ctor_and_args(Type0, TypeCtor0, Args0) } ->
- ( { is_builtin_atomic_type(TypeCtor0) } ->
- { TypeCtor = TypeCtor0 },
- { Info1 = Info0 }
- ; { type_ctor_is_higher_order(TypeCtor0, _, _, _) } ->
- { TypeCtor = TypeCtor0 },
- { Info1 = Info0 }
- ; { type_ctor_is_tuple(TypeCtor0) } ->
- { TypeCtor = TypeCtor0 },
- { Info1 = Info0 }
+qualify_type(term.variable(Var), term.variable(Var), !Info, !IO).
+qualify_type(Type0, Type, !Info, !IO) :-
+ Type0 = term.functor(_, _, _),
+ ( type_to_ctor_and_args(Type0, TypeCtor0, Args0) ->
+ ( is_builtin_atomic_type(TypeCtor0) ->
+ TypeCtor = TypeCtor0
+ ; type_ctor_is_higher_order(TypeCtor0, _, _, _) ->
+ TypeCtor = TypeCtor0
+ ; type_ctor_is_tuple(TypeCtor0) ->
+ TypeCtor = TypeCtor0
;
- { mq_info_get_types(Info0, Types) },
+ mq_info_get_types(!.Info, Types),
find_unique_match(TypeCtor0, TypeCtor, Types,
- type_id, Info0, Info1)
+ type_id, !Info, !IO)
),
- qualify_type_list(Args0, Args, Info1, Info2),
- { construct_type(TypeCtor, Args, Type) }
+ qualify_type_list(Args0, Args, !Info, !IO),
+ construct_type(TypeCtor, Args, Type)
;
- { mq_info_get_error_context(Info0, ErrorContext) },
- report_invalid_type(Type0, ErrorContext),
- { Type = Type0 },
- { Info2 = Info0 }
+ mq_info_get_error_context(!.Info, ErrorContext),
+ report_invalid_type(Type0, ErrorContext, !IO),
+ Type = Type0
),
%
% The types `int', `float', and `string' are builtin types,
@@ -971,8 +946,8 @@
% uses the type `int' in the interface, then we don't want
% to warn about `import_module int' in the interface.
%
- {
- Type = term__functor(term__atom(Typename), [], _),
+ (
+ Type = term.functor(term.atom(Typename), [], _),
( Typename = "int"
; Typename = "string"
; Typename = "float"
@@ -981,147 +956,144 @@
% -- not yet:
% StdLibraryModule = qualified(unqualified("std"), Typename),
StdLibraryModule = unqualified(Typename),
- mq_info_set_module_used(Info2, StdLibraryModule, Info)
+ mq_info_set_module_used(StdLibraryModule, !Info)
;
- Info = Info2
- }.
+ true
+ ).
% 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__state::di, io__state::uo) is det.
+ mq_info::in, mq_info::out, io::di, io::uo) is det.
-qualify_pragma(X at source_file(_), X, Info, Info) --> [].
-qualify_pragma(X at foreign_decl(_, _, _), X, Info, Info) --> [].
-qualify_pragma(X at foreign_code(_, _), X, Info, Info) --> [].
-qualify_pragma(X at foreign_import_module(_, _), X, Info, Info) --> [].
-qualify_pragma(X, Y, Info0, Info) -->
- { PragmaVars0 = X ^ proc_vars },
- qualify_pragma_vars(PragmaVars0, PragmaVars, Info0, Info),
- { Y = X ^ proc_vars := PragmaVars }.
+qualify_pragma(X at source_file(_), X, !Info, !IO).
+qualify_pragma(X at foreign_decl(_, _, _), X, !Info, !IO).
+qualify_pragma(X at foreign_code(_, _), X, !Info, !IO).
+qualify_pragma(X at foreign_import_module(_, _), X, !Info, !IO).
+qualify_pragma(X, Y, !Info, !IO) :-
+ PragmaVars0 = X ^ proc_vars,
+ qualify_pragma_vars(PragmaVars0, PragmaVars, !Info, !IO),
+ Y = X ^ proc_vars := PragmaVars.
qualify_pragma(tabled(A, B, C, D, MModes0), tabled(A, B, C, D, MModes),
- Info0, Info) -->
+ !Info, !IO) :-
(
- { MModes0 = yes(Modes0) }
- ->
- qualify_mode_list(Modes0, Modes, Info0, Info),
- { MModes = yes(Modes) }
- ;
- { Info = Info0 },
- { MModes = no }
- ).
-qualify_pragma(X at inline(_, _), X, Info, Info) --> [].
-qualify_pragma(X at no_inline(_, _), X, Info, Info) --> [].
-qualify_pragma(X at obsolete(_, _), X, Info, Info) --> [].
+ MModes0 = yes(Modes0),
+ qualify_mode_list(Modes0, Modes, !Info, !IO),
+ MModes = yes(Modes)
+ ;
+ MModes0 = no,
+ MModes = no
+ ).
+qualify_pragma(X at inline(_, _), X, !Info, !IO).
+qualify_pragma(X at no_inline(_, _), X, !Info, !IO).
+qualify_pragma(X at obsolete(_, _), X, !Info, !IO).
qualify_pragma(import(Name, PredOrFunc, Modes0, Attributes, CFunc),
import(Name, PredOrFunc, Modes, Attributes, CFunc),
- Info0, Info) -->
- qualify_mode_list(Modes0, Modes, Info0, Info).
+ !Info, !IO) :-
+ qualify_mode_list(Modes0, Modes, !Info, !IO).
qualify_pragma(export(Name, PredOrFunc, Modes0, CFunc),
- export(Name, PredOrFunc, Modes, CFunc), Info0, Info) -->
- qualify_mode_list(Modes0, Modes, Info0, Info).
-qualify_pragma(X at unused_args(_, _, _, _, _), X, Info, Info) --> [].
-qualify_pragma(X at exceptions(_, _, _, _, _), X, Info, Info) --> [].
+ export(Name, PredOrFunc, Modes, CFunc), !Info, !IO) :-
+ qualify_mode_list(Modes0, Modes, !Info, !IO).
+qualify_pragma(X at unused_args(_, _, _, _, _), X, !Info, !IO).
+qualify_pragma(X at exceptions(_, _, _, _, _), X, !Info, !IO).
qualify_pragma(type_spec(A, B, C, D, MaybeModes0, Subst0, G, H),
type_spec(A, B, C, D, MaybeModes, Subst, G, H),
- Info0, Info) -->
+ !Info, !IO) :-
(
- { MaybeModes0 = yes(Modes0) }
- ->
- qualify_mode_list(Modes0, Modes, Info0, Info1),
- { MaybeModes = yes(Modes) }
+ MaybeModes0 = yes(Modes0),
+ qualify_mode_list(Modes0, Modes, !Info, !IO),
+ MaybeModes = yes(Modes)
;
- { Info1 = Info0 },
- { MaybeModes = no }
+ MaybeModes0 = no,
+ MaybeModes = no
),
- qualify_type_spec_subst(Subst0, Subst, Info1, Info).
-qualify_pragma(X at fact_table(_, _, _), X, Info, Info) --> [].
-qualify_pragma(X at reserve_tag(_, _), X, Info, Info) --> [].
-qualify_pragma(X at aditi(_, _), X, Info, Info) --> [].
-qualify_pragma(X at base_relation(_, _), X, Info, Info) --> [].
-qualify_pragma(X at aditi_index(_, _, _), X, Info, Info) --> [].
-qualify_pragma(X at supp_magic(_, _), X, Info, Info) --> [].
-qualify_pragma(X at context(_, _), X, Info, Info) --> [].
-qualify_pragma(X at aditi_memo(_, _), X, Info, Info) --> [].
-qualify_pragma(X at aditi_no_memo(_, _), X, Info, Info) --> [].
-qualify_pragma(X at naive(_, _), X, Info, Info) --> [].
-qualify_pragma(X at psn(_, _), X, Info, Info) --> [].
-qualify_pragma(X at owner(_, _, _), X, Info, Info) --> [].
-qualify_pragma(X at promise_pure(_, _), X, Info, Info) --> [].
-qualify_pragma(X at promise_semipure(_, _), X, Info, Info) --> [].
+ qualify_type_spec_subst(Subst0, Subst, !Info, !IO).
+qualify_pragma(X at fact_table(_, _, _), X, !Info, !IO).
+qualify_pragma(X at reserve_tag(_, _), X, !Info, !IO).
+qualify_pragma(X at aditi(_, _), X, !Info, !IO).
+qualify_pragma(X at base_relation(_, _), X, !Info, !IO).
+qualify_pragma(X at aditi_index(_, _, _), X, !Info, !IO).
+qualify_pragma(X at supp_magic(_, _), X, !Info, !IO).
+qualify_pragma(X at context(_, _), X, !Info, !IO).
+qualify_pragma(X at aditi_memo(_, _), X, !Info, !IO).
+qualify_pragma(X at aditi_no_memo(_, _), X, !Info, !IO).
+qualify_pragma(X at naive(_, _), X, !Info, !IO).
+qualify_pragma(X at psn(_, _), X, !Info, !IO).
+qualify_pragma(X at owner(_, _, _), X, !Info, !IO).
+qualify_pragma(X at promise_pure(_, _), X, !Info, !IO).
+qualify_pragma(X at promise_semipure(_, _), X, !Info, !IO).
qualify_pragma(termination_info(PredOrFunc, SymName, ModeList0, Args, Term),
termination_info(PredOrFunc, SymName, ModeList, Args, Term),
- Info0, Info) -->
- qualify_mode_list(ModeList0, ModeList, Info0, Info).
-qualify_pragma(X at terminates(_, _), X, Info, Info) --> [].
-qualify_pragma(X at does_not_terminate(_, _), X, Info, Info) --> [].
-qualify_pragma(X at check_termination(_, _), X, Info, Info) --> [].
+ !Info, !IO) :-
+ qualify_mode_list(ModeList0, ModeList, !Info, !IO).
+qualify_pragma(X at terminates(_, _), X, !Info, !IO).
+qualify_pragma(X at does_not_terminate(_, _), X, !Info, !IO).
+qualify_pragma(X at check_termination(_, _), X, !Info, !IO).
:- pred qualify_pragma_vars(list(pragma_var)::in, list(pragma_var)::out,
- mq_info::in, mq_info::out, io__state::di, io__state::uo) is det.
+ mq_info::in, mq_info::out, io::di, io::uo) is det.
-qualify_pragma_vars([], [], Info, Info) --> [].
+qualify_pragma_vars([], [], !Info, !IO).
qualify_pragma_vars([pragma_var(Var, Name, Mode0) | PragmaVars0],
- [pragma_var(Var, Name, Mode) | PragmaVars], Info0, Info) -->
- qualify_mode(Mode0, Mode, Info0, Info1),
- qualify_pragma_vars(PragmaVars0, PragmaVars, Info1, Info).
+ [pragma_var(Var, Name, Mode) | PragmaVars], !Info, !IO) :-
+ qualify_mode(Mode0, Mode, !Info, !IO),
+ qualify_pragma_vars(PragmaVars0, PragmaVars, !Info, !IO).
:- pred qualify_type_spec_subst(assoc_list(tvar, type)::in,
- assoc_list(tvar, type)::out, mq_info::in, mq_info::out,
- io__state::di, io__state::uo) is det.
+ assoc_list(tvar, type)::out, mq_info::in, mq_info::out,
+ io::di, io::uo) is det.
-qualify_type_spec_subst([], [], Info, Info) --> [].
+qualify_type_spec_subst([], [], !Info, !IO).
qualify_type_spec_subst([Var - Type0 | Subst0], [Var - Type | Subst],
- Info0, Info) -->
- qualify_type(Type0, Type, Info0, Info1),
- qualify_type_spec_subst(Subst0, Subst, Info1, Info).
+ !Info, !IO) :-
+ qualify_type(Type0, Type, !Info, !IO),
+ qualify_type_spec_subst(Subst0, Subst, !Info, !IO).
:- pred qualify_class_constraints(class_constraints::in,
- class_constraints::out, mq_info::in, mq_info::out, io__state::di,
- io__state::uo) is det.
+ class_constraints::out, mq_info::in, mq_info::out,
+ io::di, io::uo) is det.
qualify_class_constraints(constraints(UnivCs0, ExistCs0),
- constraints(UnivCs, ExistCs), MQInfo0, MQInfo) -->
- qualify_class_constraint_list(UnivCs0, UnivCs, MQInfo0, MQInfo1),
- qualify_class_constraint_list(ExistCs0, ExistCs, MQInfo1, MQInfo).
+ constraints(UnivCs, ExistCs), !Info, !IO) :-
+ qualify_class_constraint_list(UnivCs0, UnivCs, !Info, !IO),
+ qualify_class_constraint_list(ExistCs0, ExistCs, !Info, !IO).
:- pred qualify_class_constraint_list(list(class_constraint)::in,
- list(class_constraint)::out, mq_info::in, mq_info::out, io__state::di,
- io__state::uo) is det.
+ list(class_constraint)::out, mq_info::in, mq_info::out,
+ io::di, io::uo) is det.
-qualify_class_constraint_list([], [], MQInfo, MQInfo) --> [].
-qualify_class_constraint_list([C0|C0s], [C|Cs], MQInfo0, MQInfo) -->
- qualify_class_constraint(C0, C, MQInfo0, MQInfo1),
- qualify_class_constraint_list(C0s, Cs, MQInfo1, MQInfo).
+qualify_class_constraint_list([], [], !Info, !IO).
+qualify_class_constraint_list([C0|C0s], [C|Cs], !Info, !IO) :-
+ qualify_class_constraint(C0, C, !Info, !IO),
+ qualify_class_constraint_list(C0s, Cs, !Info, !IO).
:- pred qualify_class_constraint(class_constraint::in, class_constraint::out,
- mq_info::in, mq_info::out, io__state::di, io__state::uo) is det.
+ mq_info::in, mq_info::out, io::di, io::uo) is det.
qualify_class_constraint(constraint(ClassName0, Types0),
- constraint(ClassName, Types), MQInfo0, MQInfo) -->
- { list__length(Types0, Arity) },
- qualify_class_name(ClassName0 - Arity, ClassName - _, MQInfo0, MQInfo1),
- qualify_type_list(Types0, Types, MQInfo1, MQInfo).
+ constraint(ClassName, Types), !Info, !IO) :-
+ list.length(Types0, Arity),
+ qualify_class_name(ClassName0 - Arity, ClassName - _, !Info, !IO),
+ qualify_type_list(Types0, Types, !Info, !IO).
:- pred qualify_class_name(pair(class_name, arity)::in,
pair(class_name, arity)::out, mq_info::in, mq_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
-qualify_class_name(Class0, Class, MQInfo0, MQInfo) -->
- { mq_info_get_classes(MQInfo0, ClassIdSet) },
- find_unique_match(Class0, Class, ClassIdSet, class_id,
- MQInfo0, MQInfo).
+qualify_class_name(Class0, Class, !Info, !IO) :-
+ mq_info_get_classes(!.Info, ClassIdSet),
+ find_unique_match(Class0, Class, ClassIdSet, class_id, !Info, !IO).
:- pred qualify_class_interface(list(class_method)::in,
list(class_method)::out, mq_info::in, mq_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
-qualify_class_interface([], [], MQInfo, MQInfo) --> [].
-qualify_class_interface([M0|M0s], [M|Ms], MQInfo0, MQInfo) -->
- qualify_class_method(M0, M, MQInfo0, MQInfo1),
- qualify_class_interface(M0s, Ms, MQInfo1, MQInfo).
+qualify_class_interface([], [], !Info, !IO).
+qualify_class_interface([M0 | M0s], [M | Ms], !Info, !IO) :-
+ qualify_class_method(M0, M, !Info, !IO),
+ qualify_class_interface(M0s, Ms, !Info, !IO).
:- pred qualify_class_method(class_method::in, class_method::out,
- mq_info::in, mq_info::out, io__state::di, io__state::uo) is det.
+ mq_info::in, mq_info::out, io::di, io::uo) is det.
% There is no need to qualify the method name, since that is
% done when the item is parsed.
@@ -1132,23 +1104,19 @@
pred_or_func(TypeVarset, InstVarset, ExistQVars, PredOrFunc,
Name, TypesAndModes, WithType, WithInst, MaybeDet,
Cond, Purity, ClassContext, Context),
- MQInfo0, MQInfo
- ) -->
- qualify_types_and_modes(TypesAndModes0, TypesAndModes,
- MQInfo0, MQInfo1),
- qualify_class_constraints(ClassContext0, ClassContext,
- MQInfo1, MQInfo2),
- map_fold2_maybe(qualify_type, WithType0, WithType, MQInfo2, MQInfo3),
- map_fold2_maybe(qualify_inst, WithInst0, WithInst, MQInfo3, MQInfo).
+ !Info, !IO) :-
+ qualify_types_and_modes(TypesAndModes0, TypesAndModes, !Info, !IO),
+ qualify_class_constraints(ClassContext0, ClassContext, !Info, !IO),
+ map_fold2_maybe(qualify_type, WithType0, WithType, !Info, !IO),
+ map_fold2_maybe(qualify_inst, WithInst0, WithInst, !Info, !IO).
qualify_class_method(
pred_or_func_mode(Varset, PredOrFunc, Name, Modes0,
WithInst0, MaybeDet, Cond, Context),
pred_or_func_mode(Varset, PredOrFunc, Name, Modes,
WithInst, MaybeDet, Cond, Context),
- MQInfo0, MQInfo
- ) -->
- qualify_mode_list(Modes0, Modes, MQInfo0, MQInfo1),
- map_fold2_maybe(qualify_inst, WithInst0, WithInst, MQInfo1, MQInfo).
+ !Info, !IO) :-
+ qualify_mode_list(Modes0, Modes, !Info, !IO),
+ map_fold2_maybe(qualify_inst, WithInst0, WithInst, !Info, !IO).
:- pred qualify_instance_body(sym_name::in, instance_body::in,
instance_body::out) is det.
@@ -1164,14 +1132,14 @@
add_module_qualifier(Module, Method0, Method),
M = instance_method(A, Method, C, D, E)
),
- list__map(Qualify, M0s, Ms)
+ list.map(Qualify, M0s, Ms)
).
:- pred add_module_qualifier(sym_name::in, sym_name::in, sym_name::out) is det.
add_module_qualifier(Module, unqualified(SymName), qualified(Module, SymName)).
add_module_qualifier(DefaultModule, qualified(SymModule, SymName),
- qualified(Module, SymName)) :-
+ qualified(Module, SymName)) :-
( match_sym_name(SymModule, DefaultModule) ->
Module = DefaultModule
;
@@ -1197,78 +1165,79 @@
% 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__state::di, io__state::uo) is det.
+ mq_info::in, mq_info::out, io::di, io::uo) is det.
-find_unique_match(Id0, Id, Ids, TypeOfId, Info0, Info) -->
+find_unique_match(Id0, Id, Ids, TypeOfId, !Info, !IO) :-
% Find all IDs which match the current id.
- { Id0 = SymName0 - Arity },
- { mq_info_get_modules(Info0, Modules) },
- { id_set_search_sym_arity(Ids, SymName0, Arity, Modules,
- MatchingModules0) },
+ Id0 = SymName0 - Arity,
+ mq_info_get_modules(!.Info, Modules),
+ id_set_search_sym_arity(Ids, SymName0, Arity, Modules,
+ MatchingModules0),
- { mq_info_get_import_status(Info0, exported) ->
+ ( mq_info_get_import_status(!.Info, exported) ->
% Items in the interface may only refer to modules
% imported in the interface.
- mq_info_get_interface_visible_modules(Info0,
+ mq_info_get_interface_visible_modules(!.Info,
InterfaceImports),
- list__filter(set__contains(InterfaceImports),
+ list.filter(set.contains(InterfaceImports),
MatchingModules0, MatchingModules)
;
MatchingModules = MatchingModules0
- },
+ ),
- ( { MatchingModules = [] } ->
+ (
+ MatchingModules = [],
% No matches for this id.
- { Id = Id0 },
- ( { mq_info_get_report_error_flag(Info0, yes) } ->
- report_undefined(MatchingModules0,
- Info0, Id0, TypeOfId),
- { mq_info_set_error_flag(Info0, TypeOfId, Info1) },
- { mq_info_incr_errors(Info1, Info) }
+ Id = Id0,
+ ( mq_info_get_report_error_flag(!.Info, yes) ->
+ report_undefined(MatchingModules0, !.Info, Id0,
+ TypeOfId, !IO),
+ mq_info_set_error_flag(TypeOfId, !Info),
+ mq_info_incr_errors(!Info)
;
- { Info = Info0 }
+ true
)
- ; { MatchingModules = [Module] } ->
+ ;
+ MatchingModules = [Module],
% A unique match for this ID.
- { unqualify_name(SymName0, IdName) },
- { Id = qualified(Module, IdName) - Arity },
- { mq_info_set_module_used(Info0, Module, Info1) },
- { ItemType = convert_simple_item_type(TypeOfId) },
- { update_recompilation_info(
- recompilation__record_used_item(ItemType, Id0, Id),
- Info1, Info) }
+ unqualify_name(SymName0, IdName),
+ Id = qualified(Module, IdName) - Arity,
+ mq_info_set_module_used(Module, !Info),
+ ItemType = convert_simple_item_type(TypeOfId),
+ update_recompilation_info(
+ recompilation.record_used_item(ItemType, Id0, Id),
+ !Info)
;
+ MatchingModules = [_, _ | _],
% There are multiple matches.
- { Id = Id0 },
- ( { mq_info_get_report_error_flag(Info0, yes) } ->
- { mq_info_get_error_context(Info0, ErrorContext) },
+ Id = Id0,
+ ( mq_info_get_report_error_flag(!.Info, yes) ->
+ mq_info_get_error_context(!.Info, ErrorContext),
report_ambiguous_match(ErrorContext, Id0, TypeOfId,
- MatchingModules),
- { mq_info_set_error_flag(Info0, TypeOfId, Info1) },
- { mq_info_incr_errors(Info1, Info) }
+ MatchingModules, !IO),
+ mq_info_set_error_flag(TypeOfId, !Info),
+ mq_info_incr_errors(!Info)
;
- { Info = Info0 }
+ true
)
).
-:- pred update_recompilation_info(pred(recompilation_info, recompilation_info),
- mq_info, mq_info).
-:- mode update_recompilation_info(pred(in, out) is det, in, out) is det.
+:- pred update_recompilation_info(
+ pred(recompilation_info, recompilation_info)::in(pred(in, out) is det),
+ mq_info::in, mq_info::out) is det.
-update_recompilation_info(Pred, Info0, Info) :-
- mq_info_get_recompilation_info(Info0, MaybeRecompInfo0),
+update_recompilation_info(Pred, !Info) :-
+ mq_info_get_recompilation_info(!.Info, MaybeRecompInfo0),
(
MaybeRecompInfo0 = yes(RecompInfo0),
Pred(RecompInfo0, RecompInfo),
- mq_info_set_recompilation_info(Info0, yes(RecompInfo), Info)
+ mq_info_set_recompilation_info(yes(RecompInfo), !Info)
;
- MaybeRecompInfo0 = no,
- Info = Info0
+ MaybeRecompInfo0 = no
).
:- func convert_simple_item_type(id_type) = item_type.
-:- mode convert_simple_item_type(in) = out is det.
convert_simple_item_type(type_id) = (type).
convert_simple_item_type(mode_id) = (mode).
@@ -1277,18 +1246,18 @@
%------------------------------------------------------------------------------
-:- type id_type --->
- type_id
+:- type id_type
+ ---> type_id
; mode_id
; inst_id
; class_id.
-:- type error_context == pair(error_context2, prog_context).
+:- type error_context == pair(mq_error_context, prog_context).
:- type id == pair(sym_name, int).
-:- type error_context2 --->
- type(id)
+:- type mq_error_context
+ ---> type(id)
; inst(id)
; mode(id)
; pred_or_func(pred_or_func, id)
@@ -1300,138 +1269,124 @@
; class(id)
; instance(id).
+:- func id_to_sym_name_and_arity(id) = sym_name_and_arity.
+
+id_to_sym_name_and_arity(SymName - Arity) = SymName / Arity.
+
% Report an undefined type, inst or mode.
-:- pred report_undefined(list(module_name), mq_info, pair(sym_name, int),
- id_type, io__state, io__state).
-:- mode report_undefined(in, in, in, in, di, uo) is det.
-
-report_undefined(MatchingModules, Info, Id, IdType) -->
- { mq_info_get_error_context(Info, ErrorContext - Context) },
- io__set_exit_status(1),
- prog_out__write_context(Context),
- io__write_string("In "),
- write_error_context2(ErrorContext),
- io__write_string(":\n"),
- prog_out__write_context(Context),
- io__write_string(" error: undefined "),
- { id_type_to_string(IdType, IdStr) },
- io__write_string(IdStr),
- io__write_string(" "),
- write_id(Id),
+:- pred report_undefined(list(module_name)::in, mq_info::in,
+ id::in, id_type::in, io::di, io::uo) is det.
+
+report_undefined(MatchingModules, Info, Id, IdType, !IO) :-
+ mq_info_get_error_context(Info, ErrorContext - Context),
+ id_type_to_string(IdType, IdStr),
+ io.set_exit_status(1, !IO),
+
+ Pieces1 = [words("In")] ++ mq_error_context_to_pieces(ErrorContext) ++
+ [suffix(":"), nl, words("error: undefined"), fixed(IdStr),
+ sym_name_and_arity(id_to_sym_name_and_arity(Id)),
+ suffix("."), nl],
(
%
- % if it is a qualified symbol, then check whether the module
- % specified has been imported
+ % If it is a qualified symbol, then check whether the module
+ % specified has been imported.
%
- { Id = qualified(ModuleName, _) - _Arity },
- { mq_info_get_imported_modules(Info, ImportedModules) },
- { \+ set__member(ModuleName, ImportedModules) },
- { \+ ModuleName = Info^this_module }
+ Id = qualified(ModuleName, _) - _Arity,
+ mq_info_get_imported_modules(Info, ImportedModules),
+ \+ set.member(ModuleName, ImportedModules),
+ \+ ModuleName = Info ^ this_module
->
- io__write_string("\n"),
- prog_out__write_context(Context),
- io__write_string(" (the module `"),
- mercury_output_bracketed_sym_name(ModuleName),
- io__write_string("' has not been imported).\n")
+ Pieces2 = [words("(The module"), sym_name(ModuleName),
+ words("has not been imported.)"), nl]
;
- { MatchingModules = [_ | MatchingModules1] }
+ MatchingModules = [_ | MatchingModules1]
->
- { MatchingModules1 = [],
- ModuleWord = "module ",
- HasWord = " has"
- ; MatchingModules1 = [_|_],
- ModuleWord = "modules ",
- HasWord = " have"
- },
-
- io__write_string("\n"),
- prog_out__write_context(Context),
- io__write_string(" (the "),
- io__write_string(ModuleWord),
- prog_out__write_module_list(MatchingModules),
- io__write_string(HasWord),
- io__write_string(" not been imported in the interface).\n")
+ (
+ MatchingModules1 = [],
+ ModuleWord = "module",
+ HasWord = "has"
+ ;
+ MatchingModules1 = [_|_],
+ ModuleWord = "modules",
+ HasWord = "have"
+ ),
+ MatchingSymNames = list.map(wrap_module_name,
+ MatchingModules),
+ Pieces2 = [words("(The"), fixed(ModuleWord)] ++
+ component_list_to_pieces(MatchingSymNames) ++
+ [fixed(HasWord),
+ words("not been imported in the interface.)")]
;
- io__write_string(".\n")
- ).
+ Pieces2 = []
+ ),
+ write_error_pieces(Context, 0, Pieces1 ++ Pieces2, !IO).
% Report an error where a type, inst or mode had multiple possible
% matches.
:- pred report_ambiguous_match(error_context::in, id::in, id_type::in,
- list(module_name)::in, io__state::di, io__state::uo) is det.
+ list(module_name)::in, io::di, io::uo) is det.
-report_ambiguous_match(ErrorContext - Context, Id, IdType, Modules) -->
- io__set_exit_status(1),
- prog_out__write_context(Context),
- io__write_string("In "),
- write_error_context2(ErrorContext),
- io__write_string("\n"),
- prog_out__write_context(Context),
- io__write_string(" ambiguity error: multiple possible matches for "),
- { id_type_to_string(IdType, IdStr) },
- io__write_string(IdStr),
- io__write_string(" "),
- write_id(Id),
- io__write_string(".\n"),
- prog_out__write_context(Context),
- io__write_string(" The possible matches are in modules\n"),
- prog_out__write_context(Context),
- io__write_string(" "),
- prog_out__write_module_list(Modules),
- io__write_string(".\n"),
- globals__io_lookup_bool_option(verbose_errors, Verbose),
- ( { Verbose = yes } ->
- prog_out__write_context(Context),
- io__write_string(" An explicit module qualifier may be necessary.\n")
+report_ambiguous_match(ErrorContext - Context, Id, IdType, Modules, !IO) :-
+ id_type_to_string(IdType, IdStr),
+ ModuleNames = list.map(wrap_module_name, Modules),
+ Pieces1 = [words("In")] ++ mq_error_context_to_pieces(ErrorContext) ++
+ [words("ambiguity error: multiple possible matches for"),
+ fixed(IdStr), wrap_id(Id), suffix("."), nl,
+ words("The possible matches are in modules")] ++ ModuleNames ++
+ [suffix("."), nl],
+ globals.io_lookup_bool_option(verbose_errors, Verbose, !IO),
+ (
+ Verbose = yes,
+ Pieces2 = [words("An explicit module qualifier"),
+ words("may be necessary."), nl]
;
- []
- ).
+ Verbose = no,
+ Pieces2 = []
+ ),
+ write_error_pieces(Context, 0, Pieces1 ++ Pieces2, !IO),
+ io.set_exit_status(1, !IO).
% Give a context for the current error message.
-:- pred write_error_context2(error_context2::in, io__state::di,
- io__state::uo) is det.
+:- func mq_error_context_to_pieces(mq_error_context) = list(format_component).
-write_error_context2(type(Id)) -->
- io__write_string("definition of type "),
- write_id(Id).
-write_error_context2(mode(Id)) -->
- io__write_string("definition of mode "),
- write_id(Id).
-write_error_context2(inst(Id)) -->
- io__write_string("definition of inst "),
- write_id(Id).
-write_error_context2(pred_or_func(PredOrFunc, SymName - Arity)) -->
- io__write_string("definition of "),
- io__write(PredOrFunc),
- io__write_string(" "),
- { adjust_func_arity(PredOrFunc, OrigArity, Arity) },
- write_id(SymName - OrigArity).
-write_error_context2(pred_or_func_mode(MaybePredOrFunc, SymName - Arity)) -->
- io__write_string("mode declaration for "),
- (
- { MaybePredOrFunc = yes(PredOrFunc) },
- io__write(PredOrFunc),
- io__write_string(" "),
- { adjust_func_arity(PredOrFunc, OrigArity, Arity) }
- ;
- { MaybePredOrFunc = no },
- { OrigArity = Arity }
- ),
- write_id(SymName - OrigArity).
-write_error_context2(lambda_expr) -->
- io__write_string("mode declaration for lambda expression").
-write_error_context2(clause_mode_annotation) -->
- io__write_string("clause mode annotation").
-write_error_context2(pragma) -->
- io__write_string("pragma").
-write_error_context2(type_qual) -->
- io__write_string("explicit type qualification").
-write_error_context2(class(Id)) -->
- io__write_string("declaration of typeclass "),
- write_id(Id).
-write_error_context2(instance(Id)) -->
- io__write_string("declaration of instance of typeclass "),
- write_id(Id).
+mq_error_context_to_pieces(type(Id)) =
+ [words("definition of type"), wrap_id(Id)].
+mq_error_context_to_pieces(mode(Id)) =
+ [words("definition of mode"), wrap_id(Id)].
+mq_error_context_to_pieces(inst(Id)) =
+ [words("definition of inst"), wrap_id(Id)].
+mq_error_context_to_pieces(pred_or_func(PredOrFunc, SymName - OrigArity))
+ = Pieces :-
+ adjust_func_arity(PredOrFunc, OrigArity, Arity),
+ Pieces = [words("definition of "),
+ fixed(pred_or_func_to_full_str(PredOrFunc)),
+ sym_name_and_arity(SymName / Arity)].
+mq_error_context_to_pieces(pred_or_func_mode(MaybePredOrFunc,
+ SymName - OrigArity)) = Pieces :-
+ (
+ MaybePredOrFunc = yes(PredOrFunc),
+ adjust_func_arity(PredOrFunc, OrigArity, Arity),
+ Pieces = [words("mode declaration for"),
+ fixed(pred_or_func_to_full_str(PredOrFunc)),
+ sym_name_and_arity(SymName / Arity)]
+ ;
+ MaybePredOrFunc = no,
+ Pieces = [words("mode declaration for"),
+ sym_name_and_arity(SymName / OrigArity)]
+ ).
+mq_error_context_to_pieces(lambda_expr) =
+ [words("mode declaration for lambda expression")].
+mq_error_context_to_pieces(clause_mode_annotation) =
+ [words("clause mode annotation")].
+mq_error_context_to_pieces(pragma) =
+ [words("pragma")].
+mq_error_context_to_pieces(type_qual) =
+ [words("explicit type qualification")].
+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)].
:- pred id_type_to_string(id_type::in, string::out) is det.
@@ -1440,92 +1395,75 @@
id_type_to_string(inst_id, "inst").
id_type_to_string(class_id, "typeclass").
- % Write sym_name/arity.
-:- pred write_id(id::in, io__state::di, io__state::uo) is det.
-
-write_id(SymName - Arity) -->
- io__write_string("`"),
- prog_out__write_sym_name(SymName),
- io__write_string("'/"),
- io__write_int(Arity).
-
% Warn about modules imported in the interface when they do not
% need to be.
:- pred maybe_warn_unused_interface_imports(module_name::in,
- list(module_name)::in, io__state::di, io__state::uo) is det.
+ list(module_name)::in, io::di, io::uo) is det.
-maybe_warn_unused_interface_imports(ModuleName, UnusedImports) -->
- globals__io_lookup_bool_option(warn_interface_imports, Warn),
- globals__io_lookup_bool_option(halt_at_warn, HaltAtWarn),
+maybe_warn_unused_interface_imports(ModuleName, UnusedImports, !IO) :-
+ globals.io_lookup_bool_option(warn_interface_imports, Warn, !IO),
(
- { UnusedImports = []
+ ( UnusedImports = []
; Warn = no
- }
+ )
->
- []
+ true
;
- module_name_to_file_name(ModuleName, ".m", no, FileName),
- { term__context_init(FileName, 1, Context) },
- prog_out__write_context(Context),
- io__write_string("In module `"),
- prog_out__write_sym_name(ModuleName),
- io__write_string("':\n"),
- prog_out__write_context(Context),
- io__write_string(" warning: "),
- ( { UnusedImports = [_] } ->
- io__write_string("module ")
+ module_name_to_file_name(ModuleName, ".m", no, FileName, !IO),
+ term.context_init(FileName, 1, Context),
+ ( UnusedImports = [_] ->
+ ModuleWord = "module"
;
- io__write_string("modules ")
+ ModuleWord = "modules"
),
- prog_out__write_module_list(UnusedImports),
- io__write_string("\n"),
- prog_out__write_context(Context),
- { is_or_are(UnusedImports, IsOrAre) },
- io__write_strings([
- " ", IsOrAre,
- " imported in the interface, but ",
- IsOrAre, " not\n"
- ]),
- prog_out__write_context(Context),
- io__write_string(" used in the interface.\n"),
- (
- { HaltAtWarn = yes }
- ->
- io__set_exit_status(1)
- ;
- []
- )
+ UnusedSymNames = list.map(wrap_module_name, UnusedImports),
+ is_or_are(UnusedImports, IsOrAre),
+ Pieces = [words("In module"), sym_name(ModuleName),
+ suffix(":"), nl,
+ words("warning:"), words(ModuleWord)] ++
+ component_list_to_pieces(UnusedSymNames) ++
+ [fixed(IsOrAre), words("imported in the interface,"),
+ words("but"), fixed(IsOrAre),
+ words("not used in the interface.")],
+ write_error_pieces(Context, 0, Pieces, !IO),
+ record_warning(!IO)
).
+:- func wrap_module_name(module_name) = format_component.
+
+wrap_module_name(SymName) = sym_name(SymName).
+
+:- func wrap_id(id) = format_component.
+
+wrap_id(Name - Arity) = sym_name_and_arity(Name / Arity).
+
:- pred is_or_are(list(T)::in, string::out) is det.
-is_or_are([], "") :- error("module_qual:is_or_are").
+is_or_are([], "") :-
+ error("module_qual:is_or_are").
is_or_are([_], "is").
is_or_are([_, _ | _], "are").
% Output an error message about an ill-formed type.
-:- pred report_invalid_type(type, error_context, io__state, io__state).
-:- mode report_invalid_type(in, in, di, uo) is det.
+:- pred report_invalid_type((type)::in, error_context::in,
+ io::di, io::uo) is det.
-report_invalid_type(Type, ErrorContext - Context) -->
- io__set_exit_status(1),
- prog_out__write_context(Context),
- io__write_string("In definition of "),
- write_error_context2(ErrorContext),
- io__write_string(":\n"),
- prog_out__write_context(Context),
- io__write_string(" error: ill-formed type `"),
- { varset__init(VarSet) },
- mercury_output_term(Type, VarSet, no),
- io__write_string("'.\n").
+report_invalid_type(Type, ErrorContext - Context, !IO) :-
+ ContextPieces = mq_error_context_to_pieces(ErrorContext),
+ varset.init(VarSet),
+ Pieces = [words("In definition of")] ++ ContextPieces ++
+ [suffix(":"), nl, words("error: ill-formed type"),
+ fixed("`" ++ mercury_term_to_string(Type, VarSet, no) ++
+ "'.")],
+ write_error_pieces(Context, 0, Pieces, !IO),
+ io.set_exit_status(1, !IO).
%-----------------------------------------------------------------------------%
% 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).
-:- mode is_builtin_atomic_type(in) is semidet.
+:- pred is_builtin_atomic_type(type_ctor::in) is semidet.
is_builtin_atomic_type(unqualified("int") - 0).
is_builtin_atomic_type(unqualified("float") - 0).
@@ -1538,20 +1476,20 @@
:- pred init_mq_info(item_list::in, globals::in, bool::in, module_name::in,
mq_info::out) is det.
-init_mq_info(Items, Globals, ReportErrors, ModuleName, Info0) :-
- term__context_init(Context),
+init_mq_info(Items, Globals, ReportErrors, ModuleName, Info) :-
+ term.context_init(Context),
ErrorContext = type(unqualified("") - 0) - Context,
- set__init(InterfaceModules0),
+ set.init(InterfaceModules0),
get_implicit_dependencies(Items, Globals, ImportDeps, UseDeps),
- set__list_to_set(ImportDeps `list__append` UseDeps, ImportedModules),
+ set.list_to_set(ImportDeps `list.append` UseDeps, ImportedModules),
% Ancestor modules are visible without being explicitly imported.
- set__insert_list(ImportedModules,
+ set.insert_list(ImportedModules,
[ModuleName | get_ancestors(ModuleName)],
InterfaceVisibleModules),
id_set_init(Empty),
- globals__lookup_bool_option(Globals, smart_recompilation,
+ globals.lookup_bool_option(Globals, smart_recompilation,
SmartRecompilation),
(
SmartRecompilation = no,
@@ -1560,15 +1498,15 @@
SmartRecompilation = yes,
MaybeRecompInfo = yes(init_recompilation_info(ModuleName))
),
- Info0 = mq_info(ImportedModules, InterfaceVisibleModules,
- Empty, Empty, Empty, Empty, Empty, Empty,
- InterfaceModules0, local, 0,
- no, no, ReportErrors, ErrorContext, ModuleName,
- may_be_unqualified, MaybeRecompInfo).
+ Info = mq_info(ImportedModules, InterfaceVisibleModules,
+ Empty, Empty, Empty, Empty, Empty, Empty,
+ InterfaceModules0, local, 0,
+ no, no, ReportErrors, ErrorContext, ModuleName,
+ may_be_unqualified, MaybeRecompInfo).
:- pred mq_info_get_imported_modules(mq_info::in, set(module_name)::out) is det.
:- pred mq_info_get_interface_visible_modules(mq_info::in,
- set(module_name)::out) is det.
+ set(module_name)::out) is det.
:- pred mq_info_get_modules(mq_info::in, module_id_set::out) is det.
:- pred mq_info_get_types(mq_info::in, type_id_set::out) is det.
:- pred mq_info_get_impl_types(mq_info::in, type_id_set::out) is det.
@@ -1576,7 +1514,7 @@
:- pred mq_info_get_modes(mq_info::in, mode_id_set::out) is det.
:- pred mq_info_get_classes(mq_info::in, class_id_set::out) is det.
:- pred mq_info_get_unused_interface_modules(mq_info::in,
- set(module_name)::out) is det.
+ set(module_name)::out) is det.
:- pred mq_info_get_import_status(mq_info::in, import_status::out) is det.
% :- pred mq_info_get_num_errors(mq_info::in, int::out) is det.
% :- pred mq_info_get_type_error_flag(mq_info::in, bool::out) is det.
@@ -1584,108 +1522,110 @@
:- pred mq_info_get_report_error_flag(mq_info::in, bool::out) is det.
:- pred mq_info_get_error_context(mq_info::in, error_context::out) is det.
-mq_info_get_imported_modules(MQInfo, MQInfo^imported_modules).
-mq_info_get_interface_visible_modules(MQInfo,
- MQInfo^interface_visible_modules).
-mq_info_get_modules(MQInfo, MQInfo^modules).
-mq_info_get_types(MQInfo, MQInfo^types).
-mq_info_get_impl_types(MQInfo, MQInfo^impl_types).
-mq_info_get_insts(MQInfo, MQInfo^insts).
-mq_info_get_modes(MQInfo, MQInfo^modes).
-mq_info_get_classes(MQInfo, MQInfo^classes).
-mq_info_get_unused_interface_modules(MQInfo, MQInfo^unused_interface_modules).
-mq_info_get_import_status(MQInfo, MQInfo^import_status).
-mq_info_get_num_errors(MQInfo, MQInfo^num_errors).
-mq_info_get_type_error_flag(MQInfo, MQInfo^type_error_flag).
-mq_info_get_mode_error_flag(MQInfo, MQInfo^mode_error_flag).
-mq_info_get_report_error_flag(MQInfo, MQInfo^report_error_flag).
-mq_info_get_error_context(MQInfo, MQInfo^error_context).
-mq_info_get_need_qual_flag(MQInfo, MQInfo^need_qual_flag).
+mq_info_get_imported_modules(Info, Info ^ imported_modules).
+mq_info_get_interface_visible_modules(Info, Info ^ interface_visible_modules).
+mq_info_get_modules(Info, Info ^ modules).
+mq_info_get_types(Info, Info ^ types).
+mq_info_get_impl_types(Info, Info ^ impl_types).
+mq_info_get_insts(Info, Info ^ insts).
+mq_info_get_modes(Info, Info ^ modes).
+mq_info_get_classes(Info, Info ^ classes).
+mq_info_get_unused_interface_modules(Info, Info ^ unused_interface_modules).
+mq_info_get_import_status(Info, Info ^ import_status).
+mq_info_get_num_errors(Info, Info ^ num_errors).
+mq_info_get_type_error_flag(Info, Info ^ type_error_flag).
+mq_info_get_mode_error_flag(Info, Info ^ mode_error_flag).
+mq_info_get_report_error_flag(Info, Info ^ report_error_flag).
+mq_info_get_error_context(Info, Info ^ error_context).
+mq_info_get_need_qual_flag(Info, Info ^ need_qual_flag).
mq_info_get_recompilation_info(Info, Info ^ maybe_recompilation_info).
-:- pred mq_info_set_imported_modules(mq_info::in, set(module_name)::in,
- mq_info::out) is det.
-:- pred mq_info_set_interface_visible_modules(mq_info::in,
- set(module_name)::in, mq_info::out) is det.
-:- pred mq_info_set_modules(mq_info::in, module_id_set::in, mq_info::out)
- is det.
-:- pred mq_info_set_types(mq_info::in, type_id_set::in, mq_info::out) is det.
-:- pred mq_info_set_impl_types(mq_info::in, type_id_set::in, mq_info::out)
- is det.
-:- pred mq_info_set_insts(mq_info::in, inst_id_set::in, mq_info::out) is det.
-:- pred mq_info_set_modes(mq_info::in, mode_id_set::in, mq_info::out) is det.
-:- pred mq_info_set_classes(mq_info::in, class_id_set::in, mq_info::out) is det.
-:- pred mq_info_set_unused_interface_modules(mq_info::in, set(module_name)::in,
- mq_info::out) is det.
-:- pred mq_info_set_import_status(mq_info::in, import_status::in,
- mq_info::out) is det.
+:- pred mq_info_set_imported_modules(set(module_name)::in,
+ mq_info::in, mq_info::out) is det.
+:- pred mq_info_set_interface_visible_modules(set(module_name)::in,
+ mq_info::in, mq_info::out) is det.
+:- pred mq_info_set_modules(module_id_set::in,
+ mq_info::in, mq_info::out) is det.
+:- pred mq_info_set_types(type_id_set::in,
+ mq_info::in, mq_info::out) is det.
+:- pred mq_info_set_impl_types(type_id_set::in,
+ mq_info::in, mq_info::out) is det.
+:- pred mq_info_set_insts(inst_id_set::in,
+ mq_info::in, mq_info::out) is det.
+:- pred mq_info_set_modes(mode_id_set::in,
+ mq_info::in, mq_info::out) is det.
+:- pred mq_info_set_classes(class_id_set::in,
+ mq_info::in, mq_info::out) is det.
+:- pred mq_info_set_unused_interface_modules(set(module_name)::in,
+ mq_info::in, mq_info::out) is det.
+:- pred mq_info_set_import_status(import_status::in,
+ mq_info::in, mq_info::out) is det.
:- pred mq_info_set_type_error_flag(mq_info::in, mq_info::out) is det.
:- pred mq_info_set_mode_error_flag(mq_info::in, mq_info::out) is det.
-:- pred mq_info_set_error_context(mq_info::in, error_context::in,
- mq_info::out) is det.
+:- pred mq_info_set_error_context(error_context::in,
+ mq_info::in, mq_info::out) is det.
-mq_info_set_imported_modules(MQInfo,
- ImportedModules, MQInfo^imported_modules := ImportedModules).
-mq_info_set_interface_visible_modules(MQInfo,
- ImportedModules, MQInfo^interface_visible_modules := ImportedModules).
-mq_info_set_modules(MQInfo, Modules, MQInfo^modules := Modules).
-mq_info_set_types(MQInfo, Types, MQInfo^types := Types).
-mq_info_set_impl_types(MQInfo, Types, MQInfo^impl_types := Types).
-mq_info_set_insts(MQInfo, Insts, MQInfo^insts := Insts).
-mq_info_set_modes(MQInfo, Modes, MQInfo^modes := Modes).
-mq_info_set_classes(MQInfo, Classes, MQInfo^classes := Classes).
-mq_info_set_unused_interface_modules(MQInfo,
- Modules, MQInfo^unused_interface_modules := Modules).
-mq_info_set_import_status(MQInfo, Status, MQInfo^import_status := Status).
-mq_info_set_type_error_flag(MQInfo, MQInfo^type_error_flag := yes).
-mq_info_set_mode_error_flag(MQInfo, MQInfo^mode_error_flag := yes).
-mq_info_set_error_context(MQInfo, Context, MQInfo^error_context := Context).
-mq_info_set_need_qual_flag(MQInfo, Flag, MQInfo^need_qual_flag := Flag).
-mq_info_set_recompilation_info(Info, RecompInfo,
- Info ^ maybe_recompilation_info := RecompInfo).
+mq_info_set_imported_modules(ImportedModules, Info,
+ Info ^ imported_modules := ImportedModules).
+mq_info_set_interface_visible_modules(ImportedModules, Info,
+ Info ^ interface_visible_modules := ImportedModules).
+mq_info_set_modules(Modules, Info, Info ^ modules := Modules).
+mq_info_set_types(Types, Info, Info ^ types := Types).
+mq_info_set_impl_types(Types, Info, Info ^ impl_types := Types).
+mq_info_set_insts(Insts, Info, Info ^ insts := Insts).
+mq_info_set_modes(Modes, Info, Info ^ modes := Modes).
+mq_info_set_classes(Classes, Info, Info ^ classes := Classes).
+mq_info_set_unused_interface_modules(Modules, Info,
+ Info ^ unused_interface_modules := Modules).
+mq_info_set_import_status(Status, Info, Info ^ import_status := Status).
+mq_info_set_type_error_flag(Info, Info ^ type_error_flag := yes).
+mq_info_set_mode_error_flag(Info, Info ^ mode_error_flag := yes).
+mq_info_set_error_context(Context, Info, Info ^ error_context := Context).
+mq_info_set_need_qual_flag(Flag, Info, Info ^ need_qual_flag := Flag).
+mq_info_set_recompilation_info(RecompInfo, Info,
+ Info ^ maybe_recompilation_info := RecompInfo).
:- pred mq_info_incr_errors(mq_info::in, mq_info::out) is det.
-mq_info_incr_errors(MQInfo, MQInfo^num_errors := (MQInfo^num_errors +1)).
+mq_info_incr_errors(Info, Info ^ num_errors := (Info ^ num_errors +1)).
-:- pred mq_info_set_error_flag(mq_info::in, id_type::in, mq_info::out) is det.
+:- pred mq_info_set_error_flag(id_type::in, mq_info::in, mq_info::out) is det.
-mq_info_set_error_flag(Info0, IdType, Info) :-
- mq_info_set_error_flag_2(Info0, IdType, Info).
+mq_info_set_error_flag(IdType, !Info) :-
+ mq_info_set_error_flag_2(IdType, !Info).
-:- pred mq_info_set_error_flag_2(mq_info::in,
- id_type::in, mq_info::out) is det.
-
-mq_info_set_error_flag_2(Info0, type_id, Info) :-
- mq_info_set_type_error_flag(Info0, Info).
-mq_info_set_error_flag_2(Info0, mode_id, Info) :-
- mq_info_set_mode_error_flag(Info0, Info).
-mq_info_set_error_flag_2(Info0, inst_id, Info) :-
- mq_info_set_mode_error_flag(Info0, Info).
-mq_info_set_error_flag_2(Info0, class_id, Info) :-
- mq_info_set_type_error_flag(Info0, Info).
+:- pred mq_info_set_error_flag_2(id_type::in, mq_info::in, mq_info::out)
+ is det.
+
+mq_info_set_error_flag_2(type_id, !Info) :-
+ mq_info_set_type_error_flag(!Info).
+mq_info_set_error_flag_2(mode_id, !Info) :-
+ mq_info_set_mode_error_flag(!Info).
+mq_info_set_error_flag_2(inst_id, !Info) :-
+ mq_info_set_mode_error_flag(!Info).
+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).
-:- pred mq_info_set_module_used(mq_info::in, module_name::in,
- mq_info::out) is det.
+:- pred mq_info_set_module_used(module_name::in, mq_info::in, mq_info::out)
+ is det.
-mq_info_set_module_used(Info0, Module, Info) :-
- ( mq_info_get_import_status(Info0, exported) ->
- mq_info_get_unused_interface_modules(Info0, Modules0),
- set__delete(Modules0, Module, Modules),
- mq_info_set_unused_interface_modules(Info0, Modules, Info1),
+mq_info_set_module_used(Module, !Info) :-
+ ( mq_info_get_import_status(!.Info, exported) ->
+ mq_info_get_unused_interface_modules(!.Info, Modules0),
+ set.delete(Modules0, Module, Modules),
+ mq_info_set_unused_interface_modules(Modules, !Info),
(
Module = qualified(ParentModule, _),
- mq_info_set_module_used(Info1, ParentModule, Info)
+ mq_info_set_module_used(ParentModule, !Info)
;
- Module = unqualified(_),
- Info = Info1
+ Module = unqualified(_)
)
;
- Info = Info0
+ true
).
%----------------------------------------------------------------------------%
@@ -1710,46 +1650,46 @@
:- pred id_set_init(id_set::out) is det.
id_set_init(IdSet) :-
- map__init(IdSet).
+ map.init(IdSet).
% 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.
+:- 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").
-id_set_insert(NeedQualifier, qualified(Module, Name) - Arity, IdSet0, IdSet) :-
- ( map__search(IdSet0, Name - Arity, ImportModules0 - UseModules0) ->
+id_set_insert(NeedQualifier, qualified(Module, Name) - Arity, !IdSet) :-
+ ( map.search(!.IdSet, Name - Arity, ImportModules0 - UseModules0) ->
ImportModules1 = ImportModules0,
UseModules1 = UseModules0
;
- set__init(ImportModules1),
- set__init(UseModules1)
+ set.init(ImportModules1),
+ set.init(UseModules1)
),
(
NeedQualifier = must_be_qualified,
- set__insert(UseModules1, Module, UseModules),
+ set.insert(UseModules1, Module, UseModules),
ImportModules = ImportModules1
;
NeedQualifier = may_be_unqualified,
- set__insert(ImportModules1, Module, ImportModules),
+ set.insert(ImportModules1, Module, ImportModules),
UseModules = UseModules1
),
- map__set(IdSet0, Name - Arity, ImportModules - UseModules, IdSet).
+ map.set(!.IdSet, 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.
+ module_id_set::in, list(module_name)::out) is det.
id_set_search_sym_arity(IdSet, Sym, Arity, Modules, MatchingModules) :-
unqualify_name(Sym, UnqualName),
(
- map__search(IdSet, UnqualName - Arity,
+ map.search(IdSet, UnqualName - Arity,
ImportModules - UseModules)
->
(
Sym = unqualified(_),
- set__to_sorted_list(ImportModules, MatchingModules)
+ set.to_sorted_list(ImportModules, MatchingModules)
;
Sym = qualified(Module, _),
@@ -1766,7 +1706,7 @@
unqualify_name(Module, UnqualModule),
AppendModuleName = (pred(X::in, Y::out) is det :-
Y = qualified(X, UnqualModule)),
- list__map(AppendModuleName,
+ list.map(AppendModuleName,
MatchingParentModules,
MatchingNestedModules),
@@ -1780,16 +1720,16 @@
% second, compute the set of modules that define
% this symbol
%
- set__union(ImportModules, UseModules, DefiningModules),
+ set.union(ImportModules, UseModules, DefiningModules),
%
% third, take the intersection of the sets computed
% in the first two steps
%
FindMatch = (pred(MatchModule::out) is nondet :-
- list__member(MatchModule,
+ list.member(MatchModule,
AllMatchingModules),
- set__member(MatchModule, DefiningModules)
+ set.member(MatchModule, DefiningModules)
),
solutions(FindMatch, MatchingModules)
)
@@ -1810,21 +1750,21 @@
ModuleIdSet, [], PartialQualifiers)
).
-:- pred get_partial_qualifiers_2(module_name, module_name, module_id_set,
- list(module_name), list(module_name)).
-:- mode get_partial_qualifiers_2(in, in, in, in, out) is det.
+:- pred get_partial_qualifiers_2(module_name::in, module_name::in,
+ module_id_set::in, list(module_name)::in, list(module_name)::out)
+ is det.
get_partial_qualifiers_2(ImplicitPart, ExplicitPart, ModuleIdSet,
- Qualifiers0, Qualifiers) :-
+ !Qualifiers) :-
%
% if the ImplicitPart module was imported, rather than just being
% used, then insert the ExplicitPart module into the list of
% valid partial qualifiers.
%
( parent_module_is_imported(ImplicitPart, ExplicitPart, ModuleIdSet) ->
- Qualifiers1 = [ExplicitPart | Qualifiers0]
+ !:Qualifiers = [ExplicitPart | !.Qualifiers]
;
- Qualifiers1 = Qualifiers0
+ true
),
%
% recursively try to add the other possible partial qualifiers
@@ -1833,41 +1773,39 @@
NextImplicitPart = Parent,
insert_module_qualifier(Child, ExplicitPart, NextExplicitPart),
get_partial_qualifiers_2(NextImplicitPart, NextExplicitPart,
- ModuleIdSet, Qualifiers1, Qualifiers)
+ ModuleIdSet, !Qualifiers)
;
- Qualifiers = Qualifiers1
+ true
).
% Check whether the parent module was imported, given the name of a
% child (or grandchild, etc.) module occurring in that parent module.
%
-:- pred parent_module_is_imported(module_name, module_name, module_id_set).
-:- mode parent_module_is_imported(in, in, in) is semidet.
+:- pred parent_module_is_imported(module_name::in, module_name::in,
+ module_id_set::in) is semidet.
parent_module_is_imported(ParentModule, ChildModule, ModuleIdSet) :-
% Find the module name at the start of the ChildModule;
% this sub-module will be a direct sub-module of ParentModule
- get_first_module_name(ChildModule, DirectSubModuleName),
+ DirectSubModuleName = get_first_module_name(ChildModule),
% Check that the ParentModule was imported.
% We do this by looking up the definitions for the direct sub-module
% and checking that the one in ParentModule came from an
% imported module.
Arity = 0,
- map__search(ModuleIdSet, DirectSubModuleName - Arity,
- ImportModules - _UseModules),
- set__member(ParentModule, ImportModules).
+ map.search(ModuleIdSet, DirectSubModuleName - Arity,
+ ImportModules - _UseModules),
+ set.member(ParentModule, ImportModules).
% Given a module name, possibly module-qualified,
% return the name of the first module in the qualifier list.
% e.g. given `foo.bar.baz', this returns `foo',
% and given just `baz', it returns `baz'.
%
-:- pred get_first_module_name(module_name, string).
-:- mode get_first_module_name(in, out) is det.
+:- func get_first_module_name(module_name) = string.
-get_first_module_name(unqualified(ModuleName), ModuleName).
-get_first_module_name(qualified(Parent, _), ModuleName) :-
- get_first_module_name(Parent, ModuleName).
+get_first_module_name(unqualified(ModuleName)) = ModuleName.
+get_first_module_name(qualified(Parent, _)) = get_first_module_name(Parent).
%----------------------------------------------------------------------------%
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
Index: tests/invalid/cyclic_typeclass.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/cyclic_typeclass.err_exp,v
retrieving revision 1.1
diff -u -r1.1 cyclic_typeclass.err_exp
--- tests/invalid/cyclic_typeclass.err_exp 19 Jan 2005 05:53:06 -0000 1.1
+++ tests/invalid/cyclic_typeclass.err_exp 18 Mar 2005 13:03:31 -0000
@@ -1,4 +1,4 @@
cyclic_typeclass.m:030: Error: cyclic superclass relation detected:
-cyclic_typeclass.m:030: `cyclic_typeclass.bar/1' <= `cyclic_typeclass.foo/1'
-cyclic_typeclass.m:030: <= `cyclic_typeclass.bar/1'
+cyclic_typeclass.m:030: `cyclic_typeclass.bar'/1 <= `cyclic_typeclass.foo'/1
+cyclic_typeclass.m:030: <= `cyclic_typeclass.bar'/1
For more information, try recompiling with `-E'.
Index: tests/invalid/cyclic_typeclass_2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/cyclic_typeclass_2.err_exp,v
retrieving revision 1.1
diff -u -r1.1 cyclic_typeclass_2.err_exp
--- tests/invalid/cyclic_typeclass_2.err_exp 19 Jan 2005 05:53:06 -0000 1.1
+++ tests/invalid/cyclic_typeclass_2.err_exp 18 Mar 2005 13:03:31 -0000
@@ -1,5 +1,5 @@
cyclic_typeclass_2.m:014: Error: cyclic superclass relation detected:
-cyclic_typeclass_2.m:014: `cyclic_typeclass_2.bar/1' <=
-cyclic_typeclass_2.m:014: `cyclic_typeclass_2.foo/1' <=
-cyclic_typeclass_2.m:014: `cyclic_typeclass_2.bar/1'
+cyclic_typeclass_2.m:014: `cyclic_typeclass_2.bar'/1 <=
+cyclic_typeclass_2.m:014: `cyclic_typeclass_2.foo'/1 <=
+cyclic_typeclass_2.m:014: `cyclic_typeclass_2.bar'/1
For more information, try recompiling with `-E'.
Index: tests/invalid/cyclic_typeclass_3.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/cyclic_typeclass_3.err_exp,v
retrieving revision 1.1
diff -u -r1.1 cyclic_typeclass_3.err_exp
--- tests/invalid/cyclic_typeclass_3.err_exp 19 Jan 2005 05:53:07 -0000 1.1
+++ tests/invalid/cyclic_typeclass_3.err_exp 18 Mar 2005 13:03:32 -0000
@@ -1,11 +1,11 @@
cyclic_typeclass_3.m:014: Error: cyclic superclass relation detected:
-cyclic_typeclass_3.m:014: `cyclic_typeclass_3.c/1' <=
-cyclic_typeclass_3.m:014: `cyclic_typeclass_3.e/1' <=
-cyclic_typeclass_3.m:014: `cyclic_typeclass_3.i/1' <=
-cyclic_typeclass_3.m:014: `cyclic_typeclass_3.c/1'
+cyclic_typeclass_3.m:014: `cyclic_typeclass_3.c'/1 <=
+cyclic_typeclass_3.m:014: `cyclic_typeclass_3.e'/1 <=
+cyclic_typeclass_3.m:014: `cyclic_typeclass_3.i'/1 <=
+cyclic_typeclass_3.m:014: `cyclic_typeclass_3.c'/1
cyclic_typeclass_3.m:012: Error: cyclic superclass relation detected:
-cyclic_typeclass_3.m:012: `cyclic_typeclass_3.a/1' <=
-cyclic_typeclass_3.m:012: `cyclic_typeclass_3.b/1' <=
-cyclic_typeclass_3.m:012: `cyclic_typeclass_3.g/1' <=
-cyclic_typeclass_3.m:012: `cyclic_typeclass_3.a/1'
+cyclic_typeclass_3.m:012: `cyclic_typeclass_3.a'/1 <=
+cyclic_typeclass_3.m:012: `cyclic_typeclass_3.b'/1 <=
+cyclic_typeclass_3.m:012: `cyclic_typeclass_3.g'/1 <=
+cyclic_typeclass_3.m:012: `cyclic_typeclass_3.a'/1
For more information, try recompiling with `-E'.
Index: tests/invalid/errors.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/errors.err_exp,v
retrieving revision 1.10
diff -u -r1.10 errors.err_exp
--- tests/invalid/errors.err_exp 14 Feb 2005 08:26:37 -0000 1.10
+++ tests/invalid/errors.err_exp 18 Mar 2005 13:03:35 -0000
@@ -4,9 +4,11 @@
errors.m:001: Warning: interface for module `errors' does not export anything.
errors.m:001: Warning: module `int' is imported using both
errors.m:001: `:- import_module' and `:- use_module' declarations.
-errors.m:051: In definition of type `errors.du_type_which_references_undefined_type'/0:
+errors.m:051: In definition of type
+errors.m:051: `errors.du_type_which_references_undefined_type'/0:
errors.m:051: error: undefined type `undefined_type'/0.
-errors.m:053: In definition of type `errors.eqv_type_which_references_undefined_type'/0:
+errors.m:053: In definition of type
+errors.m:053: `errors.eqv_type_which_references_undefined_type'/0:
errors.m:053: error: undefined type `undefined_type'/0.
errors.m:100: In definition of type `errors.needs_qualification'/0:
errors.m:100: error: undefined type `state'/0.
Index: tests/invalid/errors1.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/errors1.err_exp,v
retrieving revision 1.7
diff -u -r1.7 errors1.err_exp
--- tests/invalid/errors1.err_exp 14 Feb 2005 08:26:37 -0000 1.7
+++ tests/invalid/errors1.err_exp 18 Mar 2005 13:03:35 -0000
@@ -1,8 +1,10 @@
errors1.m:001: Warning: interface for module `errors1' does not export
errors1.m:001: anything.
-errors1.m:051: In definition of type `errors1.du_type_which_references_undefined_type'/0:
+errors1.m:051: In definition of type
+errors1.m:051: `errors1.du_type_which_references_undefined_type'/0:
errors1.m:051: error: undefined type `undefined_type'/0.
-errors1.m:053: In definition of type `errors1.eqv_type_which_references_undefined_type'/0:
+errors1.m:053: In definition of type
+errors1.m:053: `errors1.eqv_type_which_references_undefined_type'/0:
errors1.m:053: error: undefined type `undefined_type'/0.
errors1.m:055: Error: circular equivalence type `errors1.circular_eqv_type/0'.
errors1.m:057: Error: circular equivalence type
Index: tests/invalid/inline_conflict.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/inline_conflict.err_exp,v
retrieving revision 1.3
diff -u -r1.3 inline_conflict.err_exp
--- tests/invalid/inline_conflict.err_exp 14 Feb 2005 08:26:37 -0000 1.3
+++ tests/invalid/inline_conflict.err_exp 18 Mar 2005 13:03:45 -0000
@@ -1,3 +1,3 @@
inline_conflict.m:016: Error: `:- pragma no_inline' declaration conflicts with
-inline_conflict.m:016: previous pragma for `inline_conflict.bar/2'.
+inline_conflict.m:016: previous pragma for `inline_conflict.bar'/2.
For more information, try recompiling with `-E'.
Index: tests/invalid/invalid_typeclass.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/invalid_typeclass.err_exp,v
retrieving revision 1.3
diff -u -r1.3 invalid_typeclass.err_exp
--- tests/invalid/invalid_typeclass.err_exp 14 Feb 2005 08:26:38 -0000 1.3
+++ tests/invalid/invalid_typeclass.err_exp 18 Mar 2005 13:03:47 -0000
@@ -1,8 +1,8 @@
invalid_typeclass.m:011: Error: expected distinct variables as class parameters: class3(_1, _1).
-invalid_typeclass.m:017: Error: typeclass `invalid_typeclass.class2/1' multiply
+invalid_typeclass.m:017: Error: typeclass `invalid_typeclass.class2'/1 multiply
invalid_typeclass.m:017: defined.
invalid_typeclass.m:009: Here is the previous definition of typeclass
-invalid_typeclass.m:009: `invalid_typeclass.class2/1'.
+invalid_typeclass.m:009: `invalid_typeclass.class2'/1.
invalid_typeclass.m:017: The superclass constraints do not match.
invalid_typeclass.m:007: Error: no definition for typeclass
invalid_typeclass.m:007: `invalid_typeclass.class/1'.
Index: tests/invalid/missing_interface_import.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/missing_interface_import.err_exp,v
retrieving revision 1.5
diff -u -r1.5 missing_interface_import.err_exp
--- tests/invalid/missing_interface_import.err_exp 4 Dec 2003 12:06:20 -0000 1.5
+++ tests/invalid/missing_interface_import.err_exp 18 Mar 2005 13:03:52 -0000
@@ -1,11 +1,17 @@
-missing_interface_import.m:007: In definition of type `missing_interface_import.bar'/0:
-missing_interface_import.m:007: error: undefined type `map'/2
-missing_interface_import.m:007: (the module `map' has not been imported in the interface).
-missing_interface_import.m:009: In definition of predicate `missing_interface_import.p'/1:
-missing_interface_import.m:009: error: undefined type `std_util.univ'/0
-missing_interface_import.m:009: (the module `std_util' has not been imported in the interface).
-missing_interface_import.m:010: In definition of predicate `missing_interface_import.q'/1:
-missing_interface_import.m:010: error: undefined type `list'/1
-missing_interface_import.m:010: (the module `list' has not been imported in the interface).
+missing_interface_import.m:007: In definition of type
+missing_interface_import.m:007: `missing_interface_import.bar'/0:
+missing_interface_import.m:007: error: undefined type `map'/2.
+missing_interface_import.m:007: (The module `map' has not been imported in
+missing_interface_import.m:007: the interface.)
+missing_interface_import.m:009: In definition of predicate
+missing_interface_import.m:009: `missing_interface_import.p'/1:
+missing_interface_import.m:009: error: undefined type `std_util.univ'/0.
+missing_interface_import.m:009: (The module `std_util' has not been imported
+missing_interface_import.m:009: in the interface.)
+missing_interface_import.m:010: In definition of predicate
+missing_interface_import.m:010: `missing_interface_import.q'/1:
+missing_interface_import.m:010: error: undefined type `list'/1.
+missing_interface_import.m:010: (The module `list' has not been imported in
+missing_interface_import.m:010: the interface.)
`missing_interface_import.int' not written.
For more information, try recompiling with `-E'.
Index: tests/invalid/missing_interface_import2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/missing_interface_import2.err_exp,v
retrieving revision 1.1
diff -u -r1.1 missing_interface_import2.err_exp
--- tests/invalid/missing_interface_import2.err_exp 1 Dec 2003 15:56:11 -0000 1.1
+++ tests/invalid/missing_interface_import2.err_exp 18 Mar 2005 13:03:09 -0000
@@ -1,10 +1,17 @@
-missing_interface_import2.m:009: In definition of predicate `missing_interface_import2.write_key'/3:
-missing_interface_import2.m:009: error: undefined type `key'/0
-missing_interface_import2.m:009: (the modules `group' and `missing_interface_import3' have not been imported in the interface).
-missing_interface_import2.m:009: In definition of predicate `missing_interface_import2.write_key'/3:
-missing_interface_import2.m:009: error: undefined type `io.state'/0
-missing_interface_import2.m:009: (the module `io' has not been imported in the interface).
-missing_interface_import2.m:009: In definition of predicate `missing_interface_import2.write_key'/3:
-missing_interface_import2.m:009: error: undefined type `io.state'/0
-missing_interface_import2.m:009: (the module `io' has not been imported in the interface).
+missing_interface_import2.m:009: In definition of predicate
+missing_interface_import2.m:009: `missing_interface_import2.write_key'/3:
+missing_interface_import2.m:009: error: undefined type `key'/0.
+missing_interface_import2.m:009: (The modules `group' and
+missing_interface_import2.m:009: `missing_interface_import3' have not been
+missing_interface_import2.m:009: imported in the interface.)
+missing_interface_import2.m:009: In definition of predicate
+missing_interface_import2.m:009: `missing_interface_import2.write_key'/3:
+missing_interface_import2.m:009: error: undefined type `io.state'/0.
+missing_interface_import2.m:009: (The module `io' has not been imported in
+missing_interface_import2.m:009: the interface.)
+missing_interface_import2.m:009: In definition of predicate
+missing_interface_import2.m:009: `missing_interface_import2.write_key'/3:
+missing_interface_import2.m:009: error: undefined type `io.state'/0.
+missing_interface_import2.m:009: (The module `io' has not been imported in
+missing_interface_import2.m:009: the interface.)
For more information, try recompiling with `-E'.
Index: tests/invalid/test_nested.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/test_nested.err_exp,v
retrieving revision 1.3
diff -u -r1.3 test_nested.err_exp
--- tests/invalid/test_nested.err_exp 17 Jan 2003 05:57:09 -0000 1.3
+++ tests/invalid/test_nested.err_exp 18 Mar 2005 13:03:14 -0000
@@ -8,6 +8,7 @@
test_nested.m:013: error in `use_module' declaration:
test_nested.m:013: module `parent2.child' is inaccessible.
test_nested.m:015: In definition of type `test_nested.foo'/0:
-test_nested.m:015: error: undefined type `parent.nonexistent_child.foo'/0
-test_nested.m:015: (the module `(parent.nonexistent_child)' has not been imported).
+test_nested.m:015: error: undefined type `parent.nonexistent_child.foo'/0.
+test_nested.m:015: (The module `parent.nonexistent_child' has not been
+test_nested.m:015: imported.)
For more information, try recompiling with `-E'.
Index: tests/invalid/transitive_import.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/transitive_import.err_exp,v
retrieving revision 1.2
diff -u -r1.2 transitive_import.err_exp
--- tests/invalid/transitive_import.err_exp 17 Jan 2003 05:57:09 -0000 1.2
+++ tests/invalid/transitive_import.err_exp 18 Mar 2005 13:03:15 -0000
@@ -1,7 +1,8 @@
transitive_import.m:016: In declaration of instance of typeclass `enum.enum'/1:
-transitive_import.m:016: error: undefined typeclass `enum.enum'/1
-transitive_import.m:016: (the module `enum' has not been imported).
-transitive_import.m:025: In definition of function `transitive_import.assoc_list_first'/1:
-transitive_import.m:025: error: undefined type `std_util.pair'/2
-transitive_import.m:025: (the module `std_util' has not been imported).
+transitive_import.m:016: error: undefined typeclass `enum.enum'/1.
+transitive_import.m:016: (The module `enum' has not been imported.)
+transitive_import.m:025: In definition of function
+transitive_import.m:025: `transitive_import.assoc_list_first'/3:
+transitive_import.m:025: error: undefined type `std_util.pair'/2.
+transitive_import.m:025: (The module `std_util' has not been imported.)
For more information, try recompiling with `-E'.
Index: tests/invalid/type_spec.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/type_spec.err_exp,v
retrieving revision 1.4
diff -u -r1.4 type_spec.err_exp
--- tests/invalid/type_spec.err_exp 14 Feb 2005 08:26:38 -0000 1.4
+++ tests/invalid/type_spec.err_exp 18 Mar 2005 13:04:31 -0000
@@ -1,9 +1,9 @@
type_spec.m:010: In `:- pragma type_spec' declaration for predicate `type_spec.type_spec1/1':
type_spec.m:010: error: variable `U' does not occur in the `:- pred' declaration.
type_spec.m:011: Error: `:- pragma type_spec' declaration for
-type_spec.m:011: `type_spec.type_spec1/1' specifies non-existent mode.
+type_spec.m:011: `type_spec.type_spec1'/1 specifies non-existent mode.
type_spec.m:013: Error: `:- pragma type_spec' declaration for
-type_spec.m:013: `type_spec.type_spec1/2' without corresponding `pred' or
+type_spec.m:013: `type_spec.type_spec1'/2 without corresponding `pred' or
type_spec.m:013: `func' declaration.
type_spec.m:024: In `:- pragma type_spec' declaration for predicate `type_spec.type_spec2/1':
type_spec.m:024: error: the substitution includes the existentially
Index: tests/invalid/typeclass_missing_mode.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/typeclass_missing_mode.err_exp,v
retrieving revision 1.2
diff -u -r1.2 typeclass_missing_mode.err_exp
--- tests/invalid/typeclass_missing_mode.err_exp 17 Jan 2003 05:57:10 -0000 1.2
+++ tests/invalid/typeclass_missing_mode.err_exp 18 Mar 2005 13:04:14 -0000
@@ -1,3 +1,3 @@
typeclass_missing_mode.m:007: Error: no mode declaration for type class method
-typeclass_missing_mode.m:007: predicate `typeclass_missing_mode.p/1'.
+typeclass_missing_mode.m:007: predicate `typeclass_missing_mode.p'/1.
For more information, try recompiling with `-E'.
Index: tests/invalid/typeclass_missing_mode_2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/typeclass_missing_mode_2.err_exp,v
retrieving revision 1.3
diff -u -r1.3 typeclass_missing_mode_2.err_exp
--- tests/invalid/typeclass_missing_mode_2.err_exp 14 Feb 2005 08:26:38 -0000 1.3
+++ tests/invalid/typeclass_missing_mode_2.err_exp 18 Mar 2005 13:04:14 -0000
@@ -1,6 +1,6 @@
typeclass_missing_mode_2.m:011: Error: no mode declaration for type class
typeclass_missing_mode_2.m:011: method predicate
-typeclass_missing_mode_2.m:011: `typeclass_missing_mode_2.p/1'.
+typeclass_missing_mode_2.m:011: `typeclass_missing_mode_2.p'/1.
typeclass_missing_mode_2.m:013: In instance declaration for
typeclass_missing_mode_2.m:013: `typeclass_missing_mode_2.c/1': incorrect
typeclass_missing_mode_2.m:013: method name(s): predicate
Index: tests/invalid/typeclass_test_10.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/typeclass_test_10.err_exp,v
retrieving revision 1.1
diff -u -r1.1 typeclass_test_10.err_exp
--- tests/invalid/typeclass_test_10.err_exp 12 Feb 2003 22:58:19 -0000 1.1
+++ tests/invalid/typeclass_test_10.err_exp 19 Mar 2005 00:14:28 -0000
@@ -1,7 +1,6 @@
typeclass_test_10.m:001: In module `typeclass_test_10':
-typeclass_test_10.m:001: warning: module `std_util'
-typeclass_test_10.m:001: is imported in the interface, but is not
-typeclass_test_10.m:001: used in the interface.
+typeclass_test_10.m:001: warning: module `std_util' is imported in the
+typeclass_test_10.m:001: interface, but is not used in the interface.
typeclass_test_10.m:006: In instance declaration for `typeclass_test_10.bar/1':
typeclass_test_10.m:006: incorrect method name(s): predicate
typeclass_test_10.m:006: `typeclass_test_10.p/0' .
Index: tests/invalid/typeclass_test_9.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/typeclass_test_9.err_exp,v
retrieving revision 1.6
diff -u -r1.6 typeclass_test_9.err_exp
--- tests/invalid/typeclass_test_9.err_exp 14 Feb 2005 08:26:38 -0000 1.6
+++ tests/invalid/typeclass_test_9.err_exp 19 Mar 2005 00:14:30 -0000
@@ -1,7 +1,6 @@
typeclass_test_9.m:001: In module `typeclass_test_9':
-typeclass_test_9.m:001: warning: module `std_util'
-typeclass_test_9.m:001: is imported in the interface, but is not
-typeclass_test_9.m:001: used in the interface.
+typeclass_test_9.m:001: warning: module `std_util' is imported in the
+typeclass_test_9.m:001: interface, but is not used in the interface.
typeclass_test_9.m:004: In declaration for predicate `typeclass_test_9.p/0':
typeclass_test_9.m:004: error in type class constraints: type variable `T'
typeclass_test_9.m:004: occurs only in the constraints, not in the
@@ -11,6 +10,6 @@
typeclass_test_9.m:006: occurs only in the constraints, not in the
typeclass_test_9.m:006: predicate's argument types.
typeclass_test_9.m:010: Error: multiply defined (or overlapping) instance
-typeclass_test_9.m:010: declarations for class `typeclass_test_9.foo/1'.
+typeclass_test_9.m:010: declarations for class `typeclass_test_9.foo'/1.
typeclass_test_9.m:007: Previous instance declaration was here.
For more information, try recompiling with `-E'.
Index: tests/invalid/undef_mode_and_no_clauses.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/undef_mode_and_no_clauses.err_exp,v
retrieving revision 1.3
diff -u -r1.3 undef_mode_and_no_clauses.err_exp
--- tests/invalid/undef_mode_and_no_clauses.err_exp 14 May 2004 08:40:32 -0000 1.3
+++ tests/invalid/undef_mode_and_no_clauses.err_exp 18 Mar 2005 13:04:24 -0000
@@ -1,4 +1,5 @@
-undef_mode_and_no_clauses.m:012: In mode declaration for predicate `undef_mode_and_no_clauses.p'/2:
+undef_mode_and_no_clauses.m:012: In mode declaration for predicate
+undef_mode_and_no_clauses.m:012: `undef_mode_and_no_clauses.p'/2:
undef_mode_and_no_clauses.m:012: error: undefined mode `result'/1.
undef_mode_and_no_clauses.m:011: Error: no clauses for predicate `p/2'.
For more information, try recompiling with `-E'.
Index: tests/invalid/undef_type.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/undef_type.err_exp,v
retrieving revision 1.7
diff -u -r1.7 undef_type.err_exp
--- tests/invalid/undef_type.err_exp 19 Mar 2004 10:19:53 -0000 1.7
+++ tests/invalid/undef_type.err_exp 18 Mar 2005 13:04:25 -0000
@@ -5,6 +5,6 @@
undef_type.m:010: In definition of predicate `undef_type.q'/1:
undef_type.m:010: error: undefined type `undef2'/0.
undef_type.m:013: In definition of predicate `undef_type.r'/1:
-undef_type.m:013: error: undefined type `io.state'/0
-undef_type.m:013: (the module `io' has not been imported).
+undef_type.m:013: error: undefined type `io.state'/0.
+undef_type.m:013: (The module `io' has not been imported.)
For more information, try recompiling with `-E'.
Index: tests/invalid/undef_type_mod_qual.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/undef_type_mod_qual.err_exp,v
retrieving revision 1.2
diff -u -r1.2 undef_type_mod_qual.err_exp
--- tests/invalid/undef_type_mod_qual.err_exp 17 Jan 2003 05:57:10 -0000 1.2
+++ tests/invalid/undef_type_mod_qual.err_exp 18 Mar 2005 13:04:26 -0000
@@ -1,3 +1,5 @@
-undef_type_mod_qual.m:005: In definition of predicate `undef_type_mod_qual.blah'/1:
-undef_type_mod_qual.m:005: error: undefined type `undef_type_mod_qual.undefined_type'/0.
+undef_type_mod_qual.m:005: In definition of predicate
+undef_type_mod_qual.m:005: `undef_type_mod_qual.blah'/1:
+undef_type_mod_qual.m:005: error: undefined type
+undef_type_mod_qual.m:005: `undef_type_mod_qual.undefined_type'/0.
For more information, try recompiling with `-E'.
cvs diff: Diffing tests/invalid/purity
Index: tests/invalid/purity/purity_nonsense2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/purity/purity_nonsense2.err_exp,v
retrieving revision 1.2
diff -u -r1.2 purity_nonsense2.err_exp
--- tests/invalid/purity/purity_nonsense2.err_exp 14 Feb 2005 08:26:42 -0000 1.2
+++ tests/invalid/purity/purity_nonsense2.err_exp 18 Mar 2005 13:04:42 -0000
@@ -1,7 +1,7 @@
purity_nonsense2.m:005: Syntax error at token 'type': unexpected token at start of (sub)term.
purity_nonsense2.m:006: Syntax error at token 'mode': unexpected token at start of (sub)term.
purity_nonsense2.m:010: Error: `:- pragma promise_pure' declaration for
-purity_nonsense2.m:010: `purity_nonsense2.undefined2/0' without corresponding
+purity_nonsense2.m:010: `purity_nonsense2.undefined2'/0 without corresponding
purity_nonsense2.m:010: `pred' or `func' declaration.
purity_nonsense2.m:012: Error: clause for predicate `purity_nonsense2.e12/0'
purity_nonsense2.m:012: without preceding `pred' declaration.
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
Index: tests/recompilation/add_type_re.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/add_type_re.err_exp.2,v
retrieving revision 1.2
diff -u -r1.2 add_type_re.err_exp.2
--- tests/recompilation/add_type_re.err_exp.2 18 Jan 2003 17:02:10 -0000 1.2
+++ tests/recompilation/add_type_re.err_exp.2 18 Mar 2005 13:08:09 -0000
@@ -2,7 +2,8 @@
addition of type `add_type_re_2.bar/0' could cause an ambiguity with type
`add_type_re.bar/0'.
add_type_re.m:029: In definition of predicate `add_type_re.output_bar'/3
-add_type_re.m:029: ambiguity error: multiple possible matches for type `bar'/0.
-add_type_re.m:029: The possible matches are in modules
-add_type_re.m:029: `add_type_re' and `add_type_re_2'.
+add_type_re.m:029: ambiguity error: multiple possible matches for type
+add_type_re.m:029: `bar'/0.
+add_type_re.m:029: The possible matches are in modules `add_type_re'
+add_type_re.m:029: `add_type_re_2'.
For more information, try recompiling with `-E'.
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
Index: tests/warnings/unused_import.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/unused_import.exp,v
retrieving revision 1.4
diff -u -r1.4 unused_import.exp
--- tests/warnings/unused_import.exp 3 Mar 1998 17:48:14 -0000 1.4
+++ tests/warnings/unused_import.exp 18 Mar 2005 15:01:30 -0000
@@ -1,4 +1,3 @@
unused_import.m:001: In module `unused_import':
-unused_import.m:001: warning: modules `float' and `list'
-unused_import.m:001: are imported in the interface, but are not
-unused_import.m:001: used in the interface.
+unused_import.m:001: warning: modules `float' and `list' are imported in the
+unused_import.m:001: interface, but are not used in the interface.
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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