[m-rev.] diff: more cleanups, part 3
Zoltan Somogyi
zs at cs.mu.OZ.AU
Mon Apr 5 15:05:52 AEST 2004
Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.465
diff -u -b -r1.465 make_hlds.m
--- compiler/make_hlds.m 24 Mar 2004 00:39:28 -0000 1.465
+++ compiler/make_hlds.m 4 Apr 2004 07:44:01 -0000
@@ -82,15 +82,15 @@
pred_or_func::in, arity::in, list(type)::in, pred_markers::in,
term__context::in, import_status::in, clauses_info::out,
module_info::in, module_info::out, qual_info::in, qual_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
% Move the recompilation_info from the qual_info to the module_info
% after make_hlds is finished with it and the qual_info is dead.
:- pred set_module_recompilation_info(qual_info::in,
module_info::in, module_info::out) is det.
-:- pred next_mode_id(proc_table, maybe(determinism), proc_id).
-:- mode next_mode_id(in, in, out) is det.
+:- pred next_mode_id(proc_table::in, maybe(determinism)::in, proc_id::out)
+ is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -212,7 +212,7 @@
Module = !.Module
).
-:- pred check_for_errors(pred(module_info, module_info, io__state, io__state)
+:- pred check_for_errors(pred(module_info, module_info, io, io)
::pred(in, out, di, uo) is det, bool::out,
module_info::in, module_info::out, io::di, io::uo) is det.
@@ -285,8 +285,7 @@
% sure that there isn't a mode declaration for the function.
:- pred add_item_list_decls_pass_2(item_list::in, item_status::in,
- module_info::in, module_info::out, io__state::di, io__state::uo)
- is det.
+ module_info::in, module_info::out, io::di, io::uo) is det.
add_item_list_decls_pass_2([], _, !Module, !IO).
add_item_list_decls_pass_2([Item - Context | Items], Status0, !Module, !IO) :-
@@ -300,9 +299,9 @@
% Check that the declarations for field extraction
% and update functions are sensible.
-:- pred add_item_list_clauses(item_list::in, import_status::in, module_info::in,
- module_info::out, qual_info::in, qual_info::out,
- io__state::di, io__state::uo) is det.
+:- pred add_item_list_clauses(item_list::in, import_status::in,
+ module_info::in, module_info::out, qual_info::in, qual_info::out,
+ io::di, io::uo) is det.
add_item_list_clauses([], _Status, !Module, !Info, !IO).
add_item_list_clauses([Item - Context | Items], Status0, !Module, !Info,
@@ -317,7 +316,7 @@
:- pred add_item_decl_pass_1(item::in, prog_context::in,
item_status::in, item_status::out, module_info::in, module_info::out,
- bool::out, io__state::di, io__state::uo) is det.
+ bool::out, io::di, io::uo) is det.
% Dispatch on the different types of items.
@@ -437,7 +436,7 @@
:- pred add_item_decl_pass_2(item::in, prog_context::in, item_status::in,
item_status::out, module_info::in, module_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
add_item_decl_pass_2(module_defn(_VarSet, ModuleDefn), _Context,
!Status, !Module, !IO) :-
@@ -694,8 +693,7 @@
% so that the procedures are not ignored by the code
% generation annotation passes (e.g. arg_info.m).
:- pred maybe_enable_aditi_compilation(item_status::in, term__context::in,
- module_info::in, module_info::out, io__state::di, io__state::uo)
- is det.
+ module_info::in, module_info::out, io::di, io::uo) is det.
maybe_enable_aditi_compilation(_Status, Context, !Module, !IO) :-
globals__io_lookup_bool_option(aditi, Aditi, !IO),
@@ -718,7 +716,7 @@
:- pred add_item_clause(item::in, import_status::in, import_status::out,
prog_context::in, module_info::in, module_info::out,
- qual_info::in, qual_info::out, io__state::di, io__state::uo) is det.
+ qual_info::in, qual_info::out, io::di, io::uo) is det.
add_item_clause(clause(VarSet, PredOrFunc, PredName, Args, Body),
!Status, Context, !Module, !Info, !IO) :-
@@ -874,7 +872,7 @@
:- pred add_promise_clause(promise_type::in, list(term(prog_var_type))::in,
prog_varset::in, goal::in, prog_context::in, import_status::in,
module_info::in, module_info::out, qual_info::in, qual_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
add_promise_clause(PromiseType, HeadVars, VarSet, Goal, Context, Status,
!Module, !Info, !IO) :-
@@ -904,7 +902,7 @@
%-----------------------------------------------------------------------------%
:- pred check_not_exported(import_status::in, prog_context::in, string::in,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
check_not_exported(Status, Context, Message, !IO) :-
%
@@ -1074,8 +1072,7 @@
:- pred add_pragma_unused_args(pred_or_func::in, sym_name::in, arity::in,
mode_num::in, list(int)::in, prog_context::in,
- module_info::in, module_info::out, io__state::di, io__state::uo)
- is det.
+ module_info::in, module_info::out, io::di, io::uo) is det.
add_pragma_unused_args(PredOrFunc, SymName, Arity, ModeNum, UnusedArgs,
Context, !Module, !IO) :-
@@ -1102,7 +1099,7 @@
:- pred add_pragma_type_spec(pragma_type::in(type_spec), term__context::in,
module_info::in, module_info::out, qual_info::in, qual_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
add_pragma_type_spec(Pragma, Context, !Module, !Info, !IO) :-
Pragma = type_spec(SymName, _, Arity, MaybePredOrFunc, _, _, _, _),
@@ -1130,7 +1127,7 @@
:- pred add_pragma_type_spec_2(pragma_type::in(type_spec), prog_context::in,
pred_id::in, transform_info::in, transform_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
add_pragma_type_spec_2(Pragma0, Context, PredId,
transform_info(ModuleInfo0, Info0), TransformInfo, !IO) :-
@@ -1300,7 +1297,7 @@
assoc_list(tvar, type)::in, pred_info::in, tvarset::in, tvarset::out,
list(type)::out, existq_tvars::out, class_constraints::out,
maybe(tsubst)::out, module_info::in, module_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
handle_pragma_type_spec_subst(Context, Subst, PredInfo0, TVarSet0, TVarSet,
Types, ExistQVars, ClassContext, SubstOk, !ModuleInfo, !IO) :-
@@ -1563,7 +1560,7 @@
list(mode)::in, maybe(pragma_arg_size_info)::in,
maybe(pragma_termination_info)::in,
prog_context::in, module_info::in, module_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
add_pragma_termination_info(PredOrFunc, SymName, ModeList,
MaybePragmaArgSizeInfo, MaybePragmaTerminationInfo,
@@ -1672,8 +1669,7 @@
% an error.
:- pred add_pred_marker(string::in, sym_name::in, arity::in, import_status::in,
prog_context::in, marker::in, list(marker)::in,
- module_info::in, module_info::out, io__state::di, io__state::uo)
- is det.
+ module_info::in, module_info::out, io::di, io::uo) is det.
add_pred_marker(PragmaName, Name, Arity, Status, Context, Marker,
ConflictMarkers, !Module, !IO) :-
@@ -1695,7 +1691,7 @@
:- pred set_pred_owner(sym_name::in, arity::in, string::in, import_status::in,
prog_context::in, module_info::in, module_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
set_pred_owner(Name, Arity, Owner, Status, Context, !Module, !IO) :-
SetOwner = (pred(PredInfo0::in, PredInfo::out) is det :-
@@ -1707,7 +1703,7 @@
:- pred add_base_relation_index(sym_name::in, arity::in, index_spec::in,
import_status::in, prog_context::in, module_info::in, module_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
add_base_relation_index(Name, Arity, Index, Status, Context, !Module, !IO) :-
AddIndex = (pred(PredInfo0::in, PredInfo::out) is det :-
@@ -1726,7 +1722,7 @@
% Check that the index attributes are legal for the predicate's arity.
:- pred check_index_attribute(sym_name::in, arity::in, term__context::in,
- int::in, io__state::di, io__state::uo) is det.
+ int::in, io::di, io::uo) is det.
check_index_attribute(Name, Arity, Context, Attr, !IO) :-
( ( Attr > 0, Attr =< Arity ) ->
@@ -1747,8 +1743,7 @@
% Check that a relation with an index specified is a base relation
% and that the indexed attributes do not include aditi__states.
:- pred check_index_attribute_pred(module_info::in, sym_name::in, arity::in,
- term__context::in, list(int)::in, pred_id::in,
- io__state::di, io__state::uo) is det.
+ term__context::in, list(int)::in, pred_id::in, io::di, io::uo) is det.
check_index_attribute_pred(ModuleInfo, Name, Arity, Context, Attrs, PredId,
!IO) :-
@@ -1803,7 +1798,7 @@
import_status::in, bool::in, term__context::in,
add_marker_pred_info::in(add_marker_pred_info),
module_info::in, module_info::out, list(pred_id)::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
do_add_pred_marker(PragmaName, Name, Arity, Status, MustBeExported, Context,
UpdatePredInfo, !Module, PredIds, !IO) :-
@@ -2046,7 +2041,7 @@
:- type id == pair(sym_name, arity).
:- pred report_circular_equiv_error(string::in, id::in, id::in, list(id)::in,
- prog_context::in, io__state::di, io__state::uo) is det.
+ prog_context::in, io::di, io::uo) is det.
report_circular_equiv_error(Kind, OrigId, Id, Expansions, Context, !IO) :-
( Id = OrigId ->
@@ -2358,7 +2353,7 @@
% Add the constructors and special preds for a type to the HLDS.
:- pred process_type_defn(type_ctor::in, hlds_type_defn::in,
bool::in, bool::out, module_info::in, module_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
process_type_defn(TypeCtor, TypeDefn, !FoundError, !Module, !IO) :-
hlds_data__get_type_defn_context(TypeDefn, Context),
@@ -2845,8 +2840,7 @@
maybe(determinism)::in, condition::in, purity::in,
class_constraints::in, pred_markers::in, prog_context::in,
item_status::in, maybe(pair(pred_id, proc_id))::out,
- module_info::in, module_info::out, io__state::di, io__state::uo)
- is det.
+ module_info::in, module_info::out, io::di, io::uo) is det.
module_add_pred_or_func(TypeVarSet, InstVarSet, ExistQVars,
PredOrFunc, PredName, TypesAndModes, MaybeDet, Cond, Purity,
@@ -2903,7 +2897,7 @@
:- pred module_add_class_defn(list(class_constraint)::in, sym_name::in,
list(tvar)::in, class_interface::in, tvarset::in, prog_context::in,
item_status::in, module_info::in, module_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
module_add_class_defn(Constraints, Name, Vars, Interface, VarSet, Context,
Status, !Module, !IO) :-
@@ -3046,8 +3040,7 @@
:- pred module_add_class_interface(sym_name::in, list(tvar)::in,
list(class_method)::in, item_status::in,
list(maybe(pair(pred_id, proc_id)))::out,
- module_info::in, module_info::out, io__state::di, io__state::uo)
- is det.
+ module_info::in, module_info::out, io::di, io::uo) is det.
module_add_class_interface(Name, Vars, Methods, Status, PredProcIds,
!Module, !IO) :-
@@ -3059,8 +3052,7 @@
:- pred module_add_class_interface_2(sym_name::in, list(tvar)::in,
list(class_method)::in, item_status::in,
list(maybe(pair(pred_id, proc_id)))::out,
- module_info::in, module_info::out, io__state::di, io__state::uo)
- is det.
+ module_info::in, module_info::out, io::di, io::uo) is det.
module_add_class_interface_2(_, _, [], _, [], !Module, !IO).
module_add_class_interface_2(Name, Vars, [M | Ms], Status, [P | Ps],
@@ -3070,8 +3062,7 @@
:- pred module_add_class_method(class_method::in, sym_name::in, list(tvar)::in,
item_status::in, maybe(pair(pred_id, proc_id))::out,
- module_info::in, module_info::out, io__state::di, io__state::uo)
- is det.
+ module_info::in, module_info::out, io::di, io::uo) is det.
module_add_class_method(Method, Name, Vars, Status, MaybePredIdProcId,
!Module, !IO) :-
@@ -3115,8 +3106,7 @@
:- pred check_method_modes(list(class_method)::in,
list(maybe(pair(pred_id, proc_id)))::in,
list(maybe(pair(pred_id, proc_id)))::out,
- module_info::in, module_info::out, io__state::di, io__state::uo)
- is det.
+ module_info::in, module_info::out, io::di, io::uo) is det.
check_method_modes([], !PredProcIds, !Module, !IO).
check_method_modes([Method | Methods], !PredProcIds, !Module, !IO) :-
@@ -3176,8 +3166,7 @@
:- pred module_add_instance_defn(module_name::in, list(class_constraint)::in,
sym_name::in, list(type)::in, instance_body::in, tvarset::in,
import_status::in, prog_context::in,
- module_info::in, module_info::out, io__state::di, io__state::uo)
- is det.
+ module_info::in, module_info::out, io::di, io::uo) is det.
module_add_instance_defn(InstanceModuleName, Constraints, ClassName,
Types, Body0, VarSet, Status, Context, !Module, !IO) :-
@@ -3248,8 +3237,7 @@
list(type)::in, condition::in, purity::in, class_constraints::in,
pred_markers::in, prog_context::in, import_status::in,
need_qualifier::in, pred_or_func::in,
- module_info::in, module_info::out, io__state::di, io__state::uo)
- is det.
+ module_info::in, module_info::out, io::di, io::uo) is det.
% NB. Predicates are also added in lambda.m, which converts
% lambda expressions into separate predicates, so any changes may need
@@ -3297,8 +3285,7 @@
module_info_pred_info(!.Module, OrigPred,
OrigPredInfo),
pred_info_context(OrigPredInfo, OrigContext),
- hlds_out__pred_or_func_to_str(PredOrFunc,
- DeclString),
+ DeclString = hlds_out__pred_or_func_to_str(PredOrFunc),
adjust_func_arity(PredOrFunc, OrigArity, Arity),
multiple_def_error(ItemStatus, PredName, OrigArity,
DeclString, Context, OrigContext, FoundError,
@@ -3468,7 +3455,7 @@
io::di, io::uo) is det.
report_field_status_mismatch(Context, CallId, !IO) :-
- hlds_out__simple_call_id_to_string(CallId, CallIdString),
+ CallIdString = hlds_out__simple_call_id_to_string(CallId),
ErrorPieces = [
words("In declaration of"),
fixed(string__append(CallIdString, ":")),
@@ -3901,7 +3888,7 @@
maybe(determinism)::in, condition::in, import_status::in,
prog_context::in, pred_or_func::in, bool::in,
pair(pred_id, proc_id)::out, module_info::in, module_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
% We should store the mode varset and the mode condition
% in the hlds - at the moment we just ignore those two arguments.
@@ -3945,8 +3932,7 @@
:- pred module_do_add_mode(inst_varset::in, arity::in, list(mode)::in,
maybe(determinism)::in, bool::in, prog_context::in,
- pred_info::in, pred_info::out, proc_id::out,
- io__state::di, io__state::uo) is det.
+ pred_info::in, pred_info::out, proc_id::out, io::di, io::uo) is det.
module_do_add_mode(InstVarSet, Arity, Modes, MaybeDet, IsClassMethod, MContext,
!PredInfo, ProcId, !IO) :-
@@ -3995,7 +3981,7 @@
:- pred preds_add_implicit_report_error(module_name::in, pred_or_func::in,
sym_name::in, arity::in, import_status::in, bool::in, prog_context::in,
string::in, pred_id::out, module_info::in, module_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
preds_add_implicit_report_error(ModuleName, PredOrFunc, PredName, Arity,
Status, IsClassMethod, Context, Description, PredId,
@@ -4088,7 +4074,7 @@
:- pred module_add_clause(prog_varset::in, pred_or_func::in, sym_name::in,
list(prog_term)::in, goal::in, import_status::in, prog_context::in,
goal_type::in, module_info::in, module_info::out,
- qual_info::in, qual_info::out, io__state::di, io__state::uo) is det.
+ qual_info::in, qual_info::out, io::di, io::uo) is det.
module_add_clause(ClauseVarSet, PredOrFunc, PredName, Args0, Body, Status,
Context, GoalType, !ModuleInfo, !Info, !IO) :-
@@ -4195,8 +4181,8 @@
Status \= opt_imported
->
module_info_incr_errors(!ModuleInfo),
- hlds_out__simple_call_id_to_string(
- PredOrFunc - PredName/Arity, CallIdString0),
+ CallIdString0 = hlds_out__simple_call_id_to_string(
+ PredOrFunc - PredName/Arity),
string__append(CallIdString0, ".", CallIdString),
ErrorPieces0 = [
words("Error: clause for automatically generated"),
@@ -4296,7 +4282,7 @@
import_status::in, prog_context::in, pred_id::in, pred_info::in,
list(prog_term)::out, list(proc_id)::out,
module_info::in, module_info::out, qual_info::in, qual_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
select_applicable_modes(Args0, VarSet, Status, Context, PredId, PredInfo,
Args, ProcIds, !ModuleInfo, !Info, !IO) :-
@@ -4483,8 +4469,7 @@
:- pred produce_instance_method_clause(pred_or_func::in,
prog_context::in, import_status::in, item::in,
module_info::in, module_info::out, qual_info::in, qual_info::out,
- clauses_info::in, clauses_info::out, io__state::di, io__state::uo)
- is det.
+ clauses_info::in, clauses_info::out, io::di, io::uo) is det.
produce_instance_method_clause(PredOrFunc, Context, Status, InstanceClause,
!ModuleInfo, !QualInfo, !ClausesInfo, !IO) :-
@@ -4543,7 +4528,7 @@
:- pred module_add_pragma_import(sym_name::in, pred_or_func::in, list(mode)::in,
pragma_foreign_proc_attributes::in, string::in, import_status::in,
prog_context::in, module_info::in, module_info::out,
- qual_info::in, qual_info::out, io__state::di, io__state::uo) is det.
+ qual_info::in, qual_info::out, io::di, io::uo) is det.
module_add_pragma_import(PredName, PredOrFunc, Modes, Attributes, C_Function,
Status, Context, !ModuleInfo, !Info, !IO) :-
@@ -4688,7 +4673,7 @@
sym_name::in, pred_or_func::in, list(pragma_var)::in, prog_varset::in,
pragma_foreign_code_impl::in, import_status::in, prog_context::in,
module_info::in, module_info::out, qual_info::in, qual_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
module_add_pragma_foreign_proc(Attributes, PredName, PredOrFunc, PVars, VarSet,
PragmaImpl, Status, Context, !ModuleInfo, !Info, !IO) :-
@@ -4831,7 +4816,7 @@
:- pred module_add_pragma_tabled(eval_method::in, sym_name::in, int::in,
maybe(pred_or_func)::in, maybe(list(mode))::in, import_status::in,
prog_context::in, module_info::in, module_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
module_add_pragma_tabled(EvalMethod, PredName, Arity, MaybePredOrFunc,
MaybeModes, Status, Context, !ModuleInfo, !IO) :-
@@ -4889,7 +4874,7 @@
:- pred module_add_pragma_tabled_2(eval_method::in, sym_name::in, int::in,
maybe(pred_or_func)::in, maybe(list(mode))::in, prog_context::in,
pred_id::in, module_info::in, module_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
module_add_pragma_tabled_2(EvalMethod, PredName, Arity0, MaybePredOrFunc,
MaybeModes, Context, PredId, !ModuleInfo, !IO) :-
@@ -5525,8 +5510,7 @@
PragmaImpl = import(_, _, _, _)
).
-:- pred write_variable_warning_start(list(string)::in,
- io__state::di, io__state::uo) is det.
+:- pred write_variable_warning_start(list(string)::in, io::di, io::uo) is det.
write_variable_warning_start(UnmentionedVars) -->
( { UnmentionedVars = [_] } ->
@@ -5724,7 +5708,7 @@
goal_type::in, hlds_goal::out, prog_varset::out, tvarset::out,
clauses_info::in, clauses_info::out, list(quant_warning)::out,
module_info::in, module_info::out, qual_info::in, qual_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
clauses_info_add_clause(ModeIds0, CVarSet, TVarSet0, Args, Body, Context,
Status, PredOrFunc, Arity, GoalType, Goal, VarSet, TVarSet,
@@ -5815,8 +5799,7 @@
prog_varset::in, list(pragma_var)::in, list(type)::in,
pragma_foreign_code_impl::in, prog_context::in, pred_or_func::in,
sym_name::in, arity::in, clauses_info::in, clauses_info::out,
- module_info::in, module_info::out, io__state::di, io__state::uo)
- is det.
+ module_info::in, module_info::out, io::di, io::uo) is det.
clauses_info_add_pragma_foreign_proc(Purity, Attributes0, PredId, ProcId,
PVarSet, PVars, OrigArgTypes, PragmaImpl0, Context, PredOrFunc,
@@ -5996,8 +5979,7 @@
list(prog_term)::in, goal::in, prog_context::in, pred_or_func::in,
arity::in, goal_type::in, hlds_goal::out,
prog_varset::in, prog_varset::out, list(quant_warning)::out,
- transform_info::in, transform_info::out,
- io__state::di, io__state::uo) is det.
+ transform_info::in, transform_info::out, io::di, io::uo) is det.
transform(Subst, HeadVars, Args0, Body0, Context, PredOrFunc, Arity, GoalType,
Goal, !VarSet, Warnings, !Info, !IO) :-
@@ -6035,7 +6017,7 @@
:- pred transform_goal(goal::in, prog_substitution::in, hlds_goal::out,
prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
transform_goal(Goal0 - Context, Subst, Goal1 - GoalInfo1, !VarSet,
!Info, !SInfo, !IO) :-
@@ -6047,7 +6029,7 @@
prog_substitution::in, hlds_goal::out,
prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
transform_goal_2(fail, _, _, disj([]) - GoalInfo, !VarSet, !Info, !SInfo,
!IO) :-
@@ -6287,7 +6269,7 @@
list(prog_term)::in, prog_context::in, hlds_goal::out,
prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
transform_dcg_record_syntax(Operator, ArgTerms0, Context, Goal, !VarSet,
!Info, !SInfo, !IO) :-
@@ -6360,7 +6342,7 @@
list(prog_term)::in, prog_context::in, hlds_goal::out,
prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
transform_dcg_record_syntax_2(AccessType, FieldNames, ArgTerms, Context, Goal,
!VarSet, !Info, !SInfo, !IO) :-
@@ -6452,7 +6434,7 @@
prog_varset::in, prog_varset::out, cons_id::out,
pair(cons_id, unify_sub_contexts)::out, hlds_goal::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
expand_set_field_function_call(Context, MainContext, SubContext0, FieldNames,
FieldValueVar, TermInputVar, TermOutputVar, !VarSet, Functor,
@@ -6470,7 +6452,7 @@
prog_varset::in, prog_varset::out, cons_id::out,
pair(cons_id, unify_sub_contexts)::out, list(hlds_goal)::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
expand_set_field_function_call_2(_, _, _, [], _, _, _, _, _, _, _, _, _, _,
_, _, !IO) :-
@@ -6540,7 +6522,7 @@
prog_varset::in, prog_varset::out, cons_id::out,
pair(cons_id, unify_sub_contexts)::out, hlds_goal::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
expand_dcg_field_extraction_goal(Context, MainContext, SubContext,
FieldNames, FieldValueVar, TermInputVar, TermOutputVar,
@@ -6573,7 +6555,7 @@
prog_var::in, prog_var::in, prog_varset::in, prog_varset::out,
cons_id::out, pair(cons_id, unify_sub_contexts)::out, hlds_goal::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
expand_get_field_function_call(Context, MainContext, SubContext0,
FieldNames, FieldValueVar, TermInputVar, !VarSet,
@@ -6589,7 +6571,7 @@
prog_var::in, prog_var::in, prog_varset::in, prog_varset::out,
cons_id::out, pair(cons_id, unify_sub_contexts)::out,
list(hlds_goal)::out, transform_info::in, transform_info::out,
- svar_info::in, svar_info::out, io__state::di, io__state::uo) is det.
+ svar_info::in, svar_info::out, io::di, io::uo) is det.
expand_get_field_function_call_2(_, _, _, [], _, _, _, _, _, _, _, _, _,
_, _, !IO) :-
@@ -6698,7 +6680,7 @@
list(prog_term)::in, prog_context::in, hlds_goal::out,
prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
transform_aditi_builtin(UpdateStr, Args0, Context, Goal, !VarSet,
!Info, !SInfo, !IO) :-
@@ -6726,7 +6708,7 @@
list(prog_term)::in, prog_context::in, hlds_goal::out,
prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
transform_aditi_tuple_update(UpdateStr, Update, Args0, Context,
Goal, !VarSet, !Info, !SInfo, !IO) :-
@@ -6807,7 +6789,7 @@
list(prog_term)::in, prog_context::in, hlds_goal::out,
prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
transform_aditi_bulk_update(Descr, Update, Args0, Context, UpdateGoal,
!VarSet, !Info, !SInfo, !IO) :-
@@ -7085,7 +7067,7 @@
Goal = conj([CallGoal, Goal0]) - GoalInfo.
:- pred output_expected_aditi_update_syntax(prog_context::in,
- aditi_bulk_update::in, io__state::di, io__state::uo) is det.
+ aditi_bulk_update::in, io::di, io::uo) is det.
output_expected_aditi_update_syntax(Context, bulk_insert) -->
output_insert_or_delete_expected_syntax(Context, "aditi_bulk_insert").
@@ -7106,7 +7088,7 @@
output_aditi_closure_syntax(Context, Name).
:- pred output_insert_or_delete_expected_syntax(prog_context::in, string::in,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
output_insert_or_delete_expected_syntax(Context, Name) -->
prog_out__write_context(Context),
@@ -7116,7 +7098,7 @@
output_aditi_closure_syntax(Context, Name).
:- pred output_aditi_closure_syntax(prog_context::in, string::in,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
output_aditi_closure_syntax(Context, Name) -->
prog_out__write_context(Context),
@@ -7127,7 +7109,7 @@
% Report an error for an Aditi update with the wrong number
% of arguments.
:- pred aditi_update_arity_error(prog_context::in, string::in, int::in,
- list(int)::in, io__state::di, io__state::uo) is det.
+ list(int)::in, io::di, io::uo) is det.
aditi_update_arity_error(Context, UpdateStr, Arity, ExpectedArities) -->
io__set_exit_status(1),
@@ -7183,7 +7165,7 @@
prog_context::in, arg_context::in, hlds_goal::in, hlds_goal::out,
prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
insert_arg_unifications(HeadVars, Args0, Context, ArgContext,
!Goal, !VarSet, !Info, !SInfo, !IO) :-
@@ -7205,7 +7187,7 @@
list(hlds_goal)::in, list(hlds_goal)::out,
prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
insert_arg_unifications_2([], [_|_], _, _, _, _, _, _, _, _, _, _, _, !IO) :-
error("insert_arg_unifications_2: length mismatch").
@@ -7231,7 +7213,7 @@
prog_context::in, hlds_goal::in, hlds_goal::out,
prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out,
- svar_info::in, svar_info::out, io__state::di, io__state::uo) is det.
+ svar_info::in, svar_info::out, io::di, io::uo) is det.
insert_arg_unifications_with_supplied_contexts(ArgVars, ArgTerms0, ArgContexts,
Context, !Goal, !VarSet, !Info, !SInfo, !IO) :-
@@ -7254,7 +7236,7 @@
prog_context::in, list(hlds_goal)::in, list(hlds_goal)::out,
prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
insert_arg_unifications_with_supplied_contexts_2(Vars, Terms, ArgContexts,
Context, !List, !VarSet, !Info, !SInfo, !IO) :-
@@ -7280,7 +7262,7 @@
:- pred insert_arg_unification(prog_var::in, prog_term::in, prog_context::in,
arg_context::in, int::in, prog_varset::in, prog_varset::out,
list(hlds_goal)::out, transform_info::in, transform_info::out,
- svar_info::in, svar_info::out, io__state::di, io__state::uo) is det.
+ svar_info::in, svar_info::out, io::di, io::uo) is det.
insert_arg_unification(Var, Arg, Context, ArgContext, N1, !VarSet,
ArgUnifyConj, !Info, !SInfo, !IO) :-
@@ -7304,7 +7286,7 @@
prog_context::in, arg_context::in, hlds_goal::in, hlds_goal::out,
prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
append_arg_unifications(HeadVars, Args0, Context, ArgContext, !Goal, !VarSet,
!Info, !SInfo, !IO) :-
@@ -7325,7 +7307,7 @@
list(hlds_goal)::in, list(hlds_goal)::out,
prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
append_arg_unifications_2([], [_|_], _, _, _, _, _, _, _, _, _, _, _, !IO) :-
error("append_arg_unifications_2: length mismatch").
@@ -7345,7 +7327,7 @@
arg_context::in, int::in, list(hlds_goal)::out,
prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
append_arg_unification(Var, Arg, Context, ArgContext, N1, ConjList,
!VarSet, !Info, !SInfo, !IO) :-
@@ -7430,7 +7412,7 @@
unify_main_context::in, unify_sub_contexts::in, purity::in,
hlds_goal::out, prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out,
- svar_info::in, svar_info::out, io__state::di, io__state::uo) is det.
+ svar_info::in, svar_info::out, io::di, io::uo) is det.
unravel_unification(LHS0, RHS0, Context, MainContext, SubContext,
Purity, Goal, !VarSet, !Info, !SInfo, !IO) :-
@@ -7443,7 +7425,7 @@
unify_main_context::in, unify_sub_contexts::in, purity::in,
hlds_goal::out, prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
% `X = Y' needs no unravelling.
@@ -7762,7 +7744,7 @@
:- pred make_hlds__qualify_lambda_mode_list(list(mode)::in, list(mode)::out,
prog_context::in, transform_info::in, transform_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
make_hlds__qualify_lambda_mode_list(Modes0, Modes, Context, !Info, !IO) :-
% The modes in `.opt' files are already fully module qualified.
@@ -7780,8 +7762,7 @@
%-----------------------------------------------------------------------------%
:- pred check_expr_purity(purity::in, prog_context::in,
- transform_info::in, transform_info::out, io__state::di, io__state::uo)
- is det.
+ transform_info::in, transform_info::out, io::di, io::uo) is det.
check_expr_purity(Purity, Context, !Info, !IO) :-
( Purity \= pure ->
@@ -7819,7 +7800,7 @@
unify_sub_contexts::in, hlds_goal::out,
prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out,
- svar_info::in, io__state::di, io__state::uo) is det.
+ svar_info::in, io::di, io::uo) is det.
build_lambda_expression(X, Purity, PredOrFunc, EvalMethod, Args0, Modes, Det,
ParsedGoal, Context, MainContext, SubContext, Goal, !VarSet,
@@ -8110,7 +8091,7 @@
:- pred get_rev_conj(goal::in, prog_substitution::in, list(hlds_goal)::in,
list(hlds_goal)::out, prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
get_rev_conj(Goal, Subst, RevConj0, RevConj, !VarSet, !Info, !SInfo, !IO) :-
( Goal = (A,B) - _Context ->
@@ -8132,7 +8113,7 @@
:- pred get_rev_par_conj(goal::in, prog_substitution::in, list(hlds_goal)::in,
list(hlds_goal)::out, prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in, svar_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
get_rev_par_conj(Goal, Subst, RevParConj0, RevParConj, !VarSet, !Info, !SInfo,
!IO) :-
@@ -8155,7 +8136,7 @@
:- pred get_disj(goal::in, prog_substitution::in, hlds_goal_svar_infos::in,
hlds_goal_svar_infos::out, prog_varset::in, prog_varset::out,
transform_info::in, transform_info::out, svar_info::in,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
get_disj(Goal, Subst, Disj0, Disj, !VarSet, !Info, SInfo, !IO) :-
( Goal = (A;B) - _Context ->
@@ -8384,7 +8365,7 @@
% Similar to undefined_mode_error, but gives more information.
:- pred undeclared_mode_error(list(mode)::in, prog_varset::in,
pred_id::in, pred_info::in, module_info::in, prog_context::in,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
undeclared_mode_error(ModeList, VarSet, PredId, PredInfo, ModuleInfo,
Context, !IO) :-
@@ -8476,7 +8457,7 @@
io__write_string("\n"),
prog_out__write_context(Context),
io__write_string(" without preceding `"),
- { hlds_out__pred_or_func_to_str(PredOrFunc, DeclString) },
+ { DeclString = hlds_out__pred_or_func_to_str(PredOrFunc) },
io__write_string(DeclString),
io__write_string("' declaration.\n")
).
@@ -8606,7 +8587,7 @@
:- pred module_add_pragma_fact_table(sym_name::in, arity::in, string::in,
import_status::in, prog_context::in, module_info::in, module_info::out,
- qual_info::in, qual_info::out, io__state::di, io__state::uo) is det.
+ qual_info::in, qual_info::out, io::di, io::uo) is det.
module_add_pragma_fact_table(Pred, Arity, FileName, Status, Context,
!Module, !Info, !IO) :-
@@ -8692,7 +8673,7 @@
:- pred module_add_fact_table_proc(proc_id::in, proc_id::in, proc_table::in,
sym_name::in, pred_or_func::in, arity::in, list(type)::in,
import_status::in, prog_context::in, module_info::in, module_info::out,
- qual_info::in, qual_info::out, io__state::di, io__state::uo) is det.
+ qual_info::in, qual_info::out, io::di, io::uo) is det.
module_add_fact_table_proc(ProcID, PrimaryProcID, ProcTable, SymName,
PredOrFunc, Arity, ArgTypes, Status, Context, !Module,
Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.237
diff -u -b -r1.237 mercury_to_mercury.m
--- compiler/mercury_to_mercury.m 23 Mar 2004 10:52:07 -0000 1.237
+++ compiler/mercury_to_mercury.m 4 Apr 2004 07:58:38 -0000
@@ -1980,7 +1980,7 @@
),
add_purity_prefix(Purity),
- { hlds_out__pred_or_func_to_str(PredOrFunc, PredOrFuncStr) },
+ { PredOrFuncStr = hlds_out__pred_or_func_to_str(PredOrFunc) },
add_string(PredOrFuncStr),
add_string(" "),
Index: compiler/ml_tailcall.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_tailcall.m,v
retrieving revision 1.21
diff -u -b -r1.21 ml_tailcall.m
--- compiler/ml_tailcall.m 19 Mar 2004 10:19:22 -0000 1.21
+++ compiler/ml_tailcall.m 4 Apr 2004 07:58:20 -0000
@@ -636,8 +636,8 @@
(
PredLabel = pred(PredOrFunc, _MaybeModule, Name, Arity,
_CodeModel, _NonOutputFunc),
- hlds_out__simple_call_id_to_string(PredOrFunc -
- unqualified(Name) / Arity, CallId),
+ CallId = hlds_out__simple_call_id_to_string(PredOrFunc -
+ unqualified(Name) / Arity),
proc_id_to_int(ProcId, ProcNumber0),
ProcNumber = ProcNumber0 + 1,
ProcNumberStr = string__int_to_string(ProcNumber),
Index: compiler/ml_unify_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_unify_gen.m,v
retrieving revision 1.73
diff -u -b -r1.73 ml_unify_gen.m
--- compiler/ml_unify_gen.m 24 Mar 2004 02:57:12 -0000 1.73
+++ compiler/ml_unify_gen.m 4 Apr 2004 08:10:03 -0000
@@ -1193,7 +1193,7 @@
ConsId = ctor_id(ConsName, Arity),
ModuleName = mercury_module_name_to_mlds(SymModuleName)
;
- hlds_out__cons_id_to_string(HLDS_ConsId, ConsName),
+ ConsName = hlds_out__cons_id_to_string(HLDS_ConsId),
ConsId = ctor_id(ConsName, 0),
ModuleName = mercury_module_name_to_mlds(unqualified(""))
),
Index: compiler/mmc_analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mmc_analysis.m,v
retrieving revision 1.2
diff -u -b -r1.2 mmc_analysis.m
--- compiler/mmc_analysis.m 15 Mar 2003 03:09:02 -0000 1.2
+++ compiler/mmc_analysis.m 4 Apr 2004 07:58:56 -0000
@@ -58,8 +58,8 @@
string_to_sym_name(ModuleId, ".", ModuleName).
pred_or_func_name_arity_to_func_id(PredOrFunc, Name, Arity, ProcId) = FuncId :-
- hlds_out__simple_call_id_to_string(
- PredOrFunc - unqualified(Name)/Arity, FuncId0),
+ FuncId0 = hlds_out__simple_call_id_to_string(PredOrFunc
+ - unqualified(Name)/Arity),
proc_id_to_int(ProcId, ProcInt),
FuncId = FuncId0 ++ "-" ++ int_to_string(ProcInt).
Index: compiler/mode_errors.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mode_errors.m,v
retrieving revision 1.77
diff -u -b -r1.77 mode_errors.m
--- compiler/mode_errors.m 6 Nov 2003 03:42:35 -0000 1.77
+++ compiler/mode_errors.m 4 Apr 2004 07:41:34 -0000
@@ -443,7 +443,7 @@
prog_out__write_context(Context),
io__write_string(" inside the condition of an if-then-else.\n")
; { Reason = lambda(PredOrFunc) },
- { hlds_out__pred_or_func_to_str(PredOrFunc, PredOrFuncS) },
+ { PredOrFuncS = hlds_out__pred_or_func_to_str(PredOrFunc) },
io__write_string("attempt to bind a non-local variable inside\n"),
prog_out__write_context(Context),
io__write_strings([" a ", PredOrFuncS, " lambda goal.\n"])
Index: compiler/passes_aux.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/passes_aux.m,v
retrieving revision 1.59
diff -u -b -r1.59 passes_aux.m
--- compiler/passes_aux.m 5 Nov 2003 03:17:41 -0000 1.59
+++ compiler/passes_aux.m 3 Apr 2004 18:48:23 -0000
@@ -53,39 +53,34 @@
univ)
.
-
:- type pred_error_task ==
pred(pred_id, module_info, module_info, pred_info, pred_info,
int, int, io__state, io__state).
-/****************
-
-Note that update_module_cookie causes some difficulties.
-Ideally, it should be implemented using existential types:
-
- :- type task --->
- ...
- ; some [T] update_module_cookie(pred(
- pred_id, proc_id, proc_info, proc_info,
- T, T, module_info, module_info),
- T)
-
-That would avoid the need for messing about with type_to_univ and
-univ_to_type.
-
-Originally, it was implemented by changing `task' to `task(T)':
-
- :- type task(T) --->
- ...
- ; update_module_cookie(pred(
- pred_id, proc_id, proc_info, proc_info,
- T, T, module_info, module_info),
- T)
-
-but that is not a good solution, because it causes a lot of warnings
-about unbound type variables.
-
-****************/
+% Note that update_module_cookie causes some difficulties.
+% Ideally, it should be implemented using existential types:
+%
+% :- type task --->
+% ...
+% ; some [T] update_module_cookie(pred(
+% pred_id, proc_id, proc_info, proc_info,
+% T, T, module_info, module_info),
+% T)
+%
+% That would avoid the need for messing about with type_to_univ and
+% univ_to_type.
+%
+% Originally, it was implemented by changing `task' to `task(T)':
+%
+% :- type task(T) --->
+% ...
+% ; update_module_cookie(pred(
+% pred_id, proc_id, proc_info, proc_info,
+% T, T, module_info, module_info),
+% T)
+%
+% but that is not a good solution, because it causes a lot of warnings
+% about unbound type variables.
:- inst task = bound(( update_proc(pred(in, in, out) is det)
; update_proc_predid(pred(in, in, in, out) is det)
@@ -110,72 +105,58 @@
:- mode task :: task -> task.
-:- pred process_all_nonimported_procs(task, module_info, module_info,
- io__state, io__state).
-:- mode process_all_nonimported_procs(task, in, out, di, uo) is det.
+:- pred process_all_nonimported_procs(task::task,
+ module_info::in, module_info::out, io::di, io::uo) is det.
% Process procedures for which a given test succeeds.
-:- pred process_matching_nonimported_procs(task, pred(pred_info),
- module_info, module_info, io__state, io__state).
-:- mode process_matching_nonimported_procs(task, pred(in) is semidet,
- in, out, di, uo) is det.
-
-:- pred process_matching_nonimported_procs(task, task, pred(pred_info),
- module_info, module_info, io__state, io__state).
-:- mode process_matching_nonimported_procs(task, out(task),
- pred(in) is semidet, in, out, di, uo) is det.
-
-:- pred process_all_nonimported_nonaditi_procs(task, module_info, module_info,
- io__state, io__state).
-:- mode process_all_nonimported_nonaditi_procs(task, in, out, di, uo) is det.
-
-:- pred process_all_nonimported_nonaditi_procs(task, task,
- module_info, module_info, io__state, io__state).
-:- mode process_all_nonimported_nonaditi_procs(task, out(task),
- in, out, di, uo) is det.
-
-:- pred process_all_nonimported_procs(task, task,
- module_info, module_info, io__state, io__state).
-:- mode process_all_nonimported_procs(task, out(task), in, out, di, uo) is det.
+:- pred process_matching_nonimported_procs(task::task,
+ pred(pred_info)::in(pred(in) is semidet),
+ module_info::in, module_info::out, io::di, io::uo) is det.
+
+:- pred process_matching_nonimported_procs(task::task, task::out(task),
+ pred(pred_info)::in(pred(in) is semidet),
+ module_info::in, module_info::out, io::di, io::uo) is det.
+
+:- pred process_all_nonimported_nonaditi_procs(task::task,
+ module_info::in, module_info::out, io::di, io::uo) is det.
+
+:- pred process_all_nonimported_nonaditi_procs(task::task, task::out(task),
+ module_info::in, module_info::out, io::di, io::uo) is det.
+
+:- pred process_all_nonimported_procs(task::task, task::out(task),
+ module_info::in, module_info::out, io::di, io::uo) is det.
:- pred write_pred_progress_message(string::in, pred_id::in, module_info::in,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
:- pred write_proc_progress_message(string::in, pred_id::in, proc_id::in,
- module_info::in, io__state::di, io__state::uo) is det.
+ module_info::in, io::di, io::uo) is det.
-:- pred maybe_report_stats(bool::in, io__state::di, io__state::uo) is det.
-:- pred maybe_write_string(bool::in, string::in,
- io__state::di, io__state::uo) is det.
-:- pred maybe_flush_output(bool::in, io__state::di, io__state::uo) is det.
+:- pred maybe_report_stats(bool::in, io::di, io::uo) is det.
+:- pred maybe_write_string(bool::in, string::in, io::di, io::uo) is det.
+:- pred maybe_flush_output(bool::in, io::di, io::uo) is det.
-:- pred report_error(string::in, io__state::di, io__state::uo) is det.
-:- pred report_error(io__output_stream::in, string::in,
- io__state::di, io__state::uo) is det.
+:- pred report_error(string::in, io::di, io::uo) is det.
+:- pred report_error(io__output_stream::in, string::in, io::di, io::uo) is det.
-:- pred maybe_report_sizes(module_info::in, io__state::di, io__state::uo)
- is det.
+:- pred maybe_report_sizes(module_info::in, io::di, io::uo) is det.
-:- pred report_pred_proc_id(module_info, pred_id, proc_id,
- maybe(prog_context), prog_context, io__state, io__state).
-:- mode report_pred_proc_id(in, in, in, in, out, di, uo) is det.
-
-:- pred report_pred_name_mode(pred_or_func, string, list((mode)),
- io__state, io__state).
-:- mode report_pred_name_mode(in, in, in, di, uo) is det.
+:- pred report_pred_proc_id(module_info::in, pred_id::in, proc_id::in,
+ maybe(prog_context)::in, prog_context::out, io::di, io::uo) is det.
+
+:- pred report_pred_name_mode(pred_or_func::in, string::in, list(mode)::in,
+ io::di, io::uo) is det.
% Write to a given filename, giving appropriate status
% messages and error messages if the file cannot be opened.
-:- pred output_to_file(string, pred(io__state, io__state),
- io__state, io__state).
-:- mode output_to_file(in, pred(di, uo) is det, di, uo) is det.
+:- pred output_to_file(string::in, pred(io, io)::in(pred(di, uo) is det),
+ io::di, io::uo) is det.
% Same as output_to_file/4 above, but allow the writing predicate
% to generate some output.
-:- pred output_to_file(string, pred(T, io__state, io__state),
- maybe(T), io__state, io__state).
-:- mode output_to_file(in, pred(out, di, uo) is det, out, di, uo) is det.
-
+:- pred output_to_file(string::in,
+ pred(T, io, io)::in(pred(out, di, uo) is det),
+ maybe(T)::out, io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
@@ -302,10 +283,9 @@
process_nonimported_procs_in_preds(PredIds, Task0, Task, Filter,
ModuleInfo0, ModuleInfo).
-:- pred process_nonimported_pred(pred_error_task, pred(pred_info), pred_id,
- module_info, module_info, io__state, io__state).
-:- mode process_nonimported_pred(in(pred_error_task), pred(in) is semidet, in,
- in, out, di, uo) is det.
+:- pred process_nonimported_pred(pred_error_task::in(pred_error_task),
+ pred(pred_info)::in(pred(in) is semidet), pred_id::in,
+ module_info::in, module_info::out, io::di, io::uo) is det.
process_nonimported_pred(Task, Filter, PredId, !ModuleInfo, !IO) :-
module_info_pred_info(!.ModuleInfo, PredId, PredInfo0),
@@ -322,10 +302,9 @@
passes_aux__handle_errors(WarnCnt, ErrCnt, !ModuleInfo, !IO)
).
-:- pred process_nonimported_procs_in_preds(list(pred_id), task, task,
- pred(pred_info), module_info, module_info, io__state, io__state).
-:- mode process_nonimported_procs_in_preds(in, task, out(task),
- pred(in) is semidet, in, out, di, uo) is det.
+:- pred process_nonimported_procs_in_preds(list(pred_id)::in,
+ task::task, task::out(task), pred(pred_info)::in(pred(in) is semidet),
+ module_info::in, module_info::out, io::di, io::uo) is det.
process_nonimported_procs_in_preds([], !Task, _, !ModuleInfo, !IO).
process_nonimported_procs_in_preds([PredId | PredIds], !Task, Filter,
@@ -342,10 +321,9 @@
process_nonimported_procs_in_preds(PredIds, !Task, Filter,
!ModuleInfo, !IO).
-:- pred process_nonimported_procs(list(proc_id), pred_id, task, task,
- module_info, module_info, io__state, io__state).
-:- mode process_nonimported_procs(in, in, task, out(task), in, out, di, uo)
- is det.
+:- pred process_nonimported_procs(list(proc_id)::in, pred_id::in,
+ task::task, task::out(task),
+ module_info::in, module_info::out, io::di, io::uo) is det.
process_nonimported_procs([], _PredId, !Task, !ModuleInfo, !IO).
process_nonimported_procs([ProcId | ProcIds], PredId, !Task, !ModuleInfo,
@@ -444,9 +422,8 @@
report_error(ErrorMessage),
io__set_output_stream(OldStream, _).
-:- pred passes_aux__handle_errors(int, int, module_info, module_info,
- io__state, io__state).
-:- mode passes_aux__handle_errors(in, in, in, out, di, uo) is det.
+:- pred passes_aux__handle_errors(int::in, int::in,
+ module_info::in, module_info::out, io::di, io::uo) is det.
passes_aux__handle_errors(WarnCnt, ErrCnt, ModuleInfo1, ModuleInfo8,
State1, State9) :-
@@ -659,16 +636,15 @@
% See comment above for why it is OK to just succeed here.
use_win32 :- semidet_succeed.
-maybe_report_sizes(HLDS) -->
- globals__io_lookup_bool_option(statistics, Statistics),
- ( { Statistics = yes } ->
- report_sizes(HLDS)
+maybe_report_sizes(HLDS, !IO) :-
+ globals__io_lookup_bool_option(statistics, Statistics, !IO),
+ ( Statistics = yes ->
+ report_sizes(HLDS, !IO)
;
- []
+ true
).
-:- pred report_sizes(module_info, io__state, io__state).
-:- mode report_sizes(in, di, uo) is det.
+:- pred report_sizes(module_info::in, io::di, io::uo) is det.
report_sizes(ModuleInfo) -->
{ module_info_preds(ModuleInfo, Preds) },
@@ -678,8 +654,7 @@
{ module_info_ctors(ModuleInfo, Ctors) },
tree_stats("Constructor table", Ctors).
-:- pred tree_stats(string, map(_K, _V), io__state, io__state).
-:- mode tree_stats(in, in, di, uo) is det.
+:- pred tree_stats(string::in, map(_K, _V)::in, io::di, io::uo) is det.
tree_stats(Description, Tree) -->
{ map__count(Tree, Count) },
@@ -720,34 +695,33 @@
report_pred_name_mode(PredOrFunc, PredName, ArgModes),
io__write_string("':\n").
-
-report_pred_name_mode(predicate, PredName, ArgModes) -->
- io__write_string(PredName),
- ( { ArgModes \= [] } ->
- { varset__init(InstVarSet) }, % XXX inst var names
- io__write_string("("),
- { strip_builtin_qualifiers_from_mode_list(ArgModes,
- ArgModes1) },
- mercury_output_mode_list(ArgModes1, InstVarSet),
- io__write_string(")")
+report_pred_name_mode(predicate, PredName, ArgModes, !IO) :-
+ io__write_string(PredName, !IO),
+ ( ArgModes \= [] ->
+ varset__init(InstVarSet), % XXX inst var names
+ io__write_string("(", !IO),
+ strip_builtin_qualifiers_from_mode_list(ArgModes,
+ StrippedArgModes),
+ mercury_output_mode_list(StrippedArgModes, InstVarSet, !IO),
+ io__write_string(")", !IO)
;
- []
+ true
).
-report_pred_name_mode(function, FuncName, ArgModes) -->
- { varset__init(InstVarSet) }, % XXX inst var names
- { strip_builtin_qualifiers_from_mode_list(ArgModes, ArgModes1) },
- { pred_args_to_func_args(ArgModes1, FuncArgModes, FuncRetMode) },
- io__write_string(FuncName),
- ( { FuncArgModes \= [] } ->
- io__write_string("("),
- mercury_output_mode_list(FuncArgModes, InstVarSet),
- io__write_string(")")
+report_pred_name_mode(function, FuncName, ArgModes, !IO) :-
+ varset__init(InstVarSet), % XXX inst var names
+ strip_builtin_qualifiers_from_mode_list(ArgModes, StrippedArgModes),
+ pred_args_to_func_args(StrippedArgModes, FuncArgModes, FuncRetMode),
+ io__write_string(FuncName, !IO),
+ ( FuncArgModes \= [] ->
+ io__write_string("(", !IO),
+ mercury_output_mode_list(FuncArgModes, InstVarSet, !IO),
+ io__write_string(")", !IO)
;
- []
+ true
),
- io__write_string(" = "),
- mercury_output_mode(FuncRetMode, InstVarSet).
+ io__write_string(" = ", !IO),
+ mercury_output_mode(FuncRetMode, InstVarSet, !IO).
%-----------------------------------------------------------------------------%
Index: compiler/post_typecheck.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/post_typecheck.m,v
retrieving revision 1.62
diff -u -b -r1.62 post_typecheck.m
--- compiler/post_typecheck.m 19 Mar 2004 10:19:24 -0000 1.62
+++ compiler/post_typecheck.m 4 Apr 2004 07:41:51 -0000
@@ -1104,7 +1104,7 @@
),
string__append_list(["`:- pragma ", Pragma, "'"], PragmaStr),
CallId = PredOrFunc - qualified(Module, Name)/Arity,
- hlds_out__simple_call_id_to_string(CallId, CallIdStr),
+ CallIdStr = hlds_out__simple_call_id_to_string(CallId),
ErrorPieces = [fixed("Error:"), fixed(PragmaStr),
words("declaration for"), fixed(CallIdStr)].
Index: compiler/size_prof.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/size_prof.m,v
retrieving revision 1.5
diff -u -b -r1.5 size_prof.m
--- compiler/size_prof.m 8 Mar 2004 02:30:31 -0000 1.5
+++ compiler/size_prof.m 3 Apr 2004 22:07:29 -0000
@@ -97,7 +97,7 @@
% Perform the transformation on the specified predicate.
:- pred process_proc_msg(construct_transform::in, pred_id::in, proc_id::in,
proc_info::in, proc_info::out, module_info::in, module_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -199,18 +199,19 @@
).
process_proc_msg(Transform, PredId, ProcId, ProcInfo0, ProcInfo,
- ModuleInfo0, ModuleInfo, !IO) :-
+ !ModuleInfo, !IO) :-
globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
( VeryVerbose = yes ->
io__write_string("% Adding typeinfos in ", !IO),
- hlds_out__write_pred_proc_id(ModuleInfo0, PredId, ProcId, !IO),
+ hlds_out__write_pred_proc_id(!.ModuleInfo, PredId, ProcId,
+ !IO),
io__write_string(": ", !IO),
process_proc(Transform, PredId, ProcId, ProcInfo0, ProcInfo,
- ModuleInfo0, ModuleInfo),
+ !ModuleInfo),
io__write_string("done.\n", !IO)
;
process_proc(Transform, PredId, ProcId, ProcInfo0, ProcInfo,
- ModuleInfo0, ModuleInfo)
+ !ModuleInfo)
).
:- pred process_proc(construct_transform::in, pred_id::in, proc_id::in,
Index: compiler/switch_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/switch_util.m,v
retrieving revision 1.16
diff -u -b -r1.16 switch_util.m
--- compiler/switch_util.m 27 Oct 2003 05:42:37 -0000 1.16
+++ compiler/switch_util.m 3 Apr 2004 11:50:55 -0000
@@ -53,8 +53,8 @@
% Fail if the type isn't the sort of type that has a range
% or if the type's range is too big to switch on (e.g. int).
%
-:- pred switch_util__type_range(type_category, type, module_info, int, int).
-:- mode switch_util__type_range(in, in, in, out, out) is semidet.
+:- pred switch_util__type_range(type_category::in, (type)::in, module_info::in,
+ int::out, int::out) is semidet.
%-----------------------------------------------------------------------------%
%
@@ -174,49 +174,43 @@
switch_util__calc_hash_slots(HashValList, HashMap, Map) :-
map__init(Map0),
- switch_util__calc_hash_slots_1(HashValList, HashMap, Map0, 0,
- Map, _).
+ switch_util__calc_hash_slots_1(HashValList, HashMap, Map0, Map, 0, _).
-:- pred switch_util__calc_hash_slots_1(assoc_list(int, cases_list),
- map(int, cases_list), map(int, hash_slot), int,
- map(int, hash_slot), int).
-:- mode switch_util__calc_hash_slots_1(in, in, in, in, out, out) is det.
-
-switch_util__calc_hash_slots_1([], _, Map, LastUsed, Map, LastUsed).
-switch_util__calc_hash_slots_1([HashVal-Cases | Rest], HashMap, Map0,
- LastUsed0, Map, LastUsed) :-
- switch_util__calc_hash_slots_2(Cases, HashVal, HashMap, Map0,
- LastUsed0, Map1, LastUsed1),
- switch_util__calc_hash_slots_1(Rest, HashMap, Map1,
- LastUsed1, Map, LastUsed).
-
-:- pred switch_util__calc_hash_slots_2(cases_list, int,
- map(int, cases_list), map(int, hash_slot), int,
- map(int, hash_slot), int).
-:- mode switch_util__calc_hash_slots_2(in, in, in, in, in, out, out) is det.
-
-switch_util__calc_hash_slots_2([], _HashVal, _HashMap, Map, LastUsed,
- Map, LastUsed).
-switch_util__calc_hash_slots_2([Case | Cases], HashVal, HashMap, Map0,
- LastUsed0, Map, LastUsed) :-
- switch_util__calc_hash_slots_2(Cases, HashVal, HashMap, Map0,
- LastUsed0, Map1, LastUsed1),
- ( map__contains(Map1, HashVal) ->
- switch_util__follow_hash_chain(Map1, HashVal, ChainEnd),
- switch_util__next_free_hash_slot(Map1, HashMap, LastUsed1,
- Next),
- map__lookup(Map1, ChainEnd, hash_slot(PrevCase, _)),
- map__det_update(Map1, ChainEnd, hash_slot(PrevCase, Next),
- Map2),
- map__det_insert(Map2, Next, hash_slot(Case, -1), Map),
- LastUsed = Next
+:- pred switch_util__calc_hash_slots_1(assoc_list(int, cases_list)::in,
+ map(int, cases_list)::in,
+ map(int, hash_slot)::in, map(int, hash_slot)::out,
+ int::in, int::out) is det.
+
+switch_util__calc_hash_slots_1([], _, !Map, !LastUsed).
+switch_util__calc_hash_slots_1([HashVal - Cases | Rest], HashMap,
+ !Map, !LastUsed) :-
+ switch_util__calc_hash_slots_2(Cases, HashVal, HashMap,
+ !Map, !LastUsed),
+ switch_util__calc_hash_slots_1(Rest, HashMap, !Map, !LastUsed).
+
+:- pred switch_util__calc_hash_slots_2(cases_list::in, int::in,
+ map(int, cases_list)::in,
+ map(int, hash_slot)::in, map(int, hash_slot)::out,
+ int::in, int::out) is det.
+
+switch_util__calc_hash_slots_2([], _HashVal, _HashMap, !Map, !LastUsed).
+switch_util__calc_hash_slots_2([Case | Cases], HashVal, HashMap,
+ !Map, !LastUsed) :-
+ switch_util__calc_hash_slots_2(Cases, HashVal, HashMap,
+ !Map, !LastUsed),
+ ( map__contains(!.Map, HashVal) ->
+ switch_util__follow_hash_chain(!.Map, HashVal, ChainEnd),
+ switch_util__next_free_hash_slot(!.Map, HashMap, !LastUsed),
+ map__lookup(!.Map, ChainEnd, hash_slot(PrevCase, _)),
+ map__det_update(!.Map, ChainEnd,
+ hash_slot(PrevCase, !.LastUsed), !:Map),
+ map__det_insert(!.Map, !.LastUsed, hash_slot(Case, -1), !:Map)
;
- map__det_insert(Map1, HashVal, hash_slot(Case, -1), Map),
- LastUsed = LastUsed1
+ map__det_insert(!.Map, HashVal, hash_slot(Case, -1), !:Map)
).
-:- pred switch_util__follow_hash_chain(map(int, hash_slot), int, int).
-:- mode switch_util__follow_hash_chain(in, in, out) is det.
+:- pred switch_util__follow_hash_chain(map(int, hash_slot)::in,
+ int::in, int::out) is det.
switch_util__follow_hash_chain(Map, Slot, LastSlot) :-
map__lookup(Map, Slot, hash_slot(_, NextSlot)),
@@ -235,9 +229,8 @@
% going to be used a primary slot (contained in H_M),
% starting at the slot after LastUsed.
-:- pred switch_util__next_free_hash_slot(map(int, hash_slot),
- map(int, cases_list), int, int).
-:- mode switch_util__next_free_hash_slot(in, in, in, out) is det.
+:- pred switch_util__next_free_hash_slot(map(int, hash_slot)::in,
+ map(int, cases_list)::in, int::in, int::out) is det.
switch_util__next_free_hash_slot(Map, H_Map, LastUsed, FreeSlot) :-
NextSlot = LastUsed + 1,
@@ -345,7 +338,7 @@
hlds_data__get_type_defn_body(TypeDefn, Body),
( ConsTable = Body ^ du_type_cons_tag_values ->
map__to_assoc_list(ConsTable, ConsList),
- switch_util__cons_list_to_tag_list(ConsList, TagList)
+ assoc_list__values(ConsList, TagList)
;
error("non-du type in switch_util__get_ptag_counts")
),
@@ -353,28 +346,27 @@
switch_util__get_ptag_counts_2(TagList, -1, MaxPrimary,
PtagCountMap0, PtagCountMap).
-:- pred switch_util__get_ptag_counts_2(list(cons_tag), int, int,
- ptag_count_map, ptag_count_map).
-:- mode switch_util__get_ptag_counts_2(in, in, out, in, out) is det.
-
-switch_util__get_ptag_counts_2([], Max, Max, PtagCountMap, PtagCountMap).
-switch_util__get_ptag_counts_2([ConsTag | TagList], MaxPrimary0, MaxPrimary,
- PtagCountMap0, PtagCountMap) :-
+:- pred switch_util__get_ptag_counts_2(list(cons_tag)::in, int::in, int::out,
+ ptag_count_map::in, ptag_count_map::out) is det.
+
+switch_util__get_ptag_counts_2([], !Max, !PtagCountMap).
+switch_util__get_ptag_counts_2([ConsTag | TagList], !MaxPrimary,
+ !PtagCountMap) :-
(
( ConsTag = single_functor, Primary = 0
; ConsTag = unshared_tag(Primary)
)
->
- int__max(MaxPrimary0, Primary, MaxPrimary1),
- ( map__search(PtagCountMap0, Primary, _) ->
+ int__max(Primary, !MaxPrimary),
+ ( map__search(!.PtagCountMap, Primary, _) ->
error("unshared tag is shared")
;
- map__det_insert(PtagCountMap0, Primary, none - (-1),
- PtagCountMap1)
+ map__det_insert(!.PtagCountMap, Primary, none - (-1),
+ !:PtagCountMap)
)
; ConsTag = shared_remote_tag(Primary, Secondary) ->
- int__max(MaxPrimary0, Primary, MaxPrimary1),
- ( map__search(PtagCountMap0, Primary, Target) ->
+ int__max(Primary, !MaxPrimary),
+ ( map__search(!.PtagCountMap, Primary, Target) ->
Target = TagType - MaxSoFar,
( TagType = remote ->
true
@@ -382,15 +374,15 @@
error("remote tag is shared with non-remote")
),
int__max(Secondary, MaxSoFar, Max),
- map__det_update(PtagCountMap0, Primary, remote - Max,
- PtagCountMap1)
+ map__det_update(!.PtagCountMap, Primary, remote - Max,
+ !:PtagCountMap)
;
- map__det_insert(PtagCountMap0, Primary,
- remote - Secondary, PtagCountMap1)
+ map__det_insert(!.PtagCountMap, Primary,
+ remote - Secondary, !:PtagCountMap)
)
; ConsTag = shared_local_tag(Primary, Secondary) ->
- int__max(MaxPrimary0, Primary, MaxPrimary1),
- ( map__search(PtagCountMap0, Primary, Target) ->
+ int__max(Primary, !MaxPrimary),
+ ( map__search(!.PtagCountMap, Primary, Target) ->
Target = TagType - MaxSoFar,
( TagType = local ->
true
@@ -398,41 +390,40 @@
error("local tag is shared with non-local")
),
int__max(Secondary, MaxSoFar, Max),
- map__det_update(PtagCountMap0, Primary, local - Max,
- PtagCountMap1)
+ map__det_update(!.PtagCountMap, Primary, local - Max,
+ !:PtagCountMap)
;
- map__det_insert(PtagCountMap0, Primary,
- local - Secondary, PtagCountMap1)
+ map__det_insert(!.PtagCountMap, Primary,
+ local - Secondary, !:PtagCountMap)
)
;
error("non-du tag in switch_util__get_ptag_counts_2")
),
- switch_util__get_ptag_counts_2(TagList, MaxPrimary1, MaxPrimary,
- PtagCountMap1, PtagCountMap).
+ switch_util__get_ptag_counts_2(TagList, !MaxPrimary, !PtagCountMap).
%-----------------------------------------------------------------------------%
% Group together all the cases that depend on the given variable
% having the same primary tag value.
-switch_util__group_cases_by_ptag([], PtagCaseMap, PtagCaseMap).
-switch_util__group_cases_by_ptag([Case0 | Cases0], PtagCaseMap0, PtagCaseMap) :-
+switch_util__group_cases_by_ptag([], !PtagCaseMap).
+switch_util__group_cases_by_ptag([Case0 | Cases0], !PtagCaseMap) :-
Case0 = case(_Priority, Tag, _ConsId, Goal),
(
( Tag = single_functor, Primary = 0
; Tag = unshared_tag(Primary)
)
->
- ( map__search(PtagCaseMap0, Primary, _Group) ->
+ ( map__search(!.PtagCaseMap, Primary, _Group) ->
error("unshared tag is shared")
;
map__init(StagGoalMap0),
map__det_insert(StagGoalMap0, -1, Goal, StagGoalMap),
- map__det_insert(PtagCaseMap0, Primary,
- none - StagGoalMap, PtagCaseMap1)
+ map__det_insert(!.PtagCaseMap, Primary,
+ none - StagGoalMap, !:PtagCaseMap)
)
; Tag = shared_remote_tag(Primary, Secondary) ->
- ( map__search(PtagCaseMap0, Primary, Group) ->
+ ( map__search(!.PtagCaseMap, Primary, Group) ->
Group = StagLoc - StagGoalMap0,
( StagLoc = remote ->
true
@@ -441,17 +432,17 @@
),
map__det_insert(StagGoalMap0, Secondary, Goal,
StagGoalMap),
- map__det_update(PtagCaseMap0, Primary,
- remote - StagGoalMap, PtagCaseMap1)
+ map__det_update(!.PtagCaseMap, Primary,
+ remote - StagGoalMap, !:PtagCaseMap)
;
map__init(StagGoalMap0),
map__det_insert(StagGoalMap0, Secondary, Goal,
StagGoalMap),
- map__det_insert(PtagCaseMap0, Primary,
- remote - StagGoalMap, PtagCaseMap1)
+ map__det_insert(!.PtagCaseMap, Primary,
+ remote - StagGoalMap, !:PtagCaseMap)
)
; Tag = shared_local_tag(Primary, Secondary) ->
- ( map__search(PtagCaseMap0, Primary, Group) ->
+ ( map__search(!.PtagCaseMap, Primary, Group) ->
Group = StagLoc - StagGoalMap0,
( StagLoc = local ->
true
@@ -460,19 +451,19 @@
),
map__det_insert(StagGoalMap0, Secondary, Goal,
StagGoalMap),
- map__det_update(PtagCaseMap0, Primary,
- local - StagGoalMap, PtagCaseMap1)
+ map__det_update(!.PtagCaseMap, Primary,
+ local - StagGoalMap, !:PtagCaseMap)
;
map__init(StagGoalMap0),
map__det_insert(StagGoalMap0, Secondary, Goal,
StagGoalMap),
- map__det_insert(PtagCaseMap0, Primary,
- local - StagGoalMap, PtagCaseMap1)
+ map__det_insert(!.PtagCaseMap, Primary,
+ local - StagGoalMap, !:PtagCaseMap)
)
;
error("non-du tag in switch_util__group_cases_by_ptag")
),
- switch_util__group_cases_by_ptag(Cases0, PtagCaseMap1, PtagCaseMap).
+ switch_util__group_cases_by_ptag(Cases0, !PtagCaseMap).
%-----------------------------------------------------------------------------%
@@ -504,19 +495,19 @@
( map__is_empty(PtagCaseMap0) ->
PtagCaseList = []
;
- error("PtagCaseMap0 is not empty in switch_util__order_ptags_by_count")
+ error("PtagCaseMap0 is not empty in " ++
+ "switch_util__order_ptags_by_count")
)
).
% Select the most frequently used primary tag based on the number of
% secondary tags associated with it.
-:- pred switch_util__select_frequent_ptag(ptag_count_list, tag_bits, int,
- ptag_count_list).
-:- mode switch_util__select_frequent_ptag(in, out, out, out) is semidet.
+:- pred switch_util__select_frequent_ptag(ptag_count_list::in, tag_bits::out,
+ int::out, ptag_count_list::out) is semidet.
-switch_util__select_frequent_ptag([PtagCount0 | PtagCountList1], Primary, Count,
- PtagCountList) :-
+switch_util__select_frequent_ptag([PtagCount0 | PtagCountList1], Primary,
+ Count, PtagCountList) :-
PtagCount0 = Primary0 - (_ - Count0),
(
switch_util__select_frequent_ptag(PtagCountList1,
@@ -555,19 +546,9 @@
( map__is_empty(PtagCaseMap0) ->
PtagCaseList = []
;
- error("PtagCaseMap0 is not empty in order_ptags_by_value")
+ error("PtagCaseMap0 is not empty in " ++
+ "order_ptags_by_value")
)
).
-
-%-----------------------------------------------------------------------------%
-
-:- pred switch_util__cons_list_to_tag_list(assoc_list(cons_id, cons_tag),
- list(cons_tag)).
-:- mode switch_util__cons_list_to_tag_list(in, out) is det.
-
-switch_util__cons_list_to_tag_list([], []).
-switch_util__cons_list_to_tag_list([_ConsId - ConsTag | ConsList],
- [ConsTag | Tagslist]) :-
- switch_util__cons_list_to_tag_list(ConsList, Tagslist).
%-----------------------------------------------------------------------------%
Index: compiler/table_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/table_gen.m,v
retrieving revision 1.58
diff -u -b -r1.58 table_gen.m
--- compiler/table_gen.m 23 Mar 2004 10:52:12 -0000 1.58
+++ compiler/table_gen.m 4 Apr 2004 07:59:09 -0000
@@ -1695,7 +1695,7 @@
Name = pred_info_name(PredInfo),
Arity = pred_info_arity(PredInfo),
PredOrFunc = pred_info_is_pred_or_func(PredInfo),
- hlds_out__pred_or_func_to_str(PredOrFunc, PredOrFuncS),
+ PredOrFuncS = hlds_out__pred_or_func_to_str(PredOrFunc),
prog_out__sym_name_to_string(qualified(Module, Name), NameS),
string__int_to_string(Arity, ArityS),
string__append_list([Msg, " in ", PredOrFuncS,
Index: compiler/term_errors.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/term_errors.m,v
retrieving revision 1.23
diff -u -b -r1.23 term_errors.m
--- compiler/term_errors.m 19 Mar 2004 10:19:25 -0000 1.23
+++ compiler/term_errors.m 3 Apr 2004 15:53:57 -0000
@@ -124,8 +124,7 @@
:- type term_errors__error == pair(prog_context, termination_error).
:- pred term_errors__report_term_errors(list(pred_proc_id)::in,
- list(term_errors__error)::in, module_info::in,
- io__state::di, io__state::uo) is det.
+ list(term_errors__error)::in, module_info::in, io::di, io::uo) is det.
% An error is considered an indirect error if it is due either to a
% language feature we cannot analyze or due to an error in another part
@@ -134,8 +133,7 @@
% and in the second case, the piece of code that the programmer *can* do
% something about is not this piece.
-:- pred indirect_error(term_errors__termination_error).
-:- mode indirect_error(in) is semidet.
+:- pred indirect_error(term_errors__termination_error::in) is semidet.
:- implementation.
@@ -160,114 +158,118 @@
indirect_error(horder_args(_, _)).
indirect_error(does_not_term_pragma(_)).
-term_errors__report_term_errors(SCC, Errors, Module) -->
- { get_context_from_scc(SCC, Module, Context) },
- ( { SCC = [PPId] } ->
- { Pieces0 = [words("Termination of")] },
- { describe_one_proc_name(Module, PPId, PredName) },
- { list__append(Pieces0, [fixed(PredName)], Pieces1) },
- { Single = yes(PPId) }
- ;
- { Pieces0 = [words("Termination of the mutually recursive procedures")] },
- { describe_several_proc_names(Module, SCC, ProcNamePieces) },
- { list__append(Pieces0, ProcNamePieces, Pieces1) },
- { Single = no }
+term_errors__report_term_errors(SCC, Errors, Module, !IO) :-
+ get_context_from_scc(SCC, Module, Context),
+ ( SCC = [PPId] ->
+ Pieces0 = [words("Termination of")],
+ describe_one_proc_name(Module, PPId, PredName),
+ list__append(Pieces0, [fixed(PredName)], Pieces1),
+ Single = yes(PPId)
+ ;
+ Pieces0 = [words("Termination of the "),
+ words("mutually recursive procedures")],
+ describe_several_proc_names(Module, SCC, ProcNamePieces),
+ list__append(Pieces0, ProcNamePieces, Pieces1),
+ Single = no
),
(
- { Errors = [] },
+ Errors = [],
% XXX this should never happen
% XXX but for some reason, it often does
- % { error("empty list of errors") }
- { Pieces2 = [words("not proven, for unknown reason(s).")] },
- { list__append(Pieces1, Pieces2, Pieces) },
- write_error_pieces(Context, 0, Pieces)
- ;
- { Errors = [Error] },
- { Pieces2 = [words("not proven for the following reason:")] },
- { list__append(Pieces1, Pieces2, Pieces) },
- write_error_pieces(Context, 0, Pieces),
- term_errors__output_error(Error, Single, no, 0, Module)
- ;
- { Errors = [_, _ | _] },
- { Pieces2 = [words("not proven for the following reasons:")] },
- { list__append(Pieces1, Pieces2, Pieces) },
- write_error_pieces(Context, 0, Pieces),
- term_errors__output_errors(Errors, Single, 1, 0, Module)
+ % error("empty list of errors")
+ Pieces2 = [words("not proven, for unknown reason(s).")],
+ list__append(Pieces1, Pieces2, Pieces),
+ write_error_pieces(Context, 0, Pieces, !IO)
+ ;
+ Errors = [Error],
+ Pieces2 = [words("not proven for the following reason:")],
+ list__append(Pieces1, Pieces2, Pieces),
+ write_error_pieces(Context, 0, Pieces, !IO),
+ term_errors__output_error(Error, Single, no, 0, Module, !IO)
+ ;
+ Errors = [_, _ | _],
+ Pieces2 = [words("not proven for the following reasons:")],
+ list__append(Pieces1, Pieces2, Pieces),
+ write_error_pieces(Context, 0, Pieces, !IO),
+ term_errors__output_errors(Errors, Single, 1, 0, Module, !IO)
).
:- pred term_errors__report_arg_size_errors(list(pred_proc_id)::in,
list(term_errors__error)::in, module_info::in,
io__state::di, io__state::uo) is det.
-term_errors__report_arg_size_errors(SCC, Errors, Module) -->
- { get_context_from_scc(SCC, Module, Context) },
- ( { SCC = [PPId] } ->
- { Pieces0 = [words("Termination constant of")] },
- { describe_one_proc_name(Module, PPId, ProcName) },
- { list__append(Pieces0, [fixed(ProcName)], Pieces1) },
- { Single = yes(PPId) }
- ;
- { Pieces0 = [words("Termination constants"),
- words("of the mutually recursive procedures")] },
- { describe_several_proc_names(Module, SCC, ProcNamePieces) },
- { list__append(Pieces0, ProcNamePieces, Pieces1) },
- { Single = no }
+term_errors__report_arg_size_errors(SCC, Errors, Module, !IO) :-
+ get_context_from_scc(SCC, Module, Context),
+ ( SCC = [PPId] ->
+ Pieces0 = [words("Termination constant of")],
+ describe_one_proc_name(Module, PPId, ProcName),
+ list__append(Pieces0, [fixed(ProcName)], Pieces1),
+ Single = yes(PPId)
+ ;
+ Pieces0 = [words("Termination constants"),
+ words("of the mutually recursive procedures")],
+ describe_several_proc_names(Module, SCC, ProcNamePieces),
+ list__append(Pieces0, ProcNamePieces, Pieces1),
+ Single = no
),
- { Piece2 = words("set to infinity for the following") },
+ Piece2 = words("set to infinity for the following"),
(
- { Errors = [] },
- { error("empty list of errors") }
+ Errors = [],
+ error("empty list of errors")
;
- { Errors = [Error] },
- { Piece3 = words("reason:") },
- { list__append(Pieces1, [Piece2, Piece3], Pieces) },
- write_error_pieces(Context, 0, Pieces),
- term_errors__output_error(Error, Single, no, 0, Module)
- ;
- { Errors = [_, _ | _] },
- { Piece3 = words("reasons:") },
- { list__append(Pieces1, [Piece2, Piece3], Pieces) },
- write_error_pieces(Context, 0, Pieces),
- term_errors__output_errors(Errors, Single, 1, 0, Module)
+ Errors = [Error],
+ Piece3 = words("reason:"),
+ list__append(Pieces1, [Piece2, Piece3], Pieces),
+ write_error_pieces(Context, 0, Pieces, !IO),
+ term_errors__output_error(Error, Single, no, 0, Module, !IO)
+ ;
+ Errors = [_, _ | _],
+ Piece3 = words("reasons:"),
+ list__append(Pieces1, [Piece2, Piece3], Pieces),
+ write_error_pieces(Context, 0, Pieces, !IO),
+ term_errors__output_errors(Errors, Single, 1, 0, Module, !IO)
).
:- pred term_errors__output_errors(list(term_errors__error)::in,
maybe(pred_proc_id)::in, int::in, int::in, module_info::in,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
-term_errors__output_errors([], _, _, _, _) --> [].
-term_errors__output_errors([Error | Errors], Single, ErrNum0, Indent, Module)
- -->
- term_errors__output_error(Error, Single, yes(ErrNum0), Indent, Module),
- { ErrNum1 = ErrNum0 + 1 },
- term_errors__output_errors(Errors, Single, ErrNum1, Indent, Module).
+term_errors__output_errors([], _, _, _, _, !IO).
+term_errors__output_errors([Error | Errors], Single, ErrNum0, Indent, Module,
+ !IO) :-
+ term_errors__output_error(Error, Single, yes(ErrNum0), Indent, Module,
+ !IO),
+ term_errors__output_errors(Errors, Single, ErrNum0 + 1, Indent, Module,
+ !IO).
:- pred term_errors__output_error(term_errors__error::in,
maybe(pred_proc_id)::in, maybe(int)::in, int::in, module_info::in,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
-term_errors__output_error(Context - Error, Single, ErrorNum, Indent, Module) -->
- { term_errors__description(Error, Single, Module, Pieces0, Reason) },
- { ErrorNum = yes(N) ->
+term_errors__output_error(Context - Error, Single, ErrorNum, Indent, Module,
+ !IO) :-
+ term_errors__description(Error, Single, Module, Pieces0, Reason),
+ ( ErrorNum = yes(N) ->
string__int_to_string(N, Nstr),
string__append_list(["Reason ", Nstr, ":"], Preamble),
Pieces = [fixed(Preamble) | Pieces0]
;
Pieces = Pieces0
- },
- write_error_pieces(Context, Indent, Pieces),
- ( { Reason = yes(InfArgSizePPId) } ->
- { lookup_proc_arg_size_info(Module, InfArgSizePPId, ArgSize) },
- ( { ArgSize = yes(infinite(ArgSizeErrors)) } ->
+ ),
+ write_error_pieces(Context, Indent, Pieces, !IO),
+ ( Reason = yes(InfArgSizePPId) ->
+ lookup_proc_arg_size_info(Module, InfArgSizePPId, ArgSize),
+ ( ArgSize = yes(infinite(ArgSizeErrors)) ->
% XXX the next line is cheating
- { ArgSizePPIdSCC = [InfArgSizePPId] },
+ ArgSizePPIdSCC = [InfArgSizePPId],
term_errors__report_arg_size_errors(ArgSizePPIdSCC,
- ArgSizeErrors, Module)
+ ArgSizeErrors, Module, !IO)
;
- { error("inf arg size procedure does not have inf arg size") }
+ error("inf arg size procedure " ++
+ "does not have inf arg size")
)
;
- []
+ true
).
:- pred term_errors__description(termination_error::in,
@@ -429,7 +431,8 @@
(
Single = yes(PPId),
PPId = proc(SCCPredId, _),
- require(unify(PredId, SCCPredId), "does not terminate pragma outside this SCC"),
+ require(unify(PredId, SCCPredId),
+ "does not terminate pragma outside this SCC"),
Piece2 = words("it.")
;
Single = no,
Index: compiler/transform_llds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/transform_llds.m,v
retrieving revision 1.11
diff -u -b -r1.11 transform_llds.m
--- compiler/transform_llds.m 12 Nov 2003 17:06:49 -0000 1.11
+++ compiler/transform_llds.m 3 Apr 2004 11:37:24 -0000
@@ -28,8 +28,7 @@
:- import_module ll_backend__llds.
:- import_module io.
-:- pred transform_llds(c_file, c_file, io__state, io__state).
-:- mode transform_llds(in, out, di, uo) is det.
+:- pred transform_llds(c_file::in, c_file::out, io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
@@ -45,33 +44,34 @@
:- import_module bool, int, string, list, require, std_util, counter.
-transform_llds(LLDS0, LLDS) -->
- transform_c_file(LLDS0, LLDS).
+transform_llds(LLDS0, LLDS, !IO) :-
+ globals__io_get_globals(Globals, !IO),
+ transform_c_file(LLDS0, LLDS, Globals).
%-----------------------------------------------------------------------------%
-:- pred transform_c_file(c_file, c_file, io__state, io__state).
-:- mode transform_c_file(in, out, di, uo) is det.
+:- pred transform_c_file(c_file::in, c_file::out, globals::in) is det.
-transform_c_file(c_file(ModuleName, HeaderInfo, A, B, C, D, Modules0),
- c_file(ModuleName, HeaderInfo, A, B, C, D, Modules)) -->
+transform_c_file(CFile0, CFile, Globals) :-
+ CFile0 = c_file(ModuleName, _, _, _, _, _, Modules0),
% split up large computed gotos
- globals__io_lookup_int_option(max_jump_table_size, MaxJumpTableSize),
- ( { MaxJumpTableSize = 0 } ->
- { Modules1 = Modules0 }
+ globals__lookup_int_option(Globals, max_jump_table_size, MaxSize),
+ ( MaxSize = 0 ->
+ Modules1 = Modules0
;
- transform_c_module_list(Modules0, Modules1)
+ transform_c_module_list(Modules0, Modules1, MaxSize)
),
% append an end label for accurate GC
- globals__io_get_gc_method(GC),
- { GC = accurate, Modules1 \= [] ->
+ globals__get_gc_method(Globals, GC),
+ ( GC = accurate, Modules1 \= [] ->
list__last_det(Modules1, LastModule),
LastModule = comp_gen_c_module(LastModuleName, _),
Modules = Modules1 ++
[gen_end_label_module(ModuleName, LastModuleName)]
;
Modules = Modules1
- }.
+ ),
+ CFile = CFile0 ^ cfile_code := Modules.
%
% For LLDS native GC, we need to add a dummy comp_gen_c_module at the end of
@@ -95,7 +95,9 @@
% corresponds to a new C function). XXX Hopefully GCC won't mess with the
% order of the functions...
%
+
:- func gen_end_label_module(module_name, string) = comp_gen_c_module.
+
gen_end_label_module(ModuleName, LastModule) = EndLabelModule :-
Arity = 0,
ProcId = hlds_pred__initial_proc_id,
@@ -106,145 +108,104 @@
Instrs = [label(local(ProcLabel)) -
"label to indicate end of previous procedure"],
DummyProc = c_procedure(PredName, Arity, proc(PredId, ProcId),
- Instrs, ProcLabel,
- counter__init(0), must_not_alter_rtti),
+ Instrs, ProcLabel, counter__init(0), must_not_alter_rtti),
EndLabelModule = comp_gen_c_module(LastModule ++ "_END", [DummyProc]).
%-----------------------------------------------------------------------------%
-:- pred transform_c_module_list(list(comp_gen_c_module),
- list(comp_gen_c_module), io__state, io__state).
-:- mode transform_c_module_list(in, out, di, uo) is det.
+:- pred transform_c_module_list(list(comp_gen_c_module)::in,
+ list(comp_gen_c_module)::out, int::in) is det.
-transform_c_module_list([], []) --> [].
-transform_c_module_list([M0 | M0s], [M | Ms]) -->
- transform_c_module(M0, M),
- transform_c_module_list(M0s, Ms).
+transform_c_module_list([], [], _MaxSize).
+transform_c_module_list([Module0 | Module0s], [Module | Modules], MaxSize) :-
+ transform_c_module(Module0, Module, MaxSize),
+ transform_c_module_list(Module0s, Modules, MaxSize).
%-----------------------------------------------------------------------------%
-:- pred transform_c_module(comp_gen_c_module, comp_gen_c_module,
- io__state, io__state).
-:- mode transform_c_module(in, out, di, uo) is det.
+:- pred transform_c_module(comp_gen_c_module::in, comp_gen_c_module::out,
+ int::in) is det.
transform_c_module(comp_gen_c_module(Name, Procedures0),
- comp_gen_c_module(Name, Procedures)) -->
- transform_c_procedure_list(Procedures0, Procedures).
+ comp_gen_c_module(Name, Procedures), MaxSize) :-
+ transform_c_procedure_list(Procedures0, Procedures, MaxSize).
%-----------------------------------------------------------------------------%
-:- pred transform_c_procedure_list(list(c_procedure), list(c_procedure),
- io__state, io__state).
-:- mode transform_c_procedure_list(in, out, di, uo) is det.
+:- pred transform_c_procedure_list(list(c_procedure)::in,
+ list(c_procedure)::out, int::in) is det.
-transform_c_procedure_list([], []) --> [].
-transform_c_procedure_list([P0 | P0s], [P | Ps]) -->
- transform_c_procedure(P0, P),
- transform_c_procedure_list(P0s, Ps).
+transform_c_procedure_list([], [], _MaxSize).
+transform_c_procedure_list([Proc0 | Proc0s], [Proc | Procs], MaxSize) :-
+ transform_c_procedure(Proc0, Proc, MaxSize),
+ transform_c_procedure_list(Proc0s, Procs, MaxSize).
%-----------------------------------------------------------------------------%
-:- pred transform_c_procedure(c_procedure, c_procedure, io__state, io__state).
-:- mode transform_c_procedure(in, out, di, uo) is det.
-
-transform_c_procedure(Proc0, Proc) -->
- { Proc0 = c_procedure(Name, Arity, PPId, Instrs0,
- ProcLabel, C0, Recons) },
- { Proc = c_procedure(Name, Arity, PPId, Instrs,
- ProcLabel, C, Recons) },
- transform_instructions(Instrs0, ProcLabel, C0, C, Instrs).
-
-%-----------------------------------------------------------------------------%
+:- pred transform_c_procedure(c_procedure::in, c_procedure::out, int::in)
+ is det.
-:- pred transform_instructions(list(instruction), proc_label, counter, counter,
- list(instruction), io__state, io__state).
-:- mode transform_instructions(in, in, in, out, out, di, uo) is det.
-
-transform_instructions(Instrs0, ProcLabel, C0, C, Instrs) -->
- transform_instructions_2(Instrs0, ProcLabel, C0, C, Instrs).
-
-:- pred transform_instructions_2(list(instruction), proc_label,
- counter, counter, list(instruction), io__state, io__state).
-:- mode transform_instructions_2(in, in, in, out, out, di, uo) is det.
-
-transform_instructions_2([], _, C, C, []) --> [].
-transform_instructions_2([Instr0 | Instrs0], ProcLabel, C0, C, Instrs) -->
- transform_instruction(Instr0, ProcLabel, C0, InstrsA, C1),
- transform_instructions_2(Instrs0, ProcLabel, C1, C, InstrsB),
- { list__append(InstrsA, InstrsB, Instrs) }.
-
-%-----------------------------------------------------------------------------%
+transform_c_procedure(Proc0, Proc, MaxSize) :-
+ Proc0 = c_procedure(_, _, _, Instrs0, ProcLabel, C0, _),
+ transform_instructions(Instrs0, Instrs, C0, C, ProcLabel, MaxSize),
+ Proc = (Proc0 ^ cproc_code := Instrs) ^ cproc_label_nums := C.
-:- pred transform_instruction(instruction, proc_label, counter,
- list(instruction), counter, io__state, io__state).
-:- mode transform_instruction(in, in, in, out, out, di, uo) is det.
+:- pred transform_instructions(list(instruction)::in, list(instruction)::out,
+ counter::in, counter::out, proc_label::in, int::in) is det.
-transform_instruction(Instr0, ProcLabel, C0, Instrs, C) -->
- globals__io_lookup_int_option(max_jump_table_size, Size),
+transform_instructions([], [], !C, _, _).
+transform_instructions([Instr0 | Instrs0], Instrs, !C, ProcLabel, MaxSize) :-
+ transform_instructions(Instrs0, InstrsTail, !C, ProcLabel, MaxSize),
(
- { Size \= 0 },
- { Instr0 = computed_goto(_Rval, Labels) - _},
- { list__length(Labels, L) },
- { L > Size }
+ Instr0 = computed_goto(Rval, Labels) - Comment,
+ list__length(Labels, NumLabels),
+ NumLabels > MaxSize
->
- split_computed_goto(Instr0, Size, L, ProcLabel, C0, Instrs, C)
+ split_computed_goto(Rval, Labels, Comment, InstrsHead, !C,
+ MaxSize, NumLabels, ProcLabel),
+ list__append(InstrsHead, InstrsTail, Instrs)
;
- { Instrs = [Instr0] },
- { C = C0 }
+ Instrs = [Instr0 | InstrsTail]
).
%-----------------------------------------------------------------------------%
%
- % split_computed_goto(I, S, L, P, N0, Is, N)
+ % Given the pieces of a computed_goto instruction, split the table
+ % in half as many times as necessary to bring the jump table size
+ % below MaxSize, doing a binary search on the way.
%
- % If instruction, I, is a computed_goto whose jump_table size is
- % greater then S, then split the table in half and insert the
- % instructions, Is, to do a binary search down to a jump_table
- % whose size is sufficiently small.
- %
-:- pred split_computed_goto(instruction, int, int, proc_label, counter,
- list(instruction), counter, io__state, io__state).
-:- mode split_computed_goto(in, in, in, in, in, out, out, di, uo) is det.
-
-split_computed_goto(Instr0, MaxSize, Length, ProcLabel, C0, Instrs, C) -->
- (
- { Length =< MaxSize }
- ->
- { Instrs = [Instr0] },
- { C = C0 }
- ;
- { Instr0 = computed_goto(Rval, Labels) - _Comment }
- ->
- { counter__allocate(N, C0, C1) },
- { Mid = Length // 2 },
-
- (
- { list__split_list(Mid, Labels, Start0, End0) }
- ->
- { Start = Start0, End = End0 }
+:- pred split_computed_goto(rval::in, list(label)::in, string::in,
+ list(instruction)::out, counter::in, counter::out, int::in, int::in,
+ proc_label::in) is det.
+
+split_computed_goto(Rval, Labels, Comment, Instrs, !C, MaxSize, NumLabels,
+ ProcLabel) :-
+ ( NumLabels =< MaxSize ->
+ Instrs = [computed_goto(Rval, Labels) - Comment]
+ ;
+ counter__allocate(LabelNum, !C),
+ Mid = NumLabels // 2,
+ ( list__split_list(Mid, Labels, StartPrime, EndPrime) ->
+ Start = StartPrime,
+ End = EndPrime
;
- { error("split_computed_goto: list__split_list") }
+ error("split_computed_goto: list__split_list")
),
- { Index = binop((-), Rval, const(int_const(Mid))) },
- { Test = binop((>=), Rval, const(int_const(Mid))) },
- { ElseAddr = label(local(N, ProcLabel)) },
- { ElseLabel = label(local(N, ProcLabel)) - ""},
- { IfInstr = if_val(Test, ElseAddr ) - "Binary search"},
-
- { ThenInstr = computed_goto(Rval, Start) - "Then section" },
- { ElseInstr = computed_goto(Index, End) - "Else section" },
-
- split_computed_goto(ThenInstr, MaxSize, Mid, ProcLabel, C1,
- ThenInstrs, C2),
- split_computed_goto(ElseInstr, MaxSize, Length - Mid,
- ProcLabel, C2, ElseInstrs, C),
+ Index = binop((-), Rval, const(int_const(Mid))),
+ Test = binop((>=), Rval, const(int_const(Mid))),
+ ElseAddr = label(local(LabelNum, ProcLabel)),
+ IfInstr = if_val(Test, ElseAddr) - "binary search",
+ ElseInstr = label(local(LabelNum, ProcLabel)) - "",
+
+ split_computed_goto(Rval, Start, Comment ++ " then",
+ ThenInstrs, !C, MaxSize, Mid, ProcLabel),
+ split_computed_goto(Index, End, Comment ++ " else",
+ ElseInstrs, !C, MaxSize, NumLabels - Mid, ProcLabel),
- { list__append(ThenInstrs, [ElseLabel | ElseInstrs], InstrsA) },
- { Instrs = [IfInstr | InstrsA] }
- ;
- { error("split_computed_goto") }
+ list__append([IfInstr | ThenInstrs], [ElseInstr | ElseInstrs],
+ Instrs)
).
%-----------------------------------------------------------------------------%
Index: compiler/type_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/type_util.m,v
retrieving revision 1.137
diff -u -b -r1.137 type_util.m
--- compiler/type_util.m 23 Mar 2004 10:52:14 -0000 1.137
+++ compiler/type_util.m 4 Apr 2004 07:42:05 -0000
@@ -723,8 +723,7 @@
TypeArgs0)
->
TypeArgs = TypeArgs0,
- hlds_out__pred_or_func_to_str(PredOrFunc,
- PredOrFuncStr),
+ PredOrFuncStr = hlds_out__pred_or_func_to_str(PredOrFunc),
TypeCtor = unqualified(PredOrFuncStr) - 0
;
type_is_tuple(Type, TypeArgs1)
Index: compiler/unify_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unify_gen.m,v
retrieving revision 1.139
diff -u -b -r1.139 unify_gen.m
--- compiler/unify_gen.m 24 Mar 2004 02:57:13 -0000 1.139
+++ compiler/unify_gen.m 4 Apr 2004 08:09:47 -0000
@@ -199,7 +199,7 @@
Reverse = no
),
VarName = code_info__variable_to_string(!.CI, Var),
- hlds_out__cons_id_to_string(ConsId, ConsIdName),
+ ConsIdName = hlds_out__cons_id_to_string(ConsId),
(
Reverse = no,
string__append_list(["checking that ", VarName,
Index: compiler/unneeded_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unneeded_code.m,v
retrieving revision 1.17
diff -u -b -r1.17 unneeded_code.m
--- compiler/unneeded_code.m 23 Mar 2004 10:52:14 -0000 1.17
+++ compiler/unneeded_code.m 3 Apr 2004 17:38:04 -0000
@@ -62,9 +62,9 @@
:- import_module io.
-:- pred unneeded_code__process_proc_msg(pred_id::in, proc_id::in,
+:- pred process_proc_msg(pred_id::in, proc_id::in,
proc_info::in, proc_info::out, module_info::in, module_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -204,32 +204,31 @@
% Therefore we preprocess the procedure body to ensure that the nonlocals
% sets are accurate reflections of the true needs of goals.
-unneeded_code__process_proc_msg(PredId, ProcId, ProcInfo0, ProcInfo,
- ModuleInfo0, ModuleInfo) -->
- globals__io_lookup_bool_option(very_verbose, VeryVerbose),
- ( { VeryVerbose = yes } ->
- io__write_string("% Removing dead code in "),
- hlds_out__write_pred_proc_id(ModuleInfo0, PredId, ProcId),
- io__write_string(": "),
- { unneeded_code__pre_process_proc(ProcInfo0, ProcInfo1) },
- { unneeded_code__process_proc(ProcInfo1, ProcInfo,
- ModuleInfo0, ModuleInfo, Successful) },
+process_proc_msg(PredId, ProcId, !ProcInfo, !ModuleInfo, !IO) :-
+ globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
+ ( VeryVerbose = yes ->
+ io__write_string("% Removing dead code in ", !IO),
+ hlds_out__write_pred_proc_id(!.ModuleInfo, PredId, ProcId,
+ !IO),
+ io__write_string(": ", !IO),
+ pre_process_proc(!ProcInfo),
+ process_proc(!ProcInfo, !ModuleInfo,
+ Successful),
(
- { Successful = yes },
- io__write_string("done.\n")
+ Successful = yes,
+ io__write_string("done.\n", !IO)
;
- { Successful = no },
- io__write_string("none found.\n")
+ Successful = no,
+ io__write_string("none found.\n", !IO)
)
;
- { unneeded_code__pre_process_proc(ProcInfo0, ProcInfo1) },
- { unneeded_code__process_proc(ProcInfo1, ProcInfo,
- ModuleInfo0, ModuleInfo, _) }
+ pre_process_proc(!ProcInfo),
+ process_proc(!ProcInfo, !ModuleInfo, _)
).
-:- pred unneeded_code__pre_process_proc(proc_info::in, proc_info::out) is det.
+:- pred pre_process_proc(proc_info::in, proc_info::out) is det.
-unneeded_code__pre_process_proc(!ProcInfo) :-
+pre_process_proc(!ProcInfo) :-
proc_info_headvars(!.ProcInfo, HeadVars),
proc_info_goal(!.ProcInfo, Goal0),
proc_info_varset(!.ProcInfo, Varset0),
@@ -273,18 +272,18 @@
copy_limit :: int
).
-:- pred unneeded_code__process_proc(proc_info::in, proc_info::out,
+:- pred process_proc(proc_info::in, proc_info::out,
module_info::in, module_info::out, bool::out) is det.
-unneeded_code__process_proc(!ProcInfo, !ModuleInfo, Successful) :-
+process_proc(!ProcInfo, !ModuleInfo, Successful) :-
goal_path__fill_slots(!.ModuleInfo, !ProcInfo),
proc_info_goal(!.ProcInfo, Goal0),
proc_info_varset(!.ProcInfo, Varset0),
proc_info_vartypes(!.ProcInfo, VarTypes0),
- proc_info_get_initial_instmap(!.ProcInfo, !.ModuleInfo, InstMap0),
+ proc_info_get_initial_instmap(!.ProcInfo, !.ModuleInfo, InitInstMap),
Goal0 = _ - GoalInfo0,
goal_info_get_instmap_delta(GoalInfo0, InstMapDelta),
- instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap),
+ instmap__apply_instmap_delta(InitInstMap, InstMapDelta, FinalInstMap),
proc_info_instantiated_head_vars(!.ModuleInfo, !.ProcInfo,
NeededVarsList),
map__init(WhereNeededMap0),
@@ -294,20 +293,20 @@
),
list__foldl(NeededEverywhere, NeededVarsList,
WhereNeededMap0, WhereNeededMap1),
- map__init(RefinedGoals0),
module_info_globals(!.ModuleInfo, Globals),
globals__lookup_bool_option(Globals, reorder_conj, ReorderConj),
globals__lookup_bool_option(Globals, fully_strict, FullyStrict),
globals__lookup_int_option(Globals, unneeded_code_copy_limit,
Limit),
Options = option_values(FullyStrict, ReorderConj, Limit),
- unneeded_code__process_goal(Goal0, Goal1, InstMap0, InstMap,
+ process_goal(Goal0, Goal1, InitInstMap, FinalInstMap,
VarTypes0, !.ModuleInfo, Options, WhereNeededMap1, _,
- RefinedGoals0, RefinedGoals1, no, Changed),
- unneeded_code__refine_goal(Goal1, RefinedGoals1, Goal2, RefinedGoals),
+ map__init, RefinedGoals1, no, Changed),
+ refine_goal(Goal1, Goal2, RefinedGoals1, RefinedGoals),
require(map__is_empty(RefinedGoals),
- "unneeded_code__process_proc: goal reattachment unsuccessful"),
- ( Changed = yes ->
+ "process_proc: goal reattachment unsuccessful"),
+ (
+ Changed = yes,
% We need to fix up the goal_info by recalculating
% the nonlocal vars and the non-atomic instmap deltas.
proc_info_headvars(!.ProcInfo, HeadVars),
@@ -315,45 +314,46 @@
implicitly_quantify_clause_body(HeadVars, _Warnings,
Goal2, Goal3, Varset0, Varset, VarTypes0, VarTypes),
recompute_instmap_delta(no, Goal3, Goal, VarTypes, InstVarSet,
- InstMap0, !ModuleInfo),
+ InitInstMap, !ModuleInfo),
proc_info_set_goal(Goal, !ProcInfo),
proc_info_set_varset(Varset, !ProcInfo),
proc_info_set_vartypes(VarTypes, !ProcInfo),
- unneeded_code__process_proc(!ProcInfo, !ModuleInfo, _),
+ process_proc(!ProcInfo, !ModuleInfo, _),
Successful = yes
;
+ Changed = no,
Successful = no
).
-:- pred unneeded_code__process_goal(hlds_goal::in, hlds_goal::out, instmap::in,
- instmap::in, vartypes::in, module_info::in, option_values::in,
+:- pred process_goal(hlds_goal::in, hlds_goal::out,
+ instmap::in, instmap::in, vartypes::in, module_info::in,
+ option_values::in,
where_needed_map::in, where_needed_map::out,
refined_goal_map::in, refined_goal_map::out,
bool::in, bool::out) is det.
-unneeded_code__process_goal(Goal0, Goal, InstMap0, InstMap, VarTypes,
- ModuleInfo, Options, WhereNeededMap0, WhereNeededMap,
- RefinedGoals0, RefinedGoals, Changed0, Changed) :-
- unneeded_code__can_eliminate_or_move(Goal0, InstMap0, InstMap,
- VarTypes, ModuleInfo, Options, WhereNeededMap0, WhereInfo),
+process_goal(Goal0, Goal, InitInstMap, FinalInstMap, VarTypes,
+ ModuleInfo, Options, !WhereNeededMap, !RefinedGoals,
+ !Changed) :-
+ can_eliminate_or_move(Goal0, InitInstMap, FinalInstMap,
+ VarTypes, ModuleInfo, Options, !.WhereNeededMap, WhereInfo),
(
WhereInfo = everywhere,
- unneeded_code__process_goal_internal(Goal0, Goal,
- InstMap0, InstMap, VarTypes, ModuleInfo, Options,
- WhereNeededMap0, WhereNeededMap1,
- RefinedGoals0, RefinedGoals, Changed0, Changed)
+ process_goal_internal(Goal0, Goal, InitInstMap, FinalInstMap,
+ VarTypes, ModuleInfo, Options,
+ !WhereNeededMap, !RefinedGoals, !Changed)
;
WhereInfo = branches(Branches),
- unneeded_code__demand_inputs(Goal0, ModuleInfo, InstMap0,
- WhereInfo, WhereNeededMap0, WhereNeededMap1),
+ demand_inputs(Goal0, ModuleInfo, InitInstMap,
+ WhereInfo, !WhereNeededMap),
map__to_assoc_list(Branches, BranchList),
- list__foldl(unneeded_code__insert_branch_into_refined_goals(
- Goal0), BranchList, RefinedGoals0, RefinedGoals),
+ list__foldl(insert_branch_into_refined_goals(Goal0),
+ BranchList, !RefinedGoals),
true_goal(Goal),
- Changed = yes
+ !:Changed = yes
),
- unneeded_code__undemand_virgin_outputs(Goal0, ModuleInfo, InstMap0,
- WhereNeededMap1, WhereNeededMap2),
+ undemand_virgin_outputs(Goal0, ModuleInfo, InitInstMap,
+ !WhereNeededMap),
(
Goal = _ - GoalInfo,
goal_info_get_features(GoalInfo, Features),
@@ -366,70 +366,64 @@
%
% This code requires compound goals containing impure
% code to also be marked impure.
- map__map_values(unneeded_code__demand_var_everywhere,
- WhereNeededMap2, WhereNeededMap)
+ map__map_values(demand_var_everywhere, !WhereNeededMap)
;
- WhereNeededMap = WhereNeededMap2
+ true
).
-:- pred unneeded_code__insert_branch_into_refined_goals(hlds_goal::in,
+:- pred insert_branch_into_refined_goals(hlds_goal::in,
pair(branch_point, set(int))::in,
refined_goal_map::in, refined_goal_map::out) is det.
-unneeded_code__insert_branch_into_refined_goals(Goal,
- BranchPoint - BranchNumSet, RefinedGoals0, RefinedGoals) :-
+insert_branch_into_refined_goals(Goal, BranchPoint - BranchNumSet,
+ !RefinedGoals) :-
BranchPoint = branch_point(GoalPath, _),
set__to_sorted_list(BranchNumSet, BranchNums),
- list__foldl(unneeded_code__insert_branch_arm_into_refined_goals(
- Goal, GoalPath), BranchNums, RefinedGoals0, RefinedGoals).
+ list__foldl(insert_branch_arm_into_refined_goals(
+ Goal, GoalPath), BranchNums, !RefinedGoals).
-:- pred unneeded_code__insert_branch_arm_into_refined_goals(hlds_goal::in,
+:- pred insert_branch_arm_into_refined_goals(hlds_goal::in,
goal_path::in, int::in,
refined_goal_map::in, refined_goal_map::out) is det.
-unneeded_code__insert_branch_arm_into_refined_goals(Goal, GoalPath, BranchNum,
- RefinedGoals0, RefinedGoals) :-
+insert_branch_arm_into_refined_goals(Goal, GoalPath, BranchNum,
+ !RefinedGoals) :-
Key = GoalPath - BranchNum,
- ( map__search(RefinedGoals0, Key, Goals0) ->
+ ( map__search(!.RefinedGoals, Key, Goals0) ->
Goals = [Goal | Goals0],
- map__det_update(RefinedGoals0, Key, Goals, RefinedGoals)
+ map__det_update(!.RefinedGoals, Key, Goals, !:RefinedGoals)
;
- map__det_insert(RefinedGoals0, Key, [Goal], RefinedGoals)
+ map__det_insert(!.RefinedGoals, Key, [Goal], !:RefinedGoals)
).
%-----------------------------------------------------------------------------%
-:- pred unneeded_code__can_eliminate_or_move(hlds_goal::in, instmap::in,
+:- pred can_eliminate_or_move(hlds_goal::in, instmap::in,
instmap::in, vartypes::in, module_info::in, option_values::in,
where_needed_map::in, where_needed::out) is det.
-unneeded_code__can_eliminate_or_move(Goal, InstMap0, InstMap, VarTypes,
- ModuleInfo, Options, WhereNeededMap, WhereInfo) :-
- instmap_changed_vars(InstMap0, InstMap, VarTypes, ModuleInfo,
+can_eliminate_or_move(Goal, InitInstMap, FinalInstMap, VarTypes, ModuleInfo,
+ Options, WhereNeededMap, !:WhereInfo) :-
+ instmap_changed_vars(InitInstMap, FinalInstMap, VarTypes, ModuleInfo,
ChangedVarSet),
set__to_sorted_list(ChangedVarSet, ChangedVars),
map__init(Empty),
- WhereInfo0 = branches(Empty),
+ !:WhereInfo = branches(Empty),
Goal = _ - GoalInfo,
goal_info_get_goal_path(GoalInfo, CurrentPath),
- list__foldl(
- unneeded_code__collect_where_needed(
- CurrentPath, WhereNeededMap),
- ChangedVars, WhereInfo0, WhereInfo1),
- unneeded_code__adjust_where_needed(Goal, Options,
- WhereInfo1, WhereInfo).
+ list__foldl(collect_where_needed(CurrentPath, WhereNeededMap),
+ ChangedVars, !WhereInfo),
+ adjust_where_needed(Goal, Options, !WhereInfo).
-:- pred unneeded_code__collect_where_needed(goal_path::in,
+:- pred collect_where_needed(goal_path::in,
where_needed_map::in, prog_var::in,
where_needed::in, where_needed::out) is det.
-unneeded_code__collect_where_needed(CurrentPath, WhereNeededMap, ChangedVar,
- WhereInfo0, WhereInfo) :-
+collect_where_needed(CurrentPath, WhereNeededMap, ChangedVar, !WhereInfo) :-
( map__search(WhereNeededMap, ChangedVar, Where) ->
- unneeded_code__where_needed_upper_bound(CurrentPath,
- Where, WhereInfo0, WhereInfo)
+ where_needed_upper_bound(CurrentPath, Where, !WhereInfo)
;
- WhereInfo = WhereInfo0
+ true
).
% This is the predicate responsible for ensuring that the act of optimizing
@@ -437,10 +431,10 @@
% operational semantics only in ways that are explicitly permitted by the
% programmer.
-:- pred unneeded_code__adjust_where_needed(hlds_goal::in, option_values::in,
+:- pred adjust_where_needed(hlds_goal::in, option_values::in,
where_needed::in, where_needed::out) is det.
-unneeded_code__adjust_where_needed(Goal, Options, WhereInfo0, WhereInfo) :-
+adjust_where_needed(Goal, Options, !WhereInfo) :-
(
Goal = GoalExpr - GoalInfo,
(
@@ -449,7 +443,7 @@
% it shouldn't, and those goals may have
% undesirable behavior (e.g. infinite loops).
goal_info_get_determinism(GoalInfo, Detism),
- unneeded_code__detism_is_moveable(Detism, no)
+ detism_is_moveable(Detism, no)
;
% Do not move impure or semipure goals,
% since their ordering wrt other such goals
@@ -467,7 +461,7 @@
% delete them.
Options^reorder_conj = no,
goal_can_loop_or_throw(Goal),
- WhereInfo0 = branches(BranchMap),
+ !.WhereInfo = branches(BranchMap),
\+ map__is_empty(BranchMap)
;
% Do not delete the `true' goal, since
@@ -477,7 +471,7 @@
% body is executed.
GoalExpr = conj([])
;
- WhereInfo0 = branches(BranchMap),
+ !.WhereInfo = branches(BranchMap),
map__values(BranchMap, BranchArms),
list__map(set__count, BranchArms, BranchArmCounts),
BranchArmCount = list__foldl(int__plus,
@@ -496,151 +490,135 @@
% code after all.
)
->
- WhereInfo = everywhere
+ !:WhereInfo = everywhere
;
- WhereInfo = WhereInfo0
+ true
).
-:- pred unneeded_code__detism_is_moveable(determinism::in, bool::out) is det.
+:- pred detism_is_moveable(determinism::in, bool::out) is det.
-unneeded_code__detism_is_moveable(det, yes).
-unneeded_code__detism_is_moveable(semidet, no).
-unneeded_code__detism_is_moveable(nondet, no).
-unneeded_code__detism_is_moveable(multidet, yes).
-unneeded_code__detism_is_moveable(erroneous, no).
-unneeded_code__detism_is_moveable(failure, no).
-unneeded_code__detism_is_moveable(cc_nondet, no).
-unneeded_code__detism_is_moveable(cc_multidet, yes).
+detism_is_moveable(det, yes).
+detism_is_moveable(semidet, no).
+detism_is_moveable(nondet, no).
+detism_is_moveable(multidet, yes).
+detism_is_moveable(erroneous, no).
+detism_is_moveable(failure, no).
+detism_is_moveable(cc_nondet, no).
+detism_is_moveable(cc_multidet, yes).
%---------------------------------------------------------------------------%
-:- pred unneeded_code__demand_inputs(hlds_goal::in, module_info::in,
+:- pred demand_inputs(hlds_goal::in, module_info::in,
instmap::in, where_needed::in,
where_needed_map::in, where_needed_map::out) is det.
-unneeded_code__demand_inputs(Goal, ModuleInfo, InstMap0, WhereNeeded,
- WhereNeededMap0, WhereNeededMap) :-
+demand_inputs(Goal, ModuleInfo, InitInstMap, WhereNeeded, !WhereNeededMap) :-
Goal = _ - GoalInfo,
goal_info_get_nonlocals(GoalInfo, NonLocalSet),
goal_info_get_goal_path(GoalInfo, GoalPath),
set__to_sorted_list(NonLocalSet, NonLocals),
- list__filter(unneeded_code__nonlocal_may_be_input(ModuleInfo, InstMap0),
+ list__filter(nonlocal_may_be_input(ModuleInfo, InitInstMap),
NonLocals, Inputs),
- list__foldl(unneeded_code__demand_var(GoalPath, WhereNeeded), Inputs,
- WhereNeededMap0, WhereNeededMap).
+ list__foldl(demand_var(GoalPath, WhereNeeded), Inputs,
+ !WhereNeededMap).
-:- pred unneeded_code__nonlocal_may_be_input(module_info::in, instmap::in,
+:- pred nonlocal_may_be_input(module_info::in, instmap::in,
prog_var::in) is semidet.
-unneeded_code__nonlocal_may_be_input(ModuleInfo, InstMap0, Var) :-
- instmap__lookup_var(InstMap0, Var, Inst),
+nonlocal_may_be_input(ModuleInfo, InstMap, Var) :-
+ instmap__lookup_var(InstMap, Var, Inst),
inst_is_bound(ModuleInfo, Inst).
%---------------------------------------------------------------------------%
-:- pred unneeded_code__undemand_virgin_outputs(hlds_goal::in, module_info::in,
+:- pred undemand_virgin_outputs(hlds_goal::in, module_info::in,
instmap::in, where_needed_map::in, where_needed_map::out) is det.
-unneeded_code__undemand_virgin_outputs(Goal, ModuleInfo, InstMap0,
- WhereNeededMap0, WhereNeededMap) :-
+undemand_virgin_outputs(Goal, ModuleInfo, InstMap, !WhereNeededMap) :-
Goal = _ - GoalInfo,
goal_info_get_nonlocals(GoalInfo, NonLocalSet),
set__to_sorted_list(NonLocalSet, NonLocals),
- list__filter(unneeded_code__nonlocal_is_virgin_output(
- ModuleInfo, InstMap0), NonLocals, VirginOutputs),
- list__foldl(unneeded_code__undemand_var, VirginOutputs,
- WhereNeededMap0, WhereNeededMap).
+ list__filter(nonlocal_is_virgin_output(ModuleInfo, InstMap),
+ NonLocals, VirginOutputs),
+ list__foldl(undemand_var, VirginOutputs, !WhereNeededMap).
-:- pred unneeded_code__nonlocal_is_virgin_output(module_info::in, instmap::in,
+:- pred nonlocal_is_virgin_output(module_info::in, instmap::in,
prog_var::in) is semidet.
-unneeded_code__nonlocal_is_virgin_output(ModuleInfo, InstMap0, Var) :-
- instmap__lookup_var(InstMap0, Var, Inst),
+nonlocal_is_virgin_output(ModuleInfo, InstMap, Var) :-
+ instmap__lookup_var(InstMap, Var, Inst),
\+ inst_is_bound(ModuleInfo, Inst).
%---------------------------------------------------------------------------%
-:- pred unneeded_code__demand_var(goal_path::in, where_needed::in,
+:- pred demand_var(goal_path::in, where_needed::in,
prog_var::in, where_needed_map::in, where_needed_map::out) is det.
-unneeded_code__demand_var(CurrentPath, WhereNeeded, Var,
- WhereNeededMap0, WhereNeededMap) :-
- ( map__search(WhereNeededMap0, Var, Where0) ->
- unneeded_code__where_needed_upper_bound(CurrentPath,
- WhereNeeded, Where0, Where),
- map__det_update(WhereNeededMap0, Var, Where, WhereNeededMap)
+demand_var(CurrentPath, WhereNeeded, Var, !WhereNeededMap) :-
+ ( map__search(!.WhereNeededMap, Var, Where0) ->
+ where_needed_upper_bound(CurrentPath, WhereNeeded, Where0,
+ Where),
+ map__det_update(!.WhereNeededMap, Var, Where, !:WhereNeededMap)
;
- map__det_insert(WhereNeededMap0, Var, WhereNeeded,
- WhereNeededMap)
+ map__det_insert(!.WhereNeededMap, Var, WhereNeeded,
+ !:WhereNeededMap)
).
-:- pred unneeded_code__undemand_var(prog_var::in,
+:- pred undemand_var(prog_var::in,
where_needed_map::in, where_needed_map::out) is det.
-unneeded_code__undemand_var(Var, WhereNeededMap0, WhereNeededMap) :-
+undemand_var(Var, WhereNeededMap0, WhereNeededMap) :-
map__delete(WhereNeededMap0, Var, WhereNeededMap).
%---------------------------------------------------------------------------%
-:- pred unneeded_code__demand_var_everywhere(prog_var::in, where_needed::in,
+:- pred demand_var_everywhere(prog_var::in, where_needed::in,
where_needed::out) is det.
-unneeded_code__demand_var_everywhere(_Var, _WhereNeeded0, everywhere).
+demand_var_everywhere(_Var, _WhereNeeded0, everywhere).
%---------------------------------------------------------------------------%
-:- pred unneeded_code__process_goal_internal(hlds_goal::in, hlds_goal::out,
+:- pred process_goal_internal(hlds_goal::in, hlds_goal::out,
instmap::in, instmap::in, vartypes::in, module_info::in,
option_values::in, where_needed_map::in, where_needed_map::out,
refined_goal_map::in, refined_goal_map::out,
bool::in, bool::out) is det.
-unneeded_code__process_goal_internal(Goal0, Goal, InstMap0, InstMap,
- VarTypes, ModuleInfo, Options, WhereNeededMap0, WhereNeededMap,
- RefinedGoals0, RefinedGoals, Changed0, Changed) :-
+process_goal_internal(Goal0, Goal, InitInstMap, FinalInstMap, VarTypes,
+ ModuleInfo, Options, !WhereNeededMap, !RefinedGoals,
+ !Changed) :-
Goal0 = GoalExpr0 - GoalInfo0,
- % Goal = GoalExpr - GoalInfo,
(
GoalExpr0 = unify(_, _, _, _, _),
Goal = Goal0,
- unneeded_code__demand_inputs(Goal, ModuleInfo, InstMap0,
- everywhere, WhereNeededMap0, WhereNeededMap),
- RefinedGoals = RefinedGoals0,
- Changed = Changed0
+ demand_inputs(Goal, ModuleInfo, InitInstMap,
+ everywhere, !WhereNeededMap)
;
GoalExpr0 = call(_, _, _, _, _, _),
Goal = Goal0,
- unneeded_code__demand_inputs(Goal, ModuleInfo, InstMap0,
- everywhere, WhereNeededMap0, WhereNeededMap),
- RefinedGoals = RefinedGoals0,
- Changed = Changed0
+ demand_inputs(Goal, ModuleInfo, InitInstMap,
+ everywhere, !WhereNeededMap)
;
GoalExpr0 = generic_call(_, _, _, _),
Goal = Goal0,
- unneeded_code__demand_inputs(Goal, ModuleInfo, InstMap0,
- everywhere, WhereNeededMap0, WhereNeededMap),
- RefinedGoals = RefinedGoals0,
- Changed = Changed0
+ demand_inputs(Goal, ModuleInfo, InitInstMap,
+ everywhere, !WhereNeededMap)
;
GoalExpr0 = foreign_proc(_, _, _, _, _, _, _),
Goal = Goal0,
- unneeded_code__demand_inputs(Goal, ModuleInfo, InstMap0,
- everywhere, WhereNeededMap0, WhereNeededMap),
- RefinedGoals = RefinedGoals0,
- Changed = Changed0
+ demand_inputs(Goal, ModuleInfo, InitInstMap,
+ everywhere, !WhereNeededMap)
;
GoalExpr0 = par_conj(_),
Goal = Goal0,
- unneeded_code__demand_inputs(Goal, ModuleInfo, InstMap0,
- everywhere, WhereNeededMap0, WhereNeededMap),
- RefinedGoals = RefinedGoals0,
- Changed = Changed0
+ demand_inputs(Goal, ModuleInfo, InitInstMap,
+ everywhere, !WhereNeededMap)
;
GoalExpr0 = conj(Conjuncts0),
- unneeded_code__process_conj(Conjuncts0, Conjuncts,
- InstMap0, InstMap, VarTypes, ModuleInfo, Options,
- WhereNeededMap0, WhereNeededMap,
- RefinedGoals0, RefinedGoals, Changed0, Changed),
+ process_conj(Conjuncts0, Conjuncts, InitInstMap, FinalInstMap,
+ VarTypes, ModuleInfo, Options,
+ !WhereNeededMap, !RefinedGoals, !Changed),
GoalExpr = conj(Conjuncts),
Goal = GoalExpr - GoalInfo0
;
@@ -654,67 +632,60 @@
->
NumAlt = NumCases
;
- error("unneeded_code__process_goal_internal: switch count")
+ error("process_goal_internal: switch count")
),
goal_info_get_goal_path(GoalInfo0, GoalPath),
BranchPoint = branch_point(GoalPath, switch(NumAlt)),
- map__map_values(unneeded_code__demand_var_everywhere,
- WhereNeededMap0, WhereNeededMap1),
+ map__map_values(demand_var_everywhere, !WhereNeededMap),
map__init(BranchNeededMap0),
- unneeded_code__process_cases(Cases0, BranchPoint, 1,
- InstMap0, InstMap, VarTypes, ModuleInfo, Options,
- GoalPath, Cases, WhereNeededMap1,
- BranchNeededMap0, BranchNeededMap,
- RefinedGoals0, RefinedGoals, Changed0, Changed),
- unneeded_code__merge_where_needed_maps(GoalPath,
- WhereNeededMap1, BranchNeededMap, WhereNeededMap2),
- unneeded_code__demand_var(GoalPath, everywhere, SwitchVar,
- WhereNeededMap2, WhereNeededMap),
+ process_cases(Cases0, Cases, BranchPoint, 1,
+ InitInstMap, FinalInstMap,
+ VarTypes, ModuleInfo, Options, GoalPath,
+ !.WhereNeededMap, BranchNeededMap0, BranchNeededMap,
+ !RefinedGoals, !Changed),
+ merge_where_needed_maps(GoalPath, !.WhereNeededMap,
+ BranchNeededMap, !:WhereNeededMap),
+ demand_var(GoalPath, everywhere, SwitchVar, !WhereNeededMap),
GoalExpr = switch(SwitchVar, CanFail, Cases),
Goal = GoalExpr - GoalInfo0
;
GoalExpr0 = disj(Disjuncts0),
goal_info_get_goal_path(GoalInfo0, GoalPath),
- map__map_values(unneeded_code__demand_var_everywhere,
- WhereNeededMap0, WhereNeededMap1),
- unneeded_code__process_disj(Disjuncts0, InstMap0, InstMap,
- VarTypes, ModuleInfo, Options, GoalPath, Disjuncts,
- WhereNeededMap1, WhereNeededMap1, WhereNeededMap,
- RefinedGoals0, RefinedGoals, Changed0, Changed),
+ map__map_values(demand_var_everywhere, !WhereNeededMap),
+ process_disj(Disjuncts0, Disjuncts, InitInstMap, FinalInstMap,
+ VarTypes, ModuleInfo, Options, GoalPath,
+ !.WhereNeededMap, !.WhereNeededMap, !:WhereNeededMap,
+ !RefinedGoals, !Changed),
GoalExpr = disj(Disjuncts),
Goal = GoalExpr - GoalInfo0
;
GoalExpr0 = if_then_else(Quant, Cond0, Then0, Else0),
goal_info_get_goal_path(GoalInfo0, GoalPath),
BranchPoint = branch_point(GoalPath, ite),
- map__map_values(unneeded_code__demand_var_everywhere,
- WhereNeededMap0, WhereNeededMap1),
- unneeded_code__process_ite(Cond0, Then0, Else0, BranchPoint,
- InstMap0, InstMap, VarTypes, ModuleInfo, Options,
- GoalPath, Cond, Then, Else, WhereNeededMap1,
- WhereNeededMap, RefinedGoals0, RefinedGoals, Changed0,
- Changed),
+ map__map_values(demand_var_everywhere, !WhereNeededMap),
+ process_ite(Cond0, Cond, Then0, Then, Else0, Else, BranchPoint,
+ InitInstMap, FinalInstMap, VarTypes, ModuleInfo,
+ Options, GoalPath, !WhereNeededMap,
+ !RefinedGoals, !Changed),
GoalExpr = if_then_else(Quant, Cond, Then, Else),
Goal = GoalExpr - GoalInfo0
;
GoalExpr0 = not(NegGoal0),
- unneeded_code__process_goal(NegGoal0, NegGoal,
- InstMap0, InstMap, VarTypes, ModuleInfo, Options,
- WhereNeededMap0, WhereNeededMap,
- RefinedGoals0, RefinedGoals, Changed0, Changed),
+ process_goal(NegGoal0, NegGoal, InitInstMap, FinalInstMap,
+ VarTypes, ModuleInfo, Options,
+ !WhereNeededMap, !RefinedGoals, !Changed),
GoalExpr = not(NegGoal),
Goal = GoalExpr - GoalInfo0
;
GoalExpr0 = some(Vars, CanRemove, SomeGoal0),
- unneeded_code__process_goal(SomeGoal0, SomeGoal,
- InstMap0, InstMap, VarTypes, ModuleInfo, Options,
- WhereNeededMap0, WhereNeededMap,
- RefinedGoals0, RefinedGoals, Changed0, Changed),
+ process_goal(SomeGoal0, SomeGoal, InitInstMap, FinalInstMap,
+ VarTypes, ModuleInfo, Options,
+ !WhereNeededMap, !RefinedGoals, !Changed),
GoalExpr = some(Vars, CanRemove, SomeGoal),
Goal = GoalExpr - GoalInfo0
;
GoalExpr0 = shorthand(_),
- error("shorthand in unneeded_code__process_goal_internal")
+ error("shorthand in process_goal_internal")
).
%---------------------------------------------------------------------------%
@@ -722,60 +693,54 @@
:- type bracketed_goal
---> bracketed_goal(hlds_goal, instmap, instmap).
-:- pred unneeded_code__process_conj(list(hlds_goal)::in, list(hlds_goal)::out,
+:- pred process_conj(list(hlds_goal)::in, list(hlds_goal)::out,
instmap::in, instmap::in, vartypes::in, module_info::in,
option_values::in, where_needed_map::in, where_needed_map::out,
refined_goal_map::in, refined_goal_map::out,
bool::in, bool::out) is det.
-unneeded_code__process_conj(Goals0, Goals, InstMap0, _InstMap, VarTypes,
- ModuleInfo, Options, WhereNeededMap0, WhereNeededMap,
- RefinedGoals0, RefinedGoals, Changed0, Changed) :-
- unneeded_code__build_bracketed_conj(Goals0, InstMap0, BracketedGoals),
+process_conj(Goals0, Goals, InitInstMap, _FinalInstMap, VarTypes, ModuleInfo,
+ Options, !WhereNeededMap, !RefinedGoals, !Changed) :-
+ build_bracketed_conj(Goals0, InitInstMap, BracketedGoals),
list__reverse(BracketedGoals, RevBracketedGoals),
- unneeded_code__process_rev_bracketed_conj(RevBracketedGoals, RevGoals,
- VarTypes, ModuleInfo, Options, WhereNeededMap0, WhereNeededMap,
- RefinedGoals0, RefinedGoals, Changed0, Changed),
+ process_rev_bracketed_conj(RevBracketedGoals, RevGoals, VarTypes,
+ ModuleInfo, Options, !WhereNeededMap, !RefinedGoals, !Changed),
list__reverse(RevGoals, Goals).
-:- pred unneeded_code__build_bracketed_conj(list(hlds_goal)::in, instmap::in,
+:- pred build_bracketed_conj(list(hlds_goal)::in, instmap::in,
list(bracketed_goal)::out) is det.
-unneeded_code__build_bracketed_conj([], _, []).
-unneeded_code__build_bracketed_conj([Goal | Goals], InstMap0, BracketedGoals)
- :-
- ( instmap__is_unreachable(InstMap0) ->
+build_bracketed_conj([], _, []).
+build_bracketed_conj([Goal | Goals], InitInstMap, BracketedGoals) :-
+ ( instmap__is_unreachable(InitInstMap) ->
BracketedGoals = []
;
Goal = _ - GoalInfo,
goal_info_get_instmap_delta(GoalInfo, InstMapDelta),
- instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap1),
- unneeded_code__build_bracketed_conj(Goals, InstMap1,
- BracketedTail),
- BracketedGoal = bracketed_goal(Goal, InstMap0, InstMap1),
+ instmap__apply_instmap_delta(InitInstMap, InstMapDelta,
+ FinalInstMap),
+ build_bracketed_conj(Goals, FinalInstMap, BracketedTail),
+ BracketedGoal = bracketed_goal(Goal,
+ InitInstMap, FinalInstMap),
BracketedGoals = [BracketedGoal | BracketedTail]
).
-:- pred unneeded_code__process_rev_bracketed_conj(list(bracketed_goal)::in,
+:- pred process_rev_bracketed_conj(list(bracketed_goal)::in,
list(hlds_goal)::out, vartypes::in, module_info::in, option_values::in,
where_needed_map::in, where_needed_map::out,
refined_goal_map::in, refined_goal_map::out,
bool::in, bool::out) is det.
-unneeded_code__process_rev_bracketed_conj([], [], _, _, _,
- WhereNeededMap, WhereNeededMap,
- RefinedGoals, RefinedGoals, Changed, Changed).
-unneeded_code__process_rev_bracketed_conj([BracketedGoal | BracketedGoals],
- Goals, VarTypes, ModuleInfo, Options, WhereNeededMap0,
- WhereNeededMap, RefinedGoals0, RefinedGoals, Changed0,
- Changed) :-
- BracketedGoal = bracketed_goal(Goal0, InstMap0, InstMap),
- unneeded_code__process_goal(Goal0, Goal1, InstMap0, InstMap,
- VarTypes, ModuleInfo, Options, WhereNeededMap0, WhereNeededMap1,
- RefinedGoals0, RefinedGoals1, Changed0, Changed1),
- unneeded_code__process_rev_bracketed_conj(BracketedGoals, Goals1,
- VarTypes, ModuleInfo, Options, WhereNeededMap1, WhereNeededMap,
- RefinedGoals1, RefinedGoals, Changed1, Changed),
+process_rev_bracketed_conj([], [], _, _, _,
+ !WhereNeededMap, !RefinedGoals, !Changed).
+process_rev_bracketed_conj([BracketedGoal | BracketedGoals], Goals,
+ VarTypes, ModuleInfo, Options,
+ !WhereNeededMap, !RefinedGoals, !Changed) :-
+ BracketedGoal = bracketed_goal(Goal0, InitInstMap, FinalInstMap),
+ process_goal(Goal0, Goal1, InitInstMap, FinalInstMap, VarTypes,
+ ModuleInfo, Options, !WhereNeededMap, !RefinedGoals, !Changed),
+ process_rev_bracketed_conj(BracketedGoals, Goals1, VarTypes,
+ ModuleInfo, Options, !WhereNeededMap, !RefinedGoals, !Changed),
( true_goal(Goal1) ->
Goals = Goals1
;
@@ -784,99 +749,91 @@
%---------------------------------------------------------------------------%
-:- pred unneeded_code__process_disj(list(hlds_goal)::in, instmap::in,
- instmap::in, vartypes::in, module_info::in, option_values::in,
- goal_path::in, list(hlds_goal)::out,
+:- pred process_disj(list(hlds_goal)::in, list(hlds_goal)::out,
+ instmap::in, instmap::in, vartypes::in, module_info::in,
+ option_values::in, goal_path::in,
where_needed_map::in, where_needed_map::in, where_needed_map::out,
refined_goal_map::in, refined_goal_map::out,
bool::in, bool::out) is det.
-unneeded_code__process_disj([], _, _, _, _, _, _, [],
- _, WhereNeededMap, WhereNeededMap,
- RefinedGoals, RefinedGoals, Changed, Changed).
-unneeded_code__process_disj([Goal0 | Goals0], InstMap0, InstMap, VarTypes,
- ModuleInfo, Options, CurrentPath, [Goal | Goals],
- StartWhereNeededMap, WhereNeededMap0, WhereNeededMap,
- RefinedGoals0, RefinedGoals, Changed0, Changed) :-
- unneeded_code__process_goal(Goal0, Goal, InstMap0, InstMap, VarTypes,
+process_disj([], [], _, _, _, _, _, _, _,
+ !WhereNeededMap, !RefinedGoals, !Changed).
+process_disj([Goal0 | Goals0], [Goal | Goals], InitInstMap, FinalInstMap,
+ VarTypes, ModuleInfo, Options, CurrentPath,
+ StartWhereNeededMap, !WhereNeededMap, !RefinedGoals,
+ !Changed) :-
+ process_goal(Goal0, Goal, InitInstMap, FinalInstMap, VarTypes,
ModuleInfo, Options, StartWhereNeededMap, WhereNeededMapFirst,
- RefinedGoals0, RefinedGoals1, Changed0, Changed1),
+ !RefinedGoals, !Changed),
map__to_assoc_list(WhereNeededMapFirst, WhereNeededList),
- unneeded_code__add_where_needed_list(WhereNeededList, CurrentPath,
- WhereNeededMap0, WhereNeededMap1),
- unneeded_code__process_disj(Goals0, InstMap0, InstMap, VarTypes,
- ModuleInfo, Options, CurrentPath, Goals,
- StartWhereNeededMap, WhereNeededMap1, WhereNeededMap,
- RefinedGoals1, RefinedGoals, Changed1, Changed).
+ add_where_needed_list(WhereNeededList, CurrentPath, !WhereNeededMap),
+ process_disj(Goals0, Goals, InitInstMap, FinalInstMap, VarTypes,
+ ModuleInfo, Options, CurrentPath, StartWhereNeededMap,
+ !WhereNeededMap, !RefinedGoals, !Changed).
%---------------------------------------------------------------------------%
-:- pred unneeded_code__process_cases(list(case)::in, branch_point::in, int::in,
- instmap::in, instmap::in, vartypes::in, module_info::in,
- option_values::in, goal_path::in, list(case)::out, where_needed_map::in,
+:- pred process_cases(list(case)::in, list(case)::out, branch_point::in,
+ int::in, instmap::in, instmap::in, vartypes::in, module_info::in,
+ option_values::in, goal_path::in, where_needed_map::in,
where_needed_map::in, where_needed_map::out,
refined_goal_map::in, refined_goal_map::out,
bool::in, bool::out) is det.
-unneeded_code__process_cases([], _, _, _, _, _, _, _, _, [],
- _, WhereNeededMap, WhereNeededMap,
- RefinedGoals, RefinedGoals, Changed, Changed).
-unneeded_code__process_cases([case(Var, Goal0) | Cases0],
- BranchPoint, BranchNum, InstMap0, InstMap,
- VarTypes, ModuleInfo, Options, CurrentPath,
- [case(Var, Goal) | Cases], StartWhereNeededMap,
- WhereNeededMap0, WhereNeededMap,
- RefinedGoals0, RefinedGoals, Changed0, Changed) :-
- unneeded_code__process_goal(Goal0, Goal, InstMap0, InstMap, VarTypes,
+process_cases([], [], _, _, _, _, _, _, _, _, _,
+ !WhereNeededMap, !RefinedGoals, !Changed).
+process_cases([case(Var, Goal0) | Cases0], [case(Var, Goal) | Cases],
+ BranchPoint, BranchNum, InitInstMap, FinalInstMap, VarTypes,
+ ModuleInfo, Options, CurrentPath, StartWhereNeededMap,
+ !WhereNeededMap, !RefinedGoals, !Changed) :-
+ process_goal(Goal0, Goal, InitInstMap, FinalInstMap, VarTypes,
ModuleInfo, Options, StartWhereNeededMap, WhereNeededMapFirst,
- RefinedGoals0, RefinedGoals1, Changed0, Changed1),
+ !RefinedGoals, !Changed),
map__to_assoc_list(WhereNeededMapFirst, WhereNeededList),
- unneeded_code__add_alt_start(WhereNeededList, BranchPoint, BranchNum,
- CurrentPath, WhereNeededMap0, WhereNeededMap1),
- unneeded_code__process_cases(Cases0, BranchPoint, BranchNum + 1,
- InstMap0, InstMap, VarTypes, ModuleInfo, Options, CurrentPath,
- Cases, StartWhereNeededMap, WhereNeededMap1, WhereNeededMap,
- RefinedGoals1, RefinedGoals, Changed1, Changed).
+ add_alt_start(WhereNeededList, BranchPoint, BranchNum,
+ CurrentPath, !WhereNeededMap),
+ process_cases(Cases0, Cases, BranchPoint, BranchNum + 1,
+ InitInstMap, FinalInstMap, VarTypes, ModuleInfo, Options,
+ CurrentPath, StartWhereNeededMap,
+ !WhereNeededMap, !RefinedGoals, !Changed).
%---------------------------------------------------------------------------%
-:- pred unneeded_code__process_ite(hlds_goal::in, hlds_goal::in, hlds_goal::in,
+:- pred process_ite(hlds_goal::in, hlds_goal::out,
+ hlds_goal::in, hlds_goal::out, hlds_goal::in, hlds_goal::out,
branch_point::in, instmap::in, instmap::in, vartypes::in,
module_info::in, option_values::in, goal_path::in,
- hlds_goal::out, hlds_goal::out, hlds_goal::out,
where_needed_map::in, where_needed_map::out,
refined_goal_map::in, refined_goal_map::out,
bool::in, bool::out) is det.
-unneeded_code__process_ite(Cond0, Then0, Else0, BranchPoint,
- InstMap0, InstMap, VarTypes, ModuleInfo, Options, CurrentPath,
- Cond, Then, Else, WhereNeededMap0, WhereNeededMap,
- RefinedGoals0, RefinedGoals, Changed0, Changed) :-
+process_ite(Cond0, Cond, Then0, Then, Else0, Else, BranchPoint,
+ InitInstMap, FinalInstMap, VarTypes, ModuleInfo, Options,
+ CurrentPath, !WhereNeededMap, !RefinedGoals, !Changed) :-
Cond0 = _ - CondInfo0,
goal_info_get_instmap_delta(CondInfo0, InstMapDelta),
- instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMapCond),
+ instmap__apply_instmap_delta(InitInstMap, InstMapDelta, InstMapCond),
- unneeded_code__process_goal(Else0, Else, InstMap0, InstMap, VarTypes,
- ModuleInfo, Options, WhereNeededMap0, WhereNeededMapElse,
- RefinedGoals0, RefinedGoals1, Changed0, Changed1),
- unneeded_code__process_goal(Then0, Then, InstMapCond, InstMap,
- VarTypes, ModuleInfo, Options, WhereNeededMap0,
- WhereNeededMapThen, RefinedGoals1, RefinedGoals2, Changed1,
- Changed2),
+ process_goal(Else0, Else, InitInstMap, FinalInstMap, VarTypes,
+ ModuleInfo, Options, !.WhereNeededMap, WhereNeededMapElse,
+ !RefinedGoals, !Changed),
+ process_goal(Then0, Then, InstMapCond, FinalInstMap,
+ VarTypes, ModuleInfo, Options, !.WhereNeededMap,
+ WhereNeededMapThen, !RefinedGoals, !Changed),
map__init(BranchNeededMap0),
map__to_assoc_list(WhereNeededMapElse, WhereNeededListElse),
- unneeded_code__add_alt_start(WhereNeededListElse, BranchPoint, 2,
+ add_alt_start(WhereNeededListElse, BranchPoint, 2,
CurrentPath, BranchNeededMap0, BranchNeededMap1),
map__to_assoc_list(WhereNeededMapThen, WhereNeededListThen),
- unneeded_code__add_alt_start(WhereNeededListThen, BranchPoint, 1,
+ add_alt_start(WhereNeededListThen, BranchPoint, 1,
CurrentPath, BranchNeededMap1, BranchNeededMap),
- unneeded_code__merge_where_needed_maps(CurrentPath,
- WhereNeededMap0, BranchNeededMap, WhereNeededMapCond),
+ merge_where_needed_maps(CurrentPath,
+ !.WhereNeededMap, BranchNeededMap, WhereNeededMapCond),
- unneeded_code__process_goal(Cond0, Cond, InstMap0, InstMapCond,
+ process_goal(Cond0, Cond, InitInstMap, InstMapCond,
VarTypes, ModuleInfo, Options, WhereNeededMapCond,
- WhereNeededMap, RefinedGoals2, RefinedGoals, Changed2, Changed).
+ !:WhereNeededMap, !RefinedGoals, !Changed).
%---------------------------------------------------------------------------%
@@ -884,34 +841,33 @@
% in the resulting where_needed_map iff it is needed there in one of the input
% maps.
-:- pred unneeded_code__merge_where_needed_maps(goal_path::in,
+:- pred merge_where_needed_maps(goal_path::in,
where_needed_map::in, where_needed_map::in, where_needed_map::out)
is det.
-unneeded_code__merge_where_needed_maps(CurrentPath,
+merge_where_needed_maps(CurrentPath,
WhereNeededMap1, WhereNeededMap2, WhereNeededMap) :-
map__to_assoc_list(WhereNeededMap1, WhereNeededList1),
- unneeded_code__add_where_needed_list(WhereNeededList1, CurrentPath,
+ add_where_needed_list(WhereNeededList1, CurrentPath,
WhereNeededMap2, WhereNeededMap).
-:- pred unneeded_code__add_where_needed_list(
- assoc_list(prog_var, where_needed)::in, goal_path::in,
- where_needed_map::in, where_needed_map::out) is det.
+:- pred add_where_needed_list(assoc_list(prog_var, where_needed)::in,
+ goal_path::in, where_needed_map::in, where_needed_map::out) is det.
-unneeded_code__add_where_needed_list([], _, WhereNeededMap, WhereNeededMap).
-unneeded_code__add_where_needed_list([Var - BranchWhere | WhereNeededList],
- CurrentPath, WhereNeededMap0, WhereNeededMap) :-
- ( map__search(WhereNeededMap0, Var, OldWhere) ->
- unneeded_code__where_needed_upper_bound(CurrentPath,
+add_where_needed_list([], _, !WhereNeededMap).
+add_where_needed_list([Var - BranchWhere | WhereNeededList],
+ CurrentPath, !WhereNeededMap) :-
+ ( map__search(!.WhereNeededMap, Var, OldWhere) ->
+ where_needed_upper_bound(CurrentPath,
BranchWhere, OldWhere, CombinedWhere),
- map__det_update(WhereNeededMap0, Var, CombinedWhere,
- WhereNeededMap1)
+ map__det_update(!.WhereNeededMap, Var, CombinedWhere,
+ !:WhereNeededMap)
;
- map__det_insert(WhereNeededMap0, Var, BranchWhere,
- WhereNeededMap1)
+ map__det_insert(!.WhereNeededMap, Var, BranchWhere,
+ !:WhereNeededMap)
),
- unneeded_code__add_where_needed_list(WhereNeededList, CurrentPath,
- WhereNeededMap1, WhereNeededMap).
+ add_where_needed_list(WhereNeededList, CurrentPath,
+ !WhereNeededMap).
% Given a where_needed_map, add to it the where_needed information for the
% start of an alternative in a branched goal. This source is important,
@@ -919,14 +875,13 @@
% variable is needed everywhere, the scope of this "everywhere" is only
% that alternative.
-:- pred unneeded_code__add_alt_start(assoc_list(prog_var, where_needed)::in,
+:- pred add_alt_start(assoc_list(prog_var, where_needed)::in,
branch_point::in, int::in, goal_path::in,
where_needed_map::in, where_needed_map::out) is det.
-unneeded_code__add_alt_start([], _, _, _, WhereNeededMap, WhereNeededMap).
-unneeded_code__add_alt_start([Var - BranchWhere0 | WhereNeededList],
- BranchPoint, BranchNum, CurrentPath,
- WhereNeededMap0, WhereNeededMap) :-
+add_alt_start([], _, _, _, !WhereNeededMap).
+add_alt_start([Var - BranchWhere0 | WhereNeededList],
+ BranchPoint, BranchNum, CurrentPath, !WhereNeededMap) :-
(
BranchWhere0 = everywhere,
map__init(Empty),
@@ -937,173 +892,161 @@
BranchWhere0 = branches(_),
BranchWhere = BranchWhere0
),
- ( map__search(WhereNeededMap0, Var, OldWhere) ->
- unneeded_code__where_needed_upper_bound(CurrentPath,
+ ( map__search(!.WhereNeededMap, Var, OldWhere) ->
+ where_needed_upper_bound(CurrentPath,
BranchWhere, OldWhere, CombinedWhere),
- map__det_update(WhereNeededMap0, Var, CombinedWhere,
- WhereNeededMap1)
+ map__det_update(!.WhereNeededMap, Var, CombinedWhere,
+ !:WhereNeededMap)
;
- map__det_insert(WhereNeededMap0, Var, BranchWhere,
- WhereNeededMap1)
+ map__det_insert(!.WhereNeededMap, Var, BranchWhere,
+ !:WhereNeededMap)
),
- unneeded_code__add_alt_start(WhereNeededList, BranchPoint, BranchNum,
- CurrentPath, WhereNeededMap1, WhereNeededMap).
+ add_alt_start(WhereNeededList, BranchPoint, BranchNum,
+ CurrentPath, !WhereNeededMap).
%---------------------------------------------------------------------------%
-:- pred unneeded_code__refine_goal(hlds_goal::in, refined_goal_map::in,
- hlds_goal::out, refined_goal_map::out) is det.
+:- pred refine_goal(hlds_goal::in, hlds_goal::out,
+ refined_goal_map::in, refined_goal_map::out) is det.
-unneeded_code__refine_goal(Goal0, RefinedGoals0, Goal, RefinedGoals) :-
+refine_goal(Goal0, Goal, !RefinedGoals) :-
Goal0 = GoalExpr0 - GoalInfo0,
(
GoalExpr0 = unify(_, _, _, _, _),
- Goal = Goal0,
- RefinedGoals = RefinedGoals0
+ Goal = Goal0
;
GoalExpr0 = call(_, _, _, _, _, _),
- Goal = Goal0,
- RefinedGoals = RefinedGoals0
+ Goal = Goal0
;
GoalExpr0 = generic_call(_, _, _, _),
- Goal = Goal0,
- RefinedGoals = RefinedGoals0
+ Goal = Goal0
;
GoalExpr0 = foreign_proc(_, _, _, _, _, _, _),
- Goal = Goal0,
- RefinedGoals = RefinedGoals0
+ Goal = Goal0
;
GoalExpr0 = par_conj(_),
- Goal = Goal0,
- RefinedGoals = RefinedGoals0
+ Goal = Goal0
;
GoalExpr0 = conj(Conjuncts0),
- unneeded_code__refine_conj(Conjuncts0, RefinedGoals0,
- Conjuncts, RefinedGoals),
+ refine_conj(Conjuncts0, Conjuncts,
+ !RefinedGoals),
GoalExpr = conj(Conjuncts),
Goal = GoalExpr - GoalInfo0
;
GoalExpr0 = switch(SwitchVar, CanFail, Cases0),
goal_info_get_goal_path(GoalInfo0, GoalPath),
- unneeded_code__refine_cases(Cases0, RefinedGoals0,
- GoalPath, 1, Cases, RefinedGoals),
+ refine_cases(Cases0, Cases,
+ !RefinedGoals, GoalPath, 1),
GoalExpr = switch(SwitchVar, CanFail, Cases),
Goal = GoalExpr - GoalInfo0
;
GoalExpr0 = disj(Disjuncts0),
goal_info_get_goal_path(GoalInfo0, GoalPath),
- unneeded_code__refine_disj(Disjuncts0, RefinedGoals0,
- GoalPath, 1, Disjuncts, RefinedGoals),
+ refine_disj(Disjuncts0, Disjuncts,
+ !RefinedGoals, GoalPath, 1),
GoalExpr = disj(Disjuncts),
Goal = GoalExpr - GoalInfo0
;
GoalExpr0 = if_then_else(Quant, Cond0, Then0, Else0),
goal_info_get_goal_path(GoalInfo0, GoalPath),
- unneeded_code__refine_ite(Cond0, Then0, Else0, RefinedGoals0,
- GoalPath, Cond, Then, Else, RefinedGoals),
+ refine_ite(Cond0, Cond, Then0, Then,
+ Else0, Else, !RefinedGoals, GoalPath),
GoalExpr = if_then_else(Quant, Cond, Then, Else),
Goal = GoalExpr - GoalInfo0
;
GoalExpr0 = not(NegGoal0),
- unneeded_code__refine_goal(NegGoal0, RefinedGoals0,
- NegGoal, RefinedGoals),
+ refine_goal(NegGoal0, NegGoal, !RefinedGoals),
GoalExpr = not(NegGoal),
Goal = GoalExpr - GoalInfo0
;
GoalExpr0 = some(Vars, CanFail, SomeGoal0),
- unneeded_code__refine_goal(SomeGoal0, RefinedGoals0,
- SomeGoal, RefinedGoals),
+ refine_goal(SomeGoal0, SomeGoal, !RefinedGoals),
GoalExpr = some(Vars, CanFail, SomeGoal),
Goal = GoalExpr - GoalInfo0
;
GoalExpr0 = shorthand(_),
- error("shorthand in unneeded_code__refine_goal")
+ error("shorthand in refine_goal")
).
-:- pred unneeded_code__refine_conj(list(hlds_goal)::in, refined_goal_map::in,
- list(hlds_goal)::out, refined_goal_map::out) is det.
+:- pred refine_conj(list(hlds_goal)::in, list(hlds_goal)::out,
+ refined_goal_map::in, refined_goal_map::out) is det.
-unneeded_code__refine_conj([], RefinedGoals, [], RefinedGoals).
-unneeded_code__refine_conj([Goal0 | Goals0], RefinedGoals0, Goals,
- RefinedGoals) :-
- unneeded_code__refine_goal(Goal0, RefinedGoals0, HeadGoal,
- RefinedGoals1),
- unneeded_code__refine_conj(Goals0, RefinedGoals1, TailGoals,
- RefinedGoals),
+refine_conj([], [], !RefinedGoals).
+refine_conj([Goal0 | Goals0], Goals, !RefinedGoals) :-
+ refine_goal(Goal0, HeadGoal, !RefinedGoals),
+ refine_conj(Goals0, TailGoals, !RefinedGoals),
( HeadGoal = conj(HeadGoals) - _ ->
list__append(HeadGoals, TailGoals, Goals)
;
Goals = [HeadGoal | TailGoals]
).
-:- pred unneeded_code__refine_cases(list(case)::in, refined_goal_map::in,
- goal_path::in, int::in, list(case)::out, refined_goal_map::out) is det.
+:- pred refine_cases(list(case)::in, list(case)::out,
+ refined_goal_map::in, refined_goal_map::out,
+ goal_path::in, int::in) is det.
-unneeded_code__refine_cases([], RefinedGoals, _, _, [], RefinedGoals).
-unneeded_code__refine_cases([case(Var, Goal0) | Cases0], RefinedGoals0,
- GoalPath, BranchNum,
- [case(Var, Goal) | Cases], RefinedGoals) :-
- unneeded_code__refine_goal(Goal0, RefinedGoals0, Goal1, RefinedGoals1),
- ( map__search(RefinedGoals1, GoalPath - BranchNum, ToInsertGoals) ->
- unneeded_code__insert_refine_goals(ToInsertGoals, Goal1, Goal),
- map__delete(RefinedGoals1, GoalPath - BranchNum, RefinedGoals2)
+refine_cases([], [], !RefinedGoals, _, _).
+refine_cases([case(Var, Goal0) | Cases0],
+ [case(Var, Goal) | Cases], !RefinedGoals,
+ GoalPath, BranchNum) :-
+ refine_goal(Goal0, Goal1, !RefinedGoals),
+ ( map__search(!.RefinedGoals, GoalPath - BranchNum, ToInsertGoals) ->
+ insert_refine_goals(ToInsertGoals, Goal1, Goal),
+ map__delete(!.RefinedGoals, GoalPath - BranchNum,
+ !:RefinedGoals)
;
- Goal = Goal1,
- RefinedGoals2 = RefinedGoals1
+ Goal = Goal1
),
- unneeded_code__refine_cases(Cases0, RefinedGoals2,
- GoalPath, BranchNum + 1, Cases, RefinedGoals).
+ refine_cases(Cases0, Cases, !RefinedGoals,
+ GoalPath, BranchNum + 1).
-:- pred unneeded_code__refine_disj(list(hlds_goal)::in, refined_goal_map::in,
- goal_path::in, int::in, list(hlds_goal)::out, refined_goal_map::out)
- is det.
+:- pred refine_disj(list(hlds_goal)::in, list(hlds_goal)::out,
+ refined_goal_map::in, refined_goal_map::out,
+ goal_path::in, int::in) is det.
-unneeded_code__refine_disj([], RefinedGoals, _, _, [], RefinedGoals).
-unneeded_code__refine_disj([Goal0 | Goals0], RefinedGoals0,
- GoalPath, BranchNum, [Goal | Goals], RefinedGoals) :-
- unneeded_code__refine_goal(Goal0, RefinedGoals0, Goal1, RefinedGoals1),
- ( map__search(RefinedGoals1, GoalPath - BranchNum, ToInsertGoals) ->
- unneeded_code__insert_refine_goals(ToInsertGoals, Goal1, Goal),
- map__delete(RefinedGoals1, GoalPath - BranchNum, RefinedGoals2)
+refine_disj([], [], !RefinedGoals, _, _).
+refine_disj([Goal0 | Goals0], [Goal | Goals], !RefinedGoals,
+ GoalPath, BranchNum) :-
+ refine_goal(Goal0, Goal1, !RefinedGoals),
+ ( map__search(!.RefinedGoals, GoalPath - BranchNum, ToInsertGoals) ->
+ insert_refine_goals(ToInsertGoals, Goal1, Goal),
+ map__delete(!.RefinedGoals, GoalPath - BranchNum,
+ !:RefinedGoals)
;
- Goal = Goal1,
- RefinedGoals2 = RefinedGoals1
+ Goal = Goal1
),
- unneeded_code__refine_disj(Goals0, RefinedGoals2,
- GoalPath, BranchNum + 1, Goals, RefinedGoals).
+ refine_disj(Goals0, Goals, !RefinedGoals,
+ GoalPath, BranchNum + 1).
-:- pred unneeded_code__refine_ite(hlds_goal::in, hlds_goal::in, hlds_goal::in,
- refined_goal_map::in, goal_path::in,
- hlds_goal::out, hlds_goal::out, hlds_goal::out, refined_goal_map::out)
- is det.
-
-unneeded_code__refine_ite(Cond0, Then0, Else0, RefinedGoals0, GoalPath,
- Cond, Then, Else, RefinedGoals) :-
- unneeded_code__refine_goal(Cond0, RefinedGoals0, Cond, RefinedGoals1),
- unneeded_code__refine_goal(Then0, RefinedGoals1, Then1, RefinedGoals2),
- unneeded_code__refine_goal(Else0, RefinedGoals2, Else1, RefinedGoals3),
+:- pred refine_ite(hlds_goal::in, hlds_goal::out,
+ hlds_goal::in, hlds_goal::out, hlds_goal::in, hlds_goal::out,
+ refined_goal_map::in, refined_goal_map::out, goal_path::in) is det.
+
+refine_ite(Cond0, Cond, Then0, Then, Else0, Else,
+ !RefinedGoals, GoalPath) :-
+ refine_goal(Cond0, Cond, !RefinedGoals),
+ refine_goal(Then0, Then1, !RefinedGoals),
+ refine_goal(Else0, Else1, !RefinedGoals),
- ( map__search(RefinedGoals3, GoalPath - 1, ToInsertGoalsThen) ->
- unneeded_code__insert_refine_goals(ToInsertGoalsThen, Then1,
+ ( map__search(!.RefinedGoals, GoalPath - 1, ToInsertGoalsThen) ->
+ insert_refine_goals(ToInsertGoalsThen, Then1,
Then),
- map__delete(RefinedGoals3, GoalPath - 1, RefinedGoals4)
+ map__delete(!.RefinedGoals, GoalPath - 1, !:RefinedGoals)
;
- Then = Then1,
- RefinedGoals4 = RefinedGoals3
+ Then = Then1
),
- ( map__search(RefinedGoals4, GoalPath - 2, ToInsertGoalsElse) ->
- unneeded_code__insert_refine_goals(ToInsertGoalsElse, Else1,
+ ( map__search(!.RefinedGoals, GoalPath - 2, ToInsertGoalsElse) ->
+ insert_refine_goals(ToInsertGoalsElse, Else1,
Else),
- map__delete(RefinedGoals4, GoalPath - 2, RefinedGoals)
+ map__delete(!.RefinedGoals, GoalPath - 2, !:RefinedGoals)
;
- Else = Else1,
- RefinedGoals = RefinedGoals4
+ Else = Else1
).
-:- pred unneeded_code__insert_refine_goals(list(hlds_goal)::in, hlds_goal::in,
+:- pred insert_refine_goals(list(hlds_goal)::in, hlds_goal::in,
hlds_goal::out) is det.
-unneeded_code__insert_refine_goals(ToInsertGoals, Goal0, Goal) :-
+insert_refine_goals(ToInsertGoals, Goal0, Goal) :-
list__append(ToInsertGoals, [Goal0], Conj),
% XXX GoalInfo0
Goal0 = _ - GoalInfo0,
@@ -1116,10 +1059,10 @@
% is to discover when the union of two sets of requirements (e.g. branch sets
% {b1,b2} and {b3} covers all computation paths.
-:- pred unneeded_code__where_needed_upper_bound(goal_path::in,
+:- pred where_needed_upper_bound(goal_path::in,
where_needed::in, where_needed::in, where_needed::out) is det.
-unneeded_code__where_needed_upper_bound(CurrentPath,
+where_needed_upper_bound(CurrentPath,
WhereNeededA, WhereNeededB, WhereNeeded) :-
(
WhereNeededA = everywhere,
@@ -1131,37 +1074,37 @@
WhereNeeded = everywhere
;
WhereNeededB = branches(BranchesB),
- unneeded_code__where_needed_branches_upper_bound(
+ where_needed_branches_upper_bound(
CurrentPath, BranchesA, BranchesB, WhereNeeded)
)
).
-:- pred unneeded_code__where_needed_branches_upper_bound(goal_path::in,
+:- pred where_needed_branches_upper_bound(goal_path::in,
where_needed_branches::in, where_needed_branches::in,
where_needed::out) is det.
-unneeded_code__where_needed_branches_upper_bound(CurrentPath,
+where_needed_branches_upper_bound(CurrentPath,
BranchesA, BranchesB, WhereNeeded) :-
% should select smaller map to convert to list
map__to_assoc_list(BranchesA, BranchesList),
- unneeded_code__where_needed_branches_upper_bound_2(CurrentPath,
+ where_needed_branches_upper_bound_2(CurrentPath,
BranchesList, BranchesB, WhereNeeded).
-:- pred unneeded_code__where_needed_branches_upper_bound_2(goal_path::in,
+:- pred where_needed_branches_upper_bound_2(goal_path::in,
assoc_list(branch_point, set(int))::in, where_needed_branches::in,
where_needed::out) is det.
-unneeded_code__where_needed_branches_upper_bound_2(_, [],
+where_needed_branches_upper_bound_2(_, [],
Branches, branches(Branches)).
-unneeded_code__where_needed_branches_upper_bound_2(CurrentPath, [First | Rest],
+where_needed_branches_upper_bound_2(CurrentPath, [First | Rest],
Branches0, WhereNeeded) :-
First = BranchPoint - NewAlts,
( map__search(Branches0, BranchPoint, OldAlts) ->
set__union(OldAlts, NewAlts, Alts),
BranchPoint = branch_point(GoalPath, BranchAlts),
- ( unneeded_code__branch_point_is_complete(BranchAlts, Alts) ->
+ ( branch_point_is_complete(BranchAlts, Alts) ->
(
- unneeded_code__get_parent_branch_point(GoalPath,
+ get_parent_branch_point(GoalPath,
ParentGoalPath, ParentGoalPathStep,
ParentBranchAlt, ParentBranchNum),
\+ list__remove_suffix(CurrentPath,
@@ -1173,7 +1116,7 @@
ParentGoalPath, ParentBranchAlt),
set__singleton_set(ParentAlts,
ParentBranchNum),
- unneeded_code__where_needed_branches_upper_bound_2(
+ where_needed_branches_upper_bound_2(
CurrentPath,
[ParentBranchPoint - ParentAlts
| Rest],
@@ -1184,19 +1127,19 @@
;
map__det_update(Branches0, BranchPoint, Alts,
Branches1),
- unneeded_code__where_needed_branches_upper_bound_2(
- CurrentPath, Rest, Branches1, WhereNeeded)
+ where_needed_branches_upper_bound_2(CurrentPath,
+ Rest, Branches1, WhereNeeded)
)
;
map__det_insert(Branches0, BranchPoint, NewAlts, Branches1),
- unneeded_code__where_needed_branches_upper_bound_2(CurrentPath,
+ where_needed_branches_upper_bound_2(CurrentPath,
Rest, Branches1, WhereNeeded)
).
-:- pred unneeded_code__get_parent_branch_point(goal_path::in, goal_path::out,
+:- pred get_parent_branch_point(goal_path::in, goal_path::out,
goal_path_step::out, branch_alts::out, int::out) is semidet.
-unneeded_code__get_parent_branch_point([First | Rest], Parent, ParentStep,
+get_parent_branch_point([First | Rest], Parent, ParentStep,
BranchAlt, BranchNum) :-
( First = switch(Arm, NumAlts) ->
Parent = Rest,
@@ -1214,17 +1157,17 @@
BranchAlt = ite,
BranchNum = 2
;
- unneeded_code__get_parent_branch_point(Rest, Parent, ParentStep,
- BranchAlt, BranchNum)
+ get_parent_branch_point(Rest, Parent,
+ ParentStep, BranchAlt, BranchNum)
).
-:- pred unneeded_code__branch_point_is_complete(branch_alts::in, set(int)::in)
+:- pred branch_point_is_complete(branch_alts::in, set(int)::in)
is semidet.
-unneeded_code__branch_point_is_complete(ite, Alts) :-
+branch_point_is_complete(ite, Alts) :-
set__count(Alts, NumAlts),
NumAlts = 2.
-unneeded_code__branch_point_is_complete(switch(NumFunctors), Alts) :-
+branch_point_is_complete(switch(NumFunctors), Alts) :-
set__count(Alts, NumAlts),
NumAlts = NumFunctors.
Index: compiler/unused_args.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unused_args.m,v
retrieving revision 1.90
diff -u -b -r1.90 unused_args.m
--- compiler/unused_args.m 21 Dec 2003 05:04:38 -0000 1.90
+++ compiler/unused_args.m 3 Apr 2004 18:02:40 -0000
@@ -49,7 +49,7 @@
:- import_module io.
:- pred unused_args__process_module(module_info::in, module_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
% Instances used by mmc_analysis.m.
:- type unused_args_answer.
@@ -92,8 +92,8 @@
% Information about the dependencies of a variable
% that is not known to be used.
-:- type usage_info --->
- unused(set(prog_var), set(arg)).
+:- type usage_info
+ ---> unused(set(prog_var), set(arg)).
% A collection of variable usages for each procedure.
:- type var_usage == map(pred_proc_id, var_dep).
@@ -106,8 +106,8 @@
% in a procedure that are not yet known to be used.
:- type var_dep == map(prog_var, usage_info).
-:- type warning_info --->
- warning_info(prog_context, string, int, list(int)).
+:- type warning_info
+ ---> warning_info(prog_context, string, int, list(int)).
% context, pred name, arity, list of args to warn
%-----------------------------------------------------------------------------%
@@ -116,8 +116,8 @@
% The list of unused arguments is in sorted order.
:- type unused_args_answer ---> unused_args(list(int)).
-:- instance analysis(unused_args_func_info, any_call,
- unused_args_answer) where [
+:- instance analysis(unused_args_func_info, any_call, unused_args_answer)
+ where [
analysis_name(_, _, _) = "unused_args",
analysis_version_number(_, _, _) = 1,
preferred_fixpoint_type(_, _, _) = least_fixpoint
@@ -144,92 +144,101 @@
].
:- instance to_string(unused_args_answer) where [
- to_string(unused_args(Args)) =
- string__join_list(" ", list__map(int_to_string, Args)),
- (from_string(String) = unused_args(Args) :-
- {Digits, Args0} = string__foldl(
- (func(Char, {Digits0, Ints0}) =
+ func(to_string/1) is unused_args_answer_to_string,
+ func(from_string/1) is unused_args_answer_from_string
+].
+
+:- func unused_args_answer_to_string(unused_args_answer) = string.
+
+unused_args_answer_to_string(unused_args(Args)) =
+ string__join_list(" ", list__map(int_to_string, Args)).
+
+:- func unused_args_answer_from_string(string) = unused_args_answer is semidet.
+
+unused_args_answer_from_string(String) = unused_args(Args) :-
+ {Digits, Args0} = string__foldl((func(Char, {Digits0, Ints0}) =
( char__is_digit(Char) ->
{[Char | Digits0], Ints0}
;
{[], [string__det_to_int(
string__from_rev_char_list(Digits0)) | Ints0]}
- )
- ), String, {[], []}),
+ )), String, {[], []}),
Args = list__reverse([string__det_to_int(
- string__from_rev_char_list(Digits)) | Args0])
- )
-].
+ string__from_rev_char_list(Digits)) | Args0]),
+ semidet_succeed.
%-----------------------------------------------------------------------------%
-unused_args__process_module(!ModuleInfo) -->
- globals__io_lookup_bool_option(very_verbose, VeryVerbose),
- init_var_usage(VarUsage0, PredProcs, ProcCallInfo0, !ModuleInfo),
- %maybe_write_string(VeryVerbose, "% Finished initialisation.\n"),
-
- { unused_args_pass(PredProcs, VarUsage0, VarUsage) },
- %maybe_write_string(VeryVerbose, "% Finished analysis.\n"),
-
- { map__init(UnusedArgInfo0) },
- { get_unused_arg_info(!.ModuleInfo, PredProcs, VarUsage,
- UnusedArgInfo0, UnusedArgInfo) },
-
- { map__keys(UnusedArgInfo, PredProcsToFix) },
-
- globals__io_lookup_bool_option(make_optimization_interface, MakeOpt),
- ( { MakeOpt = yes } ->
- { module_info_name(!.ModuleInfo, ModuleName) },
+unused_args__process_module(!ModuleInfo, !IO) :-
+ globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
+ init_var_usage(VarUsage0, PredProcs, ProcCallInfo0, !ModuleInfo, !IO),
+ % maybe_write_string(VeryVerbose, "% Finished initialisation.\n", !IO),
+
+ unused_args_pass(PredProcs, VarUsage0, VarUsage),
+ % maybe_write_string(VeryVerbose, "% Finished analysis.\n", !IO),
+
+ map__init(UnusedArgInfo0),
+ get_unused_arg_info(!.ModuleInfo, PredProcs, VarUsage,
+ UnusedArgInfo0, UnusedArgInfo),
+
+ map__keys(UnusedArgInfo, PredProcsToFix),
+
+ globals__io_lookup_bool_option(make_optimization_interface, MakeOpt,
+ !IO),
+ ( MakeOpt = yes ->
+ module_info_name(!.ModuleInfo, ModuleName),
module_name_to_file_name(ModuleName, ".opt.tmp", no,
- OptFileName),
- io__open_append(OptFileName, OptFileRes),
- ( { OptFileRes = ok(OptFile) },
- { MaybeOptFile = yes(OptFile) }
- ; { OptFileRes = error(IOError) },
- { io__error_message(IOError, IOErrorMessage) },
+ OptFileName, !IO),
+ io__open_append(OptFileName, OptFileRes, !IO),
+ ( OptFileRes = ok(OptFile),
+ MaybeOptFile = yes(OptFile)
+ ; OptFileRes = error(IOError),
+ io__error_message(IOError, IOErrorMessage),
io__write_strings(["Cannot open `", OptFileName,
- "' for output: ", IOErrorMessage]),
- io__set_exit_status(1),
- { MaybeOptFile = no }
+ "' for output: ", IOErrorMessage], !IO),
+ io__set_exit_status(1, !IO),
+ MaybeOptFile = no
)
;
- { MaybeOptFile = no }
+ MaybeOptFile = no
),
- globals__io_lookup_bool_option(warn_unused_args, DoWarn),
- ( { DoWarn = yes ; MakeOpt = yes } ->
- { set__init(WarnedPredIds0) },
+ globals__io_lookup_bool_option(warn_unused_args, DoWarn, !IO),
+ ( ( DoWarn = yes ; MakeOpt = yes ) ->
+ set__init(WarnedPredIds0),
output_warnings_and_pragmas(!.ModuleInfo, UnusedArgInfo,
- MaybeOptFile, DoWarn, PredProcsToFix, WarnedPredIds0)
+ MaybeOptFile, DoWarn, PredProcsToFix, WarnedPredIds0,
+ !IO)
;
- []
+ true
),
- ( { MaybeOptFile = yes(OptFile2) } ->
- io__close_output(OptFile2)
+ ( MaybeOptFile = yes(OptFile2) ->
+ io__close_output(OptFile2, !IO)
;
- []
+ true
),
- globals__io_lookup_bool_option(optimize_unused_args, DoFixup),
+ globals__io_lookup_bool_option(optimize_unused_args, DoFixup, !IO),
(
- { DoFixup = yes }
- ->
+ DoFixup = yes,
list__foldl3(create_new_pred(UnusedArgInfo), PredProcsToFix,
- ProcCallInfo0, ProcCallInfo, !ModuleInfo),
- % maybe_write_string(VeryVerbose, "% Finished new preds.\n"),
- fixup_unused_args(VarUsage, PredProcs,
- ProcCallInfo, !ModuleInfo, VeryVerbose),
- % maybe_write_string(VeryVerbose, "% Fixed up goals.\n"),
- { map__is_empty(ProcCallInfo) ->
+ ProcCallInfo0, ProcCallInfo, !ModuleInfo, !IO),
+ % maybe_write_string(VeryVerbose, "% Finished new preds.\n",
+ % !IO),
+ fixup_unused_args(VarUsage, PredProcs, ProcCallInfo,
+ !ModuleInfo, VeryVerbose, !IO),
+ % maybe_write_string(VeryVerbose, "% Fixed up goals.\n", !IO),
+ ( map__is_empty(ProcCallInfo) ->
true
;
% The dependencies have changed, so the dependency
% graph needs rebuilding.
module_info_clobber_dependency_info(!ModuleInfo)
- }
+ )
;
- []
+ DoFixup = no
).
%-------------------------------------------------------------------------------
+
% Initialisation section
% init_var_usage/4 - set initial status of all args of local
@@ -240,7 +249,7 @@
% unused argument information from .opt files.
:- pred init_var_usage(var_usage::out, pred_proc_list::out,
proc_call_info::out, module_info::in, module_info::out,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
init_var_usage(VarUsage, PredProcList, ProcCallInfo, !ModuleInfo, !IO) :-
map__init(ProcCallInfo0),
@@ -255,7 +264,7 @@
:- pred setup_local_var_usage(list(pred_id)::in, unused_arg_info::in,
var_usage::in, var_usage::out, pred_proc_list::in, pred_proc_list::out,
proc_call_info::in, proc_call_info::out, module_info::in,
- module_info::out, io__state::di, io__state::uo) is det.
+ module_info::out, io::di, io::uo) is det.
setup_local_var_usage([], _, !VarUsage, !PredProcs,
!OptProcs, !ModuleInfo, !IO).
@@ -289,7 +298,7 @@
:- pred setup_pred_args(pred_id::in, list(proc_id)::in, unused_arg_info::in,
var_usage::in, var_usage::out, pred_proc_list::in, pred_proc_list::out,
proc_call_info::in, proc_call_info::out, module_info::in,
- module_info::out, io__state::di, io__state::uo) is det.
+ module_info::out, io::di, io::uo) is det.
setup_pred_args(_, [], _, !VarUsage, !PredProcs, !OptProcs, !ModuleInfo, !IO).
setup_pred_args(PredId, [ProcId | Rest], UnusedArgInfo, !VarUsage,
@@ -374,7 +383,6 @@
setup_pred_args(PredId, Rest, UnusedArgInfo,
!VarUsage, !PredProcs, !OptProcs, !ModuleInfo, !IO).
-
:- pred initialise_vardep(var_dep::in, list(prog_var)::in, var_dep::out) is det.
initialise_vardep(VarDep, [], VarDep).
@@ -413,7 +421,6 @@
setup_typeinfo_deps(Vars, VarTypeMap, PredProcId, TVarMap,
VarDep1, VarDep).
-
% Get output arguments for a procedure given the headvars and the
% argument modes, and set them as used.
:- pred setup_output_args(module_info::in, proc_info::in,
@@ -466,13 +473,11 @@
set_var_used(Var, UseInfo0, UseInfo) :-
map__delete(UseInfo0, Var, UseInfo).
-
:- pred lookup_local_var(var_dep::in, prog_var::in, usage_info::out) is semidet.
lookup_local_var(VarDep, Var, UsageInfo) :-
map__search(VarDep, Var, UsageInfo).
-
%-------------------------------------------------------------------------------
% Traversal of goal structure, building up dependencies for all
% variables.
@@ -571,7 +576,7 @@
add_aliases(UseInf0, Var1, OutputVars, UseInf1),
% Treat a deconstruction that further instantiates its
% left arg as a partial construction.
- add_construction_aliases(UseInf1, Var1, InputVars, UseInf2),
+ add_construction_aliases(Var1, InputVars, UseInf1, UseInf2),
(
CanFail = can_fail
->
@@ -586,7 +591,7 @@
( local_var_is_used(UseInf0, Var1) ->
set_list_vars_used(UseInf0, Args, UseInf)
;
- add_construction_aliases(UseInf0, Var1, Args, UseInf)
+ add_construction_aliases(Var1, Args, UseInf0, UseInf)
).
% These should be transformed into calls by polymorphism.m.
@@ -626,7 +631,6 @@
error("add_pred_call_arg_dep: invalid call")
).
-
:- pred add_arg_dep(var_dep::in, prog_var::in, pred_proc_id::in,
prog_var::in, var_dep::out) is det.
@@ -689,22 +693,19 @@
).
% add Alias as an alias for all of Vars
-:- pred add_construction_aliases(var_dep::in, prog_var::in, list(prog_var)::in,
- var_dep::out) is det.
+:- pred add_construction_aliases(prog_var::in, list(prog_var)::in,
+ var_dep::in, var_dep::out) is det.
-add_construction_aliases(UseInf, _, [], UseInf).
-add_construction_aliases(UseInf0, Alias, [Var | Vars], UseInf) :-
- (
- lookup_local_var(UseInf0, Var, VarInf)
- ->
+add_construction_aliases(_, [], !UseInf).
+add_construction_aliases(Alias, [Var | Vars], !UseInf) :-
+ ( lookup_local_var(!.UseInf, Var, VarInf) ->
VarInf = unused(VarDep0, ArgDep),
set__insert(VarDep0, Alias, VarDep),
- map__set(UseInf0, Var, unused(VarDep, ArgDep), UseInf1)
+ map__set(!.UseInf, Var, unused(VarDep, ArgDep), !:UseInf)
;
- UseInf1 = UseInf0
+ true
),
- add_construction_aliases(UseInf1, Alias, Vars, UseInf).
-
+ add_construction_aliases(Alias, Vars, !UseInf).
:- pred list_case_to_list_goal(list(case)::in, list(hlds_goal)::out) is det.
@@ -712,15 +713,13 @@
list_case_to_list_goal([case(_, Goal) | Cases], [Goal | Goals]) :-
list_case_to_list_goal(Cases, Goals).
-
:- pred traverse_list_of_goals(traverse_info::in, list(hlds_goal)::in,
var_dep::in, var_dep::out) is det.
-traverse_list_of_goals(_, [], UseInf, UseInf).
-traverse_list_of_goals(Info, [Goal - _ | Goals], UseInf0, UseInf) :-
- traverse_goal(Info, Goal, UseInf0, UseInf1),
- traverse_list_of_goals(Info, Goals, UseInf1, UseInf).
-
+traverse_list_of_goals(_, [], !UseInf).
+traverse_list_of_goals(Info, [Goal - _ | Goals], !UseInf) :-
+ traverse_goal(Info, Goal, !UseInf),
+ traverse_list_of_goals(Info, Goals, !UseInf).
%-------------------------------------------------------------------------------
% Analysis section - do the fixpoint iteration.
@@ -729,61 +728,49 @@
:- pred unused_args_pass(pred_proc_list::in, var_usage::in,var_usage::out)
is det.
-unused_args_pass(LocalPredProcs, VarUsage0, VarUsage) :-
- unused_args_single_pass(LocalPredProcs, no, Changed,
- VarUsage0, VarUsage1),
+unused_args_pass(LocalPredProcs, !VarUsage) :-
+ unused_args_single_pass(LocalPredProcs, no, Changed, !VarUsage),
(
- Changed = yes
- ->
- unused_args_pass(LocalPredProcs, VarUsage1, VarUsage)
+ Changed = yes,
+ unused_args_pass(LocalPredProcs, !VarUsage)
;
- VarUsage = VarUsage1
+ Changed = no
).
-
% check over all the procedures in a module
:- pred unused_args_single_pass(pred_proc_list::in, bool::in, bool::out,
var_usage::in, var_usage::out) is det.
-unused_args_single_pass([], Changed, Changed, VarUsage, VarUsage).
-unused_args_single_pass([PredProc | Rest], Changed0, Changed,
- VarUsage0, VarUsage) :-
- unused_args_check_proc(PredProc, Changed0, Changed1,
- VarUsage0, VarUsage1),
- unused_args_single_pass(Rest, Changed1, Changed, VarUsage1, VarUsage).
-
+unused_args_single_pass([], !Changed, !VarUsage).
+unused_args_single_pass([PredProc | Rest], !Changed, !VarUsage) :-
+ unused_args_check_proc(PredProc, !Changed, !VarUsage),
+ unused_args_single_pass(Rest, !Changed, !VarUsage).
% check a single procedure
:- pred unused_args_check_proc(pred_proc_id::in, bool::in, bool::out,
var_usage::in, var_usage::out) is det.
-unused_args_check_proc(PredProcId, Changed0, Changed, VarUsage0, VarUsage) :-
- map__lookup(VarUsage0, PredProcId, LocalUsages0),
+unused_args_check_proc(PredProcId, !Changed, !VarUsage) :-
+ map__lookup(!.VarUsage, PredProcId, LocalUsages0),
map__keys(LocalUsages0, Vars),
- unused_args_check_all_vars(VarUsage0, no, LocalChanged, Vars,
+ unused_args_check_all_vars(!.VarUsage, Vars, no, LocalChanged,
LocalUsages0, LocalUsages),
(
- LocalChanged = yes
- ->
- map__det_update(VarUsage0, PredProcId, LocalUsages, VarUsage),
- Changed = yes
+ LocalChanged = yes,
+ map__det_update(!.VarUsage, PredProcId, LocalUsages,
+ !:VarUsage),
+ !:Changed = yes
;
- VarUsage = VarUsage0,
- Changed = Changed0
+ LocalChanged = no
).
-
-
% check each var of a procedure in turn
-:- pred unused_args_check_all_vars(var_usage::in, bool::in, bool::out,
- list(prog_var)::in, var_dep::in, var_dep::out) is det.
+:- pred unused_args_check_all_vars(var_usage::in, list(prog_var)::in,
+ bool::in, bool::out, var_dep::in, var_dep::out) is det.
-unused_args_check_all_vars(_, Changed, Changed, [], LocalVars, LocalVars).
-unused_args_check_all_vars(VarUsage, Changed0, Changed, [Var| Vars],
- LocalVars0, LocalVars) :-
- (
- lookup_local_var(LocalVars0, Var, Usage)
- ->
+unused_args_check_all_vars(_, [], !Changed, !LocalVars).
+unused_args_check_all_vars(VarUsage, [Var| Vars], !Changed, !LocalVars) :-
+ ( lookup_local_var(!.LocalVars, Var, Usage) ->
Usage = unused(VarDep0, ArgDep0),
(
(
@@ -796,40 +783,34 @@
% Check whether any variables that the
% current variable depends on are used.
set__member(Var2, VarDep0),
- local_var_is_used(LocalVars0, Var2)
+ local_var_is_used(!.LocalVars, Var2)
)
->
% set the current variable to used
- set_var_used(Var, LocalVars0, LocalVars1),
- Changed1 = yes
+ set_var_used(Var, !LocalVars),
+ !:Changed = yes
;
- Changed1 = Changed0,
- LocalVars1 = LocalVars0
+ true
)
;
- LocalVars1 = LocalVars0,
- Changed1 = Changed0
+ true
),
- unused_args_check_all_vars(VarUsage, Changed1, Changed,
- Vars, LocalVars1, LocalVars).
-
-
+ unused_args_check_all_vars(VarUsage, Vars, !Changed, !LocalVars).
:- pred get_unused_arg_info(module_info::in, pred_proc_list::in, var_usage::in,
unused_arg_info::in, unused_arg_info::out) is det.
-get_unused_arg_info(_, [], _, UnusedArgInfo, UnusedArgInfo).
+get_unused_arg_info(_, [], _, !UnusedArgInfo).
get_unused_arg_info(ModuleInfo, [PredProc | PredProcs], VarUsage,
- UnusedArgInfo0, UnusedArgInfo) :-
+ !UnusedArgInfo) :-
PredProc = proc(PredId, ProcId),
map__lookup(VarUsage, PredProc, LocalVarUsage),
module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _, ProcInfo),
proc_info_headvars(ProcInfo, HeadVars),
get_unused_arg_nos(LocalVarUsage, HeadVars, 1, UnusedArgs),
- map__det_insert(UnusedArgInfo0, PredProc, UnusedArgs, UnusedArgInfo1),
- get_unused_arg_info(ModuleInfo, PredProcs, VarUsage,
- UnusedArgInfo1, UnusedArgInfo).
-
+ map__det_insert(!.UnusedArgInfo, PredProc, UnusedArgs,
+ !:UnusedArgInfo),
+ get_unused_arg_info(ModuleInfo, PredProcs, VarUsage, !UnusedArgInfo).
%-------------------------------------------------------------------------------
% Fix up the module
@@ -840,9 +821,8 @@
% new pred_id, proc_id, name, and the indices in the argument
% vector of the arguments that have been removed.
-:- type new_proc_info --->
- call_info(pred_id, proc_id, sym_name, list(int)).
-
+:- type new_proc_info
+ ---> call_info(pred_id, proc_id, sym_name, list(int)).
% Create a new predicate for each procedure which has unused
% arguments. There are two reasons why we can't throw away
@@ -854,19 +834,17 @@
% chosen based on the length of the list of proc_ids.
:- pred create_new_pred(unused_arg_info::in, pred_proc_id::in,
proc_call_info::in, proc_call_info::out,
- module_info::in, module_info::out,
- io__state::di, io__state::uo) is det.
+ module_info::in, module_info::out, io::di, io::uo) is det.
-create_new_pred(UnusedArgInfo, proc(PredId, ProcId),
- !ProcCallInfo, !ModuleInfo, !IO) :-
+create_new_pred(UnusedArgInfo, proc(PredId, ProcId), !ProcCallInfo,
+ !ModuleInfo, !IO) :-
map__lookup(UnusedArgInfo, proc(PredId, ProcId), UnusedArgs),
- module_info_pred_proc_info(!.ModuleInfo,
- PredId, ProcId, OrigPredInfo, OrigProcInfo),
+ module_info_pred_proc_info(!.ModuleInfo, PredId, ProcId,
+ OrigPredInfo, OrigProcInfo),
(
UnusedArgs = []
- ->
- true
;
+ UnusedArgs = [_ | _],
PredModule = pred_info_module(OrigPredInfo),
PredName = pred_info_name(OrigPredInfo),
@@ -1075,8 +1053,8 @@
:- pred create_call_goal(list(int)::in, pred_id::in, proc_id::in,
module_name::in, string::in, proc_info::in, proc_info::out) is det.
-create_call_goal(UnusedArgs, NewPredId, NewProcId, PredModule,
- PredName, !OldProc) :-
+create_call_goal(UnusedArgs, NewPredId, NewProcId, PredModule, PredName,
+ !OldProc) :-
proc_info_headvars(!.OldProc, HeadVars),
proc_info_goal(!.OldProc, Goal0),
Goal0 = _GoalExpr - GoalInfo0,
@@ -1113,7 +1091,7 @@
module_info::in, module_info::out) is det.
make_imported_unused_args_pred_info(OptProc, UnusedArgs,
- ProcCallInfo0, ProcCallInfo, !ModuleInfo) :-
+ !ProcCallInfo, !ModuleInfo) :-
OptProc = proc(PredId, ProcId),
module_info_pred_proc_info(!.ModuleInfo,
PredId, ProcId, PredInfo0, ProcInfo0),
@@ -1139,90 +1117,77 @@
PredName = pred_info_name(NewPredInfo),
PredSymName = qualified(PredModule, PredName),
% Add the new proc to the proc_call_info map.
- map__det_insert(ProcCallInfo0, proc(PredId, ProcId),
+ map__det_insert(!.ProcCallInfo, proc(PredId, ProcId),
call_info(NewPredId, ProcId, PredSymName, UnusedArgs),
- ProcCallInfo).
+ !:ProcCallInfo).
:- pred remove_listof_elements(list(T)::in, int::in, list(int)::in,
list(T)::out) is det.
remove_listof_elements(List0, ArgNo, ElemsToRemove, List) :-
- (
- ElemsToRemove = []
- ->
+ ( ElemsToRemove = [] ->
List = List0
;
(
List0 = [Head | Tail],
NextArg = ArgNo + 1,
- (
- list__member(ArgNo, ElemsToRemove)
- ->
+ ( list__member(ArgNo, ElemsToRemove) ->
List = List1
;
List = [Head | List1]
),
- remove_listof_elements(Tail, NextArg,
- ElemsToRemove, List1)
+ remove_listof_elements(Tail, NextArg, ElemsToRemove,
+ List1)
;
List0 = [],
List = List0
)
).
-
:- pred get_unused_arg_nos(var_dep::in, list(prog_var)::in, int::in,
list(int)::out) is det.
get_unused_arg_nos(_, [], _, []).
get_unused_arg_nos(LocalVars, [HeadVar | HeadVars], ArgNo, UnusedArgs) :-
NextArg = ArgNo + 1,
- (
- map__contains(LocalVars, HeadVar)
- ->
+ ( map__contains(LocalVars, HeadVar) ->
UnusedArgs = [ArgNo | UnusedArgs1]
;
UnusedArgs = UnusedArgs1
),
get_unused_arg_nos(LocalVars, HeadVars, NextArg, UnusedArgs1).
-
- % note - we should probably remove unused variables from
- % the type map
+ % note - we should probably remove unused variables from the type map.
:- pred fixup_unused_args(var_usage::in, pred_proc_list::in, proc_call_info::in,
- module_info::in, module_info::out, bool::in,
- io__state::di, io__state::uo) is det.
+ module_info::in, module_info::out, bool::in, io::di, io::uo) is det.
-fixup_unused_args(_, [], _, Mod, Mod, _) --> [].
+fixup_unused_args(_, [], _, !ModuleInfo, _, !IO).
fixup_unused_args(VarUsage, [PredProc | PredProcs], ProcCallInfo,
- ModuleInfo0, ModuleInfo, VeryVerbose) -->
- (
- { VeryVerbose = yes }
- ->
- { PredProc = proc(PredId, ProcId) },
- io__write_string("% Fixing up `"),
- { predicate_name(ModuleInfo0, PredId, Name) },
- { predicate_arity(ModuleInfo0, PredId, Arity) },
- { proc_id_to_int(ProcId, ProcInt) },
- io__write_string(Name),
- io__write_string("/"),
- io__write_int(Arity),
- io__write_string("' in mode "),
- io__write_int(ProcInt),
- io__write_char('\n')
- ;
- []
- ),
- { do_fixup_unused_args(VarUsage, PredProc, ProcCallInfo, ModuleInfo0,
- ModuleInfo1) },
- fixup_unused_args(VarUsage, PredProcs, ProcCallInfo, ModuleInfo1,
- ModuleInfo, VeryVerbose).
+ !ModuleInfo, VeryVerbose, !IO) :-
+ ( VeryVerbose = yes ->
+ PredProc = proc(PredId, ProcId),
+ io__write_string("% Fixing up `", !IO),
+ predicate_name(!.ModuleInfo, PredId, Name),
+ predicate_arity(!.ModuleInfo, PredId, Arity),
+ proc_id_to_int(ProcId, ProcInt),
+ io__write_string(Name, !IO),
+ io__write_string("/", !IO),
+ io__write_int(Arity, !IO),
+ io__write_string("' in mode ", !IO),
+ io__write_int(ProcInt, !IO),
+ io__write_char('\n', !IO)
+ ;
+ true
+ ),
+ do_fixup_unused_args(VarUsage, PredProc, ProcCallInfo, !ModuleInfo),
+ fixup_unused_args(VarUsage, PredProcs, ProcCallInfo, !ModuleInfo,
+ VeryVerbose, !IO).
:- pred do_fixup_unused_args(var_usage::in, pred_proc_id::in,
proc_call_info::in, module_info::in, module_info::out) is det.
do_fixup_unused_args(VarUsage, proc(OldPredId, OldProcId), ProcCallInfo,
- Mod0, Mod) :-
+ ModuleInfo0, ModuleInfo) :-
(
% work out which proc we should be fixing up
map__search(ProcCallInfo, proc(OldPredId, OldProcId),
@@ -1238,9 +1203,10 @@
),
map__lookup(VarUsage, proc(OldPredId, OldProcId), UsageInfos),
map__keys(UsageInfos, UnusedVars),
- module_info_pred_proc_info(Mod0, PredId, ProcId, PredInfo0, ProcInfo0),
+ module_info_pred_proc_info(ModuleInfo0, PredId, ProcId, PredInfo0,
+ ProcInfo0),
proc_info_vartypes(ProcInfo0, VarTypes0),
- module_info_preds(Mod0, Preds0),
+ module_info_preds(ModuleInfo0, Preds0),
pred_info_procedures(PredInfo0, Procs0),
proc_info_headvars(ProcInfo0, HeadVars0),
@@ -1253,7 +1219,8 @@
proc_info_set_argmodes(ArgModes, FixedProc1, FixedProc2),
% remove unused vars from goal
- fixup_goal(Mod0, UnusedVars, ProcCallInfo, Changed, Goal0, Goal1),
+ fixup_goal(ModuleInfo0, UnusedVars, ProcCallInfo, Changed,
+ Goal0, Goal1),
(
Changed = yes,
% if anything has changed, rerun quantification
@@ -1270,69 +1237,69 @@
map__set(Procs0, ProcId, FixedProc5, Procs),
pred_info_set_procedures(Procs, PredInfo0, PredInfo),
map__set(Preds0, PredId, PredInfo, Preds),
- module_info_set_preds(Preds, Mod0, Mod).
+ module_info_set_preds(Preds, ModuleInfo0, ModuleInfo).
-% this is the important bit of the transformation
+ % this is the important bit of the transformation
:- pred fixup_goal(module_info::in, list(prog_var)::in, proc_call_info::in,
bool::out, hlds_goal::in, hlds_goal::out) is det.
fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo, Changed, Goal0, Goal) :-
- fixup_goal_expr(ModuleInfo, UnusedVars, ProcCallInfo,
- Changed, Goal0, Goal1),
+ fixup_goal_expr(ModuleInfo, UnusedVars, ProcCallInfo, Changed,
+ Goal0, Goal1),
Goal1 = GoalExpr - GoalInfo0,
- (
- Changed = yes
- ->
+ ( Changed = yes ->
fixup_goal_info(UnusedVars, GoalInfo0, GoalInfo)
;
GoalInfo = GoalInfo0
),
Goal = GoalExpr - GoalInfo.
-
-:- pred fixup_goal_expr(module_info::in, list(prog_var)::in, proc_call_info::in,
- bool::out, hlds_goal::in, hlds_goal::out) is det.
+:- pred fixup_goal_expr(module_info::in, list(prog_var)::in,
+ proc_call_info::in, bool::out, hlds_goal::in, hlds_goal::out) is det.
fixup_goal_expr(ModuleInfo, UnusedVars, ProcCallInfo, Changed,
conj(Goals0) - GoalInfo, conj(Goals) - GoalInfo) :-
- fixup_conjuncts(ModuleInfo, UnusedVars, ProcCallInfo, no,
- Changed, Goals0, Goals).
+ fixup_conjuncts(ModuleInfo, UnusedVars, ProcCallInfo, no, Changed,
+ Goals0, Goals).
fixup_goal_expr(ModuleInfo, UnusedVars, ProcCallInfo, Changed,
par_conj(Goals0) - GoalInfo,
par_conj(Goals) - GoalInfo) :-
- fixup_conjuncts(ModuleInfo, UnusedVars, ProcCallInfo, no,
- Changed, Goals0, Goals).
+ fixup_conjuncts(ModuleInfo, UnusedVars, ProcCallInfo, no, Changed,
+ Goals0, Goals).
fixup_goal_expr(ModuleInfo, UnusedVars, ProcCallInfo, Changed,
disj(Goals0) - GoalInfo, disj(Goals) - GoalInfo) :-
- fixup_disjuncts(ModuleInfo, UnusedVars, ProcCallInfo,
- no, Changed, Goals0, Goals).
+ fixup_disjuncts(ModuleInfo, UnusedVars, ProcCallInfo, no, Changed,
+ Goals0, Goals).
fixup_goal_expr(ModuleInfo, UnusedVars, ProcCallInfo, Changed,
not(NegGoal0) - GoalInfo, not(NegGoal) - GoalInfo) :-
- fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo,
- Changed, NegGoal0, NegGoal).
+ fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo, Changed,
+ NegGoal0, NegGoal).
fixup_goal_expr(ModuleInfo, UnusedVars, ProcCallInfo, Changed,
switch(Var, CanFail, Cases0) - GoalInfo,
switch(Var, CanFail, Cases) - GoalInfo) :-
- fixup_cases(ModuleInfo, UnusedVars, ProcCallInfo,
- no, Changed, Cases0, Cases).
+ fixup_cases(ModuleInfo, UnusedVars, ProcCallInfo, no, Changed,
+ Cases0, Cases).
fixup_goal_expr(ModuleInfo, UnusedVars, ProcCallInfo, Changed,
if_then_else(Vars, Cond0, Then0, Else0) - GoalInfo,
if_then_else(Vars, Cond, Then, Else) - GoalInfo) :-
- fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo, Changed1, Cond0, Cond),
- fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo, Changed2, Then0, Then),
- fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo, Changed3, Else0, Else),
+ fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo, Changed1,
+ Cond0, Cond),
+ fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo, Changed2,
+ Then0, Then),
+ fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo, Changed3,
+ Else0, Else),
bool__or_list([Changed1, Changed2, Changed3], Changed).
fixup_goal_expr(ModuleInfo, UnusedVars, ProcCallInfo, Changed,
some(Vars, CanRemove, SubGoal0) - GoalInfo,
some(Vars, CanRemove, SubGoal) - GoalInfo) :-
- fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo,
- Changed, SubGoal0, SubGoal).
+ fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo, Changed,
+ SubGoal0, SubGoal).
fixup_goal_expr(_ModuleInfo, _UnusedVars, ProcCallInfo, Changed,
call(PredId0, ProcId0, ArgVars0, B, C, Name0) - GoalInfo,
@@ -1354,12 +1321,10 @@
Name = Name0
).
-fixup_goal_expr(ModuleInfo, UnusedVars, _ProcCallInfo,
- Changed, GoalExpr0 - GoalInfo, GoalExpr - GoalInfo) :-
+fixup_goal_expr(ModuleInfo, UnusedVars, _ProcCallInfo, Changed,
+ GoalExpr0 - GoalInfo, GoalExpr - GoalInfo) :-
GoalExpr0 = unify(Var, Rhs, Mode, Unify0, Context),
- (
- fixup_unify(ModuleInfo, UnusedVars, Changed0, Unify0, Unify)
- ->
+ ( fixup_unify(ModuleInfo, UnusedVars, Changed0, Unify0, Unify) ->
GoalExpr = unify(Var, Rhs, Mode, Unify, Context),
Changed = Changed0
;
@@ -1383,30 +1348,25 @@
:- pred fixup_conjuncts(module_info::in, list(prog_var)::in, proc_call_info::in,
bool::in, bool::out, hlds_goals::in, hlds_goals::out) is det.
-fixup_conjuncts(_, _, _, Changed, Changed, [], []).
-fixup_conjuncts(ModuleInfo, UnusedVars, ProcCallInfo, Changed0, Changed,
+fixup_conjuncts(_, _, _, !Changed, [], []).
+fixup_conjuncts(ModuleInfo, UnusedVars, ProcCallInfo, !Changed,
[Goal0 | Goals0], Goals) :-
- fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo,
- LocalChanged, Goal0, Goal),
- (
- LocalChanged = yes
- ->
- Changed1 = yes
+ fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo, LocalChanged,
+ Goal0, Goal),
+ ( LocalChanged = yes ->
+ !:Changed = yes
;
- Changed1 = Changed0
+ true
),
- (
% replacing a goal with conj([]) signals that it is
% no longer needed
- Goal = conj([]) - _
- ->
+ ( Goal = conj([]) - _ ->
Goals = Goals1
;
Goals = [Goal | Goals1]
),
- fixup_conjuncts(ModuleInfo, UnusedVars, ProcCallInfo,
- Changed1, Changed, Goals0, Goals1).
-
+ fixup_conjuncts(ModuleInfo, UnusedVars, ProcCallInfo, !Changed,
+ Goals0, Goals1).
% We can't remove unused goals from the list of disjuncts as we do
% for conjuncts, since that would change the determinism of
@@ -1414,39 +1374,35 @@
:- pred fixup_disjuncts(module_info::in, list(prog_var)::in, proc_call_info::in,
bool::in, bool::out, hlds_goals::in, hlds_goals::out) is det.
-fixup_disjuncts(_, _, _, Changed, Changed, [], []).
-fixup_disjuncts(ModuleInfo, UnusedVars, ProcCallInfo, Changed0, Changed,
+fixup_disjuncts(_, _, _, !Changed, [], []).
+fixup_disjuncts(ModuleInfo, UnusedVars, ProcCallInfo, !Changed,
[Goal0 | Goals0], [Goal | Goals]) :-
- fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo,
- LocalChanged, Goal0, Goal),
- (
- LocalChanged = yes
- ->
- Changed1 = yes
+ fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo, LocalChanged,
+ Goal0, Goal),
+ ( LocalChanged = yes ->
+ !:Changed = yes
;
- Changed1 = Changed0
+ true
),
- fixup_disjuncts(ModuleInfo, UnusedVars, ProcCallInfo,
- Changed1, Changed, Goals0, Goals).
+ fixup_disjuncts(ModuleInfo, UnusedVars, ProcCallInfo, !Changed,
+ Goals0, Goals).
:- pred fixup_cases(module_info::in, list(prog_var)::in, proc_call_info::in,
bool::in, bool::out, list(case)::in, list(case)::out) is det.
-fixup_cases(_, _, _, Changed, Changed, [], []).
-fixup_cases(ModuleInfo, UnusedVars, ProcCallInfo, Changed0, Changed,
- [case(ConsId, Goal0) | Cases0], [case(ConsId, Goal) | Cases]) :-
- fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo,
- LocalChanged, Goal0, Goal),
- (
- LocalChanged = yes
- ->
- Changed1 = yes
+fixup_cases(_, _, _, !Changed, [], []).
+fixup_cases(ModuleInfo, UnusedVars, ProcCallInfo, !Changed,
+ [case(ConsId, Goal0) | Cases0],
+ [case(ConsId, Goal) | Cases]) :-
+ fixup_goal(ModuleInfo, UnusedVars, ProcCallInfo, LocalChanged,
+ Goal0, Goal),
+ ( LocalChanged = yes ->
+ !:Changed = yes
;
- Changed1 = Changed0
+ true
),
- fixup_cases(ModuleInfo, UnusedVars, ProcCallInfo,
- Changed1, Changed, Cases0, Cases).
-
+ fixup_cases(ModuleInfo, UnusedVars, ProcCallInfo, !Changed,
+ Cases0, Cases).
% fix up a unification, fail if the unification is no
% longer needed
@@ -1494,7 +1450,8 @@
check_deconstruct_args(ModuleInfo, UnusedVars, Args, Modes, Changed, Used) :-
(
- Args = [ArgVar | ArgVars], Modes = [ArgMode | ArgModes]
+ Args = [ArgVar | ArgVars],
+ Modes = [ArgMode | ArgModes]
->
(
ArgMode = ((Inst1 - Inst2) -> _),
@@ -1509,7 +1466,8 @@
ArgVars, ArgModes, Changed, yes)
)
;
- Args = [], Modes = []
+ Args = [],
+ Modes = []
->
Changed = no,
Used = yes
@@ -1522,10 +1480,10 @@
:- pred fixup_goal_info(list(prog_var)::in, hlds_goal_info::in,
hlds_goal_info::out) is det.
-fixup_goal_info(UnusedVars, GoalInfo0, GoalInfo) :-
- goal_info_get_instmap_delta(GoalInfo0, InstMap0),
+fixup_goal_info(UnusedVars, !GoalInfo) :-
+ goal_info_get_instmap_delta(!.GoalInfo, InstMap0),
instmap_delta_delete_vars(InstMap0, UnusedVars, InstMap),
- goal_info_set_instmap_delta(GoalInfo0, InstMap, GoalInfo).
+ goal_info_set_instmap_delta(!.GoalInfo, InstMap, !:GoalInfo).
%-------------------------------------------------------------------------------
@@ -1535,18 +1493,17 @@
% for each predicate.
:- pred output_warnings_and_pragmas(module_info::in, unused_arg_info::in,
maybe(io__output_stream)::in, bool::in, pred_proc_list::in,
- set(pred_id)::in, io__state::di, io__state::uo) is det.
+ set(pred_id)::in, io::di, io::uo) is det.
-output_warnings_and_pragmas(_, _, _, _, [], _) --> [].
+output_warnings_and_pragmas(_, _, _, _, [], _, !IO).
output_warnings_and_pragmas(ModuleInfo, UnusedArgInfo, WriteOptPragmas,
- DoWarn, [proc(PredId, ProcId) | Rest], WarnedPredIds0) -->
+ DoWarn, [proc(PredId, ProcId) | Rest], !.WarnedPredIds, !IO) :-
(
- { map__search(UnusedArgInfo, proc(PredId, ProcId),
- UnusedArgs) }
+ map__search(UnusedArgInfo, proc(PredId, ProcId),
+ UnusedArgs)
->
- { module_info_pred_info(ModuleInfo, PredId, PredInfo) },
+ module_info_pred_info(ModuleInfo, PredId, PredInfo),
(
- {
Name = pred_info_name(PredInfo),
\+ pred_info_is_imported(PredInfo),
\+ pred_info_import_status(PredInfo, opt_imported),
@@ -1575,62 +1532,59 @@
string__right(Name, IdLen, Id),
string__to_int(Id, _)
)
- }
->
write_unused_args_to_opt_file(WriteOptPragmas,
- PredInfo, ProcId, UnusedArgs),
+ PredInfo, ProcId, UnusedArgs, !IO),
maybe_warn_unused_args(DoWarn, ModuleInfo, PredInfo,
- PredId, ProcId, UnusedArgs,
- WarnedPredIds0, WarnedPredIds1)
+ PredId, ProcId, UnusedArgs, !WarnedPredIds,
+ !IO)
;
- { WarnedPredIds1 = WarnedPredIds0 }
+ true
)
;
- { WarnedPredIds1 = WarnedPredIds0 }
+ true
),
- output_warnings_and_pragmas(ModuleInfo, UnusedArgInfo,
- WriteOptPragmas, DoWarn, Rest, WarnedPredIds1).
-
+ output_warnings_and_pragmas(ModuleInfo, UnusedArgInfo, WriteOptPragmas,
+ DoWarn, Rest, !.WarnedPredIds, !IO).
:- pred write_unused_args_to_opt_file(maybe(io__output_stream)::in,
- pred_info::in, proc_id::in, list(int)::in,
- io__state::di, io__state::uo) is det.
+ pred_info::in, proc_id::in, list(int)::in, io::di, io::uo) is det.
-write_unused_args_to_opt_file(no, _, _, _) --> [].
-write_unused_args_to_opt_file(yes(OptStream), PredInfo, ProcId, UnusedArgs) -->
+write_unused_args_to_opt_file(no, _, _, _, !IO).
+write_unused_args_to_opt_file(yes(OptStream), PredInfo, ProcId, UnusedArgs,
+ !IO) :-
(
- ( { pred_info_is_exported(PredInfo) }
- ; { pred_info_is_opt_exported(PredInfo) }
- ; { pred_info_is_exported_to_submodules(PredInfo) }
+ ( pred_info_is_exported(PredInfo)
+ ; pred_info_is_opt_exported(PredInfo)
+ ; pred_info_is_exported_to_submodules(PredInfo)
),
- { UnusedArgs \= [] }
+ UnusedArgs \= []
->
- { Module = pred_info_module(PredInfo) },
- { Name = pred_info_name(PredInfo) },
- { Arity = pred_info_arity(PredInfo) },
- { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
- io__set_output_stream(OptStream, OldOutput),
- { proc_id_to_int(ProcId, ModeNum) },
+ Module = pred_info_module(PredInfo),
+ Name = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
+ io__set_output_stream(OptStream, OldOutput, !IO),
+ proc_id_to_int(ProcId, ModeNum),
mercury_output_pragma_unused_args(PredOrFunc,
- qualified(Module, Name), Arity, ModeNum, UnusedArgs),
- io__set_output_stream(OldOutput, _)
+ qualified(Module, Name), Arity, ModeNum, UnusedArgs,
+ !IO),
+ io__set_output_stream(OldOutput, _, !IO)
;
- []
+ true
).
:- pred maybe_warn_unused_args(bool::in, module_info::in, pred_info::in,
- pred_id::in, proc_id::in, list(int)::in, set(pred_id)::in,
- set(pred_id)::out, io__state::di, io__state::uo) is det.
+ pred_id::in, proc_id::in, list(int)::in,
+ set(pred_id)::in, set(pred_id)::out, io::di, io::uo) is det.
-
-maybe_warn_unused_args(no, _, _, _, _, _, WarnedPredIds, WarnedPredIds) --> [].
+maybe_warn_unused_args(no, _, _, _, _, _, !WarnedPredIds, !IO).
maybe_warn_unused_args(yes, _ModuleInfo, PredInfo, PredId, ProcId,
- UnusedArgs0, WarnedPredIds0, WarnedPredIds) -->
- ( { set__member(PredId, WarnedPredIds0) } ->
- { WarnedPredIds = WarnedPredIds0 }
+ UnusedArgs0, !WarnedPredIds, !IO) :-
+ ( set__member(PredId, !.WarnedPredIds) ->
+ true
;
- {
- set__insert(WarnedPredIds0, PredId, WarnedPredIds),
+ set__insert(!.WarnedPredIds, PredId, !:WarnedPredIds),
pred_info_procedures(PredInfo, Procs),
map__lookup(Procs, ProcId, Proc),
proc_info_headvars(Proc, HeadVars),
@@ -1639,21 +1593,20 @@
% Strip off the extra type_info arguments
% inserted at the front by polymorphism.m
NumToDrop = NumHeadVars - pred_info_arity(PredInfo),
- adjust_unused_args(NumToDrop, UnusedArgs0, UnusedArgs)
- },
- ( { UnusedArgs \= [] } ->
- report_unused_args(PredInfo, UnusedArgs)
+ adjust_unused_args(NumToDrop, UnusedArgs0, UnusedArgs),
+ (
+ UnusedArgs = [_ | _],
+ report_unused_args(PredInfo, UnusedArgs, !IO)
;
- []
+ UnusedArgs = []
)
).
-
% Warn about unused arguments in a predicate. Only arguments unused
% in every mode of a predicate are warned about. The warning is
% suppressed for type_infos.
:- pred report_unused_args(pred_info::in, list(int)::in,
- io__state::di, io__state::uo) is det.
+ io::di, io::uo) is det.
report_unused_args(PredInfo, UnusedArgs) -->
{ list__length(UnusedArgs, NumArgs) },
@@ -1699,36 +1652,34 @@
),
adjust_unused_args(NumToDrop, UnusedArgNos0, AdjUnusedArgs1).
+:- pred output_arg_list(list(int)::in, io::di, io::uo) is det.
-:- pred output_arg_list(list(int)::in, io__state::di, io__state::uo) is det.
-
-output_arg_list([]) --> { error("output_list_int called with empty list") }.
-output_arg_list([Arg | Rest]) -->
- io__write_int(Arg),
+output_arg_list([], !IO) :-
+ error("output_list_int called with empty list").
+output_arg_list([Arg | Rest], !IO) :-
+ io__write_int(Arg, !IO),
(
- { Rest = [] }
+ Rest = []
;
- { Rest = [_ | _] },
- output_arg_list_2(Rest)
+ Rest = [_ | _],
+ output_arg_list_2(Rest, !IO)
).
+:- pred output_arg_list_2(list(int)::in, io::di, io::uo) is det.
-:- pred output_arg_list_2(list(int)::in, io__state::di,
- io__state::uo) is det.
-
-output_arg_list_2(Args) -->
+output_arg_list_2(Args, !IO) :-
(
- { Args = [First, Second | Rest] }
+ Args = [First, Second | Rest]
->
- io__write_string(", "),
- io__write_int(First),
- output_arg_list_2([Second | Rest])
+ io__write_string(", ", !IO),
+ io__write_int(First, !IO),
+ output_arg_list_2([Second | Rest], !IO)
;
- { Args = [Last] }
+ Args = [Last]
->
- io__write_string(" and "),
- io__write_int(Last)
+ io__write_string(" and ", !IO),
+ io__write_int(Last, !IO)
;
- { error("output_arg_list_2 called with empty list") }
+ error("output_arg_list_2 called with empty list")
).
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/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/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 java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
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/assert_in_interface.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/assert_in_interface.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 assert_in_interface.err_exp
--- tests/invalid/assert_in_interface.err_exp 17 Jan 2003 05:57:07 -0000 1.3
+++ tests/invalid/assert_in_interface.err_exp 4 Apr 2004 10:34:29 -0000
@@ -1,4 +1,6 @@
assert_in_interface.m:005: In interface for module `assert_in_interface':
-assert_in_interface.m:005: error: exported promise refers to predicate `list.last/2'
-assert_in_interface.m:005: which is defined in the implementation of module `assert_in_interface'.
+assert_in_interface.m:005: error: exported promise refers to predicate
+assert_in_interface.m:005: `list.last/2' which is defined in the
+assert_in_interface.m:005: implementation section of module
+assert_in_interface.m:005: `assert_in_interface'.
For more information, try recompiling with `-E'.
Index: tests/invalid/multisoln_func.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/multisoln_func.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 multisoln_func.err_exp
--- tests/invalid/multisoln_func.err_exp 22 Aug 1997 13:58:46 -0000 1.3
+++ tests/invalid/multisoln_func.err_exp 4 Apr 2004 10:40:30 -0000
@@ -1,19 +1,19 @@
multisoln_func.m:026: Inferred :- func test2 = int.
multisoln_func.m:030: Inferred :- func test3(int) = int.
multisoln_func.m:034: Inferred :- func test3b(int) = int.
-multisoln_func.m:013: Error: invalid determinism for function
-multisoln_func.m:013: `f(in) = out':
-multisoln_func.m:013: the primary mode for a function cannot be `cc_multi'.
-multisoln_func.m:019: Error: invalid determinism for function
-multisoln_func.m:019: `test = out':
-multisoln_func.m:019: the primary mode for a function cannot be `cc_multi'.
-multisoln_func.m:026: Error: invalid determinism for function
-multisoln_func.m:026: `test2 = out':
-multisoln_func.m:026: the primary mode for a function cannot be `multi'.
-multisoln_func.m:030: Error: invalid determinism for function
-multisoln_func.m:030: `test3(in) = out':
-multisoln_func.m:030: the primary mode for a function cannot be `nondet'.
-multisoln_func.m:034: Error: invalid determinism for function
-multisoln_func.m:034: `test3b(in) = out':
-multisoln_func.m:034: the primary mode for a function cannot be `cc_nondet'.
+multisoln_func.m:013: Error: invalid determinism for
+multisoln_func.m:013: function `multisoln_func.f(in) = out':
+multisoln_func.m:013: the primary mode of a function cannot be `cc_multi'.
+multisoln_func.m:019: Error: invalid determinism for
+multisoln_func.m:019: function `multisoln_func.test() = out':
+multisoln_func.m:019: the primary mode of a function cannot be `cc_multi'.
+multisoln_func.m:026: Error: invalid determinism for
+multisoln_func.m:026: function `multisoln_func.test2() = out':
+multisoln_func.m:026: the primary mode of a function cannot be `multi'.
+multisoln_func.m:030: Error: invalid determinism for
+multisoln_func.m:030: function `multisoln_func.test3(in) = out':
+multisoln_func.m:030: the primary mode of a function cannot be `nondet'.
+multisoln_func.m:034: Error: invalid determinism for
+multisoln_func.m:034: function `multisoln_func.test3b(in) = out':
+multisoln_func.m:034: the primary mode of a function cannot be `cc_nondet'.
For more information, try recompiling with `-E'.
Index: tests/invalid/tricky_assert1.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/tricky_assert1.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 tricky_assert1.err_exp
--- tests/invalid/tricky_assert1.err_exp 17 Jan 2003 05:57:10 -0000 1.3
+++ tests/invalid/tricky_assert1.err_exp 4 Apr 2004 10:42:10 -0000
@@ -1,4 +1,5 @@
tricky_assert1.m:005: In interface for module `tricky_assert1':
-tricky_assert1.m:005: error: exported promise refers to predicate `tricky_assert1.local/0'
-tricky_assert1.m:005: which is defined in the implementation of module `tricky_assert1'.
+tricky_assert1.m:005: error: exported promise refers to predicate
+tricky_assert1.m:005: `tricky_assert1.local/0' which is defined in the
+tricky_assert1.m:005: implementation section of module `tricky_assert1'.
For more information, try recompiling with `-E'.
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
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