[m-rev.] for review: check module qualification when testing for type_info

David Overton dmo at cs.mu.OZ.AU
Thu Aug 23 01:06:26 AEST 2001


Hi,

This is for Tyson to review.  The new definitions of type_info, etc in
library/rtti_implementation.m were not compilable in reserved_tag
grades.  This change fixes that, but I'm not sure if it is the right
way to do it since I don't know enough about the current designs and
future plans for RTTI.


Estimated hours taken: 0.5
Branches: main

compiler/type_util.m:
	When testing for type_info types, check that the type is either
	unqualified or qualified as 'private_builtin'.

Index: type_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/type_util.m,v
retrieving revision 1.97
diff -u -r1.97 type_util.m
--- type_util.m	27 Jun 2001 05:04:30 -0000	1.97
+++ type_util.m	22 Aug 2001 06:05:21 -0000
@@ -994,12 +994,12 @@
 
 type_constructors_are_no_tag_type(Ctors, Ctor, ArgType, MaybeArgName) :-
 	type_is_single_ctor_single_arg(Ctors, Ctor, MaybeSymName, ArgType),
-	unqualify_name(Ctor, Name),
-	\+ name_is_type_info(Name),
+	\+ ctor_is_type_info(Ctor),
 
 	% We don't handle unary tuples as no_tag types --
 	% they are rare enough that it's not worth
 	% the implementation effort.
+	unqualify_name(Ctor, Name),
 	Name \= "{}",
 
 	(
@@ -1013,7 +1013,13 @@
 
 type_constructors_are_type_info(Ctors) :-
 	type_is_single_ctor_single_arg(Ctors, Ctor, _, _),
-	unqualify_name(Ctor, Name),
+	ctor_is_type_info(Ctor).
+
+:- pred ctor_is_type_info(sym_name).
+:- mode ctor_is_type_info(in) is semidet.
+
+ctor_is_type_info(Ctor) :-
+	unqualify_private_builtin(Ctor, Name),
 	name_is_type_info(Name).
 
 :- pred name_is_type_info(string).
@@ -1023,6 +1029,18 @@
 name_is_type_info("type_ctor_info").
 name_is_type_info("typeclass_info").
 name_is_type_info("base_typeclass_info").
+
+	% If the sym_name is in the private_builtin module, unqualify it,
+	% otherwise fail.
+	% A sym_name is in private_builtin iff it is unqualified or it is
+	% qualified with the private_builtin module.
+
+:- pred unqualify_private_builtin(sym_name, string).
+:- mode unqualify_private_builtin(in, out) is semidet.
+
+unqualify_private_builtin(unqualified(Name), Name).
+unqualify_private_builtin(qualified(ModuleName, Name), Name) :-
+	mercury_private_builtin_module(ModuleName).
 
 :- pred type_is_single_ctor_single_arg(list(constructor), sym_name, 
 	maybe(sym_name), type).
-- 
David Overton      Department of Computer Science & Software Engineering
PhD Student        The University of Melbourne, Victoria 3010, Australia
+61 3 8344 9159    http://www.cs.mu.oz.au/~dmo
--------------------------------------------------------------------------
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