[m-rev.] diff: c_code formatting

Zoltan Somogyi zs at cs.mu.OZ.AU
Sun Aug 18 16:39:59 AEST 2002


Make newlines line terminators, not line separators, in C code constructed by
the compiler. This makes it easier to put such C code fragments together
and get nice looking code.

compiler/llds_out.m:
	Do not add a newline at the end of such C code fragments.

compiler/code_info.m:
compiler/trace.m:
	Adjust the formatting of compiler-generated C code fragments
	accordingly.

Zoltan.

cvs diff: Diffing .
Index: code_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.269
diff -u -b -r1.269 code_info.m
--- code_info.m	2002/07/30 08:24:57	1.269
+++ code_info.m	2002/08/16 07:39:12
@@ -1866,13 +1866,13 @@
 			% inside MR_commit_{mark,cut}.
 			Components = [
 				pragma_c_raw_code(
-					"\tMR_save_transient_registers();\n",
+					"\t\tMR_save_transient_registers();\n",
 					live_lvals_info(set__init)),
 				pragma_c_raw_code(
-					"\tMR_commit_mark();\n",
+					"\t\tMR_commit_mark();\n",
 					live_lvals_info(set__init)),
 				pragma_c_raw_code(
-					"\tMR_restore_transient_registers();\n",
+					"\t\tMR_restore_transient_registers();\n",
 					live_lvals_info(set__init))
 			],
 			MarkCode = node([
@@ -1951,7 +1951,7 @@
 			UseMinimalModel = yes,
 			% See the comment in prepare_for_semi_commit above.
 			Components = [
-				pragma_c_raw_code("\tMR_commit_cut();\n",
+				pragma_c_raw_code("\t\tMR_commit_cut();\n",
 					live_lvals_info(set__init))
 			],
 			CutCode = node([
Index: llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.198
diff -u -b -r1.198 llds_out.m
--- llds_out.m	2002/08/08 08:15:41	1.198
+++ llds_out.m	2002/08/16 07:39:12
@@ -1865,7 +1865,7 @@
 	io__write_string("\t{\n"),
 	output_pragma_decls(Decls),
 	output_pragma_c_components(Components),
-	io__write_string("\n\t}\n").
+	io__write_string("\t}\n").
 
 output_instruction(init_sync_term(Lval, N), _) -->
 	io__write_string("\tMR_init_sync_term("),
Index: trace.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/trace.m,v
retrieving revision 1.54
diff -u -b -r1.54 trace.m
--- trace.m	2002/07/30 08:25:12	1.54
+++ trace.m	2002/08/16 07:39:25
@@ -511,14 +511,14 @@
 	string__append_list([
 		"\t\t", EventNumStr, " = MR_trace_event_number;\n",
 		"\t\t", CallNumStr, " = MR_trace_incr_seq();\n",
-		"\t\t", CallDepthStr, " = MR_trace_incr_depth();"
+		"\t\t", CallDepthStr, " = MR_trace_incr_depth();\n"
 	], FillThreeSlots),
 	(
 		MaybeIoSeqSlot = yes(IoSeqLval),
 		trace__stackref_to_string(IoSeqLval, IoSeqStr),
 		string__append_list([
-			FillThreeSlots, "\n",
-			"\t\t", IoSeqStr, " = MR_io_tabling_counter;"
+			FillThreeSlots,
+			"\t\t", IoSeqStr, " = MR_io_tabling_counter;\n"
 		], FillSlotsUptoIoSeq)
 	;
 		MaybeIoSeqSlot = no,
@@ -531,10 +531,10 @@
 		LayoutAddrStr =
 			layout_out__make_label_layout_name(RedoLayoutLabel),
 		string__append_list([
-			FillSlotsUptoIoSeq, "\n",
+			FillSlotsUptoIoSeq,
 			"\t\t", RedoLayoutStr,
 				" = (MR_Word) (const MR_Word *) &",
-				LayoutAddrStr, ";"
+				LayoutAddrStr, ";\n"
 		], FillSlotsUptoRedo),
 		MaybeLayoutLabel = yes(RedoLayoutLabel)
 	;
@@ -551,9 +551,9 @@
 		trace__stackref_to_string(TrailLval, TrailLvalStr),
 		trace__stackref_to_string(TicketLval, TicketLvalStr),
 		string__append_list([
-			FillSlotsUptoRedo, "\n",
+			FillSlotsUptoRedo,
 			"\t\tMR_mark_ticket_stack(", TicketLvalStr, ");\n",
-			"\t\tMR_store_ticket(", TrailLvalStr, ");"
+			"\t\tMR_store_ticket(", TrailLvalStr, ");\n"
 		], FillSlotsUptoTrail)
 	;
 		MaybeTrailLvals = no,
@@ -566,10 +566,10 @@
 		string__append_list([
 			"\t\t", CallFromFullSlotStr, " = MR_trace_from_full;\n",
 			"\t\tif (MR_trace_from_full) {\n",
-			FillSlotsUptoTrail, "\n",
+			FillSlotsUptoTrail,
 			"\t\t} else {\n",
 			"\t\t\t", CallDepthStr, " = MR_trace_call_depth;\n",
-			"\t\t}"
+			"\t\t}\n"
 		], TraceStmt1)
 	;
 		MaybeFromFullSlot = no,
@@ -594,7 +594,7 @@
 		MaybeCallTableLval = yes(CallTableLval),
 		trace__stackref_to_string(CallTableLval, CallTableLvalStr),
 		string__append_list([
-			"\t\t", CallTableLvalStr, " = 0;"
+			"\t\t", CallTableLvalStr, " = 0;\n"
 		], TraceStmt3),
 		TraceCode3 = node([
 			pragma_c([], [pragma_c_raw_code(TraceStmt3,
@@ -818,7 +818,7 @@
 	DeclStmt = "\t\tMR_Code *MR_jumpaddr;\n",
 	SaveStmt = "\t\tMR_save_transient_registers();\n",
 	RestoreStmt = "\t\tMR_restore_transient_registers();\n",
-	GotoStmt = "\t\tif (MR_jumpaddr != NULL) MR_GOTO(MR_jumpaddr);"
+	GotoStmt = "\t\tif (MR_jumpaddr != NULL) MR_GOTO(MR_jumpaddr);\n"
 	},
 	{ string__append_list([
 		"\t\tMR_jumpaddr = MR_trace(\n",
cvs diff: Diffing notes
--------------------------------------------------------------------------
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