[m-rev.] diff: handle field look ups of types represented as IL arrays.

Peter Ross pro at missioncriticalit.com
Fri Dec 13 22:46:10 AEDT 2002


Hi,


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


Estimated hours taken: 8
Branches: main

Fix a bug in get_load_store_lval_instrs/5 where it didn't handle
accessing fields of types which where represented as IL arrays.

tests/hard_coded/tuple_test.m triggers this bug for the code the
compiler generates for the complicated unify.

compiler/mlds_to_il.m:
	Handle the case where we lookup a field of a type whose
	representation is an IL array.
	

Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.122
diff -u -r1.122 mlds_to_il.m
--- compiler/mlds_to_il.m	5 Nov 2002 17:26:17 -0000	1.122
+++ compiler/mlds_to_il.m	13 Dec 2002 10:48:37 -0000
@@ -2181,13 +2181,30 @@
 		{ StoreLvalInstrs = instr_node(stind(SimpleType)) } 
 	; { Lval = field(_MaybeTag, FieldRval, FieldNum, FieldType, 
 			ClassType) } -> 
-		{ get_fieldref(DataRep, FieldNum, FieldType, ClassType,
-			FieldRef, CastClassInstrs) },
-		load(FieldRval, LoadMemRefInstrs0),
-		{ LoadMemRefInstrs = tree__list([
-			LoadMemRefInstrs0,
-			CastClassInstrs]) },
-		{ StoreLvalInstrs = instr_node(stfld(FieldRef)) } 
+		{ ClassILType = mlds_type_to_ilds_type(DataRep, ClassType) },
+		( { ClassILType = ilds__type(_, '[]'(_, _)) } ->
+			( { FieldNum = offset(OffsetRval) },
+				{ FieldILType = mlds_type_to_ilds_simple_type(
+							DataRep, FieldType) },
+				load(FieldRval, LoadArrayRval),
+				load(OffsetRval, LoadIndexRval),
+				{ LoadMemRefInstrs = tree__list([
+						LoadArrayRval,
+						LoadIndexRval]) },
+				{ StoreLvalInstrs = node([stelem(FieldILType)]) }
+			; { FieldNum = named_field(_, _) },
+				{ unexpected(this_file, "named_field for a type with an array representation.") }
+			)
+		;
+			{ get_fieldref(DataRep, FieldNum, FieldType, ClassType,
+				FieldRef, CastClassInstrs) },
+			load(FieldRval, LoadMemRefInstrs0),
+			{ LoadMemRefInstrs = tree__list([
+				LoadMemRefInstrs0,
+				CastClassInstrs]) },
+			{ StoreLvalInstrs = instr_node(stfld(FieldRef)) } 
+		)
+
 	;
 		{ LoadMemRefInstrs = empty },
 		store(Lval, StoreLvalInstrs)

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