[m-dev.] for review: --auto-comments in IL backend

Tyson Dowd trd at cs.mu.OZ.AU
Thu Jan 11 21:21:49 AEDT 2001


Hi,

This one might go on the stable branch one day, but for now just on the
main development branch.

===================================================================


Estimated hours taken: 0.5

compiler/ilasm.m:
	Don't output comments in the IL assembler unless --auto-comments
	is set.  


Index: compiler/ilasm.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ilasm.m,v
retrieving revision 1.3
diff -u -r1.3 ilasm.m
--- compiler/ilasm.m	2000/11/09 07:47:03	1.3
+++ compiler/ilasm.m	2001/01/11 10:08:39
@@ -285,18 +285,33 @@
 	output_data_body(Body).
 
 ilasm__output_decl(comment_term(CommentTerm)) --> 
-	io__write_string("// "),
-	{ varset__init(VarSet) },
-	term_io__write_term(VarSet, CommentTerm),
-	io__write_string("\n").
+	globals__io_lookup_bool_option(auto_comments, PrintComments),
+	( { PrintComments = yes } ->
+		io__write_string("// "),
+		{ varset__init(VarSet) },
+		term_io__write_term(VarSet, CommentTerm),
+		io__write_string("\n")
+	;
+		[]
+	).
 
 ilasm__output_decl(comment_thing(Thing)) --> 
-	{ Doc = label("// ", to_doc(Thing)) },
-	write(70, Doc),
-	io__write_string("\n").
+	globals__io_lookup_bool_option(auto_comments, PrintComments),
+	( { PrintComments = yes } ->
+		{ Doc = label("// ", to_doc(Thing)) },
+		write(70, Doc),
+		io__nl
+	;
+		[]
+	).
 
 ilasm__output_decl(comment(CommentStr)) --> 
-	output_comment_string(CommentStr).
+	globals__io_lookup_bool_option(auto_comments, PrintComments),
+	( { PrintComments = yes } ->
+		output_comment_string(CommentStr)
+	;
+		[]
+	).
 
 ilasm__output_decl(extern_assembly(AsmName)) --> 
 	io__write_string(".assembly extern "),
@@ -345,18 +360,33 @@
 	output_field_initializer(Initializer).
 
 ilasm__output_classdecl(comment(CommentStr)) --> 
-	output_comment_string(CommentStr).
+	globals__io_lookup_bool_option(auto_comments, PrintComments),
+	( { PrintComments = yes } ->
+		output_comment_string(CommentStr)
+	;
+		[]
+	).
 
 ilasm__output_classdecl(comment_term(CommentTerm)) --> 
-	io__write_string("// "),
-	{ varset__init(VarSet) },
-	term_io__write_term(VarSet, CommentTerm),
-	io__write_string("\n").
+	globals__io_lookup_bool_option(auto_comments, PrintComments),
+	( { PrintComments = yes } ->
+		io__write_string("// "),
+		{ varset__init(VarSet) },
+		term_io__write_term(VarSet, CommentTerm),
+		io__nl
+	;
+		[]
+	).
 
 ilasm__output_classdecl(comment_thing(Thing)) --> 
-	{ Doc = label("// ", to_doc(Thing)) },
-	write(70, Doc),
-	io__write_string("\n").
+	globals__io_lookup_bool_option(auto_comments, PrintComments),
+	( { PrintComments = yes } ->
+		{ Doc = label("// ", to_doc(Thing)) },
+		write(70, Doc),
+		io__nl
+	;
+		[]
+	).
 
 :- pred ilasm__output_methodhead(methodhead::in, io__state::di,
 	io__state::uo) is det.
@@ -565,13 +595,14 @@
 	list(instr)::in, io__state::di, io__state::uo) is det.
 
 output_instructions(Instructions) --> 
+	globals__io_lookup_bool_option(auto_comments, PrintComments),
 	globals__io_lookup_bool_option(debug_il_asm, DebugIlAsm),
 	( 
 		{ DebugIlAsm = yes },
 		list__foldl(output_debug_instruction, Instructions)
 	;
 		{ DebugIlAsm = no },
-		list__foldl(output_instruction, Instructions)
+		list__foldl(output_instruction(PrintComments), Instructions)
 	).
 
 
@@ -645,20 +676,23 @@
 	io__write_string("\\n""\n"),
 	io__write_string("\t\tcall void System.Console::Write(class System.String)\n").
 
-:- pred output_instruction(instr::in, io__state::di,
+:- pred output_instruction(bool::in, instr::in, io__state::di,
 	io__state::uo) is det.
 
-output_instruction(Instr) --> 
-	io__write_string("\t"),
-	output_instr(Instr),
-	io__write_string("\n").
+output_instruction(PrintComments, Instr) --> 
+	( { Instr = comment(_), PrintComments = no } ->
+		[]
+	;
+		io__write_string("\t"),
+		output_instr(Instr),
+		io__write_string("\n")
+	).
 
 :- pred output_instr(instr::in, io__state::di,
 	io__state::uo) is det.
 
 output_instr(comment(Comment)) --> 
 	output_comment_string(Comment).
-
 
 output_instr(label(Label)) --> 
 	output_label(Label),


-- 
       Tyson Dowd           # Suburbia is where the developer bulldozes
                            # out the trees, then names the streets
     trd at cs.mu.oz.au        # after them.
http://www.cs.mu.oz.au/~trd # 		-- Bill Vaughn
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list