[m-dev.] for review: none.gc grade compiling with MSVC

Peter Ross petdr at cs.mu.OZ.AU
Wed Jun 28 02:56:12 AEST 2000


Hi,

This is very rough, as I have to go and catch my bus.
In particular MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_NOCM needs a better name,
suggest away.

PS. This is best reviewed by Tyson, Zoltan or Fergus.

Pete


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


Estimated hours taken: 16

Changes required for the compiler to bootstrap in the none.gc grade
using MSVC.

compiler/rtti.m:
    The RTTI has forward declarations of static variables with unknown
    array sizes.  Add a field to all RTTI fields which are represented
    as C arrays, except base_typeclass_info, which is the size of the
    array needed to hold the RTTI data.

compiler/rtti_out.m:
    For RTTI structures of size 0 don't output anything as the forward
    declaration, has already allocated space.
    No longer output forward declarations for base_typeclass_info, as it
    is not easy to determine the array size.  AFAIK no other type needs
    the forward declaration of base_typeclass_info so this should be
    safe.
    Change rtti_name_c_type so that it prints out the size of the array,
    instead of "[]".  If the array is of size 0, it makes it of size 1.

compiler/opt_debug.m:
compiler/rtti_to_mlds.m:
compiler/type_ctor_info.m:
    Changes to handle the new array size information.

library/builtin.m:
    Use MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_NOCM instead of
    MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL when we have a blank cm field
    as the MSVC CPP doesn't like blank fields.

runtime/mercury_type_info.h:
    Create new macro MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_NOCM, which is the
    same as MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL but with no cm field.

trace/mercury_trace_vars.c:
    Delete the definitions of mercury_data___type_ctor_info_func_0 and
    mercury_data___type_ctor_info_pred_0 because the true definitions
    are visible.


Index: compiler/opt_debug.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/opt_debug.m,v
retrieving revision 1.104
diff -u -b -r1.104 opt_debug.m
--- compiler/opt_debug.m	2000/05/10 18:06:57	1.104
+++ compiler/opt_debug.m	2000/06/27 16:40:42
@@ -752,16 +752,16 @@
 	string__append_list(["rtti_type_id(", ModuleName_str, ", ",
 		TypeName_str, Arity_str, ")"], Str).
 
-opt_debug__dump_rtti_name(exist_locns(Ordinal), Str) :-
+opt_debug__dump_rtti_name(exist_locns(Ordinal, _), Str) :-
 	string__int_to_string(Ordinal, Ordinal_str),
 	string__append("exist_locns_", Ordinal_str, Str).
 opt_debug__dump_rtti_name(exist_info(Ordinal), Str) :-
 	string__int_to_string(Ordinal, Ordinal_str),
 	string__append("exist_info_", Ordinal_str, Str).
-opt_debug__dump_rtti_name(field_names(Ordinal), Str) :-
+opt_debug__dump_rtti_name(field_names(Ordinal, _), Str) :-
 	string__int_to_string(Ordinal, Ordinal_str),
 	string__append("field_names_", Ordinal_str, Str).
-opt_debug__dump_rtti_name(field_types(Ordinal), Str) :-
+opt_debug__dump_rtti_name(field_types(Ordinal, _), Str) :-
 	string__int_to_string(Ordinal, Ordinal_str),
 	string__append("field_types_", Ordinal_str, Str).
 opt_debug__dump_rtti_name(enum_functor_desc(Ordinal), Str) :-
@@ -772,16 +772,16 @@
 opt_debug__dump_rtti_name(du_functor_desc(Ordinal), Str) :-
 	string__int_to_string(Ordinal, Ordinal_str),
 	string__append("du_functor_desc_", Ordinal_str, Str).
-opt_debug__dump_rtti_name(enum_name_ordered_table, Str) :-
+opt_debug__dump_rtti_name(enum_name_ordered_table(_), Str) :-
 	Str = "enum_name_ordered_table".
-opt_debug__dump_rtti_name(enum_value_ordered_table, Str) :-
+opt_debug__dump_rtti_name(enum_value_ordered_table(_), Str) :-
 	Str = "enum_value_ordered_table".
-opt_debug__dump_rtti_name(du_name_ordered_table, Str) :-
+opt_debug__dump_rtti_name(du_name_ordered_table(_), Str) :-
 	Str = "du_name_ordered_table".
-opt_debug__dump_rtti_name(du_stag_ordered_table(Ptag), Str) :-
+opt_debug__dump_rtti_name(du_stag_ordered_table(Ptag, _), Str) :-
 	string__int_to_string(Ptag, Ptag_str),
 	string__append("du_stag_ordered_table_", Ptag_str, Str).
-opt_debug__dump_rtti_name(du_ptag_ordered_table, Str) :-
+opt_debug__dump_rtti_name(du_ptag_ordered_table(_), Str) :-
 	Str = "du_ptag_ordered_table".
 opt_debug__dump_rtti_name(type_ctor_info, Str) :-
 	Str = "type_ctor_info".
