for review: fixing formatting of HLDS dumps

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Feb 18 18:50:34 AEDT 1999


For review by someone who understands mercury to mercury translation
(e.g. fjh).

Fix some old problems with HLDS dumps, including blank lines between goals
(using vi's paragraph commands to move between predicates now works),
unquoted strings and chars in unifications and extra dots in type definitions.

compiler/hlds_out.m:
	Make the above fixes. To fix the problem of blank lines between goals,
	we reinterpret the meaning of the Follow arguments of several
	predicates that print goals, which say what to print after the
	goal, to include the newline to print after the goal. This avoids
	lots of separate calls to io__write_string("\n").

compiler/prog_out.m:
	Add a new predicate for printing a quoted symbol (since strings,
	as cons_ids, are printed as symbols).

compiler/mercury_to_mercury:
	When printing cons_id, quote strings.

compiler/constraint.m:
compiler/mode_errors.m:
compiler/pd_debug.m:
compiler/rl_dump.m:
compiler/saved_vars.m:
	Conform to the new meaning of the Follow arguments in hlds_out.m.

Zoltan.

cvs diff: Diffing .
Index: constraint.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/constraint.m,v
retrieving revision 1.42
diff -u -u -r1.42 constraint.m
--- constraint.m	1998/11/20 04:07:15	1.42
+++ constraint.m	1999/02/18 03:51:34
@@ -352,8 +352,8 @@
 	( semidet_succeed ->
 		mode_info_get_module_info(ModeInfo0, ModuleInfo),
 		mode_info_get_varset(ModeInfo0, VarSet),
-		hlds_out__write_goal(Goal, ModuleInfo, VarSet, no, Indent, "",
-				IOState1, IOState)
+		hlds_out__write_goal(Goal, ModuleInfo, VarSet, no, Indent,
+			"\n", IOState1, IOState)
 	;
 		IOState = IOState1
 	),
Index: hlds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.214
diff -u -u -r1.214 hlds_out.m
--- hlds_out.m	1999/02/18 03:48:39	1.214
+++ hlds_out.m	1999/02/18 06:22:15
@@ -231,15 +231,13 @@
 	"<tabling_pointer>").
 
 hlds_out__write_cons_id(cons(SymName, Arity)) -->
-	prog_out__write_sym_name(SymName),
+	prog_out__write_quoted_sym_name(SymName),
 	io__write_string("/"),
 	io__write_int(Arity).
 hlds_out__write_cons_id(int_const(Int)) -->
 	io__write_int(Int).
 hlds_out__write_cons_id(string_const(String)) -->
-	io__write_char('"'),
-	io__write_string(String),
-	io__write_char('"').
+	term_io__quote_string(String).
 hlds_out__write_cons_id(float_const(Float)) -->
 	io__write_float(Float).
 hlds_out__write_cons_id(pred_const(_PredId, _ProcId)) -->
@@ -387,9 +385,7 @@
 		module_info_superclasses(Module, SuperClassTable),
 		module_info_instances(Module, InstanceTable)
 	},
-	io__write_string("\n"),
 	hlds_out__write_header(Indent, Module),
-	io__write_string("\n"),
 	globals__io_lookup_string_option(dump_hlds_options, Verbose),
 	( { string__contains_char(Verbose, 'T') } ->
 		hlds_out__write_types(Indent, TypeTable),
@@ -409,10 +405,9 @@
 		hlds_out__write_modes(Indent, ModeTable),
 		io__write_string("\n")
 	;
-		io__write_string("\n")
+		[]
 	),
 	hlds_out__write_preds(Indent, Module, PredTable),
-	io__write_string("\n"),
 	hlds_out__write_footer(Indent, Module).
 
 :- pred hlds_out__write_header(int, module_info, io__state, io__state).
@@ -423,7 +418,7 @@
 	hlds_out__write_indent(Indent),
 	io__write_string(":- module "),
 	prog_out__write_sym_name(Name),
-	io__write_string(".\n").
+	io__write_string(".\n\n").
 
 :- pred hlds_out__write_footer(int, module_info, io__state, io__state).
 :- mode hlds_out__write_footer(in, in, di, uo) is det.
@@ -676,7 +671,7 @@
 	;
 		io__write_string(" :-\n"),
 		hlds_out__write_goal_a(Goal, ModuleInfo, VarSet, AppendVarnums,
-			Indent1, ".", TypeQual)
+			Indent1, ".\n", TypeQual)
 	).
 
 :- pred hlds_out__write_intlist(list(int), io__state, io__state).
