[m-rev.] diff: fix bug with --mlds-dump & --target il
Fergus Henderson
fjh at cs.mu.OZ.AU
Sat Aug 11 22:33:43 AEST 2001
Estimated hours taken: 0.5
Branches: main
compiler/mlds_to_c.m:
Fix a bug that broke things when compiling with `--target il
--mlds-dump all'; it was calling map__lookup on an empty map.
Workspace: /home/venus/fjh/ws-venus4/mercury
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.100
diff -u -d -r1.100 mlds_to_c.m
--- compiler/mlds_to_c.m 3 Aug 2001 12:07:25 -0000 1.100
+++ compiler/mlds_to_c.m 11 Aug 2001 12:21:39 -0000
@@ -124,7 +124,7 @@
mlds_output_hdr_start(Indent, ModuleName), io__nl,
mlds_output_hdr_imports(Indent, Imports), io__nl,
% Get the foreign code for C
- { ForeignCode = map__lookup(AllForeignCode, c) },
+ { ForeignCode = mlds_get_c_foreign_code(AllForeignCode) },
mlds_output_c_hdr_decls(MLDS_ModuleName, Indent, ForeignCode), io__nl,
%
% The header file must contain _definitions_ of all public types,
@@ -197,7 +197,7 @@
mlds_output_src_imports(Indent, Imports), io__nl,
% Get the foreign code for C
- { ForeignCode = map__lookup(AllForeignCode, c) },
+ { ForeignCode = mlds_get_c_foreign_code(AllForeignCode) },
mlds_output_c_decls(Indent, ForeignCode), io__nl,
%
% The public types have already been defined in the
@@ -368,6 +368,19 @@
"/* ensure everything is compiled with the same grade */\n"),
io__write_string(
"static const void *const MR_grade = &MR_GRADE_VAR;\n").
+
+:- func mlds_get_c_foreign_code(map(foreign_language, mlds__foreign_code))
+ = mlds__foreign_code.
+
+ % Get the foreign code for C
+mlds_get_c_foreign_code(AllForeignCode) = ForeignCode :-
+ ( map__search(AllForeignCode, c, ForeignCode0) ->
+ ForeignCode = ForeignCode0
+ ;
+ % this can occur when compiling to a non-C target
+ % using "--mlds-dump all"
+ ForeignCode = foreign_code([], [], [])
+ ).
%-----------------------------------------------------------------------------%
--
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