[m-rev.] diff: state_var.m

Zoltan Somogyi zs at csse.unimelb.edu.au
Tue Jan 29 12:47:02 AEDT 2008


Improve state_var.m.

compiler/state_var.m:
	Put svar_ prefixes on predicate names in order to make it clear
	what they do (in several cases, this was far from obvious).

	Put svar_ prefixes on field names to avoid collisions in tags files.

	Replace the use of ^ elem(...) notation with calls to map.search
	and map.set, in order to make the code more readable. In some cases,
	this allowed the deletion of redundant searches and updates. In others,
	it allowed the replacement of map.sets with map.det_inserts or
	map.det_updates.

	Replace some functions with predicates where this allows the natural
	use of state variable notation.

compiler/add_clause.m:
compiler/superhomogeneous.m:
	Conform to the new svar_ prefixes on predicate names.

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/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing boehm_gc/windows-untested
cvs diff: Diffing boehm_gc/windows-untested/vc60
cvs diff: Diffing boehm_gc/windows-untested/vc70
cvs diff: Diffing boehm_gc/windows-untested/vc71
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/add_clause.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_clause.m,v
retrieving revision 1.47
diff -u -b -r1.47 add_clause.m
--- compiler/add_clause.m	23 Nov 2007 07:34:53 -0000	1.47
+++ compiler/add_clause.m	11 Jan 2008 03:38:23 -0000
@@ -479,12 +479,11 @@
     IsEmpty = clause_list_is_empty(ClausesRep0),
     (
         IsEmpty = yes,
-        % Create the mapping from type variable name, used to
-        % rename type variables occurring in explicit type
-        % qualifications. The version of this mapping stored
-        % in the clauses_info should only contain type variables
-        % which occur in the argument types of the predicate.
-        % Type variables which only occur in explicit type
+        % Create the mapping from type variable name, used to rename
+        % type variables occurring in explicit type qualifications.
+        % The version of this mapping stored in the clauses_info should
+        % only contain type variables which occur in the argument types
+        % of the predicate. Type variables which only occur in explicit type
         % qualifications are local to the clause in which they appear.
         varset.create_name_var_map(TVarSet0, TVarNameMap)
     ;
@@ -555,7 +554,7 @@
         !QualInfo, !Specs) :-
     some [!SInfo] (
         HeadVarList = proc_arg_vector_to_list(HeadVars),
-        prepare_for_head(!:SInfo),
+        svar_prepare_for_head(!:SInfo),
         rename_vars_in_term_list(need_not_rename, Renaming, Args0, Args1),
         substitute_state_var_mappings(Args1, Args, !VarSet, !SInfo, !Specs),
         HeadGoal0 = true_goal,
@@ -569,16 +568,15 @@
             attach_features_to_all_goals([feature_from_head],
                 HeadGoal1, HeadGoal)
         ),
-        prepare_for_body(FinalSVarMap, !VarSet, !SInfo),
+        svar_prepare_for_body(FinalSVarMap, !VarSet, !SInfo),
         transform_goal(ParseBody, Renaming, BodyGoal, _, !VarSet, !ModuleInfo,
             !QualInfo, !SInfo, !Specs),
