[m-dev.] for review: MLDS back-end: clean up `pragma c_code' handling

Fergus Henderson fjh at cs.mu.OZ.AU
Fri May 26 17:01:34 AEST 2000


On 26-May-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> 
> Clean up the handling of `pragma c_code' in the MLDS back-end.

Testing revealed that this change caused some problems,
because some of the `#line' directives that we generated
did not start at the beginning of a line.  Hence the
following additional changes.

I'll go ahead and commit this change now.

diff -u old/mlds.m ./mlds.m
--- old/mlds.m	Fri May 26 16:56:50 2000
+++ ./mlds.m	Fri May 26 16:56:31 2000
@@ -887,7 +887,10 @@
 			% the user's `pragma c_code' declaration
 	;	raw_target_code(string)
 			% raw_target_code holds C code that the
-			% compiler has generated.
+			% compiler has generated.  To ensure that
+			% following `#line' directives work OK,
+			% the string in a raw_target_code must
+			% end in `\n' (or `\n' followed by whitespace).
 	;	target_code_input(mlds__rval)
 	;	target_code_output(mlds__lval)
 	.
diff -u old/ml_code_gen.m ./ml_code_gen.m
--- old/ml_code_gen.m	Fri May 26 16:49:27 2000
+++ ./ml_code_gen.m	Fri May 26 16:49:30 2000
@@ -2015,7 +2015,7 @@
 		;
 			Cast = ""
 		},
-		{ string__format("\t%s = %s", [s(ArgName), s(Cast)],
+		{ string__format("\t%s = %s\n", [s(ArgName), s(Cast)],
 			AssignToArgName) },
 		{ AssignInput = [
 			raw_target_code(AssignToArgName),
diff -u old/mlds_to_c.m ./mlds_to_c.m
--- old/mlds_to_c.m	Fri May 26 16:49:27 2000
+++ ./mlds_to_c.m	Fri May 26 16:49:32 2000
@@ -1595,7 +1595,8 @@
 	;
 		mlds_output_context(Context)
 	),
-	io__write_string(CodeString).
+	io__write_string(CodeString),
+	io__write_string("\n").
 mlds_output_target_code_component(Context, raw_target_code(CodeString)) -->
 	mlds_output_context(Context),
 	io__write_string(CodeString).

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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