[m-dev.] for review: rename base_type_* to type_ctor_* (part 1/2)

Tyson Dowd trd at cs.mu.OZ.AU
Thu Mar 18 13:49:13 AEDT 1999


New log message:
---------------------------------------

Estimated hours taken: 8

During the writing of the RTTI paper, we decided that type_ctor_info
was a much better name than base_type_info.

Rename base_type* as type_ctor*, except we don't rename the modules
base_type_info and base_type_layout just yet.

Most of these changes were made using the following sed patterns:

s/base_type_info/type_ctor_info/g
s/base_type_layout/type_ctor_layout/g
s/base_type_functors/type_ctor_functors/g
s/BASETYPE_INFO/TYPE_CTOR_INFO/g
s/TYPEFUNCTORS/TYPE_CTOR_FUNCTORS/g
s/TYPELAYOUT/TYPE_CTOR_LAYOUT/g
s/BASE_TYPEINFO/TYPE_CTOR_INFO/g
s/BASE_TYPE_INFO/TYPE_CTOR_INFO/g
s/BaseTypeInfo/TypeCtorInfo/g
s/BaseTypeLayout/TypeCtorLayout/g
s/base_type(/type_ctor(/g
s/:- module type_ctor_info/:- module base_type_info/g
s/:- module type_ctor_layout/:- module base_type_layout/g
s/type_ctor_info__/base_type_info__/g
s/type_ctor_layout__/base_type_layout__/g
/import_module/s/type_ctor_info/base_type_info/g
/import_module/s/type_ctor_layout/base_type_layout/g

compiler/*.m:
library/*.m:
runtime/*.{c,h}:
profiler/demangle.m:
util/mdemangle.c:
	Applied the above sed commands.

runtime/mercury_bootstrap.h:
	Add bootstrapping #defines so the type_ctor_* substitutions in
	the library don't cause link problems.

	Delete some redundant bootstrapping definitions.

> Did you modify util/mdemangle.c and profiler/demangle.m?

Index: profiler//demangle.m
===================================================================
RCS file: /home/mercury1/repository/mercury/profiler/demangle.m,v
retrieving revision 1.7
diff -u -r1.7 demangle.m
--- demangle.m	1999/02/04 14:58:19	1.7
+++ demangle.m	1999/03/18 01:56:57
@@ -331,22 +331,22 @@
 demangle_data -->
 	remove_prefix("mercury_data_"),
 	remove_maybe_module_prefix(MaybeModule0,
-		["base_type_info_", "base_type_layout_",
-		"base_type_functors_", "common_"]),
+		["type_ctor_info_", "type_ctor_layout_",
+		"type_ctor_functors_", "common_"]),
 	{ MaybeModule0 = yes("") ->
 		MaybeModule = no
 	;
 		MaybeModule = MaybeModule0
 	},
-	( remove_prefix("base_type_info_") ->
+	( remove_prefix("type_ctor_info_") ->
 		{ DataCategory = info },
 		remove_trailing_int(Arity),
 		m_remove_suffix("_")
-	; remove_prefix("base_type_layout_") ->
+	; remove_prefix("type_ctor_layout_") ->
 		{ DataCategory = layout },
 		remove_trailing_int(Arity),
 		m_remove_suffix("_")
-	; remove_prefix("base_type_functors_") ->
+	; remove_prefix("type_ctor_functors_") ->
 		{ DataCategory = functors },
 		remove_trailing_int(Arity),
 		m_remove_suffix("_")
Index: profiler/util//mdemangle.c
===================================================================
RCS file: /home/mercury1/repository/mercury/util/mdemangle.c,v
retrieving revision 1.33
diff -u -r1.33 mdemangle.c
--- mdemangle.c	1999/02/04 15:26:40	1.33
+++ mdemangle.c	1999/03/18 01:56:02
@@ -119,9 +119,9 @@
 	static const char ho_suffix[] = "__ho"; /* added by higher_order.m */
 
 	static const char mercury_data[] = "mercury_data_";
-	static const char base_type_layout[] = "base_type_layout_";
-	static const char base_type_info[] = "base_type_info_";
-	static const char base_type_functors[] = "base_type_functors_";
+	static const char type_ctor_layout[] = "type_ctor_layout_";
+	static const char type_ctor_info[] = "type_ctor_info_";
+	static const char type_ctor_functors[] = "type_ctor_functors_";
 	static const char base_typeclass_info[] = "__base_typeclass_info_";
 	static const char common[] = "common";
 	static const char arity_string[] = "arity";
@@ -134,9 +134,9 @@
 	};
 
 	static const char * trailing_context_2[] = {
-		base_type_layout,
-		base_type_info,
-		base_type_functors,
+		type_ctor_layout,
+		type_ctor_info,
+		type_ctor_functors,
 		common,
 		NULL
 	};
@@ -441,17 +441,17 @@
 
 	module = strip_module_name(&start, end, trailing_context_2);
 
-	if (strip_prefix(&start, base_type_info)) {
+	if (strip_prefix(&start, type_ctor_info)) {
 		data_category = INFO;
 		if (!cut_trailing_underscore_integer(start, &end, &arity)) {
 			goto wrong_format;
 		}
-	} else if (strip_prefix(&start, base_type_layout)) {
+	} else if (strip_prefix(&start, type_ctor_layout)) {
 		data_category = LAYOUT;
 		if (!cut_trailing_underscore_integer(start, &end, &arity)) {
 			goto wrong_format;
 		}
-	} else if (strip_prefix(&start, base_type_functors)) {
+	} else if (strip_prefix(&start, type_ctor_functors)) {
 		data_category = FUNCTORS;
 		if (!cut_trailing_underscore_integer(start, &end, &arity)) {
 			goto wrong_format;

> 
> I didn't look at most of the changes in any detail, but if they were
> applied by automatic application of the above sed script, and it
> bootstraps, then I'm happy.  If there were changes other than
> ones resulting from the sed script, it would be nice if we could
> see a separate diff for those.

It bootstrapped fine.  I will run it again though just to be sure of
the latest changes.

The only thing done by hand now is the stuff in mercury_bootstrap.h,
and a few changes in llds_out.m to output type_ctor instead of
base_type, and renamed llds_out__make_base_type_name to
llds_out__make_type_ctor_name (forgot to mention llds_out in my last
mail).  Since you have supplied to appropriate sed command the
import_module fixes are no longer hand written.

I could probably catch these cases with s/base_type_/type_ctor_/g
but I don't really want to have to redo all the changes and check.

Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.103
diff -u -r1.103 llds_out.m
--- llds_out.m	1999/02/04 14:58:10	1.103
+++ llds_out.m	1999/03/16 03:31:06
@@ -108,10 +108,10 @@
 :- pred output_c_quoted_string(string, io__state, io__state).
 :- mode output_c_quoted_string(in, di, uo) is det.
 
-	% Create a name for base_type_*
+	% Create a name for type_ctor_*
 
-:- pred llds_out__make_base_type_name(base_data, string, arity, string).
-:- mode llds_out__make_base_type_name(in, in, in, out) is det.
+:- pred llds_out__make_type_ctor_name(base_data, string, arity, string).
+:- mode llds_out__make_type_ctor_name(in, in, in, out) is det.
 
 	% Create a name for base_typeclass_info
 
@@ -508,8 +508,8 @@
 	{ NextSeq is Seq + 1 },
 	output_init_bunch_calls(Bunches, ModuleName, InitStatus, NextSeq).
 
-	% Output MR_INIT_BASE_TYPE_INFO(BaseTypeInfo, TypeId);
-	% for each base_type_info defined in this module.
+	% Output MR_INIT_TYPE_CTOR_INFO(TypeCtorInfo, TypeId);
+	% for each type_ctor_info defined in this module.
 
 :- pred output_c_data_init_list(list(comp_gen_c_data)::in,
 	io__state::di, io__state::uo) is det.
@@ -518,9 +518,9 @@
 output_c_data_init_list([Data | Datas]) -->
 	(
 		{ Data = comp_gen_c_data(ModuleName, DataName, _, _, _) },
-		{ DataName = base_type(info, TypeName, Arity) }
+		{ DataName = type_ctor(info, TypeName, Arity) }
 	->
-		io__write_string("\t\tMR_INIT_BASE_TYPE_INFO(\n\t\t"),
+		io__write_string("\t\tMR_INIT_TYPE_CTOR_INFO(\n\t\t"),
 		output_data_addr(ModuleName, DataName),
 		io__write_string(",\n\t\t\t"),
 		{ llds_out__sym_name_mangle(ModuleName, ModuleNameString) },
@@ -2192,9 +2192,9 @@
 :- mode data_name_would_include_code_address(in, out) is det.
 
 data_name_would_include_code_address(common(_), no).
-data_name_would_include_code_address(base_type(info, _, _), yes).
-data_name_would_include_code_address(base_type(layout, _, _), no).
-data_name_would_include_code_address(base_type(functors, _, _), no).
+data_name_would_include_code_address(type_ctor(info, _, _), yes).
+data_name_would_include_code_address(type_ctor(layout, _, _), no).
+data_name_would_include_code_address(type_ctor(functors, _, _), no).
 data_name_would_include_code_address(base_typeclass_info(_, _), yes).
 data_name_would_include_code_address(proc_layout(_), yes).
 data_name_would_include_code_address(internal_layout(_), no).
@@ -2533,10 +2533,10 @@
 
 	globals__io_get_globals(Globals),
 
-		% Don't make decls of base_type_infos `const' if we
+		% Don't make decls of type_ctor_infos `const' if we
 		% don't have static code addresses.
 	(
-		{ VarName = base_type(info, _, _) },
+		{ VarName = type_ctor(info, _, _) },
 		{ globals__have_static_code_addresses(Globals, no) }
 	->
 		[]
@@ -2566,9 +2566,9 @@
 
 :- pred linkage(data_name::in, linkage::out) is det.
 linkage(common(_),                 static).
-linkage(base_type(info, _, _),     extern).
-linkage(base_type(layout, _, _),   static).
-linkage(base_type(functors, _, _), static).
+linkage(type_ctor(info, _, _),     extern).
+linkage(type_ctor(layout, _, _),   static).
+linkage(type_ctor(functors, _, _), static).
 linkage(base_typeclass_info(_, _), extern).
 linkage(proc_layout(_),            static).
 linkage(internal_layout(_),        static).
@@ -2826,9 +2826,9 @@
 	;
 		{ llds_out__sym_name_mangle(ModuleName, MangledModuleName) },
 		io__write_string("mercury_data_"),
-		{ VarName = base_type(BaseData, TypeName0, TypeArity) },
+		{ VarName = type_ctor(BaseData, TypeName0, TypeArity) },
 		io__write_string(MangledModuleName),
-		{ llds_out__make_base_type_name(BaseData, TypeName0, TypeArity,
+		{ llds_out__make_type_ctor_name(BaseData, TypeName0, TypeArity,
 			Str) },
 		io__write_string("__"),
 		io__write_string(Str)
@@ -3797,7 +3797,7 @@
 
 %-----------------------------------------------------------------------------%
 
-llds_out__make_base_type_name(BaseData, TypeName0, TypeArity, Str) :-
+llds_out__make_type_ctor_name(BaseData, TypeName0, TypeArity, Str) :-
 	(
 		BaseData = info,
 		BaseString = "info"
@@ -3810,7 +3810,7 @@
 	),
 	llds_out__name_mangle(TypeName0, TypeName),
 	string__int_to_string(TypeArity, A_str),
-        string__append_list(["base_type_", BaseString, "_", TypeName, "_", 
+        string__append_list(["type_ctor_", BaseString, "_", TypeName, "_", 
 		A_str], Str).
 
 
Index: runtime/mercury_bootstrap.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_bootstrap.h,v
retrieving revision 1.4
diff -u -r1.4 mercury_bootstrap.h
--- mercury_bootstrap.h	1998/12/16 16:35:38	1.4
+++ mercury_bootstrap.h	1999/03/18 02:10:35
@@ -49,24 +49,108 @@
 				curredoip = redoip;			\
 			} while (0)
 
-
-#define TYPELAYOUT_UNASSIGNED_VALUE	(MR_TYPELAYOUT_UNASSIGNED_VALUE)
-#define TYPELAYOUT_UNUSED_VALUE		(MR_TYPELAYOUT_UNUSED_VALUE)
-#define TYPELAYOUT_STRING_VALUE		(MR_TYPELAYOUT_STRING_VALUE)
-#define TYPELAYOUT_FLOAT_VALUE		(MR_TYPELAYOUT_FLOAT_VALUE)
-#define TYPELAYOUT_INT_VALUE		(MR_TYPELAYOUT_INT_VALUE)
-#define TYPELAYOUT_CHARACTER_VALUE	(MR_TYPELAYOUT_CHARACTER_VALUE)
-#define TYPELAYOUT_UNIV_VALUE		(MR_TYPELAYOUT_UNIV_VALUE)
-#define TYPELAYOUT_PREDICATE_VALUE	(MR_TYPELAYOUT_PREDICATE_VALUE)
-#define TYPELAYOUT_VOID_VALUE		(MR_TYPELAYOUT_VOID_VALUE)
-#define TYPELAYOUT_ARRAY_VALUE		(MR_TYPELAYOUT_ARRAY_VALUE)
-#define TYPELAYOUT_TYPEINFO_VALUE	(MR_TYPELAYOUT_TYPEINFO_VALUE)
-#define TYPELAYOUT_C_POINTER_VALUE	(MR_TYPELAYOUT_C_POINTER_VALUE)
-
 /*
 ** The code generated by Mercury 0.8 includes references to these macros.
 */
 #define MR_OBTAIN_GLOBAL_C_LOCK()	MR_OBTAIN_GLOBAL_LOCK("pragma c code")
 #define MR_RELEASE_GLOBAL_C_LOCK()	MR_RELEASE_GLOBAL_LOCK("pragma c code")
+
+
+/*
+** Generated code will create references to base_type_* which has been
+** renamed.  Builtin types use hand-defined type_ctor_*, so we need to
+** #define the old names for these structures so the stage 1 compiler
+** will link.  The stage 2 compiler will just generate type_ctor_*
+** references anyway, so then these #defines are not needed.
+*/
+#define MR_INIT_BASE_TYPE_INFO		MR_INIT_TYPE_CTOR_INFO
+
+#define mercury_data_array__base_type_functors_array_1 \
+	mercury_data_array__type_ctor_functors_array_1 
+
+#define mercury_data_array__base_type_functors_array_1_struct \
+	mercury_data_array__type_ctor_functors_array_1_struct
+
+#define mercury_data_array__base_type_layout_array_1 \
+	mercury_data_array__type_ctor_layout_array_1 
+
+#define mercury_data_array__base_type_layout_array_1_struct \
+	mercury_data_array__type_ctor_layout_array_1_struct
+
+
+#define mercury_data_builtin__base_type_functors_c_pointer_0 \
+	mercury_data_builtin__type_ctor_functors_c_pointer_0 
+
+#define mercury_data_builtin__base_type_functors_c_pointer_0_struct \
+	mercury_data_builtin__type_ctor_functors_c_pointer_0_struct
+
+#define mercury_data_builtin__base_type_layout_c_pointer_0 \
+	mercury_data_builtin__type_ctor_layout_c_pointer_0 
+
+#define mercury_data_builtin__base_type_layout_c_pointer_0_struct \
+	mercury_data_builtin__type_ctor_layout_c_pointer_0_struct
+
+
+#define mercury_data_std_util__base_type_functors_type_info_0 \
+	mercury_data_std_util__type_ctor_functors_type_info_0 
+
+#define mercury_data_std_util__base_type_functors_type_info_0_struct \
+	mercury_data_std_util__type_ctor_functors_type_info_0_struct
+
+#define mercury_data_std_util__base_type_layout_type_info_0 \
+	mercury_data_std_util__type_ctor_layout_type_info_0 
+
+#define mercury_data_std_util__base_type_layout_type_info_0_struct \
+	mercury_data_std_util__type_ctor_layout_type_info_0_struct
+
+
+#define mercury_data_std_util__base_type_functors_univ_0 \
+	mercury_data_std_util__type_ctor_functors_univ_0 
+
+#define mercury_data_std_util__base_type_functors_univ_0_struct \
+	mercury_data_std_util__type_ctor_functors_univ_0_struct
+
+#define mercury_data_std_util__base_type_layout_univ_0 \
+	mercury_data_std_util__type_ctor_layout_univ_0 
+
+#define mercury_data_std_util__base_type_layout_univ_0_struct \
+	mercury_data_std_util__type_ctor_layout_univ_0_struct
+
+#define mercury_data___base_type_info_int_0_struct \
+	mercury_data___type_ctor_info_int_0_struct
+
+#define mercury_data___base_type_info_int_0 \
+	mercury_data___type_ctor_info_int_0
+
+#define mercury_data___base_type_info_string_0_struct \
+	mercury_data___type_ctor_info_string_0_struct
+
+#define mercury_data___base_type_info_string_0 \
+	mercury_data___type_ctor_info_string_0
+
+#define mercury_data___base_type_info_character_0 \
+	mercury_data___type_ctor_info_character_0
+
+#define mercury_data___base_type_info_character_0_struct \
+	mercury_data___type_ctor_info_character_0_struct
+
+#define mercury_data___base_type_info_float_0 \
+	mercury_data___type_ctor_info_float_0
+
+#define mercury_data___base_type_info_float_0_struct \
+	mercury_data___type_ctor_info_float_0_struct
+
+#define mercury_data___base_type_info_pred_0 \
+	mercury_data___type_ctor_info_pred_0
+
+#define mercury_data___base_type_info_pred_0_struct \
+	mercury_data___type_ctor_info_pred_0_struct
+
+#define mercury_data_private_builtin__base_type_info_type_info_1 \
+	mercury_data_private_builtin__type_ctor_info_type_info_1
+
+#define mercury_data_private_builtin__base_type_info_type_info_1_struct \
+	mercury_data_private_builtin__type_ctor_info_type_info_1_struct
+
 
 #endif	/* MERCURY_BOOTSTRAP_H */




More information about the developers mailing list