@@ -977,8 +972,7 @@
 	),
 	hlds_out__write_indent(Indent),
 	io__write_string(")"),
-	io__write_string(Follow),
-	io__write_string("\n").
+	io__write_string(Follow).
 
 hlds_out__write_goal_2(some(Vars, Goal), ModuleInfo, VarSet, AppendVarnums,
 		Indent, Follow, TypeQual) -->
@@ -988,11 +982,10 @@
 	io__write_string("] (\n"),
 	{ Indent1 is Indent + 1 },
 	hlds_out__write_goal_a(Goal, ModuleInfo, VarSet, AppendVarnums,
-		Indent1, "", TypeQual),
+		Indent1, "\n", TypeQual),
 	hlds_out__write_indent(Indent),
 	io__write_string(")"),
-	io__write_string(Follow),
-	io__write_string("\n").
+	io__write_string(Follow).
 
 hlds_out__write_goal_2(if_then_else(Vars, Cond, Then, Else, _), ModuleInfo,
 		VarSet, AppendVarnums, Indent, Follow, TypeQual) -->
@@ -1002,11 +995,11 @@
 	io__write_string("\n"),
 	{ Indent1 is Indent + 1 },
 	hlds_out__write_goal_a(Cond, ModuleInfo, VarSet, AppendVarnums,
-		Indent1, "", TypeQual),
+		Indent1, "\n", TypeQual),
 	hlds_out__write_indent(Indent),
 	io__write_string("then\n"),
 	hlds_out__write_goal_a(Then, ModuleInfo, VarSet, AppendVarnums,
-		Indent1, "", TypeQual),
+		Indent1, "\n", TypeQual),
 	hlds_out__write_indent(Indent),
 	io__write_string("else\n"),
 	globals__io_lookup_string_option(dump_hlds_options, Verbose),
@@ -1015,15 +1008,14 @@
 		{ Else = if_then_else(_, _, _, _, _) - _ }
 	->
 		hlds_out__write_goal_a(Else, ModuleInfo, VarSet, AppendVarnums,
-			Indent, "", TypeQual)
+			Indent, "\n", TypeQual)
 	;
 		hlds_out__write_goal_a(Else, ModuleInfo, VarSet, AppendVarnums,
-			Indent1, "", TypeQual)
+			Indent1, "\n", TypeQual)
 	),
 	hlds_out__write_indent(Indent),
 	io__write_string(")"),
-	io__write_string(Follow),
-	io__write_string("\n").
+	io__write_string(Follow).
 
 hlds_out__write_goal_2(not(Goal), ModuleInfo, VarSet, AppendVarnums,
 		Indent, Follow, TypeQual) -->
@@ -1031,11 +1023,10 @@
 	io__write_string("\\+ (\n"),
 	{ Indent1 is Indent + 1 },
 	hlds_out__write_goal_a(Goal, ModuleInfo, VarSet, AppendVarnums,
-		Indent1, "", TypeQual),
+		Indent1, "\n", TypeQual),
 	hlds_out__write_indent(Indent),
 	io__write_string(")"),
-	io__write_string(Follow),
-	io__write_string("\n").
+	io__write_string(Follow).
 
 hlds_out__write_goal_2(conj(List), ModuleInfo, VarSet, AppendVarnums,
 		Indent, Follow, TypeQual) -->
@@ -1046,12 +1037,11 @@
 			hlds_out__write_indent(Indent),
 			io__write_string("( % conjunction\n"),
 			hlds_out__write_conj(Goal, Goals, ModuleInfo, VarSet,
-				AppendVarnums, Indent1, "", Verbose, ",\n",
+				AppendVarnums, Indent1, "\n", Verbose, ",\n",
 				TypeQual),
 			hlds_out__write_indent(Indent),
 			io__write_string(")"),
