[m-rev.] for review: fix rtti get_arg bugs for il grade

Peter Ross pro at missioncriticalit.com
Thu Nov 28 09:46:45 AEDT 2002


Here is a new patch to fix some bugs in my previous patch where we were
looking up the exist_info structure when it didn't exist.

With this patch we now pass all the tests in hard_coded/typeclasses
except for those with missing foreign code implementations.


diff -u library/rtti_implementation.m library/rtti_implementation.m
--- library/rtti_implementation.m
+++ library/rtti_implementation.m
@@ -793,9 +793,12 @@
 		U, int, sectag_locn, du_functor_descriptor, type_info) = T.
 
 get_arg(Term, Index, SecTagLocn, FunctorDesc, TypeInfo) = (Arg) :-
-	ExistInfo = FunctorDesc ^ functor_exist_info,
-	ExtraArgs = (ExistInfo ^ exist_info_typeinfos_plain) + 
-			(ExistInfo ^ exist_info_tcis),
+	( ExistInfo = FunctorDesc ^ functor_exist_info ->
+		ExtraArgs = (ExistInfo ^ exist_info_typeinfos_plain) + 
+				(ExistInfo ^ exist_info_tcis)
+	;
+		ExtraArgs = 0
+	),
 
 	ArgTypes = FunctorDesc ^ functor_arg_types,
 	PseudoTypeInfo = get_pti_from_arg_types(ArgTypes, Index),
@@ -949,7 +952,12 @@
 	->
 		ArgTypeInfo = TypeInfo ^ type_info_index(VarNum)
 	;
-		ExistInfo = FunctorDesc ^ functor_exist_info,
+		( ExistInfo0 = FunctorDesc ^ functor_exist_info ->
+			ExistInfo = ExistInfo0
+		;
+			error("get_type_info_for_var no exist_info")
+		),
+
 		ExistVarNum = VarNum - pseudotypeinfo_exist_var_base - 1,
 		ExistLocn = ExistInfo ^ typeinfo_locns_index(ExistVarNum),
 		Slot = ExistLocn ^ exist_arg_num,
@@ -1249,7 +1257,8 @@
 		
 ").
 
-:- func functor_exist_info(du_functor_descriptor) = exist_info.
+:- func functor_exist_info(du_functor_descriptor::in) =
+		(exist_info::out) is semidet.
 
 functor_exist_info(X::in) = (unsafe_cast(X)::out) :- 
 	det_unimplemented("functor_exist_info").
@@ -1260,6 +1269,12 @@
 	ExistInfo = (object[])
 		FunctorDescriptor[(int)
 			du_functor_field_nums.du_functor_exist_info];
+
+	if (ExistInfo != null) {
+		SUCCESS_INDICATOR = true;
+	} else {
+		SUCCESS_INDICATOR = false;
+	}
 		
 ").
 
--------------------------------------------------------------------------
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