for review: type_info/[01] saga continues.

Tyson Dowd trd at cs.mu.OZ.AU
Mon Aug 10 19:00:22 AEST 1998


Hi,

Fergus and I discussed this change on Friday.
Could someone check it?

It was causing problems in particular with type_name, because
type_name was seeing through the equivalence (which isn't really
what we wanted).


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


Estimated hours taken: 0.5

Make std_util:type_info/0 different to private_builtin:type_info/1.

library/std_util.m:
	Although std_util:type_info/0 is equivalent to
	private_builtin:type_info/1, we want to make this equivalence
	opaque, so we will reuturn std_util:private_builtin to its
	previous defintion.  Of course it is still implemented as the
	same type.

cvs server: Diffing library
Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.126
diff -u -r1.126 std_util.m
--- std_util.m	1998/08/04 02:22:01	1.126
+++ std_util.m	1998/08/10 08:40:36
@@ -943,13 +943,9 @@
 		"Y = X;").
 %-----------------------------------------------------------------------------%
 
-	% We define type_info as the same as the private_builtin
-	% definition of type_info.  `unit' is just used as a placeholder.
-	% type_info/1 is defined internally, and the type parameter
-	% is really some sort of existential type.
+	% The type `std_util:type_info/0' happens to use much the same
+	% representation as `private_builtin:type_info/1'.
 	
-:- type type_info == private_builtin:type_info(unit). 
-
 univ_to_type(Univ, X) :- type_to_univ(X, Univ).
 
 univ(X) = Univ :- type_to_univ(X, Univ).
@@ -1063,6 +1059,21 @@
 	MR_TYPEFUNCTORS_UNIV
 };
 
+const struct mercury_data_std_util__base_type_layout_type_info_0_struct
+{
+	TYPE_LAYOUT_FIELDS
+} mercury_data_std_util__base_type_layout_type_info_0 = {
+	make_typelayout_for_all_tags(TYPELAYOUT_CONST_TAG, 
+		mkbody(TYPELAYOUT_TYPEINFO_VALUE))
+};
+
+const struct
+mercury_data_std_util__base_type_functors_type_info_0_struct {
+	Integer f1;
+} mercury_data_std_util__base_type_functors_type_info_0 = {
+	MR_TYPEFUNCTORS_SPECIAL
+};
+
 #endif
 
 Define_extern_entry(mercury____Unify___std_util__univ_0_0);
@@ -1074,12 +1085,23 @@
 MR_MAKE_STACK_LAYOUT_ENTRY(mercury____Compare___std_util__univ_0_0);
 MR_MAKE_STACK_LAYOUT_INTERNAL(mercury____Compare___std_util__univ_0_0, 1);
 
+Define_extern_entry(mercury____Unify___std_util__type_info_0_0);
+Define_extern_entry(mercury____Index___std_util__type_info_0_0);
+Define_extern_entry(mercury____Compare___std_util__type_info_0_0);
+MR_MAKE_STACK_LAYOUT_ENTRY(mercury____Unify___std_util__type_info_0_0);
+MR_MAKE_STACK_LAYOUT_ENTRY(mercury____Index___std_util__type_info_0_0);
+MR_MAKE_STACK_LAYOUT_ENTRY(mercury____Compare___std_util__type_info_0_0);
 
 BEGIN_MODULE(unify_univ_module)
 	init_entry_sl(mercury____Unify___std_util__univ_0_0);
 	init_entry_sl(mercury____Index___std_util__univ_0_0);
 	init_entry_sl(mercury____Compare___std_util__univ_0_0);
 	init_label_sl(mercury____Compare___std_util__univ_0_0_i1);
+
+	init_entry_sl(mercury____Unify___std_util__type_info_0_0);
+	init_entry_sl(mercury____Index___std_util__type_info_0_0);
+	init_entry_sl(mercury____Compare___std_util__type_info_0_0);
+
 BEGIN_CODE
 Define_entry(mercury____Unify___std_util__univ_0_0);
 {
@@ -1189,6 +1211,43 @@
 	r1 = r2;
 	proceed();
 #endif
+
+
+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.
+	*/
+	int comp;
+	save_transient_registers();
+	comp = MR_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.
+	*/
+	int comp;
+	save_transient_registers();
+	comp = MR_compare_type_info(unify_input1, unify_input2);
+	restore_transient_registers();
+	compare_output = comp;
+	proceed();
+}
 
 END_MODULE
 


-- 
       Tyson Dowd           # "Bill Gates is a white persian cat and a monocle
                            # away from becoming another James Bond villan."
     trd at cs.mu.oz.au        # "No Mr Bond, I expect you to upgrade."
http://www.cs.mu.oz.au/~trd #                -- Dennis Miller and Terri Branch



More information about the developers mailing list