[m-rev.] help needed: fix rtti bug

Peter Ross pro at missioncriticalit.com
Fri Dec 19 22:05:10 AEDT 2003


Hi,

Any hints on how to work out the arity of a variable arity type_ctor
on the IL backend.  I've looked at the C-code, but despite it's
simplicity I don't grok it!  Help needed for the correct fix.

I don't intend to check this in and sorry if the help message is
incomprehensible, but I have only 5 minutes before I get back on my
aeroplane.

Greetings from singapore.

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


Estimated hours taken: 8
Branches: main

Work around a bug in the IL implementation of type_ctor_name_and_arity
where we don't get the correct arity for a variable arity type.

library/rtti_implementation.m:
	Add the code which needs to be fixed.

library/type_desc.m:
	Work around the fact type_ctor_name_and_arity doesn't return
	the correct arity, by calculating the arity by using
	type_ctor_and_args.

Index: library/rtti_implementation.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/rtti_implementation.m,v
retrieving revision 1.50
diff -u -r1.50 rtti_implementation.m
--- library/rtti_implementation.m	4 Dec 2003 09:11:34 -0000	1.50
+++ library/rtti_implementation.m	19 Dec 2003 10:58:51 -0000
@@ -919,7 +919,15 @@
 type_ctor_name_and_arity(TypeCtorInfo, ModuleName, Name, Arity) :-
 	ModuleName = type_ctor_module_name(TypeCtorInfo),
 	Name = type_ctor_name(TypeCtorInfo),
-	Arity = type_ctor_arity(TypeCtorInfo).
+	( type_ctor_is_variable_arity(TypeCtorInfo) ->
+		Arity = type_ctor_va_arity(TypeCtorInfo)
+	;
+		Arity = type_ctor_arity(TypeCtorInfo)
+	).
+
+	% XXX This needs to be fixed.
+:- func type_ctor_va_arity(type_ctor_info) = int.
+type_ctor_va_arity(_) = 0.
 
 type_ctor_and_args(TypeInfo0, TypeCtorInfo, TypeArgs) :-
 	TypeInfo = collapse_equivalences(TypeInfo0),
Index: library/type_desc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/type_desc.m,v
retrieving revision 1.23
diff -u -r1.23 type_desc.m
--- library/type_desc.m	1 Dec 2003 13:17:11 -0000	1.23
+++ library/type_desc.m	19 Dec 2003 10:59:08 -0000
@@ -284,7 +284,12 @@
 
 type_name(Type) = TypeName :-
 	type_ctor_and_args(Type, TypeCtor, ArgTypes),
-	type_ctor_name_and_arity(TypeCtor, ModuleName, Name, Arity),
+	type_ctor_name_and_arity(TypeCtor, ModuleName, Name, _Arity),
+
+	% XXX type_ctor_name_and_arity doesn't return the correct
+	% arity for variable arity types
+	Arity = list__length(ArgTypes),
+
 	( Arity = 0 ->
 		UnqualifiedTypeName = Name
 	;


-- 
Peter Ross		
Software Engineer                                (Work)   +32 2 757 10 15
Mission Critical                                 (Mobile) +32 485 482 559
--------------------------------------------------------------------------
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