[m-rev.] for review: fix expand equivalence type for special preds bug

Peter Ross pro at missioncriticalit.com
Thu Nov 7 23:14:45 AEDT 2002


On Thu, Nov 07, 2002 at 12:45:12PM +0100, Peter Ross wrote:
> Hi,
> 
> ===================================================================
> 
> 
> Estimated hours taken: 6
> Branches: main
> 
> Fix a bug highlighted by the .NET backend where the comparison,
> unification and index predicates for types defined as equivalence
> types were being generated refering to the original types instead of
> the expanded out equivalent type.
> 
> compiler/ml_code_util.m:
> 	Expand out the equivalence types in any special preds before
> 	generating the func_params type.
> 
> compiler/rtti.m:
> 	Record the the actual argument types for a special predicate
> 	in the rtti_proc_label type.
> 
> compiler/special_pred.m:
> 	Add a new predicate, is_special_pred, which tests if a
> 	pred_info represents a special pred and return the list of
> 	arguments with all the equivalence types expanded out.
> 
> compiler/type_util.m:
> 	Add a utility predicate to expand out equivalence types.
> 
> compiler/typecheck.m:
> 	Ensure that the type_table map lookup can't fail by only
> 	searching for user_types in the type table.
> 
> compiler/code_util.m:
> compiler/layout_out.m:
> 	Handle the rtti_proc_label structure correctly.
> 
Hmmm didn't do enough of even the basic tests.

This is bootchecking now.

diff -u compiler/ml_code_util.m compiler/ml_code_util.m
--- compiler/ml_code_util.m	7 Nov 2002 11:34:17 -0000
+++ compiler/ml_code_util.m	7 Nov 2002 12:10:11 -0000
@@ -1142,10 +1142,15 @@
 	%
 ml_gen_proc_params_from_rtti(ModuleInfo, RttiProcId) = FuncParams :-
 	HeadVars = RttiProcId ^ proc_headvars,
+	PredInfoArgTypes = RttiProcId ^ arg_types,
 	( RttiProcId ^ is_special_pred_instance = yes(ArgTypes0) ->
-		ArgTypes = ArgTypes0
+		NumArgs = list__length(PredInfoArgTypes),
+		NumSpecialArgs = list__length(ArgTypes0),
+		PreArgs = list__take_upto(
+				NumArgs - NumSpecialArgs, PredInfoArgTypes),
+		ArgTypes = PreArgs ++ ArgTypes0
 	;
-		ArgTypes = RttiProcId ^ arg_types
+		ArgTypes = PredInfoArgTypes
 	),
 	ArgModes = RttiProcId ^ proc_arg_modes,
 	PredOrFunc = RttiProcId ^ pred_or_func,
@@ -1185,10 +1190,15 @@
 :- func get_actual_arg_types(module_info, pred_info) = list(prog_data__type).
 
 get_actual_arg_types(ModuleInfo, PredInfo) = ArgTypes :-
+	pred_info_arg_types(PredInfo, PredInfoArgTypes),
 	( is_special_pred(ModuleInfo, PredInfo, ArgTypes0) ->
-		ArgTypes = ArgTypes0
+		NumArgs = list__length(PredInfoArgTypes),
+		NumSpecialArgs = list__length(ArgTypes0),
+		PreArgs = list__take_upto(
+				NumArgs - NumSpecialArgs, PredInfoArgTypes),
+		ArgTypes = PreArgs ++ ArgTypes0
 	;
-		pred_info_arg_types(PredInfo, ArgTypes)
+		ArgTypes = PredInfoArgTypes
 	).
 
 :- pred ml_gen_params_base(module_info, list(mlds__var_name), list(prog_type),
--------------------------------------------------------------------------
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