-			io__write_string(Follow),
-			io__write_string("\n")
+			io__write_string(Follow)
 		;
 			hlds_out__write_conj(Goal, Goals, ModuleInfo, VarSet,
 				AppendVarnums, Indent, Follow, Verbose, ",\n",
@@ -1060,8 +1050,7 @@
 	;
 		hlds_out__write_indent(Indent),
 		io__write_string("true"),
-		io__write_string(Follow),
-		io__write_string("\n")
+		io__write_string(Follow)
 	).
 
 hlds_out__write_goal_2(par_conj(List, _), ModuleInfo, VarSet, AppendVarnums,
@@ -1071,18 +1060,16 @@
 		io__write_string("( % parallel conjunction\n"),
 		{ Indent1 is Indent + 1 },
 		hlds_out__write_goal_a(Goal, ModuleInfo, VarSet, AppendVarnums,
-			Indent1, "", TypeQual),
+			Indent1, "\n", TypeQual),
 			% See comments at hlds_out__write_goal_list.
 		hlds_out__write_goal_list(Goals, ModuleInfo, VarSet,
-			AppendVarnums, Indent, "&", TypeQual),
+			AppendVarnums, Indent, "&\n", TypeQual),
 		hlds_out__write_indent(Indent),
 		io__write_string(")"),
-		io__write_string(Follow),
-		io__write_string("\n")
+		io__write_string(Follow)
 	;
 		io__write_string("/* parallel */ true"),
-		io__write_string(Follow),
-		io__write_string("\n")
+		io__write_string(Follow)
 	).
 
 hlds_out__write_goal_2(disj(List, _), ModuleInfo, VarSet, AppendVarnums,
@@ -1092,17 +1079,15 @@
 		io__write_string("( % disjunction\n"),
 		{ Indent1 is Indent + 1 },
 		hlds_out__write_goal_a(Goal, ModuleInfo, VarSet, AppendVarnums,
-			Indent1, "", TypeQual),
+			Indent1, "\n", TypeQual),
 		hlds_out__write_goal_list(Goals, ModuleInfo, VarSet,
-			AppendVarnums, Indent, ";", TypeQual),
+			AppendVarnums, Indent, ";\n", TypeQual),
 		hlds_out__write_indent(Indent),
 		io__write_string(")"),
-		io__write_string(Follow),
-		io__write_string("\n")
+		io__write_string(Follow)
 	;
 		io__write_string("fail"),
-		io__write_string(Follow),
-		io__write_string("\n")
+		io__write_string(Follow)
 	).
 
 hlds_out__write_goal_2(higher_order_call(PredVar, ArgVars, _, _, _, PredOrFunc),
@@ -1136,8 +1121,7 @@
 		hlds_out__write_functor(term__atom("apply"), FuncArgVars,
 				VarSet, AppendVarnums)
 	),
-	io__write_string(Follow),
-	io__write_string("\n").
+	io__write_string(Follow).
 
 hlds_out__write_goal_2(class_method_call(TCInfoVar, _, ArgVars, _, _, _),
 		_ModuleInfo, VarSet, AppendVarnums, Indent, Follow, _) -->
@@ -1152,8 +1136,7 @@
 	),
 	hlds_out__write_functor(term__atom("class_method_call"),
 			[TCInfoVar|ArgVars], VarSet, AppendVarnums),
-	io__write_string(Follow),
-	io__write_string("\n").
+	io__write_string(Follow).
 
 hlds_out__write_goal_2(call(PredId, ProcId, ArgVars, Builtin,
 			MaybeUnifyContext, PredName),
@@ -1193,7 +1176,6 @@
 			AppendVarnums)
 	),
 	io__write_string(Follow),
