[m-rev.] diff: treat foreign types as equivalent to c_pointer

Peter Ross peter.ross at miscrit.be
Thu May 16 19:21:50 AEST 2002


On Wed, May 15, 2002 at 06:42:26PM +1000, Zoltan Somogyi wrote:
> On 15-May-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > You should not hard-code the name "builtin".
> > Instead, you should use `mercury_public_builtin_module'.
> > Also, it would be simpler if you use `construct_type':
> > 
> > 	mercury_public_builtin_module(Builtin),
> > 	construct_type(qualified(Builtin, "c_pointer") - 0, [], Type)
> 
> Actually, even that is too verbose.
> 
> 	Type = c_pointer_type
> 
> is sufficient. There is such a function for pretty much all the builtin types
> the compiler handles specially in type_util.m.
> 


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


Estimated hours taken: 0.25
Branches: main

compiler/type_ctor_info.m:
compiler/unify_proc.m:
    Use the function c_pointer_type from type_util to get the
    representation of the builtin type c_pointer.


Index: type_ctor_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/type_ctor_info.m,v
retrieving revision 1.27
diff -u -r1.27 type_ctor_info.m
--- type_ctor_info.m	13 May 2002 09:44:20 -0000	1.27
+++ type_ctor_info.m	16 May 2002 09:20:23 -0000
@@ -257,12 +257,7 @@
 			% We treat foreign_types as equivalent to the
 			% type builtin__c_pointer.
 		TypeBody = foreign_type(_, _),
-		Ctxt = term__context("builtin.m", 1),
-		Type = functor(term__atom(":"), [
-				functor(term__atom("builtin"), [], Ctxt),
-				functor(term__atom("c_pointer"), [], Ctxt)],
-				Ctxt),
-		gen_layout_info_eqv_type(Type, TypeArity,
+		gen_layout_info_eqv_type(c_pointer_type, TypeArity,
 				TypeCtorRep, NumFunctors, FunctorsInfo,
 				LayoutInfo, NumPtags, TypeTables)
 	;
Index: unify_proc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unify_proc.m,v
retrieving revision 1.109
diff -u -r1.109 unify_proc.m
--- unify_proc.m	13 May 2002 09:44:20 -0000	1.109
+++ unify_proc.m	16 May 2002 09:20:23 -0000
@@ -744,12 +744,8 @@
 		% We treat foreign_type as if they were an equivalent to
 		% the builtin type c_pointer.
 		{ TypeBody = foreign_type(_, _) },
-		{ Ctxt = term__context("builtin.m", 1) },
-		{ Type = functor(term__atom(":"), [
-				functor(term__atom("builtin"), [], Ctxt),
-				functor(term__atom("c_pointer"), [], Ctxt)],
-				Ctxt) },
-		generate_unify_clauses_eqv_type(Type, H1, H2, Context, Clauses)
+		generate_unify_clauses_eqv_type(c_pointer_type,
+				H1, H2, Context, Clauses)
 	;
 		{ TypeBody = abstract_type },
 		{ error("trying to create unify proc for abstract type") }
@@ -886,12 +882,7 @@
 				Res, H1, H2, Context, Clauses)
 	;
 		{ TypeBody = foreign_type(_, _) },
-		{ Ctxt = term__context("builtin.m", 1) },
-		{ CPointerType = functor(term__atom(":"), [
-				functor(term__atom("builtin"), [], Ctxt),
-				functor(term__atom("c_pointer"), [], Ctxt)],
-				Ctxt) },
-		generate_compare_clauses_eqv_type(CPointerType,
+		generate_compare_clauses_eqv_type(c_pointer_type,
 				Res, H1, H2, Context, Clauses)
 	;
 		{ TypeBody = abstract_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