Index: compiler/rtti.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti.m,v
retrieving revision 1.8
diff -u -b -r1.8 rtti.m
--- compiler/rtti.m	2000/05/10 18:07:04	1.8
+++ compiler/rtti.m	2000/06/27 16:40:50
@@ -309,18 +309,18 @@
 	.
 
 :- type rtti_name
-	--->	exist_locns(int)		% functor ordinal
+	--->	exist_locns(int, int)		% functor ordinal, array size
 	;	exist_info(int)			% functor ordinal
-	;	field_names(int)		% functor ordinal
-	;	field_types(int)		% functor ordinal
+	;	field_names(int, int)		% functor ordinal, array size
+	;	field_types(int, int)		% functor ordinal, array size
 	;	enum_functor_desc(int)		% functor ordinal
 	;	notag_functor_desc
 	;	du_functor_desc(int)		% functor ordinal
-	;	enum_name_ordered_table
-	;	enum_value_ordered_table
-	;	du_name_ordered_table
-	;	du_stag_ordered_table(int)	% primary tag
-	;	du_ptag_ordered_table
+	;	enum_name_ordered_table(int)	% size of the array
+	;	enum_value_ordered_table(int)	% size of the array
+	;	du_name_ordered_table(int)	% size of the array
+	;	du_stag_ordered_table(int, int)	% primary tag, array size
+	;	du_ptag_ordered_table(int)	% size of the array
 	;	type_ctor_info
 	;	pseudo_type_info(pseudo_type_info)
 	;	base_typeclass_info(
@@ -435,30 +435,30 @@
 
 :- import_module string, require.
 
-rtti_data_to_name(exist_locns(RttiTypeId, Ordinal, _),
-	RttiTypeId, exist_locns(Ordinal)).
+rtti_data_to_name(exist_locns(RttiTypeId, Ordinal, Locns),
+	RttiTypeId, exist_locns(Ordinal, list__length(Locns))).
 rtti_data_to_name(exist_info(RttiTypeId, Ordinal, _, _, _, _),
 	RttiTypeId, exist_info(Ordinal)).
-rtti_data_to_name(field_names(RttiTypeId, Ordinal, _),
-	RttiTypeId, field_names(Ordinal)).
-rtti_data_to_name(field_types(RttiTypeId, Ordinal, _),
-	RttiTypeId, field_types(Ordinal)).
+rtti_data_to_name(field_names(RttiTypeId, Ordinal, Names),
+	RttiTypeId, field_names(Ordinal, list__length(Names))).
+rtti_data_to_name(field_types(RttiTypeId, Ordinal, Types),
+	RttiTypeId, field_types(Ordinal, list__length(Types))).
 rtti_data_to_name(enum_functor_desc(RttiTypeId, _, Ordinal),
 	RttiTypeId, enum_functor_desc(Ordinal)).
 rtti_data_to_name(notag_functor_desc(RttiTypeId, _, _),
 	RttiTypeId, notag_functor_desc).
 rtti_data_to_name(du_functor_desc(RttiTypeId, _,_,_,_, Ordinal, _,_,_,_,_),
 	RttiTypeId, du_functor_desc(Ordinal)).
-rtti_data_to_name(enum_name_ordered_table(RttiTypeId, _),
-	RttiTypeId, enum_name_ordered_table).
-rtti_data_to_name(enum_value_ordered_table(RttiTypeId, _),
-	RttiTypeId, enum_value_ordered_table).
-rtti_data_to_name(du_name_ordered_table(RttiTypeId, _),
-	RttiTypeId, du_name_ordered_table).
-rtti_data_to_name(du_stag_ordered_table(RttiTypeId, Ptag, _),
-	RttiTypeId, du_stag_ordered_table(Ptag)).
-rtti_data_to_name(du_ptag_ordered_table(RttiTypeId, _),
-	RttiTypeId, du_ptag_ordered_table).
+rtti_data_to_name(enum_name_ordered_table(RttiTypeId, RttiNames),
+	RttiTypeId, enum_name_ordered_table(list__length(RttiNames))).
+rtti_data_to_name(enum_value_ordered_table(RttiTypeId, RttiNames),
+	RttiTypeId, enum_value_ordered_table(list__length(RttiNames))).
+rtti_data_to_name(du_name_ordered_table(RttiTypeId, RttiNames),
+	RttiTypeId, du_name_ordered_table(list__length(RttiNames))).
+rtti_data_to_name(du_stag_ordered_table(RttiTypeId, Ptag, RttiNames),
+	RttiTypeId, du_stag_ordered_table(Ptag, list__length(RttiNames))).
+rtti_data_to_name(du_ptag_ordered_table(RttiTypeId, Layouts),
+	RttiTypeId, du_ptag_ordered_table(list__length(Layouts))).
 rtti_data_to_name(type_ctor_info(RttiTypeId, _,_,_,_,_,_,_,_,_,_,_,_),
 	RttiTypeId, type_ctor_info).
 rtti_data_to_name(base_typeclass_info(_, _, _), _, _) :-
@@ -476,35 +476,35 @@
 	% there's no rtti_type_id associated with a type_var
 	error("rtti_data_to_name: type_var").
 
-rtti_name_has_array_type(exist_locns(_))		= yes.
+rtti_name_has_array_type(exist_locns(_, _))		= yes.
 rtti_name_has_array_type(exist_info(_))			= no.
-rtti_name_has_array_type(field_names(_))		= yes.
-rtti_name_has_array_type(field_types(_))		= yes.
+rtti_name_has_array_type(field_names(_, _))		= yes.
+rtti_name_has_array_type(field_types(_, _))		= yes.
 rtti_name_has_array_type(enum_functor_desc(_))		= no.
 rtti_name_has_array_type(notag_functor_desc)		= no.
 rtti_name_has_array_type(du_functor_desc(_))		= no.
-rtti_name_has_array_type(enum_name_ordered_table)	= yes.
-rtti_name_has_array_type(enum_value_ordered_table)	= yes.
-rtti_name_has_array_type(du_name_ordered_table)		= yes.
-rtti_name_has_array_type(du_stag_ordered_table(_))	= yes.
-rtti_name_has_array_type(du_ptag_ordered_table)		= yes.
+rtti_name_has_array_type(enum_name_ordered_table(_))	= yes.
+rtti_name_has_array_type(enum_value_ordered_table(_))	= yes.
+rtti_name_has_array_type(du_name_ordered_table(_))	= yes.
+rtti_name_has_array_type(du_stag_ordered_table(_, _))	= yes.
+rtti_name_has_array_type(du_ptag_ordered_table(_))	= yes.
 rtti_name_has_array_type(type_ctor_info)		= no.
 rtti_name_has_array_type(pseudo_type_info(_))		= no.
 rtti_name_has_array_type(base_typeclass_info(_, _))	= yes.
 rtti_name_has_array_type(type_hashcons_pointer)		= no.
 
-rtti_name_is_exported(exist_locns(_))		= no.
+rtti_name_is_exported(exist_locns(_, _))		= no.
 rtti_name_is_exported(exist_info(_))            = no.
-rtti_name_is_exported(field_names(_))           = no.
-rtti_name_is_exported(field_types(_))           = no.
+rtti_name_is_exported(field_names(_, _))		= no.
+rtti_name_is_exported(field_types(_, _))		= no.
 rtti_name_is_exported(enum_functor_desc(_))     = no.
 rtti_name_is_exported(notag_functor_desc)       = no.
 rtti_name_is_exported(du_functor_desc(_))       = no.
-rtti_name_is_exported(enum_name_ordered_table)  = no.
-rtti_name_is_exported(enum_value_ordered_table) = no.
-rtti_name_is_exported(du_name_ordered_table)    = no.
-rtti_name_is_exported(du_stag_ordered_table(_)) = no.
-rtti_name_is_exported(du_ptag_ordered_table)    = no.
+rtti_name_is_exported(enum_name_ordered_table(_))	= no.
+rtti_name_is_exported(enum_value_ordered_table(_))	= no.
+rtti_name_is_exported(du_name_ordered_table(_))		= no.
+rtti_name_is_exported(du_stag_ordered_table(_, _))	= no.
+rtti_name_is_exported(du_ptag_ordered_table(_))		= no.
 rtti_name_is_exported(type_ctor_info)           = yes.
 rtti_name_is_exported(pseudo_type_info(Pseudo)) =
 	pseudo_type_info_is_exported(Pseudo).
@@ -544,7 +544,7 @@
 rtti__addr_to_string(RttiTypeId, RttiName, Str) :-
 	rtti__mangle_rtti_type_id(RttiTypeId, ModuleName, TypeName, A_str),
 	(
-		RttiName = exist_locns(Ordinal),
+		RttiName = exist_locns(Ordinal, _),
 		string__int_to_string(Ordinal, O_str),
 		string__append_list([ModuleName, "__exist_locns_",
 			TypeName, "_", A_str, "_", O_str], Str)
@@ -554,12 +554,12 @@
 		string__append_list([ModuleName, "__exist_info_",
 			TypeName, "_", A_str, "_", O_str], Str)
 	;
-		RttiName = field_names(Ordinal),
+		RttiName = field_names(Ordinal, _),
 		string__int_to_string(Ordinal, O_str),
 		string__append_list([ModuleName, "__field_names_",
 			TypeName, "_", A_str, "_", O_str], Str)
 	;
-		RttiName = field_types(Ordinal),
+		RttiName = field_types(Ordinal, _),
 		string__int_to_string(Ordinal, O_str),
 		string__append_list([ModuleName, "__field_types_",
 			TypeName, "_", A_str, "_", O_str], Str)
@@ -578,24 +578,24 @@
 		string__append_list([ModuleName, "__du_functor_desc_",
 			TypeName, "_", A_str, "_", O_str], Str)
 	;
-		RttiName = enum_name_ordered_table,
+		RttiName = enum_name_ordered_table(_),
 		string__append_list([ModuleName, "__enum_name_ordered_",
 			TypeName, "_", A_str], Str)
 	;
-		RttiName = enum_value_ordered_table,
+		RttiName = enum_value_ordered_table(_),
 		string__append_list([ModuleName, "__enum_value_ordered_",
 			TypeName, "_", A_str], Str)
 	;
-		RttiName = du_name_ordered_table,
+		RttiName = du_name_ordered_table(_),
 		string__append_list([ModuleName, "__du_name_ordered_",
 			TypeName, "_", A_str], Str)
 	;
-		RttiName = du_stag_ordered_table(Ptag),
+		RttiName = du_stag_ordered_table(Ptag, _),
 		string__int_to_string(Ptag, P_str),
 		string__append_list([ModuleName, "__du_stag_ordered_",
 			TypeName, "_", A_str, "_", P_str], Str)
 	;
-		RttiName = du_ptag_ordered_table,
+		RttiName = du_ptag_ordered_table(_),
 		string__append_list([ModuleName, "__du_ptag_ordered_",
 			TypeName, "_", A_str], Str)
 	;
Index: compiler/rtti_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti_out.m,v
retrieving revision 1.11
diff -u -b -r1.11 rtti_out.m
--- compiler/rtti_out.m	2000/05/10 18:07:05	1.11
+++ compiler/rtti_out.m	2000/06/27 16:40:53
@@ -86,11 +86,19 @@
 
 output_rtti_data_defn(exist_locns(RttiTypeId, Ordinal, Locns),
 		DeclSet0, DeclSet) -->
-	output_generic_rtti_data_defn_start(RttiTypeId, exist_locns(Ordinal),
+	(
+			% For size 0 data structures we output nothing.
+		{ Locns = [] }
+	->
+		{ DeclSet = DeclSet0 }
+	;
+		output_generic_rtti_data_defn_start(RttiTypeId,
+			exist_locns(Ordinal, list__length(Locns)),
 		DeclSet0, DeclSet),
 	io__write_string(" = {\n"),
 	output_exist_locns(Locns),
-	io__write_string("};\n").
+		io__write_string("};\n")
+	).
 output_rtti_data_defn(exist_info(RttiTypeId, Ordinal, Plain, InTci, Tci,
 		Locns), DeclSet0, DeclSet) -->
 	output_rtti_addr_decls(RttiTypeId, Locns, "", "", 0, _,
@@ -108,19 +116,36 @@
 	io__write_string("\n};\n").
 output_rtti_data_defn(field_names(RttiTypeId, Ordinal, MaybeNames),
 		DeclSet0, DeclSet) -->
-	output_generic_rtti_data_defn_start(RttiTypeId, field_names(Ordinal),
+	(
+			% For size 0 data structures we output nothing.
+		{ MaybeNames = [] }
+	->
+		{ DeclSet = DeclSet0 }
+	;
+		output_generic_rtti_data_defn_start(RttiTypeId,
+			field_names(Ordinal, list__length(MaybeNames)),
 		DeclSet0, DeclSet),
 	io__write_string(" = {\n"),
 	output_maybe_quoted_strings(MaybeNames),
-	io__write_string("};\n").
+		io__write_string("};\n")
+	).
 output_rtti_data_defn(field_types(RttiTypeId, Ordinal, Types),
 		DeclSet0, DeclSet) -->
-	output_rtti_datas_decls(Types, "", "", 0, _, DeclSet0, DeclSet1),
-	output_generic_rtti_data_defn_start(RttiTypeId, field_types(Ordinal),
+	(
+			% For size 0 data structures we output nothing.
+		{ Types = [] }
+	->
+		{ DeclSet = DeclSet0 }
+	;
+		output_rtti_datas_decls(Types, "", "", 0, _,
+			DeclSet0, DeclSet1),
+		output_generic_rtti_data_defn_start(RttiTypeId,
+			field_types(Ordinal, list__length(Types)),
 		DeclSet1, DeclSet),
 	io__write_string(" = {\n"),
 	output_addr_of_rtti_datas(Types),
-	io__write_string("};\n").
+		io__write_string("};\n")
+	).
 output_rtti_data_defn(enum_functor_desc(RttiTypeId, FunctorName, Ordinal),
 		DeclSet0, DeclSet) -->
 	output_generic_rtti_data_defn_start(RttiTypeId,
@@ -204,7 +229,8 @@
 	output_rtti_addrs_decls(RttiTypeId, Functors, "", "", 0, _,
 		DeclSet0, DeclSet1),
 	output_generic_rtti_data_defn_start(RttiTypeId,
-		enum_name_ordered_table, DeclSet1, DeclSet),
+		enum_name_ordered_table(list__length(Functors)),
+		DeclSet1, DeclSet),
 	io__write_string(" = {\n"),
 	output_addr_of_rtti_addrs(RttiTypeId, Functors),
 	io__write_string("};\n").
@@ -213,7 +239,8 @@
 	output_rtti_addrs_decls(RttiTypeId, Functors, "", "", 0, _,
 		DeclSet0, DeclSet1),
 	output_generic_rtti_data_defn_start(RttiTypeId,
-		enum_value_ordered_table, DeclSet1, DeclSet),
+		enum_value_ordered_table(list__length(Functors)),
+		DeclSet1, DeclSet),
 	io__write_string(" = {\n"),
 	output_addr_of_rtti_addrs(RttiTypeId, Functors),
 	io__write_string("};\n").
@@ -222,7 +249,8 @@
 	output_rtti_addrs_decls(RttiTypeId, Functors, "", "", 0, _,
 		DeclSet0, DeclSet1),
 	output_generic_rtti_data_defn_start(RttiTypeId,
-		du_name_ordered_table, DeclSet1, DeclSet),
+		du_name_ordered_table(list__length(Functors)),
+		DeclSet1, DeclSet),
 	io__write_string(" = {\n"),
 	output_addr_of_rtti_addrs(RttiTypeId, Functors),
 	io__write_string("};\n").
@@ -231,7 +259,8 @@
 	output_rtti_addrs_decls(RttiTypeId, Sharers, "", "", 0, _,
 		DeclSet0, DeclSet1),
 	output_generic_rtti_data_defn_start(RttiTypeId,
-		du_stag_ordered_table(Ptag), DeclSet1, DeclSet),
+		du_stag_ordered_table(Ptag, list__length(Sharers)),
+		DeclSet1, DeclSet),
 	io__write_string(" = {\n"),
 	output_addr_of_rtti_addrs(RttiTypeId, Sharers),
 	io__write_string("\n};\n").
@@ -239,7 +268,8 @@
 		DeclSet0, DeclSet) -->
 	output_ptag_layout_decls(PtagLayouts, RttiTypeId, DeclSet0, DeclSet1),
 	output_generic_rtti_data_defn_start(RttiTypeId,
-		du_ptag_ordered_table, DeclSet1, DeclSet),
+		du_ptag_ordered_table(list__length(PtagLayouts)),
+		DeclSet1, DeclSet),
 	io__write_string(" = {\n"),
 	output_ptag_layout_defns(PtagLayouts, RttiTypeId),
 	io__write_string("\n};\n").
@@ -495,10 +525,16 @@
 		% so we don't need to declare them.
 		% Also rtti_data_to_name/3 does not handle this case.
 		{ DeclSet = DeclSet0 }
-	; { RttiData = base_typeclass_info(ClassId, InstanceStr, _) } ->
+	; { RttiData = base_typeclass_info(_ClassId, _InstanceStr, _) } ->
+			% We don't output a declartion for the
+			% base_typeclass_info because we don't know how
+			% big to make the array.
+			% AFAIK no other types actually need the forward
+			% declaration, so it is safe not to declare it.
+		{ DeclSet = DeclSet0 }
 		% rtti_data_to_name/3 does not handle this case
-		output_base_typeclass_info_decl(ClassId,
-			InstanceStr, no, DeclSet0, DeclSet)
+		% output_base_typeclass_info_decl(ClassId,
+		%	InstanceStr, no, DeclSet0, DeclSet)
 	;
 		{ rtti_data_to_name(RttiData, RttiTypeId, RttiName) },
 		output_generic_rtti_data_decl(RttiTypeId, RttiName,
@@ -904,18 +940,18 @@
 
 %-----------------------------------------------------------------------------%
 
-rtti_name_would_include_code_addr(exist_locns(_),            no).
+rtti_name_would_include_code_addr(exist_locns(_, _),           no).
 rtti_name_would_include_code_addr(exist_info(_),             no).
-rtti_name_would_include_code_addr(field_names(_),            no).
-rtti_name_would_include_code_addr(field_types(_),            no).
+rtti_name_would_include_code_addr(field_names(_, _),           no).
+rtti_name_would_include_code_addr(field_types(_, _),           no).
 rtti_name_would_include_code_addr(enum_functor_desc(_),      no).
 rtti_name_would_include_code_addr(notag_functor_desc,        no).
 rtti_name_would_include_code_addr(du_functor_desc(_),        no).
-rtti_name_would_include_code_addr(enum_name_ordered_table,   no).
-rtti_name_would_include_code_addr(enum_value_ordered_table,  no).
-rtti_name_would_include_code_addr(du_name_ordered_table,     no).
-rtti_name_would_include_code_addr(du_stag_ordered_table(_),  no).
-rtti_name_would_include_code_addr(du_ptag_ordered_table,     no).
+rtti_name_would_include_code_addr(enum_name_ordered_table(_),  no).
+rtti_name_would_include_code_addr(enum_value_ordered_table(_), no).
+rtti_name_would_include_code_addr(du_name_ordered_table(_),    no).
+rtti_name_would_include_code_addr(du_stag_ordered_table(_, _), no).
+rtti_name_would_include_code_addr(du_ptag_ordered_table(_),    no).
 rtti_name_would_include_code_addr(type_ctor_info,            yes).
 rtti_name_would_include_code_addr(base_typeclass_info(_, _), yes).
 rtti_name_would_include_code_addr(pseudo_type_info(Pseudo),
@@ -934,24 +970,37 @@
 	; Exported = no, Linkage = static
         ).
 
-rtti_name_c_type(exist_locns(_),           "MR_DuExistLocn", "[]").
+rtti_name_c_type(exist_locns(_, Size),     "MR_DuExistLocn", array(Size)).
 rtti_name_c_type(exist_info(_),            "MR_DuExistInfo", "").
-rtti_name_c_type(field_names(_),           "ConstString", "[]").
-rtti_name_c_type(field_types(_),           "MR_PseudoTypeInfo", "[]").
+rtti_name_c_type(field_names(_, Size),     "ConstString", array(Size)).
+rtti_name_c_type(field_types(_, Size),     "MR_PseudoTypeInfo", array(Size)).
 rtti_name_c_type(enum_functor_desc(_),     "MR_EnumFunctorDesc", "").
 rtti_name_c_type(notag_functor_desc,       "MR_NotagFunctorDesc", "").
 rtti_name_c_type(du_functor_desc(_),       "MR_DuFunctorDesc", "").
-rtti_name_c_type(enum_name_ordered_table,  "MR_EnumFunctorDesc *", "[]").
-rtti_name_c_type(enum_value_ordered_table, "MR_EnumFunctorDesc *", "[]").
-rtti_name_c_type(du_name_ordered_table,    "MR_DuFunctorDesc *", "[]").
-rtti_name_c_type(du_stag_ordered_table(_), "MR_DuFunctorDesc *", "[]").
-rtti_name_c_type(du_ptag_ordered_table,    "MR_DuPtagLayout", "[]").
+rtti_name_c_type(enum_name_ordered_table(Size),  "MR_EnumFunctorDesc *",
+		array(Size)).
+rtti_name_c_type(enum_value_ordered_table(Size), "MR_EnumFunctorDesc *",
+		array(Size)).
+rtti_name_c_type(du_name_ordered_table(Size),    "MR_DuFunctorDesc *",
+		array(Size)).
+rtti_name_c_type(du_stag_ordered_table(_, Size), "MR_DuFunctorDesc *",
+		array(Size)).
+rtti_name_c_type(du_ptag_ordered_table(Size),    "MR_DuPtagLayout",
+		array(Size)).
 rtti_name_c_type(type_ctor_info,           "struct MR_TypeCtorInfo_Struct",
 						"").
 rtti_name_c_type(base_typeclass_info(_, _), "Code *", "[]").
 rtti_name_c_type(pseudo_type_info(Pseudo), TypePrefix, TypeSuffix) :-
 	pseudo_type_info_name_c_type(Pseudo, TypePrefix, TypeSuffix).
 rtti_name_c_type(type_hashcons_pointer,    "union MR_TableNode_Union **", "").
+
+	% Construct the string "[n]", where n is the integer passed in.
+	% Note that if n is 0, we change it to 1 as ANSI C forbids 0
+	% sized arrays.
+:- func array(int) = string.
+array(Size) = string__append_list(["[", int_to_string(NewSize), "]"]) :-
+		% ANSI C forbids arrays of array 0
+	( if Size = 0 then NewSize = 1 else NewSize = Size ).
 
 :- pred pseudo_type_info_name_c_type(pseudo_type_info, string, string).
 :- mode pseudo_type_info_name_c_type(in, out, out) is det.
Index: compiler/rtti_to_mlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti_to_mlds.m,v
retrieving revision 1.5
diff -u -b -r1.5 rtti_to_mlds.m
--- compiler/rtti_to_mlds.m	2000/05/31 06:04:16	1.5
+++ compiler/rtti_to_mlds.m	2000/06/27 16:40:55
@@ -578,18 +578,18 @@
 
 %-----------------------------------------------------------------------------%
 
-mlds_rtti_type_name(exist_locns(_)) =		"DuExistLocnArray".
+mlds_rtti_type_name(exist_locns(_, _)) =	"DuExistLocnArray".
 mlds_rtti_type_name(exist_info(_)) =		"DuExistInfo".
-mlds_rtti_type_name(field_names(_)) =		"ConstStringArray".
-mlds_rtti_type_name(field_types(_)) =		"PseudoTypeInfoArray".
+mlds_rtti_type_name(field_names(_, _)) =	"ConstStringArray".
+mlds_rtti_type_name(field_types(_, _)) =	"PseudoTypeInfoArray".
 mlds_rtti_type_name(enum_functor_desc(_)) =	"EnumFunctorDesc".
 mlds_rtti_type_name(notag_functor_desc) =	"NotagFunctorDesc".
 mlds_rtti_type_name(du_functor_desc(_)) =	"DuFunctorDesc".
-mlds_rtti_type_name(enum_name_ordered_table) =	"EnumFunctorDescPtrArray".
-mlds_rtti_type_name(enum_value_ordered_table) =	"EnumFunctorDescPtrArray".
-mlds_rtti_type_name(du_name_ordered_table) =	"DuFunctorDescPtrArray".
-mlds_rtti_type_name(du_stag_ordered_table(_)) =	"DuFunctorDescPtrArray".
-mlds_rtti_type_name(du_ptag_ordered_table) =	"DuPtagLayoutArray".
+mlds_rtti_type_name(enum_name_ordered_table(_)) = "EnumFunctorDescPtrArray".
+mlds_rtti_type_name(enum_value_ordered_table(_)) = "EnumFunctorDescPtrArray".
+mlds_rtti_type_name(du_name_ordered_table(_)) =	"DuFunctorDescPtrArray".
+mlds_rtti_type_name(du_stag_ordered_table(_, _)) = "DuFunctorDescPtrArray".
+mlds_rtti_type_name(du_ptag_ordered_table(_)) =	"DuPtagLayoutArray".
 mlds_rtti_type_name(type_ctor_info) =		"TypeCtorInfo_Struct".
 mlds_rtti_type_name(base_typeclass_info(_, _)) = "BaseTypeclassInfo".
 mlds_rtti_type_name(pseudo_type_info(Pseudo)) =
Index: compiler/type_ctor_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/type_ctor_info.m,v
retrieving revision 1.7
diff -u -b -r1.7 type_ctor_info.m
--- compiler/type_ctor_info.m	2000/04/18 16:41:55	1.7
+++ compiler/type_ctor_info.m	2000/06/27 16:41:00
@@ -408,12 +408,14 @@
 
 	NameOrderedTable = enum_name_ordered_table(RttiTypeId,
 		NameOrderedRttiNames),
-	NameOrderedTableRttiName = enum_name_ordered_table,
+	NameOrderedTableRttiName = enum_name_ordered_table(
+			list__length(NameOrderedRttiNames)),
 	FunctorInfo = enum_functors(NameOrderedTableRttiName),
 
 	ValueOrderedTable = enum_value_ordered_table(RttiTypeId,
 		OrdinalOrderRttiNames),
-	ValueOrderedTableRttiName = enum_value_ordered_table,
+	ValueOrderedTableRttiName = enum_value_ordered_table(
+			list__length(OrdinalOrderRttiNames)),
 	LayoutInfo = enum_layout(ValueOrderedTableRttiName),
 
 	TypeTables = [NameOrderedTable, ValueOrderedTable | FunctorDescs].
@@ -481,7 +483,8 @@
 
 	NameOrderedTable = du_name_ordered_table(RttiTypeId,
 		NameOrderedRttiNames),
-	NameOrderedTableRttiName = du_name_ordered_table,
+	NameOrderedTableRttiName = du_name_ordered_table(
+			list__length(NameOrderedRttiNames)),
 	FunctorInfo = du_functors(NameOrderedTableRttiName),
 
 	type_ctor_info__make_du_ptag_ordered_table(TagMap, MaxPtag,
@@ -577,9 +580,10 @@
 	type_ctor_info__generate_arg_infos(Args, TypeArity, ExistTvars,
 		ModuleInfo, MaybeArgNames, PseudoTypeInfos,
 		0, 0, ContainsVarBitVector, [], Tables0),
-	FieldTypesRttiName = field_types(Ordinal),
 	FieldTypesTable = field_types(RttiTypeId, Ordinal,
 			PseudoTypeInfos),
+	FieldTypesRttiName = field_types(Ordinal,
+			list__length(PseudoTypeInfos)),
 	Tables1 = [FieldTypesTable | Tables0],
 	list__filter((lambda([MaybeName::in] is semidet, MaybeName = yes(_))),
 		MaybeArgNames, FieldNames),
@@ -591,7 +595,8 @@
 		FieldNames = [_|_],
 		FieldNameTable = field_names(RttiTypeId, Ordinal,
 			MaybeArgNames),
-		FieldNamesRttiName = field_names(Ordinal),
+		FieldNamesRttiName = field_names(Ordinal,
+			list__length(FieldNames)),
 		MaybeFieldNamesRttiName = yes(FieldNamesRttiName),
 		Tables = [FieldNameTable | Tables1]
 	).
@@ -680,7 +685,8 @@
 		ConstrainedTvars, LocnMap1, LocnMap),
 	list__length(Constraints, TCIs),
 	ExistInfo = exist_info(RttiTypeId, Ordinal,
-		TIsPlain, TIsInTCIs, TCIs, exist_locns(Ordinal)),
+		TIsPlain, TIsInTCIs, TCIs,
+		exist_locns(Ordinal, list__length(ExistTvars))),
 	list__map((pred(Tvar::in, Locn::out) is det :-
 		map__lookup(LocnMap, Tvar, Locn)),
 		ExistTvars, Locns),
