[m-dev.] Type names in type info change

Oliver Hutchison ohutch at students.cs.mu.oz.au
Tue Feb 18 13:06:55 AEDT 1997


On Tue, 18 Feb 1997, Tyson Richard DOWD wrote:

> 
> >  			TypeArity, LayoutArg),
> > -		list__append(PredAddrArgs, [LayoutArg], FinalArgs)
> > +		string__format("%s/%i", [s(TypeName), i(TypeArity)], 
> > +			FullTypeName),
> > +		NameArg = yes(const(string_const(FullTypeName))),
> > +		list__append(PredAddrArgs, [LayoutArg, NameArg], FinalArgs)
> >  	;
> 
> Since the arity is already stored in the first word of the
> base_type_info, is it necessary to encode it in the string as well?
> If you need the name seperately, you need to split the string... 
> 
> If it's not going to cause too much trouble with code that uses this
> string, can we remove the "/Arity" ?
> 

There is no problem with that.

Oliver

Estimated hours taken: 0.3

Added code to store type names in the base type info.
By storing type names in the base type info we can now give more
helpful debugging messages. i.e. we can actually say what type the
error etc... happened in.

compiler/base_type_info.m :
        Added code to place the type name at the end of base type
        info's.

compiler/polymorphism.m :
        Documented change to base type info structure.

library/mercury_builtin.m :
        Changed hand coded type_infos to conform to new structure.

runtime/type_info.h :
        Added hash define for type name offset in type info.

        
Index: compiler/base_type_info.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/base_type_info.m,v
retrieving revision 1.6
diff -u -r1.6 base_type_info.m
--- base_type_info.m	1997/02/14 05:53:54	1.6
+++ base_type_info.m	1997/02/18 00:53:44
@@ -145,7 +145,10 @@
 	->
 		base_type_info__construct_layout(ModuleInfo, TypeName,
 			TypeArity, LayoutArg),
-		list__append(PredAddrArgs, [LayoutArg], FinalArgs)
+		NameArg = yes(const(string_const(TypeName))),
+		list__append(PredAddrArgs, [LayoutArg, NameArg], FinalArgs)
 	;
 		FinalArgs = PredAddrArgs
 	),
Index: compiler/polymorphism.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/polymorphism.m,v
retrieving revision 1.95
diff -u -r1.95 polymorphism.m
--- polymorphism.m	1997/02/17 01:26:55	1.95
+++ polymorphism.m	1997/02/18 00:54:04
@@ -41,6 +41,9 @@
 %	word 2		<index/2 predicate for type>
 %	word 3		<compare/3 predicate for type>
 %	word 4		<base_type_layout for type>
+%	word 5		<string name of type>
+%			e.g. "int" for 'int', "list" for 'list(T),
+%			"map" for 'map(K,V)'
 %
 %	or if using type_to_term predicates:
 %
Index: library/mercury_builtin.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/mercury_builtin.m,v
retrieving revision 1.65
diff -u -r1.65 mercury_builtin.m
--- mercury_builtin.m	1997/02/14 05:54:25	1.65
+++ mercury_builtin.m	1997/02/18 01:00:31
@@ -530,6 +530,7 @@
 #endif
 #ifdef USE_TYPE_LAYOUT
 	const Word *f7;
+	const Word *f8;
 #endif
 } mercury_data___base_type_info_int_0 = {
 	((Integer) 0),
@@ -541,7 +542,8 @@
 	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_type_to_term_int_2_0)),
 #endif
 #ifdef  USE_TYPE_LAYOUT
-	(const Word *) & mercury_data___base_type_layout_int_0
+	(const Word *) & mercury_data___base_type_layout_int_0,
+	(const Word *) string_const(""int"", 5)
 #endif
 };
 
@@ -563,6 +565,7 @@
 #endif
 #ifdef USE_TYPE_LAYOUT
 	const Word *f7;
+	const Word *f8;
 #endif
 } mercury_data___base_type_info_character_0 = {
 	((Integer) 0),
@@ -576,7 +579,8 @@
 		ENTRY(mercury__builtin_type_to_term_character_2_0)),
 #endif
 #ifdef  USE_TYPE_LAYOUT
-	(const Word *) & mercury_data___base_type_layout_character_0
+	(const Word *) & mercury_data___base_type_layout_character_0,
+	(const Word *) string_const(""char"", 6)
 #endif
 };
 
@@ -597,6 +601,7 @@
 #endif
 #ifdef USE_TYPE_LAYOUT
 	const Word *f7;
+	const Word *f8;
 #endif
 } mercury_data___base_type_info_string_0 = {
 	((Integer) 0),
@@ -608,7 +613,8 @@
 	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_type_to_term_string_2_0))
 #endif
 #ifdef  USE_TYPE_LAYOUT
-	(const Word *) & mercury_data___base_type_layout_string_0
+	(const Word *) & mercury_data___base_type_layout_string_0,
+	(const Word *) string_const(""string"", 8)
 #endif
 };
 
@@ -629,6 +635,7 @@
 #endif
 #ifdef USE_TYPE_LAYOUT
 	const Word *f7;
+	const Word *f8;
 #endif
 } mercury_data___base_type_info_float_0 = {
 	((Integer) 0),
@@ -640,7 +647,8 @@
 	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_type_to_term_float_2_0))
 #endif
 #ifdef  USE_TYPE_LAYOUT
-	(const Word *) & mercury_data___base_type_layout_float_0
+	(const Word *) & mercury_data___base_type_layout_float_0,
+	(const Word *) string_const(""float"", 7)
 #endif
 };
 
@@ -661,6 +669,7 @@
 #endif
 #ifdef USE_TYPE_LAYOUT
 	const Word *f7;
+	const Word *f8;
 #endif
 } mercury_data___base_type_info_pred_0 = {
 	((Integer) 0),
@@ -672,7 +681,8 @@
 	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_type_to_term_pred_2_0))
 #endif
 #ifdef  USE_TYPE_LAYOUT
-	(const Word *) & mercury_data___base_type_layout_pred_0
+	(const Word *) & mercury_data___base_type_layout_pred_0,
+	(const Word *) string_const(""pred"", 6)
 #endif
 };
 
Index: runtime/type_info.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/type_info.h,v
retrieving revision 1.18
diff -u -r1.18 type_info.h
--- type_info.h	1997/02/18 00:28:16	1.18
+++ type_info.h	1997/02/18 00:59:03
@@ -73,9 +73,11 @@
 #ifdef USE_TYPE_TO_TERM
 	#define OFFSET_FOR_ARG_TYPE_INFOS 6 
 	#define OFFSET_FOR_BASE_TYPE_LAYOUT 6 
+	#define OFFSET_FOR_TYPE_NAME 7
 #else
 	#define OFFSET_FOR_ARG_TYPE_INFOS 4
 	#define OFFSET_FOR_BASE_TYPE_LAYOUT 4
+	#define OFFSET_FOR_TYPE_NAME 5
 #endif
 
 /*





More information about the developers mailing list