[m-rev.] diff: box value classes on IL backend

Peter Ross peter.ross at miscrit.be
Mon Jan 14 15:22:55 AEDT 2002


Hi,


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


Estimated hours taken: 12
Branches: main

Fix a bug where value classes introduced by pragma foreign type's were
not being boxed.  Note that we don't detect all possible value classes
just the ones which are represented specially by the .NET backend.

ilasm.m:
    Move name_to_simple_type to the interface.

mlds_to_il.m:
    Check whether a class is a value class before deciding whether or
    not it has been already boxed.


Index: ilasm.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ilasm.m,v
retrieving revision 1.27
diff -u -r1.27 ilasm.m
--- ilasm.m	13 Dec 2001 16:41:18 -0000	1.27
+++ ilasm.m	14 Jan 2002 04:16:56 -0000
@@ -269,6 +269,14 @@
 	--->	type(ilds__type)
 	;	methodref(ilds__methodref).
 
+:- type ref_or_value
+	--->	reference(simple_type)
+	;	value(simple_type).
+
+	% If possible converts a class name to a simple type and an
+	% indicator of whether or not that simple type is a reference or
+	% value class.
+:- pred name_to_simple_type(class_name::in, ref_or_value::out) is semidet.
 
 :- implementation.
 
@@ -738,12 +750,6 @@
 output_simple_type('&'(Type), Info0, Info) --> 
 	output_type(Type, Info0, Info),
 	io__write_string("&").
-
-:- type ref_or_value
-	--->	reference(simple_type)
-	;	value(simple_type).
-
-:- pred name_to_simple_type(structured_name::in, ref_or_value::out) is semidet.
 
 name_to_simple_type(Name, Type) :-
 		% Parition II section 'Built-in Types' (7.2 in Beta2) states
Index: mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.92
diff -u -r1.92 mlds_to_il.m
--- mlds_to_il.m	21 Nov 2001 03:49:29 -0000	1.92
+++ mlds_to_il.m	14 Jan 2002 04:16:56 -0000
@@ -2460,7 +2460,12 @@
 	}.
 
 :- pred already_boxed(ilds__type::in) is semidet.
-already_boxed(ilds__type(_, class(_))).
+already_boxed(ilds__type(_, class(Name))) :-
+		% XXX Value classes are not already boxed, this call
+		% catches some of the value classes (which can be
+		% introduced by a :- pragma foreign_type), but not all
+		% possible values classes.
+	\+ name_to_simple_type(Name, value(_)).
 already_boxed(ilds__type(_, '[]'(_, _))).
 
 :- pred binaryop_to_il(binary_op, instr_tree, il_info,
@@ -3665,8 +3670,12 @@
 	error("no value class for System.String").
 simple_type_to_value_class(refany) = _ :-
 	error("no value class for refany").
-simple_type_to_value_class(class(_)) = _ :-
-	error("no value class for class").
+simple_type_to_value_class(class(Name)) = Result :-
+	( name_to_simple_type(Name, value(Simple)) ->
+		Result = simple_type_to_value_class(Simple)
+	;
+		error("no value class for class")
+	).
 simple_type_to_value_class(value_class(_)) = _ :-
 	error("no value class for value_class").
 simple_type_to_value_class(interface(_)) = _ :-

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