diff: output class table properly
David Glen JEFFERY
dgj at cs.mu.OZ.AU
Tue Jan 27 15:26:29 AEDT 1998
Hi,
Zoltan, can you please review this?
Estimated hours taken: 1
compiler/hlds_out.m:
Output the contents of the class table in a nicely readable format,
rather than just io__printing.
Index: hlds_out.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/hlds_out.m,v
retrieving revision 1.181
diff -u -r1.181 hlds_out.m
--- hlds_out.m 1998/01/13 10:12:15 1.181
+++ hlds_out.m 1998/01/27 04:22:47
@@ -1893,10 +1893,71 @@
% XXX fix this up.
hlds_out__write_indent(Indent),
io__write_string("%-------- Classes --------\n"),
+ { map__to_assoc_list(ClassTable, ClassTableList) },
+ io__write_list(ClassTableList, "\n",
+ hlds_out__write_class_defn(Indent)),
+ io__nl.
+
+:- pred hlds_out__write_class_defn(int, pair(class_id, hlds_class_defn),
+ io__state, io__state).
+:- mode hlds_out__write_class_defn(in, in, di, uo) is det.
+
+hlds_out__write_class_defn(Indent, ClassId - ClassDefn) -->
hlds_out__write_indent(Indent),
io__write_string("% "),
- io__print(ClassTable),
+
+ { ClassId = class_id(SymName, Arity) },
+ prog_out__write_sym_name(SymName),
+ io__write_string("/"),
+ io__write_int(Arity),
+ io__write_string(":\n"),
+
+ { ClassDefn = hlds_class_defn(Constraints, Vars, Interface, VarSet,
+ Context) },
+
+ { term__context_file(Context, FileName) },
+ { term__context_line(Context, LineNumber) },
+ ( { FileName \= "" } ->
+ hlds_out__write_indent(Indent),
+ io__write_string("% context: file `"),
+ io__write_string(FileName),
+ io__write_string("', line "),
+ io__write_int(LineNumber),
+ io__write_string("\n")
+ ;
+ []
+ ),
+
+ % curry the varset for term_io__write_variable/4
+ { PrintVar = lambda([VarName::in, IO0::di, IO::uo] is det,
+ term_io__write_variable(VarName, VarSet, IO0, IO)
+ ) },
+ hlds_out__write_indent(Indent),
+ io__write_string("% Vars: "),
+ io__write_list(Vars, ", ", PrintVar),
+ io__nl,
+
+ hlds_out__write_indent(Indent),
+ io__write_string("% Constraints: "),
+ io__write_list(Constraints, ", ", mercury_output_constraint(VarSet)),
+ io__nl,
+
+ hlds_out__write_indent(Indent),
+ io__write_string("% Class Methods: "),
+ io__write_list(Interface, ", ", hlds_out__write_class_proc),
io__nl.
+
+:- pred hlds_out__write_class_proc(hlds_class_proc, io__state, io__state).
+:- mode hlds_out__write_class_proc(in, di, uo) is det.
+
+hlds_out__write_class_proc(hlds_class_proc(PredId, ProcId)) -->
+ io__write_string("hlds_class_proc(pred_id:"),
+ { pred_id_to_int(PredId, PredInt) },
+ io__write_int(PredInt),
+ io__write_string(", proc_id:"),
+ { proc_id_to_int(ProcId, ProcInt) },
+ io__write_int(ProcInt),
+ io__write_char(')').
%-----------------------------------------------------------------------------%
love and cuddles,
dgj
--
David Jeffery (dgj at cs.mu.oz.au) | Marge: Did you just call everyone "chicken"?
MEngSc student, | Homer: Noooo. I swear on this Bible!
Department of Computer Science | Marge: That's not a Bible; that's a book of
University of Melbourne | carpet samples!
Australia | Homer: Ooooh... Fuzzy.
More information about the developers
mailing list