[m-rev.] For review: Add --dump-xml-hlds option to compiler
Ian MacLarty
maclarty at cs.mu.OZ.AU
Thu Dec 9 13:13:46 AEDT 2004
Estimated hours taken: 0.5
Branches: main
Add --dump-xml-hlds option to compiler to dump the HLDS in XML format (some
code thanks to Julien).
compiler/mercury_compile.m
Handle --dump-xml-hlds option.
compiler/options.m
Add --dump-xml-hlds option.
doc/user_guide.texi
Document --dump-xml-hlds option.
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.316
diff -u -r1.316 mercury_compile.m
--- compiler/mercury_compile.m 20 Oct 2004 09:44:57 -0000 1.316
+++ compiler/mercury_compile.m 9 Dec 2004 01:53:38 -0000
@@ -168,6 +168,7 @@
:- import_module library, getopt, set_bbbtree, term, varset, assoc_list.
:- import_module gc.
:- import_module pprint.
+:- import_module term_to_xml.
%-----------------------------------------------------------------------------%
@@ -4336,6 +4337,25 @@
string__append_list(["can't open file `",
DumpFile, "' for output."], ErrorMessage),
report_error(ErrorMessage, !IO)
+ ),
+ globals.io_lookup_bool_option(dump_xml_hlds, DumpXML, !IO),
+ ( DumpXML = yes ->
+ io__open_output(DumpFile ++ ".xml", XMLRes, !IO),
+ maybe_write_string(Verbose, "% Dump out HLDSXML ...\n", !IO),
+ ( XMLRes = ok(XMLFileStream) ->
+ term_to_xml__write_xml_doc(XMLFileStream, HLDS, simple,
+ no_stylesheet, no_dtd, _, !IO),
+ io__close_output(XMLFileStream, !IO),
+ maybe_write_string(Verbose, " done.\n", !IO)
+ ;
+ maybe_write_string(Verbose, "\n", !IO),
+ string__append_list(["can't open file `",
+ DumpFile ++ ".xml",
+ "' for output."], XMLErrorMessage),
+ report_error(XMLErrorMessage, !IO)
+ )
+ ;
+ true
).
:- pred mercury_compile__maybe_dump_mlds(mlds::in, int::in, string::in,
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.437
diff -u -r1.437 options.m
--- compiler/options.m 30 Nov 2004 06:54:32 -0000 1.437
+++ compiler/options.m 9 Dec 2004 01:53:38 -0000
@@ -163,6 +163,7 @@
; auto_comments
; show_dependency_graph
; dump_hlds
+ ; dump_xml_hlds
; dump_hlds_pred_id
; dump_hlds_alias
; dump_hlds_options
@@ -828,6 +829,7 @@
auto_comments - bool(no),
show_dependency_graph - bool(no),
dump_hlds - accumulating([]),
+ dump_xml_hlds - bool(no),
dump_hlds_pred_id - int(-1),
dump_hlds_alias - string(""),
dump_hlds_options - string(""),
@@ -1478,6 +1480,7 @@
long_option("auto-comments", auto_comments).
long_option("show-dependency-graph", show_dependency_graph).
long_option("dump-hlds", dump_hlds).
+long_option("dump-xml-hlds", dump_xml_hlds).
long_option("hlds-dump", dump_hlds).
long_option("dump-hlds-pred-id", dump_hlds_pred_id).
long_option("dump-hlds-alias", dump_hlds_alias).
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.399
diff -u -r1.399 user_guide.texi
--- doc/user_guide.texi 9 Dec 2004 01:03:09 -0000 1.399
+++ doc/user_guide.texi 9 Dec 2004 02:05:17 -0000
@@ -5104,6 +5104,14 @@
to the HLDS of the predicate or function with the specified pred id.
@sp 1
+ at item --dump-xml-hlds
+This option must be specified in conjunction with the --dump-hlds option and
+causes an additional dump of the entire HLDS in XML format. The filename
+used is the same as for the regular HLDS dump except with `.xml' as a suffix.
+The `simple' mapping defined in the term_to_xml standard library is used to map
+functors to XML elements. Beware that the XML dumps are very big.
+
+ at sp 1
@item --dump-mlds @var{stage}
@findex --dump-mlds
Dump the MLDS (a C-like intermediate representation) after
--------------------------------------------------------------------------
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