-        finish_goals(Context, FinalSVarMap, [HeadGoal, BodyGoal], Goal0,
+        svar_finish_goals(Context, FinalSVarMap, [HeadGoal, BodyGoal], Goal0,
             !.SInfo),
         qual_info_get_var_types(!.QualInfo, VarTypes0),
-        %
-        % The RTTI varmaps here are just a dummy value because the real
-        % ones are not introduced until typechecking and polymorphism.
-        %
+
+        % The RTTI varmaps here are just a dummy value because the real ones
+        % are not introduced until typechecking and polymorphism.
         rtti_varmaps_init(EmptyRttiVarmaps),
         implicitly_quantify_clause_body(HeadVarList, Warnings, Goal0, Goal,
             !VarSet, VarTypes0, VarTypes, EmptyRttiVarmaps, _),
@@ -603,11 +601,11 @@
 transform_goal_2(fail_expr, _, _, hlds_goal(disj([]), GoalInfo), 0,
         !VarSet, !ModuleInfo, !QualInfo, !SInfo, !Specs) :-
     goal_info_init(GoalInfo),
-    prepare_for_next_conjunct(set.init, !VarSet, !SInfo).
+    svar_prepare_for_next_conjunct(set.init, !VarSet, !SInfo).
 transform_goal_2(true_expr, _, _, hlds_goal(conj(plain_conj, []), GoalInfo), 0,
         !VarSet, !ModuleInfo, !QualInfo, !SInfo, !Specs) :-
     goal_info_init(GoalInfo),
-    prepare_for_next_conjunct(set.init, !VarSet, !SInfo).
+    svar_prepare_for_next_conjunct(set.init, !VarSet, !SInfo).
 transform_goal_2(all_expr(Vars0, Goal0), Context, Renaming, Goal, NumAdded,
         !VarSet, !ModuleInfo, !QualInfo, !SInfo, !Specs) :-
     % Convert `all [Vars] Goal' into `not some [Vars] not Goal'.
@@ -720,20 +718,20 @@
     BeforeSInfo = !.SInfo,
     rename_var_list(need_not_rename, Renaming, Vars0, Vars),
     rename_var_list(need_not_rename, Renaming, StateVars0, StateVars),
-    prepare_for_if_then_else_goal(StateVars, !VarSet, !SInfo),
+    svar_prepare_for_if_then_else_goal(StateVars, !VarSet, !SInfo),
     transform_goal(Cond0, Renaming, Cond, CondAdded, !VarSet, !ModuleInfo,
         !QualInfo, !SInfo, !Specs),
-    finish_if_then_else_goal_condition(StateVars,
+    svar_finish_if_then_else_goal_condition(StateVars,
         BeforeSInfo, !.SInfo, AfterCondSInfo, !:SInfo),
     transform_goal(Then0, Renaming, Then1, ThenAdded, !VarSet, !ModuleInfo,
         !QualInfo, !SInfo, !Specs),
-    finish_if_then_else_goal_then_goal(StateVars, BeforeSInfo, !SInfo),
+    svar_finish_if_then_else_goal_then_goal(StateVars, BeforeSInfo, !SInfo),
     AfterThenSInfo = !.SInfo,
     transform_goal(Else0, Renaming, Else1, ElseAdded, !VarSet, !ModuleInfo,
         !QualInfo, BeforeSInfo, !:SInfo, !Specs),
     NumAdded = CondAdded + ThenAdded + ElseAdded,
     goal_info_init(Context, GoalInfo),
-    finish_if_then_else(Context, Then1, Then, Else1, Else,
+    svar_finish_if_then_else(Context, Then1, Then, Else1, Else,
         BeforeSInfo, AfterCondSInfo, AfterThenSInfo, !SInfo, !VarSet).
 transform_goal_2(not_expr(SubGoal0), _, Renaming,
         hlds_goal(negation(SubGoal), GoalInfo),
@@ -742,7 +740,7 @@
     transform_goal(SubGoal0, Renaming, SubGoal, NumAdded, !VarSet, !ModuleInfo,
         !QualInfo, !SInfo, !Specs),
     goal_info_init(GoalInfo),
-    finish_negation(BeforeSInfo, !SInfo).
+    svar_finish_negation(BeforeSInfo, !SInfo).
 transform_goal_2(conj_expr(A0, B0), _, Renaming, Goal, NumAdded, !VarSet,
         !ModuleInfo, !QualInfo, !SInfo, !Specs) :-
     get_rev_conj(A0, Renaming, [], R0, 0, NumAddedA,
@@ -767,7 +765,7 @@
         !VarSet, !ModuleInfo, !QualInfo, !.SInfo, !Specs),
     get_disj(A0, Renaming, L0, L1, NumAddedB, NumAdded,
         !VarSet, !ModuleInfo, !QualInfo, !.SInfo, !Specs),
-    finish_disjunction(Context, !.VarSet, L1, L, !:SInfo),
+    svar_finish_disjunction(Context, !.VarSet, L1, L, !:SInfo),
     goal_info_init(Context, GoalInfo),
     disj_list_to_goal(L, GoalInfo, Goal).
 transform_goal_2(implies_expr(P, Q), Context, Renaming, Goal, NumAdded,
@@ -792,11 +790,11 @@
         !SInfo, !Specs),
     NumAdded = NumAddedP + NumAddedQ,
     Goal = hlds_goal(shorthand(bi_implication(P, Q)), GoalInfo),
-    finish_equivalence(BeforeSInfo, !SInfo).
+    svar_finish_equivalence(BeforeSInfo, !SInfo).
 transform_goal_2(event_expr(EventName, Args0), Context, Renaming, Goal,
         NumAdded, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !Specs) :-
     Args1 = expand_bang_state_var_args(Args0),
-    prepare_for_call(!SInfo),
+    svar_prepare_for_call(!SInfo),
     rename_vars_in_term_list(need_not_rename, Renaming, Args1, Args),
     make_fresh_arg_vars(Args, HeadVars, !VarSet, !SInfo, !Specs),
     list.length(HeadVars, Arity),
@@ -809,7 +807,7 @@
     insert_arg_unifications(HeadVars, Args, Context, ac_call(CallId),
         Goal0, Goal, NumAdded, !VarSet, !ModuleInfo, !QualInfo,
         !SInfo, !Specs),
-    finish_call(!VarSet, !SInfo).
+    svar_finish_call(!VarSet, !SInfo).
 transform_goal_2(call_expr(Name, Args0, Purity), Context, Renaming, Goal,
         NumAdded, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !Specs) :-
     Args1 = expand_bang_state_var_args(Args0),
@@ -817,12 +815,12 @@
         Name = unqualified("\\="),
         Args1 = [LHS, RHS]
     ->
-        prepare_for_call(!SInfo),
+        svar_prepare_for_call(!SInfo),
         % `LHS \= RHS' is defined as `not (LHS = RHS)'
         transform_goal_2(not_expr(unify_expr(LHS, RHS, Purity) - Context),
             Context, Renaming, Goal, NumAdded, !VarSet, !ModuleInfo, !QualInfo,
             !SInfo, !Specs),
-        finish_call(!VarSet, !SInfo)
+        svar_finish_call(!VarSet, !SInfo)
     ;
         % check for a state var record assignment:
         % !Var ^ field := Value
@@ -832,7 +830,7 @@
         StateVar0 = functor(atom("!"), Args @ [variable(_, _)],
                 StateVarContext)
     ->
-        prepare_for_call(!SInfo),
+        svar_prepare_for_call(!SInfo),
         % !Var ^ field := Value is defined as !:Var = !.Var ^ field := Value.
         LHS = functor(atom("!:"), Args, StateVarContext),
         StateVar = functor(atom("!."), Args, StateVarContext),
@@ -842,7 +840,7 @@
         transform_goal_2(unify_expr(LHS, RHS, Purity),
             Context, Renaming, Goal, NumAdded, !VarSet, !ModuleInfo, !QualInfo,
             !SInfo, !Specs),
-        finish_call(!VarSet, !SInfo)
+        svar_finish_call(!VarSet, !SInfo)
     ;
         % check for a DCG field access goal:
         % get: Field =^ field
@@ -852,13 +850,13 @@
         ; Operator = ":="
         )
     ->
-        prepare_for_call(!SInfo),
+        svar_prepare_for_call(!SInfo),
         rename_vars_in_term_list(need_not_rename, Renaming, Args1, Args2),
         transform_dcg_record_syntax(Operator, Args2, Context, Goal, NumAdded,
             !VarSet, !ModuleInfo, !QualInfo, !SInfo, !Specs),
-        finish_call(!VarSet, !SInfo)
+        svar_finish_call(!VarSet, !SInfo)
     ;
-        prepare_for_call(!SInfo),
+        svar_prepare_for_call(!SInfo),
         rename_vars_in_term_list(need_not_rename, Renaming, Args1, Args),
         make_fresh_arg_vars(Args, HeadVars, !VarSet, !SInfo, !Specs),
         list.length(Args, Arity),
@@ -896,7 +894,7 @@
         insert_arg_unifications(HeadVars, Args, Context, ac_call(CallId),
             Goal0, Goal, NumAdded, !VarSet, !ModuleInfo, !QualInfo,
             !SInfo, !Specs),
-        finish_call(!VarSet, !SInfo)
+        svar_finish_call(!VarSet, !SInfo)
     ).
 transform_goal_2(unify_expr(A0, B0, Purity), Context, Renaming, Goal,
         NumAdded, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !Specs) :-
@@ -913,10 +911,10 @@
         Goal = true_goal,
         NumAdded = 0
     ;
-        prepare_for_call(!SInfo),
+        svar_prepare_for_call(!SInfo),
         unravel_unification(A, B, Context, umc_explicit, [], Purity, Goal,
             NumAdded, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !Specs),
-        finish_call(!VarSet, !SInfo)
+        svar_finish_call(!VarSet, !SInfo)
     ).
 
 :- pred extract_trace_mutable_var(prog_context::in, prog_varset::in,
@@ -980,7 +978,7 @@
 convert_dot_state_vars(_Context, [], [], !VarSet, !SInfo, !Specs).
 convert_dot_state_vars(Context, [Dot0 | Dots0], [Dot | Dots],
         !VarSet, !SInfo, !Specs) :-
-    dot(Context, Dot0, Dot, !VarSet, !SInfo, !Specs),
+    svar_dot(Context, Dot0, Dot, !VarSet, !SInfo, !Specs),
     convert_dot_state_vars(Context, Dots0, Dots, !VarSet, !SInfo, !Specs).
 
 :- pred convert_colon_state_vars(prog_context::in,
@@ -991,7 +989,7 @@
 convert_colon_state_vars(_Context, [], [], !VarSet, !SInfo, !Specs).
 convert_colon_state_vars(Context, [Colon0 | Colons0], [Colon | Colons],
         !VarSet, !SInfo, !Specs) :-
-    colon(Context, Colon0, Colon, !VarSet, !SInfo, !Specs),
+    svar_colon(Context, Colon0, Colon, !VarSet, !SInfo, !Specs),
     convert_colon_state_vars(Context, Colons0, Colons, !VarSet,
         !SInfo, !Specs).
 
Index: compiler/state_var.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/state_var.m,v
retrieving revision 1.22
diff -u -b -r1.22 state_var.m
--- compiler/state_var.m	19 Jan 2007 07:04:31 -0000	1.22
+++ compiler/state_var.m	28 Jan 2008 10:40:10 -0000
@@ -63,22 +63,20 @@
 
 :- type svar_info
     --->    svar_info(
-                ctxt            ::  svar_ctxt,
+                svar_ctxt           ::  svar_ctxt,
 
-                num             ::  int,
-                                % This is used to number state variables and
-                                % is incremented for each source-level
-                                % conjunct.
-
-                external_dot    ::  svar_map,
-                                % The "read only" state variables in
-                                % scope (e.g. external state variables
-                                % visible from within a lambda body or
-                                % condition of an if-then-else expression.)
+                % This is used to number state variables and is incremented
+                % for each source-level conjunct.
+                svar_num            ::  int,
+
+                % The "read only" state variables in scope (e.g. external state
+                % variables visible from within a lambda body or condition
+                % of an if-then-else expression.)
+                svar_readonly_dot   ::  svar_map,
 
-                dot             ::  svar_map,
-                colon           ::  svar_map
                                 % The "read/write" state variables in scope.
+                svar_dot            ::  svar_map,
+                svar_colon          ::  svar_map
             ).
 
     % When collecting the arms of a disjunction we also need to
@@ -105,7 +103,7 @@
     % Note that if !.X does not appear in the head then !:X must appear
     % before !.X can be referenced.
     %
-:- pred dot(prog_context::in, svar::in, prog_var::out,
+:- pred svar_dot(prog_context::in, svar::in, prog_var::out,
     prog_varset::in, prog_varset::out, svar_info::in, svar_info::out,
     list(error_spec)::in, list(error_spec)::out) is det.
 
@@ -120,13 +118,13 @@
     % We also keep track of which state variables have been updated
     % in an atomic context.
     %
-:- pred colon(prog_context::in, svar::in, prog_var::out,
+:- pred svar_colon(prog_context::in, svar::in, prog_var::out,
     prog_varset::in, prog_varset::out, svar_info::in, svar_info::out,
     list(error_spec)::in, list(error_spec)::out) is det.
 
     % Prepare for the head of a new clause.
     %
-:- pred prepare_for_head(svar_info::out) is det.
+:- pred svar_prepare_for_head(svar_info::out) is det.
 
     % We need to add the current !.Xs to the set of external ("read-only")
     % state variables and clear the !.Xs and !:Xs.
@@ -134,19 +132,19 @@
     % While processing the head, any state variables therein are implicitly
     % scoped over the body and have !. and !: mappings set up.
     %
-:- pred prepare_for_lambda(svar_info::in, svar_info::out) is det.
+:- pred svar_prepare_for_lambda(svar_info::in, svar_info::out) is det.
 
     % Having processed the head of a clause, prepare for the first
     % (source-level) atomic conjunct.  We return the final !:
     % mappings identified while processing the head.
     %
-:- pred prepare_for_body(svar_map::out, prog_varset::in, prog_varset::out,
+:- pred svar_prepare_for_body(svar_map::out, prog_varset::in, prog_varset::out,
     svar_info::in, svar_info::out) is det.
 
     % We have to conjoin the goals and add unifiers to tie up all
     % the final values of the state variables to the head variables.
     %
-:- pred finish_goals(prog_context::in, svar_map::in,
+:- pred svar_finish_goals(prog_context::in, svar_map::in,
     list(hlds_goal)::in, hlds_goal::out, svar_info::in) is det.
 
     % Add some local state variables.
@@ -168,43 +166,44 @@
     % We construct new mappings for the state variables and then
     % add unifiers.
     %
-:- pred finish_if_then_else(prog_context::in, hlds_goal::in, hlds_goal::out,
-    hlds_goal::in, hlds_goal::out, svar_info::in,
-    svar_info::in, svar_info::in, svar_info::in, svar_info::out,
+:- pred svar_finish_if_then_else(prog_context::in,
+    hlds_goal::in, hlds_goal::out, hlds_goal::in, hlds_goal::out,
+    svar_info::in, svar_info::in, svar_info::in, svar_info::in, svar_info::out,
     prog_varset::in, prog_varset::out) is det.
 
-:- pred finish_if_then_else_goal_condition(svars::in,
+:- pred svar_finish_if_then_else_goal_condition(svars::in,
     svar_info::in, svar_info::in, svar_info::out, svar_info::out) is det.
 
-:- pred finish_if_then_else_expr_condition(svar_info::in,
+:- pred svar_finish_if_then_else_expr_condition(svar_info::in,
     svar_info::in, svar_info::out) is det.
 
-:- pred finish_if_then_else_expr_then_goal(svars::in,
+:- pred svar_finish_if_then_else_expr_then_goal(svars::in,
     svar_info::in, svar_info::in, svar_info::out) is det.
 
     % We assume that a negation updates all state variables in scope,
     % so we construct new mappings for the state variables and then
     % add unifiers from their pre-negated goal mappings.
     %
-:- pred finish_negation(svar_info::in, svar_info::in, svar_info::out) is det.
+:- pred svar_finish_negation(svar_info::in, svar_info::in, svar_info::out)
+    is det.
 
     % We have to make sure that all arms of a disjunction produce the
     % same state variable bindings by adding unifiers as necessary.
     %
-:- pred finish_disjunction(prog_context::in, prog_varset::in,
-    hlds_goal_svar_infos::in, hlds_goals::out, svar_info::out) is det.
+:- pred svar_finish_disjunction(prog_context::in, prog_varset::in,
+    hlds_goal_svar_infos::in, list(hlds_goal)::out, svar_info::out) is det.
 
     % We treat equivalence goals as if they were negations (they are
     % in a negated context after all.)
     %
-:- pred finish_equivalence(svar_info::in, svar_info::in, svar_info::out)
+:- pred svar_finish_equivalence(svar_info::in, svar_info::in, svar_info::out)
     is det.
 
     % We prepare for a call by setting the ctxt to in_atom.  If we're
     % already in an atom then we inherit the parent's set of "updated"
     % state variables.
     %
-:- pred prepare_for_call(svar_info::in, svar_info::out) is det.
+:- pred svar_prepare_for_call(svar_info::in, svar_info::out) is det.
 
     % When we finish a call, we're either still inside the
     % atomic formula, in which case we simply propagate the set of
@@ -215,13 +214,13 @@
     % been processing a function call which must appear as an
     % expression and hence occur inside an atomic context.)
     %
-:- pred finish_call(prog_varset::in, prog_varset::out,
+:- pred svar_finish_call(prog_varset::in, prog_varset::out,
     svar_info::in, svar_info::out) is det.
 
-:- pred prepare_for_if_then_else_goal(svars::in,
+:- pred svar_prepare_for_if_then_else_goal(svars::in,
     prog_varset::in, prog_varset::out, svar_info::in, svar_info::out) is det.
 
-:- pred finish_if_then_else_goal_then_goal(svars::in,
+:- pred svar_finish_if_then_else_goal_then_goal(svars::in,
     svar_info::in, svar_info::in, svar_info::out) is det.
 
     % The condition of an if-then-else expression is a goal in which
@@ -229,7 +228,7 @@
     % may use local state variables introduced via an explicit
     % quantifier.)  The StateVars are local to the condition and then-goal.
     %
-:- pred prepare_for_if_then_else_expr(svars::in,
+:- pred svar_prepare_for_if_then_else_expr(svars::in,
     prog_varset::in, prog_varset::out, svar_info::in, svar_info::out) is det.
 
     % Having finished processing one source-level atomic conjunct, prepare
@@ -250,7 +249,7 @@
     %
     %   p(X0, X1) and [!.X -> X1, !:X -> X2]
     %
-:- pred prepare_for_next_conjunct(svar_set::in,
+:- pred svar_prepare_for_next_conjunct(svar_set::in,
     prog_varset::in, prog_varset::out, svar_info::in, svar_info::out) is det.
 
     % Given a list of argument terms, substitute !.X and !:X with
@@ -305,6 +304,7 @@
 :- import_module int.
 :- import_module pair.
 :- import_module string.
+:- import_module svmap.
 :- import_module term.
 :- import_module varset.
 
@@ -316,16 +316,16 @@
 :- mode in `has_svar_colon_mapping_for` in is semidet.
 
 SInfo `has_svar_colon_mapping_for` StateVar :-
-    SInfo ^ colon `contains` StateVar.
+    SInfo ^ svar_colon `contains` StateVar.
 SInfo `has_svar_colon_mapping_for` StateVar :-
-    SInfo ^ ctxt = in_atom(_, ParentSInfo),
+    SInfo ^ svar_ctxt = in_atom(_, ParentSInfo),
     ParentSInfo `has_svar_colon_mapping_for` StateVar.
 
 :- func svar_info `with_updated_svar` svar = svar_info.
 
 SInfo `with_updated_svar` StateVar =
-    ( SInfo ^ ctxt =  in_atom(UpdatedStateVars, ParentSInfo) ->
-        SInfo ^ ctxt := in_atom(set.insert(UpdatedStateVars, StateVar),
+    ( SInfo ^ svar_ctxt =  in_atom(UpdatedStateVars, ParentSInfo) ->
+        SInfo ^ svar_ctxt := in_atom(set.insert(UpdatedStateVars, StateVar),
             ParentSInfo)
     ;
         SInfo
@@ -333,18 +333,24 @@
 
 %-----------------------------------------------------------------------------%
 
-dot(Context, StateVar, Var, !VarSet, !SInfo, !Specs) :-
-    ( !.SInfo ^ ctxt = in_head ->
-        ( !.SInfo ^ dot ^ elem(StateVar) = Var0 ->
-            Var = Var0
+svar_dot(Context, StateVar, Var, !VarSet, !SInfo, !Specs) :-
+    SVarContext = !.SInfo ^ svar_ctxt,
+    DotMap = !.SInfo ^ svar_dot,
+    (
+        SVarContext = in_head,
+        ( map.search(DotMap, StateVar, VarPrime) ->
+            Var = VarPrime
         ;
             new_dot_state_var(StateVar, Var, !VarSet, !SInfo)
         )
     ;
-        ( !.SInfo ^ dot ^ elem(StateVar) = Var0 ->
-            Var = Var0
-        ; !.SInfo ^ external_dot ^ elem(StateVar) = Var0 ->
-            Var = Var0
+        ( SVarContext = in_body
+        ; SVarContext = in_atom(_, _)
+        ),
+        ( map.search(DotMap, StateVar, VarPrime) ->
+            Var = VarPrime
+        ; map.search(!.SInfo ^ svar_readonly_dot, StateVar, VarPrime) ->
+            Var = VarPrime
         ; !.SInfo `has_svar_colon_mapping_for` StateVar ->
             new_dot_state_var(StateVar, Var, !VarSet, !SInfo),
             report_uninitialized_state_var(Context, !.VarSet, StateVar, !Specs)
@@ -357,28 +363,36 @@
 
 %-----------------------------------------------------------------------------%
 
-colon(Context, StateVar, Var, !VarSet, !SInfo, !Specs) :-
-    ( !.SInfo ^ ctxt = in_head ->
-        ( !.SInfo ^ colon ^ elem(StateVar) = Var0 ->
-            Var = Var0
+svar_colon(Context, StateVar, Var, !VarSet, !SInfo, !Specs) :-
+    SVarContext = !.SInfo ^ svar_ctxt,
+    ColonMap0 = !.SInfo ^ svar_colon,
+    (
+        SVarContext = in_head,
+        ( map.search(ColonMap0, StateVar, VarPrime) ->
+            Var = VarPrime
         ;
             new_final_state_var(StateVar, Var, !VarSet, !SInfo)
         )
     ;
-        ( !.SInfo ^ colon ^ elem(StateVar) = Var0 ->
-            Var = Var0,
+        ( SVarContext = in_body
+        ; SVarContext = in_atom(_, _)
+        ),
+        ( map.search(ColonMap0, StateVar, VarPrime) ->
+            Var = VarPrime,
             !:SInfo = !.SInfo `with_updated_svar` StateVar
         ;
+            % Return a dummy variable, and set up a dummy mapping: there is
+            % no point in mentioning this error twice.
             Var = StateVar,
-            % Set up a dummy mapping: there's no point
-            % in mentioning this error twice.
-            !:SInfo = ( !.SInfo ^ colon ^ elem(StateVar) := Var ),
-            ( !.SInfo ^ external_dot `contains` StateVar ->
-                PError = report_illegal_state_var_update
+            map.det_insert(ColonMap0, StateVar, Var, ColonMap),
+            !SInfo ^ svar_colon := ColonMap,
+            ( map.contains(!.SInfo ^ svar_readonly_dot, StateVar) ->
+                report_illegal_state_var_update(Context, !.VarSet, StateVar,
+                    !Specs)
             ;
-                PError = report_non_visible_state_var(":")
-            ),
-            PError(Context, !.VarSet, StateVar, !Specs)
+                report_non_visible_state_var(":", Context, !.VarSet, StateVar,
+                    !Specs)
+            )
         )
     ).
 
@@ -399,21 +413,21 @@
     prog_varset::in, prog_varset::out, svar_info::in, svar_info::out) is det.
 
 new_dot_state_var(StateVar, VarD, !VarSet, !SInfo) :-
-    N     = !.SInfo ^ num,
+    N     = !.SInfo ^ svar_num,
     Name  = varset.lookup_name(!.VarSet, StateVar),
     NameD = string.format("STATE_VARIABLE_%s_%d", [s(Name), i(N)]),
     varset.new_named_var(!.VarSet, NameD, VarD, !:VarSet),
-    !:SInfo = ( !.SInfo ^ dot ^ elem(StateVar) := VarD ).
+    !:SInfo = ( !.SInfo ^ svar_dot ^ elem(StateVar) := VarD ).
 
 :- pred new_colon_state_var(svar::in, prog_var::out,
     prog_varset::in, prog_varset::out, svar_info::in, svar_info::out) is det.
 
 new_colon_state_var(StateVar, VarC, !VarSet, !SInfo) :-
-    N     = !.SInfo ^ num,
+    N     = !.SInfo ^ svar_num,
     Name  = varset.lookup_name(!.VarSet, StateVar),
     NameC = string.format("STATE_VARIABLE_%s_%d", [s(Name), i(N)]),
     varset.new_named_var(!.VarSet, NameC, VarC, !:VarSet),
-    !:SInfo = ( !.SInfo ^ colon ^ elem(StateVar) := VarC ).
+    !:SInfo = ( !.SInfo ^ svar_colon ^ elem(StateVar) := VarC ).
 
 :- pred new_final_state_var(svar::in, prog_var::out,
     prog_varset::in, prog_varset::out, svar_info::in, svar_info::out) is det.
@@ -422,64 +436,66 @@
     Name  = varset.lookup_name(!.VarSet, StateVar),
     NameC = string.format("STATE_VARIABLE_%s",    [s(Name)]),
     varset.new_named_var(!.VarSet, NameC, VarC, !:VarSet),
-    !:SInfo = ( !.SInfo ^ colon ^ elem(StateVar) := VarC ).
+    !:SInfo = ( !.SInfo ^ svar_colon ^ elem(StateVar) := VarC ).
 
 %-----------------------------------------------------------------------------%
 
-prepare_for_head(new_svar_info).
+svar_prepare_for_head(new_svar_info).
 
 %-----------------------------------------------------------------------------%
 
-prepare_for_lambda(!SInfo) :-
-    %
-    % Construct the new external_dots mapping by overlaying the current dots
-    % mapping onto the existing external_dots mapping.  We cannot just throw
-    % the existing external_dots mapping away because otherwise referring to
+svar_prepare_for_lambda(!SInfo) :-
+    % Construct the new readonly_dots mapping by overlaying the current dots
+    % mapping onto the existing readonly_dots mapping.  We cannot just throw
+    % the existing readonly_dots mapping away because otherwise referring to
     % externals from within closures that are nested more than one level deep
     % will not work.
-    %
-    NewExternals = map.overlay(!.SInfo ^ external_dot, !.SInfo ^ dot),
-    !:SInfo = ( new_svar_info ^ external_dot := NewExternals).
+    NewExternals =
+        map.overlay(!.SInfo ^ svar_readonly_dot, !.SInfo ^ svar_dot),
+    !:SInfo = new_svar_info,
+    !SInfo ^ svar_readonly_dot := NewExternals.
 
 %-----------------------------------------------------------------------------%
 
-prepare_for_body(FinalMap, !VarSet, !SInfo) :-
-    FinalMap  = !.SInfo ^ colon,
-    N         = !.SInfo ^ num + 1,
-    StateVars = list.merge_and_remove_dups(map.keys(!.SInfo ^ colon),
-        map.keys(!.SInfo ^ dot)),
+svar_prepare_for_body(FinalMap, !VarSet, !SInfo) :-
+    FinalMap  = !.SInfo ^ svar_colon,
+    N         = !.SInfo ^ svar_num + 1,
+    ColonKeys = map.keys(!.SInfo ^ svar_colon),
+    DotKeys   = map.keys(!.SInfo ^ svar_dot),
+    StateVars = list.merge_and_remove_dups(ColonKeys, DotKeys),
     next_svar_mappings(N, StateVars, !VarSet, Colon),
-    !:SInfo   = !.SInfo ^ ctxt  := in_body,
-    !:SInfo   = !.SInfo ^ num   := N,
-    !:SInfo   = !.SInfo ^ colon := Colon.
+    !:SInfo   = !.SInfo ^ svar_ctxt  := in_body,
+    !:SInfo   = !.SInfo ^ svar_num   := N,
+    !:SInfo   = !.SInfo ^ svar_colon := Colon.
 
 %-----------------------------------------------------------------------------%
 
-finish_goals(Context, FinalSVarMap, Goals0, Goal, SInfo) :-
+svar_finish_goals(Context, FinalSVarMap, Goals0, Goal, SInfo) :-
     goal_info_init(Context, GoalInfo),
     list.map(goal_to_conj_list, Goals0, GoalsAsConjList),
     Unifiers = svar_unifiers(yes(feature_dont_warn_singleton), Context,
-        FinalSVarMap, SInfo ^ dot),
+        FinalSVarMap, SInfo ^ svar_dot),
     Goals1 = list.condense(GoalsAsConjList),
     Goals  = Goals1 ++ Unifiers,
     conj_list_to_goal(Goals, GoalInfo, Goal).
 
 :- func svar_unifiers(maybe(goal_feature), prog_context, svar_map, svar_map)
-    = hlds_goals.
+    = list(hlds_goal).
 
-svar_unifiers(MaybeFeature, Context, LHSMap, RHSMap) =
-    map.foldl(add_svar_unifier(MaybeFeature, RHSMap, Context), LHSMap, []).
+svar_unifiers(MaybeFeature, Context, LHSMap, RHSMap) = Unifiers :-
+    map.foldl(add_svar_unifier(MaybeFeature, RHSMap, Context), LHSMap,
+        [], Unifiers).
+
+:- pred add_svar_unifier(maybe(goal_feature)::in, svar_map::in,
+    prog_context::in, svar::in, prog_var::in,
+    list(hlds_goal)::in, list(hlds_goal)::out) is det.
 
-:- func add_svar_unifier(maybe(goal_feature), svar_map, prog_context,
-    svar, prog_var, hlds_goals) = hlds_goals.
-
-add_svar_unifier(MaybeFeature, RHSMap, Context, StateVar, Var, Unifiers0)
-        = Unifiers :-
-    ( RHSVar = RHSMap ^ elem(StateVar) ->
+add_svar_unifier(MaybeFeature, RHSMap, Context, StateVar, Var, !Unifiers) :-
+    ( map.search(RHSMap, StateVar, RHSVar) ->
         Unifier = svar_unification(MaybeFeature, Context, Var, RHSVar),
-        Unifiers = [Unifier | Unifiers0]
+        !:Unifiers = [Unifier | !.Unifiers]
     ;
-        Unifiers = Unifiers0
+        true
     ).
 
 %-----------------------------------------------------------------------------%
@@ -501,32 +517,26 @@
 %-----------------------------------------------------------------------------%
 
 prepare_for_local_state_vars(StateVars, !VarSet, !SInfo) :-
-    list.foldl2(add_new_local_state_var, StateVars, !VarSet, !SInfo).
-
-:- pred add_new_local_state_var(svar::in,
-    prog_varset::in, prog_varset::out, svar_info::in, svar_info::out) is det.
-
-add_new_local_state_var(StateVar, !VarSet, !SInfo) :-
-    new_colon_state_var(StateVar, _, !VarSet, !SInfo).
+    list.map_foldl2(new_colon_state_var, StateVars, _, !VarSet, !SInfo).
 
 %-----------------------------------------------------------------------------%
 
 finish_local_state_vars(StateVars, Vars, SInfoBefore, !SInfo) :-
-    InitDot   = !.SInfo ^ dot,
-    InitColon = !.SInfo ^ colon,
-    Dots    = svar_mappings(InitDot, StateVars),
-    Colons  = svar_mappings(InitColon, StateVars),
-    Vars    = list.sort_and_remove_dups(Dots ++ Colons),
-    !:SInfo = !.SInfo ^ dot :=
-        del_locals(StateVars, SInfoBefore ^ dot, InitDot),
-    !:SInfo = !.SInfo ^ colon :=
-        del_locals(StateVars, SInfoBefore ^ colon, InitColon).
+    CurDotMap   = !.SInfo ^ svar_dot,
+    CurColonMap = !.SInfo ^ svar_colon,
+    DotVars    = svar_mappings(CurDotMap, StateVars),
+    ColonVars  = svar_mappings(CurColonMap, StateVars),
+    Vars    = list.sort_and_remove_dups(DotVars ++ ColonVars),
+    NewDotMap   = del_locals(StateVars, SInfoBefore ^ svar_dot, CurDotMap),
+    NewColonMap = del_locals(StateVars, SInfoBefore ^ svar_colon, CurColonMap),
+    !SInfo ^ svar_dot   := NewDotMap,
+    !SInfo ^ svar_colon := NewColonMap.
 
 :- func svar_mappings(svar_map, svars) = svars.
 
 svar_mappings(_, []) = [].
 svar_mappings(Map, [StateVar | StateVars]) =
-    ( Map ^ elem(StateVar) = Var ->
+    ( map.search(Map, StateVar, Var) ->
         [Var | svar_mappings(Map, StateVars)]
     ;
         svar_mappings(Map, StateVars)
@@ -536,10 +546,11 @@
 
 del_locals(StateVars, MapBefore, Map) =
     list.foldl(
-        func(K, M) =
-            ( if   MapBefore ^ elem(K) =  V
-              then M         ^ elem(K) := V
-              else map.delete(M, K)
+        func(K, M0) = M :-
+            ( map.search(MapBefore, K, V) ->
+                map.set(M0, K, V, M)
+            ;
+                map.delete(M0, K, M)
             ),
         StateVars,
         Map
@@ -547,61 +558,64 @@
 
 %-----------------------------------------------------------------------------%
 
-finish_if_then_else(Context, Then0, Then, Else0, Else,
+svar_finish_if_then_else(Context, Then0, Then, Else0, Else,
         SInfo0, SInfoC, SInfoT0, SInfoE, SInfo, !VarSet) :-
-
-        % Add unifiers to the Then arm for state variables that
-        % acquired new mappings in the condition, but not in the
-        % Them arm itself.  This is because the new mappings
-        % appear only in a negated context.
-        %
-    StateVars = list.merge_and_remove_dups(map.keys(SInfoT0 ^ dot),
-         map.keys(SInfoE  ^ dot)),
+    % Add unifiers to the Then arm for state variables that acquired
+    % new mappings in the condition, but not in the Them arm itself.
+    % This is because the new mappings appear only in a negated context.
+    StateVars = list.merge_and_remove_dups(map.keys(SInfoT0 ^ svar_dot),
+         map.keys(SInfoE  ^ svar_dot)),
     Then0 = hlds_goal(_, GoalInfo),
     goal_to_conj_list(Then0, Thens0),
     add_then_arm_specific_unifiers(Context, StateVars,
         SInfo0, SInfoC, SInfoT0, SInfoT, Thens0, Thens, !VarSet),
     conj_list_to_goal(Thens, GoalInfo, Then1),
 
-        % Calculate the svar_info with the highest numbered
-        % mappings from each arm.
-        %
+    % Calculate the svar_info with the highest numbered mappings from each arm.
     DisjSInfos = [{Then1, SInfoT}, {Else0, SInfoE}],
-    SInfo      = reconciled_disj_svar_info(!.VarSet, DisjSInfos),
+    SInfo      = reconcile_disj_svar_info(!.VarSet, DisjSInfos),
 
-        % Add unifiers to each arm to ensure they both construct
-        % the same final state variable mappings.
-        %
-    Then       = add_disj_unifiers(Context, SInfo, StateVars,
-                {Then1, SInfoT}),
-    Else       = add_disj_unifiers(Context, SInfo, StateVars,
-                {Else0, SInfoE}).
-
-    % If a new mapping was produced for state variable X in the
-    % condition-goal (i.e. the condition refers to !:X), but not
-    % in the then-goal, then we have to add a new unifier !:X = !.X
-    % to the then-goal because the new mapping was created in a
-    % negated context.
+    % Add unifiers to each arm to ensure they both construct the same
+    % final state variable mappings.
+    Then = add_disj_unifiers(Context, SInfo, StateVars, {Then1, SInfoT}),
+    Else = add_disj_unifiers(Context, SInfo, StateVars, {Else0, SInfoE}).
+
+    % If a new mapping was produced for state variable X in the condition-goal
+    % (i.e. the condition refers to !:X), but not in the then-goal, then
+    % we have to add a new unifier !:X = !.X to the then-goal because the
+    % new mapping was created in a negated context.
     %
 :- pred add_then_arm_specific_unifiers(prog_context::in, svars::in,
     svar_info::in, svar_info::in, svar_info::in, svar_info::out,
     hlds_goals::in, hlds_goals::out, prog_varset::in, prog_varset::out) is det.
 
-add_then_arm_specific_unifiers(_, [], _, _, SInfoT, SInfoT,
-        Thens, Thens, VarSet, VarSet).
-
+add_then_arm_specific_unifiers(_, [], _, _, !SInfoT, !Thens, !VarSet).
 add_then_arm_specific_unifiers(Context, [StateVar | StateVars],
         SInfo0, SInfoC, !SInfoT, !Thens, !VarSet) :-
-    (   % the condition refers to !:X, but the then-goal doesn't
-        SInfoC ^ dot ^ elem(StateVar) \= SInfo0 ^ dot ^ elem(StateVar),
-        !.SInfoT ^ dot ^ elem(StateVar) = SInfoC ^ dot ^ elem(StateVar)
+    (
+        % The condition refers to !:X, but the then-goal doesn't.
+
+        % If the condition refers to !:X, then X will appear in the map after
+        % the condition, and therefore in the following map at the end of the
+        % else too.
+        map.search(SInfoC ^ svar_dot, StateVar, DotC),
+        map.search(!.SInfoT ^ svar_dot, StateVar, DotT),
+        DotT = DotC,
+
+        % We know that the condition refers to !:X if either X did not appear
+        % in the map before the if-then-else, or if it did, but with a
+        % different program variable than at the end of the condition.
+        \+ (
+            map.search(SInfo0 ^ svar_dot, StateVar, Dot0),
+            DotC = Dot0
+        )
     ->
-        % add a new unifier !:X = !.X
-        Dot0 = !.SInfoT ^ dot ^ det_elem(StateVar),
-        new_colon_state_var(StateVar, Dot, !VarSet, !SInfoT),
-        !:Thens = [svar_unification(yes(feature_dont_warn_singleton), Context,
-            Dot, Dot0) | !.Thens],
-        prepare_for_next_conjunct(set.make_singleton_set(StateVar),
+        % Add a new unifier !:X = !.X.
+        new_colon_state_var(StateVar, NewDotT, !VarSet, !SInfoT),
+        ThenUnifier = svar_unification(yes(feature_dont_warn_singleton),
+            Context, NewDotT, DotT),
+        !:Thens = [ThenUnifier | !.Thens],
+        svar_prepare_for_next_conjunct(set.make_singleton_set(StateVar),
             !VarSet, !SInfoT)
     ;
         true
@@ -614,8 +628,8 @@
 :- pred next_svar_mappings(int::in, svars::in,
     prog_varset::in, prog_varset::out, svar_map::out) is det.
 
-next_svar_mappings(N, StateVars, VarSet0, VarSet, Map) :-
-    next_svar_mappings_2(N, StateVars, VarSet0, VarSet, map.init, Map).
+next_svar_mappings(N, StateVars, !VarSet, Map) :-
+    next_svar_mappings_2(N, StateVars, !VarSet, map.init, Map).
 
 :- pred next_svar_mappings_2(int::in, svars::in,
     prog_varset::in, prog_varset::out, svar_map::in, svar_map::out) is det.
@@ -627,161 +641,151 @@
 
 %-----------------------------------------------------------------------------%
 
-finish_negation(SInfoBefore, SInfoNeg, SInfo) :-
-    SInfo = (( SInfoBefore ^ num   := SInfoNeg ^ num   )
-                           ^ colon := SInfoNeg ^ colon ).
+svar_finish_negation(SInfoBefore, SInfoNeg, !:SInfo) :-
+    !:SInfo = SInfoBefore,
+    !SInfo ^ svar_num   := SInfoNeg ^ svar_num,
+    !SInfo ^ svar_colon := SInfoNeg ^ svar_colon.
 
 %-----------------------------------------------------------------------------%
 
-finish_disjunction(Context, VarSet, DisjSInfos, Disjs, SInfo) :-
-    SInfo      = reconciled_disj_svar_info(VarSet, DisjSInfos),
-    StateVars  = map.keys(SInfo ^ dot),
-    Disjs      = list.map( add_disj_unifiers(Context, SInfo, StateVars),
-        DisjSInfos).
+svar_finish_disjunction(Context, VarSet, DisjSInfos, Disjs, SInfo) :-
+    SInfo = reconcile_disj_svar_info(VarSet, DisjSInfos),
+    map.keys(SInfo ^ svar_dot, StateVars),
+    Disjs = list.map(add_disj_unifiers(Context, SInfo, StateVars), DisjSInfos).
 
     % Each arm of a disjunction may have a different mapping for
-    % !.X and/or !:X.  The reconciled svar_info for the disjunction
-    % takes the highest numbered mapping for each disjunct (each
-    % state variable mapping for !.X or !:X will have a name of
-    % the form `STATE_VARIABLE_X_n' for some number `n'.)
+    % !.X and/or !:X. The reconciled svar_info for the disjunction takes
+    % the highest numbered mapping for each disjunct (each state variable
+    % mapping for !.X or !:X will have a name of the form `STATE_VARIABLE_X_n'
+    % for some number `n'.)
     %
-:- func reconciled_disj_svar_info(prog_varset, hlds_goal_svar_infos) =
+:- func reconcile_disj_svar_info(prog_varset, hlds_goal_svar_infos) =
     svar_info.
 
-reconciled_disj_svar_info(_, []) = _ :-
-    unexpected(this_file, "reconciled_disj_svar_info: empty disjunct list").
-
-reconciled_disj_svar_info(VarSet, [{_, SInfo0} | DisjSInfos]) = SInfo :-
-
-        % We compute the set of final !. and !: state variables
-        % over the whole disjunction (not all arms will necessarily
-        % include !. and !: mappings for all state variables).
-        %
-    Dots0   = set.sorted_list_to_set(map.keys(SInfo0 ^ dot)),
-    Colons0 = set.sorted_list_to_set(map.keys(SInfo0 ^ colon)),
-    Dots    = union_dot_svars(Dots0, DisjSInfos),
-    Colons  = union_colon_svars(Colons0, DisjSInfos),
-
-        % Then we update SInfo0 to take the highest numbered
-        % !. and !: mapping for each state variable.
-        %
-    SInfo   = list.foldl(reconciled_svar_infos(VarSet, Dots, Colons),
-        DisjSInfos, SInfo0).
-
-:- func union_dot_svars(svar_set, hlds_goal_svar_infos) = svar_set.
-
-union_dot_svars(Dots, []                       ) = Dots.
-union_dot_svars(Dots, [{_, SInfo} | DisjSInfos]) =
-    union_dot_svars(
-        Dots `union` set.sorted_list_to_set(map.keys(SInfo ^ dot)),
-        DisjSInfos
-    ).
-
-:- func union_colon_svars(svar_set, hlds_goal_svar_infos) = svar_set.
-
-union_colon_svars(Colons, []                       ) = Colons.
-union_colon_svars(Colons, [{_, SInfo} | DisjSInfos]) =
-    union_colon_svars(
-        Colons `union` set.sorted_list_to_set(map.keys(SInfo ^ colon)),
-        DisjSInfos
-    ).
-
-:- func reconciled_svar_infos(prog_varset, svar_set, svar_set,
-    hlds_goal_svar_info, svar_info) = svar_info.
-
-reconciled_svar_infos(VarSet, Dots, Colons,
-        {_, SInfoX}, SInfo0) = SInfo :-
-    SInfo1 = set.fold(reconciled_svar_infos_dots(VarSet, SInfoX),
-        Dots, SInfo0),
-    SInfo2 = set.fold(reconciled_svar_infos_colons(VarSet, SInfoX),
-        Colons, SInfo1),
-    SInfo  = ( SInfo2 ^ num := max(SInfo0 ^ num, SInfoX ^ num) ).
+reconcile_disj_svar_info(_, []) = _ :-
+    unexpected(this_file, "reconcile_disj_svar_info: empty disjunct list").
+reconcile_disj_svar_info(VarSet, [DisjSInfo | DisjSInfos]) = SInfo :-
+    % We compute the set of final !. and !: state variables over the whole
+    % disjunction (not all arms will necessarily include !. and !: mappings
+    % for all state variables).
+    DisjSInfo = {_, SInfo0},
+    Dots0   = set.sorted_list_to_set(map.keys(SInfo0 ^ svar_dot)),
+    Colons0 = set.sorted_list_to_set(map.keys(SInfo0 ^ svar_colon)),
+    union_dot_colon_svars(DisjSInfos, Dots0, Dots, Colons0, Colons),
+
+    % Then we update SInfo0 to take the highest numbered !. and !: mapping
+    % for each state variable.
+    list.foldl(reconcile_svar_infos(VarSet, Dots, Colons), DisjSInfos,
+        SInfo0, SInfo).
+
+:- pred union_dot_colon_svars(hlds_goal_svar_infos::in,
+    svar_set::in, svar_set::out, svar_set::in, svar_set::out) is det.
+
+union_dot_colon_svars([], !Dots, !Colons).
+union_dot_colon_svars([DisjSInfo | DisjSInfos], !Dots, !Colons) :-
+    DisjSInfo = {_, SInfo},
+    set.union(set.sorted_list_to_set(map.keys(SInfo ^ svar_dot)), !Dots),
+    set.union(set.sorted_list_to_set(map.keys(SInfo ^ svar_colon)), !Colons),
+    union_dot_colon_svars(DisjSInfos, !Dots, !Colons).
+
+:- pred reconcile_svar_infos(prog_varset::in, svar_set::in, svar_set::in,
+    hlds_goal_svar_info::in, svar_info::in, svar_info::out) is det.
+
+reconcile_svar_infos(VarSet, Dots, Colons, {_, SInfoX}, !SInfo) :-
+    InitNum = !.SInfo ^ svar_num,
+    XNum = SInfoX ^ svar_num,
+    set.fold(reconcile_svar_infos_dots(VarSet, SInfoX), Dots, !SInfo),
+    set.fold(reconcile_svar_infos_colons(VarSet, SInfoX), Colons, !SInfo),
+    !SInfo ^ svar_num := max(InitNum, XNum).
 
-:- func reconciled_svar_infos_dots(prog_varset, svar_info, svar, svar_info)
-    = svar_info.
+:- pred reconcile_svar_infos_dots(prog_varset::in, svar_info::in, svar::in,
+    svar_info::in, svar_info::out) is det.
 
-reconciled_svar_infos_dots(VarSet, SInfoX, StateVar, SInfo0) = SInfo :-
+reconcile_svar_infos_dots(VarSet, SInfoX, StateVar, !SInfo) :-
+    DotMapX = SInfoX ^ svar_dot,
+    DotMap0 = !.SInfo ^ svar_dot,
     (
-        DotX = SInfoX ^ dot ^ elem(StateVar),
-        Dot0 = SInfo0 ^ dot ^ elem(StateVar)
+        map.search(DotMapX, StateVar, DotX),
+        map.search(DotMap0, StateVar, Dot0)
     ->
-        NameX = varset.lookup_name(VarSet, DotX) `with_type` string,
-        Name0 = varset.lookup_name(VarSet, Dot0) `with_type` string,
+        varset.lookup_name(VarSet, DotX, NameX),
+        varset.lookup_name(VarSet, Dot0, Name0),
         compare_svar_names(RDot, NameX, Name0),
         (
-            RDot  = (<),
-            SInfo = ( SInfo0 ^ dot ^ elem(StateVar) := Dot0 )
-        ;
-            RDot  = (=),
-            SInfo = SInfo0
+            ( RDot  = (<)
+            ; RDot  = (=)
+            )
         ;
             RDot  = (>),
-            SInfo = ( SInfo0 ^ dot ^ elem(StateVar) := DotX )
+            map.det_update(DotMap0, StateVar, DotX, DotMap),
+            !SInfo ^ svar_dot := DotMap
         )
     ;
-        SInfo = SInfo0
+        true
     ).
 
-:- func reconciled_svar_infos_colons(prog_varset, svar_info, svar, svar_info)
-    = svar_info.
+:- pred reconcile_svar_infos_colons(prog_varset::in, svar_info::in, svar::in,
+    svar_info::in, svar_info::out) is det.
 
-reconciled_svar_infos_colons(VarSet, SInfoX, StateVar, SInfo0) = SInfo :-
+reconcile_svar_infos_colons(VarSet, SInfoX, StateVar, !SInfo) :-
+    ColonMapX = SInfoX ^ svar_colon,
+    ColonMap0 = !.SInfo ^ svar_colon,
     (
-        ColonX = SInfoX ^ colon ^ elem(StateVar),
-        Colon0 = SInfo0 ^ colon ^ elem(StateVar)
+        map.search(ColonMapX, StateVar, ColonX),
+        map.search(ColonMap0, StateVar, Colon0)
     ->
-        NameX = varset.lookup_name(VarSet, ColonX) `with_type` string,
-        Name0 = varset.lookup_name(VarSet, Colon0) `with_type` string,
+        varset.lookup_name(VarSet, ColonX, NameX),
+        varset.lookup_name(VarSet, Colon0, Name0),
         compare_svar_names(RColon, NameX, Name0),
         (
-            RColon = (<),
-            SInfo  = ( SInfo0 ^ colon ^ elem(StateVar) := Colon0 )
-        ;
-            RColon = (=),
-            SInfo  = SInfo0
+            ( RColon = (<)
+            ; RColon = (=)
+            )
         ;
             RColon = (>),
-            SInfo  = ( SInfo0 ^ colon ^ elem(StateVar) := ColonX )
+            map.det_update(ColonMap0, StateVar, ColonX, ColonMap),
+            !SInfo ^ svar_colon := ColonMap
         )
     ;
-        SInfo = SInfo0
+        true
     ).
 
 :- func add_disj_unifiers(prog_context, svar_info, svars, hlds_goal_svar_info)
     = hlds_goal.
 
 add_disj_unifiers(Context, SInfo, StateVars, {GoalX, SInfoX}) = Goal :-
-    Unifiers = list.foldl(add_disj_unifier(Context, SInfo, SInfoX),
-        StateVars, []),
+    Unifiers0 = [],
+    list.foldl(add_disj_unifier(Context, SInfo, SInfoX), StateVars,
+        Unifiers0, Unifiers),
     GoalX = hlds_goal(_, GoalInfo),
     goal_to_conj_list(GoalX, GoalsX),
     conj_list_to_goal(GoalsX ++ Unifiers, GoalInfo, Goal).
 
-:- func add_disj_unifier(prog_context, svar_info, svar_info, svar, hlds_goals)
-    = hlds_goals.
+:- pred add_disj_unifier(prog_context::in, svar_info::in, svar_info::in,
+    svar::in, list(hlds_goal)::in, list(hlds_goal)::out) is det.
 
-add_disj_unifier(Context, SInfo, SInfoX, StateVar, Unifiers) =
+add_disj_unifier(Context, SInfo, SInfoX, StateVar, !Unifiers) :-
     (
-        Dot  = SInfo  ^ dot ^ elem(StateVar),
-        DotX = SInfoX ^ dot ^ elem(StateVar),
+        map.search(SInfo ^ svar_dot, StateVar, Dot),
+        map.search(SInfoX ^ svar_dot, StateVar, DotX),
         Dot \= DotX
     ->
-        [svar_unification(yes(feature_dont_warn_singleton), Context, Dot, DotX)
-            | Unifiers]
+        Unifier = svar_unification(yes(feature_dont_warn_singleton), Context,
+            Dot, DotX),
+        !:Unifiers = [Unifier | !.Unifiers]
     ;
-        Unifiers
+        true
     ).
 
 %-----------------------------------------------------------------------------%
 
-    % We implement a special purpose comparison for state variable
-    % names that compares the numbers appended at the right hand
-    % ends of the name strings.
-    %
-    % NOTE state variable names are either "..._X" or "..._X_N"
-    % where X is the name of the program variable used for the
-    % state variable and N is a decimal number with no leading
-    % zeroes.
+    % We implement a special purpose comparison for state variable names
+    % that compares the numbers appended at the right hand ends of the
+    % name strings.
+    %
+    % NOTE state variable names are either "..._X" or "..._X_N" where X is
+    % the name of the program variable used for the state variable and
+    % N is a decimal number with no leading zeroes.
     %
 :- pred compare_svar_names(comparison_result::out, string::in, string::in)
     is det.
@@ -812,126 +816,131 @@
 
 %-----------------------------------------------------------------------------%
 
-finish_equivalence(SInfoBefore, SInfoEqv, SInfo) :-
-    finish_negation(SInfoBefore, SInfoEqv, SInfo).
+svar_finish_equivalence(SInfoBefore, SInfoEqv, SInfo) :-
+    svar_finish_negation(SInfoBefore, SInfoEqv, SInfo).
 
 %-----------------------------------------------------------------------------%
 
-prepare_for_call(ParentSInfo, SInfo) :-
-    ( ParentSInfo ^ ctxt = in_atom(UpdatedStateVars, _GrandparentSInfo) ->
+svar_prepare_for_call(ParentSInfo, SInfo) :-
+    ( ParentSInfo ^ svar_ctxt = in_atom(UpdatedStateVars, _GrandparentSInfo) ->
         Ctxt = in_atom(UpdatedStateVars, ParentSInfo)
     ;
         Ctxt = in_atom(set.init, ParentSInfo)
     ),
-    SInfo = ParentSInfo ^ ctxt := Ctxt.
+    SInfo = ParentSInfo ^ svar_ctxt := Ctxt.
 
 %-----------------------------------------------------------------------------%
 
-finish_call(!VarSet, !SInfo) :-
-    ( !.SInfo ^ ctxt = in_atom(UpdatedStateVars, ParentSInfo0) ->
-        ParentSInfo = ( ParentSInfo0 ^ dot := !.SInfo ^ dot ),
-        ( ParentSInfo ^ ctxt = in_atom(_, GrandParentSInfo) ->
-            !:SInfo  = ( ParentSInfo ^ ctxt :=
+svar_finish_call(!VarSet, !SInfo) :-
+    ( !.SInfo ^ svar_ctxt = in_atom(UpdatedStateVars, ParentSInfo0) ->
+        ParentSInfo = ( ParentSInfo0 ^ svar_dot := !.SInfo ^ svar_dot ),
+        ( ParentSInfo ^ svar_ctxt = in_atom(_, GrandParentSInfo) ->
+            !:SInfo = ( ParentSInfo ^ svar_ctxt :=
                 in_atom(UpdatedStateVars, GrandParentSInfo) )
         ;
-            prepare_for_next_conjunct(UpdatedStateVars, !VarSet, ParentSInfo,
-                !:SInfo)
+            svar_prepare_for_next_conjunct(UpdatedStateVars, !VarSet,
+                ParentSInfo, !:SInfo)
         )
     ;
-        unexpected(this_file, "finish_call: ctxt is not in_atom")
+        unexpected(this_file, "svar_finish_call: ctxt is not in_atom")
     ).
 
 %-----------------------------------------------------------------------------%
 
-prepare_for_if_then_else_goal(StateVars, !VarSet, !SInfo) :-
+svar_prepare_for_if_then_else_goal(StateVars, !VarSet, !SInfo) :-
     prepare_for_local_state_vars(StateVars, !VarSet, !SInfo).
 
 %-----------------------------------------------------------------------------%
 
-finish_if_then_else_goal_condition(StateVars, SInfoBefore, SInfoA0, SInfoA,
-        SInfoB) :-
+svar_finish_if_then_else_goal_condition(StateVars, SInfoBefore,
+        SInfoA0, SInfoA, SInfoB) :-
     SInfoB = SInfoA0,
     finish_local_state_vars(StateVars, _, SInfoBefore, SInfoA0, SInfoA).
 
 %-----------------------------------------------------------------------------%
 
-finish_if_then_else_goal_then_goal(StateVars, SInfoBefore, SInfoB0, SInfoB) :-
+svar_finish_if_then_else_goal_then_goal(StateVars,
+        SInfoBefore, SInfoB0, SInfoB) :-
     finish_local_state_vars(StateVars, _, SInfoBefore, SInfoB0, SInfoB).
 
 %-----------------------------------------------------------------------------%
 
-prepare_for_if_then_else_expr(StateVars, !VarSet, !SInfo) :-
+svar_prepare_for_if_then_else_expr(StateVars, !VarSet, !SInfo) :-
     SInfo0 = !.SInfo,
-    !:SInfo = new_svar_info ^ ctxt := in_body,
-    !:SInfo = !.SInfo ^ external_dot := SInfo0 ^ dot,
-    !:SInfo = !.SInfo ^ num := SInfo0 ^ num,
+    !:SInfo = new_svar_info ^ svar_ctxt := in_body,
+    !:SInfo = !.SInfo ^ svar_readonly_dot := SInfo0 ^ svar_dot,
+    !:SInfo = !.SInfo ^ svar_num := SInfo0 ^ svar_num,
     prepare_for_local_state_vars(StateVars, !VarSet, !SInfo).
 
 %-----------------------------------------------------------------------------%
 
-finish_if_then_else_expr_condition(Before, !SInfo) :-
+svar_finish_if_then_else_expr_condition(Before, !SInfo) :-
     SInfo0 = !.SInfo,
-    !:SInfo = !.SInfo ^ external_dot := Before ^ external_dot,
-    !:SInfo = !.SInfo ^ dot := (SInfo0 ^ dot) `overlay` (Before ^ dot),
-    !:SInfo = !.SInfo ^ colon := (SInfo0 ^ colon) `overlay` (Before ^ colon),
-    !:SInfo = !.SInfo ^ ctxt := Before ^ ctxt.
+    !:SInfo = !.SInfo ^ svar_readonly_dot := Before ^ svar_readonly_dot,
+    !:SInfo = !.SInfo ^ svar_dot :=
+        (SInfo0 ^ svar_dot) `overlay` (Before ^ svar_dot),
+    !:SInfo = !.SInfo ^ svar_colon :=
+        (SInfo0 ^ svar_colon) `overlay` (Before ^ svar_colon),
+    !:SInfo = !.SInfo ^ svar_ctxt := Before ^ svar_ctxt.
 
 %-----------------------------------------------------------------------------%
 
-finish_if_then_else_expr_then_goal(StateVars, SInfoBefore, !SInfo) :-
+svar_finish_if_then_else_expr_then_goal(StateVars, SInfoBefore, !SInfo) :-
     finish_local_state_vars(StateVars, _, SInfoBefore, !SInfo).
 
 %-----------------------------------------------------------------------------%
 
-prepare_for_next_conjunct(UpdatedStateVars, !VarSet, !SInfo) :-
-    Dot0   = !.SInfo ^ dot,
-    Colon0 = !.SInfo ^ colon,
-    N      = !.SInfo ^ num + 1,
+svar_prepare_for_next_conjunct(UpdatedStateVars, !VarSet, !SInfo) :-
+    DotMap0   = !.SInfo ^ svar_dot,
+    ColonMap0 = !.SInfo ^ svar_colon,
+    N = !.SInfo ^ svar_num + 1,
     map.init(Nil),
-    map.foldl(next_dot_mapping(UpdatedStateVars, Dot0, Colon0), Colon0,
-        Nil, Dot),
-    map.foldl2(next_colon_mapping(UpdatedStateVars, Colon0, N), Colon0,
-        !VarSet, Nil, Colon),
-    !:SInfo  = !.SInfo ^ ctxt  := in_body,
-    !:SInfo  = !.SInfo ^ num   := N,
-    !:SInfo  = !.SInfo ^ dot   := Dot,
-    !:SInfo  = !.SInfo ^ colon := Colon.
-
-    % If the state variable has been updated (i.e. there was a !:X
-    % reference) then the next !.X mapping will be the current !:X
-    % mapping.
-    % Otherwise, preserve the current !.X mapping, if any (there
-    % may be none if, for example, the head only references !:X
-    % and there have been no prior references to !:X in the body.)
+    map.foldl(next_dot_mapping(UpdatedStateVars, DotMap0, ColonMap0),
+        ColonMap0, Nil, DotMap),
+    map.foldl2(next_colon_mapping(UpdatedStateVars, ColonMap0, N),
+        ColonMap0, !VarSet, Nil, ColonMap),
+    !:SInfo  = !.SInfo ^ svar_ctxt  := in_body,
+    !:SInfo  = !.SInfo ^ svar_num   := N,
+    !:SInfo  = !.SInfo ^ svar_dot   := DotMap,
+    !:SInfo  = !.SInfo ^ svar_colon := ColonMap.
+
+    % If the state variable has been updated (i.e. there was a !:X reference)
+    % then the next !.X mapping will be the current !:X mapping. Otherwise,
+    % preserve the current !.X mapping, if any (there may be none if,
+    % for example, the head only references !:X and there have been no prior
+    % references to !:X in the body.)
     %
 :- pred next_dot_mapping(svar_set::in, svar_map::in, svar_map::in, svar::in,
     prog_var::in, svar_map::in, svar_map::out) is det.
 
-next_dot_mapping(UpdatedStateVars, OldDot, OldColon, StateVar, _, Dot0, Dot) :-
+next_dot_mapping(UpdatedStateVars, OldDotMap, OldColonMap, StateVar, _,
+        !DotMap) :-
+    % XXX Should either of these svmap.sets be det_update or det_insert?
     ( UpdatedStateVars `contains` StateVar ->
-        Var = OldColon ^ det_elem(StateVar),
-        Dot = ( Dot0 ^ elem(StateVar) := Var )
-    ; Var = OldDot ^ elem(StateVar) ->
-        Dot = ( Dot0 ^ elem(StateVar) := Var )
-    ;
-        Dot = Dot0
+        map.lookup(OldColonMap, StateVar, Var),
+        svmap.set(StateVar, Var, !DotMap)
+    ; map.search(OldDotMap, StateVar, Var) ->
+        svmap.set(StateVar, Var, !DotMap)
+    ;
+        true
     ).
 
-    % If the state variable has been updated (i.e. there was a !:X
-    % reference) then create a new mapping for the next !:X.
-    % Otherwise, the next !:X mapping is the same as the current
-    % !:X mapping.
+    % If the state variable has been updated (i.e. there was a !:X reference)
+    % then create a new mapping for the next !:X. Otherwise, the next !:X
+    % mapping is the same as the current !:X mapping.
     %
 :- pred next_colon_mapping(svar_set::in, svar_map::in, int::in, svar::in,
     prog_var::in, prog_varset::in, prog_varset::out,
     svar_map::in, svar_map::out) is det.
 
 next_colon_mapping(UpdatedStateVars, OldColon, N, StateVar, _,
-        !VarSet, !Colon) :-
+        !VarSet, !ColonMap) :-
     ( UpdatedStateVars `contains` StateVar ->
-        next_svar_mapping(N, StateVar, _Var, !VarSet, !Colon)
+        next_svar_mapping(N, StateVar, _Var, !VarSet, !ColonMap)
     ;
-        !:Colon = ( !.Colon ^ elem(StateVar) := OldColon ^ det_elem(StateVar) )
+        map.lookup(OldColon, StateVar, Var),
+        % XXX Should this be svmap.det_update?
+        svmap.set(StateVar, Var, !ColonMap)
     ).
 
 :- pred next_svar_mapping(int::in, svar::in, prog_var::out,
@@ -941,25 +950,28 @@
     Name = string.format("STATE_VARIABLE_%s_%d",
         [s(varset.lookup_name(!.VarSet, StateVar)), i(N)]),
     varset.new_named_var(!.VarSet, Name, Var, !:VarSet),
-    !:Map  = ( !.Map ^ elem(StateVar) := Var ).
+    map.set(!.Map, StateVar, Var, !:Map).
 
 %-----------------------------------------------------------------------------%
 
-expand_bang_state_var_args(Args) =
-    list.foldr(expand_bang_state_var, Args, []).
-
-:- func expand_bang_state_var(prog_term, list(prog_term)) = list(prog_term).
-
-expand_bang_state_var(T @ variable(_, _), Ts) = [T | Ts].
-
-expand_bang_state_var(T @ functor(Const, Args, Ctxt), Ts) =
+expand_bang_state_var_args([]) = [].
+expand_bang_state_var_args([HeadArg0 | TailArgs0]) = Args :-
+    TailArgs = expand_bang_state_var_args(TailArgs0),
+    (
+        HeadArg0 = variable(_, _),
+        Args = [HeadArg0 | TailArgs]
+    ;
+        HeadArg0 = functor(Const, FunctorArgs, Ctxt),
     (
         Const = atom("!"),
-        Args = [variable(_StateVar, _)]
+            FunctorArgs = [variable(_StateVar, _)]
     ->
-        [functor(atom("!."), Args, Ctxt), functor(atom("!:"), Args, Ctxt) | Ts]
+            HeadArg1 = functor(atom("!."), FunctorArgs, Ctxt),
+            HeadArg2 = functor(atom("!:"), FunctorArgs, Ctxt),
+            Args = [HeadArg1, HeadArg2 | TailArgs]
     ;
-        [T | Ts]
+            Args = [HeadArg0 | TailArgs]
+        )
     ).
 
 %-----------------------------------------------------------------------------%
@@ -984,7 +996,6 @@
         Arity0, Ctxt),
     Cs  = list.map(expand_item_bsvs, Cs0),
         % Note that the condition should always succeed...
-        %
     ( Cs = [item_clause(_, _, _, _, Args, _) | _] ->
         adjust_func_arity(PredOrFunc, Arity, list.length(Args))
     ;
@@ -1014,15 +1025,11 @@
     substitute_state_var_mappings(Args0, Args, !VarSet, !SInfo, !Specs).
 
 substitute_state_var_mapping(Arg0, Arg, !VarSet, !SInfo, !Specs) :-
-    (
-        Arg0 = functor(atom("!."), [variable(StateVar, _)], Context)
-    ->
-        dot(Context, StateVar, Var, !VarSet, !SInfo, !Specs),
+    ( Arg0 = functor(atom("!."), [variable(StateVar, _)], Context) ->
+        svar_dot(Context, StateVar, Var, !VarSet, !SInfo, !Specs),
         Arg  = variable(Var, context_init)
-    ;
-        Arg0 = functor(atom("!:"), [variable(StateVar, _)], Context)
-    ->
-        colon(Context, StateVar, Var, !VarSet, !SInfo, !Specs),
+    ; Arg0 = functor(atom("!:"), [variable(StateVar, _)], Context) ->
+        svar_colon(Context, StateVar, Var, !VarSet, !SInfo, !Specs),
         Arg  = variable(Var, context_init)
     ;
         Arg  = Arg0
Index: compiler/superhomogeneous.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/superhomogeneous.m,v
retrieving revision 1.27
diff -u -b -r1.27 superhomogeneous.m
--- compiler/superhomogeneous.m	22 Jan 2008 15:06:17 -0000	1.27
+++ compiler/superhomogeneous.m	23 Jan 2008 00:46:06 -0000
@@ -642,19 +642,20 @@
         (
             MaybeVarsCond = ok3(Vars, StateVars, CondParseTree),
             BeforeSInfo = !.SInfo,
-            prepare_for_if_then_else_expr(StateVars, !VarSet, !SInfo),
+            svar_prepare_for_if_then_else_expr(StateVars, !VarSet, !SInfo),
 
             map.init(EmptySubst),
             transform_goal(CondParseTree, EmptySubst, CondGoal, CondAdded,
                 !VarSet, !ModuleInfo, !QualInfo, !SInfo, !Specs),
 
-            finish_if_then_else_expr_condition(BeforeSInfo, !SInfo),
+            svar_finish_if_then_else_expr_condition(BeforeSInfo, !SInfo),
 
             do_unravel_unification(term.variable(X, Context), ThenTerm,
                 Context, MainContext, SubContext, Purity, ThenGoal, no,
                 ThenAdded, !VarSet, !ModuleInfo, !QualInfo, !SInfo, !Specs),
 
-            finish_if_then_else_expr_then_goal(StateVars, BeforeSInfo, !SInfo),
+            svar_finish_if_then_else_expr_then_goal(StateVars,
+                BeforeSInfo, !SInfo),
 
             do_unravel_unification(term.variable(X, Context), ElseTerm,
                 Context, MainContext, SubContext, Purity, ElseGoal, no,
@@ -883,7 +884,7 @@
         Goal = true_goal,
         NumAdded = 0
     ;
-        prepare_for_lambda(!SInfo),
+        svar_prepare_for_lambda(!SInfo),
         substitute_state_var_mappings(Args0, Args, !VarSet, !SInfo, !Specs),
 
         list.length(Args, NumArgs),
@@ -926,14 +927,14 @@
             Context, ArgContext, HeadAfter0, HeadAfter, OutputAdded,
             !VarSet, !ModuleInfo, !QualInfo, !SInfo, !Specs),
 
-        prepare_for_body(FinalSVarMap, !VarSet, !SInfo),
+        svar_prepare_for_body(FinalSVarMap, !VarSet, !SInfo),
 
         transform_goal(ParsedGoal, Substitution, Body, BodyAdded,
             !VarSet, !ModuleInfo, !QualInfo, !SInfo, !Specs),
         NumAdded = NonOutputAdded + OutputAdded + BodyAdded,
 
         % Fix up any state variable unifications.
-        finish_goals(Context, FinalSVarMap, [HeadBefore, Body, HeadAfter],
+        svar_finish_goals(Context, FinalSVarMap, [HeadBefore, Body, HeadAfter],
             HLDS_Goal0, !.SInfo),
 
         % Figure out which variables we need to explicitly existentially
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/base64
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/fixed
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_allegro
cvs diff: Diffing extras/graphics/mercury_allegro/examples
cvs diff: Diffing extras/graphics/mercury_allegro/samples
cvs diff: Diffing extras/graphics/mercury_allegro/samples/demo
cvs diff: Diffing extras/graphics/mercury_allegro/samples/mandel
cvs diff: Diffing extras/graphics/mercury_allegro/samples/pendulum2
cvs diff: Diffing extras/graphics/mercury_allegro/samples/speed
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/log4m
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/mopenssl
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/net
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/posix/samples
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/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/standalone_c
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/solver_types
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 slice
cvs diff: Diffing ssdb
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/par_conj
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
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 messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list