[m-rev.] trivial diff: clean up saved_vars.m

Julien Fischer juliensf at cs.mu.OZ.AU
Tue Apr 26 13:53:45 AEST 2005


Estimated hours taken: 0.5
Branches: main

Fix up some minor issues I noticed in saved_vars.m while
we were debugging the unused_args_test problem.  There
are no changes to any algorithms.

compiler/saved_vars.m:
	Don't export the predicate saved_vars_proc_no_io/4 from
	this module since it isn't used anywhere else.

	Fix a couple of spots where the 79 character column
	limit has been exceeded.

	Re-position the comments in accordance with our current
	coding standard.

	s/opprtunities/opportunities/

Julien.

Workspace:/home/jupiter/juliensf/ws74
Index: compiler/saved_vars.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/saved_vars.m,v
retrieving revision 1.47
diff -u -r1.47 saved_vars.m
--- compiler/saved_vars.m	24 Mar 2005 05:34:14 -0000	1.47
+++ compiler/saved_vars.m	26 Apr 2005 03:48:41 -0000
@@ -34,9 +34,7 @@
 	proc_info::in, proc_info::out, module_info::in, module_info::out,
 	io::di, io::uo) is det.

-:- pred saved_vars_proc_no_io(proc_info::in, proc_info::out,
-	module_info::in, module_info::out) is det.
-
+%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%

 :- implementation.
@@ -47,6 +45,7 @@
 :- import_module hlds__hlds_out.
 :- import_module hlds__passes_aux.
 :- import_module hlds__quantification.
+:- import_module parse_tree__error_util.
 :- import_module parse_tree__prog_data.

 :- import_module bool.
@@ -65,6 +64,9 @@
 		PredId, ProcId, !.ModuleInfo, !IO),
 	saved_vars_proc_no_io(ProcInfo0, ProcInfo, !ModuleInfo).

+:- pred saved_vars_proc_no_io(proc_info::in, proc_info::out,
+	module_info::in, module_info::out) is det.
+
 saved_vars_proc_no_io(!ProcInfo, !ModuleInfo) :-
 	proc_info_goal(!.ProcInfo, Goal0),
 	proc_info_varset(!.ProcInfo, Varset0),
@@ -147,7 +149,8 @@
 	;
 		GoalExpr0 = shorthand(_),
 		% these should have been expanded out by now
-		error("saved_vars_in_goal: unexpected shorthand")
+		unexpected(this_file,
+			"saved_vars_in_goal: unexpected shorthand")
 	).

 %-----------------------------------------------------------------------------%
@@ -188,10 +191,10 @@
 		Goals = [Goal1 | Goals1]
 	).

-% ok_to_duplicate returns `no' for features which shouldn't be on construction
-% unifications in the first place as well as for construction unifications
-% that shouldn't be duplicated.
-
+	% ok_to_duplicate returns `no' for features which shouldn't be
+	% on construction unifications in the first place as well as for
+	% construction unifications that shouldn't be duplicated.
+	%
 :- func ok_to_duplicate(goal_feature) = bool.

 ok_to_duplicate(constraint) = no.
@@ -209,9 +212,9 @@
 ok_to_duplicate(save_deep_excp_vars) = no.
 ok_to_duplicate(dont_warn_singleton) = yes.

-% Divide a list of goals into an initial subsequence of goals that
-% construct constants, and all other goals.
-
+	% Divide a list of goals into an initial subsequence of goals
+	% that construct constants, and all other goals.
+	%
 :- pred skip_constant_constructs(list(hlds_goal)::in, list(hlds_goal)::out,
 	list(hlds_goal)::out) is det.

@@ -228,12 +231,14 @@
 		Others = [Goal0 | Goals0]
 	).

-% Decide whether the value of the given variable is needed immediately
-% in the goal, or whether the unification that constructs a value for
-% the variable can be usefully pushed into the goal.
-%
-% The logic of this predicate must match the logic of saved_vars_delay_goal.
-
+	% Decide whether the value of the given variable is needed
+	% immediately in the goal, or whether the unification that
+	% constructs a value for the variable can be usefully pushed
+	% into the goal.
+	%
+	% NOTE: the logic of this predicate must match the logic of
+	% saved_vars_delay_goal.
+	%
 :- pred can_push(prog_var::in, hlds_goal::in) is semidet.

 can_push(Var, First) :-
@@ -258,20 +263,22 @@
 		true
 	).

