[m-rev.] diff: more .NET fixes

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Feb 16 13:11:01 AEDT 2003


Estimated hours taken: 4
Branches: main

Various fixes for the .NET back-end.

compiler/passes_aux.m:
	Provide Mercury clauses as alternatives to C foreign_proc code
	for `use_win32'.

compiler/top_level.m:
compiler/mercury_compile.m:
	Work-around a bug with the Mercury compiler's .NET back-end:
	Define `main' in toplevel.m, rather than in `mercury_compile.m',
	because the .NET back-end assumes that `main' will be defined in
	the top-level module.
	XXX This is not the right fix, because it makes `main' and `io.*'
	visible in all the child modules of `toplevel.m', which is not
	desirable.

compiler/mercury_compile.m:
	Add Mercury clauses for gc_init.

compiler/modules.m:
	Don't warn about the fact that io__file_modification_time not
	being implemented causes problems for smart recompilation,
	unless we're actually compiling with smart recompilation enabled.

Workspace: /home/fjh/ws/hermes
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.273
diff -u -d -r1.273 mercury_compile.m
--- compiler/mercury_compile.m	11 Feb 2003 02:14:26 -0000	1.273
+++ compiler/mercury_compile.m	16 Feb 2003 02:08:05 -0000
@@ -18,8 +18,10 @@
 
 :- import_module io, list.
 
-:- pred main(io__state, io__state).
-:- mode main(di, uo) is det.
+	% This is the main entry point for the Mercury compiler.
+	% It is called from top_level.main.
+:- pred real_main(io__state, io__state).
+:- mode real_main(di, uo) is det.
 
 	% main(Args).
 :- pred main(list(string), io__state, io__state).
@@ -121,7 +123,7 @@
 
 %-----------------------------------------------------------------------------%
 
-main -->
+real_main -->
 	gc_init,
 
 	 	% All messages go to stderr
@@ -170,6 +172,9 @@
 %-----------------------------------------------------------------------------%
 
 :- pred gc_init(io__state::di, io__state::uo) is det.
+
+% This version is only used if there is no matching foreign_proc version.
+gc_init --> [].
 
 :- pragma foreign_proc("C",
 	gc_init(_IO0::di, _IO::uo),
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.265
diff -u -d -r1.265 modules.m
--- compiler/modules.m	12 Feb 2003 22:58:10 -0000	1.265
+++ compiler/modules.m	16 Feb 2003 02:08:05 -0000
@@ -5438,8 +5438,14 @@
 	;
 		{ MaybeTimestamp0 = yes(error(IOError)) },
 		{ MaybeTimestamp = no },
-		report_modification_time_warning(
-			FileName, IOError)
+		globals__io_lookup_bool_option(smart_recompilation,
+			SmartRecompilation),
+		( { SmartRecompilation = yes } ->
+			report_modification_time_warning(
+				FileName, IOError)
+		;
+			[]
+		)
 	;
 		{ MaybeTimestamp0 = no },
 		{ MaybeTimestamp = no }
Index: compiler/passes_aux.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/passes_aux.m,v
retrieving revision 1.51
diff -u -d -r1.51 passes_aux.m
--- compiler/passes_aux.m	5 Feb 2003 14:41:14 -0000	1.51
+++ compiler/passes_aux.m	16 Feb 2003 02:08:05 -0000
@@ -633,6 +634,12 @@
 	).
 
 	% Are we compiling in a win32 environment?
+	%
+	% If in doubt, use_win32 should succeed.  This is only used to
+	% decide whether to invoke Bourne shell command and shell scripts
+	% directly, or whether to invoke them via `sh -c ...'.  The latter
+	% should work correctly in a Unix environment too, but is a little
+	% less efficient since it invokes another process.
 :- pred use_win32 is semidet.
 :- pragma foreign_proc("C",
 	use_win32,
@@ -644,6 +651,9 @@
 	SUCCESS_INDICATOR = 0;
 #endif
 ").
+% The following clause is only used if there is no matching foreign_proc.
+% See comment above for why it is OK to just succeed here.
+use_win32 :- semidet_succeed.
 
 maybe_report_sizes(HLDS) -->
 	globals__io_lookup_bool_option(statistics, Statistics),
Index: compiler/top_level.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/top_level.m,v
retrieving revision 1.1
diff -u -d -r1.1 top_level.m
--- compiler/top_level.m	20 Mar 2002 12:37:29 -0000	1.1
+++ compiler/top_level.m	16 Feb 2003 02:08:05 -0000
@@ -27,6 +27,18 @@
 
 :- include_module mercury_compile.
 
+% XXX It would be nicer to define `main' in top_level.mercury_compile,
+%     rather than defining it here.  But that doesn't work with the
+%     Mercury compiler's .NET back-end, which assumes that main is defined
+%     in the program's top-level module.
+:- use_module io.
+:- use_module top_level.mercury_compile.
+:- pred main(io.state::di, io.state::uo) is det.
+
+:- implementation.
+
+main --> top_level.mercury_compile.real_main.
+
 :- end_module top_level.
 
 %-----------------------------------------------------------------------------%

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