[m-rev.] diff: state variables and hlds_pred.m
Zoltan Somogyi
zs at cs.mu.OZ.AU
Fri Oct 24 16:16:51 AEST 2003
This diff makes hlds_pred.m and many callers of its predicates easier to read
and to maintain, but contains no changes in algorithms whatsoever.
compiler/hlds_pred.m:
Bring this module into line with our current coding standards.
Use predmode declarations, functions, and state variable syntax
when appropriate.
Reorder arguments of predicates where necessary for the use of state
variable syntax, and where this improves readability.
Replace old-style lambdas with new-style lambdas or with partially
applied named procedures.
Standardize indentation.
compiler/*.m:
Conform to the changes in hlds_pred.m. This mostly means using the
new argument orders of predicates exported by hlds_pred.m. Where this
is now conveniently possible, change predicates to use state
variable notation.
In some modules, using state variable notation required changing the
orders of arguments in the module's top predicate.
compiler/passes_aux.m:
Change the order of arguments in the calls this module makes to
allow the callees to use state variable notation.
Convert this module to state variable notation too.
Zoltan.
cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/accumulator.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/accumulator.m,v
retrieving revision 1.22
diff -u -b -r1.22 accumulator.m
--- compiler/accumulator.m 15 Mar 2003 03:08:42 -0000 1.22
+++ compiler/accumulator.m 21 Oct 2003 12:24:40 -0000
@@ -1316,9 +1316,9 @@
% Ensure that the reordering doesn't cause a
% efficiency problem
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_module(PredInfo, ModuleName),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, Arity),
+ ModuleName = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo),
(
has_heuristic(ModuleName, PredName, Arity)
->
@@ -1551,8 +1551,7 @@
acc_pred_info(AccTypes, AccProcInfo, OrigPredInfo, AccProcId,
AccPredInfo),
- pred_info_name(AccPredInfo, AccPredName),
- AccName = unqualified(AccPredName),
+ AccName = unqualified(pred_info_name(AccPredInfo)),
module_info_get_predicate_table(ModuleInfo0, PredTable0),
predicate_table_insert(PredTable0, AccPredInfo, AccPredId, PredTable),
@@ -1568,9 +1567,9 @@
top_level(TopLevel, OrigGoal0, OrigBaseGoal, OrigRecGoal,
AccBaseGoal, AccRecGoal, OrigGoal, AccGoal),
- proc_info_set_goal(OrigProcInfo0, OrigGoal, OrigProcInfo1),
- proc_info_set_varset(OrigProcInfo1, VarSet, OrigProcInfo2),
- proc_info_set_vartypes(OrigProcInfo2, VarTypes, OrigProcInfo3),
+ proc_info_set_goal(OrigGoal, OrigProcInfo0, OrigProcInfo1),
+ proc_info_set_varset(VarSet, OrigProcInfo1, OrigProcInfo2),
+ proc_info_set_vartypes(VarTypes, OrigProcInfo2, OrigProcInfo3),
requantify_proc(OrigProcInfo3, OrigProcInfo),
@@ -1645,12 +1644,12 @@
% PredInfo stuff that must change.
pred_info_arg_types(PredInfo, TypeVarSet, ExistQVars, Types0),
- pred_info_module(PredInfo, ModuleName),
- pred_info_name(PredInfo, Name),
+ ModuleName = pred_info_module(PredInfo),
+ Name = pred_info_name(PredInfo),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
Cond = true,
pred_info_context(PredInfo, PredContext),
pred_info_get_markers(PredInfo, Markers),
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
pred_info_get_class_context(PredInfo, ClassContext),
pred_info_get_aditi_owner(PredInfo, Owner),
@@ -1978,9 +1977,7 @@
ModuleInfo0, ModuleInfo) :-
module_info_pred_proc_info(ModuleInfo0, NewPredId, NewProcId,
PredInfo, ProcInfo0),
-
- proc_info_set_goal(ProcInfo0, AccGoal, ProcInfo1),
-
+ proc_info_set_goal(AccGoal, ProcInfo0, ProcInfo1),
requantify_proc(ProcInfo1, ProcInfo),
module_info_set_pred_proc_info(ModuleInfo0, NewPredId, NewProcId,
PredInfo, ProcInfo, ModuleInfo).
Index: compiler/add_heap_ops.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_heap_ops.m,v
retrieving revision 1.9
diff -u -b -r1.9 add_heap_ops.m
--- compiler/add_heap_ops.m 29 May 2003 18:17:13 -0000 1.9
+++ compiler/add_heap_ops.m 21 Oct 2003 12:25:51 -0000
@@ -33,7 +33,7 @@
:- import_module hlds__hlds_module.
:- import_module hlds__hlds_pred.
-:- pred add_heap_ops(proc_info::in, module_info::in, proc_info::out) is det.
+:- pred add_heap_ops(module_info::in, proc_info::in, proc_info::out) is det.
%-----------------------------------------------------------------------------%
@@ -74,21 +74,21 @@
module_info :: module_info
).
-add_heap_ops(Proc0, ModuleInfo0, Proc) :-
- proc_info_goal(Proc0, Goal0),
- proc_info_varset(Proc0, VarSet0),
- proc_info_vartypes(Proc0, VarTypes0),
+add_heap_ops(ModuleInfo0, !Proc) :-
+ proc_info_goal(!.Proc, Goal0),
+ proc_info_varset(!.Proc, VarSet0),
+ proc_info_vartypes(!.Proc, VarTypes0),
TrailOpsInfo0 = heap_ops_info(VarSet0, VarTypes0, ModuleInfo0),
goal_add_heap_ops(Goal0, Goal, TrailOpsInfo0, TrailOpsInfo),
TrailOpsInfo = heap_ops_info(VarSet, VarTypes, _),
- proc_info_set_goal(Proc0, Goal, Proc1),
- proc_info_set_varset(Proc1, VarSet, Proc2),
- proc_info_set_vartypes(Proc2, VarTypes, Proc3),
+ proc_info_set_goal(Goal, !Proc),
+ proc_info_set_varset(VarSet, !Proc),
+ proc_info_set_vartypes(VarTypes, !Proc),
% The code below does not maintain the non-local variables,
% so we need to requantify.
% XXX it would be more efficient to maintain them
% rather than recomputing them every time.
- requantify_proc(Proc3, Proc).
+ requantify_proc(!Proc).
:- pred goal_add_heap_ops(hlds_goal::in, hlds_goal::out,
heap_ops_info::in, heap_ops_info::out) is det.
Index: compiler/add_trail_ops.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_trail_ops.m,v
retrieving revision 1.11
diff -u -b -r1.11 add_trail_ops.m
--- compiler/add_trail_ops.m 29 May 2003 18:17:13 -0000 1.11
+++ compiler/add_trail_ops.m 21 Oct 2003 12:26:40 -0000
@@ -33,7 +33,7 @@
:- import_module hlds__hlds_module.
:- import_module hlds__hlds_pred.
-:- pred add_trail_ops(proc_info::in, module_info::in, proc_info::out) is det.
+:- pred add_trail_ops(module_info::in, proc_info::in, proc_info::out) is det.
%-----------------------------------------------------------------------------%
@@ -74,21 +74,21 @@
module_info :: module_info
).
-add_trail_ops(Proc0, ModuleInfo0, Proc) :-
- proc_info_goal(Proc0, Goal0),
- proc_info_varset(Proc0, VarSet0),
- proc_info_vartypes(Proc0, VarTypes0),
+add_trail_ops(ModuleInfo0, !Proc) :-
+ proc_info_goal(!.Proc, Goal0),
+ proc_info_varset(!.Proc, VarSet0),
+ proc_info_vartypes(!.Proc, VarTypes0),
TrailOpsInfo0 = trail_ops_info(VarSet0, VarTypes0, ModuleInfo0),
goal_add_trail_ops(Goal0, Goal, TrailOpsInfo0, TrailOpsInfo),
TrailOpsInfo = trail_ops_info(VarSet, VarTypes, _),
- proc_info_set_goal(Proc0, Goal, Proc1),
- proc_info_set_varset(Proc1, VarSet, Proc2),
- proc_info_set_vartypes(Proc2, VarTypes, Proc3),
+ proc_info_set_goal(Goal, !Proc),
+ proc_info_set_varset(VarSet, !Proc),
+ proc_info_set_vartypes(VarTypes, !Proc),
% The code below does not maintain the non-local variables,
% so we need to requantify.
% XXX it would be more efficient to maintain them
% rather than recomputing them every time.
- requantify_proc(Proc3, Proc).
+ requantify_proc(!Proc).
:- pred goal_add_trail_ops(hlds_goal::in, hlds_goal::out,
trail_ops_info::in, trail_ops_info::out) is det.
Index: compiler/aditi_builtin_ops.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/aditi_builtin_ops.m,v
retrieving revision 1.5
diff -u -b -r1.5 aditi_builtin_ops.m
--- compiler/aditi_builtin_ops.m 19 Sep 2003 11:10:02 -0000 1.5
+++ compiler/aditi_builtin_ops.m 21 Oct 2003 12:28:36 -0000
@@ -68,22 +68,20 @@
:- mode transform_aditi_builtins_in_proc(in, in, in, out,
in, out, di, uo) is det.
-transform_aditi_builtins_in_proc(PredId, _ProcId, ProcInfo0, ProcInfo,
- ModuleInfo0, ModuleInfo, IO, IO) :-
- proc_info_goal(ProcInfo0, Goal0),
- construct_aditi_transform_info(ModuleInfo0, PredId, ProcInfo0,
+transform_aditi_builtins_in_proc(PredId, _ProcId, !ProcInfo,
+ !ModuleInfo, IO, IO) :-
+ proc_info_goal(!.ProcInfo, Goal0),
+ construct_aditi_transform_info(!.ModuleInfo, PredId, !.ProcInfo,
Info0),
transform_aditi_builtins_in_goal(Goal0, Goal, Info0, Info),
deconstruct_aditi_transform_info(Info, PredId,
- ModuleInfo1, ProcInfo1, Changed),
+ !:ModuleInfo, !:ProcInfo, Changed),
( Changed = yes ->
- proc_info_set_goal(ProcInfo1, Goal, ProcInfo2),
- requantify_proc(ProcInfo2, ProcInfo3),
- recompute_instmap_delta_proc(yes, ProcInfo3, ProcInfo,
- ModuleInfo1, ModuleInfo)
+ proc_info_set_goal(Goal, !ProcInfo),
+ requantify_proc(!ProcInfo),
+ recompute_instmap_delta_proc(yes, !ProcInfo, !ModuleInfo)
;
- ProcInfo = ProcInfo1,
- ModuleInfo = ModuleInfo1
+ true
).
:- pred transform_aditi_builtins_in_goal(hlds_goal, hlds_goal,
@@ -257,8 +255,8 @@
{ status_defined_in_this_module(CalleeStatus, yes) },
\+ { hlds_pred__pred_info_is_base_relation(CalleePredInfo0) }
->
- { pred_info_set_import_status(CalleePredInfo0,
- exported, CalleePredInfo) },
+ { pred_info_set_import_status(exported,
+ CalleePredInfo0, CalleePredInfo) },
{ module_info_set_pred_info(ModuleInfo1, PredId,
CalleePredInfo, ModuleInfo) },
^ module_info := ModuleInfo
@@ -270,7 +268,7 @@
% Cast the closure to the type and inst of the original closure,
% so that the HLDS is still type and mode correct.
%
- { pred_info_get_is_pred_or_func(CalleePredInfo, CalleePredOrFunc) },
+ { CalleePredOrFunc = pred_info_is_pred_or_func(CalleePredInfo) },
{ proc_info_argmodes(CalleeProcInfo, CalleeArgModes) },
{
list__drop(list__length(Args), CalleeArgModes,
@@ -386,7 +384,7 @@
ModuleInfo =^ module_info,
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
{ pred_info_arg_types(PredInfo, ArgTypes) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
{ list__length(ArgTypes, PredArity) },
{
Op = bulk_delete,
@@ -447,7 +445,7 @@
create_aditi_call_goal(ProcNameStr, HeadVars, ArgModes, Det, Goal,
Info0, Info),
Info = aditi_transform_info(ModuleInfo1, PredInfo, ProcInfo1, _),
- proc_info_set_goal(ProcInfo1, Goal, ProcInfo2),
+ proc_info_set_goal(Goal, ProcInfo1, ProcInfo2),
requantify_proc(ProcInfo2, ProcInfo3),
recompute_instmap_delta_proc(yes, ProcInfo3, ProcInfo,
ModuleInfo1, ModuleInfo2),
@@ -565,8 +563,8 @@
{ map__apply_to_list(Args, VarTypes, ArgTypes) },
{ construct_type(unqualified("{}") - list__length(Args),
ArgTypes, TupleType) },
- { proc_info_create_var_from_type(ProcInfo0, TupleType, no,
- TupleVar, ProcInfo) },
+ { proc_info_create_var_from_type(TupleType, no, TupleVar,
+ ProcInfo0, ProcInfo) },
^ proc_info := ProcInfo,
make_type_info_for_var(TupleVar, TupleTypeInfo, TupleTypeInfoGoal).
@@ -645,8 +643,8 @@
[], RelationType),
construct_higher_order_pred_type(pure, normal,
[aditi_state_type, RelationType], PredType),
- proc_info_create_var_from_type(Info0 ^ proc_info, PredType, no,
- NewVar, ProcInfo),
+ proc_info_create_var_from_type(PredType, no, NewVar,
+ Info0 ^ proc_info, ProcInfo),
Info = Info0 ^ proc_info := ProcInfo.
% Work out which predicate from aditi_private_builtin.m
Index: compiler/arg_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/arg_info.m,v
retrieving revision 1.39
diff -u -b -r1.39 arg_info.m
--- compiler/arg_info.m 15 Mar 2003 03:08:42 -0000 1.39
+++ compiler/arg_info.m 21 Oct 2003 14:47:44 -0000
@@ -32,8 +32,8 @@
% Annotate a single procedure with information
% about its argument passing interface.
-:- pred generate_proc_arg_info(proc_info::in, list(type)::in, module_info::in,
- proc_info::out) is det.
+:- pred generate_proc_arg_info(list(type)::in, module_info::in,
+ proc_info::in, proc_info::out) is det.
% Given the list of types and modes of the arguments of a procedure
% and its code model, return its argument passing interface.
@@ -117,44 +117,44 @@
:- pred generate_pred_arg_info(list(pred_id)::in,
module_info::in, module_info::out) is det.
-generate_pred_arg_info([], ModuleInfo, ModuleInfo).
-generate_pred_arg_info([PredId | PredIds], ModuleInfo0, ModuleInfo) :-
- module_info_preds(ModuleInfo0, PredTable),
+generate_pred_arg_info([], !ModuleInfo).
+generate_pred_arg_info([PredId | PredIds], !ModuleInfo) :-
+ module_info_preds(!.ModuleInfo, PredTable),
map__lookup(PredTable, PredId, PredInfo),
- pred_info_procids(PredInfo, ProcIds),
- generate_proc_list_arg_info(PredId, ProcIds, ModuleInfo0, ModuleInfo1),
- generate_pred_arg_info(PredIds, ModuleInfo1, ModuleInfo).
+ generate_proc_list_arg_info(PredId, pred_info_procids(PredInfo),
+ !ModuleInfo),
+ generate_pred_arg_info(PredIds, !ModuleInfo).
:- pred generate_proc_list_arg_info(pred_id::in, list(proc_id)::in,
module_info::in, module_info::out) is det.
-generate_proc_list_arg_info(_PredId, [], ModuleInfo, ModuleInfo).
+generate_proc_list_arg_info(_PredId, [], !ModuleInfo).
generate_proc_list_arg_info(PredId, [ProcId | ProcIds],
- ModuleInfo0, ModuleInfo) :-
- module_info_preds(ModuleInfo0, PredTable0),
+ !ModuleInfo) :-
+ module_info_preds(!.ModuleInfo, PredTable0),
map__lookup(PredTable0, PredId, PredInfo0),
( hlds_pred__pred_info_is_aditi_relation(PredInfo0) ->
- ModuleInfo1 = ModuleInfo0
+ true
;
pred_info_procedures(PredInfo0, ProcTable0),
pred_info_arg_types(PredInfo0, ArgTypes),
map__lookup(ProcTable0, ProcId, ProcInfo0),
- generate_proc_arg_info(ProcInfo0, ArgTypes,
- ModuleInfo0, ProcInfo),
+ generate_proc_arg_info(ArgTypes, !.ModuleInfo,
+ ProcInfo0, ProcInfo),
map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable),
- pred_info_set_procedures(PredInfo0, ProcTable, PredInfo),
+ pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
map__det_update(PredTable0, PredId, PredInfo, PredTable),
- module_info_set_preds(ModuleInfo0, PredTable, ModuleInfo1)
+ module_info_set_preds(!.ModuleInfo, PredTable, !:ModuleInfo)
),
- generate_proc_list_arg_info(PredId, ProcIds, ModuleInfo1, ModuleInfo).
+ generate_proc_list_arg_info(PredId, ProcIds, !ModuleInfo).
-generate_proc_arg_info(ProcInfo0, ArgTypes, ModuleInfo, ProcInfo) :-
- proc_info_argmodes(ProcInfo0, ArgModes),
- proc_info_interface_code_model(ProcInfo0, CodeModel),
+generate_proc_arg_info(ArgTypes, ModuleInfo, !ProcInfo) :-
+ proc_info_argmodes(!.ProcInfo, ArgModes),
+ proc_info_interface_code_model(!.ProcInfo, CodeModel),
make_arg_infos(ArgTypes, ArgModes, CodeModel, ModuleInfo, ArgInfo),
- proc_info_set_arg_info(ProcInfo0, ArgInfo, ProcInfo).
+ proc_info_set_arg_info(ArgInfo, !ProcInfo).
%---------------------------------------------------------------------------%
Index: compiler/assertion.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/assertion.m,v
retrieving revision 1.23
diff -u -b -r1.23 assertion.m
--- compiler/assertion.m 27 Mar 2003 05:33:43 -0000 1.23
+++ compiler/assertion.m 21 Oct 2003 10:27:07 -0000
@@ -657,15 +657,15 @@
% Record in the pred_info pointed to by Id that that predicate
% is used in the assertion pointed to by A.
%
-:- pred update_pred_info(assert_id::in, pred_id::in, module_info::in,
- module_info::out) is det.
+:- pred update_pred_info(assert_id::in, pred_id::in,
+ module_info::in, module_info::out) is det.
-update_pred_info(AssertId, PredId, Module0, Module) :-
- module_info_pred_info(Module0, PredId, PredInfo0),
+update_pred_info(AssertId, PredId, !Module) :-
+ module_info_pred_info(!.Module, PredId, PredInfo0),
pred_info_get_assertions(PredInfo0, Assertions0),
set__insert(Assertions0, AssertId, Assertions),
- pred_info_set_assertions(PredInfo0, Assertions, PredInfo),
- module_info_set_pred_info(Module0, PredId, PredInfo, Module).
+ pred_info_set_assertions(Assertions, PredInfo0, PredInfo),
+ module_info_set_pred_info(!.Module, PredId, PredInfo, !:Module).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -749,8 +749,8 @@
{ is_defined_in_implementation_section(ImportStatus, yes) }
->
{ goal_info_get_context(GoalInfo, Context) },
- { pred_info_get_is_pred_or_func(CallPredInfo, PredOrFunc) },
- { pred_info_arity(CallPredInfo, Arity) },
+ { PredOrFunc = pred_info_is_pred_or_func(CallPredInfo) },
+ { Arity = pred_info_arity(CallPredInfo) },
write_assertion_interface_error(Context,
call(PredOrFunc, SymName, Arity),
Module0, Module)
@@ -772,10 +772,10 @@
{ is_defined_in_implementation_section(ImportStatus, yes) }
->
{ goal_info_get_context(GoalInfo, Context) },
- { pred_info_get_is_pred_or_func(PragmaPredInfo, PredOrFunc) },
- { pred_info_name(PragmaPredInfo, Name) },
+ { PredOrFunc = pred_info_is_pred_or_func(PragmaPredInfo) },
+ { Name = pred_info_name(PragmaPredInfo) },
{ SymName = unqualified(Name) },
- { pred_info_arity(PragmaPredInfo, Arity) },
+ { Arity = pred_info_arity(PragmaPredInfo) },
write_assertion_interface_error(Context,
call(PredOrFunc, SymName, Arity),
Module0, Module)
Index: compiler/bytecode_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/bytecode_gen.m,v
retrieving revision 1.76
diff -u -b -r1.76 bytecode_gen.m
--- compiler/bytecode_gen.m 20 Oct 2003 07:29:04 -0000 1.76
+++ compiler/bytecode_gen.m 21 Oct 2003 09:35:52 -0000
@@ -74,7 +74,7 @@
bytecode_gen__preds([PredId | PredIds], ModuleInfo, Code) -->
{ module_info_preds(ModuleInfo, PredTable) },
{ map__lookup(PredTable, PredId, PredInfo) },
- { pred_info_non_imported_procids(PredInfo, ProcIds) },
+ { ProcIds = pred_info_non_imported_procids(PredInfo) },
( { ProcIds = [] } ->
{ PredCode = empty }
;
@@ -82,7 +82,7 @@
ProcsCode),
{ predicate_name(ModuleInfo, PredId, PredName) },
{ list__length(ProcIds, ProcsCount) },
- { pred_info_arity(PredInfo, Arity) },
+ { Arity = pred_info_arity(PredInfo) },
{ bytecode_gen__get_is_func(PredInfo, IsFunc) },
{ EnterCode = node([enter_pred(PredName, Arity, IsFunc,
ProcsCount)]) },
@@ -911,8 +911,7 @@
:- mode bytecode_gen__get_is_func(in, out) is det.
bytecode_gen__get_is_func(PredInfo, IsFunc) :-
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
- ( PredOrFunc = predicate ->
+ ( pred_info_is_pred_or_func(PredInfo) = predicate ->
IsFunc = 0
;
IsFunc = 1
Index: compiler/check_typeclass.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/check_typeclass.m,v
retrieving revision 1.48
diff -u -b -r1.48 check_typeclass.m
--- compiler/check_typeclass.m 15 Mar 2003 03:08:43 -0000 1.48
+++ compiler/check_typeclass.m 21 Oct 2003 10:00:24 -0000
@@ -438,11 +438,11 @@
error("check_instance_pred: no constraint on class method")
),
- pred_info_name(PredInfo, MethodName0),
- pred_info_module(PredInfo, PredModule),
+ MethodName0 = pred_info_name(PredInfo),
+ PredModule = pred_info_module(PredInfo),
MethodName = qualified(PredModule, MethodName0),
- pred_info_arity(PredInfo, PredArity),
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
+ PredArity = pred_info_arity(PredInfo),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
adjust_func_arity(PredOrFunc, Arity, PredArity),
pred_info_procedures(PredInfo, ProcTable),
list__map(
@@ -754,7 +754,7 @@
ExistQVars, ArgTypes, Cond, Context, ClausesInfo, Status,
Markers, none, PredOrFunc, ClassContext, Proofs, User,
PredInfo0),
- pred_info_set_clauses_info(PredInfo0, ClausesInfo, PredInfo1),
+ pred_info_set_clauses_info(ClausesInfo, PredInfo0, PredInfo1),
% Fill in some information in the pred_info which is
% used by polymorphism to make sure the type-infos
@@ -762,8 +762,8 @@
MethodConstraints = instance_method_constraints(ClassId,
InstanceTypes, InstanceConstraints,
ClassMethodClassContext),
- pred_info_set_maybe_instance_method_constraints(PredInfo1,
- yes(MethodConstraints), PredInfo2),
+ pred_info_set_maybe_instance_method_constraints(
+ yes(MethodConstraints), PredInfo1, PredInfo2),
% Add procs with the expected modes and determinisms
AddProc = lambda([ModeAndDet::in, NewProcId::out,
Index: compiler/clause_to_proc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/clause_to_proc.m,v
retrieving revision 1.36
diff -u -b -r1.36 clause_to_proc.m
--- compiler/clause_to_proc.m 26 May 2003 08:59:51 -0000 1.36
+++ compiler/clause_to_proc.m 21 Oct 2003 09:30:46 -0000
@@ -69,7 +69,7 @@
maybe_add_default_func_mode(PredInfo0, PredInfo, MaybeProcId) :-
pred_info_procedures(PredInfo0, Procs0),
- pred_info_get_is_pred_or_func(PredInfo0, PredOrFunc),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo0),
(
%
% Is this a function with no modes?
@@ -85,7 +85,7 @@
% for this function. (N.B. functions which can
% fail must be explicitly declared as semidet.)
%
- pred_info_arity(PredInfo0, PredArity),
+ PredArity = pred_info_arity(PredInfo0),
FuncArity = PredArity - 1,
in_mode(InMode),
out_mode(OutMode),
@@ -131,12 +131,12 @@
copy_module_clauses_to_procs_2(PredIds, Preds1, Preds).
-copy_clauses_to_procs(PredInfo0, PredInfo) :-
- pred_info_procedures(PredInfo0, Procs0),
- pred_info_clauses_info(PredInfo0, ClausesInfo),
- pred_info_all_non_imported_procids(PredInfo0, ProcIds),
+copy_clauses_to_procs(!PredInfo) :-
+ pred_info_procedures(!.PredInfo, Procs0),
+ pred_info_clauses_info(!.PredInfo, ClausesInfo),
+ ProcIds = pred_info_all_non_imported_procids(!.PredInfo),
copy_clauses_to_procs_2(ProcIds, ClausesInfo, Procs0, Procs),
- pred_info_set_procedures(PredInfo0, Procs, PredInfo).
+ pred_info_set_procedures(Procs, !PredInfo).
:- pred copy_clauses_to_procs_2(list(proc_id), clauses_info,
proc_table, proc_table).
Index: compiler/code_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/code_gen.m,v
retrieving revision 1.115
diff -u -b -r1.115 code_gen.m
--- compiler/code_gen.m 27 May 2003 05:57:08 -0000 1.115
+++ compiler/code_gen.m 21 Oct 2003 09:48:59 -0000
@@ -145,39 +145,37 @@
% by mercury_compile__backend_pass_by_preds, so modifications here may
% also need to be repeated there.
-generate_maybe_pred_code(ModuleInfo0, GlobalData0, GlobalData,
- PredId, Predicates) -->
- { module_info_preds(ModuleInfo0, PredInfos) },
+generate_maybe_pred_code(ModuleInfo0, !GlobalData, PredId, Predicates, !IO) :-
+ module_info_preds(ModuleInfo0, PredInfos),
% get the pred_info structure for this predicate
- { map__lookup(PredInfos, PredId, PredInfo) },
+ map__lookup(PredInfos, PredId, PredInfo),
% extract a list of all the procedure ids for this
% predicate and generate code for them
- { pred_info_non_imported_procids(PredInfo, ProcIds) },
+ ProcIds = pred_info_non_imported_procids(PredInfo),
(
- { ProcIds = []
+ ( ProcIds = []
; hlds_pred__pred_info_is_aditi_relation(PredInfo)
- }
+ )
->
- { Predicates = [] },
- { GlobalData = GlobalData0 }
+ Predicates = []
;
- { module_info_globals(ModuleInfo0, Globals0) },
- { globals__lookup_bool_option(Globals0, very_verbose,
- VeryVerbose) },
- ( { VeryVerbose = yes } ->
- io__write_string("% Generating code for "),
- hlds_out__write_pred_id(ModuleInfo0, PredId),
- io__write_string("\n"),
- { globals__lookup_bool_option(Globals0,
- statistics, Statistics) },
- maybe_report_stats(Statistics)
+ module_info_globals(ModuleInfo0, Globals0),
+ globals__lookup_bool_option(Globals0, very_verbose,
+ VeryVerbose),
+ ( VeryVerbose = yes ->
+ io__write_string("% Generating code for ", !IO),
+ hlds_out__write_pred_id(ModuleInfo0, PredId, !IO),
+ io__write_string("\n", !IO),
+ globals__lookup_bool_option(Globals0,
+ statistics, Statistics),
+ maybe_report_stats(Statistics, !IO)
;
- []
+ true
),
- {
- pred_info_module(PredInfo, PredModule),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, PredArity),
+ (
+ PredModule = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
+ PredArity = pred_info_arity(PredInfo),
no_type_info_builtin(PredModule, PredName, PredArity)
->
% These predicates should never be traced,
@@ -188,14 +186,12 @@
globals__set_trace_level_none(Globals0, Globals1),
module_info_set_globals(ModuleInfo0, Globals1,
ModuleInfo1),
- generate_pred_code(ModuleInfo1,
- GlobalData0, GlobalData,
+ generate_pred_code(ModuleInfo1, !GlobalData,
PredId, PredInfo, ProcIds, Predicates)
;
- generate_pred_code(ModuleInfo0,
- GlobalData0, GlobalData,
+ generate_pred_code(ModuleInfo0, !GlobalData,
PredId, PredInfo, ProcIds, Predicates)
- }
+ )
).
% Translate a HLDS predicate to LLDS.
@@ -378,8 +374,8 @@
maybe_add_tabling_pointer_var(ModuleInfo, PredId, ProcId, ProcInfo,
ProcLabel, !GlobalData),
- pred_info_name(PredInfo, Name),
- pred_info_arity(PredInfo, Arity),
+ Name = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo),
code_info__get_label_counter(LabelCounter, CodeInfo, _),
(
@@ -764,9 +760,9 @@
{ TraceFillCode = empty }
),
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_module(PredInfo, ModuleName) },
- { pred_info_name(PredInfo, PredName) },
- { pred_info_arity(PredInfo, Arity) },
+ { ModuleName = pred_info_module(PredInfo) },
+ { PredName = pred_info_name(PredInfo) },
+ { Arity = pred_info_arity(PredInfo) },
{ PushMsg = code_gen__push_msg(ModuleInfo, PredId, ProcId) },
(
@@ -1282,19 +1278,19 @@
code_gen__bytecode_stub(ModuleInfo, PredId, ProcId, BytecodeInstructions) :-
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_module(PredInfo, ModuleSymName),
+ ModuleSymName = pred_info_module(PredInfo),
prog_out__sym_name_to_string(ModuleSymName, "__", ModuleName),
code_util__make_local_entry_label(ModuleInfo, PredId,
ProcId, no, Entry),
- pred_info_name(PredInfo, PredName),
+ PredName = pred_info_name(PredInfo),
proc_id_to_int(ProcId, ProcNum),
string__int_to_string(ProcNum, ProcStr),
- pred_info_arity(PredInfo, Arity),
+ Arity = pred_info_arity(PredInfo),
int_to_string(Arity, ArityStr),
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
CallStructName = "bytecode_call_info",
@@ -1340,10 +1336,10 @@
code_gen__push_msg(ModuleInfo, PredId, ProcId) = PushMsg :-
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
- pred_info_module(PredInfo, ModuleName),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, Arity),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
+ ModuleName = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo),
pred_info_get_maybe_special_pred(PredInfo, MaybeSpecial),
( MaybeSpecial = yes(SpecialId - TypeCtor) ->
code_gen__find_arg_type_ctor_name(TypeCtor, TypeName),
Index: compiler/context.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/context.m,v
retrieving revision 1.7
diff -u -b -r1.7 context.m
--- compiler/context.m 15 Mar 2003 03:08:43 -0000 1.7
+++ compiler/context.m 21 Oct 2003 12:29:46 -0000
@@ -363,8 +363,8 @@
magic_info_get_magic_vars(MagicVars),
{ list__append(MagicVars, Args0, Args) },
magic_info_get_pred_info(PredInfo),
- { pred_info_module(PredInfo, PredModule) },
- { pred_info_name(PredInfo, PredName) },
+ { PredModule = pred_info_module(PredInfo) },
+ { PredName = pred_info_name(PredInfo) },
magic_info_get_curr_pred_proc_id(proc(PredId, ProcId)),
{ CallGoal = call(PredId, ProcId, Args, not_builtin, no,
qualified(PredModule, PredName)) - RecGoalInfo },
@@ -427,8 +427,8 @@
% Update the called pred_proc_id.
{ FirstRecCall0 = db_call(_, _ - RecGoalInfo, _, Args0, _, _, _) },
magic_info_get_pred_info(PredInfo),
- { pred_info_module(PredInfo, PredModule) },
- { pred_info_name(PredInfo, PredName) },
+ { PredModule = pred_info_module(PredInfo) },
+ { PredName = pred_info_name(PredInfo) },
magic_info_get_curr_pred_proc_id(proc(PredId, ProcId)),
magic_info_get_magic_vars(MagicVars),
{ list__append(MagicVars, Args0, Args) },
@@ -522,8 +522,8 @@
{ goal_info_set_nonlocals(GoalInfo1,
GoalNonLocals, GoalInfo) },
magic_info_get_pred_info(PredInfo),
- { pred_info_module(PredInfo, PredModule) },
- { pred_info_name(PredInfo, PredName) },
+ { PredModule = pred_info_module(PredInfo) },
+ { PredName = pred_info_name(PredInfo) },
magic_info_get_magic_vars(MagicVars),
{ list__append(MagicVars, NewArgs, AllArgs) },
{ RecGoal = call(PredId, ProcId, AllArgs, not_builtin, no,
@@ -545,8 +545,8 @@
magic_info_get_proc_info(ProcInfo0),
{ proc_info_vartypes(ProcInfo0, VarTypes0) },
{ map__apply_to_list(InputArgs, VarTypes0, InputTypes) },
- { proc_info_create_vars_from_types(ProcInfo0,
- InputTypes, NewInputArgs, ProcInfo) },
+ { proc_info_create_vars_from_types(InputTypes, NewInputArgs,
+ ProcInfo0, ProcInfo) },
magic_info_set_proc_info(ProcInfo),
( { RenameInputs = yes } ->
Index: compiler/cse_detection.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/cse_detection.m,v
retrieving revision 1.75
diff -u -b -r1.75 cse_detection.m
--- compiler/cse_detection.m 15 Mar 2003 03:08:44 -0000 1.75
+++ compiler/cse_detection.m 21 Oct 2003 12:30:23 -0000
@@ -80,9 +80,9 @@
module_info::in, module_info::out, io__state::di, io__state::uo)
is det.
-detect_cse_in_pred(PredId, PredInfo0, ModuleInfo0, ModuleInfo) -->
- { pred_info_non_imported_procids(PredInfo0, ProcIds) },
- detect_cse_in_procs(ProcIds, PredId, ModuleInfo0, ModuleInfo).
+detect_cse_in_pred(PredId, PredInfo0, !ModuleInfo, !IO) :-
+ ProcIds = pred_info_non_imported_procids(PredInfo0),
+ detect_cse_in_procs(ProcIds, PredId, !ModuleInfo, !IO).
:- pred detect_cse_in_procs(list(proc_id)::in, pred_id::in,
module_info::in, module_info::out, io__state::di, io__state::uo)
@@ -177,19 +177,19 @@
TypeInfoVarMap, TypeClassInfoVarMap, _),
proc_info_headvars(ProcInfo0, HeadVars),
- implicitly_quantify_clause_body(HeadVars, Goal1, VarSet1,
- VarTypes1, Goal, VarSet, VarTypes, _Warnings),
+ implicitly_quantify_clause_body(HeadVars, _Warnings,
+ Goal1, Goal, VarSet1, VarSet, VarTypes1, VarTypes),
- proc_info_set_goal(ProcInfo0, Goal, ProcInfo1),
- proc_info_set_varset(ProcInfo1, VarSet, ProcInfo2),
- proc_info_set_vartypes(ProcInfo2, VarTypes, ProcInfo3),
- proc_info_set_typeinfo_varmap(ProcInfo3,
- TypeInfoVarMap, ProcInfo4),
- proc_info_set_typeclass_info_varmap(ProcInfo4,
- TypeClassInfoVarMap, ProcInfo),
+ proc_info_set_goal(Goal, ProcInfo0, ProcInfo1),
+ proc_info_set_varset(VarSet, ProcInfo1, ProcInfo2),
+ proc_info_set_vartypes(VarTypes, ProcInfo2, ProcInfo3),
+ proc_info_set_typeinfo_varmap(TypeInfoVarMap,
+ ProcInfo3, ProcInfo4),
+ proc_info_set_typeclass_info_varmap(TypeClassInfoVarMap,
+ ProcInfo4, ProcInfo),
map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable),
- pred_info_set_procedures(PredInfo0, ProcTable, PredInfo),
+ pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
map__det_update(PredTable0, PredId, PredInfo, PredTable),
module_info_set_preds(ModuleInfo0, PredTable, ModuleInfo)
).
@@ -835,7 +835,7 @@
NewTvarMap0, NewTvarMap) :-
type_info_locn_var(TypeInfoLocn0, Old),
( map__search(FirstOldNewMap, Old, New) ->
- type_info_locn_set_var(TypeInfoLocn0, New, TypeInfoLocn),
+ type_info_locn_set_var(New, TypeInfoLocn0, TypeInfoLocn),
map__det_insert(NewTvarMap0, TypeInfoLocn, Tvar, NewTvarMap)
;
NewTvarMap = NewTvarMap0
@@ -850,7 +850,7 @@
TypeInfoVarMap0, TypeInfoVarMap, TvarSub0, TvarSub) :-
type_info_locn_var(TypeInfoLocn0, Old),
( map__search(FirstOldNewMap, Old, New) ->
- type_info_locn_set_var(TypeInfoLocn0, New, TypeInfoLocn),
+ type_info_locn_set_var(New, TypeInfoLocn0, TypeInfoLocn),
map__det_insert(TypeInfoVarMap0, Tvar, TypeInfoLocn,
TypeInfoVarMap),
map__lookup(NewTvarMap, TypeInfoLocn, NewTvar),
Index: compiler/dead_proc_elim.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/dead_proc_elim.m,v
retrieving revision 1.82
diff -u -b -r1.82 dead_proc_elim.m
--- compiler/dead_proc_elim.m 23 Jul 2003 03:38:10 -0000 1.82
+++ compiler/dead_proc_elim.m 21 Oct 2003 12:32:43 -0000
@@ -151,15 +151,13 @@
entity_queue, entity_queue, needed_map, needed_map).
:- mode dead_proc_elim__initialize_preds(in, in, in, out, in, out) is det.
-dead_proc_elim__initialize_preds([], _PredTable, Queue, Queue, Needed, Needed).
+dead_proc_elim__initialize_preds([], _PredTable, !Queue, !Needed).
dead_proc_elim__initialize_preds([PredId | PredIds], PredTable,
- Queue0, Queue, Needed0, Needed) :-
+ !Queue, !Needed) :-
map__lookup(PredTable, PredId, PredInfo),
- pred_info_exported_procids(PredInfo, ProcIds),
- dead_proc_elim__initialize_procs(PredId, ProcIds,
- Queue0, Queue1, Needed0, Needed1),
- dead_proc_elim__initialize_preds(PredIds, PredTable,
- Queue1, Queue, Needed1, Needed).
+ ProcIds = pred_info_exported_procids(PredInfo),
+ dead_proc_elim__initialize_procs(PredId, ProcIds, !Queue, !Needed),
+ dead_proc_elim__initialize_preds(PredIds, PredTable, !Queue, !Needed).
% Add the listed procedures to the queue and map.
@@ -388,22 +386,21 @@
entity_queue, entity_queue, needed_map, needed_map).
:- mode dead_proc_elim__examine_proc(in, in, in, out, in, out) is det.
-dead_proc_elim__examine_proc(proc(PredId, ProcId), ModuleInfo, Queue0, Queue,
- Needed0, Needed) :-
+dead_proc_elim__examine_proc(proc(PredId, ProcId), ModuleInfo,
+ !Queue, !Needed) :-
(
module_info_preds(ModuleInfo, PredTable),
map__lookup(PredTable, PredId, PredInfo),
- pred_info_non_imported_procids(PredInfo, ProcIds),
+ ProcIds = pred_info_non_imported_procids(PredInfo),
list__member(ProcId, ProcIds),
pred_info_procedures(PredInfo, ProcTable),
map__lookup(ProcTable, ProcId, ProcInfo)
->
proc_info_goal(ProcInfo, Goal),
dead_proc_elim__examine_goal(Goal, proc(PredId, ProcId),
- Queue0, Queue, Needed0, Needed)
+ !Queue, !Needed)
;
- Queue = Queue0,
- Needed = Needed0
+ true
).
:- pred dead_proc_elim__examine_goals(list(hlds_goal), pred_proc_id,
@@ -608,7 +605,7 @@
% containing procedure if appropriate.
% Likewise, don't warn for procedures
% introduced for type specialization.
- pred_info_name(PredInfo0, PredName),
+ PredName = pred_info_name(PredInfo0),
( string__prefix(PredName, "IntroducedFrom__")
; string__prefix(PredName, "TypeSpecOf__")
)
@@ -626,13 +623,13 @@
WarnForThisProc = no
)
->
- pred_info_procids(PredInfo0, ProcIds),
+ ProcIds = pred_info_procids(PredInfo0),
pred_info_procedures(PredInfo0, ProcTable0),
list__foldl2(dead_proc_elim__eliminate_proc(Pass, PredId,
Keep, WarnForThisProc, ElimInfo0),
ProcIds, Changed0 - ProcTable0, Changed - ProcTable,
State0, State),
- pred_info_set_procedures(PredInfo0, ProcTable, PredInfo),
+ pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
map__det_update(PredTable0, PredId, PredInfo, PredTable)
;
% Don't generate code in the current module for
@@ -645,7 +642,7 @@
Status = opt_imported
->
Changed = yes,
- pred_info_procids(PredInfo0, ProcIds),
+ ProcIds = pred_info_procids(PredInfo0),
pred_info_procedures(PredInfo0, ProcTable0),
% Reduce memory usage by replacing the goals with
% conj([]).
@@ -655,13 +652,13 @@
map__lookup(ProcTable0, Id, ProcInfo0),
goal_info_init(GoalInfo),
Goal = conj([]) - GoalInfo,
- proc_info_set_goal(ProcInfo0, Goal, ProcInfo),
+ proc_info_set_goal(Goal, ProcInfo0, ProcInfo),
map__det_update(PTable0, Id, ProcInfo, PTable)
)),
list__foldl(DestroyGoal, ProcIds, ProcTable0, ProcTable),
- pred_info_set_procedures(PredInfo0, ProcTable, PredInfo1),
- pred_info_set_import_status(PredInfo1, imported(interface),
- PredInfo),
+ pred_info_set_procedures(ProcTable, PredInfo0, PredInfo1),
+ pred_info_set_import_status(imported(interface),
+ PredInfo1, PredInfo),
map__det_update(PredTable0, PredId, PredInfo, PredTable),
globals__io_lookup_bool_option(very_verbose, VeryVerbose,
State0, State1),
@@ -850,9 +847,9 @@
DeadInfo0 = dead_pred_info(ModuleInfo, Q0, Ex, Needed, NeededNames0),
module_info_pred_info(ModuleInfo, PredId, PredInfo),
(
- pred_info_module(PredInfo, PredModule),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, PredArity),
+ PredModule = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
+ PredArity = pred_info_arity(PredInfo),
(
% Don't eliminate special preds since they won't
% be actually called from the HLDS until after
Index: compiler/deep_profiling.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/deep_profiling.m,v
retrieving revision 1.19
diff -u -b -r1.19 deep_profiling.m
--- compiler/deep_profiling.m 29 May 2003 18:17:14 -0000 1.19
+++ compiler/deep_profiling.m 21 Oct 2003 12:36:48 -0000
@@ -122,7 +122,7 @@
Goal, no, FoundTailCall, _),
FoundTailCall = yes
->
- proc_info_set_goal(ProcInfo0, Goal, ProcInfo1),
+ proc_info_set_goal(Goal, ProcInfo0, ProcInfo1),
figure_out_rec_call_numbers(Goal, 0, _N, [], TailCallSites),
OrigDeepProfileInfo = deep_profile_proc_info(
outer_proc(ClonePredProcId),
@@ -132,14 +132,14 @@
inner_proc(PredProcId),
[visible_scc_data(PredProcId, ClonePredProcId,
TailCallSites)]),
- proc_info_set_maybe_deep_profile_info(ProcInfo1,
- yes(OrigDeepProfileInfo), ProcInfo),
- proc_info_set_maybe_deep_profile_info(ProcInfo1,
- yes(CloneDeepProfileInfo), CloneProcInfo),
+ proc_info_set_maybe_deep_profile_info(
+ yes(OrigDeepProfileInfo), ProcInfo1, ProcInfo),
+ proc_info_set_maybe_deep_profile_info(
+ yes(CloneDeepProfileInfo), ProcInfo1, CloneProcInfo),
map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable1),
map__det_insert(ProcTable1, CloneProcId, CloneProcInfo,
ProcTable),
- pred_info_set_procedures(PredInfo0, ProcTable, PredInfo),
+ pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
map__det_update(PredTable0, PredId, PredInfo, PredTable),
module_info_set_preds(ModuleInfo0, PredTable, ModuleInfo)
;
@@ -463,11 +463,11 @@
transform_predicate(ModuleInfo, PredId, PredMap0, PredMap,
ProcStatics0, ProcStatics) :-
map__lookup(PredMap0, PredId, PredInfo0),
- pred_info_non_imported_procids(PredInfo0, ProcIds),
+ ProcIds = pred_info_non_imported_procids(PredInfo0),
pred_info_procedures(PredInfo0, ProcTable0),
list__foldl2(maybe_transform_procedure(ModuleInfo, PredId),
ProcIds, ProcTable0, ProcTable, ProcStatics0, ProcStatics),
- pred_info_set_procedures(PredInfo0, ProcTable, PredInfo),
+ pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
map__det_update(PredMap0, PredId, PredInfo, PredMap).
:- pred maybe_transform_procedure(module_info::in, pred_id::in, proc_id::in,
@@ -556,11 +556,11 @@
:- pred transform_det_proc(module_info::in, pred_proc_id::in,
proc_info::in, proc_info::out, maybe(layout_data)::out) is det.
-transform_det_proc(ModuleInfo, PredProcId, Proc0, Proc, yes(ProcStatic)) :-
- proc_info_goal(Proc0, Goal0),
+transform_det_proc(ModuleInfo, PredProcId, !Proc, yes(ProcStatic)) :-
+ proc_info_goal(!.Proc, Goal0),
Goal0 = _ - GoalInfo0,
- proc_info_varset(Proc0, Vars0),
- proc_info_vartypes(Proc0, VarTypes0),
+ proc_info_varset(!.Proc, Vars0),
+ proc_info_vartypes(!.Proc, VarTypes0),
CPointerType = c_pointer_type,
varset__new_named_var(Vars0, "TopCSD", TopCSD, Vars1),
map__set(VarTypes0, TopCSD, CPointerType, VarTypes1),
@@ -583,11 +583,11 @@
VarTypes5 = VarTypes3,
MaybeActivationPtr = no
),
- proc_info_context(Proc0, Context),
+ proc_info_context(!.Proc, Context),
FileName = term__context_file(Context),
LineNumber = term__context_line(Context),
- proc_info_get_maybe_deep_profile_info(Proc0, MaybeRecInfo),
+ proc_info_get_maybe_deep_profile_info(!.Proc, MaybeRecInfo),
DeepInfo0 = deep_info(ModuleInfo, PredProcId, MiddleCSD,
counter__init(0), [], Vars5, VarTypes5,
FileName, MaybeRecInfo),
@@ -637,18 +637,18 @@
TransformedGoal,
ExitPortCode
]) - GoalInfo,
- proc_info_set_varset(Proc0, Vars, Proc1),
- proc_info_set_vartypes(Proc1, VarTypes, Proc2),
- proc_info_set_goal(Proc2, Goal, Proc).
+ proc_info_set_varset(Vars, !Proc),
+ proc_info_set_vartypes(VarTypes, !Proc),
+ proc_info_set_goal(Goal, !Proc).
:- pred transform_semi_proc(module_info::in, pred_proc_id::in,
proc_info::in, proc_info::out, maybe(layout_data)::out) is det.
-transform_semi_proc(ModuleInfo, PredProcId, Proc0, Proc, yes(ProcStatic)) :-
- proc_info_goal(Proc0, Goal0),
+transform_semi_proc(ModuleInfo, PredProcId, !Proc, yes(ProcStatic)) :-
+ proc_info_goal(!.Proc, Goal0),
Goal0 = _ - GoalInfo0,
- proc_info_varset(Proc0, Vars0),
- proc_info_vartypes(Proc0, VarTypes0),
+ proc_info_varset(!.Proc, Vars0),
+ proc_info_vartypes(!.Proc, VarTypes0),
CPointerType = c_pointer_type,
varset__new_named_var(Vars0, "TopCSD", TopCSD, Vars1),
map__set(VarTypes0, TopCSD, CPointerType, VarTypes1),
@@ -671,11 +671,11 @@
VarTypes5 = VarTypes3,
MaybeActivationPtr = no
),
- proc_info_context(Proc0, Context),
+ proc_info_context(!.Proc, Context),
FileName = term__context_file(Context),
LineNumber = term__context_line(Context),
- proc_info_get_maybe_deep_profile_info(Proc0, MaybeRecInfo),
+ proc_info_get_maybe_deep_profile_info(!.Proc, MaybeRecInfo),
DeepInfo0 = deep_info(ModuleInfo, PredProcId, MiddleCSD,
counter__init(0), [], Vars5, VarTypes5,
FileName, MaybeRecInfo),
@@ -740,18 +740,18 @@
FailPortCode
]) - ExitConjGoalInfo
]) - GoalInfo,
- proc_info_set_varset(Proc0, Vars, Proc1),
- proc_info_set_vartypes(Proc1, VarTypes, Proc2),
- proc_info_set_goal(Proc2, Goal, Proc).
+ proc_info_set_varset(Vars, !Proc),
+ proc_info_set_vartypes(VarTypes, !Proc),
+ proc_info_set_goal(Goal, !Proc).
:- pred transform_non_proc(module_info::in, pred_proc_id::in,
proc_info::in, proc_info::out, maybe(layout_data)::out) is det.
-transform_non_proc(ModuleInfo, PredProcId, Proc0, Proc, yes(ProcStatic)) :-
- proc_info_goal(Proc0, Goal0),
+transform_non_proc(ModuleInfo, PredProcId, !Proc, yes(ProcStatic)) :-
+ proc_info_goal(!.Proc, Goal0),
Goal0 = _ - GoalInfo0,
- proc_info_varset(Proc0, Vars0),
- proc_info_vartypes(Proc0, VarTypes0),
+ proc_info_varset(!.Proc, Vars0),
+ proc_info_vartypes(!.Proc, VarTypes0),
CPointerType = c_pointer_type,
varset__new_named_var(Vars0, "TopCSD", TopCSD, Vars1),
map__set(VarTypes0, TopCSD, CPointerType, VarTypes1),
@@ -781,11 +781,11 @@
VarTypes5),
MaybeOldActivationPtr = no
),
- proc_info_context(Proc0, Context),
+ proc_info_context(!.Proc, Context),
FileName = term__context_file(Context),
LineNumber = term__context_line(Context),
- proc_info_get_maybe_deep_profile_info(Proc0, MaybeRecInfo),
+ proc_info_get_maybe_deep_profile_info(!.Proc, MaybeRecInfo),
DeepInfo0 = deep_info(ModuleInfo, PredProcId, MiddleCSD,
counter__init(0), [], Vars5, VarTypes5,
FileName, MaybeRecInfo),
@@ -878,18 +878,18 @@
FailPortCode
]) - CallExitRedoGoalInfo
]) - GoalInfo,
- proc_info_set_varset(Proc0, Vars, Proc1),
- proc_info_set_vartypes(Proc1, VarTypes, Proc2),
- proc_info_set_goal(Proc2, Goal, Proc).
+ proc_info_set_varset(Vars, !Proc),
+ proc_info_set_vartypes(VarTypes, !Proc),
+ proc_info_set_goal(Goal, !Proc).
:- pred transform_inner_proc(module_info::in, pred_proc_id::in,
proc_info::in, proc_info::out, maybe(layout_data)::out) is det.
-transform_inner_proc(ModuleInfo, PredProcId, Proc0, Proc, no) :-
- proc_info_goal(Proc0, Goal0),
+transform_inner_proc(ModuleInfo, PredProcId, !Proc, no) :-
+ proc_info_goal(!.Proc, Goal0),
Goal0 = _ - GoalInfo0,
- proc_info_varset(Proc0, Vars0),
- proc_info_vartypes(Proc0, VarTypes0),
+ proc_info_varset(!.Proc, Vars0),
+ proc_info_vartypes(!.Proc, VarTypes0),
CPointerType = c_pointer_type,
% MiddleCSD should be unused
varset__new_named_var(Vars0, "MiddleCSD", MiddleCSD, Vars1),
@@ -898,7 +898,7 @@
goal_info_get_context(GoalInfo0, Context),
FileName = term__context_file(Context),
- proc_info_get_maybe_deep_profile_info(Proc0, MaybeRecInfo),
+ proc_info_get_maybe_deep_profile_info(!.Proc, MaybeRecInfo),
DeepInfo0 = deep_info(ModuleInfo, PredProcId, MiddleCSD,
counter__init(0), [], Vars1, VarTypes1,
FileName, MaybeRecInfo),
@@ -908,9 +908,9 @@
Vars = DeepInfo ^ vars,
VarTypes = DeepInfo ^ var_types,
- proc_info_set_varset(Proc0, Vars, Proc1),
- proc_info_set_vartypes(Proc1, VarTypes, Proc2),
- proc_info_set_goal(Proc2, TransformedGoal, Proc).
+ proc_info_set_varset(Vars, !Proc),
+ proc_info_set_vartypes(VarTypes, !Proc),
+ proc_info_set_goal(TransformedGoal, !Proc).
%-----------------------------------------------------------------------------%
@@ -1720,19 +1720,22 @@
PredIds = [PredId],
predicate_table_get_preds(PredTable, Preds),
lookup(Preds, PredId, PredInfo),
- pred_info_procids(PredInfo, ProcIds),
+ ProcIds = pred_info_procids(PredInfo),
(
ProcIds = [],
- error("get_deep_profile_builtin_ppid: no proc_id")
+ error("get_deep_profile_builtin_ppid: " ++
+ "no proc_id")
;
ProcIds = [ProcId]
;
ProcIds = [_, _ | _],
- error("get_deep_profile_builtin_ppid: proc_id not unique")
+ error("get_deep_profile_builtin_ppid: " ++
+ "proc_id not unique")
)
;
PredIds = [_, _ | _],
- error("get_deep_profile_builtin_ppid: pred_id not unique")
+ error("get_deep_profile_builtin_ppid: " ++
+ "pred_id not unique")
)
;
format("couldn't find pred_id for `%s'/%d",
Index: compiler/deforest.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/deforest.m,v
retrieving revision 1.30
diff -u -b -r1.30 deforest.m
--- compiler/deforest.m 26 May 2003 08:59:52 -0000 1.30
+++ compiler/deforest.m 21 Oct 2003 12:38:47 -0000
@@ -144,19 +144,19 @@
:- pred reset_inferred_proc_determinism(pred_proc_id::in,
module_info::in, module_info::out) is det.
-reset_inferred_proc_determinism(PredProcId, ModuleInfo0, ModuleInfo) :-
- module_info_pred_proc_info(ModuleInfo0, PredProcId,
+reset_inferred_proc_determinism(PredProcId, !ModuleInfo) :-
+ module_info_pred_proc_info(!.ModuleInfo, PredProcId,
PredInfo, ProcInfo0),
proc_info_inferred_determinism(ProcInfo0, Detism0),
( determinism_components(Detism0, _, at_most_many_cc) ->
% `cc_multi' or `cc_nondet' determinisms are never inferred,
% so resetting the determinism would cause determinism errors.
- ModuleInfo = ModuleInfo0
+ true
;
- proc_info_set_inferred_determinism(ProcInfo0, erroneous,
- ProcInfo),
- module_info_set_pred_proc_info(ModuleInfo0, PredProcId,
- PredInfo, ProcInfo, ModuleInfo)
+ proc_info_set_inferred_determinism(erroneous,
+ ProcInfo0, ProcInfo),
+ module_info_set_pred_proc_info(!.ModuleInfo, PredProcId,
+ PredInfo, ProcInfo, !:ModuleInfo)
).
:- pred proc_arg_info_init(map(pred_proc_id, pd_proc_arg_info)::out) is det.
@@ -212,7 +212,7 @@
deforest__goal(Goal2, Goal3),
pd_info_get_proc_info(ProcInfo1),
- { proc_info_set_goal(ProcInfo1, Goal3, ProcInfo2) },
+ { proc_info_set_goal(Goal3, ProcInfo1, ProcInfo2) },
pd_info_get_changed(Changed),
( { Changed = yes } ->
@@ -228,7 +228,7 @@
pd_info_set_module_info(ModuleInfo3),
pd_info_get_pred_info(PredInfo),
- { proc_info_set_goal(ProcInfo3, Goal, ProcInfo) },
+ { proc_info_set_goal(Goal, ProcInfo3, ProcInfo) },
{ module_info_set_pred_proc_info(ModuleInfo3, PredId, ProcId,
PredInfo, ProcInfo, ModuleInfo4) },
@@ -1207,15 +1207,15 @@
% Rename the argument types using the current pred's tvarset.
{ varset__merge_subst(TVarSet0, CalledTVarSet,
TVarSet, TypeRenaming) },
- { pred_info_set_typevarset(PredInfo0, TVarSet, PredInfo) },
+ { pred_info_set_typevarset(TVarSet, PredInfo0, PredInfo) },
pd_info_set_pred_info(PredInfo),
{ term__apply_substitution_to_list(ArgTypes0,
TypeRenaming, ArgTypes1) },
{ deforest__create_deforest_call_args(OldArgs, ArgTypes1, Renaming,
TypeSubn, Args, VarSet0, VarSet, VarTypes0, VarTypes) },
- { proc_info_set_vartypes(ProcInfo0, VarTypes, ProcInfo1) },
- { proc_info_set_varset(ProcInfo1, VarSet, ProcInfo) },
+ { proc_info_set_vartypes(VarTypes, ProcInfo0, ProcInfo1) },
+ { proc_info_set_varset(VarSet, ProcInfo1, ProcInfo) },
pd_info_set_proc_info(ProcInfo),
% Compute a goal_info.
@@ -1227,8 +1227,8 @@
{ pred_info_get_purity(CalledPredInfo, Purity) },
{ goal_info_init(NonLocals, InstMapDelta, Detism, Purity, GoalInfo) },
- { pred_info_module(CalledPredInfo, PredModule) },
- { pred_info_name(CalledPredInfo, PredName) },
+ { PredModule = pred_info_module(CalledPredInfo) },
+ { PredName = pred_info_name(CalledPredInfo) },
{ Goal = call(PredId, ProcId, Args, not_builtin, no,
qualified(PredModule, PredName)) - GoalInfo }.
@@ -1877,11 +1877,11 @@
CalledProcInfo, VarSet0, VarSet, VarTypes0, VarTypes,
TypeVarSet0, TypeVarSet, TypeInfoVarMap0,
TypeInfoVarMap, Goal1) },
- { pred_info_set_typevarset(PredInfo0, TypeVarSet, PredInfo) },
- { proc_info_set_varset(ProcInfo0, VarSet, ProcInfo1) },
- { proc_info_set_vartypes(ProcInfo1, VarTypes, ProcInfo2) },
- { proc_info_set_typeinfo_varmap(ProcInfo2,
- TypeInfoVarMap, ProcInfo) },
+ { pred_info_set_typevarset(TypeVarSet, PredInfo0, PredInfo) },
+ { proc_info_set_varset(VarSet, ProcInfo0, ProcInfo1) },
+ { proc_info_set_vartypes(VarTypes, ProcInfo1, ProcInfo2) },
+ { proc_info_set_typeinfo_varmap(TypeInfoVarMap,
+ ProcInfo2, ProcInfo) },
pd_info_set_pred_info(PredInfo),
pd_info_set_proc_info(ProcInfo),
Index: compiler/delay_construct.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/delay_construct.m,v
retrieving revision 1.4
diff -u -b -r1.4 delay_construct.m
--- compiler/delay_construct.m 15 Mar 2003 03:08:44 -0000 1.4
+++ compiler/delay_construct.m 21 Oct 2003 14:53:23 -0000
@@ -50,29 +50,28 @@
%-----------------------------------------------------------------------------%
-delay_construct_proc(PredId, ProcId, ModuleInfo, ProcInfo0, ProcInfo) -->
+delay_construct_proc(PredId, ProcId, ModuleInfo, !ProcInfo, !IO) :-
write_proc_progress_message("% Delaying construction unifications in ",
- PredId, ProcId, ModuleInfo),
- globals__io_get_globals(Globals),
- { module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { delay_construct_proc_no_io(ProcInfo0, PredInfo, ModuleInfo, Globals,
- ProcInfo) }.
+ PredId, ProcId, ModuleInfo, !IO),
+ globals__io_get_globals(Globals, !IO),
+ module_info_pred_info(ModuleInfo, PredId, PredInfo),
+ delay_construct_proc_no_io(PredInfo, ModuleInfo, Globals,
+ !ProcInfo).
-:- pred delay_construct_proc_no_io(proc_info::in, pred_info::in,
- module_info::in, globals::in, proc_info::out) is det.
+:- pred delay_construct_proc_no_io(pred_info::in, module_info::in, globals::in,
+ proc_info::in, proc_info::out) is det.
-delay_construct_proc_no_io(ProcInfo0, PredInfo, ModuleInfo, Globals, ProcInfo)
- :-
+delay_construct_proc_no_io(PredInfo, ModuleInfo, Globals, !ProcInfo) :-
body_should_use_typeinfo_liveness(PredInfo, Globals,
BodyTypeinfoLiveness),
- proc_info_vartypes(ProcInfo0, VarTypes),
- proc_info_typeinfo_varmap(ProcInfo0, TypeInfoVarMap),
- proc_info_get_initial_instmap(ProcInfo0, ModuleInfo, InstMap0),
+ proc_info_vartypes(!.ProcInfo, VarTypes),
+ proc_info_typeinfo_varmap(!.ProcInfo, TypeInfoVarMap),
+ proc_info_get_initial_instmap(!.ProcInfo, ModuleInfo, InstMap0),
DelayInfo = delay_construct_info(ModuleInfo, BodyTypeinfoLiveness,
VarTypes, TypeInfoVarMap),
- proc_info_goal(ProcInfo0, Goal0),
+ proc_info_goal(!.ProcInfo, Goal0),
delay_construct_in_goal(Goal0, InstMap0, DelayInfo, Goal),
- proc_info_set_goal(ProcInfo0, Goal, ProcInfo).
+ proc_info_set_goal(Goal, !ProcInfo).
:- type delay_construct_info
---> delay_construct_info(
Index: compiler/dependency_graph.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/dependency_graph.m,v
retrieving revision 1.63
diff -u -b -r1.63 dependency_graph.m
--- compiler/dependency_graph.m 24 Jun 2003 14:20:47 -0000 1.63
+++ compiler/dependency_graph.m 21 Oct 2003 12:41:28 -0000
@@ -215,12 +215,11 @@
% which are imported (i.e. which we don't have any
% `clauses' for).
Imported = no,
- pred_info_non_imported_procids(PredInfo, ProcIds)
+ ProcIds = pred_info_non_imported_procids(PredInfo)
;
Imported = yes,
- pred_info_procids(PredInfo, ProcIds)
+ ProcIds = pred_info_procids(PredInfo)
),
-
dependency_graph__add_proc_nodes(ProcIds, PredId, ModuleInfo,
!DepGraph),
dependency_graph__add_pred_proc_nodes(PredIds, ModuleInfo, Imported,
@@ -230,7 +229,7 @@
dependency_graph, dependency_graph).
:- mode dependency_graph__add_proc_nodes(in, in, in, in, out) is det.
-dependency_graph__add_proc_nodes([], _PredId, _ModuleInfo, DepGraph, DepGraph).
+dependency_graph__add_proc_nodes([], _PredId, _ModuleInfo, !DepGraph).
dependency_graph__add_proc_nodes([ProcId | ProcIds], PredId, ModuleInfo,
!DepGraph) :-
relation__add_element(!.DepGraph, proc(PredId, ProcId), _, !:DepGraph),
@@ -268,7 +267,7 @@
dependency_graph, dependency_graph).
:- mode dependency_graph__add_pred_proc_arcs(in, in, in, in, out) is det.
-dependency_graph__add_pred_proc_arcs([], _ModuleInfo, _, DepGraph, DepGraph).
+dependency_graph__add_pred_proc_arcs([], _ModuleInfo, _, !DepGraph).
dependency_graph__add_pred_proc_arcs([PredId | PredIds], ModuleInfo, Imported,
!DepGraph) :-
module_info_preds(ModuleInfo, PredTable),
@@ -278,10 +277,10 @@
% which are imported (i.e. which we don't have any
% `clauses' for).
Imported = no,
- pred_info_non_imported_procids(PredInfo, ProcIds)
+ ProcIds = pred_info_non_imported_procids(PredInfo)
;
Imported = yes,
- pred_info_procids(PredInfo, ProcIds)
+ ProcIds = pred_info_procids(PredInfo)
),
dependency_graph__add_proc_arcs(ProcIds, PredId, ModuleInfo, Imported,
!DepGraph),
@@ -549,7 +548,7 @@
!IO) :-
module_info_pred_proc_info(ModuleInfo, PredId, ProcId,
PredInfo, ProcInfo),
- pred_info_name(PredInfo, Name),
+ Name = pred_info_name(PredInfo),
proc_info_declared_determinism(ProcInfo, Det),
proc_info_argmodes(ProcInfo, Modes),
proc_info_context(ProcInfo, Context),
@@ -614,11 +613,11 @@
PPredInfo, PProcInfo),
module_info_pred_proc_info(ModuleInfo, CPredId, CProcId,
CPredInfo, CProcInfo),
- pred_info_name(PPredInfo, PName),
+ PName = pred_info_name(PPredInfo),
proc_info_declared_determinism(PProcInfo, PDet),
proc_info_argmodes(PProcInfo, PModes),
proc_info_context(PProcInfo, PContext),
- pred_info_name(CPredInfo, CName),
+ CName = pred_info_name(CPredInfo),
proc_info_declared_determinism(CProcInfo, CDet),
proc_info_argmodes(CProcInfo, CModes),
proc_info_context(CProcInfo, CContext),
Index: compiler/det_analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/det_analysis.m,v
retrieving revision 1.161
diff -u -b -r1.161 det_analysis.m
--- compiler/det_analysis.m 29 May 2003 09:19:43 -0000 1.161
+++ compiler/det_analysis.m 21 Oct 2003 14:40:26 -0000
@@ -306,12 +306,12 @@
Detism = eval_method_change_determinism(EvalMethod, Detism2),
% Save the newly inferred information
- proc_info_set_goal(Proc0, Goal, Proc1),
- proc_info_set_inferred_determinism(Proc1, Detism, Proc),
+ proc_info_set_goal(Goal, Proc0, Proc1),
+ proc_info_set_inferred_determinism(Detism, Proc1, Proc),
% Put back the new proc_info structure.
map__det_update(Procs0, ProcId, Proc, Procs),
- pred_info_set_procedures(Pred0, Procs, Pred),
+ pred_info_set_procedures(Procs, Pred0, Pred),
map__det_update(Preds0, PredId, Pred, Preds),
module_info_set_preds(ModuleInfo0, Preds, ModuleInfo).
@@ -1234,7 +1234,7 @@
get_all_pred_procs_2(_Preds, [], PredProcs, PredProcs).
get_all_pred_procs_2(Preds, [PredId|PredIds], PredProcs0, PredProcs) :-
map__lookup(Preds, PredId, Pred),
- pred_info_procids(Pred, ProcIds),
+ ProcIds = pred_info_procids(Pred),
fold_pred_modes(PredId, ProcIds, PredProcs0, PredProcs1),
get_all_pred_procs_2(Preds, PredIds, PredProcs1, PredProcs).
@@ -1264,12 +1264,10 @@
pred_proc_list, pred_proc_list).
:- mode segregate_procs_2(in, in, in, out, in, out, in, out) is det.
-segregate_procs_2(_ModuleInfo, [], DeclaredProcs, DeclaredProcs,
- UndeclaredProcs, UndeclaredProcs, NoInferProcs, NoInferProcs).
+segregate_procs_2(_ModuleInfo, [], !DeclaredProcs,
+ !UndeclaredProcs, !NoInferProcs).
segregate_procs_2(ModuleInfo, [proc(PredId, ProcId) | PredProcs],
- DeclaredProcs0, DeclaredProcs,
- UndeclaredProcs0, UndeclaredProcs,
- NoInferProcs0, NoInferProcs) :-
+ !DeclaredProcs, !UndeclaredProcs, !NoInferProcs) :-
module_info_preds(ModuleInfo, Preds),
map__lookup(Preds, PredId, Pred),
(
@@ -1283,29 +1281,23 @@
check_marker(Markers, class_method)
)
->
- UndeclaredProcs1 = UndeclaredProcs0,
- DeclaredProcs1 = DeclaredProcs0,
- NoInferProcs1 = [proc(PredId, ProcId) | NoInferProcs0]
+ !:NoInferProcs = [proc(PredId, ProcId) | !.NoInferProcs]
;
pred_info_procedures(Pred, Procs),
map__lookup(Procs, ProcId, Proc),
proc_info_declared_determinism(Proc, MaybeDetism),
(
MaybeDetism = no,
- UndeclaredProcs1 =
- [proc(PredId, ProcId) | UndeclaredProcs0],
- DeclaredProcs1 = DeclaredProcs0
+ !:UndeclaredProcs =
+ [proc(PredId, ProcId) | !.UndeclaredProcs]
;
MaybeDetism = yes(_),
- DeclaredProcs1 =
- [proc(PredId, ProcId) | DeclaredProcs0],
- UndeclaredProcs1 = UndeclaredProcs0
- ),
- NoInferProcs1 = NoInferProcs0
+ !:DeclaredProcs =
+ [proc(PredId, ProcId) | !.DeclaredProcs]
+ )
),
- segregate_procs_2(ModuleInfo, PredProcs, DeclaredProcs1, DeclaredProcs,
- UndeclaredProcs1, UndeclaredProcs,
- NoInferProcs1, NoInferProcs).
+ segregate_procs_2(ModuleInfo, PredProcs, !DeclaredProcs,
+ !UndeclaredProcs, !NoInferProcs).
% We can't infer a tighter determinism for imported procedures or
% for class methods, so set the inferred determinism to be the
@@ -1317,20 +1309,19 @@
module_info, module_info).
:- mode set_non_inferred_proc_determinism(in, in, out) is det.
-set_non_inferred_proc_determinism(proc(PredId, ProcId),
- ModuleInfo0, ModuleInfo) :-
- module_info_pred_info(ModuleInfo0, PredId, PredInfo0),
+set_non_inferred_proc_determinism(proc(PredId, ProcId), !ModuleInfo) :-
+ module_info_pred_info(!.ModuleInfo, PredId, PredInfo0),
pred_info_procedures(PredInfo0, Procs0),
map__lookup(Procs0, ProcId, ProcInfo0),
proc_info_declared_determinism(ProcInfo0, MaybeDet),
( MaybeDet = yes(Det) ->
- proc_info_set_inferred_determinism(ProcInfo0, Det, ProcInfo),
+ proc_info_set_inferred_determinism(Det, ProcInfo0, ProcInfo),
map__det_update(Procs0, ProcId, ProcInfo, Procs),
- pred_info_set_procedures(PredInfo0, Procs, PredInfo),
- module_info_set_pred_info(ModuleInfo0,
- PredId, PredInfo, ModuleInfo)
+ pred_info_set_procedures(Procs, PredInfo0, PredInfo),
+ module_info_set_pred_info(!.ModuleInfo,
+ PredId, PredInfo, !:ModuleInfo)
;
- ModuleInfo = ModuleInfo0
+ true
).
%-----------------------------------------------------------------------------%
Index: compiler/det_report.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/det_report.m,v
retrieving revision 1.82
diff -u -b -r1.82 det_report.m
--- compiler/det_report.m 25 Jul 2003 02:27:19 -0000 1.82
+++ compiler/det_report.m 21 Oct 2003 12:43:58 -0000
@@ -261,10 +261,10 @@
InferredDetism) = yes }
->
{
- proc_info_set_eval_method(ProcInfo0, EvalMethod, ProcInfo),
+ proc_info_set_eval_method(EvalMethod, ProcInfo0, ProcInfo),
pred_info_procedures(PredInfo0, ProcTable0),
map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable),
- pred_info_set_procedures(PredInfo0, ProcTable, PredInfo),
+ pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
module_info_set_pred_info(ModuleInfo1, PredId, PredInfo,
ModuleInfo)
}
@@ -334,8 +334,8 @@
%
{ proc_info_declared_determinism(ProcInfo, MaybeDetism) },
(
- { pred_info_name(PredInfo, "main") },
- { pred_info_arity(PredInfo, 2) },
+ { pred_info_name(PredInfo) = "main" },
+ { pred_info_arity(PredInfo) = 2 },
{ pred_info_is_exported(PredInfo) },
{ MaybeDetism = yes(DeclaredDetism) },
{ DeclaredDetism \= det, DeclaredDetism \= cc_multidet }
@@ -363,7 +363,7 @@
% function are not allowed.)
(
% if it is a mode for a function...
- { pred_info_get_is_pred_or_func(PredInfo, function) },
+ { pred_info_is_pred_or_func(PredInfo) = function },
% ... that can succeed more than once ...
{ determinism_components(InferredDetism, _CanFail, NumSolns) },
{ NumSolns \= at_most_zero },
@@ -379,7 +379,7 @@
}
->
% ... then it is an error.
- { pred_info_name(PredInfo, PredName) },
+ { PredName = pred_info_name(PredInfo) },
{ proc_info_context(ProcInfo, FuncContext) },
prog_out__write_context(FuncContext),
@@ -885,8 +885,8 @@
det_report_call_context(Context, CallUnifyContext, DetInfo, PredId, ModeId) -->
{ det_info_get_module_info(DetInfo, ModuleInfo) },
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_name(PredInfo, PredName) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { PredName = pred_info_name(PredInfo) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
{ pred_info_get_maybe_special_pred(PredInfo, MaybeSpecial) },
%
% if the error was in a call to a type-specific unification predicate
Index: compiler/dnf.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/dnf.m,v
retrieving revision 1.49
diff -u -b -r1.49 dnf.m
--- compiler/dnf.m 26 May 2003 08:59:53 -0000 1.49
+++ compiler/dnf.m 21 Oct 2003 12:44:16 -0000
@@ -119,7 +119,7 @@
NewPredIds) :-
module_info_preds(ModuleInfo0, PredTable0),
map__lookup(PredTable0, PredId, PredInfo0),
- pred_info_non_imported_procids(PredInfo0, ProcIds),
+ ProcIds = pred_info_non_imported_procids(PredInfo0),
dnf__transform_procs(ProcIds, PredId, MaybeNonAtomic,
ModuleInfo0, ModuleInfo, [], NewPredIds).
@@ -139,7 +139,7 @@
ModuleInfo0, ModuleInfo1, ProcInfo, NewPredIds0, NewPredIds1),
map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable),
- pred_info_set_procedures(PredInfo0, ProcTable, PredInfo),
+ pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
% We must look up the pred table again
% since dnf__transform_proc may have added new predicates
module_info_preds(ModuleInfo1, PredTable1),
@@ -151,7 +151,7 @@
dnf__transform_proc(ProcInfo0, PredInfo0, MaybeNonAtomic,
ModuleInfo0, ModuleInfo, ProcInfo, NewPredIds0, NewPredIds) :-
- pred_info_name(PredInfo0, PredName),
+ PredName = pred_info_name(PredInfo0),
pred_info_typevarset(PredInfo0, TVarSet),
pred_info_get_markers(PredInfo0, Markers),
pred_info_get_class_context(PredInfo0, ClassContext),
@@ -169,7 +169,7 @@
dnf__transform_goal(Goal0, InstMap, MaybeNonAtomic,
ModuleInfo0, ModuleInfo,
PredName, DnfInfo, Goal, NewPredIds0, NewPredIds),
- proc_info_set_goal(ProcInfo0, Goal, ProcInfo).
+ proc_info_set_goal(Goal, ProcInfo0, ProcInfo).
%-----------------------------------------------------------------------------%
Index: compiler/error_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/error_util.m,v
retrieving revision 1.23
diff -u -b -r1.23 error_util.m
--- compiler/error_util.m 25 Jun 2003 06:57:34 -0000 1.23
+++ compiler/error_util.m 21 Oct 2003 12:44:23 -0000
@@ -437,11 +437,11 @@
error_util__describe_one_pred_name(Module, PredId, Piece) :-
module_info_pred_info(Module, PredId, PredInfo),
- pred_info_module(PredInfo, ModuleName),
+ ModuleName = pred_info_module(PredInfo),
prog_out__sym_name_to_string(ModuleName, ModuleNameString),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, Arity),
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
+ PredName = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
PredOrFuncPart = pred_or_func_to_string(PredOrFunc),
adjust_func_arity(PredOrFunc, OrigArity, Arity),
(
Index: compiler/export.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/export.m,v
retrieving revision 1.69
diff -u -b -r1.69 export.m
--- compiler/export.m 3 Jul 2003 12:11:15 -0000 1.69
+++ compiler/export.m 21 Oct 2003 14:40:52 -0000
@@ -333,7 +333,7 @@
;
HowToDeclareLabel = "MR_declare_static"
),
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
pred_info_procedures(PredInfo, ProcTable),
map__lookup(ProcTable, ProcId, ProcInfo),
proc_info_maybe_arg_info(ProcInfo, MaybeArgInfos),
@@ -341,8 +341,8 @@
( MaybeArgInfos = yes(ArgInfos0) ->
ArgInfos = ArgInfos0
;
- generate_proc_arg_info(ProcInfo, ArgTypes,
- Module, NewProcInfo),
+ generate_proc_arg_info(ArgTypes, Module,
+ ProcInfo, NewProcInfo),
proc_info_arg_info(NewProcInfo, ArgInfos)
),
proc_info_interface_code_model(ProcInfo, CodeModel),
Index: compiler/fact_table.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/fact_table.m,v
retrieving revision 1.48
diff -u -b -r1.48 fact_table.m
--- compiler/fact_table.m 21 Jul 2003 05:33:17 -0000 1.48
+++ compiler/fact_table.m 21 Oct 2003 12:45:03 -0000
@@ -248,7 +248,7 @@
{ pred_info_procedures(PredInfo1, ProcTable0) },
infer_determinism_pass_2(ProcStreams, ProcFiles,
ExistsAllInMode, ProcTable0, ProcTable),
- { pred_info_set_procedures(PredInfo1, ProcTable, PredInfo) },
+ { pred_info_set_procedures(ProcTable, PredInfo1, PredInfo) },
io__make_temp(DataFileName),
write_fact_table_arrays(ProcFiles, DataFileName, StructName,
ProcTable, ModuleInfo, NumFacts, FactArgInfos,
@@ -265,7 +265,7 @@
% to type-check all the facts.
{ PredInfo = PredInfo0 },
{ C_HeaderCode = C_HeaderCode0 },
- { invalid_proc_id(PrimaryProcID) },
+ { PrimaryProcID = invalid_proc_id },
{ WriteDataAfterSorting = no },
{ DataFileName = "" }
),
@@ -285,7 +285,7 @@
io__set_exit_status(1),
{ PredInfo = PredInfo0 },
{ C_HeaderCode = "" },
- { invalid_proc_id(PrimaryProcID) }
+ { PrimaryProcID = invalid_proc_id }
)
;
{ Result0 = error(ErrorCode) },
@@ -302,7 +302,7 @@
io__set_exit_status(1),
{ PredInfo = PredInfo0 },
{ C_HeaderCode = "" },
- { invalid_proc_id(PrimaryProcID) }
+ { PrimaryProcID = invalid_proc_id }
).
%---------------------------------------------------------------------------%
@@ -377,7 +377,7 @@
check_fact_term(PredName, Arity0, PredInfo, ModuleInfo,
term__functor(Const, Terms0, Context), FactArgInfos, ProcStreams,
MaybeOutput, FactNum, Result) -->
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
{ unqualify_name(PredName, PredString) },
(
{ Const = term__atom(TopLevel) }
@@ -801,11 +801,11 @@
ExistsAllInMode, WriteHashTables, WriteDataTable,
FactArgInfos0, FactArgInfos, Result) -->
{ pred_info_procedures(PredInfo0, ProcTable0) },
- { pred_info_procids(PredInfo0, ProcIDs) },
+ { ProcIDs = pred_info_procids(PredInfo0) },
( { ProcIDs = [] } ->
% There are no declared modes so report an error.
- { pred_info_name(PredInfo0, PredString) },
- { pred_info_arity(PredInfo0, Arity) },
+ { PredString = pred_info_name(PredInfo0) },
+ { Arity = pred_info_arity(PredInfo0) },
prog_out__write_context(Context),
io__format("Error: no modes declared for fact table `%s/%d'.\n",
[s(PredString), i(Arity)]),
@@ -840,7 +840,7 @@
% need to get order right for CheckProcs because first procedure
% in list is used to derive the primary lookup key.
{ list__reverse(CheckProcs1, CheckProcs) },
- { pred_info_set_procedures(PredInfo0, ProcTable, PredInfo) },
+ { pred_info_set_procedures(ProcTable, PredInfo0, PredInfo) },
{ Result = ok }
).
@@ -926,8 +926,8 @@
{
InferredDetism = inferred(Determinism)
->
- proc_info_set_inferred_determinism(ProcInfo0, Determinism,
- ProcInfo),
+ proc_info_set_inferred_determinism(Determinism,
+ ProcInfo0, ProcInfo),
map__det_update(ProcTable0, ProcID, ProcInfo, ProcTable1)
;
ProcTable1 = ProcTable0
@@ -1216,8 +1216,8 @@
io__set_exit_status(1),
{ Determinism = erroneous }
),
- { proc_info_set_inferred_determinism(ProcInfo0, Determinism,
- ProcInfo)},
+ { proc_info_set_inferred_determinism(Determinism,
+ ProcInfo0, ProcInfo)},
{ map__det_update(ProcTable0, ProcID, ProcInfo, ProcTable1) },
infer_determinism_pass_2(ProcStreams, ProcFiles, ExistsAllInMode,
ProcTable1, ProcTable).
@@ -1240,7 +1240,7 @@
{ ProcFiles0 = [] },
{ C_HeaderCode = "" },
% This won't get used anyway.
- { hlds_pred__initial_proc_id(PrimaryProcID) }
+ { PrimaryProcID = hlds_pred__initial_proc_id }
;
{ ProcFiles0 = [(PrimaryProcID - FileName) | ProcFiles1] },
(
Index: compiler/follow_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/follow_code.m,v
retrieving revision 1.66
diff -u -b -r1.66 follow_code.m
--- compiler/follow_code.m 15 Mar 2003 03:08:45 -0000 1.66
+++ compiler/follow_code.m 21 Oct 2003 14:48:44 -0000
@@ -45,15 +45,15 @@
%-----------------------------------------------------------------------------%
-move_follow_code_in_proc(_PredId, _ProcId, _PredInfo, ProcInfo0, ProcInfo,
- ModuleInfo0, ModuleInfo) :-
- module_info_globals(ModuleInfo0, Globals),
+move_follow_code_in_proc(_PredId, _ProcId, _PredInfo, !ProcInfo,
+ !ModuleInfo) :-
+ module_info_globals(!.ModuleInfo, Globals),
globals__lookup_bool_option(Globals, follow_code, FollowCode),
globals__lookup_bool_option(Globals, prev_code, PrevCode),
Flags = FollowCode - PrevCode,
- proc_info_goal(ProcInfo0, Goal0),
- proc_info_varset(ProcInfo0, Varset0),
- proc_info_vartypes(ProcInfo0, VarTypes0),
+ proc_info_goal(!.ProcInfo, Goal0),
+ proc_info_varset(!.ProcInfo, Varset0),
+ proc_info_vartypes(!.ProcInfo, VarTypes0),
(
move_follow_code_in_goal(Goal0, Goal1, Flags, no, Res),
% did the goal change?
@@ -61,24 +61,22 @@
->
% we need to fix up the goal_info by recalculating
% the nonlocal vars and the non-atomic instmap deltas.
- proc_info_headvars(ProcInfo0, HeadVars),
- implicitly_quantify_clause_body(HeadVars,
- Goal1, Varset0, VarTypes0,
- Goal2, Varset, VarTypes, _Warnings),
- proc_info_get_initial_instmap(ProcInfo0,
- ModuleInfo0, InstMap0),
- proc_info_inst_varset(ProcInfo0, InstVarSet),
+ proc_info_headvars(!.ProcInfo, HeadVars),
+ implicitly_quantify_clause_body(HeadVars, _Warnings,
+ Goal1, Goal2, Varset0, Varset, VarTypes0, VarTypes),
+ proc_info_get_initial_instmap(!.ProcInfo,
+ !.ModuleInfo, InstMap0),
+ proc_info_inst_varset(!.ProcInfo, InstVarSet),
recompute_instmap_delta(no, Goal2, Goal, VarTypes, InstVarSet,
- InstMap0, ModuleInfo0, ModuleInfo)
+ InstMap0, !ModuleInfo)
;
Goal = Goal0,
Varset = Varset0,
- VarTypes = VarTypes0,
- ModuleInfo = ModuleInfo0
+ VarTypes = VarTypes0
),
- proc_info_set_goal(ProcInfo0, Goal, ProcInfo1),
- proc_info_set_varset(ProcInfo1, Varset, ProcInfo2),
- proc_info_set_vartypes(ProcInfo2, VarTypes, ProcInfo).
+ proc_info_set_goal(Goal, !ProcInfo),
+ proc_info_set_varset(Varset, !ProcInfo),
+ proc_info_set_vartypes(VarTypes, !ProcInfo).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
Index: compiler/foreign.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/foreign.m,v
retrieving revision 1.30
diff -u -b -r1.30 foreign.m
--- compiler/foreign.m 21 Aug 2003 07:01:12 -0000 1.30
+++ compiler/foreign.m 21 Oct 2003 09:30:46 -0000
@@ -463,7 +463,7 @@
%
% lookup some information we need from the pred_info and proc_info
%
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
pred_info_arg_types(PredInfo, ArgTypes),
proc_info_argmodes(ProcInfo, Modes),
proc_info_interface_code_model(ProcInfo, CodeModel),
Index: compiler/goal_path.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/goal_path.m,v
retrieving revision 1.18
diff -u -b -r1.18 goal_path.m
--- compiler/goal_path.m 15 Mar 2003 03:08:46 -0000 1.18
+++ compiler/goal_path.m 21 Oct 2003 12:46:22 -0000
@@ -16,7 +16,7 @@
:- import_module hlds__hlds_module.
:- import_module hlds__hlds_pred.
-:- pred goal_path__fill_slots(proc_info::in, module_info::in, proc_info::out)
+:- pred goal_path__fill_slots(module_info::in, proc_info::in, proc_info::out)
is det.
:- implementation.
@@ -34,13 +34,13 @@
module_info
).
-goal_path__fill_slots(Proc0, ModuleInfo, Proc) :-
+goal_path__fill_slots(ModuleInfo, !Proc) :-
% The ModuleInfo argument is there just for passes_aux
- proc_info_goal(Proc0, Goal0),
- proc_info_vartypes(Proc0, VarTypes),
+ proc_info_goal(!.Proc, Goal0),
+ proc_info_vartypes(!.Proc, VarTypes),
SlotInfo = slot_info(VarTypes, ModuleInfo),
fill_goal_slots(Goal0, [], SlotInfo, Goal),
- proc_info_set_goal(Proc0, Goal, Proc).
+ proc_info_set_goal(Goal, !Proc).
:- pred fill_goal_slots(hlds_goal::in, goal_path::in, slot_info::in,
hlds_goal::out) is det.
Index: compiler/goal_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/goal_util.m,v
retrieving revision 1.87
diff -u -b -r1.87 goal_util.m
--- compiler/goal_util.m 20 Oct 2003 07:29:05 -0000 1.87
+++ compiler/goal_util.m 21 Oct 2003 09:30:46 -0000
@@ -1239,8 +1239,8 @@
% builtin_state only uses this to work out whether
% this is the "recursive" clause generated for the compiler
% for each builtin, so an invalid pred_id won't cause problems.
- invalid_pred_id(InvalidPredId),
- builtin_state(Module, InvalidPredId, PredId, ProcId, BuiltinState),
+ InvalidPredId = invalid_pred_id,
+ BuiltinState = builtin_state(Module, InvalidPredId, PredId, ProcId),
Call = call(PredId, ProcId, Args, BuiltinState, no,
qualified(ModuleName, ProcName)),
Index: compiler/higher_order.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/higher_order.m,v
retrieving revision 1.111
diff -u -b -r1.111 higher_order.m
--- compiler/higher_order.m 20 Oct 2003 07:29:05 -0000 1.111
+++ compiler/higher_order.m 21 Oct 2003 15:11:06 -0000
@@ -341,24 +341,23 @@
:- pred get_specialization_requests(pred_id::in,
higher_order_global_info::in, higher_order_global_info::out) is det.
-get_specialization_requests(PredId, GlobalInfo0, GlobalInfo) :-
- module_info_pred_info(GlobalInfo0 ^ module_info, PredId, PredInfo0),
- pred_info_non_imported_procids(PredInfo0, NonImportedProcs),
+get_specialization_requests(PredId, !GlobalInfo) :-
+ module_info_pred_info(!.GlobalInfo ^ module_info, PredId, PredInfo0),
+ NonImportedProcs = pred_info_non_imported_procids(PredInfo0),
(
- NonImportedProcs = [],
- GlobalInfo = GlobalInfo0
+ NonImportedProcs = []
;
NonImportedProcs = [ProcId | _],
MustRecompute = no,
list__foldl(traverse_proc(MustRecompute, PredId),
- NonImportedProcs, GlobalInfo0, GlobalInfo1),
- module_info_pred_proc_info(GlobalInfo1 ^ module_info,
+ NonImportedProcs, !GlobalInfo),
+ module_info_pred_proc_info(!.GlobalInfo ^ module_info,
PredId, ProcId, _, ProcInfo),
proc_info_goal(ProcInfo, Goal),
goal_size(Goal, GoalSize),
- map__set(GlobalInfo1 ^ goal_sizes, PredId,
+ map__set(!.GlobalInfo ^ goal_sizes, PredId,
GoalSize, GoalSizes),
- GlobalInfo = GlobalInfo1 ^ goal_sizes := GoalSizes
+ !:GlobalInfo = !.GlobalInfo ^ goal_sizes := GoalSizes
).
% This is called when the first procedure of a pred was
@@ -406,11 +405,11 @@
:- pred fixup_proc_info(bool::in, hlds_goal::in,
higher_order_info::in, higher_order_info::out) is det.
-fixup_proc_info(MustRecompute, Goal0, Info0, Info) :-
- ( (Info0 ^ changed = changed ; MustRecompute = yes) ->
- ModuleInfo0 = Info0 ^ global_info ^ module_info,
- ProcInfo0 = Info0 ^ proc_info,
- proc_info_set_goal(ProcInfo0, Goal0, ProcInfo1),
+fixup_proc_info(MustRecompute, Goal0, !Info) :-
+ ( (!.Info ^ changed = changed ; MustRecompute = yes) ->
+ ModuleInfo0 = !.Info ^ global_info ^ module_info,
+ ProcInfo0 = !.Info ^ proc_info,
+ proc_info_set_goal(Goal0, ProcInfo0, ProcInfo1),
requantify_proc(ProcInfo1, ProcInfo2),
proc_info_goal(ProcInfo2, Goal2),
RecomputeAtomic = no,
@@ -418,12 +417,13 @@
proc_info_vartypes(ProcInfo2, VarTypes),
proc_info_inst_varset(ProcInfo2, InstVarSet),
recompute_instmap_delta(RecomputeAtomic, Goal2, Goal3,
- VarTypes, InstVarSet, InstMap, ModuleInfo0, ModuleInfo),
- proc_info_set_goal(ProcInfo2, Goal3, ProcInfo),
- Info = (Info0 ^ proc_info := ProcInfo)
+ VarTypes, InstVarSet, InstMap,
+ ModuleInfo0, ModuleInfo),
+ proc_info_set_goal(Goal3, ProcInfo2, ProcInfo),
+ !:Info = (!.Info ^ proc_info := ProcInfo)
^ global_info ^ module_info := ModuleInfo
;
- Info = Info0
+ true
).
% Traverses the goal collecting higher order variables for which
@@ -810,8 +810,8 @@
ClassArgs, PredId, ProcId, InstanceConstraints,
UnconstrainedTVarTypes, TVarSet0, TVarSet)
->
- pred_info_set_typevarset(CallerPredInfo0,
- TVarSet, CallerPredInfo),
+ pred_info_set_typevarset(TVarSet,
+ CallerPredInfo0, CallerPredInfo),
% Pull out the argument typeclass_infos.
( InstanceConstraints = [], UnconstrainedTVarTypes = [] ->
ExtraGoals = [],
@@ -955,17 +955,15 @@
list(T)::in, int::in, list(hlds_goal)::out,
list(prog_var)::out, proc_info::in, proc_info::out) is det.
-get_typeclass_info_args_2(_, _, _, _, _, [], _, [], [], ProcInfo, ProcInfo).
+get_typeclass_info_args_2(_, _, _, _, _, [], _, [], [], !ProcInfo).
get_typeclass_info_args_2(TypeClassInfoVar, PredId, ProcId, SymName,
MakeResultType, [Arg | Args], Index,
[IndexGoal, CallGoal | Goals],
- [ResultVar | Vars], ProcInfo0, ProcInfo) :-
+ [ResultVar | Vars], !ProcInfo) :-
MakeResultType(Arg, ResultType),
- proc_info_create_var_from_type(ProcInfo0, ResultType, no,
- ResultVar, ProcInfo1),
+ proc_info_create_var_from_type(ResultType, no, ResultVar, !ProcInfo),
MaybeContext = no,
- make_int_const_construction(Index, no, IndexGoal,
- IndexVar, ProcInfo1, ProcInfo2),
+ make_int_const_construction(Index, no, IndexGoal, IndexVar, !ProcInfo),
CallArgs = [TypeClassInfoVar, IndexVar, ResultVar],
set__list_to_set(CallArgs, NonLocals),
@@ -976,8 +974,7 @@
CallGoal = call(PredId, ProcId, CallArgs, not_builtin,
MaybeContext, SymName) - GoalInfo,
get_typeclass_info_args_2(TypeClassInfoVar, PredId, ProcId, SymName,
- MakeResultType, Args, Index + 1, Goals, Vars,
- ProcInfo2, ProcInfo).
+ MakeResultType, Args, Index + 1, Goals, Vars, !ProcInfo).
%-----------------------------------------------------------------------------%
@@ -985,20 +982,20 @@
list(prog_var)::in, hlds_goal_info::in, hlds_goal::out,
higher_order_info::in, higher_order_info::out) is det.
-construct_specialized_higher_order_call(PredId, ProcId,
- AllArgs, GoalInfo, Goal - GoalInfo, Info0, Info) :-
- ModuleInfo = Info0 ^ global_info ^ module_info,
+construct_specialized_higher_order_call(PredId, ProcId, AllArgs, GoalInfo,
+ Goal - GoalInfo, !Info) :-
+ ModuleInfo = !.Info ^ global_info ^ module_info,
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_module(PredInfo, ModuleName),
- pred_info_name(PredInfo, PredName),
+ ModuleName = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
SymName = qualified(ModuleName, PredName),
- proc(CallerPredId, _) = Info0 ^ pred_proc_id,
- builtin_state(ModuleInfo, CallerPredId, PredId, ProcId, Builtin),
+ proc(CallerPredId, _) = !.Info ^ pred_proc_id,
+ Builtin = builtin_state(ModuleInfo, CallerPredId, PredId, ProcId),
MaybeContext = no,
Goal1 = call(PredId, ProcId, AllArgs, Builtin, MaybeContext, SymName),
- Info1 = Info0 ^ changed := changed,
- maybe_specialize_call(Goal1 - GoalInfo, Goal - _, Info1, Info).
+ !:Info = !.Info ^ changed := changed,
+ maybe_specialize_call(Goal1 - GoalInfo, Goal - _, !Info).
:- pred maybe_specialize_call(hlds_goal::in, hlds_goal::out,
higher_order_info::in, higher_order_info::out) is det.
@@ -1095,8 +1092,8 @@
{ type_is_higher_order(LVarType, _, _, _, ArgTypes) }
->
% Create variables to represent
- { proc_info_create_vars_from_types(ProcInfo0,
- ArgTypes, UncurriedArgs, ProcInfo1) },
+ { proc_info_create_vars_from_types(ArgTypes, UncurriedArgs,
+ ProcInfo0, ProcInfo1) },
{ list__append(Args0, UncurriedArgs, Args1) },
^ proc_info := ProcInfo1,
@@ -1149,8 +1146,8 @@
{ proc_info_vartypes(ProcInfo2, VarTypes2) },
{ map__delete_list(VarTypes2,
UncurriedArgs, VarTypes) },
- { proc_info_set_vartypes(ProcInfo2,
- VarTypes, ProcInfo) },
+ { proc_info_set_vartypes(VarTypes,
+ ProcInfo2, ProcInfo) },
^ proc_info := ProcInfo,
{ NewConsId = pred_const(NewPredId, NewProcId,
@@ -1873,10 +1870,9 @@
PredVars = Info0 ^ pred_vars,
proc_info_vartypes(ProcInfo0, VarTypes),
module_info_pred_info(ModuleInfo, CalledPred, CalledPredInfo),
- mercury_public_builtin_module(PublicBuiltin),
- pred_info_module(CalledPredInfo, PublicBuiltin),
- pred_info_name(CalledPredInfo, PredName),
- pred_info_arity(CalledPredInfo, PredArity),
+ mercury_public_builtin_module = pred_info_module(CalledPredInfo),
+ PredName = pred_info_name(CalledPredInfo),
+ PredArity = pred_info_arity(CalledPredInfo),
special_pred_name_arity(SpecialId, PredName, PredArity),
special_pred_get_type(SpecialId, Args, Var),
map__lookup(VarTypes, Var, SpecialPredType),
@@ -2114,7 +2110,7 @@
SpecialId = compare,
unify_proc__add_lazily_generated_compare_pred_decl(TypeCtor,
PredId, ModuleInfo0, ModuleInfo),
- hlds_pred__initial_proc_id(ProcId)
+ ProcId = hlds_pred__initial_proc_id
;
SpecialId = index,
% This shouldn't happen. The index predicate should
@@ -2139,8 +2135,8 @@
hlds_pred__in_in_unification_proc_id(ProcId)
),
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_module(PredInfo, ModuleName),
- pred_info_name(PredInfo, Name),
+ ModuleName = pred_info_module(PredInfo),
+ Name = pred_info_name(PredInfo),
SymName = qualified(ModuleName, Name),
Info = Info0 ^ global_info ^ module_info := ModuleInfo
).
@@ -2216,10 +2212,8 @@
(type)::in, prog_var::in, prog_var::out, hlds_goal::out,
proc_info::in, proc_info::out) is det.
-generate_unsafe_type_cast(Context, ToType, Arg, CastArg, Goal,
- ProcInfo0, ProcInfo) :-
- proc_info_create_var_from_type(ProcInfo0, ToType, no,
- CastArg, ProcInfo),
+generate_unsafe_type_cast(Context, ToType, Arg, CastArg, Goal, !ProcInfo) :-
+ proc_info_create_var_from_type(ToType, no, CastArg, !ProcInfo),
set__list_to_set([Arg, CastArg], NonLocals),
instmap_delta_from_assoc_list([CastArg - ground_inst],
InstMapDelta),
@@ -2233,9 +2227,9 @@
proc_info::in, proc_info::out) is det.
unwrap_no_tag_arg(WrappedType, Context, Constructor, Arg, UnwrappedArg,
- Goal, ProcInfo0, ProcInfo) :-
- proc_info_create_var_from_type(ProcInfo0, WrappedType, no,
- UnwrappedArg, ProcInfo),
+ Goal, !ProcInfo) :-
+ proc_info_create_var_from_type(WrappedType, no, UnwrappedArg,
+ !ProcInfo),
ConsId = cons(Constructor, 1),
UniModes = [(ground(shared, none) - free) ->
(ground(shared, none) - ground(shared, none))],
@@ -2285,9 +2279,9 @@
{ CalledPredProcId = proc(CalledPredId, _) },
{ module_info_pred_info(ModuleInfo, CalledPredId, PredInfo) },
globals__io_lookup_bool_option(very_verbose, VeryVerbose),
- { pred_info_module(PredInfo, PredModule) },
- { pred_info_name(PredInfo, PredName) },
- { pred_info_arity(PredInfo, Arity) },
+ { PredModule = pred_info_module(PredInfo) },
+ { PredName = pred_info_name(PredInfo) },
+ { Arity = pred_info_arity(PredInfo) },
{ pred_info_arg_types(PredInfo, Types) },
{ list__length(Types, ActualArity) },
maybe_write_request(VeryVerbose, ModuleInfo, "Request for",
@@ -2441,20 +2435,19 @@
higher_order_global_info::in, higher_order_global_info::out,
io__state::di, io__state::uo) is det.
-create_new_pred(Request, NewPred, Info0, Info, IOState0, IOState) :-
+create_new_pred(Request, NewPred, !Info, !IO) :-
Request = request(Caller, CalledPredProc, CallArgs, ExtraTypeInfoTVars,
- HOArgs, ArgTypes, TypeInfoLiveness,
- CallerTVarSet, IsUserTypeSpec, Context),
- ModuleInfo0 = Info0 ^ module_info,
+ HOArgs, ArgTypes, TypeInfoLiveness, CallerTVarSet,
+ IsUserTypeSpec, Context),
+ ModuleInfo0 = !.Info ^ module_info,
module_info_pred_proc_info(ModuleInfo0, CalledPredProc,
PredInfo0, ProcInfo0),
- pred_info_name(PredInfo0, Name0),
- pred_info_arity(PredInfo0, Arity),
- pred_info_get_is_pred_or_func(PredInfo0, PredOrFunc),
- pred_info_module(PredInfo0, PredModule),
- globals__io_lookup_bool_option(very_verbose, VeryVerbose,
- IOState0, IOState1),
+ Name0 = pred_info_name(PredInfo0),
+ Arity = pred_info_arity(PredInfo0),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo0),
+ PredModule = pred_info_module(PredInfo0),
+ globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
pred_info_arg_types(PredInfo0, ArgTVarSet, ExistQVars, Types),
( IsUserTypeSpec = yes ->
@@ -2480,7 +2473,6 @@
[PredName0, "_", int_to_string(CallerProcInt), "_",
int_to_string(higher_order_arg_order_version)]),
SymName = qualified(PredModule, PredName),
- Info1 = Info0,
NewProcId = CallerProcId,
% For exported predicates the type specialization must
% be exported.
@@ -2488,9 +2480,9 @@
% version if we do some other useful specialization on it.
pred_info_import_status(PredInfo0, Status)
;
- hlds_pred__initial_proc_id(NewProcId),
- NextHOid = Info0 ^ next_higher_order_id,
- Info1 = Info0 ^ next_higher_order_id := NextHOid + 1,
+ NewProcId = hlds_pred__initial_proc_id,
+ NextHOid = !.Info ^ next_higher_order_id,
+ !:Info = !.Info ^ next_higher_order_id := NextHOid + 1,
string__int_to_string(NextHOid, IdStr),
string__append_list([Name0, "__ho", IdStr], PredName),
SymName = qualified(PredModule, PredName),
@@ -2500,7 +2492,7 @@
list__length(Types, ActualArity),
maybe_write_request(VeryVerbose, ModuleInfo0, "Specializing",
qualified(PredModule, Name0), Arity, ActualArity,
- yes(PredName), HOArgs, Context, IOState1, IOState),
+ yes(PredName), HOArgs, Context, !IO),
pred_info_typevarset(PredInfo0, TypeVarSet),
pred_info_get_markers(PredInfo0, MarkerList),
@@ -2522,25 +2514,24 @@
pred_info_init(PredModule, SymName, Arity, ArgTVarSet, ExistQVars,
Types, true, Context, ClausesInfo, Status, MarkerList, GoalType,
PredOrFunc, ClassContext, EmptyProofs, Owner, NewPredInfo0),
- pred_info_set_typevarset(NewPredInfo0, TypeVarSet, NewPredInfo1),
+ pred_info_set_typevarset(TypeVarSet, NewPredInfo0, NewPredInfo1),
module_info_get_predicate_table(ModuleInfo0, PredTable0),
predicate_table_insert(PredTable0, NewPredInfo1, NewPredId, PredTable),
module_info_set_predicate_table(ModuleInfo0, PredTable, ModuleInfo1),
- Info2 = Info1 ^ module_info := ModuleInfo1,
+ !:Info = !.Info ^ module_info := ModuleInfo1,
NewPred = new_pred(proc(NewPredId, NewProcId), CalledPredProc, Caller,
SymName, HOArgs, CallArgs, ExtraTypeInfoTVars, ArgTypes,
TypeInfoLiveness, CallerTVarSet, IsUserTypeSpec),
- add_new_pred(CalledPredProc, NewPred, Info2, Info3),
+ add_new_pred(CalledPredProc, NewPred, !Info),
- create_new_proc(NewPred, ProcInfo0,
- NewPredInfo1, NewPredInfo, Info3, Info4),
- module_info_set_pred_info(Info4 ^ module_info, NewPredId, NewPredInfo,
+ create_new_proc(NewPred, ProcInfo0, NewPredInfo1, NewPredInfo, !Info),
+ module_info_set_pred_info(!.Info ^ module_info, NewPredId, NewPredInfo,
ModuleInfo),
- Info = Info4 ^ module_info := ModuleInfo.
+ !:Info = !.Info ^ module_info := ModuleInfo.
:- pred add_new_pred(pred_proc_id::in, new_pred::in,
higher_order_global_info::in, higher_order_global_info::out) is det.
@@ -2595,8 +2586,8 @@
),
( { ConsId = pred_const(PredId, _ProcId, _) } ->
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_name(PredInfo, Name) },
- { pred_info_arity(PredInfo, Arity) },
+ { Name = pred_info_name(PredInfo) },
+ { Arity = pred_info_arity(PredInfo) },
% adjust message for type_infos
{ DeclaredArgNo = ArgNo - NumToDrop },
io__write_string("HeadVar__"),
@@ -2678,9 +2669,8 @@
pred_info::out, higher_order_global_info::in,
higher_order_global_info::out) is det.
-create_new_proc(NewPred, NewProcInfo0, NewPredInfo0,
- NewPredInfo, Info0, Info) :-
- ModuleInfo = Info0 ^ module_info,
+create_new_proc(NewPred, NewProcInfo0, !NewPredInfo, !Info) :-
+ ModuleInfo = !.Info ^ module_info,
NewPred = new_pred(NewPredProcId, OldPredProcId, CallerPredProcId,
_Name, HOArgs0, CallArgs, ExtraTypeInfoTVars0, CallerArgTypes0,
@@ -2688,9 +2678,9 @@
proc_info_headvars(NewProcInfo0, HeadVars0),
proc_info_argmodes(NewProcInfo0, ArgModes0),
- pred_info_get_exist_quant_tvars(NewPredInfo0, ExistQVars0),
- pred_info_typevarset(NewPredInfo0, TypeVarSet0),
- pred_info_arg_types(NewPredInfo0, OriginalArgTypes0),
+ pred_info_get_exist_quant_tvars(!.NewPredInfo, ExistQVars0),
+ pred_info_typevarset(!.NewPredInfo, TypeVarSet0),
+ pred_info_arg_types(!.NewPredInfo, OriginalArgTypes0),
CallerPredProcId = proc(CallerPredId, _),
module_info_pred_info(ModuleInfo, CallerPredId, CallerPredInfo),
@@ -2727,7 +2717,7 @@
apply_rec_substitution_to_type_map(VarTypes1, TypeSubn, VarTypes2),
term__apply_rec_substitution_to_list(OriginalArgTypes1, TypeSubn,
OriginalArgTypes),
- proc_info_set_vartypes(NewProcInfo0, VarTypes2, NewProcInfo1),
+ proc_info_set_vartypes(VarTypes2, NewProcInfo0, NewProcInfo1),
term__var_list_to_term_list(ExtraTypeInfoTVars0,
ExtraTypeInfoTVarTypes0),
@@ -2753,8 +2743,8 @@
% Add in the extra typeinfo vars.
list__map(polymorphism__build_type_info_type,
ExtraTypeInfoTVarTypes, ExtraTypeInfoTypes),
- proc_info_create_vars_from_types(NewProcInfo1, ExtraTypeInfoTypes,
- ExtraTypeInfoVars, NewProcInfo2),
+ proc_info_create_vars_from_types(ExtraTypeInfoTypes, ExtraTypeInfoVars,
+ NewProcInfo1, NewProcInfo2),
%
% Add any extra type-infos or typeclass-infos we've added
@@ -2775,8 +2765,8 @@
ExtraTypeInfoMap),
map__overlay(TypeInfoVarMap1, ExtraTypeInfoMap, TypeInfoVarMap),
- proc_info_set_typeinfo_varmap(NewProcInfo2,
- TypeInfoVarMap, NewProcInfo3),
+ proc_info_set_typeinfo_varmap(TypeInfoVarMap,
+ NewProcInfo2, NewProcInfo3),
map__from_corresponding_lists(CallArgs, HeadVars0, VarRenaming0),
@@ -2790,7 +2780,7 @@
%
% Record extra information about this version.
%
- VersionInfoMap0 = Info0 ^ version_info,
+ VersionInfoMap0 = !.Info ^ version_info,
ArgsDepth = higher_order_args_depth(HOArgs),
( map__search(VersionInfoMap0, OldPredProcId, OldProcVersionInfo) ->
@@ -2804,15 +2794,14 @@
;
CallerParentVersions = []
),
- ParentVersions =
- [parent_version_info(OrigPredProcId, ArgsDepth)
+ ParentVersions = [parent_version_info(OrigPredProcId, ArgsDepth)
| CallerParentVersions],
VersionInfo = version_info(OrigPredProcId, ArgsDepth,
PredVars, ParentVersions),
map__det_insert(VersionInfoMap0, NewPredProcId, VersionInfo,
VersionInfoMap),
- Info = Info0 ^ version_info := VersionInfoMap,
+ !:Info = !.Info ^ version_info := VersionInfoMap,
%
% Fix up the argument vars, types and modes.
@@ -2828,15 +2817,15 @@
HeadVars),
list__condense([ExtraTypeInfoModes, ExtraArgModes, ArgModes1],
ArgModes),
- proc_info_set_headvars(NewProcInfo4, HeadVars, NewProcInfo5),
- proc_info_set_argmodes(NewProcInfo5, ArgModes, NewProcInfo6),
+ proc_info_set_headvars(HeadVars, NewProcInfo4, NewProcInfo5),
+ proc_info_set_argmodes(ArgModes, NewProcInfo5, NewProcInfo6),
proc_info_goal(NewProcInfo6, Goal6),
Goal6 = _ - GoalInfo6,
goal_to_conj_list(Goal6, GoalList6),
conj_list_to_goal(list__append(ConstGoals, GoalList6),
GoalInfo6, Goal),
- proc_info_set_goal(NewProcInfo6, Goal, NewProcInfo7),
+ proc_info_set_goal(Goal, NewProcInfo6, NewProcInfo7),
proc_info_vartypes(NewProcInfo7, VarTypes7),
map__apply_to_list(ExtraHeadVars, VarTypes7, ExtraHeadVarTypes0),
@@ -2846,9 +2835,9 @@
[ExtraTypeInfoTypes, ExtraHeadVarTypes0,
ModifiedOriginalArgTypes],
ArgTypes),
- pred_info_set_arg_types(NewPredInfo0, TypeVarSet,
- ExistQVars, ArgTypes, NewPredInfo1),
- pred_info_set_typevarset(NewPredInfo1, TypeVarSet, NewPredInfo2),
+ pred_info_set_arg_types(TypeVarSet, ExistQVars, ArgTypes,
+ !NewPredInfo),
+ pred_info_set_typevarset(TypeVarSet, !NewPredInfo),
%
% The types of the headvars in the vartypes map in the
@@ -2885,11 +2874,11 @@
map__det_update(Map0, Var, Type, Map)
),
ExtraHeadVarsAndTypes, VarTypes7, VarTypes8),
- proc_info_set_vartypes(NewProcInfo7,
- VarTypes8, NewProcInfo8)
+ proc_info_set_vartypes(VarTypes8,
+ NewProcInfo7, NewProcInfo8)
;
- error(
- "higher_order__create_new_proc: type_list_subsumes failed")
+ error("higher_order__create_new_proc: " ++
+ "type_list_subsumes failed")
)
),
@@ -2900,8 +2889,8 @@
proc_info_typeclass_info_varmap(NewProcInfo8, TCVarMap0),
apply_substitutions_to_typeclass_var_map(TCVarMap0, TypeRenaming,
TypeSubn, EmptyVarRenaming, TCVarMap),
- proc_info_set_typeclass_info_varmap(NewProcInfo8,
- TCVarMap, NewProcInfo9),
+ proc_info_set_typeclass_info_varmap(TCVarMap,
+ NewProcInfo8, NewProcInfo9),
%
% Find the new class context by searching the argument types
@@ -2910,12 +2899,12 @@
%
find_class_context(ModuleInfo, ArgTypes, ArgModes,
[], [], ClassContext),
- pred_info_set_class_context(NewPredInfo2, ClassContext, NewPredInfo3),
+ pred_info_set_class_context(ClassContext, !NewPredInfo),
map__init(NewProcs0),
NewPredProcId = proc(_, NewProcId),
map__det_insert(NewProcs0, NewProcId, NewProcInfo9, NewProcs),
- pred_info_set_procedures(NewPredInfo3, NewProcs, NewPredInfo).
+ pred_info_set_procedures(NewProcs, !NewPredInfo).
% Take an original list of headvars and arg_modes and
% return these with curried arguments added.
@@ -2955,7 +2944,7 @@
% Add the curried arguments to the procedure's argument list.
module_info_pred_proc_info(ModuleInfo, PredId, ProcId,
CalledPredInfo, CalledProcInfo),
- pred_info_get_is_pred_or_func(CalledPredInfo, PredOrFunc),
+ PredOrFunc = pred_info_is_pred_or_func(CalledPredInfo),
proc_info_argmodes(CalledProcInfo, CalledArgModes),
(
list__split_list(NumArgs, CalledArgModes,
@@ -2976,8 +2965,8 @@
list__duplicate(NumArgs, InMode, CurriedArgModes1)
),
- proc_info_create_vars_from_types(!.ProcInfo, CurriedArgTypes,
- CurriedHeadVars1, !:ProcInfo),
+ proc_info_create_vars_from_types(CurriedArgTypes, CurriedHeadVars1,
+ !ProcInfo),
CurriedHeadVarsAndTypes = assoc_list__from_corresponding_lists(
CurriedHeadVars1, CurriedArgTypes),
@@ -3066,8 +3055,7 @@
\+ map__contains(TCVarMap0, Constraint)
->
map__det_insert(TCVarMap0, Constraint, Var, TCVarMap),
- proc_info_set_typeclass_info_varmap(!.ProcInfo,
- TCVarMap, !:ProcInfo),
+ proc_info_set_typeclass_info_varmap(TCVarMap, !ProcInfo),
Constraint = constraint(_, ConstraintTypes),
list__foldl2(
(pred(ConstraintType::in, Index::in, (Index + 1)::out,
@@ -3092,7 +3080,7 @@
true
;
map__det_insert(TVarMap0, TVar, Locn, TVarMap),
- proc_info_set_typeinfo_varmap(!.ProcInfo, TVarMap, !:ProcInfo)
+ proc_info_set_typeinfo_varmap(TVarMap, !ProcInfo)
).
:- pred remove_const_higher_order_args(int::in, list(T)::in,
Index: compiler/hlds_goal.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.108
diff -u -b -r1.108 hlds_goal.m
--- compiler/hlds_goal.m 20 Oct 2003 07:29:05 -0000 1.108
+++ compiler/hlds_goal.m 21 Oct 2003 13:04:43 -0000
@@ -1760,33 +1760,24 @@
%-----------------------------------------------------------------------------%
-make_int_const_construction(Int, MaybeName, Goal, Var, ProcInfo0, ProcInfo) :-
- proc_info_create_var_from_type(ProcInfo0, int_type, MaybeName,
- Var, ProcInfo),
+make_int_const_construction(Int, MaybeName, Goal, Var, !ProcInfo) :-
+ proc_info_create_var_from_type(int_type, MaybeName, Var, !ProcInfo),
make_int_const_construction(Var, Int, Goal).
-make_string_const_construction(String, MaybeName, Goal, Var,
- ProcInfo0, ProcInfo) :-
- proc_info_create_var_from_type(ProcInfo0, string_type, MaybeName,
- Var, ProcInfo),
+make_string_const_construction(String, MaybeName, Goal, Var, !ProcInfo) :-
+ proc_info_create_var_from_type(string_type, MaybeName, Var, !ProcInfo),
make_string_const_construction(Var, String, Goal).
-make_float_const_construction(Float, MaybeName, Goal, Var,
- ProcInfo0, ProcInfo) :-
- proc_info_create_var_from_type(ProcInfo0, float_type, MaybeName,
- Var, ProcInfo),
+make_float_const_construction(Float, MaybeName, Goal, Var, !ProcInfo) :-
+ proc_info_create_var_from_type(float_type, MaybeName, Var, !ProcInfo),
make_float_const_construction(Var, Float, Goal).
-make_char_const_construction(Char, MaybeName, Goal, Var,
- ProcInfo0, ProcInfo) :-
- proc_info_create_var_from_type(ProcInfo0, char_type, MaybeName,
- Var, ProcInfo),
+make_char_const_construction(Char, MaybeName, Goal, Var, !ProcInfo) :-
+ proc_info_create_var_from_type(char_type, MaybeName, Var, !ProcInfo),
make_char_const_construction(Var, Char, Goal).
-make_const_construction(ConsId, Type, MaybeName, Goal, Var,
- ProcInfo0, ProcInfo) :-
- proc_info_create_var_from_type(ProcInfo0, Type, MaybeName,
- Var, ProcInfo),
+make_const_construction(ConsId, Type, MaybeName, Goal, Var, !ProcInfo) :-
+ proc_info_create_var_from_type(Type, MaybeName, Var, !ProcInfo),
make_const_construction(Var, ConsId, Goal).
make_int_const_construction(Int, MaybeName, Goal, Var, VarTypes0, VarTypes,
Index: compiler/hlds_module.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_module.m,v
retrieving revision 1.90
diff -u -b -r1.90 hlds_module.m
--- compiler/hlds_module.m 26 Jun 2003 00:26:46 -0000 1.90
+++ compiler/hlds_module.m 21 Oct 2003 15:03:07 -0000
@@ -849,7 +849,7 @@
module_info_set_pred_proc_info(MI0, PredId, ProcId, PredInfo0, ProcInfo, MI) :-
pred_info_procedures(PredInfo0, Procs0),
map__set(Procs0, ProcId, ProcInfo, Procs),
- pred_info_set_procedures(PredInfo0, Procs, PredInfo),
+ pred_info_set_procedures(Procs, PredInfo0, PredInfo),
module_info_set_pred_info(MI0, PredId, PredInfo, MI).
module_info_typeids(MI, TypeCtors) :-
@@ -1386,7 +1386,7 @@
Pred_N_Index, Pred_NA_Index, Pred_MNA_Index,
Func_N_Index, Func_NA_Index, Func_MNA_Index),
map__init(Preds),
- hlds_pred__initial_pred_id(NextPredId),
+ NextPredId = hlds_pred__initial_pred_id,
PredIds = [],
map__init(Pred_N_Index),
map__init(Pred_NA_Index),
@@ -1429,10 +1429,10 @@
PredN0, PredNA0, PredMNA0, FuncN0, FuncNA0, FuncMNA0),
list__delete_all(PredIds0, PredId, PredIds),
map__det_remove(Preds0, PredId, PredInfo, Preds),
- pred_info_module(PredInfo, Module),
- pred_info_name(PredInfo, Name),
- pred_info_arity(PredInfo, Arity),
- pred_info_get_is_pred_or_func(PredInfo, IsPredOrFunc),
+ Module = pred_info_module(PredInfo),
+ Name = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo),
+ IsPredOrFunc = pred_info_is_pred_or_func(PredInfo),
(
IsPredOrFunc = predicate,
predicate_table_remove_from_index(Module, Name, Arity, PredId,
@@ -1739,7 +1739,7 @@
PredIds = list__filter(
(pred(PredId::in) is semidet :-
map__lookup(Preds, PredId, PredInfo),
- pred_info_module(PredInfo, ModuleName)
+ ModuleName = pred_info_module(PredInfo)
), PredIds0).
%-----------------------------------------------------------------------------%
@@ -1853,9 +1853,9 @@
PredicateTable0 = predicate_table(Preds0, NextPredId0, PredIds0,
Pred_N_Index0, Pred_NA_Index0, Pred_MNA_Index0,
Func_N_Index0, Func_NA_Index0, Func_MNA_Index0),
- pred_info_module(PredInfo0, Module),
- pred_info_name(PredInfo0, Name),
- pred_info_arity(PredInfo0, Arity),
+ Module = pred_info_module(PredInfo0),
+ Name = pred_info_name(PredInfo0),
+ Arity = pred_info_arity(PredInfo0),
( MaybePredId = yes(PredId),
NextPredId = NextPredId0
@@ -1868,7 +1868,7 @@
% insert the pred_id into either the function or predicate
% indices, as appropriate
- pred_info_get_is_pred_or_func(PredInfo0, PredOrFunc),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo0),
(
PredOrFunc = predicate,
predicate_table_do_insert(Module, Name, Arity,
@@ -1916,7 +1916,7 @@
predicate_table_do_insert(Module, Name, Arity, NeedQual, MaybeQualInfo,
PredId, N_Index0, N_Index, NA_Index0, NA_Index,
- MNA_Index0, MNA_Index, PredInfo0, PredInfo) :-
+ MNA_Index0, MNA_Index, !PredInfo) :-
( NeedQual = may_be_unqualified ->
% insert the unqualified name into the name index
multi_map__set(N_Index0, Name, PredId, N_Index),
@@ -1924,17 +1924,15 @@
% insert the unqualified name/arity into the
% name/arity index
NA = Name / Arity,
- multi_map__set(NA_Index0, NA, PredId, NA_Index),
-
- PredInfo1 = PredInfo0
+ multi_map__set(NA_Index0, NA, PredId, NA_Index)
;
N_Index = N_Index0,
NA_Index = NA_Index0,
- pred_info_get_markers(PredInfo0, MarkersA0),
+ pred_info_get_markers(!.PredInfo, MarkersA0),
add_marker(MarkersA0, not_accessible_by_unqualifed_name,
MarkersA),
- pred_info_set_markers(PredInfo0, MarkersA, PredInfo1)
+ pred_info_set_markers(MarkersA, !PredInfo)
),
( MaybeQualInfo = yes(QualInfo) ->
@@ -1946,17 +1944,14 @@
MNAs0::in, MNAs::out] is det,
insert_into_mna_index(AncModule, Name, Arity, PredId,
MNAs0, MNAs)),
- PartialQuals, _, MNA_Index0, MNA_Index1),
-
- PredInfo = PredInfo1
+ PartialQuals, _, MNA_Index0, MNA_Index1)
;
MNA_Index1 = MNA_Index0,
- pred_info_get_markers(PredInfo1, MarkersB0),
+ pred_info_get_markers(!.PredInfo, MarkersB0),
add_marker(MarkersB0,
- not_accessible_by_partially_qualified_names,
- MarkersB),
- pred_info_set_markers(PredInfo1, MarkersB, PredInfo)
+ not_accessible_by_partially_qualified_names, MarkersB),
+ pred_info_set_markers(MarkersB, !PredInfo)
),
% insert the fully-qualified name into the
@@ -2023,13 +2018,13 @@
get_proc_id(ModuleInfo, PredId, ProcId) :-
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_procids(PredInfo, ProcIds),
+ ProcIds = pred_info_procids(PredInfo),
( ProcIds = [ProcId0] ->
ProcId = ProcId0
;
- pred_info_name(PredInfo, Name),
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
- pred_info_arity(PredInfo, Arity),
+ Name = pred_info_name(PredInfo),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
+ Arity = pred_info_arity(PredInfo),
hlds_out__pred_or_func_to_str(PredOrFunc, PredOrFuncStr),
string__int_to_string(Arity, ArityString),
( ProcIds = [] ->
@@ -2097,12 +2092,10 @@
error(ErrorMessage)
),
module_info_pred_info(Module, PredId, PredInfo),
- pred_info_procids(PredInfo, ProcIds),
+ ProcIds = pred_info_procids(PredInfo),
(
ModeNo = only_mode,
- (
- ProcIds = [ProcId0]
- ->
+ ( ProcIds = [ProcId0] ->
ProcId = ProcId0
;
error(string__format(
@@ -2111,9 +2104,7 @@
)
;
ModeNo = mode_no(N),
- (
- list__index0(ProcIds, N, ProcId0)
- ->
+ ( list__index0(ProcIds, N, ProcId0) ->
ProcId = ProcId0
;
error(string__format(
@@ -2127,23 +2118,23 @@
predicate_id(ModuleInfo, PredId, ModuleName, PredName, Arity) :-
module_info_preds(ModuleInfo, Preds),
map__lookup(Preds, PredId, PredInfo),
- pred_info_module(PredInfo, ModuleName),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, Arity).
+ ModuleName = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo).
predicate_module(ModuleInfo, PredId, ModuleName) :-
module_info_preds(ModuleInfo, Preds),
map__lookup(Preds, PredId, PredInfo),
- pred_info_module(PredInfo, ModuleName).
+ ModuleName = pred_info_module(PredInfo).
predicate_name(ModuleInfo, PredId, PredName) :-
module_info_preds(ModuleInfo, Preds),
map__lookup(Preds, PredId, PredInfo),
- pred_info_name(PredInfo, PredName).
+ PredName = pred_info_name(PredInfo).
predicate_arity(ModuleInfo, PredId, Arity) :-
module_info_preds(ModuleInfo, Preds),
map__lookup(Preds, PredId, PredInfo),
- pred_info_arity(PredInfo, Arity).
+ Arity = pred_info_arity(PredInfo).
%-----------------------------------------------------------------------------%
Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.316
diff -u -b -r1.316 hlds_out.m
--- compiler/hlds_out.m 20 Oct 2003 07:29:05 -0000 1.316
+++ compiler/hlds_out.m 21 Oct 2003 13:05:42 -0000
@@ -370,38 +370,38 @@
% error_util__describe_one_pred_name. Changes here should be made
% there as well.
-hlds_out__write_pred_id(ModuleInfo, PredId) -->
- { module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_module(PredInfo, Module) },
- { pred_info_name(PredInfo, Name) },
- { pred_info_arity(PredInfo, Arity) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
- { pred_info_get_maybe_special_pred(PredInfo, MaybeSpecial) },
- (
- { MaybeSpecial = yes(SpecialId - TypeCtor) }
- ->
- { special_pred_description(SpecialId, Descr) },
- io__write_string(Descr),
- { TypeCtor = _TypeSymName - TypeArity },
- ( { TypeArity = 0 } ->
- io__write_string(" for type ")
+hlds_out__write_pred_id(ModuleInfo, PredId, !IO) :-
+ module_info_pred_info(ModuleInfo, PredId, PredInfo),
+ Module = pred_info_module(PredInfo),
+ Name = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
+ pred_info_get_maybe_special_pred(PredInfo, MaybeSpecial),
+ (
+ MaybeSpecial = yes(SpecialId - TypeCtor)
+ ->
+ special_pred_description(SpecialId, Descr),
+ io__write_string(Descr, !IO),
+ TypeCtor = _TypeSymName - TypeArity,
+ ( TypeArity = 0 ->
+ io__write_string(" for type ", !IO)
;
- io__write_string(" for type constructor ")
+ io__write_string(" for type constructor ", !IO)
),
- hlds_out__write_type_name(TypeCtor)
+ hlds_out__write_type_name(TypeCtor, !IO)
;
- { pred_info_get_markers(PredInfo, Markers) },
- { check_marker(Markers, class_instance_method) }
+ pred_info_get_markers(PredInfo, Markers),
+ check_marker(Markers, class_instance_method)
->
- io__write_string("type class method implementation")
+ io__write_string("type class method implementation", !IO)
;
- { pred_info_get_goal_type(PredInfo, promise(PromiseType)) }
+ pred_info_get_goal_type(PredInfo, promise(PromiseType))
->
io__write_string("`" ++ prog_out__promise_to_string(PromiseType)
- ++ "' declaration")
+ ++ "' declaration", !IO)
;
hlds_out__write_simple_call_id(PredOrFunc,
- qualified(Module, Name), Arity)
+ qualified(Module, Name), Arity, !IO)
).
hlds_out__write_pred_proc_id(ModuleInfo, PredId, ProcId) -->
@@ -816,7 +816,7 @@
% mode for them.
\+ string__contains_char(Verbose, 'I'),
pred_info_is_pseudo_imported(PredInfo),
- pred_info_procids(PredInfo, ProcIds),
+ ProcIds = pred_info_procids(PredInfo),
hlds_pred__in_in_unification_proc_id(ProcId),
ProcIds = [ProcId]
;
@@ -838,16 +838,16 @@
:- mode hlds_out__write_pred(in, in, in, in, di, uo) is det.
hlds_out__write_pred(Indent, ModuleInfo, PredId, PredInfo) -->
- { pred_info_module(PredInfo, Module) },
+ { Module = pred_info_module(PredInfo) },
+ { PredName = pred_info_name(PredInfo) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
{ pred_info_arg_types(PredInfo, ArgTypes) },
{ pred_info_get_exist_quant_tvars(PredInfo, ExistQVars) },
{ pred_info_typevarset(PredInfo, TVarSet) },
{ pred_info_clauses_info(PredInfo, ClausesInfo) },
{ pred_info_context(PredInfo, Context) },
- { pred_info_name(PredInfo, PredName) },
{ pred_info_import_status(PredInfo, ImportStatus) },
{ pred_info_get_markers(PredInfo, Markers) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
{ pred_info_get_class_context(PredInfo, ClassContext) },
{ pred_info_get_constraint_proofs(PredInfo, Proofs) },
{ pred_info_get_purity(PredInfo, Purity) },
@@ -1116,7 +1116,7 @@
io__nl
),
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_procids(PredInfo, ProcIds) },
+ { ProcIds = pred_info_procids(PredInfo) },
( { Modes = [] ; Modes = ProcIds } ->
hlds_out__write_clause_head(ModuleInfo, PredId, VarSet,
AppendVarnums, HeadTerms, PredOrFunc)
@@ -1664,14 +1664,14 @@
[]
),
hlds_out__write_indent(Indent),
- ( { invalid_pred_id(PredId) } ->
+ ( { PredId = invalid_pred_id } ->
% If we don't know then the call must be treated
% as a predicate.
{ PredOrFunc = predicate }
;
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
{ pred_info_get_purity(PredInfo, Purity) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
write_purity_prefix(Purity)
),
(
@@ -2478,8 +2478,8 @@
;
{ ConsId = pred_const(PredId, _, _) },
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_module(PredInfo, PredModule) },
- { pred_info_name(PredInfo, PredName) },
+ { PredModule = pred_info_module(PredInfo) },
+ { PredName = pred_info_name(PredInfo) },
hlds_out__write_functor_cons_id(
cons(qualified(PredModule, PredName),
list__length(ArgVars)),
@@ -3367,11 +3367,11 @@
:- mode hlds_out__write_procs(in, in, in, in, in, in, di, uo) is det.
hlds_out__write_procs(Indent, AppendVarnums, ModuleInfo, PredId,
- ImportStatus, PredInfo) -->
- { pred_info_procedures(PredInfo, ProcTable) },
- { pred_info_procids(PredInfo, ProcIds) },
+ ImportStatus, PredInfo, !IO) :-
+ pred_info_procedures(PredInfo, ProcTable),
+ ProcIds = pred_info_procids(PredInfo),
hlds_out__write_procs_2(ProcIds, AppendVarnums, ModuleInfo, Indent,
- PredId, ImportStatus, ProcTable).
+ PredId, ImportStatus, ProcTable, !IO).
:- pred hlds_out__write_procs_2(list(proc_id), bool, module_info, int, pred_id,
import_status, proc_table, io__state, io__state).
@@ -3498,7 +3498,7 @@
hlds_out__write_indent(Indent),
{ predicate_name(ModuleInfo, PredId, PredName) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
{ varset__init(ModeVarSet) },
(
{ PredOrFunc = predicate },
Index: compiler/hlds_pred.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_pred.m,v
retrieving revision 1.131
diff -u -b -r1.131 hlds_pred.m
--- compiler/hlds_pred.m 20 Oct 2003 07:29:06 -0000 1.131
+++ compiler/hlds_pred.m 21 Oct 2003 16:37:21 -0000
@@ -56,14 +56,11 @@
:- type pred_id.
:- type proc_id.
-:- pred hlds_pred__initial_pred_id(pred_id).
-:- mode hlds_pred__initial_pred_id(out) is det.
+:- func hlds_pred__initial_pred_id = pred_id.
-:- pred hlds_pred__initial_proc_id(proc_id).
-:- mode hlds_pred__initial_proc_id(out) is det.
+:- func hlds_pred__initial_proc_id = proc_id.
-:- pred hlds_pred__next_pred_id(pred_id, pred_id).
-:- mode hlds_pred__next_pred_id(in, out) is det.
+:- pred hlds_pred__next_pred_id(pred_id::in, pred_id::out) is det.
:- pred pred_id_to_int(pred_id, int).
:- mode pred_id_to_int(in, out) is det.
@@ -77,18 +74,15 @@
% these are defined to have the same proc_id (0). This
% returns that proc_id.
-:- pred hlds_pred__in_in_unification_proc_id(proc_id).
-:- mode hlds_pred__in_in_unification_proc_id(out) is det.
+:- pred hlds_pred__in_in_unification_proc_id(proc_id::out) is det.
% Return an invalid pred_id. Used to initialize the pred_id
% in call(...) goals before we do typechecking or when type-checking
% finds that there was no predicate which matched the call.
-:- pred invalid_pred_id(pred_id).
-:- mode invalid_pred_id(out) is det.
+:- func invalid_pred_id = pred_id.
-:- pred invalid_proc_id(proc_id).
-:- mode invalid_proc_id(out) is det.
+:- func invalid_proc_id = proc_id.
:- type pred_info.
:- type proc_info.
@@ -97,15 +91,13 @@
:- type call_id
---> call(simple_call_id)
- ; generic_call(generic_call_id)
- .
+ ; generic_call(generic_call_id).
:- type generic_call_id
---> higher_order(purity, pred_or_func, arity)
; class_method(class_id, simple_call_id)
; unsafe_cast
- ; aditi_builtin(aditi_builtin, simple_call_id)
- .
+ ; aditi_builtin(aditi_builtin, simple_call_id).
:- type simple_call_id == pair(pred_or_func, sym_name_and_arity).
@@ -121,8 +113,8 @@
% After mode analysis the clauses and the procedure goals are not
% guaranteed to be the same, and the clauses are only kept so that
% the optimized goal can be compared with the original in HLDS dumps.
-:- type clauses_info
- ---> clauses_info(
+:- type clauses_info --->
+ clauses_info(
varset :: prog_varset,
% variable names
explicit_vartypes :: vartypes,
@@ -159,61 +151,50 @@
:- type tvar_name_map == map(string, tvar).
-:- pred clauses_info_varset(clauses_info, prog_varset).
-:- mode clauses_info_varset(in, out) is det.
+:- pred clauses_info_varset(clauses_info::in, prog_varset::out) is det.
% This partial map holds the types specified by any explicit
% type qualifiers in the clauses.
-:- pred clauses_info_explicit_vartypes(clauses_info, vartypes).
-:- mode clauses_info_explicit_vartypes(in, out) is det.
+:- pred clauses_info_explicit_vartypes(clauses_info::in, vartypes::out) is det.
% This map contains the types of all the variables, as inferred
% by typecheck.m.
-:- pred clauses_info_vartypes(clauses_info, vartypes).
-:- mode clauses_info_vartypes(in, out) is det.
+:- pred clauses_info_vartypes(clauses_info::in, vartypes::out) is det.
-:- pred clauses_info_type_info_varmap(clauses_info, type_info_varmap).
-:- mode clauses_info_type_info_varmap(in, out) is det.
+:- pred clauses_info_type_info_varmap(clauses_info::in, type_info_varmap::out)
+ is det.
-:- pred clauses_info_typeclass_info_varmap(clauses_info,
- typeclass_info_varmap).
-:- mode clauses_info_typeclass_info_varmap(in, out) is det.
+:- pred clauses_info_typeclass_info_varmap(clauses_info::in,
+ typeclass_info_varmap::out) is det.
-:- pred clauses_info_headvars(clauses_info, list(prog_var)).
-:- mode clauses_info_headvars(in, out) is det.
+:- pred clauses_info_headvars(clauses_info::in, list(prog_var)::out) is det.
-:- pred clauses_info_clauses(clauses_info, list(clause)).
-:- mode clauses_info_clauses(in, out) is det.
+:- pred clauses_info_clauses(clauses_info::in, list(clause)::out) is det.
-:- pred clauses_info_set_headvars(clauses_info, list(prog_var), clauses_info).
-:- mode clauses_info_set_headvars(in, in, out) is det.
+:- pred clauses_info_set_headvars(list(prog_var)::in,
+ clauses_info::in, clauses_info::out) is det.
-:- pred clauses_info_set_clauses(clauses_info, list(clause), clauses_info).
-:- mode clauses_info_set_clauses(in, in, out) is det.
+:- pred clauses_info_set_clauses(list(clause)::in,
+ clauses_info::in, clauses_info::out) is det.
-:- pred clauses_info_set_varset(clauses_info, prog_varset, clauses_info).
-:- mode clauses_info_set_varset(in, in, out) is det.
+:- pred clauses_info_set_varset(prog_varset::in,
+ clauses_info::in, clauses_info::out) is det.
% This partial map holds the types specified by any explicit
% type qualifiers in the clauses.
-:- pred clauses_info_set_explicit_vartypes(clauses_info, vartypes,
- clauses_info).
-:- mode clauses_info_set_explicit_vartypes(in, in, out) is det.
+:- pred clauses_info_set_explicit_vartypes(vartypes::in,
+ clauses_info::in, clauses_info::out) is det.
% This map contains the types of all the variables, as inferred
% by typecheck.m.
-:- pred clauses_info_set_vartypes(clauses_info, vartypes,
- clauses_info).
-:- mode clauses_info_set_vartypes(in, in, out) is det.
-
-:- pred clauses_info_set_type_info_varmap(clauses_info, type_info_varmap,
- clauses_info).
-:- mode clauses_info_set_type_info_varmap(in, in, out) is det.
-
-:- pred clauses_info_set_typeclass_info_varmap(clauses_info,
- typeclass_info_varmap, clauses_info).
-:- mode clauses_info_set_typeclass_info_varmap(in, in, out) is det.
+:- pred clauses_info_set_vartypes(vartypes::in,
+ clauses_info::in, clauses_info::out) is det.
+:- pred clauses_info_set_type_info_varmap(type_info_varmap::in,
+ clauses_info::in, clauses_info::out) is det.
+
+:- pred clauses_info_set_typeclass_info_varmap(typeclass_info_varmap::in,
+ clauses_info::in, clauses_info::out) is det.
% XXX we should use field names for clause
:- type clause --->
@@ -232,13 +213,12 @@
:- type implementation_language ---> mercury
; foreign_language(foreign_language).
-
% The type of goals that have been given for a pred.
-:- type goal_type ---> pragmas % pragma foreign_proc(...)
+:- type goal_type
+ ---> pragmas % pragma foreign_proc(...)
; clauses
- ; clauses_and_pragmas
- % both clauses and pragmas
+ ; clauses_and_pragmas % both clauses and pragmas
; promise(promise_type)
; none.
@@ -507,7 +487,6 @@
% partially qualified names.
.
-
% An abstract set of attributes.
:- type pred_attributes.
@@ -528,11 +507,10 @@
% typeclass_info for that constraint.
:- type constraint_proof_map == map(class_constraint, constraint_proof).
- % Describes the class constraints on an instance method
- % implementation. This information is used by polymorphism.m
- % to ensure that the type_info and typeclass_info arguments
- % are added in the order they will be passed in by
- % do_call_class_method.
+ % Describes the class constraints on an instance method implementation.
+ % This information is used by polymorphism.m to ensure that the
+ % type_info and typeclass_info arguments are added in the order in
+ % which they will be passed in by do_call_class_method.
:- type instance_method_constraints
---> instance_method_constraints(
class_id,
@@ -580,8 +558,8 @@
% a typeclass_info in which the type_info is nested.
:- pred type_info_locn_var(type_info_locn::in, prog_var::out) is det.
-:- pred type_info_locn_set_var(type_info_locn::in, prog_var::in,
- type_info_locn::out) is det.
+:- pred type_info_locn_set_var(prog_var::in,
+ type_info_locn::in, type_info_locn::out) is det.
% hlds_pred__define_new_pred(Goal, CallGoal, Args, ExtraArgs, InstMap,
% PredName, TVarSet, VarTypes, ClassContext, TVarMap, TCVarMap,
@@ -592,120 +570,102 @@
% call the created predicate. ExtraArgs is the list of extra
% type_infos and typeclass_infos required by typeinfo liveness
% which were added to the front of the argument list.
-:- pred hlds_pred__define_new_pred(hlds_goal, hlds_goal, list(prog_var),
- list(prog_var), instmap, string, tvarset, vartypes,
- class_constraints, type_info_varmap, typeclass_info_varmap,
- prog_varset, inst_varset, pred_markers, aditi_owner,
- is_address_taken, module_info, module_info, pred_proc_id).
-:- mode hlds_pred__define_new_pred(in, out, in, out, in, in, in, in, in,
- in, in, in, in, in, in, in, in, out, out) is det.
+:- pred hlds_pred__define_new_pred(hlds_goal::in, hlds_goal::out,
+ list(prog_var)::in, list(prog_var)::out, instmap::in, string::in,
+ tvarset::in, vartypes::in, class_constraints::in, type_info_varmap::in,
+ typeclass_info_varmap::in, prog_varset::in, inst_varset::in,
+ pred_markers::in, aditi_owner::in, is_address_taken::in,
+ module_info::in, module_info::out, pred_proc_id::out) is det.
% Various predicates for accessing the information stored in the
% pred_id and pred_info data structures.
-:- pred pred_info_init(module_name, sym_name, arity, tvarset, existq_tvars,
- list(type), condition, prog_context, clauses_info, import_status,
- pred_markers, goal_type, pred_or_func, class_constraints,
- constraint_proof_map, aditi_owner, pred_info).
-:- mode pred_info_init(in, in, in, in, in, in, in, in, in, in, in, in, in,
- in, in, in, out) is det.
-
-:- pred pred_info_create(module_name, sym_name, tvarset, existq_tvars,
- list(type), condition, prog_context, import_status, pred_markers,
- pred_or_func, class_constraints, aditi_owner, set(assert_id),
- proc_info, proc_id, pred_info).
-:- mode pred_info_create(in, in, in, in, in, in, in, in, in, in, in, in, in,
- in, out, out) is det.
+:- pred pred_info_init(module_name::in, sym_name::in, arity::in, tvarset::in,
+ existq_tvars::in, list(type)::in, condition::in, prog_context::in,
+ clauses_info::in, import_status::in, pred_markers::in, goal_type::in,
+ pred_or_func::in, class_constraints::in, constraint_proof_map::in,
+ aditi_owner::in, pred_info::out) is det.
+
+:- pred pred_info_create(module_name::in, sym_name::in, tvarset::in,
+ existq_tvars::in, list(type)::in, condition::in, prog_context::in,
+ import_status::in, pred_markers::in, pred_or_func::in,
+ class_constraints::in, aditi_owner::in, set(assert_id)::in,
+ proc_info::in, proc_id::out, pred_info::out) is det.
-:- pred pred_info_module(pred_info, module_name).
-:- mode pred_info_module(in, out) is det.
+:- func pred_info_module(pred_info) = module_name.
-:- pred pred_info_name(pred_info, string).
-:- mode pred_info_name(in, out) is det.
+:- func pred_info_name(pred_info) = string.
% pred_info_arity returns the arity of the predicate
% *not* counting inserted type_info arguments for polymorphic preds.
-:- pred pred_info_arity(pred_info, arity).
-:- mode pred_info_arity(in, out) is det.
+:- func pred_info_arity(pred_info) = arity.
% Return a list of all the proc_ids for the valid modes
% of this predicate. This does not include candidate modes
% that were generated during mode inference but which mode
% inference found were not valid modes.
-:- pred pred_info_procids(pred_info, list(proc_id)).
-:- mode pred_info_procids(in, out) is det.
+:- func pred_info_procids(pred_info) = list(proc_id).
% Return a list of the proc_ids for all the modes
% of this predicate, including invalid modes.
-:- pred pred_info_all_procids(pred_info, list(proc_id)).
-:- mode pred_info_all_procids(in, out) is det.
+:- func pred_info_all_procids(pred_info) = list(proc_id).
% Return a list of the proc_ids for all the valid modes
% of this predicate that are not imported.
-:- pred pred_info_non_imported_procids(pred_info, list(proc_id)).
-:- mode pred_info_non_imported_procids(in, out) is det.
+:- func pred_info_non_imported_procids(pred_info) = list(proc_id).
% Return a list of the proc_ids for all the modes
% of this predicate that are not imported
% (including invalid modes).
-:- pred pred_info_all_non_imported_procids(pred_info, list(proc_id)).
-:- mode pred_info_all_non_imported_procids(in, out) is det.
+:- func pred_info_all_non_imported_procids(pred_info) = list(proc_id).
% Return a list of the proc_ids for all the valid modes
% of this predicate that are exported.
-:- pred pred_info_exported_procids(pred_info, list(proc_id)).
-:- mode pred_info_exported_procids(in, out) is det.
+:- func pred_info_exported_procids(pred_info) = list(proc_id).
% Remove a procedure from the pred_info.
-:- pred pred_info_remove_procid(pred_info, proc_id, pred_info).
-:- mode pred_info_remove_procid(in, in, out) is det.
+:- pred pred_info_remove_procid(proc_id::in, pred_info::in, pred_info::out)
+ is det.
-:- pred pred_info_arg_types(pred_info, list(type)).
-:- mode pred_info_arg_types(in, out) is det.
+:- pred pred_info_arg_types(pred_info::in, list(type)::out) is det.
-:- pred pred_info_arg_types(pred_info, tvarset, existq_tvars, list(type)).
-:- mode pred_info_arg_types(in, out, out, out) is det.
+:- pred pred_info_arg_types(pred_info::in, tvarset::out, existq_tvars::out,
+ list(type)::out) is det.
-:- pred pred_info_set_arg_types(pred_info, tvarset, existq_tvars, list(type),
- pred_info).
-:- mode pred_info_set_arg_types(in, in, in, in, out) is det.
+:- pred pred_info_set_arg_types(tvarset::in, existq_tvars::in, list(type)::in,
+ pred_info::in, pred_info::out) is det.
-:- pred pred_info_get_exist_quant_tvars(pred_info, existq_tvars).
-:- mode pred_info_get_exist_quant_tvars(in, out) is det.
+:- pred pred_info_get_exist_quant_tvars(pred_info::in, existq_tvars::out)
+ is det.
-:- pred pred_info_get_univ_quant_tvars(pred_info, existq_tvars).
-:- mode pred_info_get_univ_quant_tvars(in, out) is det.
+:- pred pred_info_get_univ_quant_tvars(pred_info::in, existq_tvars::out)
+ is det.
:- type head_type_params == list(tvar).
-:- pred pred_info_get_head_type_params(pred_info, head_type_params).
-:- mode pred_info_get_head_type_params(in, out) is det.
+:- pred pred_info_get_head_type_params(pred_info::in, head_type_params::out)
+ is det.
-:- pred pred_info_set_head_type_params(pred_info, head_type_params, pred_info).
-:- mode pred_info_set_head_type_params(in, in, out) is det.
+:- pred pred_info_set_head_type_params(head_type_params::in,
+ pred_info::in, pred_info::out) is det.
-:- pred pred_info_get_unproven_body_constraints(pred_info,
- list(class_constraint)).
-:- mode pred_info_get_unproven_body_constraints(in, out) is det.
+:- pred pred_info_get_unproven_body_constraints(pred_info::in,
+ list(class_constraint)::out) is det.
-:- pred pred_info_set_unproven_body_constraints(pred_info,
- list(class_constraint), pred_info).
-:- mode pred_info_set_unproven_body_constraints(in, in, out) is det.
+:- pred pred_info_set_unproven_body_constraints(list(class_constraint)::in,
+ pred_info::in, pred_info::out) is det.
-:- pred pred_info_clauses_info(pred_info, clauses_info).
-:- mode pred_info_clauses_info(in, out) is det.
+:- pred pred_info_clauses_info(pred_info::in, clauses_info::out) is det.
-:- pred pred_info_set_clauses_info(pred_info, clauses_info, pred_info).
-:- mode pred_info_set_clauses_info(in, in, out) is det.
+:- pred pred_info_set_clauses_info(clauses_info::in,
+ pred_info::in, pred_info::out) is det.
-:- pred pred_info_procedures(pred_info, proc_table).
-:- mode pred_info_procedures(in, out) is det.
+:- pred pred_info_procedures(pred_info::in, proc_table::out) is det.
-:- pred pred_info_set_procedures(pred_info, proc_table, pred_info).
-:- mode pred_info_set_procedures(in, in, out) is det.
+:- pred pred_info_set_procedures(proc_table::in, pred_info::in, pred_info::out)
+ is det.
-:- pred pred_info_context(pred_info, prog_context).
-:- mode pred_info_context(in, out) is det.
+:- pred pred_info_context(pred_info::in, prog_context::out) is det.
:- pred pred_info_import_status(pred_info::in, import_status::out) is det.
@@ -733,49 +693,43 @@
:- pred pred_info_mark_as_external(pred_info::in, pred_info::out) is det.
-:- pred pred_info_set_import_status(pred_info::in, import_status::in,
- pred_info::out) is det.
+:- pred pred_info_set_import_status(import_status::in,
+ pred_info::in, pred_info::out) is det.
-:- pred pred_info_typevarset(pred_info, tvarset).
-:- mode pred_info_typevarset(in, out) is det.
+:- pred pred_info_typevarset(pred_info::in, tvarset::out) is det.
-:- pred pred_info_set_typevarset(pred_info, tvarset, pred_info).
-:- mode pred_info_set_typevarset(in, in, out) is det.
+:- pred pred_info_set_typevarset(tvarset::in, pred_info::in, pred_info::out)
+ is det.
-:- pred pred_info_get_goal_type(pred_info, goal_type).
-:- mode pred_info_get_goal_type(in, out) is det.
+:- pred pred_info_get_goal_type(pred_info::in, goal_type::out) is det.
% Do we have a clause goal type?
% (this means either "clauses" or "clauses_and_pragmas")
-:- pred pred_info_clause_goal_type(pred_info).
-:- mode pred_info_clause_goal_type(in) is semidet.
+:- pred pred_info_clause_goal_type(pred_info::in) is semidet.
% Do we have a pragma goal type?
% (this means either "pragmas" or "clauses_and_pragmas")
-:- pred pred_info_pragma_goal_type(pred_info).
-:- mode pred_info_pragma_goal_type(in) is semidet.
+:- pred pred_info_pragma_goal_type(pred_info::in) is semidet.
-:- pred pred_info_update_goal_type(pred_info, goal_type, pred_info).
-:- mode pred_info_update_goal_type(in, in, out) is det.
+:- pred pred_info_update_goal_type(goal_type::in,
+ pred_info::in, pred_info::out) is det.
-:- pred pred_info_set_goal_type(pred_info, goal_type, pred_info).
-:- mode pred_info_set_goal_type(in, in, out) is det.
+:- pred pred_info_set_goal_type(goal_type::in, pred_info::in, pred_info::out)
+ is det.
% Succeeds if there was a `:- pragma inline(...)' declaration
% for this predicate. Note that the compiler may decide
% to inline a predicate even if there was no pragma inline(...)
% declaration for that predicate.
-:- pred pred_info_requested_inlining(pred_info).
-:- mode pred_info_requested_inlining(in) is semidet.
+:- pred pred_info_requested_inlining(pred_info::in) is semidet.
% Succeeds if there was a `:- pragma no_inline(...)' declaration
% for this predicate.
-:- pred pred_info_requested_no_inlining(pred_info).
-:- mode pred_info_requested_no_inlining(in) is semidet.
+:- pred pred_info_requested_no_inlining(pred_info::in) is semidet.
% N-ary functions are converted into N+1-ary predicates.
% (Clauses are converted in make_hlds, but calls to functions
@@ -785,124 +739,103 @@
% a pred_info is really for a predicate or whether it is for
% what was originally a function.
-:- pred pred_info_get_is_pred_or_func(pred_info, pred_or_func).
-:- mode pred_info_get_is_pred_or_func(in, out) is det.
+:- func pred_info_is_pred_or_func(pred_info) = pred_or_func.
-:- pred pred_info_get_class_context(pred_info, class_constraints).
-:- mode pred_info_get_class_context(in, out) is det.
+:- pred pred_info_get_class_context(pred_info::in, class_constraints::out)
+ is det.
-:- pred pred_info_set_class_context(pred_info, class_constraints, pred_info).
-:- mode pred_info_set_class_context(in, in, out) is det.
+:- pred pred_info_set_class_context(class_constraints::in,
+ pred_info::in, pred_info::out) is det.
-:- pred pred_info_get_constraint_proofs(pred_info, constraint_proof_map).
-:- mode pred_info_get_constraint_proofs(in, out) is det.
+:- pred pred_info_get_constraint_proofs(pred_info::in,
+ constraint_proof_map::out) is det.
-:- pred pred_info_set_constraint_proofs(pred_info, constraint_proof_map,
- pred_info).
-:- mode pred_info_set_constraint_proofs(in, in, out) is det.
+:- pred pred_info_set_constraint_proofs(constraint_proof_map::in,
+ pred_info::in, pred_info::out) is det.
-:- pred pred_info_get_aditi_owner(pred_info, string).
-:- mode pred_info_get_aditi_owner(in, out) is det.
+:- pred pred_info_get_aditi_owner(pred_info::in, string::out) is det.
-:- pred pred_info_set_aditi_owner(pred_info, string, pred_info).
-:- mode pred_info_set_aditi_owner(in, in, out) is det.
+:- pred pred_info_set_aditi_owner(string::in, pred_info::in, pred_info::out)
+ is det.
-:- pred pred_info_get_indexes(pred_info, list(index_spec)).
-:- mode pred_info_get_indexes(in, out) is det.
+:- pred pred_info_get_indexes(pred_info::in, list(index_spec)::out) is det.
-:- pred pred_info_set_indexes(pred_info, list(index_spec), pred_info).
-:- mode pred_info_set_indexes(in, in, out) is det.
+:- pred pred_info_set_indexes(list(index_spec)::in,
+ pred_info::in, pred_info::out) is det.
-:- pred pred_info_get_assertions(pred_info, set(assert_id)).
-:- mode pred_info_get_assertions(in, out) is det.
+:- pred pred_info_get_assertions(pred_info::in, set(assert_id)::out) is det.
-:- pred pred_info_set_assertions(pred_info, set(assert_id), pred_info).
-:- mode pred_info_set_assertions(in, in, out) is det.
+:- pred pred_info_set_assertions(set(assert_id)::in,
+ pred_info::in, pred_info::out) is det.
-:- pred pred_info_get_maybe_special_pred(pred_info, maybe(special_pred)).
-:- mode pred_info_get_maybe_special_pred(in, out) is det.
+:- pred pred_info_get_maybe_special_pred(pred_info::in,
+ maybe(special_pred)::out) is det.
-:- pred pred_info_set_maybe_special_pred(pred_info, maybe(special_pred),
- pred_info).
-:- mode pred_info_set_maybe_special_pred(in, in, out) is det.
+:- pred pred_info_set_maybe_special_pred(maybe(special_pred)::in,
+ pred_info::in, pred_info::out) is det.
-:- pred pred_info_get_maybe_instance_method_constraints(pred_info,
- maybe(instance_method_constraints)).
-:- mode pred_info_get_maybe_instance_method_constraints(in, out) is det.
+:- pred pred_info_get_maybe_instance_method_constraints(pred_info::in,
+ maybe(instance_method_constraints)::out) is det.
-:- pred pred_info_set_maybe_instance_method_constraints(pred_info,
- maybe(instance_method_constraints), pred_info).
-:- mode pred_info_set_maybe_instance_method_constraints(in, in, out) is det.
+:- pred pred_info_set_maybe_instance_method_constraints(
+ maybe(instance_method_constraints)::in, pred_info::in, pred_info::out)
+ is det.
-:- pred pred_info_get_purity(pred_info, purity).
-:- mode pred_info_get_purity(in, out) is det.
+:- pred pred_info_get_purity(pred_info::in, purity::out) is det.
-:- pred pred_info_get_promised_purity(pred_info, purity).
-:- mode pred_info_get_promised_purity(in, out) is det.
+:- pred pred_info_get_promised_purity(pred_info::in, purity::out) is det.
-:- pred purity_to_markers(purity, pred_markers).
-:- mode purity_to_markers(in, out) is det.
+:- pred purity_to_markers(purity::in, pred_markers::out) is det.
-:- pred pred_info_get_markers(pred_info, pred_markers).
-:- mode pred_info_get_markers(in, out) is det.
+:- pred pred_info_get_markers(pred_info::in, pred_markers::out) is det.
-:- pred pred_info_set_markers(pred_info, pred_markers, pred_info).
-:- mode pred_info_set_markers(in, in, out) is det.
+:- pred pred_info_set_markers(pred_markers::in, pred_info::in, pred_info::out)
+ is det.
-:- pred pred_info_get_attributes(pred_info, pred_attributes).
-:- mode pred_info_get_attributes(in, out) is det.
+:- pred pred_info_get_attributes(pred_info::in, pred_attributes::out) is det.
-:- pred pred_info_set_attributes(pred_info, pred_attributes, pred_info).
-:- mode pred_info_set_attributes(in, in, out) is det.
+:- pred pred_info_set_attributes(pred_attributes::in,
+ pred_info::in, pred_info::out) is det.
-:- pred pred_info_get_call_id(pred_info, simple_call_id).
-:- mode pred_info_get_call_id(in, out) is det.
+:- pred pred_info_get_call_id(pred_info::in, simple_call_id::out) is det.
% create an empty set of markers
-:- pred init_markers(pred_markers).
-:- mode init_markers(out) is det.
+:- pred init_markers(pred_markers::out) is det.
% check if a particular is in the set
-:- pred check_marker(pred_markers, marker).
-:- mode check_marker(in, in) is semidet.
+:- pred check_marker(pred_markers::in, marker::in) is semidet.
% add a marker to the set
-:- pred add_marker(pred_markers, marker, pred_markers).
-:- mode add_marker(in, in, out) is det.
+:- pred add_marker(pred_markers::in, marker::in, pred_markers::out) is det.
% remove a marker from the set
-:- pred remove_marker(pred_markers, marker, pred_markers).
-:- mode remove_marker(in, in, out) is det.
+:- pred remove_marker(pred_markers::in, marker::in, pred_markers::out) is det.
% convert the set to a list
-:- pred markers_to_marker_list(pred_markers, list(marker)).
-:- mode markers_to_marker_list(in, out) is det.
+:- pred markers_to_marker_list(pred_markers::in, list(marker)::out) is det.
-:- pred marker_list_to_markers(list(marker), pred_markers).
-:- mode marker_list_to_markers(in, out) is det.
+:- pred marker_list_to_markers(list(marker)::in, pred_markers::out) is det.
% create an empty set of attributes
-:- pred init_attributes(pred_attributes).
-:- mode init_attributes(out) is det.
+:- pred init_attributes(pred_attributes::out) is det.
% check if a particular is in the set
-:- pred check_attribute(pred_attributes, attribute).
-:- mode check_attribute(in, in) is semidet.
+:- pred check_attribute(pred_attributes::in, attribute::in) is semidet.
% add a attribute to the set
-:- pred add_attribute(pred_attributes, attribute, pred_attributes).
-:- mode add_attribute(in, in, out) is det.
+:- pred add_attribute(attribute::in, pred_attributes::in, pred_attributes::out)
+ is det.
% remove a attribute from the set
-:- pred remove_attribute(pred_attributes, attribute, pred_attributes).
-:- mode remove_attribute(in, in, out) is det.
+:- pred remove_attribute(attribute::in,
+ pred_attributes::in, pred_attributes::out) is det.
% convert the set to a list
-:- pred attributes_to_attribute_list(pred_attributes, list(attribute)).
-:- mode attributes_to_attribute_list(in, out) is det.
+:- pred attributes_to_attribute_list(pred_attributes::in,
+ list(attribute)::out) is det.
-:- pred attribute_list_to_attributes(list(attribute), pred_attributes).
-:- mode attribute_list_to_attributes(in, out) is det.
+:- pred attribute_list_to_attributes(list(attribute)::in,
+ pred_attributes::out) is det.
%-----------------------------------------------------------------------------%
@@ -911,9 +844,9 @@
:- type pred_id == int.
:- type proc_id == int.
-hlds_pred__initial_pred_id(0).
+hlds_pred__initial_pred_id = 0.
-hlds_pred__initial_proc_id(0).
+hlds_pred__initial_proc_id = 0.
hlds_pred__next_pred_id(PredId, NextPredId) :-
NextPredId = PredId + 1.
@@ -924,9 +857,9 @@
hlds_pred__in_in_unification_proc_id(0).
-invalid_pred_id(-1).
+invalid_pred_id = -1.
-invalid_proc_id(-1).
+invalid_proc_id = -1.
status_is_exported(imported(_), no).
status_is_exported(external(_), no).
@@ -969,7 +902,8 @@
calls_are_fully_qualified(Markers) =
( check_marker(Markers, calls_are_fully_qualified) ->
is_fully_qualified
- ; may_be_partially_qualified
+ ;
+ may_be_partially_qualified
).
% The information specific to a predicate, as opposed to a procedure.
@@ -980,8 +914,8 @@
% polymorphically-typed arguments whose type depends on the
% values of those type_info-related variables;
% accurate GC for the MLDS back-end relies on this.
-:- type pred_info
- ---> predicate(
+:- type pred_info --->
+ predicate(
decl_typevarset :: tvarset,
% names of type vars
% in the predicate's type decl
@@ -1141,47 +1075,47 @@
UnprovenBodyConstraints, User, Indexes, Assertions,
MaybeUCI, MaybeInstanceConstraints).
-pred_info_all_procids(PredInfo, ProcIds) :-
+pred_info_all_procids(PredInfo) = ProcIds :-
ProcTable = PredInfo ^ procedures,
map__keys(ProcTable, ProcIds).
-pred_info_procids(PredInfo, ValidProcIds) :-
- pred_info_all_procids(PredInfo, AllProcIds),
+pred_info_procids(PredInfo) = ValidProcIds :-
+ AllProcIds = pred_info_all_procids(PredInfo),
ProcTable = PredInfo ^ procedures,
IsValid = (pred(ProcId::in) is semidet :-
ProcInfo = map__lookup(ProcTable, ProcId),
proc_info_is_valid_mode(ProcInfo)),
list__filter(IsValid, AllProcIds, ValidProcIds).
-pred_info_non_imported_procids(PredInfo, ProcIds) :-
+pred_info_non_imported_procids(PredInfo) = ProcIds :-
pred_info_import_status(PredInfo, ImportStatus),
( ImportStatus = imported(_) ->
ProcIds = []
; ImportStatus = external(_) ->
ProcIds = []
; ImportStatus = pseudo_imported ->
- pred_info_procids(PredInfo, ProcIds0),
+ ProcIds0 = pred_info_procids(PredInfo),
% for pseduo_imported preds, procid 0 is imported
list__delete_all(ProcIds0, 0, ProcIds)
;
- pred_info_procids(PredInfo, ProcIds)
+ ProcIds = pred_info_procids(PredInfo)
).
-pred_info_all_non_imported_procids(PredInfo, ProcIds) :-
+pred_info_all_non_imported_procids(PredInfo) = ProcIds :-
pred_info_import_status(PredInfo, ImportStatus),
( ImportStatus = imported(_) ->
ProcIds = []
; ImportStatus = external(_) ->
ProcIds = []
; ImportStatus = pseudo_imported ->
- pred_info_all_procids(PredInfo, ProcIds0),
+ ProcIds0 = pred_info_procids(PredInfo),
% for pseduo_imported preds, procid 0 is imported
list__delete_all(ProcIds0, 0, ProcIds)
;
- pred_info_all_procids(PredInfo, ProcIds)
+ ProcIds = pred_info_procids(PredInfo)
).
-pred_info_exported_procids(PredInfo, ProcIds) :-
+pred_info_exported_procids(PredInfo) = ProcIds :-
pred_info_import_status(PredInfo, ImportStatus),
(
( ImportStatus = exported
@@ -1189,7 +1123,7 @@
; ImportStatus = exported_to_submodules
)
->
- pred_info_procids(PredInfo, ProcIds)
+ ProcIds = pred_info_procids(PredInfo)
;
ImportStatus = pseudo_exported
->
@@ -1198,41 +1132,40 @@
ProcIds = []
).
-pred_info_remove_procid(PredInfo0, ProcId, PredInfo) :-
- pred_info_procedures(PredInfo0, Procs0),
+pred_info_remove_procid(ProcId, !PredInfo) :-
+ pred_info_procedures(!.PredInfo, Procs0),
map__delete(Procs0, ProcId, Procs),
- pred_info_set_procedures(PredInfo0, Procs, PredInfo).
+ pred_info_set_procedures(Procs, !PredInfo).
-pred_info_clauses_info(PredInfo, PredInfo^clauses_info).
+pred_info_clauses_info(PredInfo, PredInfo ^ clauses_info).
-pred_info_set_clauses_info(PredInfo, X, PredInfo^clauses_info := X).
+pred_info_set_clauses_info(X, PredInfo, PredInfo ^ clauses_info := X).
pred_info_arg_types(PredInfo, ArgTypes) :-
pred_info_arg_types(PredInfo, _TypeVars, _ExistQVars, ArgTypes).
-pred_info_arg_types(PredInfo, PredInfo^decl_typevarset,
- PredInfo^exist_quant_tvars, PredInfo^arg_types).
+pred_info_arg_types(PredInfo, PredInfo ^ decl_typevarset,
+ PredInfo ^ exist_quant_tvars, PredInfo ^ arg_types).
-pred_info_set_arg_types(PredInfo0, TypeVarSet, ExistQVars, ArgTypes,
- PredInfo) :-
- PredInfo = ((PredInfo0
- ^decl_typevarset := TypeVarSet)
- ^exist_quant_tvars := ExistQVars)
- ^arg_types := ArgTypes.
+pred_info_set_arg_types(TypeVarSet, ExistQVars, ArgTypes, !PredInfo) :-
+ !:PredInfo = ((!.PredInfo
+ ^ decl_typevarset := TypeVarSet)
+ ^ exist_quant_tvars := ExistQVars)
+ ^ arg_types := ArgTypes.
-pred_info_procedures(PredInfo, PredInfo^procedures).
+pred_info_procedures(PredInfo, PredInfo ^ procedures).
-pred_info_set_procedures(PredInfo, X, PredInfo^procedures := X).
+pred_info_set_procedures(X, PredInfo, PredInfo ^ procedures := X).
-pred_info_context(PredInfo, PredInfo^context).
+pred_info_context(PredInfo, PredInfo ^ context).
-pred_info_module(PredInfo, PredInfo^(module)).
+pred_info_module(PredInfo) = PredInfo ^ (module).
-pred_info_name(PredInfo, PredInfo^name).
+pred_info_name(PredInfo) = PredInfo ^ name.
-pred_info_arity(PredInfo, PredInfo^arity).
+pred_info_arity(PredInfo) = PredInfo ^ arity.
-pred_info_import_status(PredInfo, PredInfo^import_status).
+pred_info_import_status(PredInfo, PredInfo ^ import_status).
pred_info_is_imported(PredInfo) :-
pred_info_import_status(PredInfo, Status),
@@ -1276,22 +1209,22 @@
).
pred_info_mark_as_external(PredInfo0, PredInfo) :-
- status_is_exported(PredInfo0^import_status, Exported),
+ status_is_exported(PredInfo0 ^ import_status, Exported),
(
Exported = yes,
- PredInfo = PredInfo0^import_status := external(interface)
+ PredInfo = PredInfo0 ^ import_status := external(interface)
;
Exported = no,
- PredInfo = PredInfo0^import_status := external(implementation)
+ PredInfo = PredInfo0 ^ import_status := external(implementation)
).
-pred_info_set_import_status(PredInfo, X, PredInfo^import_status := X).
+pred_info_set_import_status(X, PredInfo, PredInfo ^ import_status := X).
-pred_info_typevarset(PredInfo, PredInfo^typevarset).
+pred_info_typevarset(PredInfo, PredInfo ^ typevarset).
-pred_info_set_typevarset(PredInfo, X, PredInfo^typevarset := X).
+pred_info_set_typevarset(X, PredInfo, PredInfo ^ typevarset := X).
-pred_info_get_goal_type(PredInfo, PredInfo^goal_type).
+pred_info_get_goal_type(PredInfo, PredInfo ^ goal_type).
pred_info_clause_goal_type(PredInfo) :-
clause_goal_type(PredInfo ^ goal_type).
@@ -1309,10 +1242,11 @@
pragma_goal_type(pragmas).
pragma_goal_type(clauses_and_pragmas).
-pred_info_update_goal_type(PredInfo0, GoalType1, PredInfo) :-
- pred_info_get_goal_type(PredInfo0, GoalType0),
+pred_info_update_goal_type(GoalType1, !PredInfo) :-
+ pred_info_get_goal_type(!.PredInfo, GoalType0),
(
- GoalType0 = none, GoalType = GoalType1
+ GoalType0 = none,
+ GoalType = GoalType1
;
GoalType0 = pragmas,
( clause_goal_type(GoalType1) ->
@@ -1327,16 +1261,15 @@
;
GoalType = clauses
)
-
;
GoalType0 = clauses_and_pragmas,
GoalType = GoalType0
;
GoalType0 = promise(_), error("pred_info_update_goal_type")
),
- pred_info_set_goal_type(PredInfo0, GoalType, PredInfo).
+ pred_info_set_goal_type(GoalType, !PredInfo).
-pred_info_set_goal_type(PredInfo, X, PredInfo^goal_type := X).
+pred_info_set_goal_type(X, PredInfo, PredInfo ^ goal_type := X).
pred_info_requested_inlining(PredInfo0) :-
pred_info_get_markers(PredInfo0, Markers),
@@ -1370,25 +1303,25 @@
purity_to_markers(semipure, [semipure]).
purity_to_markers(impure, [impure]).
-pred_info_get_markers(PredInfo, PredInfo^markers).
+pred_info_get_markers(PredInfo, PredInfo ^ markers).
-pred_info_set_markers(PredInfo, X, PredInfo^markers := X).
+pred_info_set_markers(X, PredInfo, PredInfo ^ markers := X).
pred_info_get_attributes(PredInfo, PredInfo ^ attributes).
-pred_info_set_attributes(PredInfo, X, PredInfo ^ attributes := X).
+pred_info_set_attributes(X, PredInfo, PredInfo ^ attributes := X).
-pred_info_get_is_pred_or_func(PredInfo, PredInfo^is_pred_or_func).
+pred_info_is_pred_or_func(PredInfo) = PredInfo ^ is_pred_or_func.
-pred_info_set_class_context(PredInfo, X, PredInfo^class_context := X).
+pred_info_set_class_context(X, PredInfo, PredInfo ^ class_context := X).
-pred_info_get_class_context(PredInfo, PredInfo^class_context).
+pred_info_get_class_context(PredInfo, PredInfo ^ class_context).
-pred_info_set_constraint_proofs(PredInfo, X, PredInfo^constraint_proofs := X).
+pred_info_set_constraint_proofs(X, PredInfo, PredInfo ^ constraint_proofs := X).
-pred_info_get_constraint_proofs(PredInfo, PredInfo^constraint_proofs).
+pred_info_get_constraint_proofs(PredInfo, PredInfo ^ constraint_proofs).
-pred_info_get_exist_quant_tvars(PredInfo, PredInfo^exist_quant_tvars).
+pred_info_get_exist_quant_tvars(PredInfo, PredInfo ^ exist_quant_tvars).
pred_info_get_univ_quant_tvars(PredInfo, UnivQVars) :-
pred_info_arg_types(PredInfo, ArgTypes),
@@ -1397,55 +1330,54 @@
pred_info_get_exist_quant_tvars(PredInfo, ExistQVars),
list__delete_elems(ArgTypeVars, ExistQVars, UnivQVars).
-pred_info_get_head_type_params(PredInfo, PredInfo^head_type_params).
+pred_info_get_head_type_params(PredInfo, PredInfo ^ head_type_params).
-pred_info_set_head_type_params(PredInfo, X, PredInfo^head_type_params := X).
+pred_info_set_head_type_params(X, PredInfo, PredInfo ^ head_type_params := X).
pred_info_get_unproven_body_constraints(PredInfo,
- PredInfo^unproven_body_constraints).
+ PredInfo ^ unproven_body_constraints).
-pred_info_set_unproven_body_constraints(PredInfo, X,
- PredInfo^unproven_body_constraints := X).
+pred_info_set_unproven_body_constraints(X, PredInfo,
+ PredInfo ^ unproven_body_constraints := X).
-pred_info_get_aditi_owner(PredInfo, PredInfo^aditi_owner).
+pred_info_get_aditi_owner(PredInfo, PredInfo ^ aditi_owner).
-pred_info_set_aditi_owner(PredInfo, X, PredInfo^aditi_owner := X).
+pred_info_set_aditi_owner(X, PredInfo, PredInfo ^ aditi_owner := X).
-pred_info_get_indexes(PredInfo, PredInfo^indexes).
+pred_info_get_indexes(PredInfo, PredInfo ^ indexes).
-pred_info_set_indexes(PredInfo, X, PredInfo^indexes := X).
+pred_info_set_indexes(X, PredInfo, PredInfo ^ indexes := X).
-pred_info_get_assertions(PredInfo, PredInfo^assertions).
+pred_info_get_assertions(PredInfo, PredInfo ^ assertions).
-pred_info_set_assertions(PredInfo, X, PredInfo^assertions := X).
+pred_info_set_assertions(X, PredInfo, PredInfo ^ assertions := X).
-pred_info_get_maybe_special_pred(PredInfo,
- PredInfo^maybe_special_pred).
+pred_info_get_maybe_special_pred(PredInfo, PredInfo ^ maybe_special_pred).
-pred_info_set_maybe_special_pred(PredInfo, X,
- PredInfo^maybe_special_pred := X).
+pred_info_set_maybe_special_pred(X, PredInfo,
+ PredInfo ^ maybe_special_pred := X).
pred_info_get_maybe_instance_method_constraints(PredInfo,
- PredInfo^maybe_instance_method_constraints).
+ PredInfo ^ maybe_instance_method_constraints).
-pred_info_set_maybe_instance_method_constraints(PredInfo, X,
- PredInfo^maybe_instance_method_constraints := X).
+pred_info_set_maybe_instance_method_constraints(X, PredInfo,
+ PredInfo ^ maybe_instance_method_constraints := X).
%-----------------------------------------------------------------------------%
pred_info_get_call_id(PredInfo, PredOrFunc - qualified(Module, Name)/Arity) :-
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
- pred_info_module(PredInfo, Module),
- pred_info_name(PredInfo, Name),
- pred_info_arity(PredInfo, Arity).
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
+ Module = pred_info_module(PredInfo),
+ Name = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo).
%-----------------------------------------------------------------------------%
type_info_locn_var(type_info(Var), Var).
type_info_locn_var(typeclass_info(Var, _), Var).
-type_info_locn_set_var(type_info(_), Var, type_info(Var)).
-type_info_locn_set_var(typeclass_info(_, Num), Var, typeclass_info(Var, Num)).
+type_info_locn_set_var(Var, type_info(_), type_info(Var)).
+type_info_locn_set_var(Var, typeclass_info(_, Num), typeclass_info(Var, Num)).
%-----------------------------------------------------------------------------%
@@ -1472,34 +1404,33 @@
check_attribute(Attributes, Attribute) :-
list__member(Attribute, Attributes).
-add_attribute(Attributes, Attribute, [Attribute | Attributes]).
+add_attribute(Attribute, Attributes, [Attribute | Attributes]).
-remove_attribute(Attributes0, Attribute, Attributes) :-
+remove_attribute(Attribute, Attributes0, Attributes) :-
list__delete_all(Attributes0, Attribute, Attributes).
attributes_to_attribute_list(Attributes, Attributes).
attribute_list_to_attributes(Attributes, Attributes).
-
%-----------------------------------------------------------------------------%
-clauses_info_varset(CI, CI^varset).
-clauses_info_explicit_vartypes(CI, CI^explicit_vartypes).
-clauses_info_vartypes(CI, CI^vartypes).
-clauses_info_headvars(CI, CI^headvars).
-clauses_info_clauses(CI, CI^clauses).
-clauses_info_type_info_varmap(CI, CI^clause_type_info_varmap).
-clauses_info_typeclass_info_varmap(CI, CI^clause_typeclass_info_varmap).
-
-clauses_info_set_varset(CI, X, CI^varset := X).
-clauses_info_set_explicit_vartypes(CI, X, CI^explicit_vartypes := X).
-clauses_info_set_vartypes(CI, X, CI^vartypes := X).
-clauses_info_set_headvars(CI, X, CI^headvars := X).
-clauses_info_set_clauses(CI, X, CI^clauses := X).
-clauses_info_set_type_info_varmap(CI, X, CI^clause_type_info_varmap := X).
-clauses_info_set_typeclass_info_varmap(CI, X,
- CI^clause_typeclass_info_varmap := X).
+clauses_info_varset(CI, CI ^ varset).
+clauses_info_explicit_vartypes(CI, CI ^ explicit_vartypes).
+clauses_info_vartypes(CI, CI ^ vartypes).
+clauses_info_headvars(CI, CI ^ headvars).
+clauses_info_clauses(CI, CI ^ clauses).
+clauses_info_type_info_varmap(CI, CI ^ clause_type_info_varmap).
+clauses_info_typeclass_info_varmap(CI, CI ^ clause_typeclass_info_varmap).
+
+clauses_info_set_varset(X, CI, CI ^ varset := X).
+clauses_info_set_explicit_vartypes(X, CI, CI ^ explicit_vartypes := X).
+clauses_info_set_vartypes(X, CI, CI ^ vartypes := X).
+clauses_info_set_headvars(X, CI, CI ^ headvars := X).
+clauses_info_set_clauses(X, CI, CI ^ clauses := X).
+clauses_info_set_type_info_varmap(X, CI, CI ^ clause_type_info_varmap := X).
+clauses_info_set_typeclass_info_varmap(X, CI,
+ CI ^ clause_typeclass_info_varmap := X).
%-----------------------------------------------------------------------------%
@@ -1561,7 +1492,7 @@
proc_info_create(VarSet, VarTypes, ArgVars, ArgModes, InstVarSet,
MaybeDeclaredDetism, Detism, Goal0, Context,
TVarMap, TCVarMap, IsAddressTaken, ProcInfo0),
- proc_info_set_maybe_termination_info(ProcInfo0, TermInfo, ProcInfo),
+ proc_info_set_maybe_termination_info(TermInfo, ProcInfo0, ProcInfo),
set__init(Assertions),
@@ -1692,207 +1623,181 @@
gen_arg_infos :: table_arg_infos
).
-:- pred proc_info_init(arity, list(type), list(mode), maybe(list(mode)),
- maybe(list(is_live)), maybe(determinism), prog_context,
- is_address_taken, proc_info).
-:- mode proc_info_init(in, in, in, in, in, in, in, in, out) is det.
-
-:- pred proc_info_set(maybe(determinism), prog_varset, vartypes,
- list(prog_var), list(mode), inst_varset, maybe(list(is_live)),
- hlds_goal, prog_context, stack_slots, determinism, bool,
- maybe(list(arg_info)), liveness_info, type_info_varmap,
- typeclass_info_varmap, maybe(arg_size_info),
- maybe(termination_info), is_address_taken, proc_info).
-:- mode proc_info_set(in, in, in, in, in, in, in, in, in, in, in, in,
- in, in, in, in, in, in, in, out) is det.
-
-:- pred proc_info_create(prog_varset, vartypes, list(prog_var),
- list(mode), inst_varset, determinism, hlds_goal, prog_context,
- type_info_varmap, typeclass_info_varmap, is_address_taken, proc_info).
-:- mode proc_info_create(in, in, in, in, in, in, in, in, in, in, in, out)
- is det.
-
-:- pred proc_info_create(prog_varset, vartypes, list(prog_var),
- list(mode), inst_varset, maybe(determinism), determinism,
- hlds_goal, prog_context, type_info_varmap, typeclass_info_varmap,
- is_address_taken, proc_info).
-:- mode proc_info_create(in, in, in, in, in, in, in, in, in, in, in, in, out)
- is det.
-
-:- pred proc_info_set_body(proc_info, prog_varset, vartypes,
- list(prog_var), hlds_goal, type_info_varmap,
- typeclass_info_varmap, proc_info).
-:- mode proc_info_set_body(in, in, in, in, in, in, in, out) is det.
+:- pred proc_info_init(arity::in, list(type)::in, list(mode)::in,
+ maybe(list(mode))::in, maybe(list(is_live))::in,
+ maybe(determinism)::in, prog_context::in, is_address_taken::in,
+ proc_info::out) is det.
+
+:- pred proc_info_set(maybe(determinism)::in, prog_varset::in, vartypes::in,
+ list(prog_var)::in, list(mode)::in, inst_varset::in,
+ maybe(list(is_live))::in, hlds_goal::in, prog_context::in,
+ stack_slots::in, determinism::in, bool::in, maybe(list(arg_info))::in,
+ liveness_info::in, type_info_varmap::in, typeclass_info_varmap::in,
+ maybe(arg_size_info)::in, maybe(termination_info)::in,
+ is_address_taken::in, proc_info::out) is det.
+
+:- pred proc_info_create(prog_varset::in, vartypes::in, list(prog_var)::in,
+ list(mode)::in, inst_varset::in, determinism::in, hlds_goal::in,
+ prog_context::in, type_info_varmap::in, typeclass_info_varmap::in,
+ is_address_taken::in, proc_info::out) is det.
+
+:- pred proc_info_create(prog_varset::in, vartypes::in, list(prog_var)::in,
+ list(mode)::in, inst_varset::in, maybe(determinism)::in,
+ determinism::in, hlds_goal::in, prog_context::in, type_info_varmap::in,
+ typeclass_info_varmap::in, is_address_taken::in, proc_info::out)
+ is det.
+
+:- pred proc_info_set_body(proc_info::in, prog_varset::in, vartypes::in,
+ list(prog_var)::in, hlds_goal::in, type_info_varmap::in,
+ typeclass_info_varmap::in, proc_info::out) is det.
-:- pred proc_info_declared_determinism(proc_info, maybe(determinism)).
-:- mode proc_info_declared_determinism(in, out) is det.
+:- pred proc_info_declared_determinism(proc_info::in,
+ maybe(determinism)::out) is det.
-:- pred proc_info_inferred_determinism(proc_info, determinism).
-:- mode proc_info_inferred_determinism(in, out) is det.
+:- pred proc_info_inferred_determinism(proc_info::in, determinism::out) is det.
% See also proc_info_interface_code_model in code_model.m.
-:- pred proc_info_interface_determinism(proc_info, determinism).
-:- mode proc_info_interface_determinism(in, out) is det.
+:- pred proc_info_interface_determinism(proc_info::in, determinism::out)
+ is det.
% proc_info_never_succeeds(ProcInfo, Result):
% return Result = yes if the procedure is known to never succeed
% according to the declared determinism.
%
-:- pred proc_info_never_succeeds(proc_info, bool).
-:- mode proc_info_never_succeeds(in, out) is det.
+:- pred proc_info_never_succeeds(proc_info::in, bool::out) is det.
-:- pred proc_info_varset(proc_info, prog_varset).
-:- mode proc_info_varset(in, out) is det.
+:- pred proc_info_varset(proc_info::in, prog_varset::out) is det.
-:- pred proc_info_set_varset(proc_info, prog_varset, proc_info).
-:- mode proc_info_set_varset(in, in, out) is det.
+:- pred proc_info_set_varset(prog_varset::in, proc_info::in, proc_info::out)
+ is det.
-:- pred proc_info_vartypes(proc_info, vartypes).
-:- mode proc_info_vartypes(in, out) is det.
+:- pred proc_info_vartypes(proc_info::in, vartypes::out) is det.
-:- pred proc_info_set_vartypes(proc_info, vartypes, proc_info).
-:- mode proc_info_set_vartypes(in, in, out) is det.
+:- pred proc_info_set_vartypes(vartypes::in, proc_info::in, proc_info::out)
+ is det.
-:- pred proc_info_headvars(proc_info, list(prog_var)).
-:- mode proc_info_headvars(in, out) is det.
+:- pred proc_info_headvars(proc_info::in, list(prog_var)::out) is det.
-:- pred proc_info_set_headvars(proc_info, list(prog_var), proc_info).
-:- mode proc_info_set_headvars(in, in, out) is det.
+:- pred proc_info_set_headvars(list(prog_var)::in,
+ proc_info::in, proc_info::out) is det.
-:- pred proc_info_argmodes(proc_info, list(mode)).
-:- mode proc_info_argmodes(in, out) is det.
+:- pred proc_info_argmodes(proc_info::in, list(mode)::out) is det.
-:- pred proc_info_set_argmodes(proc_info, list(mode), proc_info).
-:- mode proc_info_set_argmodes(in, in, out) is det.
+:- pred proc_info_set_argmodes(list(mode)::in, proc_info::in, proc_info::out)
+ is det.
-:- pred proc_info_inst_varset(proc_info, inst_varset).
-:- mode proc_info_inst_varset(in, out) is det.
+:- pred proc_info_inst_varset(proc_info::in, inst_varset::out) is det.
-:- pred proc_info_set_inst_varset(proc_info, inst_varset, proc_info).
-:- mode proc_info_set_inst_varset(in, in, out) is det.
+:- pred proc_info_set_inst_varset(inst_varset::in,
+ proc_info::in, proc_info::out) is det.
-:- pred proc_info_arglives(proc_info, module_info, list(is_live)).
-:- mode proc_info_arglives(in, in, out) is det.
+:- pred proc_info_arglives(proc_info::in, module_info::in, list(is_live)::out)
+ is det.
-:- pred proc_info_maybe_arglives(proc_info, maybe(list(is_live))).
-:- mode proc_info_maybe_arglives(in, out) is det.
+:- pred proc_info_maybe_arglives(proc_info::in, maybe(list(is_live))::out)
+ is det.
-:- pred proc_info_set_maybe_arglives(proc_info, maybe(list(is_live)),
- proc_info).
-:- mode proc_info_set_maybe_arglives(in, in, out) is det.
+:- pred proc_info_set_maybe_arglives(maybe(list(is_live))::in,
+ proc_info::in, proc_info::out) is det.
-:- pred proc_info_goal(proc_info, hlds_goal).
-:- mode proc_info_goal(in, out) is det.
+:- pred proc_info_goal(proc_info::in, hlds_goal::out) is det.
-:- pred proc_info_context(proc_info, prog_context).
-:- mode proc_info_context(in, out) is det.
+:- pred proc_info_context(proc_info::in, prog_context::out) is det.
-:- pred proc_info_stack_slots(proc_info, stack_slots).
-:- mode proc_info_stack_slots(in, out) is det.
+:- pred proc_info_stack_slots(proc_info::in, stack_slots::out) is det.
-:- pred proc_info_liveness_info(proc_info, liveness_info).
-:- mode proc_info_liveness_info(in, out) is det.
+:- pred proc_info_liveness_info(proc_info::in, liveness_info::out) is det.
-:- pred proc_info_can_process(proc_info, bool).
-:- mode proc_info_can_process(in, out) is det.
+:- pred proc_info_can_process(proc_info::in, bool::out) is det.
-:- pred proc_info_set_inferred_determinism(proc_info, determinism, proc_info).
-:- mode proc_info_set_inferred_determinism(in, in, out) is det.
+:- pred proc_info_set_inferred_determinism(determinism::in,
+ proc_info::in, proc_info::out) is det.
-:- pred proc_info_set_goal(proc_info, hlds_goal, proc_info).
-:- mode proc_info_set_goal(in, in, out) is det.
+:- pred proc_info_set_goal(hlds_goal::in, proc_info::in, proc_info::out)
+ is det.
-:- pred proc_info_arg_info(proc_info, list(arg_info)).
-:- mode proc_info_arg_info(in, out) is det.
+:- pred proc_info_arg_info(proc_info::in, list(arg_info)::out) is det.
-:- pred proc_info_maybe_arg_info(proc_info, maybe(list(arg_info))).
-:- mode proc_info_maybe_arg_info(in, out) is det.
+:- pred proc_info_maybe_arg_info(proc_info::in, maybe(list(arg_info))::out)
+ is det.
-:- pred proc_info_set_arg_info(proc_info, list(arg_info), proc_info).
-:- mode proc_info_set_arg_info(in, in, out) is det.
+:- pred proc_info_set_arg_info(list(arg_info)::in,
+ proc_info::in, proc_info::out) is det.
-:- pred proc_info_get_initial_instmap(proc_info, module_info, instmap).
-:- mode proc_info_get_initial_instmap(in, in, out) is det.
+:- pred proc_info_get_initial_instmap(proc_info::in, module_info::in,
+ instmap::out) is det.
-:- pred proc_info_set_liveness_info(proc_info, liveness_info, proc_info).
-:- mode proc_info_set_liveness_info(in, in, out) is det.
+:- pred proc_info_set_liveness_info(liveness_info::in,
+ proc_info::in, proc_info::out) is det.
-:- pred proc_info_set_stack_slots(proc_info, stack_slots, proc_info).
-:- mode proc_info_set_stack_slots(in, in, out) is det.
+:- pred proc_info_set_stack_slots(stack_slots::in,
+ proc_info::in, proc_info::out) is det.
-:- pred proc_info_get_maybe_arg_size_info(proc_info, maybe(arg_size_info)).
-:- mode proc_info_get_maybe_arg_size_info(in, out) is det.
+:- pred proc_info_get_maybe_arg_size_info(proc_info::in,
+ maybe(arg_size_info)::out) is det.
-:- pred proc_info_set_maybe_arg_size_info(proc_info, maybe(arg_size_info),
- proc_info).
-:- mode proc_info_set_maybe_arg_size_info(in, in, out) is det.
+:- pred proc_info_set_maybe_arg_size_info(maybe(arg_size_info)::in,
+ proc_info::in, proc_info::out) is det.
-:- pred proc_info_get_maybe_termination_info(proc_info,
- maybe(termination_info)).
-:- mode proc_info_get_maybe_termination_info(in, out) is det.
+:- pred proc_info_get_maybe_termination_info(proc_info::in,
+ maybe(termination_info)::out) is det.
-:- pred proc_info_set_maybe_termination_info(proc_info,
- maybe(termination_info), proc_info).
-:- mode proc_info_set_maybe_termination_info(in, in, out) is det.
+:- pred proc_info_set_maybe_termination_info(maybe(termination_info)::in,
+ proc_info::in, proc_info::out) is det.
-:- pred proc_info_set_can_process(proc_info, bool, proc_info).
-:- mode proc_info_set_can_process(in, in, out) is det.
+:- pred proc_info_set_can_process(bool::in, proc_info::in, proc_info::out)
+ is det.
-:- pred proc_info_typeinfo_varmap(proc_info, type_info_varmap).
-:- mode proc_info_typeinfo_varmap(in, out) is det.
+:- pred proc_info_typeinfo_varmap(proc_info::in, type_info_varmap::out) is det.
-:- pred proc_info_set_typeinfo_varmap(proc_info, type_info_varmap, proc_info).
-:- mode proc_info_set_typeinfo_varmap(in, in, out) is det.
+:- pred proc_info_set_typeinfo_varmap(type_info_varmap::in,
+ proc_info::in, proc_info::out) is det.
-:- pred proc_info_eval_method(proc_info, eval_method).
-:- mode proc_info_eval_method(in, out) is det.
+:- pred proc_info_eval_method(proc_info::in, eval_method::out) is det.
-:- pred proc_info_set_eval_method(proc_info, eval_method, proc_info).
-:- mode proc_info_set_eval_method(in, in, out) is det.
+:- pred proc_info_set_eval_method(eval_method::in,
+ proc_info::in, proc_info::out) is det.
-:- pred proc_info_typeclass_info_varmap(proc_info, typeclass_info_varmap).
-:- mode proc_info_typeclass_info_varmap(in, out) is det.
+:- pred proc_info_typeclass_info_varmap(proc_info::in,
+ typeclass_info_varmap::out) is det.
-:- pred proc_info_set_typeclass_info_varmap(proc_info, typeclass_info_varmap,
- proc_info).
-:- mode proc_info_set_typeclass_info_varmap(in, in, out) is det.
+:- pred proc_info_set_typeclass_info_varmap(typeclass_info_varmap::in,
+ proc_info::in, proc_info::out) is det.
-:- pred proc_info_maybe_declared_argmodes(proc_info, maybe(list(mode))).
-:- mode proc_info_maybe_declared_argmodes(in, out) is det.
+:- pred proc_info_maybe_declared_argmodes(proc_info::in,
+ maybe(list(mode))::out) is det.
-:- pred proc_info_declared_argmodes(proc_info, list(mode)).
-:- mode proc_info_declared_argmodes(in, out) is det.
+:- pred proc_info_declared_argmodes(proc_info::in, list(mode)::out) is det.
-:- pred proc_info_is_address_taken(proc_info, is_address_taken).
-:- mode proc_info_is_address_taken(in, out) is det.
+:- pred proc_info_is_address_taken(proc_info::in, is_address_taken::out)
+ is det.
-:- pred proc_info_set_address_taken(proc_info, is_address_taken, proc_info).
-:- mode proc_info_set_address_taken(in, in, out) is det.
+:- pred proc_info_set_address_taken(is_address_taken::in,
+ proc_info::in, proc_info::out) is det.
-:- pred proc_info_get_need_maxfr_slot(proc_info, bool).
-:- mode proc_info_get_need_maxfr_slot(in, out) is det.
+:- pred proc_info_get_need_maxfr_slot(proc_info::in, bool::out) is det.
-:- pred proc_info_set_need_maxfr_slot(proc_info, bool, proc_info).
-:- mode proc_info_set_need_maxfr_slot(in, in, out) is det.
+:- pred proc_info_set_need_maxfr_slot(bool::in, proc_info::in, proc_info::out)
+ is det.
-:- pred proc_info_get_call_table_tip(proc_info, maybe(prog_var)).
-:- mode proc_info_get_call_table_tip(in, out) is det.
+:- pred proc_info_get_call_table_tip(proc_info::in, maybe(prog_var)::out)
+ is det.
-:- pred proc_info_set_call_table_tip(proc_info, maybe(prog_var), proc_info).
-:- mode proc_info_set_call_table_tip(in, in, out) is det.
+:- pred proc_info_set_call_table_tip(maybe(prog_var)::in,
+ proc_info::in, proc_info::out) is det.
-:- pred proc_info_get_maybe_proc_table_info(proc_info, maybe(proc_table_info)).
-:- mode proc_info_get_maybe_proc_table_info(in, out) is det.
+:- pred proc_info_get_maybe_proc_table_info(proc_info::in,
+ maybe(proc_table_info)::out) is det.
-:- pred proc_info_set_maybe_proc_table_info(proc_info, maybe(proc_table_info),
- proc_info).
-:- mode proc_info_set_maybe_proc_table_info(in, in, out) is det.
+:- pred proc_info_set_maybe_proc_table_info(maybe(proc_table_info)::in,
+ proc_info::in, proc_info::out) is det.
:- pred proc_info_get_maybe_deep_profile_info(proc_info::in,
maybe(deep_profile_proc_info)::out) is det.
-:- pred proc_info_set_maybe_deep_profile_info(proc_info::in,
- maybe(deep_profile_proc_info)::in, proc_info::out) is det.
+:- pred proc_info_set_maybe_deep_profile_info(
+ maybe(deep_profile_proc_info)::in, proc_info::in, proc_info::out)
+ is det.
% For a set of variables V, find all the type variables in the types
% of the variables in V, and return set of typeinfo variables for
@@ -1902,39 +1807,31 @@
% for accurate garbage collection - live variables need to have
% their typeinfos stay live too.
-:- pred proc_info_get_typeinfo_vars(set(prog_var), vartypes, type_info_varmap,
- set(prog_var)).
-:- mode proc_info_get_typeinfo_vars(in, in, in, out) is det.
+:- pred proc_info_get_typeinfo_vars(set(prog_var)::in, vartypes::in,
+ type_info_varmap::in, set(prog_var)::out) is det.
-:- pred proc_info_maybe_complete_with_typeinfo_vars(set(prog_var), bool,
- vartypes, type_info_varmap, set(prog_var)).
-:- mode proc_info_maybe_complete_with_typeinfo_vars(in, in, in, in, out)
- is det.
+:- pred proc_info_maybe_complete_with_typeinfo_vars(set(prog_var)::in, bool::in,
+ vartypes::in, type_info_varmap::in, set(prog_var)::out) is det.
-:- pred proc_info_ensure_unique_names(proc_info, proc_info).
-:- mode proc_info_ensure_unique_names(in, out) is det.
+:- pred proc_info_ensure_unique_names(proc_info::in, proc_info::out) is det.
% Create a new variable of the given type to the procedure.
-:- pred proc_info_create_var_from_type(proc_info, type, maybe(string),
- prog_var, proc_info).
-:- mode proc_info_create_var_from_type(in, in, in, out, out) is det.
+:- pred proc_info_create_var_from_type((type)::in, maybe(string)::in,
+ prog_var::out, proc_info::in, proc_info::out) is det.
% Create a new variable for each element of the list of types.
-:- pred proc_info_create_vars_from_types(proc_info,
- list(type), list(prog_var), proc_info).
-:- mode proc_info_create_vars_from_types(in, in, out, out) is det.
+:- pred proc_info_create_vars_from_types(list(type)::in, list(prog_var)::out,
+ proc_info::in, proc_info::out) is det.
% Given a procedure, return a list of all its headvars which are
% (further) instantiated by the procedure.
-:- pred proc_info_instantiated_head_vars(module_info, proc_info,
- list(prog_var)).
-:- mode proc_info_instantiated_head_vars(in, in, out) is det.
+:- pred proc_info_instantiated_head_vars(module_info::in, proc_info::in,
+ list(prog_var)::out) is det.
% Given a procedure, return a list of all its headvars which are
% not (further) instantiated by the procedure.
-:- pred proc_info_uninstantiated_head_vars(module_info, proc_info,
- list(prog_var)).
-:- mode proc_info_uninstantiated_head_vars(in, in, out) is det.
+:- pred proc_info_uninstantiated_head_vars(module_info::in, proc_info::in,
+ list(prog_var)::out) is det.
% Return true if the interface of the given procedure must include
% typeinfos for all the type variables in the types of the arguments.
@@ -2011,8 +1908,8 @@
:- implementation.
:- import_module check_hlds__mode_errors.
-:- type proc_info
- ---> procedure(
+:- type proc_info --->
+ procedure(
prog_varset :: prog_varset,
var_types :: vartypes,
head_vars :: list(prog_var),
@@ -2151,9 +2048,8 @@
proc_info_init(Arity, Types, Modes, DeclaredModes, MaybeArgLives,
MaybeDet, MContext, IsAddressTaken, NewProc) :-
- varset__init(BodyVarSet0),
- make_n_fresh_vars("HeadVar__", Arity, BodyVarSet0,
- HeadVars, BodyVarSet),
+ make_n_fresh_vars("HeadVar__", Arity, HeadVars,
+ varset__init, BodyVarSet),
varset__init(InstVarSet),
map__from_corresponding_lists(HeadVars, Types, BodyTypes),
ModeErrors = [],
@@ -2209,12 +2105,12 @@
proc_info_set_body(ProcInfo0, VarSet, VarTypes, HeadVars, Goal,
TI_VarMap, TCI_VarMap, ProcInfo) :-
- ProcInfo = ((((((ProcInfo0^prog_varset := VarSet)
- ^var_types := VarTypes)
- ^head_vars := HeadVars)
- ^body := Goal)
- ^proc_type_info_varmap := TI_VarMap)
- ^proc_typeclass_info_varmap := TCI_VarMap).
+ ProcInfo = ((((((ProcInfo0 ^ prog_varset := VarSet)
+ ^ var_types := VarTypes)
+ ^ head_vars := HeadVars)
+ ^ body := Goal)
+ ^ proc_type_info_varmap := TI_VarMap)
+ ^ proc_typeclass_info_varmap := TCI_VarMap).
proc_info_is_valid_mode(ProcInfo) :-
ProcInfo ^ mode_errors = [].
@@ -2269,70 +2165,72 @@
proc_info_argmodes(ProcInfo, ArgModes)
).
-proc_info_declared_determinism(ProcInfo, ProcInfo^declared_detism).
-proc_info_varset(ProcInfo, ProcInfo^prog_varset).
-proc_info_vartypes(ProcInfo, ProcInfo^var_types).
-proc_info_headvars(ProcInfo, ProcInfo^head_vars).
-proc_info_argmodes(ProcInfo, ProcInfo^actual_head_modes).
-proc_info_inst_varset(ProcInfo, ProcInfo^inst_varset).
-proc_info_maybe_arglives(ProcInfo, ProcInfo^head_var_caller_liveness).
-proc_info_goal(ProcInfo, ProcInfo^body).
-proc_info_context(ProcInfo, ProcInfo^proc_context).
-proc_info_stack_slots(ProcInfo, ProcInfo^stack_slots).
-proc_info_inferred_determinism(ProcInfo, ProcInfo^inferred_detism).
-proc_info_can_process(ProcInfo, ProcInfo^can_process).
-proc_info_maybe_arg_info(ProcInfo, ProcInfo^arg_pass_info).
+proc_info_declared_determinism(ProcInfo, ProcInfo ^ declared_detism).
+proc_info_varset(ProcInfo, ProcInfo ^ prog_varset).
+proc_info_vartypes(ProcInfo, ProcInfo ^ var_types).
+proc_info_headvars(ProcInfo, ProcInfo ^ head_vars).
+proc_info_argmodes(ProcInfo, ProcInfo ^ actual_head_modes).
+proc_info_inst_varset(ProcInfo, ProcInfo ^ inst_varset).
+proc_info_maybe_arglives(ProcInfo, ProcInfo ^ head_var_caller_liveness).
+proc_info_goal(ProcInfo, ProcInfo ^ body).
+proc_info_context(ProcInfo, ProcInfo ^ proc_context).
+proc_info_stack_slots(ProcInfo, ProcInfo ^ stack_slots).
+proc_info_inferred_determinism(ProcInfo, ProcInfo ^ inferred_detism).
+proc_info_can_process(ProcInfo, ProcInfo ^ can_process).
+proc_info_maybe_arg_info(ProcInfo, ProcInfo ^ arg_pass_info).
proc_info_arg_info(ProcInfo, ArgInfo) :-
- ( yes(ArgInfo0) = ProcInfo^arg_pass_info ->
+ ( yes(ArgInfo0) = ProcInfo ^ arg_pass_info ->
ArgInfo = ArgInfo0
;
error("proc_info_arg_info: arg_pass_info not set")
).
-proc_info_liveness_info(ProcInfo, ProcInfo^initial_liveness).
-proc_info_typeinfo_varmap(ProcInfo, ProcInfo^proc_type_info_varmap).
-proc_info_typeclass_info_varmap(ProcInfo, ProcInfo^proc_typeclass_info_varmap).
-proc_info_eval_method(ProcInfo, ProcInfo^eval_method).
-proc_info_get_maybe_arg_size_info(ProcInfo, ProcInfo^maybe_arg_sizes).
-proc_info_get_maybe_termination_info(ProcInfo, ProcInfo^maybe_termination).
-proc_info_maybe_declared_argmodes(ProcInfo, ProcInfo^maybe_declared_head_modes).
-proc_info_is_address_taken(ProcInfo, ProcInfo^is_address_taken).
-proc_info_get_need_maxfr_slot(ProcInfo, ProcInfo^need_maxfr_slot).
-proc_info_get_call_table_tip(ProcInfo, ProcInfo^call_table_tip).
-proc_info_get_maybe_proc_table_info(ProcInfo, ProcInfo^maybe_table_info).
+proc_info_liveness_info(ProcInfo, ProcInfo ^ initial_liveness).
+proc_info_typeinfo_varmap(ProcInfo, ProcInfo ^ proc_type_info_varmap).
+proc_info_typeclass_info_varmap(ProcInfo,
+ ProcInfo ^ proc_typeclass_info_varmap).
+proc_info_eval_method(ProcInfo, ProcInfo ^ eval_method).
+proc_info_get_maybe_arg_size_info(ProcInfo, ProcInfo ^ maybe_arg_sizes).
+proc_info_get_maybe_termination_info(ProcInfo, ProcInfo ^ maybe_termination).
+proc_info_maybe_declared_argmodes(ProcInfo,
+ ProcInfo ^ maybe_declared_head_modes).
+proc_info_is_address_taken(ProcInfo, ProcInfo ^ is_address_taken).
+proc_info_get_need_maxfr_slot(ProcInfo, ProcInfo ^ need_maxfr_slot).
+proc_info_get_call_table_tip(ProcInfo, ProcInfo ^ call_table_tip).
+proc_info_get_maybe_proc_table_info(ProcInfo, ProcInfo ^ maybe_table_info).
proc_info_get_maybe_deep_profile_info(ProcInfo,
- ProcInfo^maybe_deep_profile_proc_info).
+ ProcInfo ^ maybe_deep_profile_proc_info).
-proc_info_set_varset(ProcInfo, VS, ProcInfo^prog_varset := VS).
-proc_info_set_vartypes(ProcInfo, VT, ProcInfo^var_types := VT).
-proc_info_set_headvars(ProcInfo, HV, ProcInfo^head_vars := HV).
-proc_info_set_argmodes(ProcInfo, AM, ProcInfo^actual_head_modes := AM).
-proc_info_set_inst_varset(ProcInfo, IV, ProcInfo^inst_varset := IV).
-proc_info_set_maybe_arglives(ProcInfo, CL,
- ProcInfo^head_var_caller_liveness := CL).
-proc_info_set_goal(ProcInfo, G, ProcInfo^body := G).
-proc_info_set_stack_slots(ProcInfo, SS, ProcInfo^stack_slots := SS).
-proc_info_set_inferred_determinism(ProcInfo, ID,
- ProcInfo^inferred_detism := ID).
-proc_info_set_can_process(ProcInfo, CP, ProcInfo^can_process := CP).
-proc_info_set_arg_info(ProcInfo, AP, ProcInfo^arg_pass_info := yes(AP)).
-proc_info_set_liveness_info(ProcInfo, IL, ProcInfo^initial_liveness := IL).
-proc_info_set_typeinfo_varmap(ProcInfo, TI,
- ProcInfo^proc_type_info_varmap := TI).
-proc_info_set_typeclass_info_varmap(ProcInfo, TC,
- ProcInfo^proc_typeclass_info_varmap := TC).
-proc_info_set_eval_method(ProcInfo, EM, ProcInfo^eval_method := EM).
-proc_info_set_maybe_arg_size_info(ProcInfo, MAS,
- ProcInfo^maybe_arg_sizes := MAS).
-proc_info_set_maybe_termination_info(ProcInfo, MT,
- ProcInfo^maybe_termination := MT).
-proc_info_set_address_taken(ProcInfo, AT, ProcInfo^is_address_taken := AT).
-proc_info_set_need_maxfr_slot(ProcInfo, NMS, ProcInfo^need_maxfr_slot := NMS).
-proc_info_set_call_table_tip(ProcInfo, CTT, ProcInfo^call_table_tip := CTT).
-proc_info_set_maybe_proc_table_info(ProcInfo, MTI,
- ProcInfo^maybe_table_info := MTI).
-proc_info_set_maybe_deep_profile_info(ProcInfo, DPI,
- ProcInfo^maybe_deep_profile_proc_info := DPI).
+proc_info_set_varset(VS, ProcInfo, ProcInfo ^ prog_varset := VS).
+proc_info_set_vartypes(VT, ProcInfo, ProcInfo ^ var_types := VT).
+proc_info_set_headvars(HV, ProcInfo, ProcInfo ^ head_vars := HV).
+proc_info_set_argmodes(AM, ProcInfo, ProcInfo ^ actual_head_modes := AM).
+proc_info_set_inst_varset(IV, ProcInfo, ProcInfo ^ inst_varset := IV).
+proc_info_set_maybe_arglives(CL, ProcInfo,
+ ProcInfo ^ head_var_caller_liveness := CL).
+proc_info_set_goal(G, ProcInfo, ProcInfo ^ body := G).
+proc_info_set_stack_slots(SS, ProcInfo, ProcInfo ^ stack_slots := SS).
+proc_info_set_inferred_determinism(ID, ProcInfo,
+ ProcInfo ^ inferred_detism := ID).
+proc_info_set_can_process(CP, ProcInfo, ProcInfo ^ can_process := CP).
+proc_info_set_arg_info(AP, ProcInfo, ProcInfo ^ arg_pass_info := yes(AP)).
+proc_info_set_liveness_info(IL, ProcInfo, ProcInfo ^ initial_liveness := IL).
+proc_info_set_typeinfo_varmap(TI, ProcInfo,
+ ProcInfo ^ proc_type_info_varmap := TI).
+proc_info_set_typeclass_info_varmap(TC, ProcInfo,
+ ProcInfo ^ proc_typeclass_info_varmap := TC).
+proc_info_set_eval_method(EM, ProcInfo, ProcInfo ^ eval_method := EM).
+proc_info_set_maybe_arg_size_info(MAS, ProcInfo,
+ ProcInfo ^ maybe_arg_sizes := MAS).
+proc_info_set_maybe_termination_info(MT, ProcInfo,
+ ProcInfo ^ maybe_termination := MT).
+proc_info_set_address_taken(AT, ProcInfo, ProcInfo ^ is_address_taken := AT).
+proc_info_set_need_maxfr_slot(NMS, ProcInfo, ProcInfo ^ need_maxfr_slot := NMS).
+proc_info_set_call_table_tip(CTT, ProcInfo, ProcInfo ^ call_table_tip := CTT).
+proc_info_set_maybe_proc_table_info(MTI, ProcInfo,
+ ProcInfo ^ maybe_table_info := MTI).
+proc_info_set_maybe_deep_profile_info(DPI, ProcInfo,
+ ProcInfo ^ maybe_deep_profile_proc_info := DPI).
proc_info_get_typeinfo_vars(Vars, VarTypes, TVarMap, TypeInfoVars) :-
set__to_sorted_list(Vars, VarList),
@@ -2347,8 +2245,7 @@
proc_info_get_typeinfo_vars_2([], _, _, []).
proc_info_get_typeinfo_vars_2([Var | Vars], VarTypes, TVarMap, TypeInfoVars) :-
- ( map__search(VarTypes, Var, Type)
- ->
+ ( map__search(VarTypes, Var, Type) ->
type_util__real_vars(Type, TypeVars),
(
% Optimize common case
@@ -2393,30 +2290,30 @@
Vars = Vars0
).
-proc_info_ensure_unique_names(ProcInfo0, ProcInfo) :-
- proc_info_vartypes(ProcInfo0, VarTypes),
+proc_info_ensure_unique_names(!ProcInfo) :-
+ proc_info_vartypes(!.ProcInfo, VarTypes),
map__keys(VarTypes, AllVars),
- proc_info_varset(ProcInfo0, VarSet0),
+ proc_info_varset(!.ProcInfo, VarSet0),
varset__ensure_unique_names(AllVars, "p", VarSet0, VarSet),
- proc_info_set_varset(ProcInfo0, VarSet, ProcInfo).
+ proc_info_set_varset(VarSet, !ProcInfo).
-proc_info_create_var_from_type(ProcInfo0, Type, MaybeName, NewVar, ProcInfo) :-
- proc_info_varset(ProcInfo0, VarSet0),
- proc_info_vartypes(ProcInfo0, VarTypes0),
+proc_info_create_var_from_type(Type, MaybeName, NewVar, !ProcInfo) :-
+ proc_info_varset(!.ProcInfo, VarSet0),
+ proc_info_vartypes(!.ProcInfo, VarTypes0),
varset__new_maybe_named_var(VarSet0, MaybeName, NewVar, VarSet),
map__det_insert(VarTypes0, NewVar, Type, VarTypes),
- proc_info_set_varset(ProcInfo0, VarSet, ProcInfo1),
- proc_info_set_vartypes(ProcInfo1, VarTypes, ProcInfo).
+ proc_info_set_varset(VarSet, !ProcInfo),
+ proc_info_set_vartypes(VarTypes, !ProcInfo).
-proc_info_create_vars_from_types(ProcInfo0, Types, NewVars, ProcInfo) :-
+proc_info_create_vars_from_types(Types, NewVars, !ProcInfo) :-
list__length(Types, NumVars),
- proc_info_varset(ProcInfo0, VarSet0),
- proc_info_vartypes(ProcInfo0, VarTypes0),
+ proc_info_varset(!.ProcInfo, VarSet0),
+ proc_info_vartypes(!.ProcInfo, VarTypes0),
varset__new_vars(VarSet0, NumVars, NewVars, VarSet),
map__det_insert_from_corresponding_lists(VarTypes0,
NewVars, Types, VarTypes),
- proc_info_set_varset(ProcInfo0, VarSet, ProcInfo1),
- proc_info_set_vartypes(ProcInfo1, VarTypes, ProcInfo).
+ proc_info_set_varset(VarSet, !ProcInfo),
+ proc_info_set_vartypes(VarTypes, !ProcInfo).
proc_info_instantiated_head_vars(ModuleInfo, ProcInfo, ChangedInstHeadVars) :-
proc_info_headvars(ProcInfo, HeadVars),
@@ -2447,9 +2344,9 @@
proc_interface_should_use_typeinfo_liveness(PredInfo, ProcId, Globals,
InterfaceTypeInfoLiveness) :-
- pred_info_module(PredInfo, PredModule),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, PredArity),
+ PredModule = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
+ PredArity = pred_info_arity(PredInfo),
( no_type_info_builtin(PredModule, PredName, PredArity) ->
InterfaceTypeInfoLiveness = no
;
@@ -2493,9 +2390,9 @@
).
body_should_use_typeinfo_liveness(PredInfo, Globals, BodyTypeInfoLiveness) :-
- pred_info_module(PredInfo, PredModule),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, PredArity),
+ PredModule = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
+ PredArity = pred_info_arity(PredInfo),
( no_type_info_builtin(PredModule, PredName, PredArity) ->
BodyTypeInfoLiveness = no
;
@@ -2638,46 +2535,41 @@
% "<Name>3", and so on, where <Name> is the value of `Name'.
% `VarSet' is the resulting varset.
-:- pred make_n_fresh_vars(string, int, varset(T), list(var(T)), varset(T)).
-:- mode make_n_fresh_vars(in, in, in, out, out) is det.
+:- pred make_n_fresh_vars(string::in, int::in, list(var(T))::out,
+ varset(T)::in, varset(T)::out) is det.
% given the list of predicate arguments for a predicate that
% is really a function, split that list into the function arguments
% and the function return type.
-:- pred pred_args_to_func_args(list(T), list(T), T).
-:- mode pred_args_to_func_args(in, out, out) is det.
+:- pred pred_args_to_func_args(list(T)::in, list(T)::out, T::out) is det.
% Get the last two arguments from the list, failing if there
% aren't at least two arguments.
-:- pred get_state_args(list(T), list(T), T, T).
-:- mode get_state_args(in, out, out, out) is semidet.
+:- pred get_state_args(list(T)::in, list(T)::out, T::out, T::out) is semidet.
% Get the last two arguments from the list, aborting if there
% aren't at least two arguments.
-:- pred get_state_args_det(list(T), list(T), T, T).
-:- mode get_state_args_det(in, out, out, out) is det.
+:- pred get_state_args_det(list(T)::in, list(T)::out, T::out, T::out) is det.
:- implementation.
-make_n_fresh_vars(BaseName, N, VarSet0, Vars, VarSet) :-
- make_n_fresh_vars_2(BaseName, 0, N, VarSet0, Vars, VarSet).
+make_n_fresh_vars(BaseName, N, Vars, VarSet0, VarSet) :-
+ make_n_fresh_vars_2(BaseName, 0, N, Vars, VarSet0, VarSet).
-:- pred make_n_fresh_vars_2(string, int, int, varset(T), list(var(T)),
- varset(T)).
-:- mode make_n_fresh_vars_2(in, in, in, in, out, out) is det.
+:- pred make_n_fresh_vars_2(string::in, int::in, int::in, list(var(T))::out,
+ varset(T)::in, varset(T)::out) is det.
-make_n_fresh_vars_2(BaseName, N, Max, VarSet0, Vars, VarSet) :-
+make_n_fresh_vars_2(BaseName, N, Max, Vars, !VarSet) :-
(N = Max ->
- VarSet = VarSet0,
Vars = []
;
N1 = N + 1,
- varset__new_var(VarSet0, Var, VarSet1),
+ varset__new_var(!.VarSet, Var, !:VarSet),
string__int_to_string(N1, Num),
string__append(BaseName, Num, VarName),
- varset__name_var(VarSet1, Var, VarName, VarSet2),
+ varset__name_var(!.VarSet, Var, VarName, !:VarSet),
Vars = [Var | Vars1],
- make_n_fresh_vars_2(BaseName, N1, Max, VarSet2, Vars1, VarSet)
+ make_n_fresh_vars_2(BaseName, N1, Max, Vars1, !VarSet)
).
pred_args_to_func_args(PredArgs, FuncArgs, FuncReturn) :-
@@ -2712,31 +2604,29 @@
% field_extraction_function_args(Args, InputTermArg).
% Work out which arguments of a field access correspond to the
% field being extracted/set, and which are the container arguments.
-:- pred field_extraction_function_args(list(prog_var), prog_var).
-:- mode field_extraction_function_args(in, out) is det.
+:- pred field_extraction_function_args(list(prog_var)::in, prog_var::out)
+ is det.
% field_update_function_args(Args, InputTermArg, FieldArg).
-:- pred field_update_function_args(list(prog_var), prog_var, prog_var).
-:- mode field_update_function_args(in, out, out) is det.
+:- pred field_update_function_args(list(prog_var)::in, prog_var::out,
+ prog_var::out) is det.
% field_access_function_name(AccessType, FieldName, FuncName).
%
% From the access type and the name of the field,
% construct a function name.
-:- pred field_access_function_name(field_access_type,
- ctor_field_name, sym_name).
-:- mode field_access_function_name(in, in, out) is det.
+:- pred field_access_function_name(field_access_type::in, ctor_field_name::in,
+ sym_name::out) is det.
% is_field_access_function_name(ModuleInfo, FuncName, Arity,
% AccessType, FieldName).
%
% Inverse of the above.
-:- pred is_field_access_function_name(module_info, sym_name, arity,
- field_access_type, ctor_field_name).
-:- mode is_field_access_function_name(in, in, out, out, out) is semidet.
+:- pred is_field_access_function_name(module_info::in, sym_name::in,
+ arity::out, field_access_type::out, ctor_field_name::out) is semidet.
-:- pred pred_info_is_field_access_function(module_info, pred_info).
-:- mode pred_info_is_field_access_function(in, in) is semidet.
+:- pred pred_info_is_field_access_function(module_info::in, pred_info::in)
+ is semidet.
:- implementation.
@@ -2774,10 +2664,10 @@
map__contains(CtorFieldTable, FieldName).
pred_info_is_field_access_function(ModuleInfo, PredInfo) :-
- pred_info_get_is_pred_or_func(PredInfo, function),
- pred_info_module(PredInfo, Module),
- pred_info_name(PredInfo, Name),
- pred_info_arity(PredInfo, PredArity),
+ pred_info_is_pred_or_func(PredInfo) = function,
+ Module = pred_info_module(PredInfo),
+ Name = pred_info_name(PredInfo),
+ PredArity = pred_info_arity(PredInfo),
adjust_func_arity(function, FuncArity, PredArity),
is_field_access_function_name(ModuleInfo, qualified(Module, Name),
FuncArity, _, _).
@@ -2793,39 +2683,35 @@
% or index predicates generated as a type-specific instance of
% unify/2, index/2, or compare/3).
-:- pred is_unify_or_compare_pred(pred_info).
-:- mode is_unify_or_compare_pred(in) is semidet.
+:- pred is_unify_or_compare_pred(pred_info::in) is semidet.
% Is the argument the pred_info for a builtin that can be
% generated inline?
-:- pred pred_info_is_builtin(pred_info).
-:- mode pred_info_is_builtin(in) is semidet.
+:- pred pred_info_is_builtin(pred_info::in) is semidet.
% builtin_state(ModuleInfo, CallerPredId,
% PredId, ProcId, BuiltinState)
%
% Is the given procedure a builtin that should be generated inline
% in the given caller?
-:- pred builtin_state(module_info, pred_id, pred_id, proc_id, builtin_state).
-:- mode builtin_state(in, in, in, in, out) is det.
+:- func builtin_state(module_info, pred_id, pred_id, proc_id) = builtin_state.
:- implementation.
:- import_module backend_libs__builtin_ops, hlds__special_pred.
pred_info_is_builtin(PredInfo) :-
- pred_info_module(PredInfo, ModuleName),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, Arity),
- hlds_pred__initial_proc_id(ProcId),
+ ModuleName = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo),
+ ProcId = hlds_pred__initial_proc_id,
is_inline_builtin(ModuleName, PredName, ProcId, Arity).
-builtin_state(ModuleInfo, CallerPredId,
- PredId, ProcId, BuiltinState) :-
+builtin_state(ModuleInfo, CallerPredId, PredId, ProcId) = BuiltinState :-
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_module(PredInfo, ModuleName),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, Arity),
+ ModuleName = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo),
module_info_globals(ModuleInfo, Globals),
globals__lookup_bool_option(Globals, inline_builtins, InlineBuiltins),
(
@@ -2843,8 +2729,8 @@
BuiltinState = not_builtin
).
-:- pred is_inline_builtin(module_name, string, proc_id, arity).
-:- mode is_inline_builtin(in, in, in, in) is semidet.
+:- pred is_inline_builtin(module_name::in, string::in, proc_id::in, arity::in)
+ is semidet.
is_inline_builtin(ModuleName, PredName, ProcId, Arity) :-
Arity =< 3,
@@ -2935,16 +2821,16 @@
hlds_pred__pred_info_is_aditi_aggregate(PredInfo).
hlds_pred__pred_info_is_aditi_aggregate(PredInfo) :-
- pred_info_module(PredInfo, Module),
- pred_info_name(PredInfo, Name),
- pred_info_arity(PredInfo, Arity),
+ Module = pred_info_module(PredInfo),
+ Name = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo),
hlds_pred__aditi_aggregate(Module, Name, Arity).
-:- pred hlds_pred__aditi_aggregate(sym_name, string, int).
-:- mode hlds_pred__aditi_aggregate(in, in, in) is semidet.
+:- pred hlds_pred__aditi_aggregate(sym_name::in, string::in, int::in)
+ is semidet.
-hlds_pred__aditi_aggregate(unqualified("aditi"),
- "aggregate_compute_initial", 5).
+hlds_pred__aditi_aggregate(unqualified("aditi"), "aggregate_compute_initial",
+ 5).
hlds_pred__is_aditi_memoed(ModuleInfo, PredId) :-
% XXX memoing doesn't work yet.
Index: compiler/inlining.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/inlining.m,v
retrieving revision 1.111
diff -u -b -r1.111 inlining.m
--- compiler/inlining.m 26 May 2003 08:59:57 -0000 1.111
+++ compiler/inlining.m 21 Oct 2003 13:06:52 -0000
@@ -476,12 +476,12 @@
TypeVarSet, TypeInfoVarMap, DidInlining, Requantify,
DetChanged, PurityChanged),
- pred_info_set_typevarset(PredInfo0, TypeVarSet, PredInfo1),
+ pred_info_set_typevarset(TypeVarSet, PredInfo0, PredInfo1),
- proc_info_set_varset(ProcInfo0, VarSet, ProcInfo1),
- proc_info_set_vartypes(ProcInfo1, VarTypes, ProcInfo2),
- proc_info_set_typeinfo_varmap(ProcInfo2, TypeInfoVarMap, ProcInfo3),
- proc_info_set_goal(ProcInfo3, Goal, ProcInfo4),
+ proc_info_set_varset(VarSet, ProcInfo0, ProcInfo1),
+ proc_info_set_vartypes(VarTypes, ProcInfo1, ProcInfo2),
+ proc_info_set_typeinfo_varmap(TypeInfoVarMap, ProcInfo2, ProcInfo3),
+ proc_info_set_goal(Goal, ProcInfo3, ProcInfo4),
(
Requantify = yes,
@@ -502,7 +502,7 @@
),
map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable),
- pred_info_set_procedures(PredInfo1, ProcTable, PredInfo2),
+ pred_info_set_procedures(ProcTable, PredInfo1, PredInfo2),
(
PurityChanged = yes,
Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.147
diff -u -b -r1.147 intermod.m
--- compiler/intermod.m 20 Oct 2003 07:29:06 -0000 1.147
+++ compiler/intermod.m 21 Oct 2003 16:20:58 -0000
@@ -293,10 +293,10 @@
{ DoWrite = no }
),
( { DoWrite = yes } ->
- { clauses_info_set_clauses(ClausesInfo0, Clauses,
- ClausesInfo) },
- { pred_info_set_clauses_info(PredInfo0, ClausesInfo,
- PredInfo) },
+ { clauses_info_set_clauses(Clauses,
+ ClausesInfo0, ClausesInfo) },
+ { pred_info_set_clauses_info(ClausesInfo,
+ PredInfo0, PredInfo) },
{ map__det_update(PredTable0, PredId,
PredInfo, PredTable) },
{ module_info_set_preds(ModuleInfo0, PredTable,
@@ -344,7 +344,7 @@
pred_info_clauses_info(PredInfo, ClauseInfo),
clauses_info_clauses(ClauseInfo, Clauses),
- pred_info_procids(PredInfo, [ProcId | _ProcIds]),
+ [ProcId | _ProcIds] = pred_info_procids(PredInfo),
pred_info_procedures(PredInfo, Procs),
map__lookup(Procs, ProcId, ProcInfo),
@@ -352,7 +352,7 @@
% HeadVar1 = X, HeadVar2 = Y, etc. which will be optimized away
% later. To counter for this, we add the arity to the
% size thresholds.
- pred_info_arity(PredInfo, Arity),
+ Arity = pred_info_arity(PredInfo),
% Predicates with `class_method' markers contain
% class_method_call goals which can't be written
@@ -589,7 +589,7 @@
intermod_info::in, intermod_info::out) is det.
intermod__add_proc(PredId, DoWrite) -->
- ( { invalid_pred_id(PredId) } ->
+ ( { PredId = invalid_pred_id } ->
% This will happen for type class instance methods
% defined using the clause syntax. Currently we
% can't handle intermodule-optimization of those.
@@ -605,7 +605,7 @@
intermod_info_get_module_info(ModuleInfo),
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
{ pred_info_import_status(PredInfo, Status) },
- { pred_info_procids(PredInfo, ProcIds) },
+ { ProcIds = pred_info_procids(PredInfo) },
{ pred_info_get_markers(PredInfo, Markers) },
(
%
@@ -705,7 +705,7 @@
% imported pred - add import for module
%
{ DoWrite = yes },
- { pred_info_module(PredInfo, PredModule) },
+ { PredModule = pred_info_module(PredInfo) },
intermod_info_get_modules(Modules0),
{ set__insert(Modules0, PredModule, Modules) },
intermod_info_set_modules(Modules)
@@ -893,7 +893,7 @@
;
% This will force intermod__add_proc to
% return DoWrite = no
- invalid_pred_id(PredId),
+ PredId = invalid_pred_id,
PredIds = [PredId | PredIds0],
% We can just leave the method definition unchanged
@@ -918,7 +918,7 @@
% syntax.
%
% This will force intermod__add_proc to return DoWrite = no
- invalid_pred_id(PredId),
+ PredId = invalid_pred_id,
PredIds = [PredId | PredIds0],
% We can just leave the method definition unchanged
InstanceMethodDefn = InstanceMethodDefn0
@@ -1487,12 +1487,12 @@
intermod__write_pred_decls(_, []) --> [].
intermod__write_pred_decls(ModuleInfo, [PredId | PredIds]) -->
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_module(PredInfo, Module) },
- { pred_info_name(PredInfo, Name) },
+ { Module = pred_info_module(PredInfo) },
+ { Name = pred_info_name(PredInfo) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
{ pred_info_arg_types(PredInfo, TVarSet, ExistQVars, ArgTypes) },
{ pred_info_context(PredInfo, Context) },
{ pred_info_get_purity(PredInfo, Purity) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
{ pred_info_get_class_context(PredInfo, ClassContext) },
{ pred_info_get_goal_type(PredInfo, GoalType) },
{
@@ -1532,7 +1532,7 @@
AppendVarNums)
),
{ pred_info_procedures(PredInfo, Procs) },
- { pred_info_procids(PredInfo, ProcIds) },
+ { ProcIds = pred_info_procids(PredInfo) },
% Make sure the mode declarations go out in the same
% order they came in, so that the all the modes get the
% same proc_id in the importing modules.
@@ -1585,10 +1585,10 @@
intermod__write_preds(_, []) --> [].
intermod__write_preds(ModuleInfo, [PredId | PredIds]) -->
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_module(PredInfo, Module) },
- { pred_info_name(PredInfo, Name) },
+ { Module = pred_info_module(PredInfo) },
+ { Name = pred_info_name(PredInfo) },
{ SymName = qualified(Module, Name) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
intermod__write_pragmas(PredInfo),
% The type specialization pragmas for exported preds should
% already be in the interface file.
@@ -1777,13 +1777,13 @@
io__state::di, io__state::uo) is det.
intermod__write_pragmas(PredInfo) -->
- { pred_info_module(PredInfo, Module) },
- { pred_info_name(PredInfo, Name) },
- { pred_info_arity(PredInfo, Arity) },
+ { Module = pred_info_module(PredInfo) },
+ { Name = pred_info_name(PredInfo) },
+ { Arity = pred_info_arity(PredInfo) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
{ SymName = qualified(Module, Name) },
{ pred_info_get_markers(PredInfo, Markers) },
{ markers_to_marker_list(Markers, MarkerList) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
intermod__write_pragmas(SymName, Arity, MarkerList, PredOrFunc).
:- pred intermod__write_pragmas(sym_name::in, int::in, list(marker)::in,
@@ -2182,7 +2182,7 @@
;
NewStatus = opt_exported
),
- pred_info_set_import_status(PredInfo0, NewStatus, PredInfo),
+ pred_info_set_import_status(NewStatus, PredInfo0, PredInfo),
map__det_update(Preds0, PredId, PredInfo, Preds1)
;
Preds1 = Preds0
Index: compiler/lambda.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/lambda.m,v
retrieving revision 1.83
diff -u -b -r1.83 lambda.m
--- compiler/lambda.m 20 Oct 2003 07:29:06 -0000 1.83
+++ compiler/lambda.m 21 Oct 2003 13:14:08 -0000
@@ -148,7 +148,7 @@
lambda__process_pred(PredId, ModuleInfo0, ModuleInfo) :-
module_info_pred_info(ModuleInfo0, PredId, PredInfo),
- pred_info_procids(PredInfo, ProcIds),
+ ProcIds = pred_info_procids(PredInfo),
lambda__process_procs(PredId, ProcIds, ModuleInfo0, ModuleInfo).
:- pred lambda__process_procs(pred_id, list(proc_id), module_info, module_info).
@@ -168,52 +168,50 @@
pred_info_procedures(PredInfo0, ProcTable0),
map__lookup(ProcTable0, ProcId, ProcInfo0),
- lambda__process_proc_2(ProcInfo0, PredInfo0, ModuleInfo0,
- ProcInfo, PredInfo1, ModuleInfo1),
+ lambda__process_proc_2(ProcInfo0, ProcInfo, PredInfo0, PredInfo1,
+ ModuleInfo0, ModuleInfo1),
pred_info_procedures(PredInfo1, ProcTable1),
map__det_update(ProcTable1, ProcId, ProcInfo, ProcTable),
- pred_info_set_procedures(PredInfo1, ProcTable, PredInfo),
+ pred_info_set_procedures(ProcTable, PredInfo1, PredInfo),
module_info_preds(ModuleInfo1, PredTable1),
map__det_update(PredTable1, PredId, PredInfo, PredTable),
module_info_set_preds(ModuleInfo1, PredTable, ModuleInfo).
-:- pred lambda__process_proc_2(proc_info, pred_info, module_info,
- proc_info, pred_info, module_info).
-:- mode lambda__process_proc_2(in, in, in, out, out, out) is det.
+:- pred lambda__process_proc_2(proc_info::in, proc_info::out,
+ pred_info::in, pred_info::out, module_info::in, module_info::out)
+ is det.
-lambda__process_proc_2(ProcInfo0, PredInfo0, ModuleInfo0,
- ProcInfo, PredInfo, ModuleInfo) :-
+lambda__process_proc_2(!ProcInfo, !PredInfo, !ModuleInfo) :-
% grab the appropriate fields from the pred_info and proc_info
- pred_info_name(PredInfo0, PredName),
- pred_info_get_is_pred_or_func(PredInfo0, PredOrFunc),
- pred_info_typevarset(PredInfo0, TypeVarSet0),
- pred_info_get_markers(PredInfo0, Markers),
- pred_info_get_class_context(PredInfo0, Constraints0),
- pred_info_get_aditi_owner(PredInfo0, Owner),
- proc_info_headvars(ProcInfo0, HeadVars),
- proc_info_varset(ProcInfo0, VarSet0),
- proc_info_vartypes(ProcInfo0, VarTypes0),
- proc_info_goal(ProcInfo0, Goal0),
- proc_info_typeinfo_varmap(ProcInfo0, TVarMap0),
- proc_info_typeclass_info_varmap(ProcInfo0, TCVarMap0),
- proc_info_inst_varset(ProcInfo0, InstVarSet0),
+ PredName = pred_info_name(!.PredInfo),
+ PredOrFunc = pred_info_is_pred_or_func(!.PredInfo),
+ pred_info_typevarset(!.PredInfo, TypeVarSet0),
+ pred_info_get_markers(!.PredInfo, Markers),
+ pred_info_get_class_context(!.PredInfo, Constraints0),
+ pred_info_get_aditi_owner(!.PredInfo, Owner),
+ proc_info_headvars(!.ProcInfo, HeadVars),
+ proc_info_varset(!.ProcInfo, VarSet0),
+ proc_info_vartypes(!.ProcInfo, VarTypes0),
+ proc_info_goal(!.ProcInfo, Goal0),
+ proc_info_typeinfo_varmap(!.ProcInfo, TVarMap0),
+ proc_info_typeclass_info_varmap(!.ProcInfo, TCVarMap0),
+ proc_info_inst_varset(!.ProcInfo, InstVarSet0),
MustRecomputeNonLocals0 = no,
% process the goal
Info0 = lambda_info(VarSet0, VarTypes0, Constraints0, TypeVarSet0,
InstVarSet0, TVarMap0, TCVarMap0, Markers, PredOrFunc,
- PredName, Owner, ModuleInfo0, MustRecomputeNonLocals0),
+ PredName, Owner, !.ModuleInfo, MustRecomputeNonLocals0),
lambda__process_goal(Goal0, Goal1, Info0, Info1),
Info1 = lambda_info(VarSet1, VarTypes1, Constraints, TypeVarSet,
- _, TVarMap, TCVarMap, _, _, _, _, ModuleInfo,
+ _, TVarMap, TCVarMap, _, _, _, _, !:ModuleInfo,
MustRecomputeNonLocals),
% check if we need to requantify
( MustRecomputeNonLocals = yes ->
- implicitly_quantify_clause_body(HeadVars,
- Goal1, VarSet1, VarTypes1,
- Goal, VarSet, VarTypes, _Warnings)
+ implicitly_quantify_clause_body(HeadVars, _Warnings,
+ Goal1, Goal, VarSet1, VarSet, VarTypes1, VarTypes)
;
Goal = Goal1,
VarSet = VarSet1,
@@ -221,13 +219,13 @@
),
% set the new values of the fields in proc_info and pred_info
- proc_info_set_goal(ProcInfo0, Goal, ProcInfo1),
- proc_info_set_varset(ProcInfo1, VarSet, ProcInfo2),
- proc_info_set_vartypes(ProcInfo2, VarTypes, ProcInfo3),
- proc_info_set_typeinfo_varmap(ProcInfo3, TVarMap, ProcInfo4),
- proc_info_set_typeclass_info_varmap(ProcInfo4, TCVarMap, ProcInfo),
- pred_info_set_typevarset(PredInfo0, TypeVarSet, PredInfo1),
- pred_info_set_class_context(PredInfo1, Constraints, PredInfo).
+ proc_info_set_goal(Goal, !ProcInfo),
+ proc_info_set_varset(VarSet, !ProcInfo),
+ proc_info_set_vartypes(VarTypes, !ProcInfo),
+ proc_info_set_typeinfo_varmap(TVarMap, !ProcInfo),
+ proc_info_set_typeclass_info_varmap(TCVarMap, !ProcInfo),
+ pred_info_set_typevarset(TypeVarSet, !PredInfo),
+ pred_info_set_class_context(Constraints, !PredInfo).
:- pred lambda__process_goal(hlds_goal, hlds_goal,
lambda_info, lambda_info).
@@ -430,8 +428,8 @@
)
;
HighLevelCode = yes,
- pred_info_get_is_pred_or_func(Call_PredInfo,
- Call_PredOrFunc),
+ Call_PredOrFunc =
+ pred_info_is_pred_or_func(Call_PredInfo),
PredOrFunc = Call_PredOrFunc,
CodeModel = Call_CodeModel
),
@@ -453,8 +451,8 @@
% we need to mark the procedure as having had its
% address taken
%
- proc_info_set_address_taken(Call_ProcInfo, address_is_taken,
- Call_NewProcInfo),
+ proc_info_set_address_taken(address_is_taken,
+ Call_ProcInfo, Call_NewProcInfo),
module_info_set_pred_proc_info(ModuleInfo0, PredId, ProcId,
Call_PredInfo, Call_NewProcInfo, ModuleInfo)
;
Index: compiler/liveness.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/liveness.m,v
retrieving revision 1.124
diff -u -b -r1.124 liveness.m
--- compiler/liveness.m 15 Mar 2003 07:11:56 -0000 1.124
+++ compiler/liveness.m 21 Oct 2003 14:48:58 -0000
@@ -211,14 +211,13 @@
:- import_module bool, string, map, std_util, list, assoc_list, require.
:- import_module term, varset.
-detect_liveness_proc(PredId, _ProcId, ModuleInfo, ProcInfo0, ProcInfo,
- IO0, IO) :-
- requantify_proc(ProcInfo0, ProcInfo1),
-
- proc_info_goal(ProcInfo1, Goal0),
- proc_info_varset(ProcInfo1, VarSet),
- proc_info_vartypes(ProcInfo1, VarTypes),
- proc_info_typeinfo_varmap(ProcInfo1, TVarMap),
+detect_liveness_proc(PredId, _ProcId, ModuleInfo, !ProcInfo, !IO) :-
+ requantify_proc(!ProcInfo),
+
+ proc_info_goal(!.ProcInfo, Goal0),
+ proc_info_varset(!.ProcInfo, VarSet),
+ proc_info_vartypes(!.ProcInfo, VarTypes),
+ proc_info_typeinfo_varmap(!.ProcInfo, TVarMap),
module_info_globals(ModuleInfo, Globals),
module_info_pred_info(ModuleInfo, PredId, PredInfo),
body_should_use_typeinfo_liveness(PredInfo, Globals, TypeInfoLiveness),
@@ -228,20 +227,20 @@
globals__lookup_int_option(Globals, debug_liveness, DebugLiveness),
pred_id_to_int(PredId, PredIdInt),
maybe_write_progress_message("\nbefore liveness",
- DebugLiveness, PredIdInt, Goal0, VarSet, ModuleInfo, IO0, IO1),
+ DebugLiveness, PredIdInt, Goal0, VarSet, ModuleInfo, !IO),
- initial_liveness(ProcInfo1, PredId, ModuleInfo, Liveness0),
+ initial_liveness(!.ProcInfo, PredId, ModuleInfo, Liveness0),
detect_liveness_in_goal(Goal0, Liveness0, LiveInfo,
_, Goal1),
maybe_write_progress_message("\nafter liveness",
- DebugLiveness, PredIdInt, Goal1, VarSet, ModuleInfo, IO1, IO2),
+ DebugLiveness, PredIdInt, Goal1, VarSet, ModuleInfo, !IO),
- initial_deadness(ProcInfo1, LiveInfo, ModuleInfo, Deadness0),
+ initial_deadness(!.ProcInfo, LiveInfo, ModuleInfo, Deadness0),
detect_deadness_in_goal(Goal1, Deadness0, Liveness0, LiveInfo,
_, Goal2),
maybe_write_progress_message("\nafter deadness",
- DebugLiveness, PredIdInt, Goal2, VarSet, ModuleInfo, IO2, IO3),
+ DebugLiveness, PredIdInt, Goal2, VarSet, ModuleInfo, !IO),
(
globals__get_trace_level(Globals, TraceLevel),
@@ -253,24 +252,23 @@
delay_death_proc_body(Goal2, VarSet, Liveness0, Goal3),
maybe_write_progress_message("\nafter delay death",
DebugLiveness, PredIdInt, Goal3, VarSet, ModuleInfo,
- IO3, IO4)
+ !IO)
;
- Goal3 = Goal2,
- IO4 = IO3
+ Goal3 = Goal2
),
globals__get_trace_level(Globals, TraceLevel),
- ( eff_trace_level_is_none(PredInfo, ProcInfo1, TraceLevel) = no ->
- trace__fail_vars(ModuleInfo, ProcInfo1, ResumeVars0)
+ ( eff_trace_level_is_none(PredInfo, !.ProcInfo, TraceLevel) = no ->
+ trace__fail_vars(ModuleInfo, !.ProcInfo, ResumeVars0)
;
set__init(ResumeVars0)
),
detect_resume_points_in_goal(Goal3, Liveness0, LiveInfo,
ResumeVars0, Goal, _),
maybe_write_progress_message("\nafter resume point",
- DebugLiveness, PredIdInt, Goal, VarSet, ModuleInfo, IO4, IO),
- proc_info_set_goal(ProcInfo1, Goal, ProcInfo2),
- proc_info_set_liveness_info(ProcInfo2, Liveness0, ProcInfo).
+ DebugLiveness, PredIdInt, Goal, VarSet, ModuleInfo, !IO),
+ proc_info_set_goal(Goal, !ProcInfo),
+ proc_info_set_liveness_info(Liveness0, !ProcInfo).
:- pred maybe_write_progress_message(string::in, int::in, int::in,
hlds_goal::in, prog_varset::in, module_info::in,
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.217
diff -u -b -r1.217 llds_out.m
--- compiler/llds_out.m 20 Oct 2003 07:29:07 -0000 1.217
+++ compiler/llds_out.m 21 Oct 2003 09:55:07 -0000
@@ -1509,26 +1509,25 @@
% output_instruction_and_comment/5 is only for debugging.
% Normally we use output_instruction_and_comment/6.
-output_instruction_and_comment(Instr, Comment, PrintComments) -->
- { bintree_set__init(ContLabelSet) },
- { hlds_pred__initial_proc_id(ProcId) },
- { DummyModule = unqualified("DEBUG") },
- { DummyPredName = "DEBUG" },
- { ProfInfo = local(proc(DummyModule, predicate, DummyModule,
- DummyPredName, 0, ProcId)) - ContLabelSet },
- output_instruction_and_comment(Instr, Comment, PrintComments, ProfInfo).
+output_instruction_and_comment(Instr, Comment, PrintComments, !IO) :-
+ bintree_set__init(ContLabelSet),
+ DummyModule = unqualified("DEBUG"),
+ DummyPredName = "DEBUG",
+ ProfInfo = local(proc(DummyModule, predicate, DummyModule,
+ DummyPredName, 0, hlds_pred__initial_proc_id)) - ContLabelSet,
+ output_instruction_and_comment(Instr, Comment, PrintComments,
+ ProfInfo, !IO).
% output_instruction/3 is only for debugging.
% Normally we use output_instruction/4.
-output_instruction(Instr) -->
- { bintree_set__init(ContLabelSet) },
- { hlds_pred__initial_proc_id(ProcId) },
- { DummyModule = unqualified("DEBUG") },
- { DummyPredName = "DEBUG" },
- { ProfInfo = local(proc(DummyModule, predicate, DummyModule,
- DummyPredName, 0, ProcId)) - ContLabelSet },
- output_instruction(Instr, ProfInfo).
+output_instruction(Instr, !IO) :-
+ bintree_set__init(ContLabelSet),
+ DummyModule = unqualified("DEBUG"),
+ DummyPredName = "DEBUG",
+ ProfInfo = local(proc(DummyModule, predicate, DummyModule,
+ DummyPredName, 0, hlds_pred__initial_proc_id)) - ContLabelSet,
+ output_instruction(Instr, ProfInfo, !IO).
:- pred output_instruction(instr, pair(label, bintree_set(label)),
io__state, io__state).
Index: compiler/loop_inv.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/loop_inv.m,v
retrieving revision 1.4
diff -u -b -r1.4 loop_inv.m
--- compiler/loop_inv.m 15 Mar 2003 03:08:56 -0000 1.4
+++ compiler/loop_inv.m 21 Oct 2003 13:15:54 -0000
@@ -751,7 +751,7 @@
hlds_pred__pred_info_get_markers(PredInfo, Markers),
hlds_pred__pred_info_get_aditi_owner(PredInfo, Owner),
- hlds_pred__pred_info_name(PredInfo, PredName),
+ PredName = hlds_pred__pred_info_name(PredInfo),
hlds_goal__goal_info_get_context(GoalInfo, Context),
term__context_line(Context, Line),
hlds_pred__proc_id_to_int(ProcId, ProcNo),
Index: compiler/magic.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/magic.m,v
retrieving revision 1.37
diff -u -b -r1.37 magic.m
--- compiler/magic.m 23 Jul 2003 03:38:10 -0000 1.37
+++ compiler/magic.m 21 Oct 2003 14:45:08 -0000
@@ -285,40 +285,38 @@
module_info::out, io__state::di, io__state::uo) is det.
magic__ite_to_disj_and_simplify(Simplifications, PredId, ProcId,
- ProcInfo0, ProcInfo, ModuleInfo0, ModuleInfo) -->
- { proc_info_goal(ProcInfo0, Goal0) },
+ !ProcInfo, !ModuleInfo) -->
+ { proc_info_goal(!.ProcInfo, Goal0) },
{ Goal0 = if_then_else(_Vars, Cond, Then, Else) - GoalInfo ->
goal_util__if_then_else_to_disjunction(Cond, Then, Else,
GoalInfo, Disj),
Goal1 = Disj - GoalInfo,
- proc_info_set_goal(ProcInfo0, Goal1, ProcInfo1),
+ proc_info_set_goal(Goal1, !ProcInfo),
% Requantify the goal to rename apart the variables
% in the copies of the condition.
- requantify_proc(ProcInfo1, ProcInfo3),
- ModuleInfo1 = ModuleInfo0
+ requantify_proc(!ProcInfo)
; Goal0 = switch(Var, _Canfail, Cases) - GoalInfo ->
- proc_info_varset(ProcInfo0, VarSet0),
- proc_info_vartypes(ProcInfo0, VarTypes0),
- proc_info_get_initial_instmap(ProcInfo0,
- ModuleInfo0, InstMap),
+ proc_info_varset(!.ProcInfo, VarSet0),
+ proc_info_vartypes(!.ProcInfo, VarTypes0),
+ proc_info_get_initial_instmap(!.ProcInfo,
+ !.ModuleInfo, InstMap),
% XXX check for existentially typed constructors first -
% they will cause an abort.
goal_util__switch_to_disjunction(Var, Cases,
InstMap, Disjuncts, VarSet0, VarSet1,
- VarTypes0, VarTypes1, ModuleInfo0, ModuleInfo1),
- proc_info_set_varset(ProcInfo0, VarSet1, ProcInfo1),
- proc_info_set_vartypes(ProcInfo1, VarTypes1, ProcInfo2),
+ VarTypes0, VarTypes1, !ModuleInfo),
+ proc_info_set_varset(VarSet1, !ProcInfo),
+ proc_info_set_vartypes(VarTypes1, !ProcInfo),
Goal1 = disj(Disjuncts) - GoalInfo,
- proc_info_set_goal(ProcInfo2, Goal1, ProcInfo3)
+ proc_info_set_goal(Goal1, !ProcInfo)
;
- ProcInfo3 = ProcInfo0,
- ModuleInfo1 = ModuleInfo0
+ true
},
simplify__proc(Simplifications, PredId, ProcId,
- ModuleInfo1, ModuleInfo2, ProcInfo3, ProcInfo4),
+ !ModuleInfo, !ProcInfo),
%
% Run saved_vars so that constructions of constants are close
@@ -326,8 +324,7 @@
% added to relations. We should be more aggressive about this -
% constructions of constant compound terms should also be pushed.
%
- saved_vars_proc(PredId, ProcId, ProcInfo4, ProcInfo,
- ModuleInfo2, ModuleInfo).
+ saved_vars_proc(PredId, ProcId, !ProcInfo, !ModuleInfo).
%-----------------------------------------------------------------------------%
@@ -400,7 +397,7 @@
( { check_marker(Markers0, aditi) } ->
{ remove_marker(Markers0, aditi, Markers1) },
{ remove_marker(Markers1, base_relation, Markers) },
- { pred_info_set_markers(PredInfo0, Markers, PredInfo) },
+ { pred_info_set_markers(Markers, PredInfo0, PredInfo) },
{ module_info_set_pred_info(ModuleInfo0,
PredId, PredInfo, ModuleInfo) },
magic_info_set_module_info(ModuleInfo)
@@ -468,7 +465,7 @@
{ hlds_pred__is_derived_relation(ModuleInfo, PredId) },
{ set__member(PredId, UsedPreds) }
->
- { pred_info_procids(PredInfo, ProcIds) },
+ { ProcIds = pred_info_procids(PredInfo) },
magic__process_imported_procs_2(PredId, ProcIds)
;
{ hlds_pred__pred_info_is_base_relation(PredInfo) },
@@ -476,13 +473,13 @@
% Always preprocess base relations defined in
% this module.
module_info_name(ModuleInfo, ModuleName),
- pred_info_module(PredInfo, PredModuleName),
+ PredModuleName = pred_info_module(PredInfo),
ModuleName = PredModuleName
;
set__member(PredId, UsedPreds)
}
->
- { pred_info_procids(PredInfo, ProcIds) },
+ { ProcIds = pred_info_procids(PredInfo) },
list__foldl(magic__process_base_relation(PredId), ProcIds)
;
[]
@@ -525,7 +522,7 @@
magic_info_set_error_vars(ErrorVars),
(
- { pred_info_module(PredInfo0, ModuleName) },
+ { ModuleName = pred_info_module(PredInfo0) },
{ module_info_name(ModuleInfo0, ModuleName) }
->
{ pred_info_context(PredInfo0, Context) },
@@ -543,11 +540,11 @@
{ type_util__remove_aditi_state(ArgTypes0, HeadVars0, HeadVars) },
{ pred_info_get_indexes(PredInfo0, Indexes0) },
{ list__map(magic_util__adjust_index(ArgTypes0), Indexes0, Indexes) },
- { pred_info_set_indexes(PredInfo0, Indexes, PredInfo1) },
- { pred_info_set_arg_types(PredInfo1, TVarSet, ExistQVars,
- ArgTypes, PredInfo) },
- { proc_info_set_argmodes(ProcInfo0, ArgModes, ProcInfo1) },
- { proc_info_set_headvars(ProcInfo1, HeadVars, ProcInfo) },
+ { pred_info_set_indexes(Indexes, PredInfo0, PredInfo1) },
+ { pred_info_set_arg_types(TVarSet, ExistQVars, ArgTypes,
+ PredInfo1, PredInfo) },
+ { proc_info_set_argmodes(ArgModes, ProcInfo0, ProcInfo1) },
+ { proc_info_set_headvars(HeadVars, ProcInfo1, ProcInfo) },
{ module_info_set_pred_proc_info(ModuleInfo0,
PredProcId, PredInfo, ProcInfo, ModuleInfo) },
magic_info_set_module_info(ModuleInfo),
@@ -640,8 +637,8 @@
%
% Produce a unique name for the procedure.
- { pred_info_module(PredInfo0, Module) },
- { pred_info_name(PredInfo0, Name) },
+ { Module = pred_info_module(PredInfo0) },
+ { Name = pred_info_name(PredInfo0) },
{ pred_info_get_markers(PredInfo0, Markers) },
( { check_marker(Markers, base_relation) } ->
@@ -655,7 +652,7 @@
{ pred_info_arg_types(PredInfo0, TVarSet, ExistQVars, ArgTypes) },
{ pred_info_context(PredInfo0, Context) },
{ pred_info_import_status(PredInfo0, Status) },
- { pred_info_get_is_pred_or_func(PredInfo0, PredOrFunc) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo0) },
{ pred_info_get_aditi_owner(PredInfo0, Owner) },
{ pred_info_get_indexes(PredInfo0, Indexes) },
% type classes aren't supported in Aditi.
@@ -665,7 +662,7 @@
ExistQVars, ArgTypes, true, Context, Status, Markers,
PredOrFunc, ClassConstraints, Owner, Assertions, ProcInfo0,
NewProcId, NewPredInfo0) },
- { pred_info_set_indexes(NewPredInfo0, Indexes, NewPredInfo) },
+ { pred_info_set_indexes(Indexes, NewPredInfo0, NewPredInfo) },
magic_info_get_module_info(ModuleInfo1),
{ module_info_get_predicate_table(ModuleInfo1, PredTable0) },
@@ -787,8 +784,8 @@
ArgModes1, ArgModes2) },
% Create variables for the magic input.
- { proc_info_create_vars_from_types(ProcInfo0, MagicTypes,
- MagicVars, ProcInfo1) },
+ { proc_info_create_vars_from_types(MagicTypes, MagicVars,
+ ProcInfo0, ProcInfo1) },
%
% Add the input relation variables to the arguments.
@@ -805,23 +802,23 @@
ModuleInfo0, InstMapDelta) },
{ proc_info_goal(ProcInfo1, Goal0 - GoalInfo0) },
{ goal_info_set_instmap_delta(GoalInfo0, InstMapDelta, GoalInfo) },
- { proc_info_set_goal(ProcInfo1, Goal0 - GoalInfo, ProcInfo2) },
+ { proc_info_set_goal(Goal0 - GoalInfo, ProcInfo1, ProcInfo2) },
% All Aditi procedures are considered nondet. The C interface
% procedures retain the old determinism, and abort if the number
% of answers returned doesn't match the determinism.
- { proc_info_set_inferred_determinism(ProcInfo2, nondet, ProcInfo3) },
+ { proc_info_set_inferred_determinism(nondet, ProcInfo2, ProcInfo3) },
{ partition_args(ModuleInfo0, ArgModes1,
ArgModes1, InputArgModes, _) },
{ partition_args(ModuleInfo0, ArgModes1,
ArgTypes1, InputArgTypes, _) },
- { pred_info_set_arg_types(PredInfo0, TVarSet, ExistQVars,
- ArgTypes, PredInfo) },
+ { pred_info_set_arg_types(TVarSet, ExistQVars, ArgTypes,
+ PredInfo0, PredInfo) },
- { proc_info_set_headvars(ProcInfo3, HeadVars, ProcInfo4) },
- { proc_info_set_argmodes(ProcInfo4, ArgModes, ProcInfo) },
+ { proc_info_set_headvars(HeadVars, ProcInfo3, ProcInfo4) },
+ { proc_info_set_argmodes(ArgModes, ProcInfo4, ProcInfo) },
( { InterfaceRequired = yes(Index) } ->
magic__create_interface_proc(Index, CPredProcId,
@@ -869,7 +866,7 @@
{ proc_info_goal(LocalProcInfo, Goal) },
magic_info_get_module_info(ModuleInfo1),
{ proc_info_get_initial_instmap(LocalProcInfo, ModuleInfo1, InstMap) },
- { pred_info_name(ExportedPredInfo0, PredName0) },
+ { PredName0 = pred_info_name(ExportedPredInfo0) },
{ string__append(PredName0, "__local", PredName) },
{ proc_info_headvars(LocalProcInfo, HeadVars) },
{ proc_info_vartypes(LocalProcInfo, VarTypes) },
@@ -910,12 +907,12 @@
{ ExportedArgModes = [MagicInputMode | ArgModes1] },
{ ExportedArgTypes = [MagicInputType | ArgTypes1] },
{ ExportedHeadVars = [MagicInputVar | HeadVars1] },
- { proc_info_set_headvars(ExportedProcInfo0,
- ExportedHeadVars, ExportedProcInfo1) },
- { proc_info_set_argmodes(ExportedProcInfo1,
- ExportedArgModes, ExportedProcInfo2) },
- { pred_info_set_arg_types(ExportedPredInfo0, TVarSet, [],
- ExportedArgTypes, ExportedPredInfo1) },
+ { proc_info_set_headvars(ExportedHeadVars,
+ ExportedProcInfo0, ExportedProcInfo1) },
+ { proc_info_set_argmodes(ExportedArgModes,
+ ExportedProcInfo1, ExportedProcInfo2) },
+ { pred_info_set_arg_types(TVarSet, [], ExportedArgTypes,
+ ExportedPredInfo0, ExportedPredInfo1) },
%
% Construct the input for the call to the local version.
@@ -929,11 +926,11 @@
{ CallGoal = _ - CallGoalInfo },
{ list__append(InputGoals, [CallGoal], ExportedConj) },
{ conj_list_to_goal(ExportedConj, CallGoalInfo, ExportedGoal) },
- { proc_info_set_goal(ExportedProcInfo3,
- ExportedGoal, ExportedProcInfo) },
+ { proc_info_set_goal(ExportedGoal,
+ ExportedProcInfo3, ExportedProcInfo) },
- { pred_info_set_import_status(ExportedPredInfo2, exported,
- ExportedPredInfo) },
+ { pred_info_set_import_status(exported,
+ ExportedPredInfo2, ExportedPredInfo) },
magic_info_get_module_info(ModuleInfo5),
{ module_info_set_pred_proc_info(ModuleInfo5, AditiPredProcId,
ExportedPredInfo, ExportedProcInfo, ModuleInfo6) },
@@ -971,8 +968,8 @@
error("magic__interface_call_args")
},
magic_info_get_proc_info(ProcInfo0),
- { proc_info_create_vars_from_types(ProcInfo0, ArgTypes,
- Args, ProcInfo) },
+ { proc_info_create_vars_from_types(ArgTypes, Args,
+ ProcInfo0, ProcInfo) },
magic_info_set_proc_info(ProcInfo),
{ fail_goal(LambdaGoal) },
{ list__index1_det(MagicModes, CurrVar, InputMode) },
@@ -998,10 +995,10 @@
(
{ AditiOnly = no },
{ check_marker(Markers, base_relation) },
- { pred_info_module(PredInfo0, ModuleName) }
+ { ModuleName = pred_info_module(PredInfo0) }
->
- { pred_info_set_import_status(PredInfo0,
- exported, PredInfo1) },
+ { pred_info_set_import_status(exported,
+ PredInfo0, PredInfo1) },
{ module_info_set_pred_proc_info(ModuleInfo0, CPredProcId,
PredInfo1, ProcInfo0, ModuleInfo1) },
magic_info_set_module_info(ModuleInfo1)
@@ -1021,7 +1018,7 @@
% predicate.
%
{ true_goal(Goal) },
- { proc_info_set_goal(ProcInfo0, Goal, ProcInfo) },
+ { proc_info_set_goal(Goal, ProcInfo0, ProcInfo) },
{ module_info_set_pred_proc_info(ModuleInfo1, CPredProcId,
PredInfo1, ProcInfo, ModuleInfo) },
magic_info_set_module_info(ModuleInfo)
@@ -1073,16 +1070,15 @@
InputArgModes, MagicArgModes),
JoinProcInfo0 = CProcInfo,
- proc_info_create_var_from_type(JoinProcInfo0,
- ClosureVarType, no, ClosureVar, JoinProcInfo1),
+ proc_info_create_var_from_type(ClosureVarType, no, ClosureVar,
+ JoinProcInfo0, JoinProcInfo1),
%
% Build a goal to call the input closure.
%
- set__list_to_set([ClosureVar | InputArgs],
- HOCallNonLocals),
+ set__list_to_set([ClosureVar | InputArgs], HOCallNonLocals),
instmap_delta_from_mode_list(InputArgs, MagicArgModes,
ModuleInfo0, HOCallDelta),
goal_info_init(HOCallNonLocals, HOCallDelta, nondet, pure,
@@ -1095,10 +1091,10 @@
ClosureInst = ground(shared,
higher_order(pred_inst_info(predicate, MagicArgModes, nondet))),
ClosureMode = (ClosureInst -> ClosureInst),
- proc_info_set_argmodes(JoinProcInfo1,
- [ClosureMode | OutputArgModes], JoinProcInfo2),
- proc_info_set_headvars(JoinProcInfo2,
- [ClosureVar | OutputArgs], JoinProcInfo3),
+ proc_info_set_argmodes([ClosureMode | OutputArgModes],
+ JoinProcInfo1, JoinProcInfo2),
+ proc_info_set_headvars([ClosureVar | OutputArgs],
+ JoinProcInfo2, JoinProcInfo3),
magic__build_join_pred_info(CPredProcId, CPredInfo,
JoinProcInfo3, [ClosureVar | OutputArgs],
@@ -1124,8 +1120,8 @@
),
module_info_pred_info(ModuleInfo1, AditiPredId, AditiPredInfo),
- pred_info_module(AditiPredInfo, PredModule),
- pred_info_name(AditiPredInfo, PredName),
+ PredModule = pred_info_module(AditiPredInfo),
+ PredName = pred_info_name(AditiPredInfo),
CallGoal = call(AditiPredId, AditiProcId, CallArgs, not_builtin,
no, qualified(PredModule, PredName)) - CallGoalInfo,
@@ -1136,7 +1132,7 @@
goal_info_init(GoalNonLocals, GoalDelta, nondet, pure, GoalInfo),
conj_list_to_goal([InputGoal, CallGoal | Tests], GoalInfo,
JoinGoal),
- proc_info_set_goal(JoinProcInfo4, JoinGoal, JoinProcInfo),
+ proc_info_set_goal(JoinGoal, JoinProcInfo4, JoinProcInfo),
module_info_set_pred_proc_info(ModuleInfo1, JoinPredProcId,
JoinPredInfo, JoinProcInfo, ModuleInfo).
@@ -1149,7 +1145,7 @@
ModuleInfo0, ModuleInfo) :-
proc_info_vartypes(JoinProcInfo, JoinVarTypes),
map__apply_to_list(Args, JoinVarTypes, NewArgTypes),
- pred_info_module(CPredInfo, PredModule),
+ PredModule = pred_info_module(CPredInfo),
rl__get_c_interface_proc_name(ModuleInfo0, CPredProcId, NewPredName),
init_markers(Markers0),
add_marker(Markers0, aditi, Markers1),
@@ -1288,7 +1284,7 @@
{ CPredProcId = proc(CPredId, CProcId) },
{ module_info_pred_info(ModuleInfo0, CPredId, CPredInfo) },
- { pred_info_module(CPredInfo, ModuleName) },
+ { ModuleName = pred_info_module(CPredInfo) },
magic_util__make_pred_name(CPredInfo, CProcId,
"Magic_Proc_For", no, SymName),
@@ -1346,18 +1342,17 @@
proc_info::in, proc_info::out,
magic_info::in, magic_info::out) is det.
-magic__preprocess_proc(PredProcId, PredInfo, ProcInfo0, ProcInfo) -->
- { proc_info_goal(ProcInfo0, Goal0) },
+magic__preprocess_proc(PredProcId, PredInfo, !ProcInfo) -->
+ { proc_info_goal(!.ProcInfo, Goal0) },
magic_info_set_curr_pred_proc_id(PredProcId),
magic_info_set_pred_info(PredInfo),
- magic_info_set_proc_info(ProcInfo0),
+ magic_info_set_proc_info(!.ProcInfo),
{ Goal0 = _ - GoalInfo0 },
{ goal_to_disj_list(Goal0, GoalList0) },
- list__map_foldl(magic__preprocess_disjunct,
- GoalList0, GoalList),
+ list__map_foldl(magic__preprocess_disjunct, GoalList0, GoalList),
{ disj_list_to_goal(GoalList, GoalInfo0, Goal) },
- magic_info_get_proc_info(ProcInfo1),
- { proc_info_set_goal(ProcInfo1, Goal, ProcInfo) }.
+ magic_info_get_proc_info(!:ProcInfo),
+ { proc_info_set_goal(Goal, !ProcInfo) }.
% Undo common structure elimination of higher-order terms in an
% attempt to avoid creating procedures with higher-order arguments
@@ -1519,8 +1514,8 @@
magic_info_get_proc_info(ProcInfo0),
{ proc_info_vartypes(ProcInfo0, VarTypes) },
{ map__lookup(VarTypes, Arg, ArgType) },
- { proc_info_create_var_from_type(ProcInfo0,
- ArgType, no, NewArg, ProcInfo) },
+ { proc_info_create_var_from_type(ArgType, no, NewArg,
+ ProcInfo0, ProcInfo) },
magic_info_set_proc_info(ProcInfo),
{ IntroducedArgs1 = [NewArg | IntroducedArgs0] },
{ in_mode(InMode) },
@@ -1635,8 +1630,8 @@
magic_info_get_proc_info(ProcInfo0),
{ proc_info_vartypes(ProcInfo0, VarTypes0) },
{ map__lookup(VarTypes0, Arg, Type) },
- { proc_info_create_var_from_type(ProcInfo0,
- Type, no, NewArg, ProcInfo) },
+ { proc_info_create_var_from_type(Type, no, NewArg,
+ ProcInfo0, ProcInfo) },
magic_info_set_proc_info(ProcInfo),
{ map__init(Subn0) },
{ map__det_insert(Subn0, Arg, NewArg, Subn) },
@@ -1720,7 +1715,7 @@
{ disj_list_to_goal(DisjList, GoalInfo0, Goal) },
magic_info_get_pred_info(PredInfo),
magic_info_get_proc_info(ProcInfo1),
- { proc_info_set_goal(ProcInfo1, Goal, ProcInfo) },
+ { proc_info_set_goal(Goal, ProcInfo1, ProcInfo) },
magic_info_get_module_info(ModuleInfo1),
{ module_info_set_pred_proc_info(ModuleInfo1, PredProcId,
Index: compiler/magic_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/magic_util.m,v
retrieving revision 1.31
diff -u -b -r1.31 magic_util.m
--- compiler/magic_util.m 20 Oct 2003 07:29:07 -0000 1.31
+++ compiler/magic_util.m 21 Oct 2003 13:23:30 -0000
@@ -316,9 +316,9 @@
{ set__sorted_list_to_set(NonLocals2, NonLocals) }.
magic_util__make_pred_name(PredInfo, ProcId, Prefix0, AddCount, Name) -->
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
- { pred_info_module(PredInfo, Module) },
- { pred_info_name(PredInfo, Name0) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
+ { Module = pred_info_module(PredInfo) },
+ { Name0 = pred_info_name(PredInfo) },
{ proc_id_to_int(ProcId, ProcInt) },
{ string__int_to_string(ProcInt, ProcStr) },
{ string__append_list([Prefix0, "_Mode_", ProcStr, "_Of"], Prefix) },
@@ -386,8 +386,8 @@
magic_info_get_module_info(ModuleInfo),
{ module_info_pred_proc_info(ModuleInfo, PredProcId,
CalledPredInfo, CalledProcInfo) },
- { pred_info_module(CalledPredInfo, PredModule) },
- { pred_info_name(CalledPredInfo, PredName) },
+ { PredModule = pred_info_module(CalledPredInfo) },
+ { PredName = pred_info_name(CalledPredInfo) },
{ Name = qualified(PredModule, PredName) },
{ proc_info_argmodes(CalledProcInfo, ArgModes) },
magic_info_get_proc_info(ProcInfo0),
@@ -496,8 +496,8 @@
% Update the unify_rhs.
magic_info_get_module_info(ModuleInfo),
{ module_info_pred_info(ModuleInfo, PredId, CallPredInfo) },
- { pred_info_module(CallPredInfo, PredModule) },
- { pred_info_name(CallPredInfo, PredName) },
+ { PredModule = pred_info_module(CallPredInfo) },
+ { PredName = pred_info_name(CallPredInfo) },
{ list__length(InputVars, Arity) },
{ Rhs = functor(cons(qualified(PredModule, PredName), Arity),
no, InputVars) },
@@ -508,8 +508,8 @@
{ list__append(InputGoals, [Goal1], InputAndClosure) }
;
- { error(
- "magic_util__setup_aggregate_input: non-closure input to aggregate") }
+ { error("magic_util__setup_aggregate_input: " ++
+ "non-closure input to aggregate") }
).
%-----------------------------------------------------------------------------%
@@ -571,8 +571,8 @@
magic_info_get_module_info(ModuleInfo),
{ PredProcId = proc(PredId, ProcId) },
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_module(PredInfo, PredModule) },
- { pred_info_name(PredInfo, PredName) },
+ { PredModule = pred_info_module(PredInfo) },
+ { PredName = pred_info_name(PredInfo) },
{ CallGoal = call(PredId, ProcId, AllArgs, not_builtin, no,
qualified(PredModule, PredName)) - GoalInfo }.
@@ -608,15 +608,15 @@
hlds_goal_info::out, proc_info::in, proc_info::out) is det.
magic_util__create_input_test_unification(ModuleInfo, Var, Mode, OutputVar,
- Test, CallInfo0, CallInfo, ProcInfo0, ProcInfo) :-
+ Test, CallInfo0, CallInfo, !ProcInfo) :-
mode_get_insts(ModuleInfo, Mode, _, FinalInst),
- proc_info_varset(ProcInfo0, VarSet0),
+ proc_info_varset(!.ProcInfo, VarSet0),
varset__new_var(VarSet0, OutputVar, VarSet),
- proc_info_vartypes(ProcInfo0, VarTypes0),
+ proc_info_vartypes(!.ProcInfo, VarTypes0),
map__lookup(VarTypes0, Var, VarType),
map__det_insert(VarTypes0, OutputVar, VarType, VarTypes),
- proc_info_set_varset(ProcInfo0, VarSet, ProcInfo1),
- proc_info_set_vartypes(ProcInfo1, VarTypes, ProcInfo),
+ proc_info_set_varset(VarSet, !ProcInfo),
+ proc_info_set_vartypes(VarTypes, !ProcInfo),
set__list_to_set([Var, OutputVar], NonLocals),
instmap_delta_init_reachable(InstMapDelta),
@@ -718,8 +718,8 @@
% since it is not being directly called, so create an empty
% input relation.
%
- { proc_info_create_vars_from_types(ProcInfo1, ArgTypes,
- LambdaVars, ProcInfo) },
+ { proc_info_create_vars_from_types(ArgTypes, LambdaVars,
+ ProcInfo1, ProcInfo) },
{ fail_goal(LambdaGoal) },
{ LambdaInputs = [] }
),
@@ -743,7 +743,7 @@
list(type)::out, proc_info::in, proc_info::out) is det.
magic_util__get_input_var(MagicTypes, CurrVar, InputVar, ArgTypes,
- ProcInfo0, ProcInfo) :-
+ !ProcInfo) :-
list__index1_det(MagicTypes, CurrVar, MagicType),
(
type_is_higher_order(MagicType, (pure), predicate,
@@ -752,8 +752,8 @@
ArgTypes = ArgTypes1,
construct_higher_order_type((pure), predicate,
(aditi_bottom_up), ArgTypes, ClosureType),
- proc_info_create_var_from_type(ProcInfo0, ClosureType, no,
- InputVar, ProcInfo)
+ proc_info_create_var_from_type(ClosureType, no, InputVar,
+ !ProcInfo)
;
error("magic_util__get_input_var")
).
@@ -834,8 +834,8 @@
% Construct the unify_rhs.
{ module_info_pred_info(ModuleInfo, SuppPredId, PredInfo) },
- { pred_info_module(PredInfo, SuppModule) },
- { pred_info_name(PredInfo, SuppName) },
+ { SuppModule = pred_info_module(PredInfo) },
+ { SuppName = pred_info_name(PredInfo) },
{ list__length(LambdaInputs, SuppArity) },
{ Rhs = functor(cons(qualified(SuppModule, SuppName),
SuppArity), no, LambdaInputs) },
@@ -870,7 +870,7 @@
magic_info::in, magic_info::out) is det.
magic_util__project_supp_call(SuppCall, UnrenamedInputVars,
- ProcInfo0, ProcInfo, SuppInputArgs, LambdaVars, LambdaGoal) -->
+ !ProcInfo, SuppInputArgs, LambdaVars, LambdaGoal) -->
(
{ SuppCall = call(SuppPredId1, SuppProcId1,
SuppArgs1, _, _, _) - _ }
@@ -888,10 +888,10 @@
% Rename the outputs of the supp call,
% but not the magic input relations.
- { proc_info_vartypes(ProcInfo0, VarTypes0) },
+ { proc_info_vartypes(!.ProcInfo, VarTypes0) },
{ map__apply_to_list(SuppOutputArgs, VarTypes0, SuppOutputArgTypes) },
- { proc_info_create_vars_from_types(ProcInfo0, SuppOutputArgTypes,
- NewArgs, ProcInfo) },
+ { proc_info_create_vars_from_types(SuppOutputArgTypes,
+ NewArgs, !ProcInfo) },
{ map__from_corresponding_lists(SuppOutputArgs, NewArgs, Subn) },
{ map__apply_to_list(UnrenamedInputVars, Subn, LambdaVars) },
{ goal_util__rename_vars_in_goal(SuppCall, Subn, LambdaGoal0) },
@@ -944,15 +944,14 @@
{ MagicGoal0 = _ - GoalInfo }, % near enough.
{ disj_list_to_goal([ExtraDisjunct | MagicDisjList0],
GoalInfo, MagicGoal) },
- { proc_info_set_vartypes(MagicProcInfo0,
- MagicVarTypes, MagicProcInfo1) },
- { proc_info_set_varset(MagicProcInfo1,
- MagicVarSet, MagicProcInfo2) },
- { proc_info_set_goal(MagicProcInfo2, MagicGoal, MagicProcInfo) },
+ { proc_info_set_vartypes(MagicVarTypes,
+ MagicProcInfo0, MagicProcInfo1) },
+ { proc_info_set_varset(MagicVarSet, MagicProcInfo1, MagicProcInfo2) },
+ { proc_info_set_goal(MagicGoal, MagicProcInfo2, MagicProcInfo) },
{ map__det_update(MagicProcs0, MagicProcId, MagicProcInfo,
MagicProcs) },
- { pred_info_set_procedures(MagicPredInfo0,
- MagicProcs, MagicPredInfo) },
+ { pred_info_set_procedures(MagicProcs,
+ MagicPredInfo0, MagicPredInfo) },
{ map__det_update(Preds0, MagicPredId, MagicPredInfo, Preds) },
{ module_info_set_preds(ModuleInfo0, Preds, ModuleInfo) },
magic_info_set_module_info(ModuleInfo).
@@ -986,8 +985,8 @@
magic_info_get_magic_map(MagicMap),
{ map__lookup(MagicMap, PredProcId, proc(MagicPredId, MagicProcId)) },
{ module_info_pred_info(ModuleInfo, MagicPredId, MagicPredInfo) },
- { pred_info_name(MagicPredInfo, PredName) },
- { pred_info_module(MagicPredInfo, PredModule) }.
+ { PredName = pred_info_name(MagicPredInfo) },
+ { PredModule = pred_info_module(MagicPredInfo) }.
%-----------------------------------------------------------------------------%
Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.447
diff -u -b -r1.447 make_hlds.m
--- compiler/make_hlds.m 20 Oct 2003 07:29:07 -0000 1.447
+++ compiler/make_hlds.m 21 Oct 2003 16:22:11 -0000
@@ -1280,11 +1280,11 @@
% specified types to force the specialization. For imported
% predicates this forces the creation of the proper interface.
%
- pred_info_get_is_pred_or_func(PredInfo0, PredOrFunc),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo0),
adjust_func_arity(PredOrFunc, Arity, PredArity),
varset__init(ArgVarSet0),
make_n_fresh_vars("HeadVar__", PredArity,
- ArgVarSet0, Args, ArgVarSet),
+ Args, ArgVarSet0, ArgVarSet),
% XXX We could use explicit type qualifications here
% for the argument types, but explicit type qualification
% doesn't work correctly with type inference due to
@@ -1325,14 +1325,13 @@
pred_info_import_status(PredInfo0, Status)
),
- pred_info_module(PredInfo0, ModuleName),
+ ModuleName = pred_info_module(PredInfo0),
pred_info_get_aditi_owner(PredInfo0, Owner),
pred_info_init(ModuleName, SpecName, PredArity, TVarSet,
ExistQVars, Types, true, Context, Clauses,
Status, Markers, none, PredOrFunc,
ClassContext, Proofs, Owner, NewPredInfo0),
- pred_info_set_procedures(NewPredInfo0,
- Procs, NewPredInfo),
+ pred_info_set_procedures(Procs, NewPredInfo0, NewPredInfo),
module_info_get_predicate_table(ModuleInfo2, PredTable0),
predicate_table_insert(PredTable0, NewPredInfo,
NewPredId, PredTable),
@@ -1592,7 +1591,7 @@
;
io__write_string(" do not ")
),
- { pred_info_get_is_pred_or_func(PredInfo0, PredOrFunc) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo0) },
(
{ PredOrFunc = predicate },
{ Decl = "`:- pred'" }
@@ -1609,10 +1608,10 @@
:- mode report_pragma_type_spec(in, in, di, uo) is det.
report_pragma_type_spec(PredInfo0, Context) -->
- { pred_info_module(PredInfo0, Module) },
- { pred_info_name(PredInfo0, Name) },
- { pred_info_arity(PredInfo0, Arity) },
- { pred_info_get_is_pred_or_func(PredInfo0, PredOrFunc) },
+ { Module = pred_info_module(PredInfo0) },
+ { Name = pred_info_name(PredInfo0) },
+ { Arity = pred_info_arity(PredInfo0) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo0) },
prog_out__write_context(Context),
io__write_string("In `:- pragma type_spec' declaration for "),
hlds_out__write_simple_call_id(PredOrFunc,
@@ -1702,14 +1701,14 @@
MaybePragmaTerminationInfo, Context,
MaybeTerminationInfo) },
{ map__lookup(ProcTable0, ProcId, ProcInfo0) },
- { proc_info_set_maybe_arg_size_info(ProcInfo0,
- MaybeArgSizeInfo, ProcInfo1) },
- { proc_info_set_maybe_termination_info(ProcInfo1,
- MaybeTerminationInfo, ProcInfo) },
+ { proc_info_set_maybe_arg_size_info(MaybeArgSizeInfo,
+ ProcInfo0, ProcInfo1) },
+ { proc_info_set_maybe_termination_info(
+ MaybeTerminationInfo, ProcInfo1, ProcInfo) },
{ map__det_update(ProcTable0, ProcId, ProcInfo,
ProcTable) },
- { pred_info_set_procedures(PredInfo0, ProcTable,
- PredInfo) },
+ { pred_info_set_procedures(ProcTable,
+ PredInfo0, PredInfo) },
{ map__det_update(PredTable0, PredId, PredInfo,
PredTable) },
{ module_info_set_preds(Module0, PredTable,
@@ -1813,7 +1812,7 @@
set_pred_owner(Module0, Name, Arity, Owner, Status, Context, Module) -->
{ SetOwner =
lambda([PredInfo0::in, PredInfo::out] is det, (
- pred_info_set_aditi_owner(PredInfo0, Owner, PredInfo)
+ pred_info_set_aditi_owner(Owner, PredInfo0, PredInfo)
)) },
{ MarkerMustBeExported = yes },
do_add_pred_marker(Module0, "owner", Name, Arity, Status,
@@ -1829,7 +1828,7 @@
lambda([PredInfo0::in, PredInfo::out] is det, (
pred_info_get_indexes(PredInfo0, Indexes0),
Indexes = [Index | Indexes0],
- pred_info_set_indexes(PredInfo0, Indexes, PredInfo)
+ pred_info_set_indexes(Indexes, PredInfo0, PredInfo)
)) },
{ MarkerMustBeExported = yes },
do_add_pred_marker(Module0, "aditi_index", Name, Arity, Status,
@@ -1869,7 +1868,7 @@
check_index_attribute_pred(ModuleInfo, Name, Arity, Context, Attrs, PredId) -->
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
{ pred_info_get_markers(PredInfo, Markers) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
( { check_marker(Markers, base_relation) } ->
[]
;
@@ -3659,14 +3658,14 @@
% forwarding code stub is so that things work correctly if
% you take the address of the predicate.
-add_builtin(PredId, Types, PredInfo0, PredInfo) :-
+add_builtin(PredId, Types, !PredInfo) :-
%
% lookup some useful info: Module, Name, Context, HeadVars
%
- pred_info_module(PredInfo0, Module),
- pred_info_name(PredInfo0, Name),
- pred_info_context(PredInfo0, Context),
- pred_info_clauses_info(PredInfo0, ClausesInfo0),
+ Module = pred_info_module(!.PredInfo),
+ Name = pred_info_name(!.PredInfo),
+ pred_info_context(!.PredInfo, Context),
+ pred_info_clauses_info(!.PredInfo, ClausesInfo0),
clauses_info_varset(ClausesInfo0, VarSet),
clauses_info_headvars(ClausesInfo0, HeadVars),
@@ -3674,7 +3673,7 @@
% construct the pseudo-recursive call to Module:Name(HeadVars)
%
SymName = qualified(Module, Name),
- invalid_proc_id(ModeId), % mode checking will figure it out
+ ModeId = invalid_proc_id, % mode checking will figure it out
MaybeUnifyContext = no,
Call = call(PredId, ModeId, HeadVars, inline_builtin, MaybeUnifyContext,
SymName),
@@ -3701,7 +3700,7 @@
ClausesInfo = clauses_info(VarSet, VarTypes, TVarNameMap, VarTypes,
HeadVars, ClauseList, TI_VarMap, TCI_VarMap,
HasForeignClauses),
- pred_info_set_clauses_info(PredInfo0, ClausesInfo, PredInfo1),
+ pred_info_set_clauses_info(ClausesInfo, !PredInfo),
%
% It's pointless but harmless to inline these clauses.
@@ -3711,9 +3710,9 @@
% predicates. The code generator will still generate
% inline code for calls to these predicates.
%
- pred_info_get_markers(PredInfo1, Markers0),
+ pred_info_get_markers(!.PredInfo, Markers0),
add_marker(Markers0, no_inline, Markers),
- pred_info_set_markers(PredInfo1, Markers, PredInfo).
+ pred_info_set_markers(Markers, !PredInfo).
%-----------------------------------------------------------------------------%
@@ -3887,7 +3886,7 @@
(
(Status = imported(_) ; Status = pseudo_imported)
->
- pred_info_set_import_status(PredInfo0, Status, PredInfo1)
+ pred_info_set_import_status(Status, PredInfo0, PredInfo1)
;
TypeBody ^ du_type_usereq = yes(_),
pred_info_import_status(PredInfo0, OldStatus),
@@ -3903,18 +3902,18 @@
% for the type. However, for types with user-defined equality,
% we *do* want to generate code for mode 0 of unify,
% so we fix the status.
- pred_info_set_import_status(PredInfo0, Status, PredInfo1)
+ pred_info_set_import_status(Status, PredInfo0, PredInfo1)
;
PredInfo1 = PredInfo0
),
unify_proc__generate_clause_info(SpecialPredId, Type, TypeBody,
Context, Module1, ClausesInfo),
- pred_info_set_clauses_info(PredInfo1, ClausesInfo, PredInfo2),
+ pred_info_set_clauses_info(ClausesInfo, PredInfo1, PredInfo2),
pred_info_get_markers(PredInfo2, Markers2),
add_marker(Markers2, calls_are_fully_qualified, Markers),
- pred_info_set_markers(PredInfo2, Markers, PredInfo3),
- pred_info_set_maybe_special_pred(PredInfo3,
- yes(SpecialPredId - TypeCtor), PredInfo),
+ pred_info_set_markers(Markers, PredInfo2, PredInfo3),
+ pred_info_set_maybe_special_pred(yes(SpecialPredId - TypeCtor),
+ PredInfo3, PredInfo),
map__det_update(Preds0, PredId, PredInfo, Preds),
module_info_set_preds(Module1, Preds, Module).
@@ -3971,8 +3970,8 @@
pred_info_init(ModuleName, PredName, Arity, TVarSet, ExistQVars,
ArgTypes, Cond, Context, ClausesInfo0, Status, Markers,
none, predicate, ClassContext, Proofs, Owner, PredInfo0),
- pred_info_set_maybe_special_pred(PredInfo0,
- yes(SpecialPredId - TypeCtor), PredInfo1),
+ pred_info_set_maybe_special_pred(yes(SpecialPredId - TypeCtor),
+ PredInfo0, PredInfo1),
ArgLives = no,
varset__init(InstVarSet),
% Should not be any inst vars here so it's ok to use a
@@ -4045,9 +4044,9 @@
next_mode_id(Procs0, MaybeDet, ModeId),
proc_info_init(Arity, ArgTypes, ArgModes, MaybeDeclaredArgModes,
MaybeArgLives, MaybeDet, Context, IsAddressTaken, NewProc0),
- proc_info_set_inst_varset(NewProc0, InstVarSet, NewProc),
+ proc_info_set_inst_varset(InstVarSet, NewProc0, NewProc),
map__det_insert(Procs0, ModeId, NewProc, Procs),
- pred_info_set_procedures(PredInfo0, Procs, PredInfo).
+ pred_info_set_procedures(Procs, PredInfo0, PredInfo).
%-----------------------------------------------------------------------------%
@@ -4117,9 +4116,9 @@
{ MaybeDet = no }
->
{ pred_info_import_status(PredInfo0, ImportStatus) },
- { pred_info_get_is_pred_or_func(PredInfo0, PredOrFunc) },
- { pred_info_module(PredInfo0, PredModule) },
- { pred_info_name(PredInfo0, PredName) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo0) },
+ { PredModule = pred_info_module(PredInfo0) },
+ { PredName = pred_info_name(PredInfo0) },
{ PredSymName = qualified(PredModule, PredName) },
( { IsClassMethod = yes } ->
unspecified_det_for_method(PredSymName, Arity,
@@ -4219,7 +4218,7 @@
PredName, Arity, Status, Context,
PredOrFunc, PredId, PredicateTable) :-
varset__init(TVarSet0),
- make_n_fresh_vars("T", Arity, TVarSet0, TypeVars, TVarSet),
+ make_n_fresh_vars("T", Arity, TypeVars, TVarSet0, TVarSet),
term__var_list_to_term_list(TypeVars, Types),
Cond = true,
map__init(Proofs),
@@ -4236,7 +4235,7 @@
Types, Cond, Context, ClausesInfo, Status, Markers0, none,
PredOrFunc, ClassContext, Proofs, Owner, PredInfo0),
add_marker(Markers0, infer_type, Markers),
- pred_info_set_markers(PredInfo0, Markers, PredInfo),
+ pred_info_set_markers(Markers, PredInfo0, PredInfo),
(
\+ predicate_table_search_pf_sym_arity(PredicateTable0,
is_fully_qualified, PredOrFunc, PredName, Arity, _)
@@ -4352,11 +4351,11 @@
% opt_imported preds are initially tagged as imported and are
% tagged as opt_imported only if/when we see a clause for them
{ Status = opt_imported ->
- pred_info_set_import_status(PredInfo0,
- opt_imported, PredInfo0a),
+ pred_info_set_import_status(opt_imported,
+ PredInfo0, PredInfo0a),
pred_info_get_markers(PredInfo0a, Markers0),
add_marker(Markers0, calls_are_fully_qualified, Markers1),
- pred_info_set_markers(PredInfo0a, Markers1, PredInfo1)
+ pred_info_set_markers(Markers1, PredInfo0a, PredInfo1)
;
PredInfo1 = PredInfo0
},
@@ -4437,31 +4436,31 @@
VarSet, TVarSet, Clauses, Warnings,
ModuleInfo2, ModuleInfo3, Info1, Info),
{
- pred_info_set_clauses_info(PredInfo2, Clauses, PredInfo3),
+ pred_info_set_clauses_info(Clauses, PredInfo2, PredInfo3),
(
GoalType = promise(PromiseType)
->
- pred_info_set_goal_type(PredInfo3, promise(PromiseType),
- PredInfo4)
+ pred_info_set_goal_type(promise(PromiseType),
+ PredInfo3, PredInfo4)
;
- pred_info_update_goal_type(PredInfo3,
- clauses, PredInfo4)
+ pred_info_update_goal_type(clauses,
+ PredInfo3, PredInfo4)
),
- pred_info_set_typevarset(PredInfo4, TVarSet, PredInfo5),
+ pred_info_set_typevarset(TVarSet, PredInfo4, PredInfo5),
pred_info_arg_types(PredInfo5, _ArgTVarSet,
ExistQVars, ArgTypes),
- pred_info_set_arg_types(PredInfo5, TVarSet,
- ExistQVars, ArgTypes, PredInfo6),
+ pred_info_set_arg_types(TVarSet, ExistQVars, ArgTypes,
+ PredInfo5, PredInfo6),
%
% check if there are still no modes for the predicate,
% and if so, set the `infer_modes' flag for that predicate
%
- pred_info_all_procids(PredInfo6, ProcIds),
+ ProcIds = pred_info_all_procids(PredInfo6),
( ProcIds = [] ->
pred_info_get_markers(PredInfo6, Markers6),
add_marker(Markers6, infer_modes, Markers),
- pred_info_set_markers(PredInfo6, Markers, PredInfo)
+ pred_info_set_markers(Markers, PredInfo6, PredInfo)
;
PredInfo = PredInfo6
),
@@ -4533,7 +4532,7 @@
ModuleInfo, Context),
% apply the clause to all modes
% XXX would it be better to apply it to none?
- { pred_info_all_procids(PredInfo, ProcIds) }
+ { ProcIds = pred_info_all_procids(PredInfo) }
)
;
{ ModeAnnotations = empty },
@@ -4541,7 +4540,7 @@
% We are only allowed to mix foreign procs and
% mode specific clauses, so make this clause
% mode specific but apply to all modes.
- pred_info_all_procids(PredInfo, ProcIds)
+ ProcIds = pred_info_all_procids(PredInfo)
;
% this means the clauses applies to all modes
ProcIds = []
@@ -4554,7 +4553,7 @@
% We are only allowed to mix foreign procs and
% mode specific clauses, so make this clause
% mode specific but apply to all modes.
- pred_info_all_procids(PredInfo, ProcIds)
+ ProcIds = pred_info_all_procids(PredInfo)
;
% this means the clauses applies to all modes
ProcIds = []
@@ -4575,7 +4574,7 @@
" syntax error: some but not all arguments have mode annotations.\n"),
% apply the clause to all modes
% XXX would it be better to apply it to none?
- { pred_info_all_procids(PredInfo, ProcIds) }
+ { ProcIds = pred_info_all_procids(PredInfo) }
).
% Clauses can have mode annotations on them, to indicate that the
@@ -4663,9 +4662,8 @@
% Then the goal itself
varset__init(VarSet0),
- make_n_fresh_vars("HeadVar__", PredArity, VarSet0, HeadVars, VarSet),
- invalid_pred_id(InvalidPredId),
- construct_pred_or_func_call(InvalidPredId, PredOrFunc,
+ make_n_fresh_vars("HeadVar__", PredArity, HeadVars, VarSet0, VarSet),
+ construct_pred_or_func_call(invalid_pred_id, PredOrFunc,
InstancePredName, HeadVars, GoalInfo, IntroducedGoal,
transform_info(ModuleInfo0, QualInfo0),
transform_info(ModuleInfo, QualInfo)),
@@ -4809,7 +4807,7 @@
% tagged as opt_imported only if/when we see a clause (including
% a `pragma import' clause) for them
{ Status = opt_imported ->
- pred_info_set_import_status(PredInfo0, opt_imported, PredInfo1)
+ pred_info_set_import_status(opt_imported, PredInfo0, PredInfo1)
;
PredInfo1 = PredInfo0
},
@@ -4836,7 +4834,7 @@
io__write_string(" with preceding clauses.\n"),
{ Info = Info0 }
;
- { pred_info_update_goal_type(PredInfo1, pragmas, PredInfo2) },
+ { pred_info_update_goal_type(pragmas, PredInfo1, PredInfo2) },
%
% add the pragma declaration to the proc_info for this procedure
%
@@ -4889,8 +4887,8 @@
%
% lookup some information we need from the pred_info and proc_info
%
- { pred_info_name(PredInfo0, PredName) },
- { pred_info_module(PredInfo0, PredModule) },
+ { PredName = pred_info_name(PredInfo0) },
+ { PredModule = pred_info_module(PredInfo0) },
{ pred_info_clauses_info(PredInfo0, Clauses0) },
{ pred_info_get_purity(PredInfo0, Purity) },
@@ -4905,7 +4903,7 @@
%
% Store the clauses_info etc. back into the pred_info
%
- { pred_info_set_clauses_info(PredInfo0, Clauses, PredInfo) }.
+ { pred_info_set_clauses_info(Clauses, PredInfo0, PredInfo) }.
%-----------------------------------------------------------------------------%
@@ -4964,7 +4962,8 @@
% tagged as opt_imported only if/when we see a clause (including
% a `pragma c_code' clause) for them
{ Status = opt_imported ->
- pred_info_set_import_status(PredInfo0, opt_imported, PredInfo1a)
+ pred_info_set_import_status(opt_imported,
+ PredInfo0, PredInfo1a)
;
PredInfo1a = PredInfo0
},
@@ -4983,10 +4982,10 @@
;
C
) :-
- pred_info_all_procids(PredInfo1a, AllProcIds)
+ AllProcIds = pred_info_all_procids(PredInfo1a)
), ClauseList0),
- clauses_info_set_clauses(CInfo0, ClauseList, CInfo),
- pred_info_set_clauses_info(PredInfo1a, CInfo, PredInfo1)
+ clauses_info_set_clauses(ClauseList, CInfo0, CInfo),
+ pred_info_set_clauses_info(CInfo, PredInfo1a, PredInfo1)
;
PredInfo1 = PredInfo1a
},
@@ -5006,7 +5005,7 @@
% than the ones we can generate code for.
{ not list__member(PragmaForeignLanguage, BackendForeignLangs) }
->
- { pred_info_update_goal_type(PredInfo0, pragmas, PredInfo) },
+ { pred_info_update_goal_type(pragmas, PredInfo0, PredInfo) },
{ module_info_set_pred_info(ModuleInfo1,
PredId, PredInfo, ModuleInfo) },
{ Info = Info0 }
@@ -5029,10 +5028,10 @@
PragmaImpl, Context, PredOrFunc,
PredName, Arity, Clauses, ModuleInfo1,
ModuleInfo2, Info0, Info),
- { pred_info_set_clauses_info(PredInfo1, Clauses,
- PredInfo2) },
- { pred_info_update_goal_type(PredInfo2, pragmas,
- PredInfo) },
+ { pred_info_set_clauses_info(Clauses,
+ PredInfo1, PredInfo2) },
+ { pred_info_update_goal_type(pragmas,
+ PredInfo2, PredInfo) },
{ map__det_update(Preds0, PredId, PredInfo, Preds) },
{ predicate_table_set_preds(PredicateTable1, Preds,
PredicateTable) },
@@ -5142,7 +5141,7 @@
->
{ PredOrFunc = PredOrFunc0 }
;
- { pred_info_get_is_pred_or_func(PredInfo0, PredOrFunc) }
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo0) }
),
{ adjust_func_arity(PredOrFunc, Arity0, Arity) },
@@ -5197,12 +5196,12 @@
ProcId) }
->
{ map__lookup(Procs0, ProcId, ProcInfo0) },
- { proc_info_set_eval_method(ProcInfo0,
- EvalMethod, ProcInfo) },
+ { proc_info_set_eval_method(EvalMethod,
+ ProcInfo0, ProcInfo) },
{ map__det_update(Procs0, ProcId, ProcInfo,
Procs) },
- { pred_info_set_procedures(PredInfo0, Procs,
- PredInfo) },
+ { pred_info_set_procedures(Procs,
+ PredInfo0, PredInfo) },
{ module_info_set_pred_info(ModuleInfo1,
PredId, PredInfo, ModuleInfo) }
;
@@ -5233,8 +5232,8 @@
;
{ set_eval_method_list(ExistingProcs, EvalMethod,
Procs0, Procs) },
- { pred_info_set_procedures(PredInfo0, Procs,
- PredInfo) },
+ { pred_info_set_procedures(Procs,
+ PredInfo0, PredInfo) },
{ module_info_set_pred_info(ModuleInfo1, PredId,
PredInfo, ModuleInfo) }
)
@@ -5246,7 +5245,7 @@
set_eval_method_list([], _, Procs, Procs).
set_eval_method_list([ProcId - ProcInfo0|Rest], EvalMethod, Procs0, Procs) :-
- proc_info_set_eval_method(ProcInfo0, EvalMethod, ProcInfo),
+ proc_info_set_eval_method(EvalMethod, ProcInfo0, ProcInfo),
map__det_update(Procs0, ProcId, ProcInfo, Procs1),
set_eval_method_list(Rest, EvalMethod, Procs1, Procs).
@@ -5340,10 +5339,10 @@
:- pred add_marker_pred_info(marker, pred_info, pred_info).
:- mode add_marker_pred_info(in, in, out) is det.
-add_marker_pred_info(Marker, PredInfo0, PredInfo) :-
- pred_info_get_markers(PredInfo0, Markers0),
+add_marker_pred_info(Marker, !PredInfo) :-
+ pred_info_get_markers(!.PredInfo, Markers0),
add_marker(Markers0, Marker, Markers),
- pred_info_set_markers(PredInfo0, Markers, PredInfo).
+ pred_info_set_markers(Markers, !PredInfo).
% Succeed if a marker for an exported procedure must also
% be exported.
@@ -5982,7 +5981,7 @@
map__init(VarTypes),
map__init(TVarNameMap),
varset__init(VarSet0),
- make_n_fresh_vars("HeadVar__", Arity, VarSet0, HeadVars, VarSet),
+ make_n_fresh_vars("HeadVar__", Arity, HeadVars, VarSet0, VarSet),
map__init(TI_VarMap),
map__init(TCI_VarMap),
HasForeignClauses = no,
@@ -6251,9 +6250,9 @@
- GoalInfo,
ModuleInfo = ModuleInfo1,
map__init(EmptyVarTypes),
- implicitly_quantify_clause_body(HeadVars,
- HldsGoal0, VarSet0, EmptyVarTypes,
- HldsGoal, VarSet, _, _Warnings),
+ implicitly_quantify_clause_body(HeadVars, _Warnings,
+ HldsGoal0, HldsGoal, VarSet0, VarSet,
+ EmptyVarTypes, _),
NewClause = clause([ProcId], HldsGoal,
foreign_language(NewLang), Context),
UpdateClauses(NewClause, NewClauseList),
@@ -6325,8 +6324,8 @@
SInfo),
VarTypes2 = Info2 ^ qual_info ^ vartypes,
- implicitly_quantify_clause_body(HeadVars, Goal0, VarSet4, VarTypes2,
- Goal, VarSet, VarTypes, Warnings),
+ implicitly_quantify_clause_body(HeadVars, Warnings,
+ Goal0, Goal, VarSet4, VarSet, VarTypes2, VarTypes),
Info = Info2 ^ qual_info ^ vartypes := VarTypes.
@@ -6569,8 +6568,8 @@
;
{
% initialize some fields to junk
- invalid_pred_id(PredId),
- invalid_proc_id(ModeId),
+ PredId = invalid_pred_id,
+ ModeId = invalid_proc_id,
MaybeUnifyContext = no,
Call = call(PredId, ModeId, HeadVars, not_builtin,
@@ -7153,7 +7152,7 @@
[AditiState0Var, AditiStateVar], AllArgs),
list__length(TupleArgVars, InsertArity),
- invalid_pred_id(PredId),
+ PredId = invalid_pred_id,
Builtin = aditi_tuple_update(Update, PredId),
InsertCallId = PredOrFunc - SymName/InsertArity,
Call = generic_call(
@@ -7303,7 +7302,7 @@
Detism, PredGoal0, PredGoal) },
{ ModifiedCallId = PredOrFunc - SymName/PredArity },
- { invalid_pred_id(PredId) },
+ { PredId = invalid_pred_id },
{ Builtin = aditi_bulk_update(Update, PredId, Syntax) },
{ MainContext =
call(generic_call(
@@ -7381,7 +7380,7 @@
{ make_fresh_arg_vars(OtherArgs0,
VarSet0, OtherArgs, VarSet1) },
- { invalid_pred_id(PredId) },
+ { PredId = invalid_pred_id },
{ Builtin = aditi_bulk_update(Update, PredId, Syntax) },
@@ -7481,7 +7480,7 @@
:- mode conjoin_aditi_update_goal_with_call(in, in, in, in, out) is det.
conjoin_aditi_update_goal_with_call(PredOrFunc, SymName, Args, Goal0, Goal) :-
- invalid_pred_id(PredId),
+ PredId = invalid_pred_id,
Goal0 = _ - GoalInfo,
% The predicate is recorded as used in
@@ -7562,11 +7561,9 @@
:- mode invalid_goal(in, in, in, out, in, out) is det.
invalid_goal(UpdateStr, Args0, GoalInfo, Goal, VarSet0, VarSet) :-
- invalid_pred_id(PredId),
- invalid_proc_id(ProcId),
make_fresh_arg_vars(Args0, VarSet0, HeadVars, VarSet),
MaybeUnifyContext = no,
- Goal = call(PredId, ProcId, HeadVars, not_builtin,
+ Goal = call(invalid_pred_id, invalid_proc_id, HeadVars, not_builtin,
MaybeUnifyContext, unqualified(UpdateStr)) - GoalInfo.
%-----------------------------------------------------------------------------
@@ -8451,8 +8448,7 @@
GoalInfo, Goal) :-
(
PredOrFunc = predicate,
- invalid_proc_id(DummyProcId),
- Goal = call(PredId, DummyProcId, Args,
+ Goal = call(PredId, invalid_proc_id, Args,
not_builtin, no, SymName) - GoalInfo
;
PredOrFunc = function,
@@ -8876,9 +8872,9 @@
pred_method_with_no_modes_error(PredInfo) -->
{ pred_info_context(PredInfo, Context) },
- { pred_info_module(PredInfo, Module) },
- { pred_info_name(PredInfo, Name) },
- { pred_info_arity(PredInfo, Arity) },
+ { Module = pred_info_module(PredInfo) },
+ { Name = pred_info_name(PredInfo) },
+ { Arity = pred_info_arity(PredInfo) },
io__set_exit_status(1),
prog_out__write_context(Context),
io__write_string("Error: no mode declaration for type class method\n"),
@@ -8923,8 +8919,8 @@
io__write_string(" `"),
{ strip_builtin_qualifiers_from_mode_list(ModeList,
StrippedModeList) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
- { pred_info_name(PredInfo, Name) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
+ { Name = pred_info_name(PredInfo) },
{ MaybeDet = no },
mercury_output_mode_subdecl(PredOrFunc,
varset__coerce(VarSet),
@@ -8935,9 +8931,8 @@
io__write_string(" of "),
hlds_out__write_pred_id(ModuleInfo, PredId),
io__write_string(".\n"),
- globals__io_lookup_bool_option(verbose_errors,
- VerboseErrors),
- { pred_info_all_procids(PredInfo, ProcIds) },
+ globals__io_lookup_bool_option(verbose_errors, VerboseErrors),
+ { ProcIds = pred_info_all_procids(PredInfo) },
( { ProcIds = [] } ->
prog_out__write_context(Context),
io__write_string(
@@ -9167,9 +9162,9 @@
{module_info_set_pred_info(Module0, PredID, PredInfo, Module1)},
{ pred_info_procedures(PredInfo, ProcTable) },
- { pred_info_procids(PredInfo, ProcIDs) },
{ pred_info_arg_types(PredInfo, ArgTypes) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { ProcIDs = pred_info_procids(PredInfo) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
{ adjust_func_arity(PredOrFunc, Arity, NumArgs) },
% create pragma c_header_code to declare extern variables
Index: compiler/mark_static_terms.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mark_static_terms.m,v
retrieving revision 1.10
diff -u -b -r1.10 mark_static_terms.m
--- compiler/mark_static_terms.m 15 Mar 2003 03:08:57 -0000 1.10
+++ compiler/mark_static_terms.m 21 Oct 2003 13:36:44 -0000
@@ -21,7 +21,7 @@
:- import_module hlds__hlds_module.
:- import_module hlds__hlds_pred.
-:- pred mark_static_terms(proc_info::in, module_info::in, proc_info::out)
+:- pred mark_static_terms(module_info::in, proc_info::in, proc_info::out)
is det.
%-----------------------------------------------------------------------------%
@@ -44,12 +44,12 @@
:- import_module hlds__hlds_goal.
:- import_module int, list, std_util, require.
-mark_static_terms(Proc0, _ModuleInfo, Proc) :-
+mark_static_terms(_ModuleInfo, !Proc) :-
% The ModuleInfo argument is there just for passes_aux
- proc_info_goal(Proc0, Goal0),
+ proc_info_goal(!.Proc, Goal0),
map__init(StaticInfo0),
goal_mark_static_terms(Goal0, Goal, StaticInfo0, _StaticInfo),
- proc_info_set_goal(Proc0, Goal, Proc).
+ proc_info_set_goal(Goal, !Proc).
:- pred goal_mark_static_terms(hlds_goal::in, hlds_goal::out,
static_info::in, static_info::out) is det.
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.291
diff -u -b -r1.291 mercury_compile.m
--- compiler/mercury_compile.m 23 Oct 2003 02:02:08 -0000 1.291
+++ compiler/mercury_compile.m 23 Oct 2003 02:12:01 -0000
@@ -2374,7 +2374,7 @@
ModuleInfo, GlobalData0, GlobalData, Code) -->
{ module_info_preds(ModuleInfo0, PredTable) },
{ map__lookup(PredTable, PredId, PredInfo) },
- { pred_info_non_imported_procids(PredInfo, ProcIds) },
+ { ProcIds = pred_info_non_imported_procids(PredInfo) },
(
{ ProcIds = []
; hlds_pred__pred_info_is_aditi_relation(PredInfo)
@@ -2393,9 +2393,9 @@
[]
),
(
- { pred_info_module(PredInfo, PredModule) },
- { pred_info_name(PredInfo, PredName) },
- { pred_info_arity(PredInfo, PredArity) },
+ { PredModule = pred_info_module(PredInfo) },
+ { PredName = pred_info_name(PredInfo) },
+ { PredArity = pred_info_arity(PredInfo) },
{ no_type_info_builtin(PredModule, PredName,
PredArity) }
->
@@ -2511,15 +2511,15 @@
write_proc_progress_message(
"% Allocating storage locations for live vars in ",
PredId, ProcId, ModuleInfoSimplify),
- { allocate_store_maps(final_allocation, ProcInfoStackSlot,
- PredId, ModuleInfoSimplify, ProcInfoStoreAlloc) },
+ { allocate_store_maps(final_allocation, PredId, ModuleInfoSimplify,
+ ProcInfoStackSlot, ProcInfoStoreAlloc) },
globals__io_get_trace_level(TraceLevel),
( { given_trace_level_is_none(TraceLevel) = no } ->
write_proc_progress_message(
"% Calculating goal paths in ",
PredId, ProcId, ModuleInfoSimplify),
- { goal_path__fill_slots(ProcInfoStoreAlloc, ModuleInfoSimplify,
- ProcInfo) }
+ { goal_path__fill_slots(ModuleInfoSimplify,
+ ProcInfoStoreAlloc, ProcInfo) }
;
{ ProcInfo = ProcInfoStoreAlloc }
),
@@ -3142,7 +3142,7 @@
add_aditi_procs(HLDS0, PredId, AditiPreds0, AditiPreds) :-
module_info_pred_info(HLDS0, PredId, PredInfo),
( hlds_pred__pred_info_is_aditi_relation(PredInfo) ->
- pred_info_procids(PredInfo, ProcIds),
+ ProcIds = pred_info_procids(PredInfo),
AddProc =
lambda([ProcId::in, Preds0::in, Preds::out] is det, (
set__insert(Preds0, proc(PredId, ProcId), Preds)
Index: compiler/ml_call_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_call_gen.m,v
retrieving revision 1.41
diff -u -b -r1.41 ml_call_gen.m
--- compiler/ml_call_gen.m 28 Mar 2003 06:42:48 -0000 1.41
+++ compiler/ml_call_gen.m 21 Oct 2003 09:44:24 -0000
@@ -413,7 +413,7 @@
%
{ module_info_pred_proc_info(ModuleInfo, PredId, ProcId,
PredInfo, ProcInfo) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
{ pred_info_arg_types(PredInfo, PredArgTypes) },
{ proc_info_argmodes(ProcInfo, ArgModes) },
Index: compiler/ml_closure_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_closure_gen.m,v
retrieving revision 1.20
diff -u -b -r1.20 ml_closure_gen.m
--- compiler/ml_closure_gen.m 25 Sep 2003 07:56:28 -0000 1.20
+++ compiler/ml_closure_gen.m 21 Oct 2003 09:44:55 -0000
@@ -709,7 +709,7 @@
PredInfo, ProcInfo) },
%{ pred_info_purity(PredInfo, Purity) },
%{ pred_info_arg_types(PredInfo, ProcArgTypes) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
{ proc_info_headvars(ProcInfo, ProcHeadVars) },
{ proc_info_argmodes(ProcInfo, ProcArgModes) },
{ proc_info_interface_code_model(ProcInfo, CodeModel) },
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.131
diff -u -b -r1.131 ml_code_gen.m
--- compiler/ml_code_gen.m 25 Jul 2003 02:27:21 -0000 1.131
+++ compiler/ml_code_gen.m 21 Oct 2003 09:41:18 -0000
@@ -996,25 +996,24 @@
% Generate MLDS definitions for all the non-imported
% procedures of a given predicate (or function).
%
-:- pred ml_gen_pred(module_info, pred_id, pred_info, import_status,
- mlds__defns, mlds__defns, io__state, io__state).
-:- mode ml_gen_pred(in, in, in, in, in, out, di, uo) is det.
-
-ml_gen_pred(ModuleInfo, PredId, PredInfo, ImportStatus,
- MLDS_Defns0, MLDS_Defns) -->
- ( { ImportStatus = external(_) } ->
- { pred_info_procids(PredInfo, ProcIds) }
+:- pred ml_gen_pred(module_info::in, pred_id::in, pred_info::in,
+ import_status::in, mlds__defns::in, mlds__defns::out,
+ io__state::di, io__state::uo) is det.
+
+ml_gen_pred(ModuleInfo, PredId, PredInfo, ImportStatus, !MLDS_Defns, !IO) :-
+ ( ImportStatus = external(_) ->
+ ProcIds = pred_info_procids(PredInfo)
;
- { pred_info_non_imported_procids(PredInfo, ProcIds) }
+ ProcIds = pred_info_non_imported_procids(PredInfo)
),
- ( { ProcIds = [] } ->
- { MLDS_Defns = MLDS_Defns0 }
+ ( ProcIds = [] ->
+ true
;
write_pred_progress_message("% Generating MLDS code for ",
- PredId, ModuleInfo),
- { pred_info_procedures(PredInfo, ProcTable) },
- { ml_gen_procs(ProcIds, ModuleInfo, PredId, PredInfo,
- ProcTable, MLDS_Defns0, MLDS_Defns) }
+ PredId, ModuleInfo, !IO),
+ pred_info_procedures(PredInfo, ProcTable),
+ ml_gen_procs(ProcIds, ModuleInfo, PredId, PredInfo,
+ ProcTable, !MLDS_Defns)
).
:- pred ml_gen_procs(list(proc_id), module_info, pred_id, pred_info,
@@ -2890,7 +2889,7 @@
ThreadSafe = not_thread_safe
->
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_name(PredInfo, Name),
+ Name = pred_info_name(PredInfo),
c_util__quote_string(Name, MangledName),
string__append_list(["\tMR_OBTAIN_GLOBAL_LOCK(""",
MangledName, """);\n"], ObtainLock),
Index: compiler/ml_code_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_code_util.m,v
retrieving revision 1.74
diff -u -b -r1.74 ml_code_util.m
--- compiler/ml_code_util.m 20 Oct 2003 07:29:08 -0000 1.74
+++ compiler/ml_code_util.m 21 Oct 2003 13:38:33 -0000
@@ -1112,7 +1112,7 @@
PredInfo, ProcInfo),
proc_info_varset(ProcInfo, VarSet),
proc_info_headvars(ProcInfo, HeadVars),
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
pred_info_arg_types(PredInfo, HeadTypes),
proc_info_argmodes(ProcInfo, HeadModes),
proc_info_interface_code_model(ProcInfo, CodeModel),
@@ -1126,7 +1126,7 @@
PredInfo, ProcInfo),
proc_info_varset(ProcInfo, VarSet),
proc_info_headvars(ProcInfo, HeadVars),
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
pred_info_arg_types(PredInfo, HeadTypes),
proc_info_argmodes(ProcInfo, HeadModes),
proc_info_interface_code_model(ProcInfo, CodeModel),
@@ -1134,9 +1134,9 @@
% we must not generate GC tracing code for no_type_info_builtin
% procedures, because the generated GC tracing code would refer
% to type_infos that don't get passed
- pred_info_module(PredInfo, PredModule),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, PredArity),
+ PredModule = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
+ PredArity = pred_info_arity(PredInfo),
( no_type_info_builtin(PredModule, PredName, PredArity) ->
FuncParams = ml_gen_params(ModuleInfo, HeadVarNames, HeadTypes,
HeadModes, PredOrFunc, CodeModel),
@@ -1360,12 +1360,10 @@
),
FuncArg = mlds__argument(Name, MLDS_ArgType, Maybe_GC_TraceCode).
-
ml_is_output_det_function(ModuleInfo, PredId, ProcId, RetArgVar) :-
module_info_pred_proc_info(ModuleInfo, PredId, ProcId, PredInfo,
ProcInfo),
-
- pred_info_get_is_pred_or_func(PredInfo, function),
+ pred_info_is_pred_or_func(PredInfo) = function,
proc_info_interface_code_model(ProcInfo, model_det),
proc_info_argmodes(ProcInfo, Modes),
@@ -1379,7 +1377,6 @@
RetArgMode = top_out,
\+ type_util__is_dummy_argument_type(RetArgType).
-
%-----------------------------------------------------------------------------%
%
% Code for generating mlds__entity_names.
@@ -2341,7 +2338,7 @@
{ PredOrigArity = 1 },
{ Pred = pred((predicate), no, PredName, PredOrigArity, model_det,
no) },
- { hlds_pred__initial_proc_id(ProcId) },
+ { ProcId = hlds_pred__initial_proc_id },
{ mercury_private_builtin_module(PredModule) },
{ MLDS_Module = mercury_module_name_to_mlds(PredModule) },
{ Proc = qual(MLDS_Module, Pred - ProcId) },
Index: compiler/mlds_to_gcc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_gcc.m,v
retrieving revision 1.88
diff -u -b -r1.88 mlds_to_gcc.m
--- compiler/mlds_to_gcc.m 23 Oct 2003 02:02:09 -0000 1.88
+++ compiler/mlds_to_gcc.m 23 Oct 2003 02:12:02 -0000
@@ -2461,8 +2461,7 @@
% so we can use get_func_name below
ProcLabel = PredLabel - ProcId,
MaybeSeqNum = no,
- invalid_pred_id(InvalidPredId),
- Name = function(PredLabel, ProcId, MaybeSeqNum, InvalidPredId),
+ Name = function(PredLabel, ProcId, MaybeSeqNum, invalid_pred_id),
get_func_name(Name, _FuncName, AsmFuncName),
TablingPointerName = string__append("table_for_", AsmFuncName).
@@ -3531,9 +3530,8 @@
% convert the label into a entity_name,
% so we can use make_func_decl below
{ Label = qual(ModuleName, PredLabel - ProcId) },
- { invalid_pred_id(InvalidPredId) },
{ Name = qual(ModuleName, function(PredLabel, ProcId,
- MaybeSeqNum, InvalidPredId)) },
+ MaybeSeqNum, invalid_pred_id)) },
% build a function declaration for the function,
% and take its address.
make_func_decl(Name, Signature, GlobalInfo, FuncDecl),
Index: compiler/mlds_to_java.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_java.m,v
retrieving revision 1.44
diff -u -b -r1.44 mlds_to_java.m
--- compiler/mlds_to_java.m 20 Oct 2003 07:29:09 -0000 1.44
+++ compiler/mlds_to_java.m 21 Oct 2003 09:43:51 -0000
@@ -786,8 +786,8 @@
% XXX We should fill in the Context properly.
Context = mlds__make_context(term__context_init),
ModuleName = ProcLabel ^ mod_name,
- hlds_pred__initial_pred_id(PredID),
- initial_proc_id(ProcID),
+ PredID = hlds_pred__initial_pred_id,
+ ProcID = initial_proc_id,
%
% Create new method name
%
Index: compiler/mode_errors.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mode_errors.m,v
retrieving revision 1.75
diff -u -b -r1.75 mode_errors.m
--- compiler/mode_errors.m 26 May 2003 09:00:01 -0000 1.75
+++ compiler/mode_errors.m 21 Oct 2003 09:30:49 -0000
@@ -881,11 +881,11 @@
{ mode_info_get_procid(ModeInfo, ProcId) },
{ module_info_pred_proc_info(ModuleInfo, PredId, ProcId,
PredInfo, ProcInfo) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
{ pred_info_get_markers(PredInfo, PredMarkers) },
{ proc_info_declared_argmodes(ProcInfo, Modes0) },
{ strip_builtin_qualifiers_from_mode_list(Modes0, Modes) },
- { pred_info_name(PredInfo, Name0) },
+ { Name0 = pred_info_name(PredInfo) },
{ Name = unqualified(Name0) },
{ mode_info_get_instvarset(ModeInfo, InstVarSet) },
{ MaybeDet = no },
@@ -1006,7 +1006,7 @@
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
{ pred_info_get_markers(PredInfo, Markers) },
( { check_marker(Markers, infer_modes) } ->
- { pred_info_all_procids(PredInfo, ProcIds) },
+ { ProcIds = pred_info_all_procids(PredInfo) },
{ pred_info_procedures(PredInfo, Procs) },
write_mode_inference_messages_2(ProcIds, Procs, PredInfo,
OutputDetism, ModuleInfo)
@@ -1053,10 +1053,10 @@
:- mode write_mode_inference_message(in, in, in, in, di, uo) is det.
write_mode_inference_message(PredInfo, ProcInfo, OutputDetism, ModuleInfo) -->
- { pred_info_name(PredInfo, PredName) },
+ { PredName = pred_info_name(PredInfo) },
{ Name = unqualified(PredName) },
{ pred_info_context(PredInfo, Context) },
- { pred_info_arity(PredInfo, PredArity) },
+ { PredArity = pred_info_arity(PredInfo) },
{ proc_info_argmodes(ProcInfo, ArgModes0) },
% We need to strip off the extra type_info arguments inserted at the
@@ -1071,7 +1071,7 @@
),
{ varset__init(VarSet) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
( { OutputDetism = yes } ->
{ proc_info_inferred_determinism(ProcInfo, Detism) },
{ MaybeDet0 = yes(Detism) }
@@ -1197,19 +1197,19 @@
io__write_string(
" Here is the conflicting mode declaration.\n").
-output_mode_decl(ProcId, PredInfo) -->
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
- { pred_info_name(PredInfo, Name0) },
- { pred_info_procedures(PredInfo, Procs) },
- { map__lookup(Procs, ProcId, ProcInfo) },
- { proc_info_declared_argmodes(ProcInfo, Modes0) },
- { proc_info_declared_determinism(ProcInfo, MaybeDet) },
- { proc_info_context(ProcInfo, Context) },
- { varset__init(InstVarSet) },
- { Name = unqualified(Name0) },
- { strip_builtin_qualifiers_from_mode_list(Modes0, Modes) },
+output_mode_decl(ProcId, PredInfo, !IO) :-
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
+ Name0 = pred_info_name(PredInfo),
+ Name = unqualified(Name0),
+ pred_info_procedures(PredInfo, Procs),
+ map__lookup(Procs, ProcId, ProcInfo),
+ proc_info_declared_argmodes(ProcInfo, Modes0),
+ proc_info_declared_determinism(ProcInfo, MaybeDet),
+ proc_info_context(ProcInfo, Context),
+ varset__init(InstVarSet),
+ strip_builtin_qualifiers_from_mode_list(Modes0, Modes),
mercury_output_mode_subdecl(PredOrFunc, InstVarSet, Name, Modes,
- MaybeDet, Context).
+ MaybeDet, Context, !IO).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
Index: compiler/mode_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mode_util.m,v
retrieving revision 1.154
diff -u -b -r1.154 mode_util.m
--- compiler/mode_util.m 23 Aug 2003 13:31:03 -0000 1.154
+++ compiler/mode_util.m 21 Oct 2003 14:45:34 -0000
@@ -1280,15 +1280,14 @@
% and deconstructions may become non-local (XXX does this require
% rerunning mode analysis rather than just recompute_instmap_delta?).
-recompute_instmap_delta_proc(RecomputeAtomic, ProcInfo0, ProcInfo) -->
- =(ModuleInfo0),
- { proc_info_get_initial_instmap(ProcInfo0, ModuleInfo0, InstMap0) },
- { proc_info_vartypes(ProcInfo0, VarTypes) },
- { proc_info_goal(ProcInfo0, Goal0) },
- { proc_info_inst_varset(ProcInfo0, InstVarSet) },
+recompute_instmap_delta_proc(RecomputeAtomic, !ProcInfo, !ModuleInfo) :-
+ proc_info_get_initial_instmap(!.ProcInfo, !.ModuleInfo, InstMap0),
+ proc_info_vartypes(!.ProcInfo, VarTypes),
+ proc_info_goal(!.ProcInfo, Goal0),
+ proc_info_inst_varset(!.ProcInfo, InstVarSet),
recompute_instmap_delta(RecomputeAtomic, Goal0, Goal,
- VarTypes, InstVarSet, InstMap0),
- { proc_info_set_goal(ProcInfo0, Goal, ProcInfo) }.
+ VarTypes, InstVarSet, InstMap0, !ModuleInfo),
+ proc_info_set_goal(Goal, !ProcInfo).
recompute_instmap_delta(RecomputeAtomic, Goal0, Goal, VarTypes, InstVarSet,
InstMap0, ModuleInfo0, ModuleInfo) :-
Index: compiler/modecheck_call.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modecheck_call.m,v
retrieving revision 1.45
diff -u -b -r1.45 modecheck_call.m
--- compiler/modecheck_call.m 19 Sep 2003 11:10:03 -0000 1.45
+++ compiler/modecheck_call.m 21 Oct 2003 09:30:49 -0000
@@ -216,7 +216,7 @@
pred_info_procedures(PredInfo, Procs),
( MayChangeCalledProc = may_not_change_called_proc ->
- ( invalid_proc_id(ProcId0) ->
+ ( ProcId0 = invalid_proc_id ->
error("modecheck_call_pred: invalid proc_id")
;
ProcIds = [ProcId0]
@@ -224,7 +224,7 @@
;
% Get the list of different possible
% modes for the called predicate
- pred_info_all_procids(PredInfo, ProcIds)
+ ProcIds = pred_info_all_procids(PredInfo)
),
compute_arg_offset(PredInfo, ArgOffset),
@@ -240,7 +240,7 @@
set__init(WaitingVars),
mode_info_error(WaitingVars, mode_error_no_mode_decl,
ModeInfo0, ModeInfo),
- invalid_proc_id(TheProcId),
+ TheProcId = invalid_proc_id,
ArgVars = ArgVars0,
ExtraGoals = no_extra_goals
;
@@ -364,7 +364,7 @@
instmap__init_unreachable(Instmap),
mode_info_set_instmap(Instmap, ModeInfo1, ModeInfo)
;
- invalid_proc_id(TheProcId), % dummy value
+ TheProcId = invalid_proc_id, % dummy value
mode_info_get_instmap(ModeInfo0, InstMap),
instmap__lookup_vars(ArgVars, InstMap, ArgInsts),
mode_info_set_call_arg_context(0, ModeInfo0, ModeInfo1),
Index: compiler/modecheck_unify.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modecheck_unify.m,v
retrieving revision 1.63
diff -u -b -r1.63 modecheck_unify.m
--- compiler/modecheck_unify.m 21 Oct 2003 00:49:24 -0000 1.63
+++ compiler/modecheck_unify.m 21 Oct 2003 09:30:49 -0000
@@ -1080,8 +1080,8 @@
->
module_info_pred_info(ModuleInfo,
PredId, PredInfo),
- pred_info_module(PredInfo, PredModule),
- pred_info_name(PredInfo, PredName),
+ PredModule = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
RHS = functor(
cons(qualified(PredModule, PredName),
Arity),
Index: compiler/modes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modes.m,v
retrieving revision 1.272
diff -u -b -r1.272 modes.m
--- compiler/modes.m 28 Jul 2003 21:50:44 -0000 1.272
+++ compiler/modes.m 21 Oct 2003 15:02:38 -0000
@@ -532,7 +532,7 @@
map__keys(OldProcTable, OldProcIds),
list__foldl(copy_proc_body(OldProcTable), OldProcIds,
ProcTable0, ProcTable),
- pred_info_set_procedures(PredInfo0, ProcTable, PredInfo),
+ pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
map__set(PredTable0, PredId, PredInfo, PredTable)
).
@@ -545,7 +545,7 @@
map__lookup(OldProcTable, ProcId, OldProcInfo),
proc_info_goal(OldProcInfo, OldProcBody),
map__lookup(ProcTable0, ProcId, ProcInfo0),
- proc_info_set_goal(ProcInfo0, OldProcBody, ProcInfo),
+ proc_info_set_goal(OldProcBody, ProcInfo0, ProcInfo),
map__set(ProcTable0, ProcId, ProcInfo, ProcTable).
:- pred modecheck_pred_modes_2(list(pred_id), how_to_check_goal,
@@ -670,7 +670,7 @@
% pred_info_all_procids here, which means that we
% don't process modes that have already been inferred
% as invalid.
- { pred_info_procids(PredInfo0, ProcIds) },
+ { ProcIds = pred_info_procids(PredInfo0) },
modecheck_procs(ProcIds, PredId, WhatToCheck, MayChangeCalledProc,
ModuleInfo0, Changed0, 0,
ModuleInfo, Changed, NumErrors).
@@ -717,63 +717,61 @@
:- mode modecheck_proc_2(in, in, in, in, in, in, out, out, out, di, uo) is det.
modecheck_proc_2(ProcId, PredId, WhatToCheck, MayChangeCalledProc,
- ModuleInfo0, Changed0, ModuleInfo, Changed, NumErrors) -->
+ ModuleInfo0, Changed0, ModuleInfo, Changed, NumErrors, !IO) :-
% get the proc_info from the module_info
- { module_info_pred_proc_info(ModuleInfo0, PredId, ProcId,
- _PredInfo0, ProcInfo0) },
- ( { proc_info_can_process(ProcInfo0, no) } ->
- { ModuleInfo = ModuleInfo0 },
- { Changed = Changed0 },
- { NumErrors = 0 }
+ module_info_pred_proc_info(ModuleInfo0, PredId, ProcId,
+ _PredInfo0, ProcInfo0),
+ ( proc_info_can_process(ProcInfo0, no) ->
+ ModuleInfo = ModuleInfo0,
+ Changed = Changed0,
+ NumErrors = 0
;
% modecheck it
modecheck_proc_3(ProcId, PredId, WhatToCheck,
- MayChangeCalledProc, ModuleInfo0, ProcInfo0, Changed0,
- ModuleInfo1, ProcInfo, Changed, NumErrors),
+ MayChangeCalledProc, ModuleInfo0, ModuleInfo1,
+ ProcInfo0, ProcInfo, Changed0, Changed,
+ NumErrors, !IO),
% save the proc_info back in the module_info
- { module_info_preds(ModuleInfo1, Preds1) },
- { map__lookup(Preds1, PredId, PredInfo1) },
- { pred_info_procedures(PredInfo1, Procs1) },
- { map__set(Procs1, ProcId, ProcInfo, Procs) },
- { pred_info_set_procedures(PredInfo1, Procs, PredInfo) },
- { map__set(Preds1, PredId, PredInfo, Preds) },
- { module_info_set_preds(ModuleInfo1, Preds, ModuleInfo) }
+ module_info_preds(ModuleInfo1, Preds1),
+ map__lookup(Preds1, PredId, PredInfo1),
+ pred_info_procedures(PredInfo1, Procs1),
+ map__set(Procs1, ProcId, ProcInfo, Procs),
+ pred_info_set_procedures(Procs, PredInfo1, PredInfo),
+ map__set(Preds1, PredId, PredInfo, Preds),
+ module_info_set_preds(ModuleInfo1, Preds, ModuleInfo)
).
modecheck_proc_info(ProcId, PredId, ModuleInfo0, ProcInfo0,
ModuleInfo, ProcInfo, NumErrors) -->
{ WhatToCheck = check_modes },
modecheck_proc_3(ProcId, PredId, WhatToCheck, may_change_called_proc,
- ModuleInfo0, ProcInfo0, no,
- ModuleInfo, ProcInfo, _Changed, NumErrors).
+ ModuleInfo0, ModuleInfo, ProcInfo0, ProcInfo, no, _Changed,
+ NumErrors).
-:- pred modecheck_proc_3(proc_id, pred_id, how_to_check_goal,
- may_change_called_proc, module_info, proc_info, bool,
- module_info, proc_info, bool, int, io__state, io__state).
-:- mode modecheck_proc_3(in, in, in, in, in, in, in,
- out, out, out, out, di, uo) is det.
+:- pred modecheck_proc_3(proc_id::in, pred_id::in, how_to_check_goal::in,
+ may_change_called_proc::in, module_info::in, module_info::out,
+ proc_info::in, proc_info::out, bool::in, bool::out, int::out,
+ io__state::di, io__state::uo) is det.
modecheck_proc_3(ProcId, PredId, WhatToCheck, MayChangeCalledProc,
- ModuleInfo0, ProcInfo0, Changed0,
- ModuleInfo, ProcInfo, Changed, NumErrors,
- IOState0, IOState) :-
+ !ModuleInfo, !ProcInfo, !Changed, NumErrors, !IO) :-
% extract the useful fields in the proc_info
- proc_info_headvars(ProcInfo0, HeadVars),
- proc_info_argmodes(ProcInfo0, ArgModes0),
- proc_info_arglives(ProcInfo0, ModuleInfo0, ArgLives0),
- proc_info_goal(ProcInfo0, Body0),
+ proc_info_headvars(!.ProcInfo, HeadVars),
+ proc_info_argmodes(!.ProcInfo, ArgModes0),
+ proc_info_arglives(!.ProcInfo, !.ModuleInfo, ArgLives0),
+ proc_info_goal(!.ProcInfo, Body0),
% We use the context of the first clause, unless
% there weren't any clauses at all, in which case
% we use the context of the mode declaration.
- module_info_pred_info(ModuleInfo0, PredId, PredInfo),
+ module_info_pred_info(!.ModuleInfo, PredId, PredInfo),
pred_info_clauses_info(PredInfo, ClausesInfo),
clauses_info_clauses(ClausesInfo, ClauseList),
( ClauseList = [FirstClause | _] ->
FirstClause = clause(_, _, _, Context)
;
- proc_info_context(ProcInfo0, Context)
+ proc_info_context(!.ProcInfo, Context)
),
%
@@ -784,8 +782,9 @@
%
% construct the initial instmap
- mode_list_get_initial_insts(ArgModes0, ModuleInfo0, ArgInitialInsts),
- assoc_list__from_corresponding_lists(HeadVars, ArgInitialInsts, InstAL),
+ mode_list_get_initial_insts(ArgModes0, !.ModuleInfo, ArgInitialInsts),
+ assoc_list__from_corresponding_lists(HeadVars, ArgInitialInsts,
+ InstAL),
instmap__from_assoc_list(InstAL, InstMap0),
% construct the initial set of live vars:
@@ -794,10 +793,10 @@
set__list_to_set(LiveVarsList, LiveVars),
% initialize the mode info
- mode_info_init(IOState0, ModuleInfo0, PredId, ProcId, Context,
+ mode_info_init(!.IO, !.ModuleInfo, PredId, ProcId, Context,
LiveVars, InstMap0, WhatToCheck,
MayChangeCalledProc, ModeInfo0),
- mode_info_set_changed_flag(Changed0, ModeInfo0, ModeInfo1),
+ mode_info_set_changed_flag(!.Changed, ModeInfo0, ModeInfo1),
% modecheck the procedure body
( WhatToCheck = check_unique_modes ->
@@ -808,7 +807,7 @@
% check that final insts match those specified in the
% mode declaration
- mode_list_get_final_insts(ArgModes0, ModuleInfo0, ArgFinalInsts0),
+ mode_list_get_final_insts(ArgModes0, !.ModuleInfo, ArgFinalInsts0),
pred_info_get_markers(PredInfo, Markers),
( check_marker(Markers, infer_modes) ->
InferModes = yes
@@ -826,25 +825,24 @@
% This is sometimes handy for debugging:
% report_mode_errors(ModeInfo3, ModeInfo),
mode_info_get_errors(ModeInfo, ModeErrors),
- ProcInfo1 = ProcInfo0 ^ mode_errors := ModeErrors,
+ !:ProcInfo = !.ProcInfo ^ mode_errors := ModeErrors,
NumErrors = 0
;
% report any errors we found
report_mode_errors(ModeInfo3, ModeInfo),
- mode_info_get_num_errors(ModeInfo, NumErrors),
- ProcInfo1 = ProcInfo0
+ mode_info_get_num_errors(ModeInfo, NumErrors)
),
% save away the results
inst_lists_to_mode_list(ArgInitialInsts, ArgFinalInsts, ArgModes),
- mode_info_get_changed_flag(ModeInfo, Changed),
- mode_info_get_module_info(ModeInfo, ModuleInfo),
- mode_info_get_io_state(ModeInfo, IOState),
+ mode_info_get_changed_flag(ModeInfo, !:Changed),
+ mode_info_get_module_info(ModeInfo, !:ModuleInfo),
+ mode_info_get_io_state(ModeInfo, !:IO),
mode_info_get_varset(ModeInfo, VarSet),
mode_info_get_var_types(ModeInfo, VarTypes),
- proc_info_set_goal(ProcInfo1, Body, ProcInfo2),
- proc_info_set_varset(ProcInfo2, VarSet, ProcInfo3),
- proc_info_set_vartypes(ProcInfo3, VarTypes, ProcInfo4),
- proc_info_set_argmodes(ProcInfo4, ArgModes, ProcInfo).
+ proc_info_set_goal(Body, !ProcInfo),
+ proc_info_set_varset(VarSet, !ProcInfo),
+ proc_info_set_vartypes(VarTypes, !ProcInfo),
+ proc_info_set_argmodes(ArgModes, !ProcInfo).
% modecheck_final_insts for a lambda expression
modecheck_final_insts(HeadVars, ArgFinalInsts, ModeInfo0, ModeInfo) :-
@@ -1181,7 +1179,7 @@
=(ModeInfo),
{ mode_info_get_module_info(ModeInfo, ModuleInfo) },
{ mode_info_get_predid(ModeInfo, CallerPredId) },
- { builtin_state(ModuleInfo, CallerPredId, PredId, Mode, Builtin) },
+ { Builtin = builtin_state(ModuleInfo, CallerPredId, PredId, Mode) },
{ Call = call(PredId, Mode, Args, Builtin, Context, PredName) },
handle_extra_goals(Call, ExtraGoals, GoalInfo0, Args0, Args,
InstMap0, Goal),
@@ -1795,7 +1793,7 @@
% type_info arguments get argument numbers less than or equal to 0.
%
compute_arg_offset(PredInfo, ArgOffset) :-
- pred_info_arity(PredInfo, OrigArity),
+ OrigArity = pred_info_arity(PredInfo),
pred_info_arg_types(PredInfo, ArgTypes),
list__length(ArgTypes, CurrentArity),
ArgOffset = OrigArity - CurrentArity.
@@ -2236,7 +2234,7 @@
pred_check_eval_methods([PredId|Rest], ModuleInfo0, ModuleInfo) -->
{ module_info_preds(ModuleInfo0, Preds) },
{ map__lookup(Preds, PredId, PredInfo) },
- { pred_info_procids(PredInfo, ProcIds) },
+ { ProcIds = pred_info_procids(PredInfo) },
proc_check_eval_methods(ProcIds, PredId, ModuleInfo0, ModuleInfo1),
pred_check_eval_methods(Rest, ModuleInfo1, ModuleInfo).
@@ -2269,8 +2267,8 @@
{ ModuleInfo2 = ModuleInfo1 }
),
(
- { pred_info_name(PredInfo, "main") },
- { pred_info_arity(PredInfo, 2) },
+ { pred_info_name(PredInfo) = "main" },
+ { pred_info_arity(PredInfo) = 2 },
{ pred_info_is_exported(PredInfo) },
{ \+ check_mode_of_main(Modes, ModuleInfo2) }
->
Index: compiler/passes_aux.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/passes_aux.m,v
retrieving revision 1.56
diff -u -b -r1.56 passes_aux.m
--- compiler/passes_aux.m 6 Aug 2003 12:38:11 -0000 1.56
+++ compiler/passes_aux.m 21 Oct 2003 15:05:43 -0000
@@ -22,12 +22,12 @@
%-----------------------------------------------------------------------------%
:- type task ---> update_proc(pred(
- proc_info, module_info, proc_info))
+ module_info, proc_info, proc_info))
; update_proc_predid(pred(
- proc_info, pred_id, module_info, proc_info))
+ pred_id, module_info, proc_info, proc_info))
; update_proc_predprocid(pred(
- proc_info, pred_id, proc_id,
- module_info, proc_info))
+ pred_id, proc_id, module_info,
+ proc_info, proc_info))
; update_proc_io(pred(
pred_id, proc_id, module_info,
proc_info, proc_info, io__state, io__state))
@@ -331,106 +331,82 @@
:- mode process_nonimported_procs_in_preds(in, task, out(task),
pred(in) is semidet, in, out, di, uo) is det.
-process_nonimported_procs_in_preds([], Task, Task, _, ModuleInfo, ModuleInfo)
- --> [].
-process_nonimported_procs_in_preds([PredId | PredIds], Task0, Task, Filter,
- ModuleInfo0, ModuleInfo) -->
- { module_info_preds(ModuleInfo0, PredTable) },
- { map__lookup(PredTable, PredId, PredInfo) },
- ( { call(Filter, PredInfo) } ->
- { pred_info_non_imported_procids(PredInfo, ProcIds) },
- process_nonimported_procs(ProcIds, PredId, Task0, Task1,
- ModuleInfo0, ModuleInfo1)
+process_nonimported_procs_in_preds([], !Task, _, !ModuleInfo, !IO).
+process_nonimported_procs_in_preds([PredId | PredIds], !Task, Filter,
+ !ModuleInfo, !IO) :-
+ module_info_preds(!.ModuleInfo, PredTable),
+ map__lookup(PredTable, PredId, PredInfo),
+ ( call(Filter, PredInfo) ->
+ ProcIds = pred_info_non_imported_procids(PredInfo),
+ process_nonimported_procs(ProcIds, PredId, !Task,
+ !ModuleInfo, !IO)
;
- { ModuleInfo1 = ModuleInfo0 },
- { Task1 = Task0 }
+ true
),
- process_nonimported_procs_in_preds(PredIds, Task1, Task, Filter,
- ModuleInfo1, ModuleInfo).
+ 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.
-process_nonimported_procs([], _PredId, Task, Task,
- ModuleInfo, ModuleInfo, State, State).
-process_nonimported_procs([ProcId | ProcIds], PredId, Task0, Task,
- ModuleInfo0, ModuleInfo, State0, State) :-
-
- module_info_preds(ModuleInfo0, Preds0),
+process_nonimported_procs([], _PredId, !Task, !ModuleInfo, !IO).
+process_nonimported_procs([ProcId | ProcIds], PredId, !Task, !ModuleInfo,
+ !IO) :-
+ module_info_preds(!.ModuleInfo, Preds0),
map__lookup(Preds0, PredId, Pred0),
pred_info_procedures(Pred0, Procs0),
map__lookup(Procs0, ProcId, Proc0),
(
- Task0 = update_module(Closure),
- call(Closure, PredId, ProcId, Pred0, Proc0, Proc,
- ModuleInfo0, ModuleInfo8),
- Task1 = Task0,
- State9 = State0
+ !.Task = update_module(Closure),
+ call(Closure, PredId, ProcId, Pred0, Proc0, Proc, !ModuleInfo)
;
- Task0 = update_module_io(Closure),
- call(Closure, PredId, ProcId, Proc0, Proc,
- ModuleInfo0, ModuleInfo8, State0, State9),
- Task1 = Task0
+ !.Task = update_module_io(Closure),
+ call(Closure, PredId, ProcId, Proc0, Proc, !ModuleInfo, !IO)
+ ;
+ !.Task = update_proc(Closure),
+ call(Closure, !.ModuleInfo, Proc0, Proc)
+ ;
+ !.Task = update_proc_predid(Closure),
+ call(Closure, PredId, !.ModuleInfo, Proc0, Proc)
+ ;
+ !.Task = update_proc_predprocid(Closure),
+ call(Closure, PredId, ProcId, !.ModuleInfo, Proc0, Proc)
+ ;
+ !.Task = update_proc_io(Closure),
+ call(Closure, PredId, ProcId, !.ModuleInfo, Proc0, Proc, !IO)
;
- Task0 = update_proc(Closure),
- call(Closure, Proc0, ModuleInfo0, Proc),
- ModuleInfo8 = ModuleInfo0,
- Task1 = Task0,
- State9 = State0
- ;
- Task0 = update_proc_predid(Closure),
- call(Closure, Proc0, PredId, ModuleInfo0, Proc),
- ModuleInfo8 = ModuleInfo0,
- Task1 = Task0,
- State9 = State0
- ;
- Task0 = update_proc_predprocid(Closure),
- call(Closure, Proc0, PredId, ProcId, ModuleInfo0, Proc),
- ModuleInfo8 = ModuleInfo0,
- Task1 = Task0,
- State9 = State0
- ;
- Task0 = update_proc_io(Closure),
- call(Closure, PredId, ProcId, ModuleInfo0,
- Proc0, Proc, State0, State9),
- ModuleInfo8 = ModuleInfo0,
- Task1 = Task0
- ;
- Task0 = update_proc_error(Closure),
- call(Closure, PredId, ProcId, ModuleInfo0, ModuleInfo1,
- Proc0, Proc, WarnCnt, ErrCnt, State0, State1),
- Task1 = Task0,
+ !.Task = update_proc_error(Closure),
+ call(Closure, PredId, ProcId, !ModuleInfo, Proc0, Proc,
+ WarnCnt, ErrCnt, !IO),
passes_aux__handle_errors(WarnCnt, ErrCnt,
- ModuleInfo1, ModuleInfo8, State1, State9)
+ !ModuleInfo, !IO)
;
- Task0 = update_pred_error(_),
+ !.Task = update_pred_error(_),
error("passes_aux:process_non_imported_procs")
;
- Task0 = update_module_cookie(Closure, Cookie0),
+ !.Task = update_module_cookie(Closure, Cookie0),
call(Closure, PredId, ProcId, Proc0, Proc,
- Cookie0, Cookie1, ModuleInfo0, ModuleInfo8),
- Task1 = update_module_cookie(Closure, Cookie1),
- State9 = State0
+ Cookie0, Cookie1, !ModuleInfo),
+ !:Task = update_module_cookie(Closure, Cookie1)
),
% If the pass changed the module_info, it may have changed
% the pred table or the proc table for this pred_id. Don't
% take any chances.
- module_info_preds(ModuleInfo8, Preds8),
+ module_info_preds(!.ModuleInfo, Preds8),
map__lookup(Preds8, PredId, Pred8),
pred_info_procedures(Pred8, Procs8),
map__det_update(Procs8, ProcId, Proc, Procs),
- pred_info_set_procedures(Pred8, Procs, Pred),
+ pred_info_set_procedures(Procs, Pred8, Pred),
map__det_update(Preds8, PredId, Pred, Preds),
- module_info_set_preds(ModuleInfo8, Preds, ModuleInfo9),
+ module_info_set_preds(!.ModuleInfo, Preds, !:ModuleInfo),
- process_nonimported_procs(ProcIds, PredId, Task1, Task,
- ModuleInfo9, ModuleInfo, State9, State).
+ process_nonimported_procs(ProcIds, PredId, !Task, !ModuleInfo, !IO).
write_pred_progress_message(Message, PredId, ModuleInfo) -->
globals__io_lookup_bool_option(very_verbose, VeryVerbose),
@@ -721,9 +697,9 @@
report_pred_proc_id(ModuleInfo, PredId, ProcId, MaybeContext, Context) -->
{ module_info_pred_proc_info(ModuleInfo, PredId, ProcId,
PredInfo, ProcInfo) },
- { pred_info_name(PredInfo, PredName) },
- { pred_info_arity(PredInfo, Arity) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { PredName = pred_info_name(PredInfo) },
+ { Arity = pred_info_arity(PredInfo) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
{ proc_info_context(ProcInfo, Context) },
{ proc_info_argmodes(ProcInfo, ArgModes0) },
Index: compiler/pd_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/pd_info.m,v
retrieving revision 1.11
diff -u -b -r1.11 pd_info.m
--- compiler/pd_info.m 26 May 2003 09:00:04 -0000 1.11
+++ compiler/pd_info.m 21 Oct 2003 13:52:16 -0000
@@ -705,7 +705,7 @@
{ counter__allocate(Count, Counter0, Counter) },
pd_info_set_counter(Counter),
pd_info_get_pred_info(PredInfo),
- { pred_info_name(PredInfo, PredName) },
+ { PredName = pred_info_name(PredInfo) },
{ goal_info_get_context(GoalInfo, Context) },
{ term__context_line(Context, Line) },
pd_info_get_module_info(ModuleInfo0),
Index: compiler/pd_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/pd_util.m,v
retrieving revision 1.26
diff -u -b -r1.26 pd_util.m
--- compiler/pd_util.m 19 Sep 2003 11:10:03 -0000 1.26
+++ compiler/pd_util.m 21 Oct 2003 13:53:25 -0000
@@ -199,8 +199,8 @@
{ constraint_info_deconstruct(CInfo, ModuleInfo,
VarTypes, VarSet, Changed) },
pd_info_set_module_info(ModuleInfo),
- { proc_info_set_vartypes(ProcInfo0, VarTypes, ProcInfo1) },
- { proc_info_set_varset(ProcInfo1, VarSet, ProcInfo) },
+ { proc_info_set_vartypes(VarTypes, ProcInfo0, ProcInfo1) },
+ { proc_info_set_varset(VarSet, ProcInfo1, ProcInfo) },
pd_info_set_proc_info(ProcInfo),
( { Changed = yes } ->
pd_debug__output_goal(
@@ -258,10 +258,10 @@
{ simplify_info_get_type_info_varmap(SimplifyInfo, TVarMap) },
{ simplify_info_get_typeclass_info_varmap(SimplifyInfo, TCVarMap) },
pd_info_get_proc_info(ProcInfo1),
- { proc_info_set_varset(ProcInfo1, VarSet, ProcInfo2) },
- { proc_info_set_vartypes(ProcInfo2, VarTypes, ProcInfo3) },
- { proc_info_set_typeinfo_varmap(ProcInfo3, TVarMap, ProcInfo4) },
- { proc_info_set_typeclass_info_varmap(ProcInfo4, TCVarMap, ProcInfo) },
+ { proc_info_set_varset(VarSet, ProcInfo1, ProcInfo2) },
+ { proc_info_set_vartypes(VarTypes, ProcInfo2, ProcInfo3) },
+ { proc_info_set_typeinfo_varmap(TVarMap, ProcInfo3, ProcInfo4) },
+ { proc_info_set_typeclass_info_varmap(TCVarMap, ProcInfo4, ProcInfo) },
pd_info_set_proc_info(ProcInfo),
pd_info_incr_cost_delta(CostDelta),
pd_info_set_module_info(ModuleInfo).
@@ -316,8 +316,8 @@
{ module_info_pred_proc_info(ModuleInfo, PredId, ProcId,
PredInfo, ProcInfo1) },
pd_info_set_pred_info(PredInfo),
- { proc_info_set_varset(ProcInfo1, VarSet, ProcInfo2) },
- { proc_info_set_vartypes(ProcInfo2, VarTypes, ProcInfo) },
+ { proc_info_set_varset(VarSet, ProcInfo1, ProcInfo2) },
+ { proc_info_set_vartypes(VarTypes, ProcInfo2, ProcInfo) },
pd_info_set_proc_info(ProcInfo),
pd_info_set_io_state(IO).
@@ -797,10 +797,10 @@
pd_info_get_proc_info(ProcInfo0),
{ proc_info_varset(ProcInfo0, VarSet0) },
{ proc_info_vartypes(ProcInfo0, VarTypes0) },
- { implicitly_quantify_goal(Goal0, VarSet0, VarTypes0, NonLocals,
- Goal, VarSet, VarTypes, _) },
- { proc_info_set_varset(ProcInfo0, VarSet, ProcInfo1) },
- { proc_info_set_vartypes(ProcInfo1, VarTypes, ProcInfo) },
+ { implicitly_quantify_goal(NonLocals, _, Goal0, Goal,
+ VarSet0, VarSet, VarTypes0, VarTypes) },
+ { proc_info_set_varset(VarSet, ProcInfo0, ProcInfo1) },
+ { proc_info_set_vartypes(VarTypes, ProcInfo1, ProcInfo) },
pd_info_set_proc_info(ProcInfo).
pd_util__recompute_instmap_delta(Goal0, Goal) -->
Index: compiler/polymorphism.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/polymorphism.m,v
retrieving revision 1.244
diff -u -b -r1.244 polymorphism.m
--- compiler/polymorphism.m 22 Oct 2003 06:01:41 -0000 1.244
+++ compiler/polymorphism.m 23 Oct 2003 01:30:56 -0000
@@ -404,9 +404,9 @@
% to handle complicated unifications.
hlds_pred__pred_info_is_aditi_aggregate(PredInfo)
;
- pred_info_module(PredInfo, PredModule),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, PredArity),
+ PredModule = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
+ PredArity = pred_info_arity(PredInfo),
no_type_info_builtin(PredModule, PredName, PredArity)
)
->
@@ -453,8 +453,8 @@
map__apply_to_list(ExtraHeadVars, VarTypes0, ExtraArgTypes),
list__append(ExtraArgTypes, ArgTypes0, ArgTypes),
- pred_info_set_arg_types(PredInfo0, TypeVarSet, ExistQVars,
- ArgTypes, PredInfo1),
+ pred_info_set_arg_types(TypeVarSet, ExistQVars, ArgTypes,
+ PredInfo0, PredInfo1),
%
% If the clauses binds some existentially quantified
@@ -479,8 +479,8 @@
Subn, HeadVarType),
map__set(Types0, HeadVar, HeadVarType, Types)
), ExtraHeadVars, VarTypes0, VarTypes),
- clauses_info_set_vartypes(ClausesInfo0, VarTypes, ClausesInfo),
- pred_info_set_clauses_info(PredInfo1, ClausesInfo, PredInfo2),
+ clauses_info_set_vartypes(VarTypes, ClausesInfo0, ClausesInfo),
+ pred_info_set_clauses_info(ClausesInfo, PredInfo1, PredInfo2),
% Fix up the var-types in the procedures as well.
% It would be better if this were done before copying
@@ -488,10 +488,10 @@
pred_info_procedures(PredInfo2, Procs0),
map__map_values(
(pred(_::in, ProcInfo0::in, ProcInfo::out) is det :-
- proc_info_set_vartypes(ProcInfo0,
- VarTypes, ProcInfo)
+ proc_info_set_vartypes(VarTypes,
+ ProcInfo0, ProcInfo)
), Procs0, Procs),
- pred_info_set_procedures(PredInfo2, Procs, PredInfo)
+ pred_info_set_procedures(Procs, PredInfo2, PredInfo)
;
PredInfo = PredInfo1
),
@@ -529,19 +529,19 @@
ClausesInfo0, ClausesInfo, Info, ExtraArgModes),
poly_info_get_module_info(Info, !:ModuleInfo),
poly_info_get_typevarset(Info, TypeVarSet),
- pred_info_set_typevarset(PredInfo0, TypeVarSet, PredInfo1),
- pred_info_set_clauses_info(PredInfo1, ClausesInfo, PredInfo2),
+ pred_info_set_typevarset(TypeVarSet, PredInfo0, PredInfo1),
+ pred_info_set_clauses_info(ClausesInfo, PredInfo1, PredInfo2),
%
% do a pass over the proc_infos, copying the relevant information
% from the clauses_info and the poly_info, and updating all
% the argmodes with modes for the extra arguments.
%
- pred_info_procids(PredInfo2, ProcIds),
+ ProcIds = pred_info_procids(PredInfo2),
pred_info_procedures(PredInfo2, Procs0),
list__foldl(polymorphism__process_proc_in_table(PredInfo2, ClausesInfo,
ExtraArgModes), ProcIds, Procs0, Procs),
- pred_info_set_procedures(PredInfo2, Procs, PredInfo),
+ pred_info_set_procedures(Procs, PredInfo2, PredInfo),
module_info_set_pred_info(!.ModuleInfo, PredId, PredInfo,
!:ModuleInfo).
@@ -650,13 +650,12 @@
clauses_info_type_info_varmap(ClausesInfo, TypeInfoVarMap),
clauses_info_varset(ClausesInfo, VarSet),
clauses_info_vartypes(ClausesInfo, VarTypes),
- proc_info_set_headvars(!.ProcInfo, HeadVars, !:ProcInfo),
- proc_info_set_typeclass_info_varmap(!.ProcInfo,
- TypeClassInfoVarMap, !:ProcInfo),
- proc_info_set_typeinfo_varmap(!.ProcInfo,
- TypeInfoVarMap, !:ProcInfo),
- proc_info_set_varset(!.ProcInfo, VarSet, !:ProcInfo),
- proc_info_set_vartypes(!.ProcInfo, VarTypes, !:ProcInfo)
+ proc_info_set_headvars(HeadVars, !ProcInfo),
+ proc_info_set_typeclass_info_varmap(TypeClassInfoVarMap,
+ !ProcInfo),
+ proc_info_set_typeinfo_varmap(TypeInfoVarMap, !ProcInfo),
+ proc_info_set_varset(VarSet, !ProcInfo),
+ proc_info_set_vartypes(VarTypes, !ProcInfo)
;
copy_clauses_to_proc(ProcId, ClausesInfo, !ProcInfo)
),
@@ -666,7 +665,7 @@
%
proc_info_argmodes(!.ProcInfo, ArgModes1),
list__append(ExtraArgModes, ArgModes1, ArgModes),
- proc_info_set_argmodes(!.ProcInfo, ArgModes, !:ProcInfo).
+ proc_info_set_argmodes(ArgModes, !ProcInfo).
% XXX the following code ought to be rewritten to handle
% existential/universal type_infos and type_class_infos
@@ -1025,9 +1024,9 @@
poly_info_get_module_info(!.Info, ModuleInfo),
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_module(PredInfo, PredModule),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, PredArity),
+ PredModule = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
+ PredArity = pred_info_arity(PredInfo),
( no_type_info_builtin(PredModule, PredName, PredArity) ->
Goal = Goal0 - GoalInfo
@@ -1404,8 +1403,8 @@
module_info_pred_proc_info(ModuleInfo0, PredId, ProcId,
PredInfo, ProcInfo),
- pred_info_module(PredInfo, PredModule),
- pred_info_name(PredInfo, PredName),
+ PredModule = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
QualifiedPName = qualified(PredModule, PredName),
CallUnifyContext = call_unify_context(X0,
@@ -1455,7 +1454,7 @@
%
% construct the lambda expression
%
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
Functor = lambda_goal(Purity, PredOrFunc, EvalMethod, modes_are_ok,
ArgVars0, LambdaVars, LambdaModes, LambdaDet, LambdaGoal).
@@ -1807,9 +1806,9 @@
term__vars_list(PredArgTypes, PredTypeVars0)
),
- pred_info_module(PredInfo, PredModule),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, PredArity),
+ PredModule = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
+ PredArity = pred_info_arity(PredInfo),
(
(
% optimize for common case of non-polymorphic call
@@ -1971,8 +1970,8 @@
poly_info_get_varset(!.Info, VarSet0),
poly_info_get_var_types(!.Info, VarTypes0),
set__list_to_set(HeadVars, OutsideVars),
- implicitly_quantify_goal(Goal0, VarSet0, VarTypes0,
- OutsideVars, Goal, VarSet, VarTypes, _Warnings),
+ implicitly_quantify_goal(OutsideVars, _Warnings,
+ Goal0, Goal, VarSet0, VarSet, VarTypes0, VarTypes),
poly_info_set_varset_and_types(VarSet, VarTypes, !Info)
).
@@ -2011,8 +2010,8 @@
TypeClassVarMap, VarTypes0, ExistQVars,
NonLocalsPlusArgs, NewOutsideVars),
set__union(NonLocals, NewOutsideVars, OutsideVars),
- implicitly_quantify_goal(!.Goal, VarSet0, VarTypes0,
- OutsideVars, !:Goal, VarSet, VarTypes, _Warnings),
+ implicitly_quantify_goal(OutsideVars, _Warnings, !Goal,
+ VarSet0, VarSet, VarTypes0, VarTypes),
poly_info_set_varset_and_types(VarSet, VarTypes, !Info)
).
@@ -2729,8 +2728,8 @@
"type_to_ctor_and_args failed")
),
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_module(PredInfo, Module),
- pred_info_name(PredInfo, Name),
+ Module = pred_info_module(PredInfo),
+ Name = pred_info_name(PredInfo),
PredName = qualified(Module, Name),
special_pred_mode_num(SpecialPredId, ProcInt),
proc_id_to_int(ProcId, ProcInt)
@@ -3133,8 +3132,8 @@
polymorphism__is_typeclass_info_manipulator(ModuleInfo, PredId,
TypeClassManipulator) :-
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_module(PredInfo, mercury_private_builtin_module),
- pred_info_name(PredInfo, PredName),
+ mercury_private_builtin_module = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
(
PredName = "type_info_from_typeclass_info",
TypeClassManipulator = type_info_from_typeclass_info
@@ -3263,11 +3262,11 @@
goal_info_init(NonLocals, InstmapDelta, Detism, Purity, GoalInfo),
BodyGoal = BodyGoalExpr - GoalInfo,
- proc_info_set_goal(ProcInfo0, BodyGoal, ProcInfo),
+ proc_info_set_goal(BodyGoal, ProcInfo0, ProcInfo),
map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable),
- pred_info_set_procedures(PredInfo0, ProcTable, PredInfo1),
+ pred_info_set_procedures(ProcTable, PredInfo0, PredInfo1),
( pred_info_is_imported(PredInfo1) ->
- pred_info_set_import_status(PredInfo1, opt_imported, PredInfo)
+ pred_info_set_import_status(opt_imported, PredInfo1, PredInfo)
;
PredInfo = PredInfo1
),
@@ -3372,12 +3371,11 @@
TypeclassInfoLocations, _Proofs, _OldPredInfo, ModuleInfo),
% set the new values of the fields in proc_info and pred_info
- proc_info_set_varset(!.ProcInfo, VarSet, !:ProcInfo),
- proc_info_set_vartypes(!.ProcInfo, VarTypes, !:ProcInfo),
- proc_info_set_typeinfo_varmap(!.ProcInfo, TypeInfoMap, !:ProcInfo),
- proc_info_set_typeclass_info_varmap(!.ProcInfo, TypeclassInfoLocations,
- !:ProcInfo),
- pred_info_set_typevarset(!.PredInfo, TypeVarSet, !:PredInfo).
+ proc_info_set_varset(VarSet, !ProcInfo),
+ proc_info_set_vartypes(VarTypes, !ProcInfo),
+ proc_info_set_typeinfo_varmap(TypeInfoMap, !ProcInfo),
+ proc_info_set_typeclass_info_varmap(TypeclassInfoLocations, !ProcInfo),
+ pred_info_set_typevarset(TypeVarSet, !PredInfo).
%---------------------------------------------------------------------------%
Index: compiler/post_typecheck.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/post_typecheck.m,v
retrieving revision 1.57
diff -u -b -r1.57 post_typecheck.m
--- compiler/post_typecheck.m 20 Oct 2003 07:29:10 -0000 1.57
+++ compiler/post_typecheck.m 21 Oct 2003 16:22:35 -0000
@@ -291,10 +291,10 @@
pred_info_get_constraint_proofs(PredInfo0, Proofs0),
bind_type_vars_to_void(Set, VarTypesMap0, VarTypesMap,
Proofs0, Proofs),
- clauses_info_set_vartypes(ClausesInfo0, VarTypesMap,
- ClausesInfo),
- pred_info_set_clauses_info(PredInfo0, ClausesInfo, PredInfo1),
- pred_info_set_constraint_proofs(PredInfo1, Proofs, PredInfo)
+ clauses_info_set_vartypes(VarTypesMap,
+ ClausesInfo0, ClausesInfo),
+ pred_info_set_clauses_info(ClausesInfo, PredInfo0, PredInfo1),
+ pred_info_set_constraint_proofs(Proofs, PredInfo1, PredInfo)
).
:- pred check_type_bindings_2(assoc_list(prog_var, (type)), list(tvar),
@@ -458,7 +458,7 @@
post_typecheck__resolve_pred_overloading(PredId0, Args0, CallerPredInfo,
ModuleInfo, PredName0, PredName, PredId) :-
- ( invalid_pred_id(PredId0) ->
+ ( PredId0 = invalid_pred_id ->
%
% Find the set of candidate pred_ids for predicates which
% have the specified name and arity
@@ -480,8 +480,8 @@
get_qualified_pred_name(ModuleInfo, PredId, qualified(PredModule, PredName)) :-
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_module(PredInfo, PredModule),
- pred_info_name(PredInfo, PredName).
+ PredModule = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo).
%-----------------------------------------------------------------------------%
@@ -608,7 +608,7 @@
AdjustArgTypes, PredId0, PredId, SymName0, SymName) :-
% make_hlds.m checks the arity, so this is guaranteed to succeed.
get_state_args_det(Args, OtherArgs, _, _),
- ( invalid_pred_id(PredId0) ->
+ ( PredId0 = invalid_pred_id ->
(
OtherArgs = [HOArg],
pred_info_typevarset(CallerPredInfo, TVarSet),
@@ -712,7 +712,7 @@
{ pred_info_get_markers(PredInfo0, Markers) },
(
{ check_marker(Markers, base_relation) },
- { pred_info_module(PredInfo0, ModuleName) },
+ { ModuleName = pred_info_module(PredInfo0) },
{ module_info_name(ModuleInfo, ModuleName) }
->
check_aditi_state(ModuleInfo, PredInfo0)
@@ -726,24 +726,23 @@
check_for_indistinguishable_modes(ModuleInfo, PredId,
PredInfo2, PredInfo).
-post_typecheck__finish_imported_pred_no_io(ModuleInfo, Errors,
- PredInfo0, PredInfo) :-
+post_typecheck__finish_imported_pred_no_io(ModuleInfo, Errors, !PredInfo) :-
% Make sure the var-types field in the clauses_info is
% valid for imported predicates.
% Unification procedures have clauses generated, so
% they already have valid var-types.
- ( pred_info_is_pseudo_imported(PredInfo0) ->
- PredInfo1 = PredInfo0
+ ( pred_info_is_pseudo_imported(!.PredInfo) ->
+ true
;
- pred_info_clauses_info(PredInfo0, ClausesInfo0),
+ pred_info_clauses_info(!.PredInfo, ClausesInfo0),
clauses_info_headvars(ClausesInfo0, HeadVars),
- pred_info_arg_types(PredInfo0, ArgTypes),
+ pred_info_arg_types(!.PredInfo, ArgTypes),
map__from_corresponding_lists(HeadVars, ArgTypes, VarTypes),
- clauses_info_set_vartypes(ClausesInfo0, VarTypes, ClausesInfo),
- pred_info_set_clauses_info(PredInfo0, ClausesInfo, PredInfo1)
+ clauses_info_set_vartypes(VarTypes, ClausesInfo0, ClausesInfo),
+ pred_info_set_clauses_info(ClausesInfo, !PredInfo)
),
- post_typecheck__propagate_types_into_modes(ModuleInfo,
- Errors, PredInfo1, PredInfo).
+ post_typecheck__propagate_types_into_modes(ModuleInfo, Errors,
+ !PredInfo).
%
% Now that the promise has finished being typechecked,
@@ -843,8 +842,8 @@
% Check if this predicate is the
% program entry point main/2.
%
- { pred_info_name(PredInfo, "main") },
- { pred_info_arity(PredInfo, 2) },
+ { pred_info_name(PredInfo) = "main" },
+ { pred_info_arity(PredInfo) = 2 },
{ pred_info_is_exported(PredInfo) }
->
%
@@ -879,14 +878,15 @@
list(proc_id), pred_info, pred_info).
:- mode post_typecheck__propagate_types_into_modes(in, out, in, out)
is det.
+
post_typecheck__propagate_types_into_modes(ModuleInfo, ErrorProcs,
- PredInfo0, PredInfo) :-
- pred_info_arg_types(PredInfo0, ArgTypes),
- pred_info_procedures(PredInfo0, Procs0),
- pred_info_procids(PredInfo0, ProcIds),
+ !PredInfo) :-
+ pred_info_arg_types(!.PredInfo, ArgTypes),
+ pred_info_procedures(!.PredInfo, Procs0),
+ ProcIds = pred_info_procids(!.PredInfo),
propagate_types_into_proc_modes(ModuleInfo, ProcIds, ArgTypes,
[], ErrorProcs, Procs0, Procs),
- pred_info_set_procedures(PredInfo0, Procs, PredInfo).
+ pred_info_set_procedures(Procs, !PredInfo).
%-----------------------------------------------------------------------------%
@@ -913,7 +913,7 @@
Procs1 = Procs0
;
ErrorProcs1 = ErrorProcs0,
- proc_info_set_argmodes(ProcInfo0, ArgModes, ProcInfo),
+ proc_info_set_argmodes(ArgModes, ProcInfo0, ProcInfo),
map__det_update(Procs0, ProcId, ProcInfo, Procs1)
),
propagate_types_into_proc_modes(ModuleInfo, ProcIds,
@@ -923,22 +923,27 @@
pred_info, pred_info, io__state, io__state).
:- mode report_unbound_inst_vars(in, in, in, in, out, di, uo) is det.
-report_unbound_inst_vars(ModuleInfo, PredId, ErrorProcs,
- PredInfo0, PredInfo) -->
- ( { ErrorProcs = [] } ->
- { PredInfo = PredInfo0 }
- ;
- { pred_info_procedures(PredInfo0, ProcTable0) },
- list__foldl2(
- (pred(ProcId::in, Procs0::in, Procs::out, di, uo) is det -->
- { map__lookup(Procs0, ProcId, ProcInfo) },
- unbound_inst_var_error(PredId, ProcInfo, ModuleInfo),
- % delete this mode, to avoid internal errors
- { map__det_remove(Procs0, ProcId, _, Procs) }
- ), ErrorProcs, ProcTable0, ProcTable),
- { pred_info_set_procedures(PredInfo0, ProcTable, PredInfo) }
+report_unbound_inst_vars(ModuleInfo, PredId, ErrorProcs, !PredInfo, !IO) :-
+ ( ErrorProcs = [] ->
+ true
+ ;
+ pred_info_procedures(!.PredInfo, ProcTable0),
+ list__foldl2(report_unbound_inst_var_error(ModuleInfo, PredId),
+ ErrorProcs, ProcTable0, ProcTable, !IO),
+ pred_info_set_procedures(ProcTable, !PredInfo)
).
+:- pred report_unbound_inst_var_error(module_info::in,
+ pred_id::in, proc_id::in, proc_table::in, proc_table::out,
+ io__state::di, io__state::uo) is det.
+
+report_unbound_inst_var_error(ModuleInfo, PredId, ProcId, Procs0, Procs,
+ !IO) :-
+ map__lookup(Procs0, ProcId, ProcInfo),
+ unbound_inst_var_error(PredId, ProcInfo, ModuleInfo, !IO),
+ % delete this mode, to avoid internal errors
+ map__det_remove(Procs0, ProcId, _, Procs).
+
:- pred unbound_inst_var_error(pred_id, proc_info, module_info,
io__state, io__state).
:- mode unbound_inst_var_error(in, in, in, di, uo) is det.
@@ -961,7 +966,7 @@
pred_info, pred_info, io__state, io__state).
:- mode check_for_indistinguishable_modes(in, in, in, out, di, uo) is det.
-check_for_indistinguishable_modes(ModuleInfo, PredId, PredInfo0, PredInfo) -->
+check_for_indistinguishable_modes(ModuleInfo, PredId, !PredInfo, !IO) :-
(
%
% Don't check for indistinguishable modes in unification
@@ -973,14 +978,14 @@
% but the polymorphic unify needs to be able to call
% the semidet mode.)
%
- { pred_info_get_maybe_special_pred(PredInfo0, MaybeSpecial) },
- { MaybeSpecial = yes(unify - _) }
+ pred_info_get_maybe_special_pred(!.PredInfo, MaybeSpecial),
+ MaybeSpecial = yes(unify - _)
->
- { PredInfo = PredInfo0 }
+ true
;
- { pred_info_procids(PredInfo0, ProcIds) },
+ ProcIds = pred_info_procids(!.PredInfo),
check_for_indistinguishable_modes(ModuleInfo, PredId,
- ProcIds, [], PredInfo0, PredInfo)
+ ProcIds, [], !PredInfo, !IO)
).
:- pred check_for_indistinguishable_modes(module_info, pred_id, list(proc_id),
@@ -1005,14 +1010,14 @@
:- mode check_for_indistinguishable_mode(in, in, in,
in, out, in, out, di, uo) is det.
-check_for_indistinguishable_mode(_, _, _, [], no, PredInfo, PredInfo) --> [].
+check_for_indistinguishable_mode(_, _, _, [], no, !PredInfo) --> [].
check_for_indistinguishable_mode(ModuleInfo, PredId, ProcId1,
- [ProcId | ProcIds], Removed, PredInfo0, PredInfo) -->
+ [ProcId | ProcIds], Removed, !PredInfo) -->
(
{ modes_are_indistinguishable(ProcId, ProcId1,
- PredInfo0, ModuleInfo) }
+ !.PredInfo, ModuleInfo) }
->
- { pred_info_import_status(PredInfo0, Status) },
+ { pred_info_import_status(!.PredInfo, Status) },
globals__io_lookup_bool_option(intermodule_optimization,
Intermod),
globals__io_lookup_bool_option(make_optimization_interface,
@@ -1030,15 +1035,15 @@
}
->
report_indistinguishable_modes_error(ProcId1,
- ProcId, PredId, PredInfo0, ModuleInfo)
+ ProcId, PredId, !.PredInfo, ModuleInfo)
;
[]
),
- { pred_info_remove_procid(PredInfo0, ProcId1, PredInfo) },
+ { pred_info_remove_procid(ProcId1, !PredInfo) },
{ Removed = yes }
;
check_for_indistinguishable_mode(ModuleInfo, PredId, ProcId1,
- ProcIds, Removed, PredInfo0, PredInfo)
+ ProcIds, Removed, !PredInfo)
).
%-----------------------------------------------------------------------------%
@@ -1052,7 +1057,7 @@
( { AditiStateTypes = [] } ->
report_no_aditi_state(PredInfo)
;
- { pred_info_procids(PredInfo, ProcIds) },
+ { ProcIds = pred_info_procids(PredInfo) },
list__foldl(
check_aditi_state_modes(ModuleInfo,
PredInfo, ArgTypes),
@@ -1136,10 +1141,10 @@
:- mode report_aditi_pragma(in, out) is det.
report_aditi_pragma(PredInfo, ErrorPieces) :-
- pred_info_module(PredInfo, Module),
- pred_info_name(PredInfo, Name),
- pred_info_arity(PredInfo, Arity),
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
+ Module = pred_info_module(PredInfo),
+ Name = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
pred_info_get_markers(PredInfo, Markers),
( check_marker(Markers, base_relation) ->
Pragma = "base_relation"
@@ -1249,7 +1254,7 @@
% replace `X = f(A, B, C)'
% with `f(A, B, C, X)'
%
- invalid_proc_id(ProcId),
+ ProcId = invalid_proc_id,
list__append(ArgVars0, [X0], ArgVars),
FuncCallUnifyContext = call_unify_context(X0,
functor(ConsId0, no, ArgVars0), UnifyContext),
@@ -1555,7 +1560,7 @@
out, out, in, out) is det.
get_cons_id_arg_types_adding_existq_tvars(ModuleInfo, ConsId, TermType,
- ArgTypes, NewExistQVars, PredInfo0, PredInfo) :-
+ ArgTypes, NewExistQVars, !PredInfo) :-
%
% Split the list of argument types at the named field.
%
@@ -1565,17 +1570,16 @@
assoc_list__values(Args, ArgTypes0),
( ExistQVars = [] ->
ArgTypes1 = ArgTypes0,
- PredInfo = PredInfo0,
NewExistQVars = []
;
%
% Rename apart the existentially quantified type variables.
%
list__length(ExistQVars, NumExistQVars),
- pred_info_typevarset(PredInfo0, TVarSet0),
+ pred_info_typevarset(!.PredInfo, TVarSet0),
varset__new_vars(TVarSet0, NumExistQVars, NewExistQVars,
TVarSet),
- pred_info_set_typevarset(PredInfo0, TVarSet, PredInfo),
+ pred_info_set_typevarset(TVarSet, !PredInfo),
map__from_corresponding_lists(ExistQVars, NewExistQVars,
TVarSubst),
term__apply_variable_renaming_to_list(ArgTypes0, TVarSubst,
@@ -1586,8 +1590,8 @@
( type_to_ctor_and_args(TermType, _, TypeArgs) ->
map__from_corresponding_lists(TypeDefnArgs, TypeArgs, TSubst)
;
- error(
- "get_cons_id_arg_types_adding_existq_tvars: type_to_ctor_and_args failed")
+ error("get_cons_id_arg_types_adding_existq_tvars: " ++
+ "type_to_ctor_and_args failed")
),
term__apply_substitution_to_list(ArgTypes1, TSubst, ArgTypes).
Index: compiler/pragma_c_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/pragma_c_gen.m,v
retrieving revision 1.60
diff -u -b -r1.60 pragma_c_gen.m
--- compiler/pragma_c_gen.m 25 Jul 2003 02:27:23 -0000 1.60
+++ compiler/pragma_c_gen.m 21 Oct 2003 09:52:56 -0000
@@ -490,7 +490,7 @@
ReleaseLock = pragma_c_raw_code("", live_lvals_info(set__init))
;
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_name(PredInfo, Name),
+ Name = pred_info_name(PredInfo),
c_util__quote_string(Name, MangledName),
string__append_list(["\tMR_OBTAIN_GLOBAL_LOCK(""",
MangledName, """);\n"], ObtainLockStr),
@@ -651,126 +651,127 @@
string::in, maybe(prog_context)::in, code_tree::out,
code_info::in, code_info::out) is det.
-pragma_c_gen__nondet_pragma_c_code(CodeModel, Attributes,
- PredId, ProcId, ArgVars, ArgDatas, OrigArgTypes,
- _Fields, _FieldsContext, First, FirstContext,
- Later, LaterContext, Treat, Shared, SharedContext, Code) -->
- { require(unify(CodeModel, model_non),
- "inappropriate code model for nondet pragma C code") },
+pragma_c_gen__nondet_pragma_c_code(CodeModel, Attributes, PredId, ProcId,
+ ArgVars, ArgDatas, OrigArgTypes, _Fields, _FieldsContext,
+ First, FirstContext, Later, LaterContext, Treat, Shared,
+ SharedContext, Code, !CI) :-
+ require(unify(CodeModel, model_non),
+ "inappropriate code model for nondet pragma C code"),
%
% Extract the may_call_mercury attribute
%
- { may_call_mercury(Attributes, MayCallMercury) },
+ may_call_mercury(Attributes, MayCallMercury),
%
% Generate #define MR_PROC_LABEL <procedure label> /* see note (5) */
% and #undef MR_PROC_LABEL
%
- code_info__get_module_info(ModuleInfo),
- code_info__get_pred_id(CallerPredId),
- code_info__get_proc_id(CallerProcId),
- { make_proc_label_hash_define(ModuleInfo, CallerPredId, CallerProcId,
- ProcLabelDefine, ProcLabelUndef) },
+ code_info__get_module_info(ModuleInfo, !CI),
+ code_info__get_pred_id(CallerPredId, !CI),
+ code_info__get_proc_id(CallerProcId, !CI),
+ make_proc_label_hash_define(ModuleInfo, CallerPredId, CallerProcId,
+ ProcLabelDefine, ProcLabelUndef),
%
% Generate a unique prefix for the C labels that we will define
%
- { ProcLabelString = make_proc_label_string(ModuleInfo,
- PredId, ProcId) },
+ ProcLabelString = make_proc_label_string(ModuleInfo,
+ PredId, ProcId),
%
% Get a list of input and output arguments
%
- code_info__get_pred_proc_arginfo(PredId, ProcId, ArgInfos),
- { make_c_arg_list(ArgVars, ArgDatas, OrigArgTypes, ArgInfos, Args) },
- { pragma_select_in_args(Args, InArgs) },
- { pragma_select_out_args(Args, OutArgs) },
- { make_pragma_decls(Args, ModuleInfo, Decls) },
- { make_pragma_decls(OutArgs, ModuleInfo, OutDecls) },
-
- input_descs_from_arg_info(InArgs, InputDescs),
- output_descs_from_arg_info(OutArgs, OutputDescs),
-
- { module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_module(PredInfo, ModuleName) },
- { pred_info_name(PredInfo, PredName) },
- { pred_info_arity(PredInfo, Arity) },
- { pragma_c_gen__struct_name(ModuleName, PredName, Arity, ProcId,
- StructName) },
- { SaveStructDecl = pragma_c_struct_ptr_decl(StructName, "LOCALS") },
- { string__format("\tLOCALS = (struct %s *) ((char *)
+ code_info__get_pred_proc_arginfo(PredId, ProcId, ArgInfos, !CI),
+ make_c_arg_list(ArgVars, ArgDatas, OrigArgTypes, ArgInfos, Args),
+ pragma_select_in_args(Args, InArgs),
+ pragma_select_out_args(Args, OutArgs),
+ make_pragma_decls(Args, ModuleInfo, Decls),
+ make_pragma_decls(OutArgs, ModuleInfo, OutDecls),
+
+ input_descs_from_arg_info(InArgs, InputDescs, !CI),
+ output_descs_from_arg_info(OutArgs, OutputDescs, !CI),
+
+ module_info_pred_info(ModuleInfo, PredId, PredInfo),
+ ModuleName = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo),
+ pragma_c_gen__struct_name(ModuleName, PredName, Arity, ProcId,
+ StructName),
+ SaveStructDecl = pragma_c_struct_ptr_decl(StructName, "LOCALS"),
+ string__format("\tLOCALS = (struct %s *) ((char *)
(MR_curfr + 1 - MR_ORDINARY_SLOTS - MR_NONDET_FIXED_SIZE)
- sizeof(struct %s));\n",
[s(StructName), s(StructName)],
- InitSaveStruct) },
+ InitSaveStruct),
- code_info__get_next_label(RetryLabel),
- { ModFrameCode = node([
+ code_info__get_next_label(RetryLabel, !CI),
+ ModFrameCode = node([
assign(redoip(lval(curfr)),
const(code_addr_const(label(RetryLabel))))
- "Set up backtracking to retry label"
- ]) },
- { RetryLabelCode = node([
+ ]),
+ RetryLabelCode = node([
label(RetryLabel) -
"Start of the retry block"
- ]) },
+ ]),
- code_info__get_globals(Globals),
+ code_info__get_globals(Globals, !CI),
- { globals__lookup_bool_option(Globals, reclaim_heap_on_nondet_failure,
- ReclaimHeap) },
- code_info__maybe_save_hp(ReclaimHeap, SaveHeapCode, MaybeHpSlot),
- code_info__maybe_restore_hp(MaybeHpSlot, RestoreHeapCode),
-
- { globals__lookup_bool_option(Globals, use_trail, UseTrail) },
- code_info__maybe_save_ticket(UseTrail, SaveTicketCode, MaybeTicketSlot),
- code_info__maybe_reset_ticket(MaybeTicketSlot, undo, RestoreTicketCode),
+ globals__lookup_bool_option(Globals, reclaim_heap_on_nondet_failure,
+ ReclaimHeap),
+ code_info__maybe_save_hp(ReclaimHeap, SaveHeapCode, MaybeHpSlot, !CI),
+ code_info__maybe_restore_hp(MaybeHpSlot, RestoreHeapCode, !CI),
+
+ globals__lookup_bool_option(Globals, use_trail, UseTrail),
+ code_info__maybe_save_ticket(UseTrail, SaveTicketCode,
+ MaybeTicketSlot, !CI),
+ code_info__maybe_reset_ticket(MaybeTicketSlot, undo,
+ RestoreTicketCode, !CI),
- { FirstContext = yes(FirstContextPrime) ->
+ ( FirstContext = yes(FirstContextPrime) ->
ActualFirstContext = FirstContextPrime
;
term__context_init(ActualFirstContext)
- },
+ ),
trace__maybe_generate_pragma_event_code(nondet_pragma_first,
- ActualFirstContext, FirstTraceCode),
- { LaterContext = yes(LaterContextPrime) ->
+ ActualFirstContext, FirstTraceCode, !CI),
+ ( LaterContext = yes(LaterContextPrime) ->
ActualLaterContext = LaterContextPrime
;
term__context_init(ActualLaterContext)
- },
+ ),
trace__maybe_generate_pragma_event_code(nondet_pragma_later,
- ActualLaterContext, LaterTraceCode),
+ ActualLaterContext, LaterTraceCode, !CI),
- { FirstDisjunctCode =
+ ( FirstDisjunctCode =
tree(SaveHeapCode,
tree(SaveTicketCode,
FirstTraceCode))
- },
- { LaterDisjunctCode =
+ ),
+ ( LaterDisjunctCode =
tree(RestoreHeapCode,
tree(RestoreTicketCode,
LaterTraceCode))
- },
+ ),
%
% MR_save_registers(); /* see notes (1) and (2) above */
%
- { MayCallMercury = will_not_call_mercury ->
+ ( MayCallMercury = will_not_call_mercury ->
SaveRegs = ""
;
SaveRegs = "\tMR_save_registers();\n"
- },
+ ),
%
% MR_restore_registers(); /* see notes (1) and (3) above */
%
- { MayCallMercury = will_not_call_mercury ->
+ ( MayCallMercury = will_not_call_mercury ->
RestoreRegs = ""
;
RestoreRegs = "\tMR_restore_registers();\n"
- },
+ ),
- {
Succeed = "\tMR_succeed();\n",
SucceedDiscard = "\tMR_succeed_discard();\n",
@@ -798,8 +799,7 @@
Undef1 = "#undef\tSUCCEED\n",
Undef2 = "#undef\tSUCCEED_LAST\n",
- Undef3 = "#undef\tFAIL\n"
- },
+ Undef3 = "#undef\tFAIL\n",
(
% Use the form that duplicates the common code
@@ -816,7 +816,7 @@
% We use the number of semicolons in the code
% as an indication how many C statements it has
% and thus how big its object code is likely to be.
- {
+ (
Treat = duplicate
;
Treat = automatic,
@@ -831,9 +831,8 @@
),
string__foldl(CountSemis, Shared, 0, Semis),
Semis < 32
- }
+ )
->
- {
CallDecls = [SaveStructDecl | Decls],
CallComponents = [
pragma_c_inputs(InputDescs),
@@ -903,10 +902,8 @@
tree(RetryLabelCode,
tree(LaterDisjunctCode,
RetryBlockCode)))))
- }
;
- code_info__get_next_label(SharedLabel),
- {
+ code_info__get_next_label(SharedLabel, !CI),
SharedLabelCode = node([
label(SharedLabel) -
"Start of the shared block"
@@ -1029,7 +1026,6 @@
tree(RetryBlockCode,
tree(SharedLabelCode,
SharedBlockCode)))))))
- }
).
%---------------------------------------------------------------------------%
Index: compiler/prog_rep.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_rep.m,v
retrieving revision 1.20
diff -u -b -r1.20 prog_rep.m
--- compiler/prog_rep.m 24 Jun 2003 14:20:51 -0000 1.20
+++ compiler/prog_rep.m 21 Oct 2003 09:55:39 -0000
@@ -228,9 +228,9 @@
prog_rep__represent_goal_expr(call(PredId, _, Args, _, _, _),
GoalInfo, InstMap0, Info, Rep) :-
module_info_pred_info(Info ^ module_info, PredId, PredInfo),
- pred_info_module(PredInfo, ModuleSymName),
+ ModuleSymName = pred_info_module(PredInfo),
prog_out__sym_name_to_string(ModuleSymName, ModuleName),
- pred_info_name(PredInfo, PredName),
+ PredName = pred_info_name(PredInfo),
list__map(term__var_to_int, Args, ArgsRep),
AtomicGoalRep = plain_call_rep(ModuleName, PredName, ArgsRep),
prog_rep__represent_atomic_goal(GoalInfo, InstMap0, Info,
Index: compiler/purity.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/purity.m,v
retrieving revision 1.60
diff -u -b -r1.60 purity.m
--- compiler/purity.m 19 Sep 2003 11:10:04 -0000 1.60
+++ compiler/purity.m 21 Oct 2003 16:23:09 -0000
@@ -343,74 +343,79 @@
% them, and in the translation from goal to hlds_goal, the attached purity is
% turned into the appropriate feature in the hlds_goal_info.)
-:- pred puritycheck_pred(pred_id, pred_info, pred_info, module_info, int,
- io__state, io__state).
-:- mode puritycheck_pred(in, in, out, in, out, di, uo) is det.
+:- pred puritycheck_pred(pred_id::in, pred_info::in, pred_info::out,
+ module_info::in, int::out, io__state::di, io__state::uo) is det.
-puritycheck_pred(PredId, PredInfo0, PredInfo, ModuleInfo, NumErrors) -->
- { pred_info_get_purity(PredInfo0, DeclPurity) } ,
- { pred_info_get_promised_purity(PredInfo0, PromisedPurity) },
-
- { pred_info_clauses_info(PredInfo0, ClausesInfo0) },
- { pred_info_procids(PredInfo0, ProcIds) },
- { clauses_info_clauses(ClausesInfo0, Clauses0) },
- { clauses_info_vartypes(ClausesInfo0, VarTypes0) },
- { clauses_info_varset(ClausesInfo0, VarSet0) },
- { RunPostTypecheck = yes },
- { PurityInfo0 = purity_info(ModuleInfo, RunPostTypecheck,
- PredInfo0, VarTypes0, VarSet0, []) },
- { pred_info_get_goal_type(PredInfo0, GoalType) },
- { compute_purity(GoalType, Clauses0, Clauses, ProcIds, pure, Purity,
- PurityInfo0, PurityInfo) },
- { PurityInfo = purity_info(_, _, PredInfo1,
- VarTypes, VarSet, RevMessages) },
- { clauses_info_set_vartypes(ClausesInfo0, VarTypes, ClausesInfo1) },
- { clauses_info_set_varset(ClausesInfo1, VarSet, ClausesInfo2) },
- { Messages = list__reverse(RevMessages) },
- list__foldl(report_post_typecheck_message(ModuleInfo), Messages),
- { NumErrors0 = list__length(
+puritycheck_pred(PredId, !PredInfo, ModuleInfo, NumErrors, !IO) :-
+ pred_info_get_purity(!.PredInfo, DeclPurity) ,
+ pred_info_get_promised_purity(!.PredInfo, PromisedPurity),
+
+ pred_info_clauses_info(!.PredInfo, ClausesInfo0),
+ ProcIds = pred_info_procids(!.PredInfo),
+ clauses_info_clauses(ClausesInfo0, Clauses0),
+ clauses_info_vartypes(ClausesInfo0, VarTypes0),
+ clauses_info_varset(ClausesInfo0, VarSet0),
+ RunPostTypecheck = yes,
+ PurityInfo0 = purity_info(ModuleInfo, RunPostTypecheck,
+ !.PredInfo, VarTypes0, VarSet0, []),
+ pred_info_get_goal_type(!.PredInfo, GoalType),
+ compute_purity(GoalType, Clauses0, Clauses, ProcIds, pure, Purity,
+ PurityInfo0, PurityInfo),
+ PurityInfo = purity_info(_, _, !:PredInfo,
+ VarTypes, VarSet, RevMessages),
+ clauses_info_set_vartypes(VarTypes, ClausesInfo0, ClausesInfo1),
+ clauses_info_set_varset(VarSet, ClausesInfo1, ClausesInfo2),
+ Messages = list__reverse(RevMessages),
+ list__foldl(report_post_typecheck_message(ModuleInfo), Messages, !IO),
+ NumErrors0 = list__length(
list__filter((pred(error(_)::in) is semidet),
- Messages)) },
- { clauses_info_set_clauses(ClausesInfo2, Clauses, ClausesInfo) },
- { pred_info_set_clauses_info(PredInfo1, ClausesInfo, PredInfo) },
- { WorstPurity = Purity },
- { perform_pred_purity_checks(PredInfo, Purity, DeclPurity,
- PromisedPurity, PurityCheckResult) },
- ( { PurityCheckResult = inconsistent_promise },
- { NumErrors = NumErrors0 + 1 },
- error_inconsistent_promise(ModuleInfo, PredInfo, PredId,
- DeclPurity)
- ; { PurityCheckResult = unnecessary_decl },
- { NumErrors = NumErrors0 },
- warn_exaggerated_impurity_decl(ModuleInfo, PredInfo, PredId,
- DeclPurity, WorstPurity)
- ; { PurityCheckResult = insufficient_decl },
- { NumErrors = NumErrors0 + 1 },
- error_inferred_impure(ModuleInfo, PredInfo, PredId, Purity)
- ; { PurityCheckResult = unnecessary_promise_pure },
- { NumErrors = NumErrors0 },
- warn_unnecessary_promise_pure(ModuleInfo, PredInfo, PredId,
- PromisedPurity)
- ; { PurityCheckResult = no_worries },
- { NumErrors = NumErrors0 }
+ Messages)),
+ clauses_info_set_clauses(Clauses, ClausesInfo2, ClausesInfo),
+ pred_info_set_clauses_info(ClausesInfo, !PredInfo),
+ WorstPurity = Purity,
+ perform_pred_purity_checks(!.PredInfo, Purity, DeclPurity,
+ PromisedPurity, PurityCheckResult),
+ (
+ PurityCheckResult = inconsistent_promise,
+ NumErrors = NumErrors0 + 1,
+ error_inconsistent_promise(ModuleInfo, !.PredInfo, PredId,
+ DeclPurity, !IO)
+ ;
+ PurityCheckResult = unnecessary_decl,
+ NumErrors = NumErrors0,
+ warn_exaggerated_impurity_decl(ModuleInfo, !.PredInfo, PredId,
+ DeclPurity, WorstPurity, !IO)
+ ;
+ PurityCheckResult = insufficient_decl,
+ NumErrors = NumErrors0 + 1,
+ error_inferred_impure(ModuleInfo, !.PredInfo, PredId, Purity,
+ !IO)
+ ;
+ PurityCheckResult = unnecessary_promise_pure,
+ NumErrors = NumErrors0,
+ warn_unnecessary_promise_pure(ModuleInfo, !.PredInfo, PredId,
+ PromisedPurity, !IO)
+ ;
+ PurityCheckResult = no_worries,
+ NumErrors = NumErrors0
).
-repuritycheck_proc(ModuleInfo, proc(_PredId, ProcId), PredInfo0, PredInfo) :-
- pred_info_procedures(PredInfo0, Procs0),
+repuritycheck_proc(ModuleInfo, proc(_PredId, ProcId), !PredInfo) :-
+ pred_info_procedures(!.PredInfo, Procs0),
map__lookup(Procs0, ProcId, ProcInfo0),
proc_info_goal(ProcInfo0, Goal0),
proc_info_vartypes(ProcInfo0, VarTypes0),
proc_info_varset(ProcInfo0, VarSet0),
RunPostTypeCheck = no,
PurityInfo0 = purity_info(ModuleInfo, RunPostTypeCheck,
- PredInfo0, VarTypes0, VarSet0, []),
+ !.PredInfo, VarTypes0, VarSet0, []),
compute_goal_purity(Goal0, Goal, Bodypurity, PurityInfo0, PurityInfo),
- PurityInfo = purity_info(_, _, PredInfo1, VarTypes, VarSet, _),
- proc_info_set_goal(ProcInfo0, Goal, ProcInfo1),
- proc_info_set_vartypes(ProcInfo1, VarTypes, ProcInfo2),
- proc_info_set_varset(ProcInfo2, VarSet, ProcInfo),
+ PurityInfo = purity_info(_, _, !:PredInfo, VarTypes, VarSet, _),
+ proc_info_set_goal(Goal, ProcInfo0, ProcInfo1),
+ proc_info_set_vartypes(VarTypes, ProcInfo1, ProcInfo2),
+ proc_info_set_varset(VarSet, ProcInfo2, ProcInfo),
map__det_update(Procs0, ProcId, ProcInfo, Procs),
- pred_info_set_procedures(PredInfo1, Procs, PredInfo2),
+ pred_info_set_procedures(Procs, !PredInfo),
%
% A predicate should never become less pure after inlining,
@@ -418,8 +423,8 @@
% the goal worsened (for example if a promised pure predicate
% was inlined).
%
- pred_info_get_purity(PredInfo2, OldPurity),
- pred_info_get_markers(PredInfo2, Markers0),
+ pred_info_get_purity(!.PredInfo, OldPurity),
+ pred_info_get_markers(!.PredInfo, Markers0),
(
less_pure(Bodypurity, OldPurity)
->
@@ -434,12 +439,11 @@
OldPurity = (impure),
Markers = Markers0
),
- pred_info_set_markers(PredInfo2, Markers, PredInfo)
+ pred_info_set_markers(Markers, !PredInfo)
;
less_pure(OldPurity, Bodypurity),
- pred_info_procids(PredInfo2, [_])
+ [_] = pred_info_procids(!.PredInfo)
->
-
%
% If there is only one procedure, update the
% purity in the pred_info if the purity improved.
@@ -461,9 +465,9 @@
Bodypurity = (impure),
Markers = Markers0
),
- pred_info_set_markers(PredInfo2, Markers, PredInfo)
+ pred_info_set_markers(Markers, !PredInfo)
;
- PredInfo = PredInfo2
+ true
).
% Infer the purity of a single (non-pragma c_code) predicate
@@ -999,7 +1003,7 @@
io__write_string("' but promised pure.\n"),
globals__io_lookup_bool_option(verbose_errors, VerboseErrors),
( { VerboseErrors = yes } ->
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
prog_out__write_context(Context),
io__write_string(" A pure "),
hlds_out__write_pred_or_func(PredOrFunc),
@@ -1055,7 +1059,7 @@
globals__io_lookup_bool_option(verbose_errors, VerboseErrors),
( { VerboseErrors = yes } ->
prog_out__write_context(Context),
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
io__write_string(" This "),
hlds_out__write_pred_or_func(PredOrFunc),
io__write_string(" does not invoke any "),
@@ -1076,7 +1080,7 @@
error_inferred_impure(ModuleInfo, PredInfo, PredId, Purity) -->
{ pred_info_context(PredInfo, Context) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
write_context_and_pred_id(ModuleInfo, PredInfo, PredId),
prog_out__write_context(Context),
io__write_string(" purity error: "),
@@ -1164,7 +1168,7 @@
io__write_string(":\n"),
prog_out__write_context(Context),
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
{ pred_info_get_purity(PredInfo, Purity) },
( { PredOrFunc = predicate } ->
io__write_string(" purity error: call must be preceded by `"),
Index: compiler/quantification.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/quantification.m,v
retrieving revision 1.86
diff -u -b -r1.86 quantification.m
--- compiler/quantification.m 20 Oct 2003 07:29:10 -0000 1.86
+++ compiler/quantification.m 21 Oct 2003 13:58:15 -0000
@@ -7,30 +7,25 @@
% File: quantification.m.
% Main authors: fjh, conway.
- % Make implicit quantification explicit, and rename apart
- % variables with the same name that appear in distinct scopes.
- % For the rules on implicit quantification, see the
- % Mercury language reference manual.
- %
- % This pass also expands out bi-implications (that has to be
- % done after quantification, and preferably as soon as possible,
- % so we do it here).
- %
- % Rather than making implicit quantification explicit by
- % inserting additional existential quantifiers in the form of
- % `some/2' goals, we instead record existential quantification
- % in the goal_info for each goal. In fact we could (should?)
- % even delete any explicit existential quantifiers that were
- % present in the source code, since the information they convey
- % will be stored in the goal_info, although currently we don't
- % do that.
- %
- % The important piece of information that later stages of the
- % compilation process want to know is "Does this goal bind any
- % of its non-local variables?". So, rather than storing a list
- % of the variables which _are_ existentially quantified in the
- % goal_info, we store the set of variables which are _not_
- % quantified.
+% Make implicit quantification explicit, and rename apart variables
+% with the same name that appear in distinct scopes. For the rules on
+% implicit quantification, see the Mercury language reference manual.
+%
+% This pass also expands out bi-implications (that has to be done after
+% quantification, and preferably as soon as possible, so we do it here).
+%
+% Rather than making implicit quantification explicit by inserting additional
+% existential quantifiers in the form of `some/2' goals, we instead record
+% existential quantification in the goal_info for each goal. In fact we could
+% (and maybe even should?) even delete any explicit existential quantifiers
+% that were present in the source code, since the information they convey
+% will be stored in the goal_info (we currently don't do that).
+%
+% The important piece of information that later stages of the compiler
+% want to know is "Does this goal bind any of its non-local variables?".
+% So, rather than storing a list of the variables which _are_ existentially
+% quantified in the goal_info, we store the set of variables which are _not_
+% quantified.
%-----------------------------------------------------------------------------%
@@ -74,28 +69,25 @@
---> ordinary_nonlocals
; code_gen_nonlocals.
-:- pred implicitly_quantify_clause_body(
- nonlocals_to_recompute::in, list(prog_var)::in,
- hlds_goal::in, prog_varset::in, vartypes::in,
- hlds_goal::out, prog_varset::out, vartypes::out,
- list(quant_warning)::out) is det.
+:- pred implicitly_quantify_clause_body(nonlocals_to_recompute::in,
+ list(prog_var)::in, list(quant_warning)::out,
+ hlds_goal::in, hlds_goal::out, prog_varset::in, prog_varset::out,
+ vartypes::in, vartypes::out) is det.
% As above, with `ordinary_nonlocals' passed as the first argument.
:- pred implicitly_quantify_clause_body(list(prog_var)::in,
- hlds_goal::in, prog_varset::in, vartypes::in,
- hlds_goal::out, prog_varset::out, vartypes::out,
- list(quant_warning)::out) is det.
+ list(quant_warning)::out, hlds_goal::in, hlds_goal::out,
+ prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
:- pred implicitly_quantify_goal(nonlocals_to_recompute::in,
- hlds_goal::in, prog_varset::in, vartypes::in, set(prog_var)::in,
- hlds_goal::out, prog_varset::out, vartypes::out,
- list(quant_warning)::out) is det.
+ set(prog_var)::in, list(quant_warning)::out,
+ hlds_goal::in, hlds_goal::out, prog_varset::in, prog_varset::out,
+ vartypes::in, vartypes::out) is det.
% As above, with `ordinary_nonlocals' passed as the first argument.
-:- pred implicitly_quantify_goal(
- hlds_goal::in, prog_varset::in, vartypes::in, set(prog_var)::in,
- hlds_goal::out, prog_varset::out, vartypes::out,
- list(quant_warning)::out) is det.
+:- pred implicitly_quantify_goal(set(prog_var)::in, list(quant_warning)::out,
+ hlds_goal::in, hlds_goal::out, prog_varset::in, prog_varset::out,
+ vartypes::in, vartypes::out) is det.
:- pred requantify_proc(nonlocals_to_recompute::in,
proc_info::in, proc_info::out) is det.
@@ -160,18 +152,19 @@
:- type set_of_var == sparse_bitset(prog_var).
% `OutsideVars' are the variables that have occurred free outside
- % this goal, not counting occurrences in parallel goals
- % and not counting occurrences in lambda goals,
- % or which have been explicitly existentially quantified
- % over a scope which includes the current goal in a negated context.
- % `QuantVars' are the variables not in `OutsideVars'
- % that have been explicitly existentially quantified over a scope
- % which includes the current goal in a positive (non-negated) context.
+ % this goal, not counting occurrences in parallel goals and not
+ % counting occurrences in lambda goals, or which have been explicitly
+ % existentially quantified over a scope which includes the current
+ % goal in a negated context.
+ %
+ % `QuantVars' are the variables not in `OutsideVars' that have been
+ % explicitly existentially quantified over a scope which includes the
+ % current goal in a positive (non-negated) context.
+ %
% `OutsideLambdaVars' are the variables that have occurred free in
% a lambda expression outside this goal, not counting occurrences in
% parallel goals (and if this goal is itself inside a lambda
- % expression, not counting occurrences outside that lambda
- % expression).
+ % expression, not counting occurrences outside that lambda expression).
%
% For example, for
%
@@ -188,116 +181,109 @@
%-----------------------------------------------------------------------------%
-implicitly_quantify_clause_body(HeadVars, Goal0, Varset0, VarTypes0,
- Goal, Varset, VarTypes, Warnings) :-
- implicitly_quantify_clause_body(ordinary_nonlocals,
- HeadVars, Goal0, Varset0, VarTypes0,
- Goal, Varset, VarTypes, Warnings).
+implicitly_quantify_clause_body(HeadVars, Warnings,
+ !Goal, !Varset, !VarTypes) :-
+ implicitly_quantify_clause_body(ordinary_nonlocals, HeadVars, Warnings,
+ !Goal, !Varset, !VarTypes).
-implicitly_quantify_clause_body(RecomputeNonLocals, HeadVars, Goal0,
- Varset0, VarTypes0, Goal, Varset, VarTypes, Warnings) :-
+implicitly_quantify_clause_body(RecomputeNonLocals, HeadVars, Warnings,
+ !Goal, !Varset, !VarTypes) :-
list_to_set(HeadVars, OutsideVars),
- implicitly_quantify_goal(RecomputeNonLocals, Goal0, Varset0, VarTypes0,
- OutsideVars, Goal, Varset, VarTypes, Warnings).
+ implicitly_quantify_goal(RecomputeNonLocals, OutsideVars, Warnings,
+ !Goal, !Varset, !VarTypes).
requantify_proc(ProcInfo0, ProcInfo) :-
requantify_proc(ordinary_nonlocals, ProcInfo0, ProcInfo).
-requantify_proc(RecomputeNonLocals, ProcInfo0, ProcInfo) :-
- proc_info_varset(ProcInfo0, Varset0),
- proc_info_vartypes(ProcInfo0, VarTypes0),
- proc_info_headvars(ProcInfo0, HeadVars),
- proc_info_goal(ProcInfo0, Goal0),
- implicitly_quantify_clause_body(RecomputeNonLocals, HeadVars,
- Goal0, Varset0, VarTypes0, Goal, Varset, VarTypes, _),
- proc_info_set_varset(ProcInfo0, Varset, ProcInfo1),
- proc_info_set_vartypes(ProcInfo1, VarTypes, ProcInfo2),
- proc_info_set_goal(ProcInfo2, Goal, ProcInfo).
-
-implicitly_quantify_goal(Goal0, Varset0, VarTypes0, OutsideVars,
- Goal, Varset, VarTypes, Warnings) :-
- implicitly_quantify_goal(ordinary_nonlocals, Goal0, Varset0, VarTypes0,
- OutsideVars, Goal, Varset, VarTypes, Warnings).
-
-implicitly_quantify_goal(RecomputeNonLocals, Goal0, Varset0, VarTypes0,
- OutsideVars, Goal, Varset, VarTypes, Warnings) :-
- implicitly_quantify_goal_2(ordinary_nonlocals,
- Goal0, Varset0, VarTypes0, OutsideVars,
- Goal1, Varset1, VarTypes1, Warnings),
+requantify_proc(RecomputeNonLocals, !ProcInfo) :-
+ proc_info_headvars(!.ProcInfo, HeadVars),
+ proc_info_varset(!.ProcInfo, Varset0),
+ proc_info_vartypes(!.ProcInfo, VarTypes0),
+ proc_info_goal(!.ProcInfo, Goal0),
+ implicitly_quantify_clause_body(RecomputeNonLocals, HeadVars, _,
+ Goal0, Goal, Varset0, Varset, VarTypes0, VarTypes),
+ proc_info_set_varset(Varset, !ProcInfo),
+ proc_info_set_vartypes(VarTypes, !ProcInfo),
+ proc_info_set_goal(Goal, !ProcInfo).
+
+implicitly_quantify_goal(OutsideVars, Warnings, !Goal, !Varset, !VarTypes) :-
+ implicitly_quantify_goal(ordinary_nonlocals, OutsideVars, Warnings,
+ !Goal, !Varset, !VarTypes).
+
+implicitly_quantify_goal(RecomputeNonLocals, OutsideVars, Warnings,
+ !Goal, !Varset, !VarTypes) :-
+ implicitly_quantify_goal_2(ordinary_nonlocals, OutsideVars, Warnings,
+ !Goal, !Varset, !VarTypes),
(
RecomputeNonLocals = code_gen_nonlocals,
% If the goal does not contain a reconstruction,
% the code-gen nonlocals and the ordinary non-locals
% are the same.
- goal_contains_reconstruction(Goal1)
+ goal_contains_reconstruction(!.Goal)
->
- implicitly_quantify_goal_2(code_gen_nonlocals,
- Goal1, Varset1, VarTypes1, OutsideVars,
- Goal, Varset, VarTypes, _)
+ implicitly_quantify_goal_2(code_gen_nonlocals, OutsideVars, _,
+ !Goal, !Varset, !VarTypes)
;
- Goal = Goal1,
- Varset = Varset1,
- VarTypes = VarTypes1
+ true
).
:- pred implicitly_quantify_goal_2(nonlocals_to_recompute::in,
- hlds_goal::in, prog_varset::in, vartypes::in, set(prog_var)::in,
- hlds_goal::out, prog_varset::out, vartypes::out,
- list(quant_warning)::out) is det.
-
-implicitly_quantify_goal_2(RecomputeNonLocals,
- Goal0, Varset0, VarTypes0, OutsideVars0,
- Goal, Varset, VarTypes, Warnings) :-
+ set(prog_var)::in, list(quant_warning)::out,
+ hlds_goal::in, hlds_goal::out, prog_varset::in, prog_varset::out,
+ vartypes::in, vartypes::out) is det.
+
+implicitly_quantify_goal_2(RecomputeNonLocals, OutsideVars0, Warnings,
+ !Goal, !Varset, !VarTypes) :-
OutsideVars = set_to_bitset(OutsideVars0),
quantification__init(RecomputeNonLocals, OutsideVars,
- Varset0, VarTypes0, QuantInfo0),
- implicitly_quantify_goal(Goal0, Goal, QuantInfo0, QuantInfo),
- quantification__get_varset(Varset, QuantInfo, _),
- quantification__get_vartypes(VarTypes, QuantInfo, _),
+ !.Varset, !.VarTypes, QuantInfo0),
+ implicitly_quantify_goal(!Goal, QuantInfo0, QuantInfo),
+ quantification__get_varset(!:Varset, QuantInfo, _),
+ quantification__get_vartypes(!:VarTypes, QuantInfo, _),
quantification__get_warnings(Warnings0, QuantInfo, _),
list__reverse(Warnings0, Warnings).
:- pred implicitly_quantify_goal(hlds_goal::in, hlds_goal::out,
quant_info::in, quant_info::out) is det.
-implicitly_quantify_goal(Goal0 - GoalInfo0, Goal - GoalInfo) -->
- quantification__get_seen(SeenVars),
- { goal_info_get_context(GoalInfo0, Context) },
- implicitly_quantify_goal_2(Goal0, Context, Goal1),
- quantification__get_nonlocals(NonLocalVars),
- quantification__get_nonlocals_to_recompute(NonLocalsToRecompute),
+implicitly_quantify_goal(Goal0 - GoalInfo0, Goal - GoalInfo, !Info) :-
+ quantification__get_seen(SeenVars, !Info),
+ goal_info_get_context(GoalInfo0, Context),
+ implicitly_quantify_goal_2(Goal0, Goal1, Context, !Info),
+ quantification__get_nonlocals(NonLocalVars, !Info),
+ quantification__get_nonlocals_to_recompute(NonLocalsToRecompute,
+ !Info),
(
% If there are any variables that are local to the goal
% which we have come across before, then we rename them
% apart.
- { quantification__goal_vars_bitset(NonLocalsToRecompute,
- Goal0 - GoalInfo0, GoalVars0) },
- { difference(GoalVars0, NonLocalVars, LocalVars) },
- { intersect(SeenVars, LocalVars, RenameVars) },
- { \+ empty(RenameVars) }
+ quantification__goal_vars_bitset(NonLocalsToRecompute,
+ Goal0 - GoalInfo0, GoalVars0),
+ difference(GoalVars0, NonLocalVars, LocalVars),
+ intersect(SeenVars, LocalVars, RenameVars),
+ \+ empty(RenameVars)
->
quantification__rename_apart(RenameVars, _, Goal1 - GoalInfo0,
- Goal - GoalInfo1)
+ Goal - GoalInfo1, !Info)
;
- { Goal = Goal1 },
- { GoalInfo1 = GoalInfo0 }
+ Goal = Goal1,
+ GoalInfo1 = GoalInfo0
),
- quantification__set_goal_nonlocals(GoalInfo1, NonLocalVars, GoalInfo2,
- NonLocalVarsSet),
+ quantification__set_goal_nonlocals(NonLocalVars, NonLocalVarsSet,
+ GoalInfo1, GoalInfo2, !Info),
%
% If the non-locals set has shrunk (e.g. because some optimization
% optimizes away the other occurrences of a variable, causing it
% to become local when previously it was non-local),
% then we may need to likewise shrink the instmap delta.
%
- { goal_info_get_instmap_delta(GoalInfo2, InstMapDelta0) },
- { instmap_delta_restrict(InstMapDelta0,
- NonLocalVarsSet, InstMapDelta) },
- { goal_info_set_instmap_delta(GoalInfo2, InstMapDelta, GoalInfo) }.
+ goal_info_get_instmap_delta(GoalInfo2, InstMapDelta0),
+ instmap_delta_restrict(InstMapDelta0, NonLocalVarsSet, InstMapDelta),
+ goal_info_set_instmap_delta(GoalInfo2, InstMapDelta, GoalInfo).
-:- pred implicitly_quantify_goal_2(hlds_goal_expr::in, prog_context::in,
- hlds_goal_expr::out, quant_info::in, quant_info::out) is det.
+:- pred implicitly_quantify_goal_2(hlds_goal_expr::in, hlds_goal_expr::out,
+ prog_context::in, quant_info::in, quant_info::out) is det.
% After this pass, explicit quantifiers are redundant,
% since all variables which were explicitly quantified
@@ -309,149 +295,157 @@
% so we don't.) Thus we replace `some(Vars, Goal0)' with
% an empty quantifier `some([], Goal)'.
-implicitly_quantify_goal_2(some(Vars0, CanRemove, Goal0), Context,
- some([], CanRemove, Goal)) -->
- quantification__get_outside(OutsideVars),
- quantification__get_lambda_outside(LambdaOutsideVars),
- quantification__get_quant_vars(QuantVars),
+implicitly_quantify_goal_2(Expr0, Expr, Context, !Info) :-
+ Expr0 = some(Vars0, CanRemove, Goal0),
+ Expr = some([], CanRemove, Goal),
+ quantification__get_outside(OutsideVars, !Info),
+ quantification__get_lambda_outside(LambdaOutsideVars, !Info),
+ quantification__get_quant_vars(QuantVars, !Info),
% Rename apart all the quantified
% variables that occur outside this goal.
- { list_to_set(Vars0, QVars) },
- { intersect(OutsideVars, QVars, RenameVars1) },
- { intersect(LambdaOutsideVars, QVars, RenameVars2) },
- { union(RenameVars1, RenameVars2, RenameVars) },
- (
- { empty(RenameVars) }
- ->
- { Goal1 = Goal0 },
- { Vars = Vars0 }
+ list_to_set(Vars0, QVars),
+ intersect(OutsideVars, QVars, RenameVars1),
+ intersect(LambdaOutsideVars, QVars, RenameVars2),
+ union(RenameVars1, RenameVars2, RenameVars),
+ ( empty(RenameVars) ->
+ Goal1 = Goal0,
+ Vars = Vars0
;
- quantification__warn_overlapping_scope(RenameVars, Context),
+ quantification__warn_overlapping_scope(RenameVars, Context,
+ !Info),
quantification__rename_apart(RenameVars, RenameMap,
- Goal0, Goal1),
- { goal_util__rename_var_list(Vars0, no, RenameMap, Vars) }
+ Goal0, Goal1, !Info),
+ goal_util__rename_var_list(Vars0, no, RenameMap, Vars)
),
- quantification__update_seen_vars(QVars),
- { insert_list(QuantVars, Vars, QuantVars1) },
- quantification__set_quant_vars(QuantVars1),
- implicitly_quantify_goal(Goal1, Goal),
- quantification__get_nonlocals(NonLocals0),
- { delete_list(NonLocals0, Vars, NonLocals) },
- quantification__set_quant_vars(QuantVars),
- quantification__set_nonlocals(NonLocals).
-
-implicitly_quantify_goal_2(conj(List0), _, conj(List)) -->
- implicitly_quantify_conj(List0, List).
-
-implicitly_quantify_goal_2(par_conj(List0), _, par_conj(List)) -->
- implicitly_quantify_conj(List0, List).
-
-implicitly_quantify_goal_2(disj(Goals0), _, disj(Goals)) -->
- implicitly_quantify_disj(Goals0, Goals).
-
-implicitly_quantify_goal_2(switch(Var, Det, Cases0), _,
- switch(Var, Det, Cases)) -->
- implicitly_quantify_cases(Cases0, Cases),
+ quantification__update_seen_vars(QVars, !Info),
+ insert_list(QuantVars, Vars, QuantVars1),
+ quantification__set_quant_vars(QuantVars1, !Info),
+ implicitly_quantify_goal(Goal1, Goal, !Info),
+ quantification__get_nonlocals(NonLocals0, !Info),
+ delete_list(NonLocals0, Vars, NonLocals),
+ quantification__set_quant_vars(QuantVars, !Info),
+ quantification__set_nonlocals(NonLocals, !Info).
+
+implicitly_quantify_goal_2(Expr0, Expr, _, !Info) :-
+ Expr0 = conj(Goals0),
+ Expr = conj(Goals),
+ implicitly_quantify_conj(Goals0, Goals, !Info).
+
+implicitly_quantify_goal_2(Expr0, Expr, _, !Info) :-
+ Expr0 = par_conj(Goals0),
+ Expr = par_conj(Goals),
+ implicitly_quantify_conj(Goals0, Goals, !Info).
+
+implicitly_quantify_goal_2(Expr0, Expr, _, !Info) :-
+ Expr0 = disj(Goals0),
+ Expr = disj(Goals),
+ implicitly_quantify_disj(Goals0, Goals, !Info).
+
+implicitly_quantify_goal_2(Expr0, Expr, _, !Info) :-
+ Expr0 = switch(Var, Det, Cases0),
+ Expr = switch(Var, Det, Cases),
+ implicitly_quantify_cases(Cases0, Cases, !Info),
% The switch variable is guaranteed to be non-local to the
% switch, since it has to be bound elsewhere, so we put it
% in the nonlocals here.
- quantification__get_nonlocals(NonLocals0),
- { insert(NonLocals0, Var, NonLocals) },
- quantification__set_nonlocals(NonLocals).
-
-implicitly_quantify_goal_2(not(Goal0), _, not(Goal)) -->
+ quantification__get_nonlocals(NonLocals0, !Info),
+ insert(NonLocals0, Var, NonLocals),
+ quantification__set_nonlocals(NonLocals, !Info).
+
+implicitly_quantify_goal_2(Expr0, Expr, _, !Info) :-
+ Expr0 = not(Goal0),
+ Expr = not(Goal),
% quantified variables cannot be pushed inside a negation,
% so we insert the quantified vars into the outside vars set,
% and initialize the new quantified vars set to be empty
% (the lambda outside vars remain unchanged)
- quantification__get_quant_vars(QuantVars),
- quantification__get_outside(OutsideVars),
- { union(OutsideVars, QuantVars, OutsideVars1) },
- { init(QuantVars1) },
- quantification__set_quant_vars(QuantVars1),
- quantification__set_outside(OutsideVars1),
- implicitly_quantify_goal(Goal0, Goal),
- quantification__set_outside(OutsideVars),
- quantification__set_quant_vars(QuantVars).
+ quantification__get_quant_vars(QuantVars, !Info),
+ quantification__get_outside(OutsideVars, !Info),
+ union(OutsideVars, QuantVars, OutsideVars1),
+ init(QuantVars1),
+ quantification__set_quant_vars(QuantVars1, !Info),
+ quantification__set_outside(OutsideVars1, !Info),
+ implicitly_quantify_goal(Goal0, Goal, !Info),
+ quantification__set_outside(OutsideVars, !Info),
+ quantification__set_quant_vars(QuantVars, !Info).
% After this pass, explicit quantifiers are redundant,
% since all variables which were explicitly quantified
% have been renamed apart. So we don't keep them.
% Thus we replace `if_then_else(Vars, ....)' with
% `if_then_else([], ...)'.
-implicitly_quantify_goal_2(if_then_else(Vars0, Cond0, Then0, Else0),
- Context, if_then_else([], Cond, Then, Else)) -->
- quantification__get_quant_vars(QuantVars),
- quantification__get_outside(OutsideVars),
- quantification__get_lambda_outside(LambdaOutsideVars),
- { list_to_set(Vars0, QVars) },
+implicitly_quantify_goal_2(Expr0, Expr, Context, !Info) :-
+ Expr0 = if_then_else(Vars0, Cond0, Then0, Else0),
+ Expr = if_then_else([], Cond, Then, Else),
+ quantification__get_quant_vars(QuantVars, !Info),
+ quantification__get_outside(OutsideVars, !Info),
+ quantification__get_lambda_outside(LambdaOutsideVars, !Info),
+ list_to_set(Vars0, QVars),
% Rename apart those variables that
% are quantified to the cond and then
% of the i-t-e that occur outside the
% i-t-e.
- { intersect(OutsideVars, QVars, RenameVars1) },
- { intersect(LambdaOutsideVars, QVars, RenameVars2) },
- { union(RenameVars1, RenameVars2, RenameVars) },
- (
- { empty(RenameVars) }
- ->
- { Cond1 = Cond0 },
- { Then1 = Then0 },
- { Vars = Vars0 }
+ intersect(OutsideVars, QVars, RenameVars1),
+ intersect(LambdaOutsideVars, QVars, RenameVars2),
+ union(RenameVars1, RenameVars2, RenameVars),
+ ( empty(RenameVars) ->
+ Cond1 = Cond0,
+ Then1 = Then0,
+ Vars = Vars0
;
- quantification__warn_overlapping_scope(RenameVars, Context),
+ quantification__warn_overlapping_scope(RenameVars, Context,
+ !Info),
quantification__rename_apart(RenameVars, RenameMap,
- Cond0, Cond1),
- { goal_util__rename_vars_in_goal(Then0, RenameMap, Then1) },
- { goal_util__rename_var_list(Vars0, no, RenameMap, Vars) }
+ Cond0, Cond1, !Info),
+ goal_util__rename_vars_in_goal(Then0, RenameMap, Then1),
+ goal_util__rename_var_list(Vars0, no, RenameMap, Vars)
),
- { insert_list(QuantVars, Vars, QuantVars1) },
- quantification__get_nonlocals_to_recompute(NonLocalsToRecompute),
- { quantification__goal_vars(NonLocalsToRecompute,
- Then1, VarsThen, LambdaVarsThen) },
- { union(OutsideVars, VarsThen, OutsideVars1) },
- { union(LambdaOutsideVars, LambdaVarsThen, LambdaOutsideVars1) },
- quantification__set_quant_vars(QuantVars1),
- quantification__set_outside(OutsideVars1),
- quantification__set_lambda_outside(LambdaOutsideVars1),
- quantification__update_seen_vars(QVars),
- implicitly_quantify_goal(Cond1, Cond),
- quantification__get_nonlocals(NonLocalsCond),
- { union(OutsideVars, NonLocalsCond, OutsideVars2) },
- quantification__set_outside(OutsideVars2),
- quantification__set_lambda_outside(LambdaOutsideVars),
- implicitly_quantify_goal(Then1, Then),
- quantification__get_nonlocals(NonLocalsThen),
- quantification__set_outside(OutsideVars),
- quantification__set_quant_vars(QuantVars),
- implicitly_quantify_goal(Else0, Else),
- quantification__get_nonlocals(NonLocalsElse),
- { union(NonLocalsCond, NonLocalsThen, NonLocalsIfThen) },
- { union(NonLocalsIfThen, NonLocalsElse, NonLocalsIfThenElse) },
- { intersect(NonLocalsIfThenElse, OutsideVars, NonLocalsO) },
- { intersect(NonLocalsIfThenElse, LambdaOutsideVars, NonLocalsL) },
- { union(NonLocalsO, NonLocalsL, NonLocals) },
- quantification__set_nonlocals(NonLocals).
-
-implicitly_quantify_goal_2(call(A, B, HeadVars, D, E, F), _,
- call(A, B, HeadVars, D, E, F)) -->
- implicitly_quantify_atomic_goal(HeadVars).
-
-implicitly_quantify_goal_2(generic_call(GenericCall, ArgVars1, C, D), _,
- generic_call(GenericCall, ArgVars1, C, D)) -->
- { goal_util__generic_call_vars(GenericCall, ArgVars0) },
- { list__append(ArgVars0, ArgVars1, ArgVars) },
- implicitly_quantify_atomic_goal(ArgVars).
-
-implicitly_quantify_goal_2(
- unify(Var, UnifyRHS0, Mode, Unification0, UnifyContext),
- Context,
- unify(Var, UnifyRHS, Mode, Unification, UnifyContext)) -->
- quantification__get_outside(OutsideVars),
- quantification__get_lambda_outside(LambdaOutsideVars),
- { quantification__get_unify_typeinfos(Unification0, TypeInfoVars) },
+ insert_list(QuantVars, Vars, QuantVars1),
+ quantification__get_nonlocals_to_recompute(NonLocalsToRecompute,
+ !Info),
+ quantification__goal_vars(NonLocalsToRecompute,
+ Then1, VarsThen, LambdaVarsThen),
+ union(OutsideVars, VarsThen, OutsideVars1),
+ union(LambdaOutsideVars, LambdaVarsThen, LambdaOutsideVars1),
+ quantification__set_quant_vars(QuantVars1, !Info),
+ quantification__set_outside(OutsideVars1, !Info),
+ quantification__set_lambda_outside(LambdaOutsideVars1, !Info),
+ quantification__update_seen_vars(QVars, !Info),
+ implicitly_quantify_goal(Cond1, Cond, !Info),
+ quantification__get_nonlocals(NonLocalsCond, !Info),
+ union(OutsideVars, NonLocalsCond, OutsideVars2),
+ quantification__set_outside(OutsideVars2, !Info),
+ quantification__set_lambda_outside(LambdaOutsideVars, !Info),
+ implicitly_quantify_goal(Then1, Then, !Info),
+ quantification__get_nonlocals(NonLocalsThen, !Info),
+ quantification__set_outside(OutsideVars, !Info),
+ quantification__set_quant_vars(QuantVars, !Info),
+ implicitly_quantify_goal(Else0, Else, !Info),
+ quantification__get_nonlocals(NonLocalsElse, !Info),
+ union(NonLocalsCond, NonLocalsThen, NonLocalsIfThen),
+ union(NonLocalsIfThen, NonLocalsElse, NonLocalsIfThenElse),
+ intersect(NonLocalsIfThenElse, OutsideVars, NonLocalsO),
+ intersect(NonLocalsIfThenElse, LambdaOutsideVars, NonLocalsL),
+ union(NonLocalsO, NonLocalsL, NonLocals),
+ quantification__set_nonlocals(NonLocals, !Info).
+
+implicitly_quantify_goal_2(Expr, Expr, _, !Info) :-
+ Expr = call(_, _, HeadVars, _, _, _),
+ implicitly_quantify_atomic_goal(HeadVars, !Info).
+
+implicitly_quantify_goal_2(Expr, Expr, _, !Info) :-
+ Expr = generic_call(GenericCall, CallArgVars, _, _),
+ goal_util__generic_call_vars(GenericCall, ArgVars0),
+ list__append(ArgVars0, CallArgVars, ArgVars),
+ implicitly_quantify_atomic_goal(ArgVars, !Info).
- { Unification0 = construct(_, _, _, _, How, _, MaybeSize) ->
+implicitly_quantify_goal_2(Expr0, Expr, Context, !Info) :-
+ Expr0 = unify(Var, UnifyRHS0, Mode, Unification0, UnifyContext),
+ Expr = unify(Var, UnifyRHS, Mode, Unification, UnifyContext),
+ quantification__get_outside(OutsideVars, !Info),
+ quantification__get_lambda_outside(LambdaOutsideVars, !Info),
+ TypeInfoVars = quantification__get_unify_typeinfos(Unification0),
+ ( Unification0 = construct(_, _, _, _, How, _, MaybeSize) ->
( How = reuse_cell(cell_to_reuse(ReuseVar0, _, SetArgs)) ->
MaybeSetArgs = yes(SetArgs),
MaybeReuseVar = yes(ReuseVar0)
@@ -468,103 +462,98 @@
MaybeSetArgs = no,
MaybeReuseVar = no,
MaybeSizeVar = no
- },
-
- implicitly_quantify_unify_rhs(UnifyRHS0, MaybeSetArgs,
- Unification0, Context, UnifyRHS, Unification),
- quantification__get_nonlocals(VarsUnifyRHS),
- { insert(VarsUnifyRHS, Var, GoalVars0) },
- { insert_list(GoalVars0, TypeInfoVars, GoalVars1) },
-
- { MaybeReuseVar = yes(ReuseVar) ->
+ ),
+ implicitly_quantify_unify_rhs(MaybeSetArgs, Context,
+ UnifyRHS0, UnifyRHS, Unification0, Unification, !Info),
+ quantification__get_nonlocals(VarsUnifyRHS, !Info),
+ insert(VarsUnifyRHS, Var, GoalVars0),
+ insert_list(GoalVars0, TypeInfoVars, GoalVars1),
+ ( MaybeReuseVar = yes(ReuseVar) ->
insert(GoalVars1, ReuseVar, GoalVars2)
;
GoalVars2 = GoalVars1
- },
-
- { MaybeSizeVar = yes(SizeVar) ->
+ ),
+ ( MaybeSizeVar = yes(SizeVar) ->
insert(GoalVars2, SizeVar, GoalVars)
;
GoalVars = GoalVars2
- },
-
- quantification__update_seen_vars(GoalVars),
- { intersect(GoalVars, OutsideVars, NonLocalVars1) },
- { intersect(GoalVars, LambdaOutsideVars, NonLocalVars2) },
- { union(NonLocalVars1, NonLocalVars2, NonLocalVars) },
- quantification__set_nonlocals(NonLocalVars).
-
-implicitly_quantify_goal_2(foreign_proc(A,B,C,Vars,E,F,G), _,
- foreign_proc(A,B,C,Vars,E,F,G)) -->
- implicitly_quantify_atomic_goal(Vars).
-
-implicitly_quantify_goal_2(shorthand(ShorthandGoal), Context, Goal) -->
- implicitly_quantify_goal_2_shorthand(ShorthandGoal,
- Context, Goal).
-
+ ),
+ quantification__update_seen_vars(GoalVars, !Info),
+ intersect(GoalVars, OutsideVars, NonLocalVars1),
+ intersect(GoalVars, LambdaOutsideVars, NonLocalVars2),
+ union(NonLocalVars1, NonLocalVars2, NonLocalVars),
+ quantification__set_nonlocals(NonLocalVars, !Info).
+
+implicitly_quantify_goal_2(Expr, Expr, _, !Info) :-
+ Expr = foreign_proc(_, _, _, Vars, _, _, _),
+ implicitly_quantify_atomic_goal(Vars, !Info).
+
+implicitly_quantify_goal_2(Expr0, Expr, Context, !Info) :-
+ Expr0 = shorthand(ShorthandGoal),
+ implicitly_quantify_goal_2_shorthand(ShorthandGoal, Context, Expr,
+ !Info).
:- pred implicitly_quantify_goal_2_shorthand(shorthand_goal_expr::in,
prog_context::in, hlds_goal_expr::out,
quant_info::in, quant_info::out) is det.
-implicitly_quantify_goal_2_shorthand(bi_implication(LHS0, RHS0),
- Context, Goal) -->
+implicitly_quantify_goal_2_shorthand(bi_implication(LHS0, RHS0), Context, Goal,
+ !Info) :-
% get the initial values of various settings
- quantification__get_quant_vars(QuantVars0),
- quantification__get_outside(OutsideVars0),
- quantification__get_lambda_outside(LambdaOutsideVars0),
+ quantification__get_quant_vars(QuantVars0, !Info),
+ quantification__get_outside(OutsideVars0, !Info),
+ quantification__get_lambda_outside(LambdaOutsideVars0, !Info),
% quantified variables cannot be pushed inside a negation,
% so we insert the quantified vars into the outside vars set,
% and initialize the new quantified vars set to be empty
% (the lambda outside vars remain unchanged)
- { union(OutsideVars0, QuantVars0, OutsideVars1) },
- { init(QuantVars1) },
- { LambdaOutsideVars1 = LambdaOutsideVars0 },
- quantification__set_quant_vars(QuantVars1),
+ union(OutsideVars0, QuantVars0, OutsideVars1),
+ init(QuantVars1),
+ LambdaOutsideVars1 = LambdaOutsideVars0,
+ quantification__set_quant_vars(QuantVars1, !Info),
% prepare for quantifying the LHS:
% add variables from the RHS to the outside vars
% and the outside lambda vars sets.
- quantification__get_nonlocals_to_recompute(NonLocalsToRecompute),
- { quantification__goal_vars(NonLocalsToRecompute,
- RHS0, RHS_Vars, RHS_LambdaVars) },
- { union(OutsideVars1, RHS_Vars, LHS_OutsideVars) },
- { union(LambdaOutsideVars1, RHS_LambdaVars,
- LHS_LambdaOutsideVars) },
+ quantification__get_nonlocals_to_recompute(NonLocalsToRecompute, !Info),
+ quantification__goal_vars(NonLocalsToRecompute, RHS0, RHS_Vars,
+ RHS_LambdaVars),
+ union(OutsideVars1, RHS_Vars, LHS_OutsideVars),
+ union(LambdaOutsideVars1, RHS_LambdaVars, LHS_LambdaOutsideVars),
% quantify the LHS
- quantification__set_outside(LHS_OutsideVars),
- quantification__set_lambda_outside(LHS_LambdaOutsideVars),
- implicitly_quantify_goal(LHS0, LHS),
- quantification__get_nonlocals(LHS_NonLocalVars),
+ quantification__set_outside(LHS_OutsideVars, !Info),
+ quantification__set_lambda_outside(LHS_LambdaOutsideVars, !Info),
+ implicitly_quantify_goal(LHS0, LHS, !Info),
+ quantification__get_nonlocals(LHS_NonLocalVars, !Info),
% prepare for quantifying the RHS:
% add nonlocals from the LHS to the outside vars.
% (We use the nonlocals rather than the more symmetric
% approach of calling quantification__goal_vars on the
% LHS goal because it is more efficient.)
- { union(OutsideVars1, LHS_NonLocalVars, RHS_OutsideVars) },
- { RHS_LambdaOutsideVars = LambdaOutsideVars1 },
+ union(OutsideVars1, LHS_NonLocalVars, RHS_OutsideVars),
+ RHS_LambdaOutsideVars = LambdaOutsideVars1,
% quantify the RHS
- quantification__set_outside(RHS_OutsideVars),
- quantification__set_lambda_outside(RHS_LambdaOutsideVars),
- implicitly_quantify_goal(RHS0, RHS),
- quantification__get_nonlocals(RHS_NonLocalVars),
+ quantification__set_outside(RHS_OutsideVars, !Info),
+ quantification__set_lambda_outside(RHS_LambdaOutsideVars, !Info),
+ implicitly_quantify_goal(RHS0, RHS, !Info),
+ quantification__get_nonlocals(RHS_NonLocalVars, !Info),
% compute the nonlocals for this goal
- { union(LHS_NonLocalVars, RHS_NonLocalVars, AllNonLocalVars) },
- { intersect(AllNonLocalVars, OutsideVars0, NonLocalVarsO) },
- { intersect(AllNonLocalVars, LambdaOutsideVars0, NonLocalVarsL) },
- { union(NonLocalVarsO, NonLocalVarsL, NonLocalVars) },
- quantification__set_nonlocals(NonLocalVars),
+ union(LHS_NonLocalVars, RHS_NonLocalVars, AllNonLocalVars),
+ intersect(AllNonLocalVars, OutsideVars0, NonLocalVarsO),
+ intersect(AllNonLocalVars, LambdaOutsideVars0, NonLocalVarsL),
+ union(NonLocalVarsO, NonLocalVarsL, NonLocalVars),
+ quantification__set_nonlocals(NonLocalVars, !Info),
% restore the original values of various settings
- quantification__set_outside(OutsideVars0),
- quantification__set_lambda_outside(LambdaOutsideVars0),
- quantification__set_quant_vars(QuantVars0),
+ quantification__set_outside(OutsideVars0, !Info),
+ quantification__set_lambda_outside(LambdaOutsideVars0, !Info),
+ quantification__set_quant_vars(QuantVars0, !Info),
%
% We've figured out the quantification.
@@ -576,59 +565,57 @@
% ===>
% (not (LHS, not RHS)), (not (RHS, not LHS))
%
- { goal_info_init(GoalInfo0) },
- { goal_info_set_context(GoalInfo0, Context, GoalInfo1) },
- quantification__set_goal_nonlocals(GoalInfo1,
- LHS_NonLocalVars, LHS_GI),
- quantification__set_goal_nonlocals(GoalInfo1,
- RHS_NonLocalVars, RHS_GI),
- quantification__set_goal_nonlocals(GoalInfo1, NonLocalVars, GI),
- { NotLHS = not(LHS) - LHS_GI },
- { NotRHS = not(RHS) - RHS_GI },
- { ForwardsImplication = not(conj([LHS, NotRHS]) - GI) - GI },
+ goal_info_init(GoalInfo0),
+ goal_info_set_context(GoalInfo0, Context, GoalInfo1),
+ quantification__set_goal_nonlocals(LHS_NonLocalVars,
+ GoalInfo1, LHS_GI, !Info),
+ quantification__set_goal_nonlocals(RHS_NonLocalVars,
+ GoalInfo1, RHS_GI, !Info),
+ quantification__set_goal_nonlocals(NonLocalVars,
+ GoalInfo1, GI, !Info),
+ NotLHS = not(LHS) - LHS_GI,
+ NotRHS = not(RHS) - RHS_GI,
+ ForwardsImplication = not(conj([LHS, NotRHS]) - GI) - GI,
%
% Rename apart the local variables of the goals
% we've just duplicated.
%
- { ReverseImplication0 = not(conj([RHS, NotLHS]) - GI) - GI },
- { quantification__goal_vars_bitset(NonLocalsToRecompute,
- ReverseImplication0, GoalVars) },
- { difference(GoalVars, NonLocalVars, RenameVars) },
+ ReverseImplication0 = not(conj([RHS, NotLHS]) - GI) - GI,
+ quantification__goal_vars_bitset(NonLocalsToRecompute,
+ ReverseImplication0, GoalVars),
+ difference(GoalVars, NonLocalVars, RenameVars),
quantification__rename_apart(RenameVars, _,
- ReverseImplication0, ReverseImplication),
+ ReverseImplication0, ReverseImplication, !Info),
- { Goal = conj([ForwardsImplication, ReverseImplication]) }.
+ Goal = conj([ForwardsImplication, ReverseImplication]).
+:- pred implicitly_quantify_atomic_goal(list(prog_var)::in,
+ quant_info::in, quant_info::out) is det.
+implicitly_quantify_atomic_goal(HeadVars, !Info) :-
+ list_to_set(HeadVars, GoalVars),
+ quantification__update_seen_vars(GoalVars, !Info),
+ quantification__get_outside(OutsideVars, !Info),
+ quantification__get_lambda_outside(LambdaOutsideVars, !Info),
+ intersect(GoalVars, OutsideVars, NonLocals1),
+ intersect(GoalVars, LambdaOutsideVars, NonLocals2),
+ union(NonLocals1, NonLocals2, NonLocals),
+ quantification__set_nonlocals(NonLocals, !Info).
-:- pred implicitly_quantify_atomic_goal(list(prog_var), quant_info, quant_info).
-:- mode implicitly_quantify_atomic_goal(in, in, out) is det.
+:- pred implicitly_quantify_unify_rhs(maybe(list(bool))::in, prog_context::in,
+ unify_rhs::in, unify_rhs::out, unification::in, unification::out,
+ quant_info::in, quant_info::out) is det.
-implicitly_quantify_atomic_goal(HeadVars) -->
- { list_to_set(HeadVars, GoalVars) },
- quantification__update_seen_vars(GoalVars),
- quantification__get_outside(OutsideVars),
- quantification__get_lambda_outside(LambdaOutsideVars),
- { intersect(GoalVars, OutsideVars, NonLocals1) },
- { intersect(GoalVars, LambdaOutsideVars, NonLocals2) },
- { union(NonLocals1, NonLocals2, NonLocals) },
- quantification__set_nonlocals(NonLocals).
-
-:- pred implicitly_quantify_unify_rhs(unify_rhs, maybe(list(bool)),
- unification, prog_context, unify_rhs, unification,
- quant_info, quant_info).
-:- mode implicitly_quantify_unify_rhs(in, in, in, in,
- out, out, in, out) is det.
-
-implicitly_quantify_unify_rhs(var(X), _, Unification, _,
- var(X), Unification) -->
- { singleton_set(Vars, X) },
- quantification__set_nonlocals(Vars).
-implicitly_quantify_unify_rhs(functor(_, _, ArgVars) @ RHS, ReuseArgs,
- Unification, _, RHS, Unification) -->
- quantification__get_nonlocals_to_recompute(NonLocalsToRecompute),
- {
+implicitly_quantify_unify_rhs(_, _, !RHS, !Unification, !Info) :-
+ !.RHS = var(X),
+ singleton_set(Vars, X),
+ quantification__set_nonlocals(Vars, !Info).
+implicitly_quantify_unify_rhs(ReuseArgs, _, !RHS, !Unification, !Info) :-
+ !.RHS = functor(_, _, ArgVars),
+ quantification__get_nonlocals_to_recompute(NonLocalsToRecompute,
+ !Info),
+ (
NonLocalsToRecompute = code_gen_nonlocals,
ReuseArgs = yes(SetArgs)
->
@@ -638,72 +625,68 @@
list_to_set(Vars0, Vars)
;
list_to_set(ArgVars, Vars)
- },
- quantification__set_nonlocals(Vars).
-implicitly_quantify_unify_rhs(
- lambda_goal(Purity, PredOrFunc, EvalMethod, FixModes,
+ ),
+ quantification__set_nonlocals(Vars, !Info).
+implicitly_quantify_unify_rhs(_, Context, !RHS, !Unification, !Info) :-
+ !.RHS = lambda_goal(Purity, PredOrFunc, EvalMethod, FixModes,
LambdaNonLocals0, LambdaVars0, Modes, Det, Goal0),
- _, Unification0,
- Context,
- lambda_goal(Purity, PredOrFunc, EvalMethod, FixModes,
+ !:RHS = lambda_goal(Purity, PredOrFunc, EvalMethod, FixModes,
LambdaNonLocals, LambdaVars, Modes, Det, Goal),
- Unification
- ) -->
%
- % Note: make_hlds.m has already done most of the hard work
- % for lambda expressions. At this point, LambdaVars0
- % should in fact be guaranteed to be fresh distinct
- % variables. However, the code below does not assume this.
- %
- quantification__get_outside(OutsideVars0),
- { list_to_set(LambdaVars0, QVars) },
- % Figure out which variables have overlapping scopes
- % because they occur outside the goal and are also
- % lambda-quantified vars.
- { intersect(OutsideVars0, QVars, RenameVars0) },
- (
- { empty(RenameVars0) }
- ->
- []
+ % Note: make_hlds.m has already done most of the hard work for
+ % lambda expressions. At this point, LambdaVars0 should in fact be
+ % guaranteed to be fresh distinct variables. However, the code below
+ % does not assume this.
+ %
+ quantification__get_outside(OutsideVars0, !Info),
+ list_to_set(LambdaVars0, QVars),
+ % Figure out which variables have overlapping scopes because
+ % they occur outside the goal and are also lambda-quantified
+ % vars.
+ intersect(OutsideVars0, QVars, RenameVars0),
+ ( empty(RenameVars0) ->
+ true
;
- quantification__warn_overlapping_scope(RenameVars0, Context)
+ quantification__warn_overlapping_scope(RenameVars0, Context,
+ !Info)
),
% We need to rename apart any of the lambda vars that
% we have already seen, since they are new instances.
- quantification__get_seen(Seen0),
- { intersect(Seen0, QVars, RenameVars1) },
+ quantification__get_seen(Seen0, !Info),
+ intersect(Seen0, QVars, RenameVars1),
- { union(RenameVars0, RenameVars1, RenameVars) },
- quantification__rename_apart(RenameVars, RenameMap, Goal0, Goal1),
- { goal_util__rename_var_list(LambdaVars0, no, RenameMap, LambdaVars) },
+ union(RenameVars0, RenameVars1, RenameVars),
+ quantification__rename_apart(RenameVars, RenameMap, Goal0, Goal1,
+ !Info),
+ goal_util__rename_var_list(LambdaVars0, no, RenameMap, LambdaVars),
% Quantified variables cannot be pushed inside a lambda goal,
% so we insert the quantified vars into the outside vars set,
% and initialize the new quantified vars set to be empty.
- quantification__get_quant_vars(QuantVars0),
- { union(OutsideVars0, QuantVars0, OutsideVars1) },
- { init(QuantVars) },
- quantification__set_quant_vars(QuantVars),
+ quantification__get_quant_vars(QuantVars0, !Info),
+ union(OutsideVars0, QuantVars0, OutsideVars1),
+ init(QuantVars),
+ quantification__set_quant_vars(QuantVars, !Info),
% Add the lambda vars as outside vars, since they are
% outside of the lambda goal
- { insert_list(OutsideVars1, LambdaVars, OutsideVars) },
- quantification__set_outside(OutsideVars),
+ insert_list(OutsideVars1, LambdaVars, OutsideVars),
+ quantification__set_outside(OutsideVars, !Info),
% Set the LambdaOutsideVars set to empty, because
% variables that occur outside this lambda expression
% only in other lambda expressions should not be
% considered non-local.
- quantification__get_lambda_outside(LambdaOutsideVars0),
- { init(LambdaOutsideVars) },
- quantification__set_lambda_outside(LambdaOutsideVars),
- implicitly_quantify_goal(Goal1, Goal),
+ quantification__get_lambda_outside(LambdaOutsideVars0, !Info),
+ init(LambdaOutsideVars),
+ quantification__set_lambda_outside(LambdaOutsideVars, !Info),
+ implicitly_quantify_goal(Goal1, Goal, !Info),
- quantification__get_nonlocals(NonLocals0),
+ quantification__get_nonlocals(NonLocals0, !Info),
% lambda-quantified variables are local
- { delete_list(NonLocals0, LambdaVars, NonLocals) },
- quantification__set_quant_vars(QuantVars0),
- quantification__set_outside(OutsideVars0),
- quantification__set_lambda_outside(LambdaOutsideVars0),
- quantification__set_nonlocals(NonLocals),
+ delete_list(NonLocals0, LambdaVars, NonLocals),
+ quantification__set_quant_vars(QuantVars0, !Info),
+ quantification__set_outside(OutsideVars0, !Info),
+ quantification__set_lambda_outside(LambdaOutsideVars0, !Info),
+ quantification__set_nonlocals(NonLocals, !Info),
%
% Work out the list of non-local curried arguments to the lambda
@@ -711,12 +694,10 @@
% approximation that make_hlds uses includes all variables in the
% lambda expression except the quantified variables.
%
- { Goal = _ - LambdaGoalInfo },
- { goal_info_get_nonlocals(LambdaGoalInfo, LambdaGoalNonLocals) },
- { IsNonLocal = lambda([V::in] is semidet, (
- contains(LambdaGoalNonLocals, V)
- )) },
- { list__filter(IsNonLocal, LambdaNonLocals0, LambdaNonLocals) },
+ Goal = _ - LambdaGoalInfo,
+ goal_info_get_nonlocals(LambdaGoalInfo, LambdaGoalNonLocals),
+ list__filter(contains(LambdaGoalNonLocals),
+ LambdaNonLocals0, LambdaNonLocals),
%
% For a unification that constructs a lambda expression,
@@ -727,109 +708,105 @@
% The non-locals set must only ever decrease, not increase,
% so we can just use the old modes.
%
- {
- Unification0 = construct(ConstructVar, ConsId, Args0,
+ (
+ !.Unification = construct(ConstructVar, ConsId, Args0,
ArgModes0, HowToConstruct, Uniq, Size)
->
require(unify(Size, no), "lambda term has size info"),
map__from_corresponding_lists(Args0, ArgModes0, ArgModesMap),
to_sorted_list(NonLocals, Args),
map__apply_to_list(Args, ArgModesMap, ArgModes),
- Unification = construct(ConstructVar, ConsId, Args,
+ !:Unification = construct(ConstructVar, ConsId, Args,
ArgModes, HowToConstruct, Uniq, Size)
;
% after mode analysis, unifications with lambda variables
% should always be construction unifications, but
% quantification gets invoked before mode analysis,
% so we need to allow this case...
- Unification = Unification0
- }.
+ true
+ ).
+
+:- pred implicitly_quantify_conj(list(hlds_goal)::in, list(hlds_goal)::out,
+ quant_info::in, quant_info::out) is det.
+
+implicitly_quantify_conj(!Goals, !Info) :-
+ quantification__get_nonlocals_to_recompute(NonLocalsToRecompute,
+ !Info),
+ get_vars(NonLocalsToRecompute, !.Goals, FollowingVarsList),
+ implicitly_quantify_conj_2(FollowingVarsList, !Goals, !Info).
-:- pred implicitly_quantify_conj(list(hlds_goal), list(hlds_goal),
- quant_info, quant_info).
-:- mode implicitly_quantify_conj(in, out, in, out) is det.
-
-implicitly_quantify_conj(Goals0, Goals) -->
- quantification__get_nonlocals_to_recompute(NonLocalsToRecompute),
- { get_vars(NonLocalsToRecompute, Goals0, FollowingVarsList) },
- implicitly_quantify_conj_2(Goals0, FollowingVarsList, Goals).
-
-:- pred implicitly_quantify_conj_2(list(hlds_goal), list(pair(set_of_var)),
- list(hlds_goal), quant_info, quant_info).
-:- mode implicitly_quantify_conj_2(in, in, out, in, out) is det.
-
-implicitly_quantify_conj_2([], _, []) -->
- { init(NonLocalVars) },
- quantification__set_nonlocals(NonLocalVars).
-implicitly_quantify_conj_2([_|_], [], _, _, _) :-
+:- pred implicitly_quantify_conj_2(list(pair(set_of_var))::in,
+ list(hlds_goal)::in, list(hlds_goal)::out,
+ quant_info::in, quant_info::out) is det.
+
+implicitly_quantify_conj_2(_, [], [], !Info) :-
+ init(NonLocalVars),
+ quantification__set_nonlocals(NonLocalVars, !Info).
+implicitly_quantify_conj_2([], [_ | _], _, _, _) :-
error("implicitly_quantify_conj_2: length mismatch").
-implicitly_quantify_conj_2([Goal0 | Goals0],
+implicitly_quantify_conj_2(
[FollowingVars - LambdaFollowingVars | FollowingVarsList],
- [Goal | Goals]) -->
- quantification__get_outside(OutsideVars),
- quantification__get_lambda_outside(LambdaOutsideVars),
- { union(OutsideVars, FollowingVars, OutsideVars1) },
- { union(LambdaOutsideVars, LambdaFollowingVars,
- LambdaOutsideVars1) },
- quantification__set_outside(OutsideVars1),
- quantification__set_lambda_outside(LambdaOutsideVars1),
- implicitly_quantify_goal(Goal0, Goal),
- quantification__get_nonlocals(NonLocalVars1),
- { union(OutsideVars, NonLocalVars1, OutsideVars2) },
- quantification__set_outside(OutsideVars2),
- quantification__set_lambda_outside(LambdaOutsideVars),
- implicitly_quantify_conj_2(Goals0, FollowingVarsList,
- Goals),
- quantification__get_nonlocals(NonLocalVars2),
- { union(NonLocalVars1, NonLocalVars2, NonLocalVarsConj) },
- { intersect(NonLocalVarsConj, OutsideVars, NonLocalVarsO) },
- { intersect(NonLocalVarsConj, LambdaOutsideVars, NonLocalVarsL) },
- { union(NonLocalVarsO, NonLocalVarsL, NonLocalVars) },
- quantification__set_outside(OutsideVars),
- quantification__set_nonlocals(NonLocalVars).
-
-:- pred implicitly_quantify_disj(list(hlds_goal), list(hlds_goal),
- quant_info, quant_info).
-:- mode implicitly_quantify_disj(in, out, in, out) is det.
-
-implicitly_quantify_disj([], []) -->
- { init(NonLocalVars) },
- quantification__set_nonlocals(NonLocalVars).
-implicitly_quantify_disj([Goal0 | Goals0], [Goal | Goals]) -->
- implicitly_quantify_goal(Goal0, Goal),
- quantification__get_nonlocals(NonLocalVars0),
- implicitly_quantify_disj(Goals0, Goals),
- quantification__get_nonlocals(NonLocalVars1),
- { union(NonLocalVars0, NonLocalVars1, NonLocalVars) },
- quantification__set_nonlocals(NonLocalVars).
-
-:- pred implicitly_quantify_cases(list(case), list(case),
- quant_info, quant_info).
-:- mode implicitly_quantify_cases(in, out, in, out) is det.
-
-implicitly_quantify_cases([], []) -->
- { init(NonLocalVars) },
- quantification__set_nonlocals(NonLocalVars).
+ [Goal0 | Goals0], [Goal | Goals], !Info) :-
+ quantification__get_outside(OutsideVars, !Info),
+ quantification__get_lambda_outside(LambdaOutsideVars, !Info),
+ union(OutsideVars, FollowingVars, OutsideVars1),
+ union(LambdaOutsideVars, LambdaFollowingVars, LambdaOutsideVars1),
+ quantification__set_outside(OutsideVars1, !Info),
+ quantification__set_lambda_outside(LambdaOutsideVars1, !Info),
+ implicitly_quantify_goal(Goal0, Goal, !Info),
+ quantification__get_nonlocals(NonLocalVars1, !Info),
+ union(OutsideVars, NonLocalVars1, OutsideVars2),
+ quantification__set_outside(OutsideVars2, !Info),
+ quantification__set_lambda_outside(LambdaOutsideVars, !Info),
+ implicitly_quantify_conj_2(FollowingVarsList, Goals0, Goals, !Info),
+ quantification__get_nonlocals(NonLocalVars2, !Info),
+ union(NonLocalVars1, NonLocalVars2, NonLocalVarsConj),
+ intersect(NonLocalVarsConj, OutsideVars, NonLocalVarsO),
+ intersect(NonLocalVarsConj, LambdaOutsideVars, NonLocalVarsL),
+ union(NonLocalVarsO, NonLocalVarsL, NonLocalVars),
+ quantification__set_outside(OutsideVars, !Info),
+ quantification__set_nonlocals(NonLocalVars, !Info).
+
+:- pred implicitly_quantify_disj(list(hlds_goal)::in, list(hlds_goal)::out,
+ quant_info::in, quant_info::out) is det.
+
+implicitly_quantify_disj([], [], !Info) :-
+ init(NonLocalVars),
+ quantification__set_nonlocals(NonLocalVars, !Info).
+implicitly_quantify_disj([Goal0 | Goals0], [Goal | Goals], !Info) :-
+ implicitly_quantify_goal(Goal0, Goal, !Info),
+ quantification__get_nonlocals(NonLocalVars0, !Info),
+ implicitly_quantify_disj(Goals0, Goals, !Info),
+ quantification__get_nonlocals(NonLocalVars1, !Info),
+ union(NonLocalVars0, NonLocalVars1, NonLocalVars),
+ quantification__set_nonlocals(NonLocalVars, !Info).
+
+:- pred implicitly_quantify_cases(list(case)::in, list(case)::out,
+ quant_info::in, quant_info::out) is det.
+
+implicitly_quantify_cases([], [], !Info) :-
+ init(NonLocalVars),
+ quantification__set_nonlocals(NonLocalVars, !Info).
implicitly_quantify_cases([case(Cons, Goal0) | Cases0],
- [case(Cons, Goal) | Cases]) -->
- implicitly_quantify_goal(Goal0, Goal),
- quantification__get_nonlocals(NonLocalVars0),
- implicitly_quantify_cases(Cases0, Cases),
- quantification__get_nonlocals(NonLocalVars1),
- { union(NonLocalVars0, NonLocalVars1, NonLocalVars) },
- quantification__set_nonlocals(NonLocalVars).
+ [case(Cons, Goal) | Cases], !Info) :-
+ implicitly_quantify_goal(Goal0, Goal, !Info),
+ quantification__get_nonlocals(NonLocalVars0, !Info),
+ implicitly_quantify_cases(Cases0, Cases, !Info),
+ quantification__get_nonlocals(NonLocalVars1, !Info),
+ union(NonLocalVars0, NonLocalVars1, NonLocalVars),
+ quantification__set_nonlocals(NonLocalVars, !Info).
%-----------------------------------------------------------------------------%
% insert the given set of variables into the set of `seen' variables.
-:- pred quantification__update_seen_vars(set_of_var, quant_info, quant_info).
-:- mode quantification__update_seen_vars(in, in, out) is det.
+:- pred quantification__update_seen_vars(set_of_var::in,
+ quant_info::in, quant_info::out) is det.
-quantification__update_seen_vars(NewVars) -->
- quantification__get_seen(SeenVars0),
- { union(SeenVars0, NewVars, SeenVars) },
- quantification__set_seen(SeenVars).
+quantification__update_seen_vars(NewVars, !Info) :-
+ quantification__get_seen(SeenVars0, !Info),
+ union(SeenVars0, NewVars, SeenVars),
+ quantification__set_seen(SeenVars, !Info).
%-----------------------------------------------------------------------------%
@@ -842,18 +819,16 @@
% and the second contains following variables that
% occur in lambda goals.
-:- pred get_vars(nonlocals_to_recompute, list(hlds_goal),
- list(pair(set_of_var))).
-:- mode get_vars(in, in, out) is det.
+:- pred get_vars(nonlocals_to_recompute::in, list(hlds_goal)::in,
+ list(pair(set_of_var))::out) is det.
get_vars(_, [], []).
get_vars(NonLocalsToRecompute, [_Goal | Goals],
[Set - LambdaSet | SetPairs]) :-
get_vars_2(NonLocalsToRecompute, Goals, Set, LambdaSet, SetPairs).
-:- pred get_vars_2(nonlocals_to_recompute, list(hlds_goal),
- set_of_var, set_of_var, list(pair(set_of_var))).
-:- mode get_vars_2(in, in, out, out, out) is det.
+:- pred get_vars_2(nonlocals_to_recompute::in, list(hlds_goal)::in,
+ set_of_var::out, set_of_var::out, list(pair(set_of_var))::out) is det.
get_vars_2(_, [], Set, LambdaSet, []) :-
init(Set),
@@ -868,30 +843,27 @@
union(LambdaSet0, LambdaSet1, LambdaSet),
SetPairList = [Set0 - LambdaSet0 | SetPairList0].
-:- pred goal_list_vars_2(nonlocals_to_recompute, list(hlds_goal),
- set_of_var, set_of_var, set_of_var, set_of_var).
-:- mode goal_list_vars_2(in, in, in, in, out, out) is det.
+:- pred goal_list_vars_2(nonlocals_to_recompute::in, list(hlds_goal)::in,
+ set_of_var::in, set_of_var::out, set_of_var::in, set_of_var::out)
+ is det.
-goal_list_vars_2(_, [], Set, LambdaSet, Set, LambdaSet).
+goal_list_vars_2(_, [], !Set, !LambdaSet).
goal_list_vars_2(NonLocalsToRecompute, [Goal - _GoalInfo| Goals],
- Set0, LambdaSet0, Set, LambdaSet) :-
- quantification__goal_vars_2(NonLocalsToRecompute,
- Goal, Set0, LambdaSet0, Set1, LambdaSet1),
- goal_list_vars_2(NonLocalsToRecompute, Goals,
- Set1, LambdaSet1, Set, LambdaSet).
+ !Set, !LambdaSet) :-
+ quantification__goal_vars_2(NonLocalsToRecompute, Goal,
+ !Set, !LambdaSet),
+ goal_list_vars_2(NonLocalsToRecompute, Goals, !Set, !LambdaSet).
-:- pred case_list_vars_2(nonlocals_to_recompute, list(case),
- set_of_var, set_of_var, set_of_var, set_of_var).
-:- mode case_list_vars_2(in, in, in, in, out, out) is det.
-
-case_list_vars_2(_, [], Set, LambdaSet, Set, LambdaSet).
-case_list_vars_2(NonLocalsToRecompute,
- [case(_Cons, Goal - _GoalInfo)| Cases], Set0,
- LambdaSet0, Set, LambdaSet) :-
- quantification__goal_vars_2(NonLocalsToRecompute,
- Goal, Set0, LambdaSet0, Set1, LambdaSet1),
- case_list_vars_2(NonLocalsToRecompute, Cases,
- Set1, LambdaSet1, Set, LambdaSet).
+:- pred case_list_vars_2(nonlocals_to_recompute::in, list(case)::in,
+ set_of_var::in, set_of_var::out, set_of_var::in, set_of_var::out)
+ is det.
+
+case_list_vars_2(_, [], !Set, !LambdaSet).
+case_list_vars_2(NonLocalsToRecompute, [case(_Cons, Goal - _GoalInfo) | Cases],
+ !Set, !LambdaSet) :-
+ quantification__goal_vars_2(NonLocalsToRecompute, Goal,
+ !Set, !LambdaSet),
+ case_list_vars_2(NonLocalsToRecompute, Cases, !Set, !LambdaSet).
% quantification__goal_vars(NonLocalsToRecompute, Goal, Vars):
% Vars is the set of variables that occur free (unquantified)
@@ -917,81 +889,76 @@
% in Goal, not counting occurrences in lambda expressions.
% LambdaSet is the set of variables that occur free (unquantified)
% in lambda expressions in Goal.
-:- pred quantification__goal_vars(nonlocals_to_recompute,
- hlds_goal, set_of_var, set_of_var).
-:- mode quantification__goal_vars(in, in, out, out) is det.
+:- pred quantification__goal_vars(nonlocals_to_recompute::in,
+ hlds_goal::in, set_of_var::out, set_of_var::out) is det.
-quantification__goal_vars(NonLocalsToRecompute,
- Goal - _GoalInfo, Set, LambdaSet) :-
+quantification__goal_vars(NonLocalsToRecompute, Goal - _GoalInfo,
+ Set, LambdaSet) :-
init(Set0),
init(LambdaSet0),
quantification__goal_vars_2(NonLocalsToRecompute,
- Goal, Set0, LambdaSet0, Set, LambdaSet).
+ Goal, Set0, Set, LambdaSet0, LambdaSet).
-:- pred quantification__goal_vars_2(nonlocals_to_recompute, hlds_goal_expr,
- set_of_var, set_of_var, set_of_var, set_of_var).
-:- mode quantification__goal_vars_2(in, in, in, in, out, out) is det.
+:- pred quantification__goal_vars_2(nonlocals_to_recompute::in,
+ hlds_goal_expr::in,
+ set_of_var::in, set_of_var::out,
+ set_of_var::in, set_of_var::out) is det.
quantification__goal_vars_2(NonLocalsToRecompute,
- unify(A, B, _, Unification, _), Set0, LambdaSet0,
- Set, LambdaSet) :-
- insert(Set0, A, Set1),
+ unify(LHS, RHS, _, Unification, _), !Set, !LambdaSet) :-
+ insert(!.Set, LHS, !:Set),
( Unification = construct(_, _, _, _, How, _, Size) ->
( How = reuse_cell(cell_to_reuse(ReuseVar, _, SetArgs)) ->
MaybeSetArgs = yes(SetArgs),
- insert(Set1, ReuseVar, Set2)
+ insert(!.Set, ReuseVar, !:Set)
;
- MaybeSetArgs = no,
- Set2 = Set1
+ MaybeSetArgs = no
),
( Size = yes(dynamic_size(SizeVar)) ->
- insert(Set2, SizeVar, Set3)
+ insert(!.Set, SizeVar, !:Set)
;
- Set3 = Set2
+ true
)
; Unification = complicated_unify(_, _, TypeInfoVars) ->
MaybeSetArgs = no,
- insert_list(Set1, TypeInfoVars, Set3)
+ insert_list(!.Set, TypeInfoVars, !:Set)
;
- MaybeSetArgs = no,
- Set3 = Set1
+ MaybeSetArgs = no
),
- quantification__unify_rhs_vars(NonLocalsToRecompute, B, MaybeSetArgs,
- Set3, LambdaSet0, Set, LambdaSet).
+ quantification__unify_rhs_vars(NonLocalsToRecompute, RHS, MaybeSetArgs,
+ !Set, !LambdaSet).
quantification__goal_vars_2(_, generic_call(GenericCall, ArgVars1, _, _),
- Set0, LambdaSet, Set, LambdaSet) :-
+ !Set, !LambdaSet) :-
goal_util__generic_call_vars(GenericCall, ArgVars0),
- insert_list(Set0, ArgVars0, Set1),
- insert_list(Set1, ArgVars1, Set).
+ insert_list(!.Set, ArgVars0, !:Set),
+ insert_list(!.Set, ArgVars1, !:Set).
-quantification__goal_vars_2(_, call(_, _, ArgVars, _, _, _), Set0, LambdaSet,
- Set, LambdaSet) :-
- insert_list(Set0, ArgVars, Set).
+quantification__goal_vars_2(_, call(_, _, ArgVars, _, _, _),
+ !Set, !LambdaSet) :-
+ insert_list(!.Set, ArgVars, !:Set).
quantification__goal_vars_2(NonLocalsToRecompute, conj(Goals),
- Set0, LambdaSet0, Set, LambdaSet) :-
- goal_list_vars_2(NonLocalsToRecompute, Goals,
- Set0, LambdaSet0, Set, LambdaSet).
+ !Set, !LambdaSet) :-
+ goal_list_vars_2(NonLocalsToRecompute, Goals, !Set, !LambdaSet).
quantification__goal_vars_2(NonLocalsToRecompute, par_conj(Goals),
- Set0, LambdaSet0, Set, LambdaSet) :-
+ !Set, !LambdaSet) :-
goal_list_vars_2(NonLocalsToRecompute, Goals,
- Set0, LambdaSet0, Set, LambdaSet).
+ !Set, !LambdaSet).
quantification__goal_vars_2(NonLocalsToRecompute, disj(Goals),
- Set0, LambdaSet0, Set, LambdaSet) :-
- goal_list_vars_2(NonLocalsToRecompute, Goals, Set0, LambdaSet0,
- Set, LambdaSet).
+ !Set, !LambdaSet) :-
+ goal_list_vars_2(NonLocalsToRecompute, Goals,
+ !Set, !LambdaSet).
quantification__goal_vars_2(NonLocalsToRecompute, switch(Var, _Det, Cases),
- Set0, LambdaSet0, Set, LambdaSet) :-
- insert(Set0, Var, Set1),
- case_list_vars_2(NonLocalsToRecompute, Cases,
- Set1, LambdaSet0, Set, LambdaSet).
+ !Set, !LambdaSet) :-
+ insert(!.Set, Var, !:Set),
+ case_list_vars_2(NonLocalsToRecompute, Cases, !Set, !LambdaSet).
quantification__goal_vars_2(NonLocalsToRecompute, some(Vars, _, Goal),
- Set0, LambdaSet0, Set, LambdaSet) :-
+ Set0, Set, LambdaSet0, LambdaSet) :-
quantification__goal_vars(NonLocalsToRecompute,
Goal, Set1, LambdaSet1),
delete_list(Set1, Vars, Set2),
@@ -1000,62 +967,57 @@
union(LambdaSet0, LambdaSet2, LambdaSet).
quantification__goal_vars_2(NonLocalsToRecompute, not(Goal - _GoalInfo),
- Set0, LambdaSet0, Set, LambdaSet) :-
+ !Set, !LambdaSet) :-
quantification__goal_vars_2(NonLocalsToRecompute, Goal,
- Set0, LambdaSet0, Set, LambdaSet).
+ !Set, !LambdaSet).
quantification__goal_vars_2(NonLocalsToRecompute,
- if_then_else(Vars, A, B, C),
- Set0, LambdaSet0, Set, LambdaSet) :-
+ if_then_else(Vars, Cond, Then, Else),
+ !Set, !LambdaSet) :-
% This code does the following:
- % Set = Set0 + ( (vars(A) + vars(B)) \ Vars ) + vars(C)
+ % !:Set = !.Set + ( (vars(Cond) + vars(Then)) \ Vars ) + vars(Else)
% where `+' is set union and `\' is relative complement.
- quantification__goal_vars(NonLocalsToRecompute, A, Set1, LambdaSet1),
- quantification__goal_vars(NonLocalsToRecompute, B, Set2, LambdaSet2),
- union(Set1, Set2, Set3),
- union(LambdaSet1, LambdaSet2, LambdaSet3),
- delete_list(Set3, Vars, Set4),
- delete_list(LambdaSet3, Vars, LambdaSet4),
- union(Set0, Set4, Set5),
- union(LambdaSet0, LambdaSet4, LambdaSet5),
- quantification__goal_vars(NonLocalsToRecompute, C, Set6, LambdaSet6),
- union(Set5, Set6, Set),
- union(LambdaSet5, LambdaSet6, LambdaSet).
+ quantification__goal_vars(NonLocalsToRecompute, Cond,
+ CondSet, CondLambdaSet),
+ quantification__goal_vars(NonLocalsToRecompute, Then,
+ ThenSet, ThenLambdaSet),
+ quantification__goal_vars(NonLocalsToRecompute, Else,
+ ElseSet, ElseLambdaSet),
+ union(CondSet, ThenSet, CondThenSet),
+ union(CondLambdaSet, ThenLambdaSet, CondThenLambdaSet),
+ delete_list(CondThenSet, Vars, SomeCondThenSet),
+ delete_list(CondThenLambdaSet, Vars, SomeCondThenLambdaSet),
+ union(!.Set, SomeCondThenSet, !:Set),
+ union(!.LambdaSet, SomeCondThenLambdaSet, !:LambdaSet),
+ union(!.Set, ElseSet, !:Set),
+ union(!.LambdaSet, ElseLambdaSet, !:LambdaSet).
quantification__goal_vars_2(_, foreign_proc(_,_,_, ArgVars, _, _, _),
- Set0, LambdaSet, Set, LambdaSet) :-
- insert_list(Set0, ArgVars, Set).
+ !Set, !LambdaSet) :-
+ insert_list(!.Set, ArgVars, !:Set).
quantification__goal_vars_2(NonLocalsToRecompute, shorthand(ShorthandGoal),
- Set0, LambdaSet0, Set, LambdaSet) :-
+ !Set, !LambdaSet) :-
quantification__goal_vars_2_shorthand(NonLocalsToRecompute,
- ShorthandGoal, Set0, LambdaSet0, Set, LambdaSet).
+ ShorthandGoal, !Set, !LambdaSet).
-
-:- pred quantification__goal_vars_2_shorthand(nonlocals_to_recompute,
- shorthand_goal_expr, set_of_var, set_of_var, set_of_var,
- set_of_var).
-:- mode quantification__goal_vars_2_shorthand(in, in, in, in, out, out)
- is det.
+:- pred quantification__goal_vars_2_shorthand(nonlocals_to_recompute::in,
+ shorthand_goal_expr::in, set_of_var::in, set_of_var::out,
+ set_of_var::in, set_of_var::out) is det.
quantification__goal_vars_2_shorthand(NonLocalsToRecompute,
- bi_implication(LHS, RHS), Set0, LambdaSet0, Set,
- LambdaSet) :-
+ bi_implication(LHS, RHS), !Set, !LambdaSet) :-
goal_list_vars_2(NonLocalsToRecompute, [LHS, RHS],
- Set0, LambdaSet0, Set, LambdaSet).
-
+ !Set, !LambdaSet).
-:- pred quantification__unify_rhs_vars(nonlocals_to_recompute,
- unify_rhs, maybe(list(bool)), set_of_var, set_of_var,
- set_of_var, set_of_var).
-:- mode quantification__unify_rhs_vars(in, in, in, in, in, out, out) is det.
-
-quantification__unify_rhs_vars(_, var(Y), _,
- Set0, LambdaSet, Set, LambdaSet) :-
- insert(Set0, Y, Set).
-quantification__unify_rhs_vars(NonLocalsToRecompute,
- functor(_Functor, _, ArgVars), MaybeSetArgs,
- Set0, LambdaSet, Set, LambdaSet) :-
+:- pred quantification__unify_rhs_vars(nonlocals_to_recompute::in,
+ unify_rhs::in, maybe(list(bool))::in, set_of_var::in, set_of_var::out,
+ set_of_var::in, set_of_var::out) is det.
+
+quantification__unify_rhs_vars(_, var(Y), _, !Set, !LambdaSet) :-
+ insert(!.Set, Y, !:Set).
+quantification__unify_rhs_vars(NonLocalsToRecompute, functor(_, _, ArgVars),
+ MaybeSetArgs, !Set, !LambdaSet) :-
(
NonLocalsToRecompute = code_gen_nonlocals,
MaybeSetArgs = yes(SetArgs)
@@ -1063,76 +1025,70 @@
% Ignore the fields taken from the reused cell.
quantification__get_updated_fields(SetArgs, ArgVars,
ArgsToSet),
- insert_list(Set0, ArgsToSet, Set)
+ insert_list(!.Set, ArgsToSet, !:Set)
;
- insert_list(Set0, ArgVars, Set)
+ insert_list(!.Set, ArgVars, !:Set)
).
quantification__unify_rhs_vars(NonLocalsToRecompute,
- lambda_goal(_P, _POrF, _E, _F, _N, LambdaVars, _M, _D, Goal),
- _, Set, LambdaSet0, Set, LambdaSet) :-
+ lambda_goal(_, _, _, _, _, LambdaVars, _, _, Goal), _,
+ !Set, !LambdaSet) :-
% Note that the NonLocals list is not counted, since all the
% variables in that list must occur in the goal.
quantification__goal_vars_bitset(NonLocalsToRecompute, Goal, GoalVars),
delete_list(GoalVars, LambdaVars, GoalVars1),
- union(LambdaSet0, GoalVars1, LambdaSet).
+ union(!.LambdaSet, GoalVars1, !:LambdaSet).
-:- pred quantification__insert_set_fields(list(bool), list(prog_var),
- set_of_var, set_of_var).
-:- mode quantification__insert_set_fields(in, in, in, out) is det.
+:- pred quantification__insert_set_fields(list(bool)::in, list(prog_var)::in,
+ set_of_var::in, set_of_var::out) is det.
-quantification__insert_set_fields(SetArgs, Args, Set0, Set) :-
+quantification__insert_set_fields(SetArgs, Args, !Set) :-
quantification__get_updated_fields(SetArgs, Args, ArgsToSet),
- insert_list(Set0, ArgsToSet, Set).
+ insert_list(!.Set, ArgsToSet, !:Set).
-:- pred quantification__get_updated_fields(list(bool),
- list(prog_var), list(prog_var)).
-:- mode quantification__get_updated_fields(in, in, out) is det.
+:- pred quantification__get_updated_fields(list(bool)::in,
+ list(prog_var)::in, list(prog_var)::out) is det.
quantification__get_updated_fields(SetArgs, Args, ArgsToSet) :-
quantification__get_updated_fields(SetArgs, Args, [], ArgsToSet).
-:- pred quantification__get_updated_fields(list(bool),
- list(prog_var), list(prog_var), list(prog_var)).
-:- mode quantification__get_updated_fields(in, in, in, out) is det.
+:- pred quantification__get_updated_fields(list(bool)::in,
+ list(prog_var)::in, list(prog_var)::in, list(prog_var)::out) is det.
-quantification__get_updated_fields([], [], Fields, Fields).
+quantification__get_updated_fields([], [], !ArgsToSet).
quantification__get_updated_fields([], [_|_], _, _) :-
error("quantification__get_updated_fields").
quantification__get_updated_fields([_|_], [], _, _) :-
error("quantification__get_updated_fields").
quantification__get_updated_fields([SetArg | SetArgs], [Arg | Args],
- ArgsToSet0, ArgsToSet) :-
+ !ArgsToSet) :-
(
SetArg = yes,
- ArgsToSet1 = [Arg | ArgsToSet0]
+ !:ArgsToSet = [Arg | !.ArgsToSet]
;
SetArg = no,
- ArgsToSet1 = ArgsToSet0
+ !:ArgsToSet = !.ArgsToSet
),
- quantification__get_updated_fields(SetArgs, Args,
- ArgsToSet1, ArgsToSet).
+ quantification__get_updated_fields(SetArgs, Args, !ArgsToSet).
-:- pred quantification__get_unify_typeinfos(unification, list(prog_var)).
-:- mode quantification__get_unify_typeinfos(in, out) is det.
+:- func quantification__get_unify_typeinfos(unification) = list(prog_var).
-quantification__get_unify_typeinfos(Unification, TypeInfoVars) :-
+quantification__get_unify_typeinfos(Unification) =
( Unification = complicated_unify(_, _, TypeInfoVars0) ->
- TypeInfoVars = TypeInfoVars0
+ TypeInfoVars0
;
- TypeInfoVars = []
+ []
).
%-----------------------------------------------------------------------------%
-:- pred quantification__warn_overlapping_scope(set_of_var, prog_context,
- quant_info, quant_info).
-:- mode quantification__warn_overlapping_scope(in, in, in, out) is det.
-
-quantification__warn_overlapping_scope(OverlapVars, Context) -->
- { to_sorted_list(OverlapVars, Vars) },
- quantification__get_warnings(Warnings0),
- { Warnings = [warn_overlap(Vars, Context) | Warnings0] },
- quantification__set_warnings(Warnings).
+:- pred quantification__warn_overlapping_scope(set_of_var::in,
+ prog_context::in, quant_info::in, quant_info::out) is det.
+
+quantification__warn_overlapping_scope(OverlapVars, Context, !Info) :-
+ to_sorted_list(OverlapVars, Vars),
+ quantification__get_warnings(Warnings0, !Info),
+ Warnings = [warn_overlap(Vars, Context) | Warnings0],
+ quantification__set_warnings(Warnings, !Info).
%-----------------------------------------------------------------------------%
@@ -1141,12 +1097,13 @@
% and insert the mapping V->V' into RenameMap.
% Apply RenameMap to Goal0 giving Goal.
-:- pred quantification__rename_apart(set_of_var, map(prog_var, prog_var),
- hlds_goal, hlds_goal, quant_info, quant_info).
-:- mode quantification__rename_apart(in, out, in, out, in, out) is det.
+:- pred quantification__rename_apart(set_of_var::in,
+ map(prog_var, prog_var)::out, hlds_goal::in, hlds_goal::out,
+ quant_info::in, quant_info::out) is det.
-quantification__rename_apart(RenameSet, RenameMap, Goal0, Goal) -->
- quantification__get_nonlocals_to_recompute(NonLocalsToRecompute),
+quantification__rename_apart(RenameSet, RenameMap, !Goal, !Info) :-
+ quantification__get_nonlocals_to_recompute(NonLocalsToRecompute,
+ !Info),
(
%
% Don't rename apart variables when recomputing the
@@ -1157,62 +1114,60 @@
% renaming will have been done while recomputing
% the ordinary non-locals.
%
- { empty(RenameSet)
+ ( empty(RenameSet)
; NonLocalsToRecompute = code_gen_nonlocals
- }
+ )
->
- { map__init(RenameMap) },
- { Goal = Goal0 }
+ map__init(RenameMap)
;
- { to_sorted_list(RenameSet, RenameList) },
- quantification__get_varset(Varset0),
- quantification__get_vartypes(VarTypes0),
- { map__init(RenameMap0) },
- { goal_util__create_variables(RenameList,
+ to_sorted_list(RenameSet, RenameList),
+ quantification__get_varset(Varset0, !Info),
+ quantification__get_vartypes(VarTypes0, !Info),
+ map__init(RenameMap0),
+ goal_util__create_variables(RenameList,
Varset0, VarTypes0, RenameMap0, VarTypes0, Varset0,
% ^ Accumulator ^ Reference ^Var names
- Varset, VarTypes, RenameMap) },
- { goal_util__rename_vars_in_goal(Goal0, RenameMap, Goal) },
- quantification__set_varset(Varset),
- quantification__set_vartypes(VarTypes)
-/****
- We don't need to add the newly created vars to the seen vars
- because we won't find them anywhere else in the enclosing goal.
- This is a performance improvement because it keeps the size of
- the seen var set down.
- quantification__get_seen(SeenVars0),
- { map__values(RenameMap, NewVarsList) },
- { insert_list(SeenVars0, NewVarsList, SeenVars) },
- quantification__set_seen(SeenVars).
-****/
+ Varset, VarTypes, RenameMap),
+ goal_util__rename_vars_in_goal(!.Goal, RenameMap, !:Goal),
+ quantification__set_varset(Varset, !Info),
+ quantification__set_vartypes(VarTypes, !Info)
+
+ % We don't need to add the newly created vars to the seen vars
+ % because we won't find them anywhere else in the enclosing
+ % goal. This is a performance improvement because it keeps
+ % the size of the seen var set down.
+ % quantification__get_seen(SeenVars0, !Info),
+ % map__values(RenameMap, NewVarsList),
+ % insert_list(SeenVars0, NewVarsList, SeenVars),
+ % quantification__set_seen(SeenVars, !Info)
).
%-----------------------------------------------------------------------------%
-:- pred quantification__set_goal_nonlocals(hlds_goal_info,
- set_of_var, hlds_goal_info, quant_info, quant_info).
-:- mode quantification__set_goal_nonlocals(in, in, out, in, out) is det.
-
-quantification__set_goal_nonlocals(GoalInfo0, NonLocals, GoalInfo) -->
- quantification__set_goal_nonlocals(GoalInfo0, NonLocals, GoalInfo, _).
-
-:- pred quantification__set_goal_nonlocals(hlds_goal_info,
- set_of_var, hlds_goal_info, set(prog_var),
- quant_info, quant_info).
-:- mode quantification__set_goal_nonlocals(in, in, out, out, in, out) is det.
-
-quantification__set_goal_nonlocals(GoalInfo0, NonLocals0,
- GoalInfo, NonLocals) -->
- { NonLocals = bitset_to_set(NonLocals0) },
- quantification__get_nonlocals_to_recompute(NonLocalsToRecompute),
- {
+:- pred quantification__set_goal_nonlocals(set_of_var::in,
+ hlds_goal_info::in, hlds_goal_info::out,
+ quant_info::in, quant_info::out) is det.
+
+quantification__set_goal_nonlocals(NonLocals, !GoalInfo, !Info) :-
+ quantification__set_goal_nonlocals(NonLocals, _, !GoalInfo,
+ !Info).
+
+:- pred quantification__set_goal_nonlocals(set_of_var::in, set(prog_var)::out,
+ hlds_goal_info::in, hlds_goal_info::out,
+ quant_info::in, quant_info::out) is det.
+
+quantification__set_goal_nonlocals(NonLocals0, NonLocals, !GoalInfo, !Info) :-
+ NonLocals = bitset_to_set(NonLocals0),
+ quantification__get_nonlocals_to_recompute(NonLocalsToRecompute,
+ !Info),
+ (
NonLocalsToRecompute = ordinary_nonlocals,
- goal_info_set_nonlocals(GoalInfo0, NonLocals, GoalInfo)
+ goal_info_set_nonlocals(!.GoalInfo, NonLocals, !:GoalInfo)
;
NonLocalsToRecompute = code_gen_nonlocals,
- goal_info_set_code_gen_nonlocals(GoalInfo0,
- NonLocals, GoalInfo)
- }.
+ goal_info_set_code_gen_nonlocals(!.GoalInfo, NonLocals,
+ !:GoalInfo)
+ ).
%-----------------------------------------------------------------------------%
Index: compiler/recompilation.check.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/recompilation.check.m,v
retrieving revision 1.3
diff -u -b -r1.3 recompilation.check.m
--- compiler/recompilation.check.m 25 Jul 2003 02:27:23 -0000 1.3
+++ compiler/recompilation.check.m 21 Oct 2003 09:56:26 -0000
@@ -470,7 +470,7 @@
resolved_pred_or_func_map::in, resolved_pred_or_func_map::out) is det.
parse_pred_or_func_item_match(Info, Term, Items0, Items) :-
- invalid_pred_id(PredId),
+ PredId = invalid_pred_id,
(
(
Term = term__functor(term__atom("=>"),
@@ -536,9 +536,8 @@
sym_name_and_args(ModuleTerm, ModuleName, []),
ArityTerm = term__functor(term__integer(Arity), [], _)
->
- invalid_pred_id(PredId),
- Ctor = pred_or_func(PredId, ModuleName,
- PredOrFunc, Arity)
+ PredId = invalid_pred_id,
+ Ctor = pred_or_func(PredId, ModuleName, PredOrFunc, Arity)
;
Term = term__functor(term__atom("ctor"), [NameArityTerm], _),
parse_name_and_arity(NameArityTerm, TypeName, TypeArity)
@@ -1059,7 +1058,7 @@
[]
),
- { invalid_pred_id(PredId) },
+ { PredId = invalid_pred_id },
( { SymName = qualified(ModuleName, _) } ->
{
WithType = yes(_),
Index: compiler/recompilation.usage.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/recompilation.usage.m,v
retrieving revision 1.9
diff -u -b -r1.9 recompilation.usage.m
--- compiler/recompilation.usage.m 25 Jul 2003 02:27:23 -0000 1.9
+++ compiler/recompilation.usage.m 21 Oct 2003 13:59:42 -0000
@@ -654,7 +654,7 @@
(func(PredId) = PredId - PredModule :-
module_info_pred_info(ModuleInfo,
PredId, PredInfo),
- pred_info_module(PredInfo, PredModule)
+ PredModule = pred_info_module(PredInfo)
),
MatchingPredIds)) },
{ map__det_insert(MatchingNames0, ModuleQualifier,
@@ -790,9 +790,10 @@
recompilation__usage__get_pred_or_func_ctors(ModuleInfo, _SymName, Arity,
PredId) = ResolvedCtor :-
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
+ PredModule = pred_info_module(PredInfo),
+ PredArity = pred_info_arity(PredInfo),
pred_info_get_exist_quant_tvars(PredInfo, PredExistQVars),
- pred_info_arity(PredInfo, PredArity),
adjust_func_arity(PredOrFunc, OrigArity, PredArity),
(
PredOrFunc = predicate,
@@ -812,7 +813,6 @@
; OrigArity = Arity
)
),
- pred_info_module(PredInfo, PredModule),
ResolvedCtor = pred_or_func(PredId, PredModule, PredOrFunc, OrigArity).
%-----------------------------------------------------------------------------%
Index: compiler/rl.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl.m,v
retrieving revision 1.24
diff -u -b -r1.24 rl.m
--- compiler/rl.m 20 Oct 2003 07:29:11 -0000 1.24
+++ compiler/rl.m 21 Oct 2003 09:30:49 -0000
@@ -1070,8 +1070,8 @@
rl__get_entry_proc_name(ModuleInfo, PredProcId, ProcName) :-
PredProcId = proc(PredId, _),
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, Arity),
+ PredName = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo),
rl__get_entry_proc_name(ModuleInfo, PredProcId,
PredInfo, PredName, Arity, ProcName).
@@ -1082,8 +1082,8 @@
ProcName) :-
PredProcId = proc(_, ProcId),
module_info_name(ModuleInfo, ModuleName),
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
- pred_info_module(PredInfo, PredModule),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
+ PredModule = pred_info_module(PredInfo),
pred_info_get_aditi_owner(PredInfo, Owner),
IsImported = (pred_info_is_imported(PredInfo) -> yes ; no),
ProcLabel = make_user_proc_label(ModuleName, IsImported,
@@ -1108,7 +1108,7 @@
pred_id::in, string::in, rl_proc_name::out) is det.
rl__get_update_proc_name(ModuleInfo, PredId, ProcNamePrefix, ProcName) :-
- hlds_pred__initial_proc_id(ProcId),
+ ProcId = hlds_pred__initial_proc_id,
rl__get_entry_proc_name(ModuleInfo, proc(PredId, ProcId), ProcName0),
ProcName0 = rl_proc_name(Owner, Module, Name0, Arity),
string__append(ProcNamePrefix, Name0, Name),
@@ -1117,7 +1117,7 @@
rl__get_c_interface_proc_name(ModuleInfo, PredProcId, PredName) :-
PredProcId = proc(PredId, ProcId),
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_name(PredInfo, PredName0),
+ PredName0 = pred_info_name(PredInfo),
proc_id_to_int(ProcId, ProcInt),
string__int_to_string(ProcInt, ProcStr),
pred_info_arg_types(PredInfo, ArgTypes),
@@ -1151,11 +1151,11 @@
rl__get_permanent_relation_info(ModuleInfo, PredId, Owner, PredModule,
PredName, PredArity, RelName, SchemaString) :-
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_name(PredInfo, PredName),
- pred_info_module(PredInfo, PredModule0),
+ PredName = pred_info_name(PredInfo),
+ PredModule0 = pred_info_module(PredInfo),
prog_out__sym_name_to_string(PredModule0, PredModule),
pred_info_get_aditi_owner(PredInfo, Owner),
- pred_info_arity(PredInfo, PredArity),
+ PredArity = pred_info_arity(PredInfo),
string__format("%s__%i", [s(PredName), i(PredArity)], RelName),
pred_info_arg_types(PredInfo, ArgTypes0),
type_util__remove_aditi_state(ArgTypes0, ArgTypes0, ArgTypes),
Index: compiler/rl_dump.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl_dump.m,v
retrieving revision 1.9
diff -u -b -r1.9 rl_dump.m
--- compiler/rl_dump.m 15 Mar 2003 03:09:08 -0000 1.9
+++ compiler/rl_dump.m 21 Oct 2003 09:30:49 -0000
@@ -44,7 +44,7 @@
lambda([PredProcId::in, IO0::di, IO::uo] is det, (
PredProcId = proc(PredId, _ProcId),
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_name(PredInfo, PredName),
+ PredName = pred_info_name(PredInfo),
io__write_string("%\t", IO0, IO1),
io__write_string(PredName, IO1, IO2),
io__nl(IO2, IO)
@@ -87,8 +87,8 @@
{ RelType = permanent(proc(PredId, _)) },
io__write_string("base relation `"),
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_name(PredInfo, PredName) },
- { pred_info_arity(PredInfo, PredArity) },
+ { PredName = pred_info_name(PredInfo) },
+ { PredArity = pred_info_arity(PredInfo) },
io__write_string(PredName),
io__write_string("'/"),
io__write_int(PredArity)
Index: compiler/rl_exprn.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl_exprn.m,v
retrieving revision 1.33
diff -u -b -r1.33 rl_exprn.m
--- compiler/rl_exprn.m 24 Jun 2003 14:20:51 -0000 1.33
+++ compiler/rl_exprn.m 21 Oct 2003 09:30:49 -0000
@@ -956,7 +956,7 @@
\+ {
% `index/2' doesn't work in Aditi.
is_unify_or_compare_pred(PredInfo),
- \+ pred_info_name(PredInfo, "__Index__")
+ \+ (pred_info_name(PredInfo) = "__Index__")
},
{ \+ pred_info_is_builtin(PredInfo) },
{ \+ rl_exprn__is_simple_extra_aditi_builtin(PredInfo,
@@ -1547,8 +1547,8 @@
rl_exprn__generate_builtin_call(_PredId, ProcId,
PredInfo, Args, Fail, Code) -->
- { pred_info_module(PredInfo, PredModule0) },
- { pred_info_name(PredInfo, PredName) },
+ { PredModule0 = pred_info_module(PredInfo) },
+ { PredName = pred_info_name(PredInfo) },
%
% Generate LLDS for the builtin, then convert that to Aditi bytecode.
@@ -1582,7 +1582,7 @@
)
;
{ prog_out__sym_name_to_string(PredModule0, PredModule) },
- { pred_info_arity(PredInfo, Arity) },
+ { Arity = pred_info_arity(PredInfo) },
{ string__format("Sorry, not implemented in Aditi: %s.%s/%i",
[s(PredModule), s(PredName), i(Arity)], Msg) },
{ error(Msg) }
@@ -1701,11 +1701,11 @@
bytecode::out) is semidet.
rl_exprn__is_simple_extra_aditi_builtin(PredInfo, ProcId, Bytecode) :-
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
- pred_info_module(PredInfo, PredModule),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
+ PredModule = pred_info_module(PredInfo),
PredModule = unqualified(PredModuleName),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, PredArity0),
+ PredName = pred_info_name(PredInfo),
+ PredArity0 = pred_info_arity(PredInfo),
hlds_pred__proc_id_to_int(ProcId, ProcInt),
adjust_func_arity(PredOrFunc, PredArity, PredArity0),
rl_exprn__simple_extra_builtin(PredOrFunc, PredModuleName,
Index: compiler/rl_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl_gen.m,v
retrieving revision 1.12
diff -u -b -r1.12 rl_gen.m
--- compiler/rl_gen.m 19 Sep 2003 11:10:04 -0000 1.12
+++ compiler/rl_gen.m 21 Oct 2003 14:43:21 -0000
@@ -234,7 +234,7 @@
EntryPoint = proc(PredId, _ProcId),
module_info_pred_info(ModuleInfo,
PredId, PredInfo),
- pred_info_name(PredInfo, PredName),
+ PredName = pred_info_name(PredInfo),
string__format("%s%s %s %i",
[s("rl_gen__scc_list_input_args - "),
s("non higher-order input argument "),
@@ -394,8 +394,8 @@
add_pred_name_and_arity([proc(PredId, _) | PredProcIds], S0, S) -->
rl_info_get_module_info(ModuleInfo),
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_name(PredInfo, PredName) },
- { pred_info_arity(PredInfo, PredArity) },
+ { PredName = pred_info_name(PredInfo) },
+ { PredArity = pred_info_arity(PredInfo) },
{ string__int_to_string(PredArity, PredArityStr) },
{ string__append_list([PredName, "/", PredArityStr, " ", S0], S1) },
add_pred_name_and_arity(PredProcIds, S1, S).
@@ -750,8 +750,8 @@
{ PredProcId = proc(PredId, ProcId) },
{ module_info_pred_proc_info(ModuleInfo, PredId, ProcId,
PredInfo, ProcInfo) },
- { pred_info_name(PredInfo, PredName) },
- { pred_info_arity(PredInfo, PredArity) },
+ { PredName = pred_info_name(PredInfo) },
+ { PredArity = pred_info_arity(PredInfo) },
rl_info_write_message("Generating RL for `%s'/%i\n",
[s(PredName), i(PredArity)]),
{ proc_info_headvars(ProcInfo, HeadVars) },
@@ -1524,10 +1524,10 @@
{ CalledProc = proc(PredId, _) },
rl_info_get_module_info(ModuleInfo),
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_module(PredInfo, Module0) },
+ { Module0 = pred_info_module(PredInfo) },
{ prog_out__sym_name_to_string(Module0, Module) },
- { pred_info_name(PredInfo, Name) },
- { pred_info_arity(PredInfo, Arity) },
+ { Name = pred_info_name(PredInfo) },
+ { Arity = pred_info_arity(PredInfo) },
rl_info_write_message("Generating call to %s.%s/%i\n",
[s(Module), s(Name), i(Arity)]),
(
@@ -1651,8 +1651,8 @@
{ list__length(CurriedArgs, NumCurriedArgs) },
{ list__drop(NumCurriedArgs, Types, OutputArgTypes1) ->
OutputArgTypes = OutputArgTypes1,
- proc_info_create_vars_from_types(ProcInfo0,
- OutputArgTypes, OutputArgs, ProcInfo)
+ proc_info_create_vars_from_types(OutputArgTypes, OutputArgs,
+ ProcInfo0, ProcInfo)
;
error("rl_gen__lower_scc_call_input: list__drop failed")
},
@@ -1709,10 +1709,10 @@
{ inlining__do_inline_call(UnivQTVars, Args, CalledPredInfo,
CalledProcInfo, VarSet0, VarSet, VarTypes0, VarTypes,
TypeVarSet0, TypeVarSet, TVarMap0, TVarMap, Goal) },
- { proc_info_set_varset(ProcInfo0, VarSet, ProcInfo1) },
- { proc_info_set_vartypes(ProcInfo1, VarTypes, ProcInfo2) },
- { proc_info_set_typeinfo_varmap(ProcInfo2, TVarMap, ProcInfo) },
- { pred_info_set_typevarset(PredInfo0, TypeVarSet, PredInfo) },
+ { proc_info_set_varset(VarSet, ProcInfo0, ProcInfo1) },
+ { proc_info_set_vartypes(VarTypes, ProcInfo1, ProcInfo2) },
+ { proc_info_set_typeinfo_varmap(TVarMap, ProcInfo2, ProcInfo) },
+ { pred_info_set_typevarset(TypeVarSet, PredInfo0, PredInfo) },
rl_info_set_pred_info(PredInfo),
rl_info_set_proc_info(ProcInfo).
Index: compiler/rl_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl_info.m,v
retrieving revision 1.5
diff -u -b -r1.5 rl_info.m
--- compiler/rl_info.m 26 May 2003 09:00:08 -0000 1.5
+++ compiler/rl_info.m 21 Oct 2003 10:22:49 -0000
@@ -302,8 +302,8 @@
map__init(VarRels),
map__init(VarStat),
set__init(DelayedDiffs),
- invalid_pred_id(PredId),
- invalid_proc_id(ProcId),
+ PredId = invalid_pred_id,
+ ProcId = invalid_proc_id,
RLInfo = rl_info(IO, ModuleInfo, no, no, [], RelMap, RelInfo,
unit, VarRels, [], 0, 0, 0, proc(PredId, ProcId),
[], VarStat, DelayedDiffs, no, []).
@@ -499,10 +499,10 @@
% Get a (sort of) human readable version of the relation name.
{ proc_relation_type_to_str(ProcRelType, ProcRelStr) },
- { pred_info_module(PredInfo, PredModule0) },
+ { PredModule0 = pred_info_module(PredInfo) },
{ prog_out__sym_name_to_string(PredModule0, PredModule) },
- { pred_info_name(PredInfo, PredName) },
- { pred_info_arity(PredInfo, Arity) },
+ { PredName = pred_info_name(PredInfo) },
+ { Arity = pred_info_arity(PredInfo) },
rl_info_get_next_relation_id(RelationId),
{ string__format("%s-%s.%s/%i-%i",
[s(ProcRelStr), s(PredModule), s(PredName),
@@ -635,8 +635,8 @@
rl_info__comment(Comment) -->
rl_info_get_pred_info(PredInfo),
rl_info_get_rule_number(RuleNo),
- { pred_info_name(PredInfo, PredName) },
- { string__format("%s rule %i", [s(PredName), i(RuleNo)], Comment) }.
+ { string__format("%s rule %i",
+ [s(pred_info_name(PredInfo)), i(RuleNo)], Comment) }.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
Index: compiler/rl_key.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl_key.m,v
retrieving revision 1.15
diff -u -b -r1.15 rl_key.m
--- compiler/rl_key.m 20 Oct 2003 07:29:11 -0000 1.15
+++ compiler/rl_key.m 21 Oct 2003 10:23:05 -0000
@@ -677,8 +677,8 @@
rl_key__extract_key_range_call(PredId, ProcId, Args) -->
key_info_get_module_info(ModuleInfo),
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_module(PredInfo, PredModule) },
- { pred_info_name(PredInfo, PredName) },
+ { PredModule = pred_info_module(PredInfo) },
+ { PredName = pred_info_name(PredInfo) },
{ list__length(Args, Arity) },
{ pred_info_get_maybe_special_pred(PredInfo, MaybeSpecial) },
(
Index: compiler/rl_out.pp
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rl_out.pp,v
retrieving revision 1.21
diff -u -b -r1.21 rl_out.pp
--- compiler/rl_out.pp 26 May 2003 09:00:08 -0000 1.21
+++ compiler/rl_out.pp 24 Oct 2003 05:07:20 -0000
@@ -112,7 +112,7 @@
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
{ pred_info_get_markers(PredInfo, Markers) },
{ module_info_name(ModuleInfo, Module) },
- { pred_info_module(PredInfo, PredModule) },
+ { PredModule = pred_info_module(PredInfo) },
(
{ Module = PredModule },
{ check_marker(Markers, base_relation) }
@@ -145,10 +145,10 @@
{ Outputs = [OutputRel] }
->
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
- { pred_info_module(PredInfo, PredModule0) },
+ { PredModule0 = pred_info_module(PredInfo) },
{ prog_out__sym_name_to_string(PredModule0, PredModule) },
- { pred_info_name(PredInfo, PredName) },
- { pred_info_arity(PredInfo, PredArity0) },
+ { PredName = pred_info_name(PredInfo) },
+ { PredArity0 = pred_info_arity(PredInfo) },
{ string__int_to_string(PredArity0, PredArity) },
{ rl_out__get_proc_schema(ModuleInfo, RelInfo,
[InputRel, OutputRel], SchemaString) },
@@ -386,7 +386,7 @@
rl_out_info_get_module_info(ModuleInfo),
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
{ module_info_name(ModuleInfo, ModuleName) },
- { pred_info_module(PredInfo, PredModule) },
+ { PredModule = pred_info_module(PredInfo) },
(
{ ModuleName = PredModule },
{ hlds_pred__pred_info_is_base_relation(PredInfo) }
Index: compiler/rtti.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rtti.m,v
retrieving revision 1.35
diff -u -b -r1.35 rtti.m
--- compiler/rtti.m 23 Oct 2003 02:02:09 -0000 1.35
+++ compiler/rtti.m 23 Oct 2003 02:12:04 -0000
@@ -927,10 +927,10 @@
module_info_name(ModuleInfo, ThisModule),
module_info_pred_proc_info(ModuleInfo, PredId, ProcId,
PredInfo, ProcInfo),
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
- pred_info_module(PredInfo, PredModule),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, Arity),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
+ PredModule = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo),
pred_info_arg_types(PredInfo, ArgTypes),
proc_info_varset(ProcInfo, ProcVarSet),
proc_info_headvars(ProcInfo, ProcHeadVars),
Index: compiler/saved_vars.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/saved_vars.m,v
retrieving revision 1.36
diff -u -b -r1.36 saved_vars.m
--- compiler/saved_vars.m 15 May 2003 03:44:57 -0000 1.36
+++ compiler/saved_vars.m 21 Oct 2003 14:01:50 -0000
@@ -61,32 +61,32 @@
{ saved_vars_proc_no_io(ProcInfo0, ProcInfo,
ModuleInfo0, ModuleInfo) }.
-saved_vars_proc_no_io(ProcInfo0, ProcInfo, ModuleInfo0, ModuleInfo) :-
- proc_info_goal(ProcInfo0, Goal0),
- proc_info_varset(ProcInfo0, Varset0),
- proc_info_vartypes(ProcInfo0, VarTypes0),
+saved_vars_proc_no_io(!ProcInfo, !ModuleInfo) :-
+ proc_info_goal(!.ProcInfo, Goal0),
+ proc_info_varset(!.ProcInfo, Varset0),
+ proc_info_vartypes(!.ProcInfo, VarTypes0),
init_slot_info(Varset0, VarTypes0, SlotInfo0),
saved_vars_in_goal(Goal0, SlotInfo0, Goal1, SlotInfo),
final_slot_info(Varset1, VarTypes1, SlotInfo),
- proc_info_headvars(ProcInfo0, HeadVars),
+ proc_info_headvars(!.ProcInfo, HeadVars),
- % hlds_out__write_goal(Goal1, ModuleInfo, Varset1, 0, "\n"),
+ % hlds_out__write_goal(Goal1, !.ModuleInfo, Varset1, 0, "\n"),
% recompute the nonlocals for each goal
- implicitly_quantify_clause_body(HeadVars, Goal1, Varset1,
- VarTypes1, Goal2, Varset, VarTypes, _Warnings),
- proc_info_get_initial_instmap(ProcInfo0, ModuleInfo0, InstMap0),
- proc_info_inst_varset(ProcInfo0, InstVarSet),
- recompute_instmap_delta(no, Goal2, Goal, VarTypes, InstVarSet, InstMap0,
- ModuleInfo0, ModuleInfo),
-
- % hlds_out__write_goal(Goal, ModuleInfo, Varset, 0, "\n"),
-
- proc_info_set_goal(ProcInfo0, Goal, ProcInfo1),
- proc_info_set_varset(ProcInfo1, Varset, ProcInfo2),
- proc_info_set_vartypes(ProcInfo2, VarTypes, ProcInfo).
+ implicitly_quantify_clause_body(HeadVars, _Warnings, Goal1, Goal2,
+ Varset1, Varset, VarTypes1, VarTypes),
+ proc_info_get_initial_instmap(!.ProcInfo, !.ModuleInfo, InstMap0),
+ proc_info_inst_varset(!.ProcInfo, InstVarSet),
+ recompute_instmap_delta(no, Goal2, Goal, VarTypes,
+ InstVarSet, InstMap0, !ModuleInfo),
+
+ % hlds_out__write_goal(Goal, !.ModuleInfo, Varset, 0, "\n"),
+
+ proc_info_set_goal(Goal, !ProcInfo),
+ proc_info_set_varset(Varset, !ProcInfo),
+ proc_info_set_vartypes(VarTypes, !ProcInfo).
%-----------------------------------------------------------------------------%
Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.121
diff -u -b -r1.121 simplify.m
--- compiler/simplify.m 21 Oct 2003 00:49:24 -0000 1.121
+++ compiler/simplify.m 21 Oct 2003 14:37:32 -0000
@@ -113,7 +113,7 @@
simplify__pred(Simplifications0, PredId, ModuleInfo0, ModuleInfo,
PredInfo0, PredInfo, WarnCnt, ErrCnt) -->
write_pred_progress_message("% Simplifying ", PredId, ModuleInfo0),
- { pred_info_non_imported_procids(PredInfo0, ProcIds) },
+ { ProcIds = pred_info_non_imported_procids(PredInfo0) },
{ MaybeMsgs0 = no },
{
% Don't warn for compiler-generated procedures.
@@ -142,50 +142,49 @@
:- mode simplify__procs(in, in, in, in, out, in, out,
in, out) is det.
-simplify__procs(_, _, [], ModuleInfo, ModuleInfo, PredInfo, PredInfo,
- Msgs, Msgs).
-simplify__procs(Simplifications, PredId, [ProcId | ProcIds], ModuleInfo0,
- ModuleInfo, PredInfo0, PredInfo, MaybeMsgs0, MaybeMsgs) :-
- pred_info_procedures(PredInfo0, Procs0),
+simplify__procs(_, _, [], !ModuleInfo, !PredInfo, !Msgs).
+simplify__procs(Simplifications, PredId, [ProcId | ProcIds], !ModuleInfo,
+ !PredInfo, !MaybeMsgs) :-
+ pred_info_procedures(!.PredInfo, Procs0),
map__lookup(Procs0, ProcId, Proc0),
- simplify__proc_2(Simplifications, PredId, ProcId, ModuleInfo0,
- ModuleInfo1, Proc0, Proc, Msgs1),
+ simplify__proc_2(Simplifications, PredId, ProcId, !ModuleInfo,
+ Proc0, Proc, Msgs1),
map__det_update(Procs0, ProcId, Proc, Procs),
- pred_info_set_procedures(PredInfo0, Procs, PredInfo1),
+ pred_info_set_procedures(Procs, !PredInfo),
set__to_sorted_list(Msgs1, Msgs2),
list__filter(lambda([Msg::in] is semidet,
det_msg_is_any_mode_msg(Msg, any_mode)),
Msgs2, AnyModeMsgs1, AllModeMsgs1),
set__sorted_list_to_set(AnyModeMsgs1, AnyModeMsgs2),
set__sorted_list_to_set(AllModeMsgs1, AllModeMsgs2),
- ( MaybeMsgs0 = yes(AnyModeMsgs0 - AllModeMsgs0) ->
+ ( !.MaybeMsgs = yes(AnyModeMsgs0 - AllModeMsgs0) ->
set__union(AnyModeMsgs0, AnyModeMsgs2, AnyModeMsgs),
set__intersect(AllModeMsgs0, AllModeMsgs2, AllModeMsgs),
- MaybeMsgs1 = yes(AllModeMsgs - AnyModeMsgs)
+ !:MaybeMsgs = yes(AllModeMsgs - AnyModeMsgs)
;
- MaybeMsgs1 = yes(AnyModeMsgs2 - AllModeMsgs2)
+ !:MaybeMsgs = yes(AnyModeMsgs2 - AllModeMsgs2)
),
- simplify__procs(Simplifications, PredId, ProcIds, ModuleInfo1,
- ModuleInfo, PredInfo1, PredInfo, MaybeMsgs1, MaybeMsgs).
+ simplify__procs(Simplifications, PredId, ProcIds, !ModuleInfo,
+ !PredInfo, !MaybeMsgs).
-simplify__proc(Simplifications, PredId, ProcId, ModuleInfo0, ModuleInfo,
- Proc0, Proc) -->
- write_pred_progress_message("% Simplifying ", PredId, ModuleInfo0),
- { simplify__proc_2(Simplifications, PredId, ProcId, ModuleInfo0,
- ModuleInfo, Proc0, Proc, _) }.
-
-simplify__proc_2(Simplifications, PredId, ProcId, ModuleInfo0, ModuleInfo,
- ProcInfo0, ProcInfo, Msgs) :-
- module_info_globals(ModuleInfo0, Globals),
- proc_info_vartypes(ProcInfo0, VarTypes0),
- det_info_init(ModuleInfo0, VarTypes0, PredId, ProcId, Globals,
+simplify__proc(Simplifications, PredId, ProcId, !ModuleInfo, !Proc, !IO) :-
+ write_pred_progress_message("% Simplifying ", PredId, !.ModuleInfo,
+ !IO),
+ simplify__proc_2(Simplifications, PredId, ProcId, !ModuleInfo,
+ !Proc, _).
+
+simplify__proc_2(Simplifications, PredId, ProcId, !ModuleInfo, !ProcInfo,
+ Msgs) :-
+ module_info_globals(!.ModuleInfo, Globals),
+ proc_info_vartypes(!.ProcInfo, VarTypes0),
+ det_info_init(!.ModuleInfo, VarTypes0, PredId, ProcId, Globals,
DetInfo0),
- proc_info_get_initial_instmap(ProcInfo0, ModuleInfo0, InstMap0),
- proc_info_varset(ProcInfo0, VarSet0),
- proc_info_inst_varset(ProcInfo0, InstVarSet0),
- proc_info_typeinfo_varmap(ProcInfo0, TVarMap0),
- proc_info_typeclass_info_varmap(ProcInfo0, TCVarMap0),
- proc_info_goal(ProcInfo0, Goal0),
+ proc_info_get_initial_instmap(!.ProcInfo, !.ModuleInfo, InstMap0),
+ proc_info_varset(!.ProcInfo, VarSet0),
+ proc_info_inst_varset(!.ProcInfo, InstVarSet0),
+ proc_info_typeinfo_varmap(!.ProcInfo, TVarMap0),
+ proc_info_typeclass_info_varmap(!.ProcInfo, TCVarMap0),
+ proc_info_goal(!.ProcInfo, Goal0),
simplify_info_init(DetInfo0, Simplifications, InstMap0,
VarSet0, InstVarSet0, TVarMap0, TCVarMap0, Info0),
@@ -195,12 +194,12 @@
simplify_info_get_var_types(Info, VarTypes),
simplify_info_get_type_info_varmap(Info, TVarMap),
simplify_info_get_typeclass_info_varmap(Info, TCVarMap),
- proc_info_set_varset(ProcInfo0, VarSet, ProcInfo1),
- proc_info_set_vartypes(ProcInfo1, VarTypes, ProcInfo2),
- proc_info_set_goal(ProcInfo2, Goal, ProcInfo3),
- proc_info_set_typeinfo_varmap(ProcInfo3, TVarMap, ProcInfo4),
- proc_info_set_typeclass_info_varmap(ProcInfo4, TCVarMap, ProcInfo),
- simplify_info_get_module_info(Info, ModuleInfo),
+ proc_info_set_varset(VarSet, !ProcInfo),
+ proc_info_set_vartypes(VarTypes, !ProcInfo),
+ proc_info_set_goal(Goal, !ProcInfo),
+ proc_info_set_typeinfo_varmap(TVarMap, !ProcInfo),
+ proc_info_set_typeclass_info_varmap(TCVarMap, !ProcInfo),
+ simplify_info_get_module_info(Info, !:ModuleInfo),
simplify_info_get_msgs(Info, Msgs).
simplify__process_goal(Goal0, Goal, Info0, Info) :-
@@ -242,8 +241,8 @@
( simplify_info_requantify(Info1) ->
Goal1 = _ - GoalInfo1,
goal_info_get_nonlocals(GoalInfo1, NonLocals),
- implicitly_quantify_goal(Goal1, VarSet0, VarTypes0,
- NonLocals, Goal2, VarSet, VarTypes, _),
+ implicitly_quantify_goal(NonLocals, _, Goal1, Goal2,
+ VarSet0, VarSet, VarTypes0, VarTypes),
simplify_info_set_varset(Info1, VarSet, Info2),
simplify_info_set_var_types(Info2, VarTypes, Info3),
@@ -256,7 +255,7 @@
simplify_info_get_module_info(Info3, ModuleInfo3),
recompute_instmap_delta(RecomputeAtomic, Goal2, Goal3,
- VarTypes, Info3^inst_varset, InstMap0, ModuleInfo3,
+ VarTypes, Info3 ^ inst_varset, InstMap0, ModuleInfo3,
ModuleInfo4),
simplify_info_set_module_info(Info3, ModuleInfo4, Info4)
;
@@ -279,8 +278,8 @@
det_info_get_proc_id(DetInfo4, ProcId),
module_info_pred_proc_info(ModuleInfo5, PredId, ProcId,
PredInfo, ProcInfo0),
- proc_info_set_vartypes(ProcInfo0, VarTypes4, ProcInfo1),
- proc_info_set_varset(ProcInfo1, VarSet4, ProcInfo),
+ proc_info_set_vartypes(VarTypes4, ProcInfo0, ProcInfo1),
+ proc_info_set_varset(VarSet4, ProcInfo1, ProcInfo),
module_info_set_pred_proc_info(ModuleInfo5, PredId, ProcId,
PredInfo, ProcInfo, ModuleInfo6),
simplify_info_set_module_info(Info4, ModuleInfo6, Info),
@@ -771,9 +770,9 @@
%
(
Args = [TI, X, Y],
- prog_util__mercury_public_builtin_module(BuiltinModule),
- hlds_pred__pred_info_module(PredInfo, BuiltinModule),
- hlds_pred__pred_info_name(PredInfo, Name),
+ mercury_public_builtin_module =
+ hlds_pred__pred_info_module(PredInfo),
+ Name = hlds_pred__pred_info_name(PredInfo),
( Name = "@<", Inequality = "<", Invert = no
; Name = "@=<", Inequality = ">", Invert = yes
; Name = "@>=", Inequality = "<", Invert = yes
@@ -1501,8 +1500,8 @@
module_info_get_special_pred_map(ModuleInfo, SpecialPredMap),
map__lookup(SpecialPredMap, unify - TypeCtor, PredId),
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_module(PredInfo, ModuleName),
- pred_info_name(PredInfo, PredName),
+ ModuleName = pred_info_module(PredInfo),
+ PredName = pred_info_name(PredInfo),
SymName = qualified(ModuleName, PredName),
CallContext = call_unify_context(XVar, var(YVar), Context),
CallExpr = call(PredId, ProcId, ArgVars, not_builtin,
@@ -1534,8 +1533,8 @@
%
module_info_pred_proc_info(ModuleInfo0, PredId, ProcId,
PredInfo0, ProcInfo0),
- proc_info_set_vartypes(ProcInfo0, VarTypes0, ProcInfo1),
- proc_info_set_varset(ProcInfo1, VarSet0, ProcInfo2),
+ proc_info_set_vartypes(VarTypes0, ProcInfo0, ProcInfo1),
+ proc_info_set_varset(VarSet0, ProcInfo1, ProcInfo2),
%
% Call polymorphism.m to create the type_infos
Index: compiler/size_prof.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/size_prof.m,v
retrieving revision 1.2
diff -u -b -r1.2 size_prof.m
--- compiler/size_prof.m 22 Oct 2003 07:05:17 -0000 1.2
+++ compiler/size_prof.m 23 Oct 2003 01:30:57 -0000
@@ -248,14 +248,13 @@
% the nonlocal vars and the non-atomic instmap deltas.
proc_info_headvars(!.ProcInfo, HeadVars),
proc_info_inst_varset(!.ProcInfo, InstVarSet),
- implicitly_quantify_clause_body(HeadVars,
- Goal1, Info ^ varset, Info ^ vartypes,
- Goal2, VarSet, VarTypes, _Warnings),
+ implicitly_quantify_clause_body(HeadVars, _Warnings, Goal1, Goal2,
+ Info ^ varset, VarSet, Info ^ vartypes, VarTypes),
recompute_instmap_delta(no, Goal2, Goal, VarTypes, InstVarSet,
InstMap0, !ModuleInfo),
- proc_info_set_goal(!.ProcInfo, Goal, !:ProcInfo),
- proc_info_set_varset(!.ProcInfo, VarSet, !:ProcInfo),
- proc_info_set_vartypes(!.ProcInfo, VarTypes, !:ProcInfo).
+ proc_info_set_goal(Goal, !ProcInfo),
+ proc_info_set_varset(VarSet, !ProcInfo),
+ proc_info_set_vartypes(VarTypes, !ProcInfo).
:- pred process_goal(hlds_goal::in, hlds_goal::out, info::in, info::out)
is det.
Index: compiler/stack_alloc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/stack_alloc.m,v
retrieving revision 1.4
diff -u -b -r1.4 stack_alloc.m
--- compiler/stack_alloc.m 22 May 2003 05:54:38 -0000 1.4
+++ compiler/stack_alloc.m 21 Oct 2003 14:05:56 -0000
@@ -58,36 +58,35 @@
%-----------------------------------------------------------------------------%
-allocate_stack_slots_in_proc(PredId, _ProcId, ModuleInfo, ProcInfo0, ProcInfo,
- IO, IO) :-
- initial_liveness(ProcInfo0, PredId, ModuleInfo, Liveness0),
+allocate_stack_slots_in_proc(PredId, _ProcId, ModuleInfo, !ProcInfo, !IO) :-
+ initial_liveness(!.ProcInfo, PredId, ModuleInfo, Liveness0),
module_info_pred_info(ModuleInfo, PredId, PredInfo),
module_info_globals(ModuleInfo, Globals),
globals__get_trace_level(Globals, TraceLevel),
(
- eff_trace_level_needs_input_vars(PredInfo, ProcInfo0,
+ eff_trace_level_needs_input_vars(PredInfo, !.ProcInfo,
TraceLevel) = yes
->
- trace__fail_vars(ModuleInfo, ProcInfo0, FailVars)
+ trace__fail_vars(ModuleInfo, !.ProcInfo, FailVars)
;
set__init(FailVars)
),
body_should_use_typeinfo_liveness(PredInfo, Globals, TypeInfoLiveness),
globals__lookup_bool_option(Globals, opt_no_return_calls,
OptNoReturnCalls),
- AllocData = alloc_data(ModuleInfo, ProcInfo0, TypeInfoLiveness,
+ AllocData = alloc_data(ModuleInfo, !.ProcInfo, TypeInfoLiveness,
OptNoReturnCalls),
set__init(NondetLiveness0),
SimpleStackAlloc0 = stack_alloc(set__make_singleton_set(FailVars)),
- proc_info_goal(ProcInfo0, Goal0),
+ proc_info_goal(!.ProcInfo, Goal0),
build_live_sets_in_goal(Goal0, Goal, FailVars, AllocData,
SimpleStackAlloc0, SimpleStackAlloc, Liveness0, _Liveness,
NondetLiveness0, _NondetLiveness),
- proc_info_set_goal(ProcInfo0, Goal, ProcInfo3),
+ proc_info_set_goal(Goal, !ProcInfo),
SimpleStackAlloc = stack_alloc(LiveSets0),
- trace__do_we_need_maxfr_slot(Globals, PredInfo, ProcInfo3, ProcInfo4),
- trace__reserved_slots(ModuleInfo, PredInfo, ProcInfo4, Globals,
+ trace__do_we_need_maxfr_slot(Globals, PredInfo, !ProcInfo),
+ trace__reserved_slots(ModuleInfo, PredInfo, !.ProcInfo, Globals,
NumReservedSlots, MaybeReservedVarInfo),
(
MaybeReservedVarInfo = yes(ResVar - _),
@@ -99,11 +98,10 @@
),
graph_colour__group_elements(LiveSets, ColourSets),
set__to_sorted_list(ColourSets, ColourList),
- proc_info_interface_code_model(ProcInfo4, CodeModel),
+ proc_info_interface_code_model(!.ProcInfo, CodeModel),
allocate_stack_slots(ColourList, CodeModel, NumReservedSlots,
MaybeReservedVarInfo, StackSlots),
-
- proc_info_set_stack_slots(ProcInfo4, StackSlots, ProcInfo).
+ proc_info_set_stack_slots(StackSlots, !ProcInfo).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
Index: compiler/stack_opt.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/stack_opt.m,v
retrieving revision 1.9
diff -u -b -r1.9 stack_opt.m
--- compiler/stack_opt.m 25 Jul 2003 02:27:23 -0000 1.9
+++ compiler/stack_opt.m 21 Oct 2003 14:49:38 -0000
@@ -222,71 +222,67 @@
---> needs_flush
; doesnt_need_flush.
-stack_opt_cell(PredId, ProcId, ProcInfo0, ProcInfo, !ModuleInfo, !IO) :-
- detect_liveness_proc(PredId, ProcId, !.ModuleInfo,
- ProcInfo0, ProcInfo1, !IO),
- initial_liveness(ProcInfo1, PredId, !.ModuleInfo, Liveness0),
+stack_opt_cell(PredId, ProcId, !ProcInfo, !ModuleInfo, !IO) :-
+ detect_liveness_proc(PredId, ProcId, !.ModuleInfo, !ProcInfo, !IO),
+ initial_liveness(!.ProcInfo, PredId, !.ModuleInfo, Liveness0),
module_info_globals(!.ModuleInfo, Globals),
module_info_pred_info(!.ModuleInfo, PredId, PredInfo),
body_should_use_typeinfo_liveness(PredInfo, Globals, TypeInfoLiveness),
globals__lookup_bool_option(Globals, opt_no_return_calls,
OptNoReturnCalls),
- AllocData = alloc_data(!.ModuleInfo, ProcInfo1, TypeInfoLiveness,
+ AllocData = alloc_data(!.ModuleInfo, !.ProcInfo, TypeInfoLiveness,
OptNoReturnCalls),
- goal_path__fill_slots(ProcInfo1, !.ModuleInfo, ProcInfo2),
- proc_info_goal(ProcInfo2, Goal2),
+ goal_path__fill_slots(!.ModuleInfo, !ProcInfo),
+ proc_info_goal(!.ProcInfo, Goal2),
OptStackAlloc0 = init_opt_stack_alloc,
set__init(FailVars),
set__init(NondetLiveness0),
build_live_sets_in_goal(Goal2, Goal, FailVars, AllocData,
OptStackAlloc0, OptStackAlloc, Liveness0, _Liveness,
NondetLiveness0, _NondetLiveness),
- proc_info_set_goal(ProcInfo2, Goal, ProcInfo3),
- allocate_store_maps(for_stack_opt, ProcInfo3, PredId, !.ModuleInfo,
- ProcInfo4),
+ proc_info_set_goal(Goal, !ProcInfo),
+ allocate_store_maps(for_stack_opt, PredId, !.ModuleInfo, !ProcInfo),
globals__lookup_int_option(Globals, debug_stack_opt, DebugStackOpt),
pred_id_to_int(PredId, PredIdInt),
maybe_write_progress_message("\nbefore stack opt cell",
- DebugStackOpt, PredIdInt, ProcInfo4, !.ModuleInfo, !IO),
- optimize_live_sets(!.ModuleInfo, ProcInfo4, OptStackAlloc, ProcInfo5,
+ DebugStackOpt, PredIdInt, !.ProcInfo, !.ModuleInfo, !IO),
+ optimize_live_sets(!.ModuleInfo, OptStackAlloc, !ProcInfo,
Changed, DebugStackOpt, PredIdInt, !IO),
(
Changed = yes,
maybe_write_progress_message(
"\nafter stack opt transformation",
- DebugStackOpt, PredIdInt, ProcInfo5, !.ModuleInfo,
+ DebugStackOpt, PredIdInt, !.ProcInfo, !.ModuleInfo,
!IO),
- requantify_proc(ProcInfo5, ProcInfo6),
+ requantify_proc(!ProcInfo),
maybe_write_progress_message(
"\nafter stack opt requantify",
- DebugStackOpt, PredIdInt, ProcInfo6, !.ModuleInfo,
+ DebugStackOpt, PredIdInt, !.ProcInfo, !.ModuleInfo,
!IO),
- recompute_instmap_delta_proc(yes, ProcInfo6, ProcInfo,
- !ModuleInfo),
+ recompute_instmap_delta_proc(yes, !ProcInfo, !ModuleInfo),
maybe_write_progress_message(
"\nafter stack opt recompute instmaps",
- DebugStackOpt, PredIdInt, ProcInfo, !.ModuleInfo,
+ DebugStackOpt, PredIdInt, !.ProcInfo, !.ModuleInfo,
!IO)
;
- Changed = no,
- ProcInfo = ProcInfo0
+ Changed = no
).
:- func init_opt_stack_alloc = opt_stack_alloc.
init_opt_stack_alloc = opt_stack_alloc(set__init).
-:- pred optimize_live_sets(module_info::in, proc_info::in, opt_stack_alloc::in,
- proc_info::out, bool::out, int::in, int::in,
+:- pred optimize_live_sets(module_info::in, opt_stack_alloc::in,
+ proc_info::in, proc_info::out, bool::out, int::in, int::in,
io__state::di, io__state::uo) is det.
-optimize_live_sets(ModuleInfo, ProcInfo0, OptAlloc, ProcInfo, Changed,
- DebugStackOpt, PredIdInt, IO0, IO) :-
- proc_info_goal(ProcInfo0, Goal0),
- proc_info_vartypes(ProcInfo0, VarTypes0),
- proc_info_varset(ProcInfo0, VarSet0),
+optimize_live_sets(ModuleInfo, OptAlloc, !ProcInfo, Changed, DebugStackOpt,
+ PredIdInt, !IO) :-
+ proc_info_goal(!.ProcInfo, Goal0),
+ proc_info_vartypes(!.ProcInfo, VarTypes0),
+ proc_info_varset(!.ProcInfo, VarSet0),
OptAlloc = opt_stack_alloc(ParConjOwnSlot),
- arg_info__partition_proc_args(ProcInfo0, ModuleInfo,
+ arg_info__partition_proc_args(!.ProcInfo, ModuleInfo,
InputArgs, OutputArgs, UnusedArgs),
HeadVars = set__union_list([InputArgs, OutputArgs, UnusedArgs]),
module_info_globals(ModuleInfo, Globals),
@@ -345,13 +341,12 @@
SuccMap0, VarsMap0, map__init, []),
optimize_live_sets_in_goal(Goal0, OptInfo0, OptInfo),
( DebugStackOpt = PredIdInt ->
- dump_opt_info(OptInfo, IO0, IO)
+ dump_opt_info(OptInfo, !IO)
;
- IO = IO0
+ true
),
InsertMap = OptInfo ^ left_anchor_inserts,
( map__is_empty(InsertMap) ->
- ProcInfo = ProcInfo0,
Changed = no
;
VarInfo0 = var_info(VarSet0, VarTypes0),
@@ -359,9 +354,9 @@
map__init, RenameMap, InsertMap),
apply_headvar_correction(HeadVars, RenameMap, Goal1, Goal),
VarInfo = var_info(VarSet, VarTypes),
- proc_info_set_goal(ProcInfo0, Goal, ProcInfo1),
- proc_info_set_varset(ProcInfo1, VarSet, ProcInfo2),
- proc_info_set_vartypes(ProcInfo2, VarTypes, ProcInfo),
+ proc_info_set_goal(Goal, !ProcInfo),
+ proc_info_set_varset(VarSet, !ProcInfo),
+ proc_info_set_vartypes(VarTypes, !ProcInfo),
Changed = yes
).
Index: compiler/store_alloc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/store_alloc.m,v
retrieving revision 1.83
diff -u -b -r1.83 store_alloc.m
--- compiler/store_alloc.m 26 May 2003 09:00:09 -0000 1.83
+++ compiler/store_alloc.m 21 Oct 2003 14:08:08 -0000
@@ -33,8 +33,8 @@
---> final_allocation
; for_stack_opt.
-:- pred allocate_store_maps(store_map_run_type::in, proc_info::in, pred_id::in,
- module_info::in, proc_info::out) is det.
+:- pred allocate_store_maps(store_map_run_type::in, pred_id::in,
+ module_info::in, proc_info::in, proc_info::out) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -61,14 +61,14 @@
%-----------------------------------------------------------------------------%
-allocate_store_maps(RunType, ProcInfo0, PredId, ModuleInfo, ProcInfo) :-
+allocate_store_maps(RunType, PredId, ModuleInfo, !ProcInfo) :-
module_info_globals(ModuleInfo, Globals),
( RunType = final_allocation ->
- proc_info_goal(ProcInfo0, Goal0),
+ proc_info_goal(!.ProcInfo, Goal0),
- find_final_follow_vars(ProcInfo0,
+ find_final_follow_vars(!.ProcInfo,
FollowVarsMap0, NextNonReserved0),
- proc_info_vartypes(ProcInfo0, VarTypes),
+ proc_info_vartypes(!.ProcInfo, VarTypes),
find_follow_vars_in_goal(Goal0, VarTypes, ModuleInfo,
FollowVarsMap0, NextNonReserved0,
Goal1, FollowVarsMap, NextNonReserved),
@@ -78,23 +78,23 @@
GoalInfo2),
Goal2 = GoalExpr1 - GoalInfo2
;
- proc_info_goal(ProcInfo0, Goal2)
+ proc_info_goal(!.ProcInfo, Goal2)
),
- initial_liveness(ProcInfo0, PredId, ModuleInfo, Liveness0),
+ initial_liveness(!.ProcInfo, PredId, ModuleInfo, Liveness0),
globals__get_trace_level(Globals, TraceLevel),
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- ( eff_trace_level_is_none(PredInfo, ProcInfo0, TraceLevel) = no ->
- trace__fail_vars(ModuleInfo, ProcInfo0, ResumeVars0)
+ ( eff_trace_level_is_none(PredInfo, !.ProcInfo, TraceLevel) = no ->
+ trace__fail_vars(ModuleInfo, !.ProcInfo, ResumeVars0)
;
set__init(ResumeVars0)
),
- arg_info__build_input_arg_list(ProcInfo0, InputArgLvals),
+ arg_info__build_input_arg_list(!.ProcInfo, InputArgLvals),
LastLocns0 = initial_last_locns(InputArgLvals),
- proc_info_stack_slots(ProcInfo0, StackSlots),
+ proc_info_stack_slots(!.ProcInfo, StackSlots),
StoreAllocInfo = store_alloc_info(ModuleInfo, StackSlots),
store_alloc_in_goal(Goal2, Liveness0, ResumeVars0, LastLocns0,
StoreAllocInfo, Goal, _, _),
- proc_info_set_goal(ProcInfo0, Goal, ProcInfo).
+ proc_info_set_goal(Goal, !ProcInfo).
:- func initial_last_locns(assoc_list(prog_var, lval)) = last_locns.
Index: compiler/stratify.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/stratify.m,v
retrieving revision 1.30
diff -u -b -r1.30 stratify.m
--- compiler/stratify.m 20 Jun 2003 12:45:46 -0000 1.30
+++ compiler/stratify.m 21 Oct 2003 10:44:58 -0000
@@ -657,7 +657,7 @@
expand_predids([PredId|PredIds], Module, ProcCalls0, ProcCalls, HOInfo0,
HOInfo, CallsHO0, CallsHO) :-
module_info_pred_info(Module, PredId, PredInfo),
- pred_info_non_imported_procids(PredInfo, Procs),
+ Procs = pred_info_non_imported_procids(PredInfo),
pred_info_procedures(PredInfo, ProcTable),
pred_info_arg_types(PredInfo, ArgTypes),
process_procs(Procs, Module, PredId, ArgTypes, ProcTable, ProcCalls0,
Index: compiler/switch_detection.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/switch_detection.m,v
retrieving revision 1.100
diff -u -b -r1.100 switch_detection.m
--- compiler/switch_detection.m 15 Mar 2003 03:09:11 -0000 1.100
+++ compiler/switch_detection.m 21 Oct 2003 14:11:45 -0000
@@ -89,15 +89,15 @@
io__state, io__state).
:- mode detect_switches_in_pred(in, in, in, out, di, uo) is det.
-detect_switches_in_pred(PredId, PredInfo0, ModuleInfo0, ModuleInfo) -->
- { pred_info_non_imported_procids(PredInfo0, ProcIds) },
- ( { ProcIds \= [] } ->
+detect_switches_in_pred(PredId, PredInfo0, !ModuleInfo, !IO) :-
+ ProcIds = pred_info_non_imported_procids(PredInfo0),
+ ( ProcIds \= [] ->
write_pred_progress_message("% Detecting switches in ", PredId,
- ModuleInfo0)
+ !.ModuleInfo, !IO)
;
- []
+ true
),
- { detect_switches_in_procs(ProcIds, PredId, ModuleInfo0, ModuleInfo) }.
+ detect_switches_in_procs(ProcIds, PredId, !ModuleInfo).
:- pred detect_switches_in_procs(list(proc_id), pred_id,
module_info, module_info).
@@ -122,9 +122,9 @@
proc_info_get_initial_instmap(ProcInfo0, ModuleInfo0, InstMap0),
detect_switches_in_goal(Goal0, InstMap0, VarTypes, ModuleInfo0, Goal),
- proc_info_set_goal(ProcInfo0, Goal, ProcInfo),
+ proc_info_set_goal(Goal, ProcInfo0, ProcInfo),
map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable),
- pred_info_set_procedures(PredInfo0, ProcTable, PredInfo),
+ pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
map__det_update(PredTable0, PredId, PredInfo, PredTable),
module_info_set_preds(ModuleInfo0, PredTable, ModuleInfo).
Index: compiler/table_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/table_gen.m,v
retrieving revision 1.53
diff -u -b -r1.53 table_gen.m
--- compiler/table_gen.m 20 Oct 2003 07:29:11 -0000 1.53
+++ compiler/table_gen.m 21 Oct 2003 14:15:22 -0000
@@ -300,27 +300,24 @@
:- pred table_gen__process_pred(pred_id::in, module_info::in, module_info::out,
io__state::di, io__state::uo) is det.
-table_gen__process_pred(PredId, ModuleInfo0, ModuleInfo, S0, S) :-
- module_info_pred_info(ModuleInfo0, PredId, PredInfo),
- pred_info_procids(PredInfo, ProcIds),
- table_gen__process_procs(PredId, ProcIds, ModuleInfo0, ModuleInfo,
- S0, S).
+table_gen__process_pred(PredId, !ModuleInfo, !IO) :-
+ module_info_pred_info(!.ModuleInfo, PredId, PredInfo),
+ ProcIds = pred_info_procids(PredInfo),
+ table_gen__process_procs(PredId, ProcIds, !ModuleInfo, !IO).
:- pred table_gen__process_procs(pred_id::in, list(proc_id)::in,
module_info::in, module_info::out, io__state::di, io__state::uo)
is det.
-table_gen__process_procs(_PredId, [], ModuleInfo, ModuleInfo, S, S).
-table_gen__process_procs(PredId, [ProcId | ProcIds], ModuleInfo0, ModuleInfo,
- S0, S) :-
- module_info_preds(ModuleInfo0, PredTable),
+table_gen__process_procs(_PredId, [], !ModuleInfo, !IO).
+table_gen__process_procs(PredId, [ProcId | ProcIds], !ModuleInfo, !IO) :-
+ module_info_preds(!.ModuleInfo, PredTable),
map__lookup(PredTable, PredId, PredInfo),
pred_info_procedures(PredInfo, ProcTable),
map__lookup(ProcTable, ProcId, ProcInfo0),
table_gen__process_proc(PredId, ProcId, ProcInfo0, PredInfo,
- ModuleInfo0, ModuleInfo1, S0, S1),
- table_gen__process_procs(PredId, ProcIds, ModuleInfo1, ModuleInfo,
- S1, S).
+ !ModuleInfo, !IO),
+ table_gen__process_procs(PredId, ProcIds, !ModuleInfo, !IO).
:- pred table_gen__process_proc(pred_id::in, proc_id::in, proc_info::in,
pred_info::in, module_info::in, module_info::out, io__state::di,
@@ -383,8 +380,8 @@
Decl = table_io_proc
),
TableIoMethod = eval_table_io(Decl, Unitize),
- proc_info_set_eval_method(ProcInfo0, TableIoMethod,
- ProcInfo1),
+ proc_info_set_eval_method(TableIoMethod,
+ ProcInfo0, ProcInfo1),
table_gen__transform_proc(TableIoMethod,
PredId, ProcId, ProcInfo1, _, PredInfo0, _,
!ModuleInfo)
@@ -559,13 +556,11 @@
% set the new values of the fields in proc_info and pred_info
% and save in the module info
- proc_info_set_goal(!.ProcInfo, Goal, !:ProcInfo),
- proc_info_set_varset(!.ProcInfo, VarSet, !:ProcInfo),
- proc_info_set_vartypes(!.ProcInfo, VarTypes, !:ProcInfo),
- proc_info_set_call_table_tip(!.ProcInfo, MaybeCallTableTip,
- !:ProcInfo),
- proc_info_set_maybe_proc_table_info(!.ProcInfo, MaybeProcTableInfo,
- !:ProcInfo),
+ proc_info_set_goal(Goal, !ProcInfo),
+ proc_info_set_varset(VarSet, !ProcInfo),
+ proc_info_set_vartypes(VarTypes, !ProcInfo),
+ proc_info_set_call_table_tip(MaybeCallTableTip, !ProcInfo),
+ proc_info_set_maybe_proc_table_info(MaybeProcTableInfo, !ProcInfo),
% Some of the instmap_deltas generated in this module
% are pretty dodgy (especially those for if-then-elses), so
@@ -577,7 +572,7 @@
pred_info_procedures(!.PredInfo, ProcTable1),
map__det_update(ProcTable1, ProcId, !.ProcInfo, ProcTable),
- pred_info_set_procedures(!.PredInfo, ProcTable, !:PredInfo),
+ pred_info_set_procedures(ProcTable, !PredInfo),
%
% The transformation doesn't pay attention to the purity
@@ -1698,10 +1693,10 @@
ModuleInfo = TableInfo ^ table_module_info,
PredInfo = TableInfo ^ table_cur_pred_info,
- pred_info_module(PredInfo, Module),
- pred_info_name(PredInfo, Name),
- pred_info_arity(PredInfo, Arity),
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
+ Module = pred_info_module(PredInfo),
+ 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),
prog_out__sym_name_to_string(qualified(Module, Name), NameS),
string__int_to_string(Arity, ArityS),
@@ -1935,8 +1930,8 @@
% Put the varset and vartypes from the simplify_info
% back in the proc_info
%
- proc_info_set_vartypes(ProcInfo0, !.VarTypes, ProcInfo1),
- proc_info_set_varset(ProcInfo1, !.VarSet, ProcInfo2),
+ proc_info_set_vartypes(!.VarTypes, ProcInfo0, ProcInfo1),
+ proc_info_set_varset(!.VarSet, ProcInfo1, ProcInfo2),
%
% Call polymorphism.m to create the type_infos
Index: compiler/term_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/term_util.m,v
retrieving revision 1.30
diff -u -b -r1.30 term_util.m
--- compiler/term_util.m 22 Oct 2003 07:05:17 -0000 1.30
+++ compiler/term_util.m 23 Oct 2003 01:30:58 -0000
@@ -294,10 +294,10 @@
pred_info_procedures(PredInfo0, ProcTable0),
map__lookup(ProcTable0, ProcId, ProcInfo0),
- proc_info_set_maybe_arg_size_info(ProcInfo0, yes(ArgSize), ProcInfo),
+ proc_info_set_maybe_arg_size_info(yes(ArgSize), ProcInfo0, ProcInfo),
map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable),
- pred_info_set_procedures(PredInfo0, ProcTable, PredInfo),
+ pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
map__det_update(PredTable0, PredId, PredInfo, PredTable),
module_info_set_preds(Module0, PredTable, Module1),
set_pred_proc_ids_arg_size_info(PPIds, ArgSize, Module1, Module).
@@ -311,11 +311,11 @@
pred_info_procedures(PredInfo0, ProcTable0),
map__lookup(ProcTable0, ProcId, ProcInfo0),
- proc_info_set_maybe_termination_info(ProcInfo0, yes(Termination),
- ProcInfo),
+ proc_info_set_maybe_termination_info(yes(Termination),
+ ProcInfo0, ProcInfo),
map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable),
- pred_info_set_procedures(PredInfo0, ProcTable, PredInfo),
+ pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
map__det_update(PredTable0, PredId, PredInfo, PredTable),
module_info_set_preds(Module0, PredTable, Module1),
set_pred_proc_ids_termination_info(PPIds, Termination,
Index: compiler/termination.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/termination.m,v
retrieving revision 1.31
diff -u -b -r1.31 termination.m
--- compiler/termination.m 22 Oct 2003 07:05:17 -0000 1.31
+++ compiler/termination.m 23 Oct 2003 01:30:58 -0000
@@ -384,10 +384,10 @@
map__lookup(ProcTable, ProcId, ProcInfo),
map__lookup(OutputSupplierMap, PPId, OutputSuppliers),
ArgSizeInfo = finite(Gamma, OutputSuppliers),
- proc_info_set_maybe_arg_size_info(ProcInfo, yes(ArgSizeInfo),
- ProcInfo1),
+ proc_info_set_maybe_arg_size_info(yes(ArgSizeInfo),
+ ProcInfo, ProcInfo1),
map__set(ProcTable, ProcId, ProcInfo1, ProcTable1),
- pred_info_set_procedures(PredInfo, ProcTable1, PredInfo1),
+ pred_info_set_procedures(ProcTable1, PredInfo, PredInfo1),
map__set(PredTable0, PredId, PredInfo1, PredTable),
module_info_set_preds(Module0, PredTable, Module1),
set_finite_arg_size_infos(Solns, OutputSupplierMap, Module1, Module).
@@ -402,10 +402,10 @@
map__lookup(PredTable0, PredId, PredInfo),
pred_info_procedures(PredInfo, ProcTable),
map__lookup(ProcTable, ProcId, ProcInfo),
- proc_info_set_maybe_arg_size_info(ProcInfo, yes(ArgSizeInfo),
- ProcInfo1),
+ proc_info_set_maybe_arg_size_info(yes(ArgSizeInfo),
+ ProcInfo, ProcInfo1),
map__set(ProcTable, ProcId, ProcInfo1, ProcTable1),
- pred_info_set_procedures(PredInfo, ProcTable1, PredInfo1),
+ pred_info_set_procedures(ProcTable1, PredInfo, PredInfo1),
map__set(PredTable0, PredId, PredInfo1, PredTable),
module_info_set_preds(Module0, PredTable, Module1),
set_infinite_arg_size_infos(PPIds, ArgSizeInfo, Module1, Module).
@@ -422,10 +422,10 @@
map__lookup(PredTable0, PredId, PredInfo0),
pred_info_procedures(PredInfo0, ProcTable0),
map__lookup(ProcTable0, ProcId, ProcInfo0),
- proc_info_set_maybe_termination_info(ProcInfo0, yes(TerminationInfo),
- ProcInfo),
+ proc_info_set_maybe_termination_info(yes(TerminationInfo),
+ ProcInfo0, ProcInfo),
map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable),
- pred_info_set_procedures(PredInfo0, ProcTable, PredInfo),
+ pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
map__det_update(PredTable0, PredId, PredInfo, PredTable),
module_info_set_preds(Module0, PredTable, Module1),
set_termination_infos(PPIds, TerminationInfo, Module1, Module).
@@ -525,7 +525,7 @@
pred_info_context(PredInfo0, Context),
pred_info_procedures(PredInfo0, ProcTable0),
pred_info_get_markers(PredInfo0, Markers),
- pred_info_procids(PredInfo0, ProcIds),
+ ProcIds = pred_info_procids(PredInfo0),
(
% It is possible for compiler generated/mercury builtin
% predicates to be imported or locally defined, so they
@@ -583,7 +583,7 @@
;
ProcTable = ProcTable2
),
- pred_info_set_procedures(PredInfo0, ProcTable, PredInfo),
+ pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
map__set(PredTable0, PredId, PredInfo, PredTable),
module_info_set_preds(Module0, PredTable, Module1),
check_preds(PredIds, Module1, Module, State2, State).
@@ -611,10 +611,10 @@
ProcTable0, ProcTable)
;
(
- pred_info_name(PredInfo, Name),
- pred_info_arity(PredInfo, Arity),
+ ModuleName = pred_info_module(PredInfo),
+ Name = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo),
special_pred_name_arity(SpecPredId0, Name, Arity),
- pred_info_module(PredInfo, ModuleName),
any_mercury_builtin_module(ModuleName)
->
SpecialPredId = SpecPredId0
@@ -641,9 +641,9 @@
proc_info_headvars(ProcInfo0, HeadVars),
special_pred_id_to_termination(SpecialPredId, HeadVars,
ArgSize, Termination),
- proc_info_set_maybe_arg_size_info(ProcInfo0, yes(ArgSize), ProcInfo1),
- proc_info_set_maybe_termination_info(ProcInfo1, yes(Termination),
- ProcInfo),
+ proc_info_set_maybe_arg_size_info(yes(ArgSize), ProcInfo0, ProcInfo1),
+ proc_info_set_maybe_termination_info(yes(Termination),
+ ProcInfo1, ProcInfo),
map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable1),
set_generated_terminates(ProcIds, SpecialPredId,
ProcTable1, ProcTable).
@@ -687,9 +687,9 @@
Error = is_builtin(PredId),
ArgSizeInfo = yes(infinite([Context - Error]))
),
- proc_info_set_maybe_arg_size_info(ProcInfo0, ArgSizeInfo, ProcInfo1),
- proc_info_set_maybe_termination_info(ProcInfo1, yes(cannot_loop),
- ProcInfo),
+ proc_info_set_maybe_arg_size_info(ArgSizeInfo, ProcInfo0, ProcInfo1),
+ proc_info_set_maybe_termination_info(yes(cannot_loop),
+ ProcInfo1, ProcInfo),
map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable1),
set_builtin_terminates(ProcIds, PredId, PredInfo, Module,
ProcTable1, ProcTable).
@@ -747,8 +747,8 @@
proc_info_get_maybe_arg_size_info(ProcInfo0, no)
)
->
- proc_info_set_maybe_arg_size_info(ProcInfo0,
- yes(ArgSize), ProcInfo),
+ proc_info_set_maybe_arg_size_info(yes(ArgSize),
+ ProcInfo0, ProcInfo),
map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable1)
;
ProcTable1 = ProcTable0
@@ -781,8 +781,8 @@
proc_info_get_maybe_termination_info(ProcInfo0, no)
)
->
- proc_info_set_maybe_termination_info(ProcInfo0,
- yes(Termination), ProcInfo),
+ proc_info_set_maybe_termination_info(yes(Termination),
+ ProcInfo0, ProcInfo),
map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable1)
;
ProcTable1 = ProcTable0
@@ -849,11 +849,11 @@
% in an undefined predicate error.
\+ { set__member(PredId, TypeSpecForcePreds) }
->
- { pred_info_name(PredInfo, PredName) },
+ { PredName = pred_info_name(PredInfo) },
+ { ProcIds = pred_info_procids(PredInfo) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
+ { ModuleName = pred_info_module(PredInfo) },
{ pred_info_procedures(PredInfo, ProcTable) },
- { pred_info_procids(PredInfo, ProcIds) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
- { pred_info_module(PredInfo, ModuleName) },
{ pred_info_context(PredInfo, Context) },
{ SymName = qualified(ModuleName, PredName) },
termination__make_opt_int_procs(PredId, ProcIds, ProcTable,
Index: compiler/trace.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/trace.m,v
retrieving revision 1.59
diff -u -b -r1.59 trace.m
--- compiler/trace.m 16 Mar 2003 08:01:31 -0000 1.59
+++ compiler/trace.m 21 Oct 2003 14:20:24 -0000
@@ -259,20 +259,21 @@
error("length mismatch in trace__fail_vars")
).
-trace__do_we_need_maxfr_slot(Globals, PredInfo0, ProcInfo0, ProcInfo) :-
+trace__do_we_need_maxfr_slot(Globals, PredInfo0, !ProcInfo) :-
globals__get_trace_level(Globals, TraceLevel),
- proc_info_interface_code_model(ProcInfo0, CodeModel),
+ proc_info_interface_code_model(!.ProcInfo, CodeModel),
(
- eff_trace_level_is_none(PredInfo0, ProcInfo0, TraceLevel) = no,
+ eff_trace_level_is_none(PredInfo0, !.ProcInfo, TraceLevel)
+ = no,
CodeModel \= model_non,
- proc_info_goal(ProcInfo0, Goal),
+ proc_info_goal(!.ProcInfo, Goal),
code_util__goal_may_alloc_temp_frame(Goal)
->
MaxfrFlag = yes
;
MaxfrFlag = no
),
- proc_info_set_need_maxfr_slot(ProcInfo0, MaxfrFlag, ProcInfo).
+ proc_info_set_need_maxfr_slot(MaxfrFlag, !ProcInfo).
% trace__reserved_slots and trace__setup cooperate in the allocation
% of stack slots for tracing purposes. The allocation is done in the
Index: compiler/type_class_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/type_class_info.m,v
retrieving revision 1.1
diff -u -b -r1.1 type_class_info.m
--- compiler/type_class_info.m 23 Oct 2003 02:02:10 -0000 1.1
+++ compiler/type_class_info.m 23 Oct 2003 10:22:59 -0000
@@ -92,9 +92,9 @@
generate_method_id(ModuleInfo, ClassProc) = MethodId :-
ClassProc = hlds_class_proc(PredId, _ProcId),
module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_name(PredInfo, MethodName),
- pred_info_arity(PredInfo, Arity),
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
+ MethodName = pred_info_name(PredInfo),
+ Arity = pred_info_arity(PredInfo),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
MethodId = tc_method_id(MethodName, Arity, PredOrFunc).
%---------------------------------------------------------------------------%
Index: compiler/type_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/type_util.m,v
retrieving revision 1.127
diff -u -b -r1.127 type_util.m
--- compiler/type_util.m 20 Oct 2003 07:29:12 -0000 1.127
+++ compiler/type_util.m 21 Oct 2003 10:45:32 -0000
@@ -1791,7 +1791,7 @@
;
NewVar = Var
),
- type_info_locn_set_var(Locn, NewVar, NewLocn),
+ type_info_locn_set_var(NewVar, Locn, NewLocn),
% find the new tvar, if there is one, otherwise just
% create the old var as a type variable.
Index: compiler/typecheck.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/typecheck.m,v
retrieving revision 1.342
diff -u -b -r1.342 typecheck.m
--- compiler/typecheck.m 19 Sep 2003 11:10:04 -0000 1.342
+++ compiler/typecheck.m 21 Oct 2003 16:24:27 -0000
@@ -391,10 +391,8 @@
generate_stub_clause(PredName, !PredInfo, ModuleInfo,
StubClause, VarSet0, VarSet),
Clauses1 = [StubClause],
- clauses_info_set_clauses(ClausesInfo0, Clauses1,
- ClausesInfo1),
- clauses_info_set_varset(ClausesInfo1, VarSet,
- ClausesInfo2)
+ clauses_info_set_clauses(Clauses1, ClausesInfo0, ClausesInfo1),
+ clauses_info_set_varset(VarSet, ClausesInfo1, ClausesInfo2)
;
VarSet = VarSet0,
Clauses1 = Clauses0,
@@ -411,18 +409,17 @@
% of the head vars into the clauses_info
map__from_corresponding_lists(HeadVars, ArgTypes0,
VarTypes),
- clauses_info_set_vartypes(ClausesInfo2, VarTypes,
- ClausesInfo),
- pred_info_set_clauses_info(!.PredInfo, ClausesInfo,
- !:PredInfo),
+ clauses_info_set_vartypes(VarTypes,
+ ClausesInfo2, ClausesInfo),
+ pred_info_set_clauses_info(ClausesInfo, !PredInfo),
% We also need to set the head_type_params
% field to indicate that all the existentially
% quantified tvars in the head of this
% pred are indeed bound by this predicate.
term__vars_list(ArgTypes0,
HeadVarsIncludingExistentials),
- pred_info_set_head_type_params(!.PredInfo,
- HeadVarsIncludingExistentials, !:PredInfo),
+ pred_info_set_head_type_params(
+ HeadVarsIncludingExistentials, !PredInfo),
Error = no,
Changed = no
;
@@ -492,8 +489,8 @@
InferredTypeConstraints0, ConstraintProofs,
TVarRenaming, ExistTypeRenaming),
map__optimize(InferredVarTypes0, InferredVarTypes),
- clauses_info_set_vartypes(ClausesInfo2, InferredVarTypes,
- ClausesInfo3),
+ clauses_info_set_vartypes(InferredVarTypes,
+ ClausesInfo2, ClausesInfo3),
%
% Apply substitutions to the explicit vartypes.
@@ -507,13 +504,12 @@
apply_variable_renaming_to_type_map(TVarRenaming,
ExplicitVarTypes1, ExplicitVarTypes),
- clauses_info_set_explicit_vartypes(ClausesInfo3,
- ExplicitVarTypes, ClausesInfo4),
- clauses_info_set_clauses(ClausesInfo4, Clauses, ClausesInfo),
- pred_info_set_clauses_info(!.PredInfo, ClausesInfo, !:PredInfo),
- pred_info_set_typevarset(!.PredInfo, TypeVarSet, !:PredInfo),
- pred_info_set_constraint_proofs(!.PredInfo, ConstraintProofs,
- !:PredInfo),
+ clauses_info_set_explicit_vartypes(ExplicitVarTypes,
+ ClausesInfo3, ClausesInfo4),
+ clauses_info_set_clauses(Clauses, ClausesInfo4, ClausesInfo),
+ pred_info_set_clauses_info(ClausesInfo, !PredInfo),
+ pred_info_set_typevarset(TypeVarSet, !PredInfo),
+ pred_info_set_constraint_proofs(ConstraintProofs, !PredInfo),
%
% Split the inferred type class constraints into those
@@ -535,8 +531,8 @@
% bound in to types that make the constraints satisfiable,
% causing the error to go away.
%
- pred_info_set_unproven_body_constraints(!.PredInfo,
- UnprovenBodyConstraints, !:PredInfo),
+ pred_info_set_unproven_body_constraints(
+ UnprovenBodyConstraints, !PredInfo),
( Inferring = yes ->
%
@@ -549,14 +545,14 @@
%
% Now save the information we inferred in the pred_info
%
- pred_info_set_head_type_params(!.PredInfo,
- HeadTypeParams, !:PredInfo),
- pred_info_set_arg_types(!.PredInfo, TypeVarSet,
- ExistQVars, ArgTypes, !:PredInfo),
+ pred_info_set_head_type_params(HeadTypeParams,
+ !PredInfo),
+ pred_info_set_arg_types(TypeVarSet, ExistQVars,
+ ArgTypes, !PredInfo),
pred_info_get_class_context(!.PredInfo,
OldTypeConstraints),
- pred_info_set_class_context(!.PredInfo,
- InferredTypeConstraints, !:PredInfo),
+ pred_info_set_class_context(InferredTypeConstraints,
+ !PredInfo),
%
% Check if anything changed
%
@@ -575,8 +571,8 @@
Changed = yes
)
; % Inferring = no
- pred_info_set_head_type_params(!.PredInfo,
- HeadTypeParams2, !:PredInfo),
+ pred_info_set_head_type_params(HeadTypeParams2,
+ !PredInfo),
pred_info_get_maybe_instance_method_constraints(
!.PredInfo, MaybeInstanceMethodConstraints0),
@@ -626,13 +622,12 @@
MaybeInstanceMethodConstraints),
% save the results in the pred_info
- pred_info_set_arg_types(!.PredInfo, TypeVarSet,
- ExistQVars, RenamedOldArgTypes, !:PredInfo),
- pred_info_set_class_context(!.PredInfo,
- RenamedOldConstraints, !:PredInfo),
+ pred_info_set_arg_types(TypeVarSet, ExistQVars,
+ RenamedOldArgTypes, !PredInfo),
+ pred_info_set_class_context(RenamedOldConstraints,
+ !PredInfo),
pred_info_set_maybe_instance_method_constraints(
- !.PredInfo, MaybeInstanceMethodConstraints,
- !:PredInfo),
+ MaybeInstanceMethodConstraints, !PredInfo),
Changed = no
),
@@ -655,35 +650,34 @@
:- pred generate_stub_clause(string, pred_info, pred_info, module_info, clause,
prog_varset, prog_varset).
:- mode generate_stub_clause(in, in, out, in, out, in, out) is det.
-generate_stub_clause(PredName, PredInfo0, PredInfo, ModuleInfo, StubClause,
- VarSet0, VarSet) :-
+
+generate_stub_clause(PredName, !PredInfo, ModuleInfo, StubClause, !VarSet) :-
%
% Mark the predicate as a stub
% (i.e. record that it originally had no clauses)
%
- pred_info_get_markers(PredInfo0, Markers0),
+ pred_info_get_markers(!.PredInfo, Markers0),
add_marker(Markers0, stub, Markers),
- pred_info_set_markers(PredInfo0, Markers, PredInfo),
+ pred_info_set_markers(Markers, !PredInfo),
%
% Generate `PredName = "<PredName>"'
%
- varset__new_named_var(VarSet0, "PredName", PredNameVar, VarSet),
+ varset__new_named_var(!.VarSet, "PredName", PredNameVar, !:VarSet),
make_string_const_construction(PredNameVar, PredName, UnifyGoal),
%
% Generate `private_builtin.no_clauses(PredName)'
% or `private_builtin.sorry(PredName)'
%
- mercury_private_builtin_module(PrivateBuiltin),
- pred_info_module(PredInfo, ModuleName),
+ ModuleName = pred_info_module(!.PredInfo),
( mercury_std_library_module_name(ModuleName) ->
CalleeName = "sorry"
;
CalleeName = "no_clauses"
),
- pred_info_context(PredInfo, Context),
- generate_simple_call(PrivateBuiltin, CalleeName, predicate,
- [PredNameVar], only_mode, det, no, [], ModuleInfo,
+ pred_info_context(!.PredInfo, Context),
+ generate_simple_call(mercury_private_builtin_module, CalleeName,
+ predicate, [PredNameVar], only_mode, det, no, [], ModuleInfo,
Context, CallGoal),
%
% Combine the unification and call into a conjunction
@@ -896,21 +890,21 @@
pred_info, pred_info).
:- mode maybe_add_field_access_function_clause(in, in, out) is det.
-maybe_add_field_access_function_clause(ModuleInfo, PredInfo0, PredInfo) :-
- pred_info_import_status(PredInfo0, ImportStatus),
- pred_info_clauses_info(PredInfo0, ClausesInfo0),
+maybe_add_field_access_function_clause(ModuleInfo, !PredInfo) :-
+ pred_info_import_status(!.PredInfo, ImportStatus),
+ pred_info_clauses_info(!.PredInfo, ClausesInfo0),
clauses_info_clauses(ClausesInfo0, Clauses0),
(
- pred_info_is_field_access_function(ModuleInfo, PredInfo0),
+ pred_info_is_field_access_function(ModuleInfo, !.PredInfo),
Clauses0 = [],
status_defined_in_this_module(ImportStatus, yes)
->
clauses_info_headvars(ClausesInfo0, HeadVars),
pred_args_to_func_args(HeadVars, FuncArgs, FuncRetVal),
- pred_info_context(PredInfo0, Context),
- pred_info_module(PredInfo0, FuncModule),
- pred_info_name(PredInfo0, FuncName),
- pred_info_arity(PredInfo0, PredArity),
+ pred_info_context(!.PredInfo, Context),
+ FuncModule = pred_info_module(!.PredInfo),
+ FuncName = pred_info_name(!.PredInfo),
+ PredArity = pred_info_arity(!.PredInfo),
adjust_func_arity(function, FuncArity, PredArity),
FuncSymName = qualified(FuncModule, FuncName),
create_atomic_unification(FuncRetVal,
@@ -922,14 +916,14 @@
Goal = GoalExpr - GoalInfo,
ProcIds = [], % the clause applies to all procedures.
Clause = clause(ProcIds, Goal, mercury, Context),
- clauses_info_set_clauses(ClausesInfo0, [Clause], ClausesInfo),
- pred_info_update_goal_type(PredInfo0, clauses, PredInfo1),
- pred_info_set_clauses_info(PredInfo1, ClausesInfo, PredInfo2),
- pred_info_get_markers(PredInfo2, Markers0),
+ clauses_info_set_clauses([Clause], ClausesInfo0, ClausesInfo),
+ pred_info_update_goal_type(clauses, !PredInfo),
+ pred_info_set_clauses_info(ClausesInfo, !PredInfo),
+ pred_info_get_markers(!.PredInfo, Markers0),
add_marker(Markers0, calls_are_fully_qualified, Markers),
- pred_info_set_markers(PredInfo2, Markers, PredInfo)
+ pred_info_set_markers(Markers, !PredInfo)
;
- PredInfo = PredInfo0
+ true
).
% If there is only one clause, use the original head variables
@@ -940,8 +934,8 @@
:- pred maybe_improve_headvar_names(globals, pred_info, pred_info).
:- mode maybe_improve_headvar_names(in, in, out) is det.
-maybe_improve_headvar_names(Globals, PredInfo0, PredInfo) :-
- pred_info_clauses_info(PredInfo0, ClausesInfo0),
+maybe_improve_headvar_names(Globals, !PredInfo) :-
+ pred_info_clauses_info(!.PredInfo, ClausesInfo0),
clauses_info_clauses(ClausesInfo0, Clauses0),
clauses_info_headvars(ClausesInfo0, HeadVars0),
clauses_info_varset(ClausesInfo0, VarSet0),
@@ -955,7 +949,7 @@
globals__lookup_bool_option(Globals,
make_optimization_interface, yes)
->
- PredInfo = PredInfo0
+ true
;
Clauses0 = [SingleClause0]
->
@@ -973,14 +967,14 @@
conj_list_to_goal(list__reverse(RevConj), GoalInfo, Goal),
apply_partial_map_to_list(HeadVars0, Subst, HeadVars),
- clauses_info_set_headvars(ClausesInfo0,
- HeadVars, ClausesInfo1),
+ clauses_info_set_headvars(HeadVars,
+ ClausesInfo0, ClausesInfo1),
SingleClause = clause(A, Goal, C, D),
- clauses_info_set_clauses(ClausesInfo1,
- [SingleClause], ClausesInfo2),
- clauses_info_set_varset(ClausesInfo2, VarSet, ClausesInfo),
- pred_info_set_clauses_info(PredInfo0, ClausesInfo, PredInfo)
+ clauses_info_set_clauses([SingleClause],
+ ClausesInfo1, ClausesInfo2),
+ clauses_info_set_varset(VarSet, ClausesInfo2, ClausesInfo),
+ pred_info_set_clauses_info(ClausesInfo, !PredInfo)
;
%
% If a headvar is assigned to a variable with the
@@ -998,8 +992,8 @@
VarSet1
)
), HeadVarNames, VarSet0),
- clauses_info_set_varset(ClausesInfo0, VarSet, ClausesInfo),
- pred_info_set_clauses_info(PredInfo0, ClausesInfo, PredInfo)
+ clauses_info_set_varset(VarSet, ClausesInfo0, ClausesInfo),
+ pred_info_set_clauses_info(ClausesInfo, !PredInfo)
).
:- pred improve_single_clause_headvars(list(hlds_goal)::in, list(prog_var)::in,
@@ -1718,7 +1712,7 @@
% at that point, enough information is
% available to determine which predicate it is.
%
- invalid_pred_id(PredId)
+ PredId = invalid_pred_id
),
% Arguably, we could do context reduction at
@@ -1730,7 +1724,7 @@
TypeCheckInfo)
;
- invalid_pred_id(PredId),
+ PredId = invalid_pred_id,
report_pred_call_error(CallId, TypeCheckInfo1, TypeCheckInfo)
).
@@ -1828,7 +1822,7 @@
typecheck_find_arities(_, [], []).
typecheck_find_arities(Preds, [PredId | PredIds], [Arity | Arities]) :-
map__lookup(Preds, PredId, PredInfo),
- pred_info_arity(PredInfo, Arity),
+ Arity = pred_info_arity(PredInfo),
typecheck_find_arities(Preds, PredIds, Arities).
:- pred typecheck_call_overloaded_pred(list(pred_id), list(prog_var),
@@ -1934,8 +1928,8 @@
% we've found a matching predicate
% was there was more than one matching predicate/function?
%
- pred_info_name(PredInfo, PName),
- pred_info_module(PredInfo, Module),
+ PName = pred_info_name(PredInfo),
+ Module = pred_info_module(PredInfo),
PredName = qualified(Module, PName),
(
typecheck__find_matching_pred_id(PredIds,
@@ -1943,7 +1937,11 @@
->
% XXX this should report an error properly, not
% via error/1
- error("Type error in predicate call: unresolvable predicate overloading. You need to use an explicit module qualifier. Compile with -V to find out where.")
+ error("Type error in predicate call: " ++
+ "unresolvable predicate overloading. " ++
+ "You need to use an explicit " ++
+ "module qualifier. " ++
+ "Compile with -V to find out where.")
;
ThePredId = PredId
)
@@ -3092,8 +3090,8 @@
make_pred_cons_info(_TypeCheckInfo, PredId, PredTable, FuncArity,
_ModuleInfo, L0, L) :-
map__lookup(PredTable, PredId, PredInfo),
- pred_info_arity(PredInfo, PredArity),
- pred_info_get_is_pred_or_func(PredInfo, IsPredOrFunc),
+ PredArity = pred_info_arity(PredInfo),
+ IsPredOrFunc = pred_info_is_pred_or_func(PredInfo),
pred_info_get_class_context(PredInfo, ClassContext),
pred_info_arg_types(PredInfo, PredTypeVarSet, PredExistQVars,
CompleteArgTypes),
@@ -5053,12 +5051,12 @@
:- mode write_inference_message(in, di, uo) is det.
write_inference_message(PredInfo) -->
- { pred_info_name(PredInfo, PredName) },
+ { PredName = pred_info_name(PredInfo) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
{ Name = unqualified(PredName) },
{ pred_info_context(PredInfo, Context) },
{ pred_info_arg_types(PredInfo, VarSet, ExistQVars, Types0) },
{ strip_builtin_qualifiers_from_type_list(Types0, Types) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
{ pred_info_get_class_context(PredInfo, ClassContext) },
{ pred_info_get_purity(PredInfo, Purity) },
{ MaybeDet = no },
Index: compiler/unify_proc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unify_proc.m,v
retrieving revision 1.125
diff -u -b -r1.125 unify_proc.m
--- compiler/unify_proc.m 25 Jul 2003 02:27:29 -0000 1.125
+++ compiler/unify_proc.m 21 Oct 2003 14:21:14 -0000
@@ -367,15 +367,15 @@
pred_info_procedures(PredInfo1, Procs1),
pred_info_clauses_info(PredInfo1, ClausesInfo),
map__lookup(Procs1, ProcId, ProcInfo0),
- proc_info_set_can_process(ProcInfo0, no, ProcInfo1),
+ proc_info_set_can_process(no, ProcInfo0, ProcInfo1),
copy_clauses_to_proc(ProcId, ClausesInfo, ProcInfo1, ProcInfo2),
proc_info_goal(ProcInfo2, Goal0),
set_goal_contexts(Context, Goal0, Goal),
- proc_info_set_goal(ProcInfo2, Goal, ProcInfo),
+ proc_info_set_goal(Goal, ProcInfo2, ProcInfo),
map__det_update(Procs1, ProcId, ProcInfo, Procs2),
- pred_info_set_procedures(PredInfo1, Procs2, PredInfo2),
+ pred_info_set_procedures(Procs2, PredInfo1, PredInfo2),
map__det_update(Preds0, PredId, PredInfo2, Preds2),
module_info_set_preds(ModuleInfo0, Preds2, ModuleInfo2),
@@ -479,9 +479,9 @@
map__lookup(Preds0, PredId, PredInfo0),
pred_info_procedures(PredInfo0, Procs0),
map__lookup(Procs0, ProcId, ProcInfo0),
- proc_info_set_can_process(ProcInfo0, yes, ProcInfo1),
+ proc_info_set_can_process(yes, ProcInfo0, ProcInfo1),
map__det_update(Procs0, ProcId, ProcInfo1, Procs1),
- pred_info_set_procedures(PredInfo0, Procs1, PredInfo1),
+ pred_info_set_procedures(Procs1, PredInfo0, PredInfo1),
map__det_update(Preds0, PredId, PredInfo1, Preds1),
module_info_set_preds(ModuleInfo0, Preds1, ModuleInfo1)
},
@@ -532,7 +532,7 @@
map__lookup(OldPredTable0, PredId, OldPredInfo0),
pred_info_procedures(OldPredInfo0, OldProcTable0),
map__set(OldProcTable0, ProcId, ProcInfo, OldProcTable),
- pred_info_set_procedures(OldPredInfo0, OldProcTable, OldPredInfo),
+ pred_info_set_procedures(OldProcTable, OldPredInfo0, OldPredInfo),
map__det_update(OldPredTable0, PredId, OldPredInfo, OldPredTable).
%-----------------------------------------------------------------------------%
@@ -795,8 +795,8 @@
% (The pred_id and proc_id will be figured
% out by type checking and mode analysis.)
%
- { invalid_pred_id(PredId) },
- { invalid_proc_id(ModeId) },
+ { PredId = invalid_pred_id },
+ { ModeId = invalid_proc_id },
{ Call = call(PredId, ModeId, [H1, H2], not_builtin,
no, UnifyPredName) },
{ goal_info_init(Context, GoalInfo) },
@@ -812,8 +812,8 @@
% out by type checking and mode analysis.)
%
unify_proc__info_new_var(comparison_result_type, ResultVar),
- { invalid_pred_id(PredId) },
- { invalid_proc_id(ModeId) },
+ { PredId = invalid_pred_id },
+ { ModeId = invalid_proc_id },
{ Call = call(PredId, ModeId, [ResultVar, H1, H2],
not_builtin, no, ComparePredName) },
{ goal_info_init(Context, GoalInfo) },
@@ -990,8 +990,8 @@
% (The pred_id and proc_id will be figured
% out by type checking and mode analysis.)
%
- { invalid_pred_id(PredId) },
- { invalid_proc_id(ModeId) },
+ { PredId = invalid_pred_id },
+ { ModeId = invalid_proc_id },
{ Call = call(PredId, ModeId, ArgVars, not_builtin,
no, ComparePredName) },
{ goal_info_init(Context, GoalInfo) },
@@ -1047,14 +1047,14 @@
prog_context::in, clause::out,
unify_proc_info::in, unify_proc_info::out) is det.
-unify_proc__quantify_clause_body(HeadVars, Goal, Context, Clause) -->
- unify_proc__info_get_varset(Varset0),
- unify_proc__info_get_types(Types0),
- { implicitly_quantify_clause_body(HeadVars, Goal, Varset0, Types0,
- Body, Varset, Types, _Warnings) },
- unify_proc__info_set_varset(Varset),
- unify_proc__info_set_types(Types),
- { Clause = clause([], Body, mercury, Context) }.
+unify_proc__quantify_clause_body(HeadVars, Goal0, Context, Clause, !Info) :-
+ unify_proc__info_get_varset(Varset0, !Info),
+ unify_proc__info_get_types(Types0, !Info),
+ implicitly_quantify_clause_body(HeadVars, _Warnings, Goal0, Goal,
+ Varset0, Varset, Types0, Types),
+ unify_proc__info_set_varset(Varset, !Info),
+ unify_proc__info_set_types(Types, !Info),
+ Clause = clause([], Goal, mercury, Context).
%-----------------------------------------------------------------------------%
Index: compiler/unneeded_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unneeded_code.m,v
retrieving revision 1.14
diff -u -b -r1.14 unneeded_code.m
--- compiler/unneeded_code.m 27 Mar 2003 05:33:43 -0000 1.14
+++ compiler/unneeded_code.m 21 Oct 2003 14:24:51 -0000
@@ -230,16 +230,16 @@
:- pred unneeded_code__pre_process_proc(proc_info::in, proc_info::out) is det.
-unneeded_code__pre_process_proc(ProcInfo0, ProcInfo) :-
- proc_info_headvars(ProcInfo0, HeadVars),
- proc_info_goal(ProcInfo0, Goal0),
- proc_info_varset(ProcInfo0, Varset0),
- proc_info_vartypes(ProcInfo0, VarTypes0),
- implicitly_quantify_clause_body(HeadVars, Goal0, Varset0, VarTypes0,
- Goal, Varset, VarTypes, _Warnings),
- proc_info_set_goal(ProcInfo0, Goal, ProcInfo1),
- proc_info_set_varset(ProcInfo1, Varset, ProcInfo2),
- proc_info_set_vartypes(ProcInfo2, VarTypes, ProcInfo).
+unneeded_code__pre_process_proc(!ProcInfo) :-
+ proc_info_headvars(!.ProcInfo, HeadVars),
+ proc_info_goal(!.ProcInfo, Goal0),
+ proc_info_varset(!.ProcInfo, Varset0),
+ proc_info_vartypes(!.ProcInfo, VarTypes0),
+ implicitly_quantify_clause_body(HeadVars, _Warnings, Goal0, Goal,
+ Varset0, Varset, VarTypes0, VarTypes),
+ proc_info_set_goal(Goal, !ProcInfo),
+ proc_info_set_varset(Varset, !ProcInfo),
+ proc_info_set_vartypes(VarTypes, !ProcInfo).
% The source-to-source transform operates in two phases.
%
@@ -277,17 +277,16 @@
:- pred unneeded_code__process_proc(proc_info::in, proc_info::out,
module_info::in, module_info::out, bool::out) is det.
-unneeded_code__process_proc(ProcInfo0, ProcInfo, ModuleInfo0, ModuleInfo,
- Successful) :-
- goal_path__fill_slots(ProcInfo0, ModuleInfo0, ProcInfo1),
- proc_info_goal(ProcInfo1, Goal0),
- proc_info_varset(ProcInfo1, Varset0),
- proc_info_vartypes(ProcInfo1, VarTypes0),
- proc_info_get_initial_instmap(ProcInfo1, ModuleInfo0, InstMap0),
+unneeded_code__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),
Goal0 = _ - GoalInfo0,
goal_info_get_instmap_delta(GoalInfo0, InstMapDelta),
instmap__apply_instmap_delta(InstMap0, InstMapDelta, InstMap),
- proc_info_instantiated_head_vars(ModuleInfo0, ProcInfo1,
+ proc_info_instantiated_head_vars(!.ModuleInfo, !.ProcInfo,
NeededVarsList),
map__init(WhereNeededMap0),
NeededEverywhere =
@@ -297,14 +296,14 @@
list__foldl(NeededEverywhere, NeededVarsList,
WhereNeededMap0, WhereNeededMap1),
map__init(RefinedGoals0),
- module_info_globals(ModuleInfo0, Globals),
+ 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,
- VarTypes0, ModuleInfo0, Options, WhereNeededMap1, _,
+ VarTypes0, !.ModuleInfo, Options, WhereNeededMap1, _,
RefinedGoals0, RefinedGoals1, no, Changed),
unneeded_code__refine_goal(Goal1, RefinedGoals1, Goal2, RefinedGoals),
require(map__is_empty(RefinedGoals),
@@ -312,22 +311,18 @@
( Changed = yes ->
% We need to fix up the goal_info by recalculating
% the nonlocal vars and the non-atomic instmap deltas.
- proc_info_headvars(ProcInfo0, HeadVars),
- proc_info_inst_varset(ProcInfo0, InstVarSet),
- implicitly_quantify_clause_body(HeadVars,
- Goal2, Varset0, VarTypes0,
- Goal3, Varset, VarTypes, _Warnings),
+ proc_info_headvars(!.ProcInfo, HeadVars),
+ proc_info_inst_varset(!.ProcInfo, InstVarSet),
+ implicitly_quantify_clause_body(HeadVars, _Warnings,
+ Goal2, Goal3, Varset0, Varset, VarTypes0, VarTypes),
recompute_instmap_delta(no, Goal3, Goal, VarTypes, InstVarSet,
- InstMap0, ModuleInfo0, ModuleInfo1),
- proc_info_set_goal(ProcInfo1, Goal, ProcInfo2),
- proc_info_set_varset(ProcInfo2, Varset, ProcInfo3),
- proc_info_set_vartypes(ProcInfo3, VarTypes, ProcInfo4),
- unneeded_code__process_proc(ProcInfo4, ProcInfo,
- ModuleInfo1, ModuleInfo, _),
+ InstMap0, !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, _),
Successful = yes
;
- ProcInfo = ProcInfo0,
- ModuleInfo = ModuleInfo0,
Successful = no
).
Index: compiler/unused_args.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unused_args.m,v
retrieving revision 1.86
diff -u -b -r1.86 unused_args.m
--- compiler/unused_args.m 27 May 2003 05:57:23 -0000 1.86
+++ compiler/unused_args.m 21 Oct 2003 15:12:19 -0000
@@ -278,7 +278,7 @@
setup_local_var_usage(PredIds, UnusedArgInfo, !VarUsage,
!PredProcList, !OptProcs, !ModuleInfo, !IO)
;
- pred_info_procids(PredInfo, ProcIds),
+ ProcIds = pred_info_procids(PredInfo),
setup_pred_args(PredId, ProcIds, UnusedArgInfo, !VarUsage,
!PredProcList, !OptProcs, !ModuleInfo, !IO),
setup_local_var_usage(PredIds, UnusedArgInfo, !VarUsage,
@@ -305,10 +305,10 @@
Intermod = yes,
pred_info_is_imported(PredInfo)
->
- pred_info_module(PredInfo, PredModule),
- pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
- pred_info_name(PredInfo, PredName),
- pred_info_arity(PredInfo, PredArity),
+ PredModule = pred_info_module(PredInfo),
+ PredOrFunc = pred_info_is_pred_or_func(PredInfo),
+ PredName = pred_info_name(PredInfo),
+ PredArity = pred_info_arity(PredInfo),
FuncId = pred_or_func_name_arity_to_func_id(PredOrFunc,
PredName, PredArity, ProcId),
module_info_analysis_info(!.ModuleInfo, AnalysisInfo0),
@@ -870,16 +870,15 @@
->
true
;
- pred_info_module(OrigPredInfo, PredModule),
- pred_info_name(OrigPredInfo, PredName),
+ PredModule = pred_info_module(OrigPredInfo),
+ PredName = pred_info_name(OrigPredInfo),
globals__io_lookup_bool_option(intermodule_analysis,
Intermod, !IO),
( Intermod = yes ->
module_info_analysis_info(!.ModuleInfo, AnalysisInfo0),
- pred_info_get_is_pred_or_func(OrigPredInfo,
- PredOrFunc),
- pred_info_arity(OrigPredInfo, PredArity),
+ PredOrFunc = pred_info_is_pred_or_func(OrigPredInfo),
+ PredArity = pred_info_arity(OrigPredInfo),
ModuleId = module_name_to_module_id(PredModule),
FuncId = pred_or_func_name_arity_to_func_id(PredOrFunc,
PredName, PredArity, ProcId),
@@ -941,15 +940,15 @@
;
Status = local
),
- make_new_pred_info(!.ModuleInfo, OrigPredInfo, UnusedArgs,
- Status, proc(PredId, ProcId), NewPredInfo0),
- pred_info_name(NewPredInfo0, NewPredName),
+ make_new_pred_info(!.ModuleInfo, UnusedArgs, Status,
+ proc(PredId, ProcId), OrigPredInfo, NewPredInfo0),
+ NewPredName = pred_info_name(NewPredInfo0),
pred_info_procedures(NewPredInfo0, NewProcs0),
% Assign the old procedure to a new predicate, which
% will be fixed up in fixup_unused_args.
map__set(NewProcs0, ProcId, OrigProcInfo, NewProcs),
- pred_info_set_procedures(NewPredInfo0, NewProcs, NewPredInfo),
+ pred_info_set_procedures(NewProcs, NewPredInfo0, NewPredInfo),
% add the new proc to the pred table
module_info_get_predicate_table(!.ModuleInfo, PredTable0),
@@ -991,34 +990,34 @@
% Add an exported predicate with the number of removed
% arguments promised in the analysis file which just calls
% the new predicate.
- make_new_pred_info(!.ModuleInfo, OrigPredInfo, UnusedArgs2,
- exported, proc(PredId, ProcId), ExtraPredInfo0),
- pred_info_module(OrigPredInfo, PredModule),
+ make_new_pred_info(!.ModuleInfo, UnusedArgs2, exported,
+ proc(PredId, ProcId), OrigPredInfo, ExtraPredInfo0),
+ PredModule = pred_info_module(OrigPredInfo),
create_call_goal(UnusedArgs, NewPredId, ProcId,
PredModule, NewPredName, OrigProcInfo, ExtraProc0),
proc_info_headvars(OrigProcInfo, HeadVars0),
remove_listof_elements(HeadVars0, 1, UnusedArgs2, IntermodHeadVars),
- proc_info_set_headvars(ExtraProc0, IntermodHeadVars, ExtraProc1),
+ proc_info_set_headvars(IntermodHeadVars, ExtraProc0, ExtraProc1),
proc_info_argmodes(OrigProcInfo, ArgModes0),
remove_listof_elements(ArgModes0, 1, UnusedArgs2, IntermodArgModes),
- proc_info_set_argmodes(ExtraProc1, IntermodArgModes, ExtraProc),
+ proc_info_set_argmodes(IntermodArgModes, ExtraProc1, ExtraProc),
pred_info_procedures(ExtraPredInfo0, ExtraProcs0),
map__set(ExtraProcs0, ProcId, ExtraProc, ExtraProcs),
- pred_info_set_procedures(ExtraPredInfo0, ExtraProcs, ExtraPredInfo),
+ pred_info_set_procedures(ExtraProcs, ExtraPredInfo0, ExtraPredInfo),
module_info_get_predicate_table(!.ModuleInfo, PredTable0),
predicate_table_insert(PredTable0, ExtraPredInfo, _, PredTable),
module_info_set_predicate_table(!.ModuleInfo, PredTable, !:ModuleInfo).
-:- pred make_new_pred_info(module_info::in, pred_info::in, list(int)::in,
- import_status::in, pred_proc_id::in, pred_info::out) is det.
+:- pred make_new_pred_info(module_info::in, list(int)::in, import_status::in,
+ pred_proc_id::in, pred_info::in, pred_info::out) is det.
-make_new_pred_info(ModuleInfo, PredInfo0, UnusedArgs, Status,
- proc(_PredId, ProcId), PredInfo) :-
- pred_info_module(PredInfo0, PredModule),
- pred_info_name(PredInfo0, Name0),
- pred_info_get_is_pred_or_func(PredInfo0, PredOrFunc),
- pred_info_arg_types(PredInfo0, Tvars, ExistQVars, ArgTypes0),
- pred_info_get_maybe_special_pred(PredInfo0, MaybeSpecial),
+make_new_pred_info(ModuleInfo, UnusedArgs, Status, proc(_PredId, ProcId),
+ !PredInfo) :-
+ PredModule = pred_info_module(!.PredInfo),
+ Name0 = pred_info_name(!.PredInfo),
+ PredOrFunc = pred_info_is_pred_or_func(!.PredInfo),
+ pred_info_arg_types(!.PredInfo, Tvars, ExistQVars, ArgTypes0),
+ pred_info_get_maybe_special_pred(!.PredInfo, MaybeSpecial),
% create a unique new pred name using the old proc_id
(
string__prefix(Name0, "__"),
@@ -1061,21 +1060,20 @@
% link errors.
proc_id_to_int(ProcId, ProcInt),
add_sym_name_suffix(Name2, "_" ++ int_to_string(ProcInt), Name),
- pred_info_arity(PredInfo0, Arity),
- pred_info_typevarset(PredInfo0, TypeVars),
+ Arity = pred_info_arity(!.PredInfo),
+ pred_info_typevarset(!.PredInfo, TypeVars),
remove_listof_elements(ArgTypes0, 1, UnusedArgs, ArgTypes),
- pred_info_context(PredInfo0, Context),
- pred_info_clauses_info(PredInfo0, ClausesInfo),
- pred_info_get_markers(PredInfo0, Markers),
- pred_info_get_goal_type(PredInfo0, GoalType),
- pred_info_get_class_context(PredInfo0, ClassContext),
- pred_info_get_aditi_owner(PredInfo0, Owner),
+ pred_info_context(!.PredInfo, Context),
+ pred_info_clauses_info(!.PredInfo, ClausesInfo),
+ pred_info_get_markers(!.PredInfo, Markers),
+ pred_info_get_goal_type(!.PredInfo, GoalType),
+ pred_info_get_class_context(!.PredInfo, ClassContext),
+ pred_info_get_aditi_owner(!.PredInfo, Owner),
map__init(EmptyProofs),
- pred_info_init(PredModule, Name, Arity, Tvars,
- ExistQVars, ArgTypes, true, Context, ClausesInfo, Status,
- Markers, GoalType, PredOrFunc, ClassContext, EmptyProofs,
- Owner, PredInfo1),
- pred_info_set_typevarset(PredInfo1, TypeVars, PredInfo).
+ pred_info_init(PredModule, Name, Arity, Tvars, ExistQVars, ArgTypes,
+ true, Context, ClausesInfo, Status, Markers, GoalType,
+ PredOrFunc, ClassContext, EmptyProofs, Owner, !:PredInfo),
+ pred_info_set_typevarset(TypeVars, !PredInfo).
% Replace the goal in the procedure with one to call the given
% pred_id and proc_id.
@@ -1083,9 +1081,9 @@
module_name::in, string::in, proc_info::in, proc_info::out) is det.
create_call_goal(UnusedArgs, NewPredId, NewProcId, PredModule,
- PredName, OldProc0, OldProc) :-
- proc_info_headvars(OldProc0, HeadVars),
- proc_info_goal(OldProc0, Goal0),
+ PredName, !OldProc) :-
+ proc_info_headvars(!.OldProc, HeadVars),
+ proc_info_goal(!.OldProc, Goal0),
Goal0 = _GoalExpr - GoalInfo0,
% We must use the interface determinism for determining
@@ -1093,25 +1091,25 @@
% arguments removed, not the actual determinism of the
% body is it may be more lax, which will lead to code
% gen problems.
- proc_info_interface_determinism(OldProc0, Determinism),
+ proc_info_interface_determinism(!.OldProc, Determinism),
goal_info_set_determinism(GoalInfo0, Determinism, GoalInfo1),
- proc_info_vartypes(OldProc0, VarTypes0),
+ proc_info_vartypes(!.OldProc, VarTypes0),
set__list_to_set(HeadVars, NonLocals),
map__apply_to_list(HeadVars, VarTypes0, VarTypeList),
map__from_corresponding_lists(HeadVars, VarTypeList, VarTypes1),
% the varset should probably be fixed up, but it
% shouldn't make too much difference
- proc_info_varset(OldProc0, Varset0),
+ proc_info_varset(!.OldProc, Varset0),
remove_listof_elements(HeadVars, 1, UnusedArgs, NewHeadVars),
GoalExpr = call(NewPredId, NewProcId, NewHeadVars,
not_builtin, no, qualified(PredModule, PredName)),
Goal1 = GoalExpr - GoalInfo1,
- implicitly_quantify_goal(Goal1, Varset0, VarTypes1,
- NonLocals, Goal, Varset, VarTypes, _),
- proc_info_set_goal(OldProc0, Goal, OldProc1),
- proc_info_set_varset(OldProc1, Varset, OldProc2),
- proc_info_set_vartypes(OldProc2, VarTypes, OldProc).
+ implicitly_quantify_goal(NonLocals, _, Goal1, Goal, Varset0, Varset,
+ VarTypes1, VarTypes),
+ proc_info_set_goal(Goal, !OldProc),
+ proc_info_set_varset(Varset, !OldProc),
+ proc_info_set_vartypes(VarTypes, !OldProc).
% Create a pred_info for an imported pred with a pragma unused_args
% in the .opt file.
@@ -1124,26 +1122,26 @@
OptProc = proc(PredId, ProcId),
module_info_pred_proc_info(ModuleInfo0,
PredId, ProcId, PredInfo0, ProcInfo0),
- make_new_pred_info(ModuleInfo0, PredInfo0, UnusedArgs,
- imported(interface), OptProc, NewPredInfo0),
+ make_new_pred_info(ModuleInfo0, UnusedArgs, imported(interface),
+ OptProc, PredInfo0, NewPredInfo0),
pred_info_procedures(NewPredInfo0, NewProcs0),
% Assign the old procedure to a new predicate.
proc_info_headvars(ProcInfo0, HeadVars0),
remove_listof_elements(HeadVars0, 1, UnusedArgs, HeadVars),
- proc_info_set_headvars(ProcInfo0, HeadVars, ProcInfo1),
- proc_info_argmodes(ProcInfo1, ArgModes0),
+ proc_info_set_headvars(HeadVars, ProcInfo0, HeadVarsProcInfo),
+ proc_info_argmodes(HeadVarsProcInfo, ArgModes0),
remove_listof_elements(ArgModes0, 1, UnusedArgs, ArgModes),
- proc_info_set_argmodes(ProcInfo0, ArgModes, ProcInfo),
+ proc_info_set_argmodes(ArgModes, ProcInfo0, ProcInfo),
map__set(NewProcs0, ProcId, ProcInfo, NewProcs),
- pred_info_set_procedures(NewPredInfo0, NewProcs, NewPredInfo),
+ pred_info_set_procedures(NewProcs, NewPredInfo0, NewPredInfo),
% Add the new proc to the pred table.
module_info_get_predicate_table(ModuleInfo0, PredTable0),
predicate_table_insert(PredTable0, NewPredInfo, NewPredId, PredTable1),
module_info_set_predicate_table(ModuleInfo0, PredTable1, ModuleInfo),
- pred_info_module(NewPredInfo, PredModule),
- pred_info_name(NewPredInfo, PredName),
+ PredModule = pred_info_module(NewPredInfo),
+ 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),
@@ -1256,8 +1254,8 @@
proc_info_goal(ProcInfo0, Goal0),
remove_listof_elements(HeadVars0, 1, UnusedArgs, HeadVars),
remove_listof_elements(ArgModes0, 1, UnusedArgs, ArgModes),
- proc_info_set_headvars(ProcInfo0, HeadVars, FixedProc1),
- proc_info_set_argmodes(FixedProc1, ArgModes, FixedProc2),
+ proc_info_set_headvars(HeadVars, ProcInfo0, FixedProc1),
+ proc_info_set_argmodes(ArgModes, FixedProc1, FixedProc2),
% remove unused vars from goal
fixup_goal(Mod0, UnusedVars, ProcCallInfo, Changed, Goal0, Goal1),
@@ -1265,21 +1263,20 @@
Changed = yes,
% if anything has changed, rerun quantification
set__list_to_set(HeadVars, NonLocals),
- implicitly_quantify_goal(Goal1, Varset0, VarTypes0,
- NonLocals, Goal, Varset, VarTypes, _),
- proc_info_set_goal(FixedProc2, Goal, FixedProc3),
- proc_info_set_varset(FixedProc3, Varset, FixedProc4),
- proc_info_set_vartypes(FixedProc4, VarTypes, FixedProc5)
+ implicitly_quantify_goal(NonLocals, _, Goal1, Goal,
+ Varset0, Varset, VarTypes0, VarTypes),
+ proc_info_set_goal(Goal, FixedProc2, FixedProc3),
+ proc_info_set_varset(Varset, FixedProc3, FixedProc4),
+ proc_info_set_vartypes(VarTypes, FixedProc4, FixedProc5)
;
Changed = no,
- proc_info_set_vartypes(FixedProc2, VarTypes0, FixedProc5)
+ proc_info_set_vartypes(VarTypes0, FixedProc2, FixedProc5)
),
map__set(Procs0, ProcId, FixedProc5, Procs),
- pred_info_set_procedures(PredInfo0, Procs, PredInfo),
+ pred_info_set_procedures(Procs, PredInfo0, PredInfo),
map__set(Preds0, PredId, PredInfo, Preds),
module_info_set_preds(Mod0, Preds, Mod).
-
% 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.
@@ -1555,7 +1552,7 @@
{ module_info_pred_info(ModuleInfo, PredId, PredInfo) },
(
{
- pred_info_name(PredInfo, Name),
+ Name = pred_info_name(PredInfo),
\+ pred_info_is_imported(PredInfo),
\+ pred_info_import_status(PredInfo, opt_imported),
% Don't warn about builtins
@@ -1613,10 +1610,10 @@
),
{ UnusedArgs \= [] }
->
- { pred_info_module(PredInfo, Module) },
- { pred_info_name(PredInfo, Name) },
- { pred_info_arity(PredInfo, Arity) },
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { 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) },
mercury_output_pragma_unused_args(PredOrFunc,
@@ -1646,10 +1643,8 @@
% Strip off the extra type_info arguments
% inserted at the front by polymorphism.m
- pred_info_arity(PredInfo, Arity),
- NumToDrop = NumHeadVars - Arity,
- adjust_unused_args(NumToDrop,
- UnusedArgs0, UnusedArgs)
+ NumToDrop = NumHeadVars - pred_info_arity(PredInfo),
+ adjust_unused_args(NumToDrop, UnusedArgs0, UnusedArgs)
},
( { UnusedArgs \= [] } ->
report_unused_args(PredInfo, UnusedArgs)
@@ -1668,18 +1663,18 @@
report_unused_args(PredInfo, UnusedArgs) -->
{ list__length(UnusedArgs, NumArgs) },
{ pred_info_context(PredInfo, Context) },
+ { PredOrFunc = pred_info_is_pred_or_func(PredInfo) },
+ { Module = pred_info_module(PredInfo) },
+ { Name = pred_info_name(PredInfo) },
+ { Arity = pred_info_arity(PredInfo) },
prog_out__write_context(Context),
io__write_string("In "),
- { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
hlds_out__write_pred_or_func(PredOrFunc),
io__write_string(" `"),
- { pred_info_module(PredInfo, Module) },
prog_out__write_sym_name(Module),
io__write_string("."),
- { pred_info_name(PredInfo, Name) },
io__write_string(Name),
io__write_string("/"),
- { pred_info_arity(PredInfo, Arity) },
io__write_int(Arity),
io__write_string("':\n"),
prog_out__write_context(Context),
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/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
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