-	io__write_string("\n"),
 	( { string__contains_char(Verbose, 'l') } ->
 		{ pred_id_to_int(PredId, PredNum) },
 		{ proc_id_to_int(ProcId, ProcNum) },
@@ -1202,7 +1184,7 @@
 		io__write_int(PredNum),
 		io__write_string(", proc id: "),
 		io__write_int(ProcNum),
-		io__write_strings([Follow, "\n"]),
+		io__write_string(Follow),
 		( { MaybeUnifyContext = yes(CallUnifyContext) } ->
 			{ TypeQual = yes(_, VarTypes) ->
 				map__lookup(VarTypes, Var, UniType),
@@ -1303,8 +1285,7 @@
 		io__write_string(""")")
 	),
 	io__write_string(")"),
-	io__write_string(Follow),
-	io__write_string("\n").
+	io__write_string(Follow).
 
 :- pred hlds_out__write_varnum_list(list(prog_var), io__state, io__state).
 :- mode hlds_out__write_varnum_list(in, di, uo) is det.
@@ -1448,8 +1429,7 @@
 		Indent, Follow, MaybeType, TypeQual) -->
 	hlds_out__write_unify_rhs_3(Rhs, ModuleInfo, VarSet, InstVarSet,
 		AppendVarnums, Indent, MaybeType, TypeQual),
-	io__write_string(Follow),
-	io__write_string("\n").
+	io__write_string(Follow).
 
 :- pred hlds_out__write_unify_rhs_3(unify_rhs, module_info, prog_varset,
 	inst_varset, bool, int, maybe(type), vartypes, io__state, io__state).
@@ -1483,7 +1463,7 @@
 		mercury_output_det(Det),
 		io__write_string(" :-\n"),
 		hlds_out__write_goal_a(Goal, ModuleInfo, VarSet, AppendVarnums,
-			Indent1, "", TypeQual),
+			Indent1, "\n", TypeQual),
 		hlds_out__write_indent(Indent),
 		io__write_string(")")
 	;
@@ -1500,7 +1480,7 @@
 		mercury_output_det(Det),
 		io__write_string(" :-\n"),
 		hlds_out__write_goal_a(Goal, ModuleInfo, VarSet, AppendVarnums,
-			Indent1, "", TypeQual),
+			Indent1, "\n", TypeQual),
 		hlds_out__write_indent(Indent),
 		io__write_string(")")
 	),
@@ -1659,7 +1639,7 @@
 			% the lines after one goal
 			% and the lines before the next
 			hlds_out__write_goal_a(Goal1, ModuleInfo, VarSet,
-				AppendVarnums, Indent, "", TypeQual),
+				AppendVarnums, Indent, "\n", TypeQual),
 			hlds_out__write_indent(Indent),
 			io__write_string(Separator)
 		;
@@ -1681,10 +1661,9 @@
 	->
 		hlds_out__write_indent(Indent),
 		io__write_string(Separator),
-		io__write_string("\n"),
 		{ Indent1 is Indent + 1 },
 		hlds_out__write_goal_a(Goal, ModuleInfo, VarSet,
-			AppendVarnums, Indent1, "", TypeQual),
+			AppendVarnums, Indent1, "\n", TypeQual),
 		hlds_out__write_goal_list(Goals, ModuleInfo, VarSet,
 			AppendVarnums, Indent, Separator, TypeQual)
 	;
@@ -1709,7 +1688,7 @@
 	% the unification. At the moment this is not a problem, since
 	% intermod.m works on the unoptimized clauses.
 	hlds_out__write_goal_a(Goal, ModuleInfo, VarSet, AppendVarnums,
-		Indent, "", VarTypes).
+		Indent, "\n", VarTypes).
 
 :- pred hlds_out__write_cases(list(case), prog_var, module_info, prog_varset,
 		bool, int, vartypes, io__state, io__state).
@@ -2036,7 +2015,9 @@
 	io__write_string(" --->\n"),
 	hlds_out__write_constructors(Indent, Tvarset, Ctors),
 	( { MaybeEqualityPred = yes(PredName) } ->
-		io__write_string("\n\twhere equality is "),
+		io__write_string("\n"),
+		hlds_out__write_indent(Indent),
+		io__write_string("where equality is "),
 		prog_out__write_sym_name(PredName)
 	;
 		[]
@@ -2079,7 +2060,7 @@
 	io__write_string(";\t"),
 	mercury_output_ctor(C, Tvarset),
 	( { Cs = [] } ->
-		io__write_string(".\n")
+		[]
 	;
 		io__write_string("\n"),
 		hlds_out__write_constructors_2(Indent, Tvarset, Cs)
@@ -2454,7 +2435,7 @@
 			AppendVarnums, HeadVars, PredOrFunc),
 		io__write_string(" :-\n"),
 		hlds_out__write_goal(Goal, ModuleInfo, VarSet, AppendVarnums,
-			Indent1, ".")
+			Indent1, ".\n")
 	).
 
 % :- pred hlds_out__write_varnames(int, map(var, string), io__state, io__state).
Index: mercury_to_mercury.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.153
diff -u -u -r1.153 mercury_to_mercury.m
--- mercury_to_mercury.m	1999/02/14 13:02:36	1.153
+++ mercury_to_mercury.m	1999/02/18 05:57:35
@@ -1039,7 +1039,9 @@
 mercury_output_cons_id(float_const(X), _) -->
 	io__write_float(X).
 mercury_output_cons_id(string_const(X), _) -->
-	io__write_strings(["""", X, """"]).
+	io__write_string(""""),
+	term_io__quote_string(X),
+	io__write_string("""").
 mercury_output_cons_id(pred_const(PredId, ProcId), _) -->
 	% XXX Sufficient, but probably should print this out in
 	%     name/arity form.
Index: mode_errors.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mode_errors.m,v
retrieving revision 1.61
diff -u -u -r1.61 mode_errors.m
--- mode_errors.m	1999/02/18 03:48:44	1.61
+++ mode_errors.m	1999/02/18 03:51:53
@@ -334,7 +334,7 @@
 	( { VeryVerbose = yes } ->
 		io__write_string("\t\t"),
 		{ mode_info_get_module_info(ModeInfo, ModuleInfo) },
-		hlds_out__write_goal(Goal, ModuleInfo, VarSet, no, 2, ".")
+		hlds_out__write_goal(Goal, ModuleInfo, VarSet, no, 2, ".\n")
 	;
 		[]
 	),
Index: pd_debug.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/pd_debug.m,v
retrieving revision 1.2
diff -u -u -r1.2 pd_debug.m
--- pd_debug.m	1998/11/20 04:08:42	1.2
+++ pd_debug.m	1999/02/18 03:52:18
@@ -129,7 +129,7 @@
 	{ instmap__restrict(InstMap, NonLocals, InstMap1) },
 	hlds_out__write_instmap(InstMap1, VarSet, yes, 1),
 	io__nl,
-	hlds_out__write_goal(Goal - GoalInfo, ModuleInfo, VarSet, no, 1, ""),
+	hlds_out__write_goal(Goal - GoalInfo, ModuleInfo, VarSet, no, 1, "\n"),
 	io__nl,
 	io__write_string("Parents: "),
 	{ set__to_sorted_list(Parents, ParentsList) },
@@ -140,7 +140,7 @@
 		{ proc_info_goal(ProcInfo, ProcGoal) },
 		io__write_string("Unfolded goal\n"),
 		hlds_out__write_goal(ProcGoal, 
-			ModuleInfo, VarSet, no, 1, ""),
+			ModuleInfo, VarSet, no, 1, "\n"),
 		io__nl
 	;
 		[]
@@ -186,7 +186,7 @@
 		hlds_out__write_instmap(InstMap1, VarSet, yes, 1, IO1, IO2),
 		io__nl(IO2, IO3),
 		hlds_out__write_goal(Goal - GoalInfo, ModuleInfo,
-			VarSet, yes, 1, "", IO3, IO4),
+			VarSet, yes, 1, "\n", IO3, IO4),
 		io__nl(IO4, IO5),
 		io__flush_output(IO5, IO)
 		},
Index: prog_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_out.m,v
retrieving revision 1.41
diff -u -u -r1.41 prog_out.m
--- prog_out.m	1998/12/06 23:44:36	1.41
+++ prog_out.m	1999/02/18 06:21:08
@@ -40,6 +40,9 @@
 :- pred prog_out__write_sym_name(sym_name, io__state, io__state).
 :- mode prog_out__write_sym_name(in, di, uo) is det.
 
+:- pred prog_out__write_quoted_sym_name(sym_name, io__state, io__state).
+:- mode prog_out__write_quoted_sym_name(in, di, uo) is det.
+
 	% sym_name_to_string(SymName, String):
 	%	convert a symbol name to a string,
 	%	with module qualifiers separated by
@@ -189,6 +192,13 @@
 	io__write_string(Name).
 prog_out__write_sym_name(unqualified(Name)) -->
 	io__write_string(Name).
+
+prog_out__write_quoted_sym_name(qualified(ModuleSpec,Name)) -->
+	prog_out__write_module_spec(ModuleSpec),
+	io__write_string(":"),
+	term_io__write_escaped_string(Name).
+prog_out__write_quoted_sym_name(unqualified(Name)) -->
+	term_io__write_escaped_string(Name).
 
 prog_out__sym_name_to_string(SymName, String) :-
 	prog_out__sym_name_to_string(SymName, ":", String).
Index: rl_dump.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rl_dump.m,v
retrieving revision 1.1
diff -u -u -r1.1 rl_dump.m
--- rl_dump.m	1998/12/06 23:44:57	1.1
+++ rl_dump.m	1999/02/18 03:52:57
@@ -628,7 +628,7 @@
 		[]
 	),
 	hlds_out__write_goal_list(GoalList, ModuleInfo,
-		VarSet, yes, 2, ",", no).
+		VarSet, yes, 2, ",\n", no).
 
 :- pred rl_dump__write_bounds(module_info::in, prog_varset::in,
 		rl_var_bounds::in, io__state::di, io__state::uo) is det.
Index: saved_vars.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/saved_vars.m,v
retrieving revision 1.17
diff -u -u -r1.17 saved_vars.m
--- saved_vars.m	1998/11/20 04:09:07	1.17
+++ saved_vars.m	1999/02/18 03:52:30
@@ -56,7 +56,7 @@
 	{ final_slot_info(Varset1, VarTypes1, SlotInfo) },
 	{ proc_info_headvars(ProcInfo0, HeadVars) },
 
-	% hlds_out__write_goal(Goal1, ModuleInfo, Varset1, 0, ""),
+	% hlds_out__write_goal(Goal1, ModuleInfo, Varset1, 0, "\n"),
 
 	% recompute the nonlocals for each goal
 	{ implicitly_quantify_clause_body(HeadVars, Goal1, Varset1,
@@ -65,7 +65,7 @@
 	{ recompute_instmap_delta(no, Goal2, Goal, InstMap0, 
 		ModuleInfo0, ModuleInfo) },
 
-	% hlds_out__write_goal(Goal, ModuleInfo, Varset, 0, ""),
+	% hlds_out__write_goal(Goal, ModuleInfo, Varset, 0, "\n"),
 
 	{ proc_info_set_goal(ProcInfo0, Goal, ProcInfo1) },
 	{ proc_info_set_varset(ProcInfo1, Varset, ProcInfo2) },
Index: table_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/table_gen.m,v
retrieving revision 1.6
diff -u -u -r1.6 table_gen.m
--- table_gen.m	1998/11/24 03:57:20	1.6
+++ table_gen.m	1999/02/17 05:08:07
@@ -1,5 +1,5 @@
 %-----------------------------------------------------------------------------%
-% Copyright (C) 1997-1998 The University of Melbourne.
+% Copyright (C) 1997-1999 The University of Melbourne.
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
@@ -27,7 +27,7 @@
 % implemented.
 %
 % XXX the current implementation of minimal_model tabling is buggy;
-% e.g. it fails for tests/tabling/coup.m.
+% e.g. it fails for tests/tabling/seq.m.
 %
 % Example of transformation for semidet minimal_model :
 %
@@ -87,30 +87,30 @@
 %	The transformed code would be :
 %
 %	p(A, B) :-
-%			% Code to get a handle on the table
+%			% Code to get a handle on the table.
 %		T0 = <table pointer for p/2>,
 %
-%			% Code to lookup input arguments and setup table
+%			% Code to lookup input arguments and setup table.
 %		impure table_lookup_insert_int(T0, A, T1),
 %		impure table_setup(T1, T2),
 %		(if
 %			semipure table_have_all_ans(T2)
 %		then
 %				% Code to return all ans if we have found
-%				% them
+%				% them.
 %			impure table_return_all_ans(T2, Ans),
 %			impure table_restore_int_ans(Ans, 0, B)
 %		else if
-%			semipure table_have_some_ans(T2)
+%			semipure table_is_active(T2)
 %		then
 %				% Code to suspend the current computational
-%				% branch
+%				% branch.
 %			impure table_suspend(T2, Ans),
 %			impure table_restore_int_ans(Ans, 0, B)
 %		else
 %		   	(		% Mark that this subgoal is being
-%					% evaluated
-%				impure table_mark_have_some_ans(T2),
+%					% evaluated.
+%				impure table_mark_as_active(T2),
 %
 %				(
 %					%
@@ -119,11 +119,11 @@
 %				),
 %
 %					% Code to check for duplicate
-%					% answers
+%					% answers.
 %				impure table_get_ans_table(T2, AT0),
 %				impure table_lookup_insert_int(AT0, B, AT1),
 %
-%					% The following pred is semidet
+%					% The following pred is semidet;
 %					% it will fail if the answer is
 %					% already in the table.
 %				semipure table_has_not_returned(AT1),
@@ -135,13 +135,10 @@
 %				impure table_create_ans_block(AS, 1, AB),
 %				impure table_save_int_ans(AB, 0, B)
 %			;
-%					% Code to resume suspended nodes.
-%				impure table_resume(T2),
-%				fail
-%			;
-%					% Code to mark the current subgoal
+%					% Code to resume all suspended nodes,
+%					% and then mark the current subgoal
 %					% as totally evaluated.
-%				impure table_mark_have_all_ans(T2),
+%				impure table_resume(T2),
 %				fail
 %			)
 %		).
@@ -322,7 +319,7 @@
 
 	( EvalMethod = eval_loop_check ->
 		SaveAnsGoal = DoneWorkingGoal
-	;	EvalMethod = eval_memo ->
+	; EvalMethod = eval_memo ->
 		SaveAnsGoal = SaveAnsGoal0
 	;
 		error(
@@ -334,8 +331,7 @@
 	generate_call("table_mark_as_working", [TableVar], det,
 		impure, [], Module, MarkAsWorkingGoal),
 
-	NoLoopGenAnsGoalEx = conj([MarkAsWorkingGoal, OrigGoal,
-		SaveAnsGoal]),
+	NoLoopGenAnsGoalEx = conj([MarkAsWorkingGoal, OrigGoal, SaveAnsGoal]),
 	create_instmap_delta([MarkAsWorkingGoal, OrigGoal,
 		SaveAnsGoal], NoLoopGenInstMapDelta0),
 	instmap_delta_restrict(NoLoopGenInstMapDelta0, GenAnsNonLocals,
@@ -540,18 +536,16 @@
 		VarSet1, VarSet2, Module, SaveAnsGoal0),
 	generate_restore_all_goal(OutputVars, TableVar,  Module, VarTypes2,
 		VarTypes3, VarSet2, VarSet3, RestoreAllAnsGoal),
-	generate_call("table_have_some_ans", [TableVar], semidet, semipure,
-		[], Module, HaveSomeAnsCheckGoal),
+	generate_call("table_is_active", [TableVar], semidet, semipure,
+		[], Module, IsActiveCheckGoal),
 	generate_suspend_goal(OutputVars, TableVar, Module, VarTypes3,
 		VarTypes4, VarSet3, VarSet4, SuspendGoal),
 	generate_loop_error_goal(PredInfo, Module, VarTypes4, VarTypes,
 		VarSet4, VarSet, LoopErrorGoal),
-	generate_call("table_mark_have_some_ans", [TableVar], det, impure,
-		[], Module, MarkHaveSomeAnsGoal),
+	generate_call("table_mark_as_active", [TableVar], det, impure,
+		[], Module, MarkAsActiveGoal),
 	generate_call("table_resume", [TableVar], failure, impure,
 		[], Module, ResumeGoal0),
-	generate_call("table_mark_have_all_ans", [TableVar], failure, impure,
-		[], Module, MarkHaveAllAnsGoal),
 
 	true_goal(TrueGoal),
 	fail_goal(FailGoal),
@@ -581,9 +575,9 @@
     "table_gen__create_new_non_goal: unsupported evaluation model")
 	),
 
-	GenAnsGoalPart1Ex = conj([MarkHaveSomeAnsGoal, OrigGoal, SaveAnsGoal]),
+	GenAnsGoalPart1Ex = conj([MarkAsActiveGoal, OrigGoal, SaveAnsGoal]),
 	set__insert(OrigNonLocals, TableVar, GenAnsGoalPart1NonLocals),
-	create_instmap_delta([MarkHaveSomeAnsGoal, OrigGoal, SaveAnsGoal],
+	create_instmap_delta([MarkAsActiveGoal, OrigGoal, SaveAnsGoal],
 		GenAnsGoalPart1IMD0),
 	instmap_delta_restrict(GenAnsGoalPart1IMD0, GenAnsGoalPart1NonLocals,
 		GenAnsGoalPart1IMD),
@@ -598,11 +592,10 @@
 	;
 		ResumeGoal = FailGoal
 	),
-	GenAnsGoalEx = disj([GenAnsGoalPart1, ResumeGoal, MarkHaveAllAnsGoal],
-		StoreMap),
+	GenAnsGoalEx = disj([GenAnsGoalPart1, ResumeGoal], StoreMap),
 	GenAnsGoal = GenAnsGoalEx - GenAnsGoalPart1GoalInfo,
 
-	ITE1GoalEx = if_then_else([], HaveSomeAnsCheckGoal, WorkingOnAnsGoal,
+	ITE1GoalEx = if_then_else([], IsActiveCheckGoal, WorkingOnAnsGoal,
 		GenAnsGoal, StoreMap),
 	ITE1Goal = ITE1GoalEx - GenAnsGoalPart1GoalInfo,
 
cvs diff: Diffing notes



More information about the developers mailing list