-% The main inputs of this predicate are a list of goals in a conjunction,
-% and a goal Construct that assigns a constant to a variable Var.
-%
-% When we find an atomic goal in the conjunction that refers to Var,
-% we create a new variable NewVar, rename both this goal and Construct
-% to refer to NewVar instead of Var, and insert the new version of Construct
-% before the new version of the goal.
-%
-% When we find a non-atomic goal in the conjunction that refers to Var,
-% we push Construct into each of its components.
-%
-% If Var is exported from the conjunction, we include Construct at the end
-% of the conjunction to give it its value.
-
+	% The main inputs of this predicate are a list of goals in a
+	% conjunction, and a goal Construct that assigns a constant to a
+	% variable Var.
+	%
+	% When we find an atomic goal in the conjunction that refers to
+	% Var, we create a new variable NewVar, rename both this goal
+	% and Construct to refer to NewVar instead of Var, and insert
+	% the new version of Construct before the new version of the
+	% goal.
+	%
+	% When we find a non-atomic goal in the conjunction that refers
+	% to Var, we push Construct into each of its components.
+	%
+	% If Var is exported from the conjunction, we include Construct
+	% at the end of the conjunction to give it its value.
+	%
 :- pred saved_vars_delay_goal(list(hlds_goal)::in, hlds_goal::in, prog_var::in,
 	bool::in, list(hlds_goal)::out, slot_info::in, slot_info::out) is det.

@@ -399,7 +406,8 @@
 		;
 			Goal0Expr = shorthand(_),
 			% these should have been expanded out by now
-			error("saved_vars_delay_goal: unexpected shorthand")
+			unexpected(this_file,
+				"saved_vars_delay_goal: unexpected shorthand")
 		)
 	;
 		saved_vars_delay_goal(Goals0, Construct, Var, IsNonLocal,
@@ -407,9 +415,10 @@
 		Goals = [Goal0 | Goals1]
 	).

-% Push a non-renamed version of the given construction into the given goal.
-% Also traverse the goal looking for further opprtunities.
-
+	% Push a non-renamed version of the given construction into the
+	% given goal.  Also traverse the goal looking for further
+	% opportunities.
+	%
 :- pred push_into_goal(hlds_goal::in, hlds_goal::in, prog_var::in,
 	hlds_goal::out, slot_info::in, slot_info::out) is det.

@@ -420,11 +429,11 @@
 	saved_vars_delay_goal(Conj1, Construct, Var, no, Conj, !SlotInfo),
 	conj_list_to_goal(Conj, Goal1Info, Goal).

-% Push a renamed version of the given construction into the given goal.
-% If the goal does not refer to the variable bound by the construction,
-% then this would have no effect, so we merely traverse the goal looking
-% for other opportunities.
-
+	% Push a renamed version of the given construction into the
+	% given goal.  If the goal does not refer to the variable bound
+	% by the construction, then this would have no effect, so we
+	% merely traverse the goal looking for other opportunities.
+	%
 :- pred push_into_goal_rename(hlds_goal::in, hlds_goal::in, prog_var::in,
 	hlds_goal::out, slot_info::in, slot_info::out) is det.

@@ -439,9 +448,10 @@
 	;
 		saved_vars_in_goal(Goal0, Goal, !SlotInfo)
 	).
-
-% Push renamed versions of the given construction into each of several goals.
-
+
+	% Push renamed versions of the given construction into each of
+	% several goals.
+	%
 :- pred push_into_goals_rename(list(hlds_goal)::in, hlds_goal::in,
 	prog_var::in, list(hlds_goal)::out, slot_info::in, slot_info::out)
 	is det.
@@ -451,9 +461,10 @@
 		!SlotInfo) :-
 	push_into_goal_rename(Goal0, Construct, Var, Goal, !SlotInfo),
 	push_into_goals_rename(Goals0, Construct, Var, Goals, !SlotInfo).
-
-% Push renamed versions of the given construction into each of several cases.
-
+
+	% Push renamed versions of the given construction into each of
+	% several cases.
+	%
 :- pred push_into_cases_rename(list(case)::in, hlds_goal::in, prog_var::in,
 	list(case)::out, slot_info::in, slot_info::out) is det.

@@ -465,9 +476,10 @@

 %-----------------------------------------------------------------------------%

-	% saved_vars_in_disj does a saved_vars_in_goal on an list of independent
-	% goals, and is used to process disjunctions and parallel conjunctions.
-
+	% saved_vars_in_disj does a saved_vars_in_goal on an list of
+	% independent goals, and is used to process disjunctions and
+	% parallel conjunctions.
+	%
 :- pred saved_vars_in_disj(list(hlds_goal)::in, list(hlds_goal)::out,
 	slot_info::in, slot_info::out) is det.

@@ -487,10 +499,11 @@

 %-----------------------------------------------------------------------------%

-:- type slot_info	--->	slot_info(
-					prog_varset,
-					vartypes
-				).
+:- type slot_info
+	---> slot_info(
+		prog_varset,
+		vartypes
+	).

 :- pred init_slot_info(prog_varset::in, map(prog_var, type)::in,
 	slot_info::out) is det.
@@ -512,4 +525,12 @@
 	map__det_insert(VarTypes0, NewVar, Type, VarTypes),
 	!:SlotInfo = slot_info(Varset, VarTypes).

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

--------------------------------------------------------------------------
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