[m-rev.] diff: .NET: fix exit status after exception

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Oct 24 02:28:47 AEST 2002


Estimated hours taken: 1
Branches: main

Fix a bug that broke tests/hard_coded/no_fully_strict in grade il.

compiler/mlds_to_il.m:
	If an exception occurs, return a non-zero exit status.

Workspace: /c/fjh/ws/2/mercury
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.120
diff -u -d -r1.120 mlds_to_il.m
--- compiler/mlds_to_il.m	17 Oct 2002 18:42:14 -0000	1.120
+++ compiler/mlds_to_il.m	23 Oct 2002 16:30:29 -0000
@@ -1134,6 +1134,9 @@
 			instr_node(ldstr("\nUncaught system exception: \n")),
 			instr_node(call(WriteString)),
 			instr_node(call(WriteObject)),
+			instr_node(ldc(int32, i(1))), 
+			instr_node(call(il_set_exit_code)),
+
 			instr_node(leave(label_target(DoneLabel))),
 			instr_node(end_block(catch(ExceptionClassName),
 				OuterCatchBlockId))
@@ -1149,6 +1152,9 @@
 
 			instr_node(call(WriteUncaughtException)),
 
+			instr_node(ldc(int32, i(1))), 
+			instr_node(call(il_set_exit_code)),
+
 			instr_node(leave(label_target(DoneLabel))),
 			instr_node(end_block(
 				catch(MercuryExceptionClassName),
@@ -1177,10 +1183,12 @@
 			%	}
 			%	catch (mercury.runtime.Exception me) {
 			%		ML_report_uncaught_exception(me);
+			%		System.Environment.ExitCode = 1;
 			%	}
 			% } 
 			% catch (System.Exception e) {
 			%	System.Console.Write(e);
+			%	System.Environment.ExitCode = 1;
 			% }
 
 		{ InstrsTree = tree__list([
@@ -3886,6 +3894,19 @@
 
 :- func il_exception_class_name = ilds__class_name.
 il_exception_class_name = mercury_runtime_name(["Exception"]).
+
+%-----------------------------------------------------------------------------%
+
+	% The System.Environment.set_ExitCode method
+	% (the "setter" for the System.Environment.ExitCode property).
+	% We use this to set a non-zero exit status when
+	% the main method exits due to an uncaught exception.
+:- func il_set_exit_code = methodref.
+il_set_exit_code = get_static_methodref(system_environment_class_name,
+	id("set_ExitCode"), void, [ilds__type([], int32)]).
+
+:- func system_environment_class_name = ilds__class_name.
+system_environment_class_name = il_system_name(["Environment"]).
 
 %-----------------------------------------------------------------------------%
 %
--------------------------------------------------------------------------
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