Diff: Printing of cons_ids

Andrew Bromage bromage at cs.mu.oz.au
Fri May 30 15:01:17 AEST 1997


G'day all.

For review.

Cheers,
Andrew Bromage
--------8<---CUT HERE---8<--------
Estimated hours taken: 0.5

Meaningful printing of cons_ids which are pred_consts, code_addr_consts
and base_type_info_consts.  Previously, the compiler was giving a run-time
error while printing some HLDS dumps.

Also the removal of one when declaration which happened to be nearby, now
deprecated since we don't really support the NU-Prolog version of the
compiler any more.

compiler/mercury_to_mercury.m:
	Minor changes described above.

Index: mercury_to_mercury.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.103
diff -u -r1.103 mercury_to_mercury.m
--- mercury_to_mercury.m	1997/05/01 09:56:10	1.103
+++ mercury_to_mercury.m	1997/05/30 01:04:22
@@ -787,14 +787,32 @@
 	io__write_float(X).
 mercury_output_cons_id(string_const(X), _) -->
 	io__write_strings(["""", X, """"]).
-mercury_output_cons_id(pred_const(_, _), _) -->
-	{ error("mercury_output_cons_id: pred_const") }.
-mercury_output_cons_id(code_addr_const(_, _), _) -->
-	{ error("mercury_output_cons_id: code_addr_const") }.
-mercury_output_cons_id(base_type_info_const(_, _, _), _) -->
-	{ error("mercury_output_cons_id: base_type_info_const") }.
+mercury_output_cons_id(pred_const(PredId, ProcId), _) -->
+	% XXX Sufficient, but probably should print this out in
+	%     name/arity form.
 
-:- mercury_output_mode_defn(_, X, _, _, _) when X. 	% NU-Prolog indexing.
+	{ pred_id_to_int(PredId, PredInt) },
+	{ proc_id_to_int(ProcId, ProcInt) },
+	io__write_string("<pred_const("),
+	io__write_int(PredInt),
+	io__write_string(", "),
+	io__write_int(ProcInt),
+	io__write_string(")>").
+mercury_output_cons_id(code_addr_const(PredId, ProcId), _) -->
+	% XXX Sufficient, but probably should print this out in
+	%     name/arity form.
+
+	{ pred_id_to_int(PredId, PredInt) },
+	{ proc_id_to_int(ProcId, ProcInt) },
+	io__write_string("<code_addr_const("),
+	io__write_int(PredInt),
+	io__write_string(", "),
+	io__write_int(ProcInt),
+	io__write_string(")>").
+mercury_output_cons_id(base_type_info_const(Module, Type, Arity), _) -->
+	{ string__int_to_string(Arity, ArityString) },
+	io__write_strings(["<base_type_info for ", Module, ":", Type, "/",
+		ArityString, ">"]).
 
 mercury_output_mode_defn(VarSet, eqv_mode(Name, Args, Mode), Context) -->
 	io__write_string(":- mode ("),



More information about the developers mailing list