diff: std_util.m changes to mercury_compare_typeinfos() etc.

Fergus Henderson fjh at cs.mu.oz.au
Fri May 23 08:09:56 AEST 1997


Hi Tyson,

Can you please review these?

library/std_util.m:
	Change mercury_compare_typeinfo so that it expands equivalence
	types, because that is needed to ensure consistent results.
	Also change it to compare the addresses of the base_type_infos,
	rather than the addresses of the unification predicates.
	(The unification predicates for `int' and enumeration types
	or `char' may be the same, but the base_type_infos are guaranteed
	to be distinct and unique.)
	Use the `ML_' prefix for C functions defined in the Mercury library,
	rather than `mercury_' (or no prefix at all).

Index: std_util.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/std_util.m,v
retrieving revision 1.88
diff -u -r1.88 std_util.m
--- std_util.m	1997/05/20 01:52:52	1.88
+++ std_util.m	1997/05/22 22:07:22
@@ -687,119 +687,126 @@
 
 #include ""type_info.h""
 
-int	mercury_compare_type_info(Word type_info_1, Word type_info_2);
+int	ML_compare_type_info(Word type_info_1, Word type_info_2);
 
 ").
 
 :- pragma c_code("
 
 /*
+** ML_compare_type_info(type_info_1, type_info_2):
+**
 ** Compare two type_info structures, using an arbitrary ordering
-** (based on the addresses of the unification predicates, or in
+** (based on the addresses of the base_type_infos, or in
 ** the case of higher order types, the arity).
+**
+** You need to save and restore transient registers around
+** calls to this function.
 */
 
 MR_DECLARE_STRUCT(mercury_data___base_type_info_pred_0);
 
 int
-mercury_compare_type_info(Word type_info_1, Word type_info_2)
+ML_compare_type_info(Word t1, Word t2)
 {
-	int	i, num_arg_types, comp;
-	Word	unify_pred_1, unify_pred_2;
-	Word	base_type_info_1, base_type_info_2;
+	Word	*type_info_1, *type_info_2;
+	Word	*base_type_info_1, *base_type_info_2;
+	int	num_arg_types;
+	int	i;
 
 	/* 
-	** If type_infos are equal, they must represent the
+	** Try to optimize a common case:
+	** If type_info addresses are equal, they must represent the
 	** same type.
 	*/
-	 if (type_info_1 == type_info_2)
+	if (t1 == t2) {
 		return COMPARE_EQUAL;
+	}
 
-	/* Next find the addresses of the unify preds in the type_infos */
-
-	base_type_info_1 = field(mktag(0), type_info_1, 0);
-	base_type_info_2 = field(mktag(0), type_info_2, 0);
+	/* 
+	** Otherwise, we need to expand equivalence types, if any.
+	*/
+	type_info_1 = (Word *) ML_collapse_equivalences(t1);
+	type_info_2 = (Word *) ML_collapse_equivalences(t2);
 
-	if (base_type_info_1 == 0)
-		unify_pred_1 = field(mktag(0), type_info_1,
-				OFFSET_FOR_UNIFY_PRED);
-	else
-		unify_pred_1 = field(mktag(0), base_type_info_1,
-				OFFSET_FOR_UNIFY_PRED);
-
-	if (base_type_info_2 == 0)
-		unify_pred_2 = field(mktag(0), type_info_2,
-				OFFSET_FOR_UNIFY_PRED);
-	else
-		unify_pred_2 = field(mktag(0), base_type_info_2,
-				OFFSET_FOR_UNIFY_PRED);
+	/* 
+	** Perhaps they are equal now...
+	*/
+	if (type_info_1 == type_info_2) {
+		return COMPARE_EQUAL;
+	}
 
-	/* Then compare the addresses of the unify preds in the type_infos */
-	if (unify_pred_1 < unify_pred_2) {
+	/*
+	** Otherwise find the addresses of the base_type_infos,
+	** and compare those.
+	**
+	** Note: this is an arbitrary ordering. It doesn't matter
+	** what the ordering is, just so long as it is consistent.
+	** ANSI C doesn't guarantee much about pointer comparisons,
+	** so it is possible that this might not do the right thing
+	** on some obscure systems.
+	** The casts to (Word) here are in the hope of increasing
+	** the chance that this will work on a segmented architecture.
+	*/
+	base_type_info_1 = MR_TYPEINFO_GET_BASE_TYPEINFO(type_info_1);
+	base_type_info_2 = MR_TYPEINFO_GET_BASE_TYPEINFO(type_info_2);
+	if ((Word) base_type_info_1 < (Word) base_type_info_2) {
 		return COMPARE_LESS;
 	}
-	if (unify_pred_1 > unify_pred_2) {
+	if ((Word) base_type_info_1 > (Word) base_type_info_2) {
 		return COMPARE_GREATER;
 	}
 
 	/*
-	** If the addresses of the unify preds are equal, we don't need to
+	** If the base_type_info addresses are equal, we don't need to
 	** compare the arity of the types - they must be the same -
 	** unless they are higher-order (which are all mapped to
 	** pred/0). 
 	** But we need to recursively compare the argument types, if any.
 	*/
-
-	/*
-	** Higher order preds can't be optimised into the
-	** type_info == base_type_info, so we don't need 
-	** to check for them in this case.
-	*/
-	if (base_type_info_1 == 0)
-		return COMPARE_EQUAL;
-	else
+		/* Check for higher order */
+	if (base_type_info_1 ==
+		(const Word *) &mercury_data___base_type_info_pred_0)
 	{
-				/* Check for higher order */
-		if (base_type_info_1 ==
-				(Word) &mercury_data___base_type_info_pred_0) {
-			int num_arg_types_2;
-
-				/* Get number of arguments from type_info */
-			num_arg_types = field(mktag(0), type_info_1, 
-				TYPEINFO_OFFSET_FOR_PRED_ARITY);
-
-			num_arg_types_2 = field(mktag(0), type_info_2, 
-				TYPEINFO_OFFSET_FOR_PRED_ARITY);
-
-				/* Check arity */
-			if (num_arg_types < num_arg_types_2) {
-				return COMPARE_LESS;
-			} else if(num_arg_types > num_arg_types_2) {
-				return COMPARE_GREATER;
-			}
+		int num_arg_types_2;
 
-				/*
-				** Increment, so arguments are at the
-				** expected offset.
-				*/
-			type_info_1 += sizeof(Word);
-			type_info_2 += sizeof(Word);
-		} else {
-			num_arg_types = field(mktag(0), base_type_info_1,
-					OFFSET_FOR_COUNT);
+			/* Get number of arguments from type_info */
+		num_arg_types = field(mktag(0), type_info_1, 
+			TYPEINFO_OFFSET_FOR_PRED_ARITY);
+
+		num_arg_types_2 = field(mktag(0), type_info_2, 
+			TYPEINFO_OFFSET_FOR_PRED_ARITY);
+
+			/* Check arity */
+		if (num_arg_types < num_arg_types_2) {
+			return COMPARE_LESS;
 		}
-		for (i = 1; i <= num_arg_types; i++) {
-			Word arg_type_info_1 = field(mktag(0),
-						type_info_1, i);
-			Word arg_type_info_2 = field(mktag(0),
-						type_info_2, i);
-			comp = mercury_compare_type_info(
-					arg_type_info_1, arg_type_info_2);
-			if (comp != COMPARE_EQUAL)
-				return comp;
+		if (num_arg_types > num_arg_types_2) {
+			return COMPARE_GREATER;
 		}
-		return COMPARE_EQUAL;
+
+			/*
+			** Increment, so arguments are at the
+			** expected offset.
+			*/
+		type_info_1++;
+		type_info_2++;
+	} else {
+		num_arg_types = field(mktag(0), base_type_info_1,
+				OFFSET_FOR_COUNT);
 	}
+		/* compare the argument types */
+	for (i = 0; i < num_arg_types; i++) {
+		Word arg_type_info_1 = field(mktag(0), type_info_1,
+			OFFSET_FOR_ARG_TYPE_INFOS + i);
+		Word arg_type_info_2 = field(mktag(0), type_info_2,
+			OFFSET_FOR_ARG_TYPE_INFOS + i);
+		int comp = ML_compare_type_info(
+				arg_type_info_1, arg_type_info_2);
+		if (comp != COMPARE_EQUAL)
+			return comp;
+	}
+	return COMPARE_EQUAL;
 }
 
 ").
@@ -844,9 +851,11 @@
 	% is the compiler-introduced type-info variable.
 :- pragma c_code(type_to_univ(Type::out, Univ::in), will_not_call_mercury, "{
 	Word univ_type_info = field(mktag(0), Univ, UNIV_OFFSET_FOR_TYPEINFO);
-	if (mercury_compare_type_info(univ_type_info, TypeInfo_for_T)
-		== COMPARE_EQUAL)
-	{
+	int comp;
+	save_transient_registers();
+	comp = ML_compare_type_info(univ_type_info, TypeInfo_for_T);
+	restore_transient_registers();
+	if (comp == COMPARE_EQUAL) {
 		Type = field(mktag(0), Univ, UNIV_OFFSET_FOR_DATA);
 		SUCCESS_INDICATOR = TRUE;
 	} else {
@@ -934,6 +943,7 @@
 
 	Word univ1, univ2;
 	Word typeinfo1, typeinfo2;
+	int comp;
 
 	univ1 = unify_input1;
 	univ2 = unify_input2;
@@ -941,8 +951,10 @@
 	/* First check the type_infos compare equal */
 	typeinfo1 = field(mktag(0), univ1, UNIV_OFFSET_FOR_TYPEINFO);
 	typeinfo2 = field(mktag(0), univ2, UNIV_OFFSET_FOR_TYPEINFO);
-	if (mercury_compare_type_info(typeinfo1, typeinfo2) != COMPARE_EQUAL)
-	{
+	save_transient_registers();
+	comp = ML_compare_type_info(typeinfo1, typeinfo2);
+	restore_transient_registers();
+	if (comp != COMPARE_EQUAL) {
 		unify_output = FALSE;
 		proceed();
 	}
@@ -983,7 +995,7 @@
 	/* First compare the type_infos */
 	typeinfo1 = field(mktag(0), univ1, UNIV_OFFSET_FOR_TYPEINFO);
 	typeinfo2 = field(mktag(0), univ2, UNIV_OFFSET_FOR_TYPEINFO);
-	compare_output = mercury_compare_type_info(typeinfo1, typeinfo2);
+	compare_output = ML_compare_type_info(typeinfo1, typeinfo2);
 	if (compare_output != COMPARE_EQUAL) {
 		proceed();
 	}
@@ -1032,30 +1044,40 @@
 
 
 Define_entry(mercury____Unify___std_util__type_info_0_0);
+{
 	/*
 	** Unification for type_info.
 	**
 	** The two inputs are in the registers named by unify_input[12].
 	** The success/failure indication should go in unify_output.
 	*/
-	unify_output = (mercury_compare_type_info(unify_input1,
-				unify_input2) == COMPARE_EQUAL);
+	int comp;
+	save_transient_registers();
+	comp = ML_compare_type_info(unify_input1, unify_input2);
+	restore_transient_registers();
+	unify_output = (comp == COMPARE_EQUAL);
 	proceed();
+}
 
 Define_entry(mercury____Index___std_util__type_info_0_0);
 	index_output = -1;
 	proceed();
 
 Define_entry(mercury____Compare___std_util__type_info_0_0);
+{
 	/*
 	** Comparison for type_info:
 	**
 	** The two inputs are in the registers named by compare_input[12].
 	** The result should go in compare_output.
 	*/
-	compare_output = mercury_compare_type_info(
-				compare_input1, compare_input2);
+	int comp;
+	save_transient_registers();
+	comp = ML_compare_type_info(unify_input1, unify_input2);
+	restore_transient_registers();
+	compare_output = comp;
 	proceed();
+}
 
 Define_entry(mercury____Term_To_Type___std_util__type_info_0_0);
 	/* don't know what to put here. */
@@ -1444,11 +1466,11 @@
 	** Prototypes
 	*/
 
-static int 	get_functor_info(Word type_info, int functor_number, 
+static int 	ML_get_functor_info(Word type_info, int functor_number, 
 				ML_Construct_Info *info);
 
 	/*
-	** get_functor_info:
+	** ML_get_functor_info:
 	**
 	** Extract the information for functor number `functor_number',
 	** for the type represented by type_info.
@@ -1459,7 +1481,7 @@
 	*/
 
 int 
-get_functor_info(Word type_info, int functor_number, ML_Construct_Info *info)
+ML_get_functor_info(Word type_info, int functor_number, ML_Construct_Info *info)
 {
 	Word *base_type_functors;
 
@@ -1513,8 +1535,8 @@
 		Word *equiv_type;
 		equiv_type = (Word *) MR_TYPEFUNCTORS_EQUIV_TYPE(
 				base_type_functors);
-		return get_functor_info((Word)
-				create_type_info((Word *) type_info, 
+		return ML_get_functor_info((Word)
+				ML_create_type_info((Word *) type_info, 
 						equiv_type),
 				functor_number, info);
 	}
@@ -1538,10 +1560,6 @@
 	** `arg_vector' may contain type variables, these
 	** will be filled in by the type arguments of `type_info'.
 	**
-	** If the type arguments of `type_info' are still type variables 
-	** they will be replaced by the void type (see the
-	** documentation of `create_type_info').
-	**
 	** Assumes the length of the list has already been checked.
 	**
 	** You need to save and restore transient registers around
@@ -1552,7 +1570,7 @@
 ML_typecheck_arguments(Word type_info, int arity, Word arg_list,
 		Word* arg_vector) 
 {
-	int i;
+	int i, comp;
 	Word arg_type_info, list_arg_type_info;
 
 		/* Type check list of arguments */
@@ -1561,14 +1579,14 @@
 		if (list_is_empty(arg_list)) {
 			return FALSE;
 		}
-		list_arg_type_info = field(0, (list_head(arg_list)), 
+		list_arg_type_info = field(0, list_head(arg_list), 
 			UNIV_OFFSET_FOR_TYPEINFO);
 
-		arg_type_info = (Word) create_type_info(
+		arg_type_info = (Word) ML_create_type_info(
 			(Word *) type_info, (Word *) arg_vector[i]);
 
-		if (mercury_compare_type_info(list_arg_type_info, 
-				arg_type_info) != COMPARE_EQUAL) {
+		comp = ML_compare_type_info(list_arg_type_info, arg_type_info);
+		if (comp != COMPARE_EQUAL) {
 			return FALSE;
 		}
 		arg_list = list_tail(arg_list);
@@ -1655,7 +1673,7 @@
 	**
 	** Check that functor_number is in range, and get the functor
 	** info if it is. Return FALSE if it is out of range, or
-	** if get_functor_info returns FALSE, otherwise return TRUE.
+	** if ML_get_functor_info returns FALSE, otherwise return TRUE.
 	**
 	** You need to save and restore transient registers around
 	** calls to this function.
@@ -1671,7 +1689,7 @@
 		*/
 	return  functor_number < ML_get_num_functors(type_info) &&
 		functor_number >= 0 &&
-		get_functor_info(type_info, functor_number, info);
+		ML_get_functor_info(type_info, functor_number, info);
 }
 
 
@@ -1701,7 +1719,7 @@
 
 			/* Fill in any polymorphic type_infos */
 		save_transient_registers();
-		argument = (Word) create_type_info(
+		argument = (Word) ML_create_type_info(
 			(Word *) type_info, (Word *) argument);
 		restore_transient_registers();
 
@@ -1741,7 +1759,7 @@
 		/* Look past equivalences */
 	while (MR_TYPEFUNCTORS_INDICATOR(functors) == MR_TYPEFUNCTORS_EQUIV) {
 		equiv_type_info = (Word) MR_TYPEFUNCTORS_EQUIV_TYPE(functors);
-		equiv_type_info = (Word) create_type_info(
+		equiv_type_info = (Word) ML_create_type_info(
 				(Word *) maybe_equiv_type_info, 
 				(Word *) equiv_type_info);
 		functors = MR_BASE_TYPEINFO_GET_TYPEFUNCTORS(
@@ -1790,7 +1808,7 @@
 				MR_TYPEFUNCTORS_EQUIV_TYPE(
 					base_type_functors);
 			Functors = ML_get_num_functors((Word)
-					create_type_info((Word *) 
+					ML_create_type_info((Word *) 
 						type_info, equiv_type));
 			break;
 		}
@@ -1835,15 +1853,15 @@
 
 	/* 
 	 * The last two fields, need_functor, and need_args, must
-	 * be set by the caller, to indicate whether mercury_expand
+	 * be set by the caller, to indicate whether ML_expand
 	 * should copy the functor (if need_functor is non-zero) or
 	 * the argument vector and type_info_vector (if need_args is
 	 * non-zero). The arity will always be set.
 	 *
-	 * mercury_expand will fill in the other fields (functor, arity,
+	 * ML_expand will fill in the other fields (functor, arity,
 	 * argument_vector and type_info_vector) accordingly, but
 	 * the values of fields not asked for should be assumed to
-	 * contain random data when mercury_expand returns.
+	 * contain random data when ML_expand returns.
 	 * (that is, they should not be relied on to remain unchanged).
 	 */
 
@@ -1860,24 +1878,23 @@
 
 	/* Prototypes */
 
-void mercury_expand(Word* type_info, Word data_word, ML_Expand_Info *info);
+void ML_expand(Word* type_info, Word data_word, ML_Expand_Info *info);
 
-Word * create_type_info(Word *term_type_info, 
-	Word *arg_pseudo_type_info);
+Word * ML_create_type_info(Word *term_type_info, Word *arg_pseudo_type_info);
 
 ").
 
 :- pragma c_code("
 
-static void mercury_expand_const(Word data_value, Word entry_value,
+static void ML_expand_const(Word data_value, Word entry_value,
 	ML_Expand_Info *info);
-static void mercury_expand_enum(Word data_value, Word entry_value, 
+static void ML_expand_enum(Word data_value, Word entry_value, 
 	ML_Expand_Info *info);
-static void mercury_expand_simple(Word data_value, Word* arg_type_infos, 
+static void ML_expand_simple(Word data_value, Word* arg_type_infos, 
 	Word * type_info, ML_Expand_Info *info);
-static void mercury_expand_builtin(Word data_value, Word entry_value,
+static void ML_expand_builtin(Word data_value, Word entry_value,
 	ML_Expand_Info *info);
-static void mercury_expand_complicated(Word data_value, Word entry_value, 
+static void ML_expand_complicated(Word data_value, Word entry_value, 
 	Word * type_info, ML_Expand_Info *info);
 
 /*
@@ -1893,9 +1910,9 @@
 ** 	- constants (eg base_type_infos)
 **
 ** Please note: 
-**	mercury_expand increments the heap pointer, however, on
+**	ML_expand increments the heap pointer, however, on
 **	some platforms the register windows mean that transient
-**	Mercury registers may be lost. Before calling mercury_expand,
+**	Mercury registers may be lost. Before calling ML_expand,
 **	call save_transient_registers(), and afterwards, call
 **	restore_transient_registers().
 **
@@ -1905,7 +1922,7 @@
 */
 
 void 
-mercury_expand(Word* type_info, Word data_word, ML_Expand_Info *info)
+ML_expand(Word* type_info, Word data_word, ML_Expand_Info *info)
 {
 	Word *base_type_info, *arg_type_info;
 	Word data_value, entry_value, base_type_layout_entry;
@@ -1938,28 +1955,28 @@
 			** entry value represents the type of builtin.
 			*/
 			entry_value = unmkbody(entry_value);
-			mercury_expand_builtin(data_word, entry_value,
+			ML_expand_builtin(data_word, entry_value,
 				info);
 		} else {
 			/* It's a complicated constant or enum */
 			if (MR_TYPELAYOUT_ENUM_VECTOR_IS_ENUM(entry_value)) {
-				mercury_expand_enum(data_word, entry_value, 
+				ML_expand_enum(data_word, entry_value, 
 					info);
 			} else {
 				data_value = unmkbody(data_value);
-				mercury_expand_const(data_value, entry_value, 
+				ML_expand_const(data_value, entry_value, 
 					info);
 			}
 		}
 		break;
 
 	case TYPELAYOUT_SIMPLE_TAG:
-		mercury_expand_simple(data_value, (Word *) entry_value, 
+		ML_expand_simple(data_value, (Word *) entry_value, 
 			type_info, info);
 		break;
 
 	case TYPELAYOUT_COMPLICATED_TAG:
-		mercury_expand_complicated(data_value, entry_value, type_info,
+		ML_expand_complicated(data_value, entry_value, type_info,
 			info);
 		break;
 
@@ -1969,9 +1986,9 @@
 			** Is it a type variable? 
 			*/
 		if (TYPEINFO_IS_VARIABLE(entry_value)) {
-			arg_type_info = create_type_info(type_info, 
+			arg_type_info = ML_create_type_info(type_info, 
 				(Word *) entry_value);
-			mercury_expand(arg_type_info, data_word, info);
+			ML_expand(arg_type_info, data_word, info);
 		}
 			/* 
 			** is it a no_tag type?
@@ -1980,17 +1997,17 @@
 			Word new_arg_vector; 
 			incr_saved_hp(new_arg_vector, 1);
 			field(0, new_arg_vector, 0) = data_word;
-			mercury_expand_simple(new_arg_vector, 
+			ML_expand_simple(new_arg_vector, 
 				(Word *) entry_value, type_info, info);
 		}
 			/* 
 			** It must be an equivalent type.
 			*/
 		else {
-			arg_type_info = create_type_info(type_info, 
+			arg_type_info = ML_create_type_info(type_info, 
 				(Word *) MR_TYPELAYOUT_EQUIV_TYPE(
 					entry_value));
-			mercury_expand(arg_type_info, data_word, info);
+			ML_expand(arg_type_info, data_word, info);
 		}
 
 		break;
@@ -2007,7 +2024,7 @@
  */
 
 void
-mercury_expand_const(Word data_value, Word entry_value, ML_Expand_Info *info) 
+ML_expand_const(Word data_value, Word entry_value, ML_Expand_Info *info) 
 {
 
 	/* the functors are stored after the enum_indicator and
@@ -2026,7 +2043,7 @@
  */
 
 void
-mercury_expand_enum(Word data_value, Word enum_vector, ML_Expand_Info *info) 
+ML_expand_enum(Word data_value, Word enum_vector, ML_Expand_Info *info) 
 {
 	info->functor = MR_TYPELAYOUT_ENUM_VECTOR_FUNCTOR_NAME(enum_vector,
 		data_value);
@@ -2047,7 +2064,7 @@
  *
  */
 void 
-mercury_expand_simple(Word data_value, Word* simple_vector, Word * type_info,
+ML_expand_simple(Word data_value, Word* simple_vector, Word * type_info,
 	ML_Expand_Info *info)
 {
 	int i;
@@ -2073,7 +2090,7 @@
 				MR_TYPELAYOUT_SIMPLE_VECTOR_ARGS(
 					simple_vector)[i];
 			info->type_info_vector[i] = (Word) 
-				create_type_info(type_info, 
+				ML_create_type_info(type_info, 
 					arg_pseudo_type_info);
 		}
 	}
@@ -2092,7 +2109,7 @@
  */
 
 void
-mercury_expand_complicated(Word data_value, Word entry_value, Word * type_info,
+ML_expand_complicated(Word data_value, Word entry_value, Word * type_info,
 	ML_Expand_Info *info)
 {
 	Word new_data_value, simple_vector, simple_vector_tag, secondary_tag;
@@ -2105,12 +2122,12 @@
 	simple_vector_tag = tag(simple_vector);
 	simple_vector = body(simple_vector, simple_vector_tag);
 
-	mercury_expand_simple(new_data_value, (Word *) simple_vector, 
+	ML_expand_simple(new_data_value, (Word *) simple_vector, 
 		type_info, info);
 }
 
 void
-mercury_expand_builtin(Word data_value, Word entry_value, ML_Expand_Info *info)
+ML_expand_builtin(Word data_value, Word entry_value, ML_Expand_Info *info)
 {
 	switch ((int) entry_value) {
 	
@@ -2197,7 +2214,7 @@
 		 * type_info and data.
 		 */
 
-		mercury_expand((Word *) 
+		ML_expand((Word *) 
 			((Word *) data_value)[UNIV_OFFSET_FOR_TYPEINFO], 
 			((Word *) data_value)[UNIV_OFFSET_FOR_DATA], info);
 		break;
@@ -2212,19 +2229,19 @@
 		break;
 
 	case TYPELAYOUT_VOID_VALUE:
-		fatal_error(""mercury_expand: found void"");
+		fatal_error(""ML_expand: found void"");
 		break;
 
 	case TYPELAYOUT_UNIQ_ARRAY_VALUE:
-		fatal_error(""mercury_expand: found uniq_array"");
+		fatal_error(""ML_expand: found uniq_array"");
 		break;
 
 	case TYPELAYOUT_TYPEINFO_VALUE:
-		fatal_error(""mercury_expand: found type_info"");
+		fatal_error(""ML_expand: found type_info"");
 		break;
 
 	case TYPELAYOUT_C_POINTER_VALUE:
-		fatal_error(""mercury_expand: found c_pointer"");
+		fatal_error(""ML_expand: found c_pointer"");
 		break;
 		
 		
@@ -2249,17 +2266,6 @@
 	** This returns a fully instantiated type_info, a version of the
 	** arg_pseudo_type_info with all the type variables filled in.
 	**
-	** If the substituted type parameters from the term_type_info
-	** were type variables, they will be replaced with references
-	** to the void type ('void'/0).
-	** XXX: This is a temporary measure. It would be best if the
-	** code in polymorphism.m and typecheck.m was changed to output
-	** references to 'void' for unbound type variables, rather than
-	** outputting NULL pointers, which we convert to references to
-	** void here. Note that this would also involve changing any
-	** code that relied upon the NULL definition (for example,
-	** mercury_compare_type_info).
-	**
 	** We allocate memory for a new type_info on the Mercury heap,
 	** copy the necessary information, and return a pointer to the
 	** new type_info. 
@@ -2273,13 +2279,13 @@
 	** type_info.
 	**
 	** NOTE: If you are changing this code, you might also need
-	** to change the code in create_type_info in runtime/deep_copy.c,
+	** to change the code in ML_create_type_info in runtime/deep_copy.c,
 	** which does much the same thing, only allocating using malloc
 	** instead of on the heap.
 	*/
 
 Word * 
-create_type_info(Word *term_type_info, Word *arg_pseudo_type_info)
+ML_create_type_info(Word *term_type_info, Word *arg_pseudo_type_info)
 {
 	int i, arity;
 	Word base_type_info;
@@ -2340,7 +2346,7 @@
 
 	save_transient_registers();
 
-	mercury_expand((Word *) TypeInfo_for_T, Type, &info);
+	ML_expand((Word *) TypeInfo_for_T, Type, &info);
 
 	restore_transient_registers();
 
@@ -2363,7 +2369,7 @@
 
 	save_transient_registers();
 
-	mercury_expand((Word *) TypeInfo_for_T, Type, &info);
+	ML_expand((Word *) TypeInfo_for_T, Type, &info);
 
 	restore_transient_registers();
 
@@ -2418,7 +2424,7 @@
 
 	save_transient_registers();
 
-	mercury_expand((Word *) TypeInfo_for_T, Type, &info);
+	ML_expand((Word *) TypeInfo_for_T, Type, &info);
 	
 	restore_transient_registers();
 

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list