[m-rev.] diff: fix pragma export bug with foreign types

Peter Ross peter.ross at miscrit.be
Wed May 8 00:44:07 AEST 2002


Hi,


===================================================================


Estimated hours taken: 4
Branches: main

Fix a bug where for the LLDS backend we where outputting the foreign
type name for pragma exported functions, instead of MR_Word.

compiler/foreign.m:
    Add llds_exported_type_string which gives the string for a type when
    it is used as in a pragma export.

compiler/export.m:
    Use llds_exported_type_string.

Index: compiler/export.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/export.m,v
retrieving revision 1.53
diff -u -r1.53 export.m
--- compiler/export.m	20 Mar 2002 12:36:09 -0000	1.53
+++ compiler/export.m	7 May 2002 14:30:33 -0000
@@ -335,7 +335,7 @@
 			RetArgMode = top_out,
 			\+ type_util__is_dummy_argument_type(RetType)
 		->
-			C_RetType = to_type_string(c, Module, RetType),
+			C_RetType = llds_exported_type_string(Module, RetType),
 			argloc_to_string(RetArgLoc, RetArgString0),
 			convert_type_from_mercury(RetArgString0, RetType,
 				RetArgString),
@@ -435,7 +435,7 @@
 	;
 		ArgName = ""
 	),
-	TypeString0 = to_type_string(c, Module, Type),
+	TypeString0 = llds_exported_type_string(Module, Type),
 	(
 		Mode = top_out
 	->
Index: compiler/foreign.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/foreign.m,v
retrieving revision 1.14
diff -u -r1.14 foreign.m
--- compiler/foreign.m	7 May 2002 11:02:44 -0000	1.14
+++ compiler/foreign.m	7 May 2002 14:30:33 -0000
@@ -79,6 +79,11 @@
 :- func foreign__to_type_string(foreign_language, exported_type) = string.
 :- func foreign__to_type_string(foreign_language, module_info, (type)) = string.
 
+	% Give a representation of a type determine the string which
+	% corresponds to that type when the type is mentioned via a
+	% pragma export on the llds backend.
+:- func llds_exported_type_string(module_info, (type)) = string.
+
 	% Filter the decls for the given foreign language. 
 	% The first return value is the list of matches, the second is
 	% the list of mis-matches.
@@ -668,6 +673,14 @@
 	).
 to_type_string(il, mercury(_Type)) = _ :-
 	sorry(this_file, "to_type_string for il").
+
+llds_exported_type_string(ModuleInfo, Type) = TypeString :-
+	ExportedType = to_exported_type(ModuleInfo, Type),
+	( ExportedType = foreign(_),
+		TypeString = "MR_Word"
+	; ExportedType = mercury(_),
+		TypeString = to_type_string(c, ExportedType)
+	).
 	
 %-----------------------------------------------------------------------------%
 

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