[m-rev.] diff: hlds dump improvements

Zoltan Somogyi zs at unimelb.edu.au
Fri Apr 13 17:20:43 AEST 2012


compiler/handle_options.m:
	If the user does not specify what to dump, dump basic predicate
	information.

compiler/hlds_out_goal.m:
	When dumping out the contents of from_ground_term scopes, use the
	option settings we use for procedure bodies, even when the goal
	is in a clause. We normally suppress the printing of most annotations
	(such as detism and instmap delta) on goals in clauses, because
	these fields won't be filled in before the clause is copied to a
	procedure body. However, some of these fields are filled in
	for goals inside from_ground_term scopes during construction,
	so they may be of interest.

compiler/hlds_out_util.m:
	Allow the code in hlds_out_goal to look at a backup, full copy
	of the dump option string.

Zoltan.

cvs diff: Diffing .
Index: handle_options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.379
diff -u -b -r1.379 handle_options.m
--- handle_options.m	5 Apr 2012 00:58:24 -0000	1.379
+++ handle_options.m	12 Apr 2012 09:20:06 -0000
@@ -392,6 +392,15 @@
 
     some [!DumpOptions] (
         lookup_string_option(!.OptionTable, dump_hlds_options, !:DumpOptions),
+
+        % If we have not specified what we want, dump bare procedures
+        % as default.
+        ( !.DumpOptions = "" ->
+            !:DumpOptions = "x"
+        ;
+            true
+        ),
+
         % If we want structured insts in arg-modes, then we want arg-modes.
         (
             string.contains_char(!.DumpOptions, 'y'),
Index: hlds_out_goal.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_out_goal.m,v
retrieving revision 1.16
diff -u -b -r1.16 hlds_out_goal.m
--- hlds_out_goal.m	12 Apr 2012 04:56:17 -0000	1.16
+++ hlds_out_goal.m	12 Apr 2012 09:26:25 -0000
@@ -1859,7 +1859,7 @@
     module_info::in, prog_varset::in, bool::in, int::in,
     string::in, maybe_vartypes::in, io::di, io::uo) is det.
 
-write_goal_scope(Info, GoalExpr, ModuleInfo, VarSet,
+write_goal_scope(!.Info, GoalExpr, ModuleInfo, VarSet,
         AppendVarNums, Indent, Follow, TypeQual, !IO) :-
     GoalExpr = scope(Reason, Goal),
     write_indent(Indent, !IO),
@@ -1969,7 +1969,13 @@
             Kind = from_ground_term_other,
             io.write_string("other", !IO)
         ),
-        io.write_string("]\n", !IO)
+        io.write_string("]\n", !IO),
+        % The goals inside from_ground_term scopes are created with
+        % all of the fields of goal infos already filled in.
+        % This means printing them is meaningful, and sometimes
+        % it is needed to diagnose problems.
+        DumpOptionsBackup = !.Info ^ hoi_dump_hlds_options_backup,
+        !:Info = !.Info ^ hoi_dump_hlds_options := DumpOptionsBackup
     ;
         Reason = trace_goal(MaybeCompileTime, MaybeRunTime, MaybeIO,
             MutableVars, QuantVars),
@@ -2022,7 +2028,7 @@
         mercury_output_vars(VarSet, AppendVarNums, [LCVar, LCSVar], !IO),
         io.write_string(") (\n", !IO)
     ),
-    do_write_goal(Info, Goal, ModuleInfo, VarSet, AppendVarNums,
+    do_write_goal(!.Info, Goal, ModuleInfo, VarSet, AppendVarNums,
         Indent + 1, "\n", TypeQual, !IO),
     write_indent(Indent, !IO),
     io.write_string(")", !IO),
Index: hlds_out_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_out_util.m,v
retrieving revision 1.4
diff -u -b -r1.4 hlds_out_util.m
--- hlds_out_util.m	8 Apr 2011 07:25:45 -0000	1.4
+++ hlds_out_util.m	12 Apr 2012 09:22:35 -0000
@@ -36,6 +36,7 @@
 :- type hlds_out_info
     --->    hlds_out_info(
                 hoi_dump_hlds_options       :: string,
+                hoi_dump_hlds_options_backup    :: string,
                 hoi_dump_hlds_pred_ids      :: list(string),
                 hoi_dump_hlds_pred_names    :: list(string),
                 hoi_mercury_to_mercury      :: merc_out_info
@@ -222,7 +223,7 @@
     globals.lookup_accumulating_option(Globals, dump_hlds_pred_id, Ids),
     globals.lookup_accumulating_option(Globals, dump_hlds_pred_name, Names),
     MercInfo = init_merc_out_info_for_hlds_dump(Globals),
-    Info = hlds_out_info(DumpOptions, Ids, Names, MercInfo).
+    Info = hlds_out_info(DumpOptions, DumpOptions, Ids, Names, MercInfo).
 
 %-----------------------------------------------------------------------------%
 %
--------------------------------------------------------------------------
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