[m-rev.] diff: fix `--target il' abort with `--use-subdirs'
Simon Taylor
stayl at cs.mu.OZ.AU
Tue Oct 29 18:00:54 AEDT 2002
Estimated hours taken: 1
Branches: main
compiler/mlds_to_ilasm.m:
Fix a compiler abort with `--use-subdirs'.
tests/valid/Mmakefile:
tests/valid/csharp_hello.m:
Test case.
Index: compiler/mlds_to_ilasm.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_ilasm.m,v
retrieving revision 1.18
diff -u -u -r1.18 mlds_to_ilasm.m
--- compiler/mlds_to_ilasm.m 21 Jun 2002 13:26:46 -0000 1.18
+++ compiler/mlds_to_ilasm.m 28 Oct 2002 12:39:22 -0000
@@ -34,6 +34,7 @@
:- import_module hlds__hlds_pred. % for `pred_proc_id'.
:- import_module parse_tree__prog_data, parse_tree__prog_out.
:- import_module backend_libs__rtti, check_hlds__type_util, hlds__error_util.
+:- import_module backend_libs__foreign.
:- import_module ml_backend__ilds, ml_backend__ilasm, ml_backend__il_peephole.
:- import_module ml_backend__ml_util, ml_backend__ml_code_util.
@@ -70,20 +71,30 @@
output_foreign_file(MLDS, ForeignLang) -->
{ ModuleName = mlds__get_module_name(MLDS) },
- { handle_foreign_lang(ForeignLang, Extension, CodeGenerator) },
- module_name_to_file_name(ModuleName, Extension, yes, File),
- output_to_file(File, (pred(di, uo) is det --> CodeGenerator(MLDS))).
+ (
+ { ForeignModuleName = foreign_language_module_name(ModuleName,
+ ForeignLang) },
+ { Extension = foreign_language_file_extension(ForeignLang) }
+ ->
+ { handle_foreign_lang(ForeignLang, CodeGenerator) },
+ module_name_to_file_name(ForeignModuleName, Extension,
+ yes, File),
+ output_to_file(File,
+ (pred(di, uo) is det --> CodeGenerator(MLDS)))
+ ;
+ { error(
+ "mlds_to_ilasm__output_foreign_file: unexpected language") }
+ ).
-:- pred handle_foreign_lang(foreign_language::in, string::out,
+:- pred handle_foreign_lang(foreign_language::in,
pred(mlds, io__state, io__state)::out(pred(in, di, uo) is det))
is det.
-handle_foreign_lang(managed_cplusplus, "__cpp_code.cpp",
- output_managed_code(managed_cplusplus)).
-handle_foreign_lang(csharp, "__csharp_code.cs", output_managed_code(csharp)).
-handle_foreign_lang(c, _, _) :-
+handle_foreign_lang(managed_cplusplus, output_managed_code(managed_cplusplus)).
+handle_foreign_lang(csharp, output_managed_code(csharp)).
+handle_foreign_lang(c, _) :-
sorry(this_file, "language C foreign code not supported").
-handle_foreign_lang(il, _, _) :-
+handle_foreign_lang(il, _) :-
sorry(this_file, "language IL foreign code not supported").
%
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.115
diff -u -u -r1.115 Mmakefile
--- tests/valid/Mmakefile 23 Oct 2002 13:16:42 -0000 1.115
+++ tests/valid/Mmakefile 28 Oct 2002 12:48:07 -0000
@@ -46,6 +46,7 @@
# Tests for which we should only produce a `.il' file.
IL_PROGS = \
+ csharp_hello \
foreign_type_spec
OTHER_PROGS= \
Index: tests/valid/csharp_hello.m
===================================================================
RCS file: tests/valid/csharp_hello.m
diff -N tests/valid/csharp_hello.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/valid/csharp_hello.m 28 Oct 2002 12:31:43 -0000
@@ -0,0 +1,12 @@
+:- module csharp_hello.
+:- interface.
+:- import_module io.
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- pragma foreign_proc("C#", main(_IO0::di,_IO::uo),
+ [will_not_call_mercury, promise_pure],
+"
+ System.Console.WriteLine(""Hello Mercury/C# world"");
+").
--------------------------------------------------------------------------
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