@@ -754,7 +760,7 @@
 	type_ctor_info__make_du_ptag_layouts(TagList, 0, MaxPtagValue,
 		RttiTypeId, PtagLayouts, SubTables, NumPtags),
 	PtagOrderedTable = du_ptag_ordered_table(RttiTypeId, PtagLayouts),
-	PtagOrderedRttiName = du_ptag_ordered_table,
+	PtagOrderedRttiName = du_ptag_ordered_table(list__length(PtagLayouts)),
 	Tables = [PtagOrderedTable | SubTables].
 
 :- pred type_ctor_info__make_du_ptag_layouts(tag_list::in, int::in, int::in,
@@ -780,7 +786,8 @@
 			StagList, StagRttiNames),
 		StagOrderedTable = du_stag_ordered_table(RttiTypeId,
 			Ptag, StagRttiNames),
-		StagOrderedAddr = du_stag_ordered_table(Ptag),
+		StagOrderedAddr = du_stag_ordered_table(Ptag,
+			list__length(StagRttiNames)),
 		PtagLayout = du_ptag_layout(StagListLength, Locn,
 			StagOrderedAddr),
 		type_ctor_info__make_du_ptag_layouts(TagList,
Index: library/builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/builtin.m,v
retrieving revision 1.36
diff -u -b -r1.36 builtin.m
--- library/builtin.m	2000/05/31 12:58:19	1.36
+++ library/builtin.m	2000/06/27 16:41:02
@@ -236,22 +236,22 @@
 
 #ifndef MR_HIGHLEVEL_CODE
 
-MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(builtin, , int, 0,
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_NOCM(builtin, int, 0,
 	MR_TYPECTOR_REP_INT,
 	mercury__builtin_unify_int_2_0,
 	mercury__builtin_compare_int_3_0);
 
-MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(builtin, , character, 0,
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_NOCM(builtin, character, 0,
 	MR_TYPECTOR_REP_CHAR,
 	mercury__builtin_unify_character_2_0,
 	mercury__builtin_compare_character_3_0);
 
-MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(builtin, , string, 0,
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_NOCM(builtin, string, 0,
 	MR_TYPECTOR_REP_STRING,
 	mercury__builtin_unify_string_2_0,
 	mercury__builtin_compare_string_3_0);
 
-MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(builtin, , float, 0,
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_NOCM(builtin, float, 0,
 	MR_TYPECTOR_REP_FLOAT,
 	mercury__builtin_unify_float_2_0,
 	mercury__builtin_compare_float_3_0);
@@ -261,11 +261,11 @@
 	** Note that they use the same three predicates.
 	*/
 
-MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(builtin, , func, 0,
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_NOCM(builtin, func, 0,
 	MR_TYPECTOR_REP_PRED,
 	mercury__builtin_unify_pred_2_0,
 	mercury__builtin_compare_pred_3_0);
-MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(builtin, , pred, 0,
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_NOCM(builtin, pred, 0,
 	MR_TYPECTOR_REP_PRED,
 	mercury__builtin_unify_pred_2_0,
 	mercury__builtin_compare_pred_3_0);
Index: runtime/mercury_type_info.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_type_info.h,v
retrieving revision 1.51
diff -u -b -r1.51 mercury_type_info.h
--- runtime/mercury_type_info.h	2000/05/05 10:14:49	1.51
+++ runtime/mercury_type_info.h	2000/06/27 16:41:09
@@ -808,10 +808,22 @@
 */
 
 #define MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(m, cm, n, a, cr, u, c)    \
+    MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL_A(u, c)			\
+    MR_PASTE6(mercury_data_, cm, __type_ctor_info_, n, _, a) = {        \
+    MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL_B(m, n, a, cr, u, c)
+
+	/* MSVC CPP doesn't like having an empty CM field. */
+#define MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_NOCM(m, n, a, cr, u, c)	\
+    MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL_A(u, c)			\
+    MR_PASTE5(mercury_data_, __type_ctor_info_, n, _, a) = {		\
+    MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL_B(m, n, a, cr, u, c)
+
+#define MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL_A(u, c)			\
     Declare_entry(u);                                                   \
     Declare_entry(c);                                                   \
     MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_Struct                  \
-    MR_PASTE6(mercury_data_, cm, __type_ctor_info_, n, _, a) = {        \
+
+#define MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL_B(m, n, a, cr, u, c)	\
         a,                                                              \
         MR_MAYBE_STATIC_CODE(ENTRY(u)),                                 \
         MR_MAYBE_STATIC_CODE(ENTRY(u)),                                 \
@@ -837,7 +849,7 @@
         MR_PASTE7(mercury____Compare___, m, __, n, _, a, _0))
 
 #define MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_UNUSED(n, a, cr)       \
-    MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(builtin, , n, a, cr,  \
+    MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_NOCM(builtin, n, a, cr,	\
         mercury__unused_0_0,                                    \
         mercury__unused_0_0)
 
Index: trace/mercury_trace_vars.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_vars.c,v
retrieving revision 1.16
diff -u -b -r1.16 mercury_trace_vars.c
--- trace/mercury_trace_vars.c	2000/05/15 16:37:48	1.16
+++ trace/mercury_trace_vars.c	2000/06/27 16:41:11
@@ -138,8 +138,6 @@
 	mercury_data_std_util__type_ctor_info_type_desc_0;
 extern	struct MR_TypeCtorInfo_Struct
 	mercury_data_std_util__type_ctor_info_type_ctor_desc_0;
-extern	struct MR_TypeCtorInfo_Struct	mercury_data___type_ctor_info_func_0;
-extern	struct MR_TypeCtorInfo_Struct	mercury_data___type_ctor_info_pred_0;
 extern	struct MR_TypeCtorInfo_Struct	mercury_data___type_ctor_info_void_0;
 
 #ifdef	NATIVE_GC

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list