[m-dev.] trivial diff: layout generated code nicely (was: implement pragma export for MLDS backend)

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Jul 24 18:48:58 AEST 2000

On 12-Jul-2000, Peter Ross <petdr at cs.mu.OZ.AU> wrote:
> Implement `pragma export' for the MLDS backend.

I noticed a couple of problems with this change:

	(a) the generated code is not as nicely formatted
	    as it could be

	(b) the generated code sometimes (or often,
	    if you enable `--high-level-data') 
	    contains type errors, which lead to warnings
	    from gcc and which could lead to errors from
	    other C compilers.
	    This is because the types of the arguments
	    in the exported function don't always match
	    the types of the arguments in the function
	    that it calls.  The generated code should
	    contain casts to convert the arguments to
	    the right type.

The following diff fixes (a).


Estimated hours taken: 0.5

	Ensure that the C code that we generate for
	`pragma export' declarations is properly indented
	and has spaces after the commas in argument lists.

Workspace: /home/pgrad/fjh/ws/hg
Index: compiler/mlds_to_c.m
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.42
diff -u -d -r1.42 mlds_to_c.m
--- compiler/mlds_to_c.m	2000/07/20 10:39:30	1.42
+++ compiler/mlds_to_c.m	2000/07/24 08:07:56
@@ -380,6 +380,8 @@
 	{ PragmaExport = ml_pragma_export(_C_name, MLDS_Name, MLDS_Signature,
 			Context, IsFunc) },
 	mlds_output_pragma_export_func_name(ModuleName, Indent, PragmaExport),
+	io__write_string("\n"),
+	mlds_indent(Context, Indent),
 	mlds_indent(Context, Indent),
@@ -474,7 +476,7 @@
 	mlds_output_fully_qualified_name(qual(ModuleName, FuncName)),
-	io__write_list(QualNames, ",", mlds_output_fully_qualified_name),
+	io__write_list(QualNames, ", ", mlds_output_fully_qualified_name),

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        |     -- 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