[m-dev.] diff: make c_pointer hand defined.

Tyson Dowd trd at cs.mu.OZ.AU
Thu Jun 24 13:52:37 AEST 1999


Hi,

Another change that needs to be bootstrapped.

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


Estimated hours taken: 0.5

c_pointer needs to be a hand defined type -- up until now everything but
the type_ctor_info is hand defined.  We need to be able to change the
contents of the type_ctor_info, however.

compiler/type_util.m:
library/builtin.m:
runtime/mercury_bootstrap.c:
	Make builtin:c_pointer a hand-defined type, doing the usual
	bootstrapping trick.


Index: compiler/type_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/type_util.m,v
retrieving revision 1.66
diff -u -r1.66 type_util.m
--- type_util.m	1999/05/31 09:22:50	1.66
+++ type_util.m	1999/06/23 21:40:20
@@ -270,6 +270,7 @@
 
 type_util__var(term__variable(Var), Var).
 
+type_id_is_hand_defined(qualified(unqualified("builtin"), "c_pointer") - 0).
 type_id_is_hand_defined(qualified(unqualified("std_util"), "univ") - 0).
 type_id_is_hand_defined(qualified(unqualified("array"), "array") - 1).
 type_id_is_hand_defined(qualified(PrivateBuiltin, "type_info") - 1) :-
Index: library/builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/builtin.m,v
retrieving revision 1.15
diff -u -r1.15 builtin.m
--- builtin.m	1999/06/01 09:45:44	1.15
+++ builtin.m	1999/06/23 23:35:44
@@ -929,8 +929,6 @@
  * be handled as a special case.
  */
 
-#ifdef  USE_TYPE_LAYOUT
-
 MR_MODULE_STATIC_OR_EXTERN
 const struct mercury_data_builtin__type_ctor_layout_c_pointer_0_struct {
 	TYPE_LAYOUT_FIELDS
@@ -947,8 +945,6 @@
 	MR_TYPE_CTOR_FUNCTORS_SPECIAL
 };
 
-#endif
-
 Define_extern_entry(mercury____Unify___builtin__c_pointer_0_0);
 Define_extern_entry(mercury____Index___builtin__c_pointer_0_0);
 Define_extern_entry(mercury____Compare___builtin__c_pointer_0_0);
@@ -986,6 +982,8 @@
 /*
 INIT sys_init_unify_c_pointer_module
 */
+
+
 extern ModuleFunc unify_c_pointer_module;
 void sys_init_unify_c_pointer_module(void);
 	/* duplicate declaration to suppress gcc -Wmissing-decl warning */
Index: runtime/mercury_bootstrap.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_bootstrap.c,v
retrieving revision 1.11
diff -u -r1.11 mercury_bootstrap.c
--- mercury_bootstrap.c	1999/06/02 10:05:08	1.11
+++ mercury_bootstrap.c	1999/06/23 23:35:14
@@ -21,4 +21,81 @@
 
 #include "mercury_imp.h"
 
+MR_MODULE_STATIC_OR_EXTERN
+const struct mercury_data_builtin__type_ctor_layout_c_pointer_0_struct_bootstrap {
+	TYPE_LAYOUT_FIELDS
+} mercury_data_builtin__type_ctor_layout_c_pointer_0_bootstrap = {
+	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
+		mkbody(MR_TYPE_CTOR_LAYOUT_C_POINTER_VALUE))
+};
 
+MR_MODULE_STATIC_OR_EXTERN
+const struct mercury_data_builtin__type_ctor_functors_c_pointer_0_struct_bootstrap {
+	Integer f1;
+} mercury_data_builtin__type_ctor_functors_c_pointer_0_bootstrap = {
+	MR_TYPE_CTOR_FUNCTORS_SPECIAL
+};
+
+Declare_entry(mercury____Unify___builtin__c_pointer_0_0_bootstrap);
+Declare_entry(mercury____Index___builtin__c_pointer_0_0_bootstrap);
+Declare_entry(mercury____Compare___builtin__c_pointer_0_0_bootstrap);
+
+const struct mercury_data_builtin__type_ctor_info_c_pointer_0_struct {
+	Integer f1;
+	Code * f2;
+	Code * f3;
+	Code * f4;
+	Integer f5;
+	Word * f6;
+	Word * f7;
+	Word * f8;
+	Word * f9;
+}  mercury_data_builtin__type_ctor_info_c_pointer_0 = {
+	(Integer) 0,
+	ENTRY(mercury____Unify___builtin__c_pointer_0_0_bootstrap),
+	ENTRY(mercury____Index___builtin__c_pointer_0_0_bootstrap),
+	ENTRY(mercury____Compare___builtin__c_pointer_0_0_bootstrap),
+	MR_TYPE_CTOR_REP_C_POINTER,
+	(Word *) &mercury_data_builtin__type_ctor_functors_c_pointer_0_bootstrap,
+	(Word *) &mercury_data_builtin__type_ctor_layout_c_pointer_0_bootstrap,
+	string_const("builtin", 7),
+	string_const("c_pointer", 9)
+};
+
+Define_extern_entry(mercury____Unify___builtin__c_pointer_0_0_bootstrap);
+Define_extern_entry(mercury____Index___builtin__c_pointer_0_0_bootstrap);
+Define_extern_entry(mercury____Compare___builtin__c_pointer_0_0_bootstrap);
+
+BEGIN_MODULE(unify_c_pointer_module_bootstrap)
+	init_entry(mercury____Unify___builtin__c_pointer_0_0_bootstrap);
+	init_entry(mercury____Index___builtin__c_pointer_0_0_bootstrap);
+	init_entry(mercury____Compare___builtin__c_pointer_0_0_bootstrap);
+
+BEGIN_CODE
+Define_entry(mercury____Unify___builtin__c_pointer_0_0_bootstrap);
+	/*
+	** For c_pointer, we assume that equality and comparison
+	** can be based on object identity (i.e. using address comparisons).
+	** This is correct for types like io__stream, and necessary since
+	** the io__state contains a map(io__stream, filename).
+	** However, it might not be correct in general...
+	*/
+	r1 = (r1 == r2);
+	proceed();
+
+Define_entry(mercury____Index___builtin__c_pointer_0_0_bootstrap);
+	r1 = -1;
+	proceed();
+
+Define_entry(mercury____Compare___builtin__c_pointer_0_0_bootstrap);
+	r1 = (r1 == r2 ? COMPARE_EQUAL :
+			  r1 < r2 ? COMPARE_LESS :
+			  COMPARE_GREATER);
+	proceed();
+
+END_MODULE
+
+/* Ensure that the initialization code for the above module gets run. */
+/*
+INIT sys_init_unify_c_pointer_module
+*/


-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't eveyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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