[m-dev.] diff: array runtime and library dependency problem

Peter Ross peter.ross at miscrit.be
Tue Feb 6 22:33:25 AEDT 2001


Hi,

I forgot to check this diff onto the version_0_10_x branch, and I had to
resolve some conflicts when porting across from the main branch.  So I
thought I better post it again.

This is currently bootchecking, and if it passes I will check it in.

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


Estimated hours taken: 5

Avoid a dependency where the runtime depends on the library.

library/array.m:
runtime/mercury.c:
runtime/mercury.h:
runtime/mercury_type_info.h:
    Move code for doing array comparisons and unifications into the std
    library.


Index: library/array.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/array.m,v
retrieving revision 1.80.2.2
diff -u -r1.80.2.2 array.m
--- library/array.m	2001/02/06 08:46:03	1.80.2.2
+++ library/array.m	2001/02/06 11:09:42
@@ -334,10 +334,27 @@
 
 %-----------------------------------------------------------------------------%
 
+:- pragma foreign_decl("C", "
+#ifdef MR_HIGHLEVEL_CODE
+  #include ""mercury_goto.h""	/* for MR_init_entry */
+
+  bool MR_CALL mercury__array__do_unify__array_1_0(
+  	MR_Mercury_Type_Info type_info, MR_Box x, MR_Box y);
+  bool MR_CALL mercury__array____Unify____array_1_0(
+	MR_Mercury_Type_Info type_info, MR_Array x, MR_Array y);
+  void MR_CALL mercury__array__do_compare__array_1_0(MR_Mercury_Type_Info
+ 	 type_info, MR_Comparison_Result *result, MR_Box x, MR_Box y);
+  void MR_CALL mercury__array____Compare____array_1_0(MR_Mercury_Type_Info
+	type_info, MR_Comparison_Result *result, MR_Array x, MR_Array y);
+#endif
+").
+
 :- pragma foreign_code("C", "
 
 #ifdef MR_HIGHLEVEL_CODE
 
+MR_define_type_ctor_info(array, array, 1, MR_TYPECTOR_REP_ARRAY);
+
 /* forward decl, to suppress gcc -Wmissing-decl warning */
 void sys_init_array_module_builtins(void);
 
@@ -352,10 +369,27 @@
 }
 
 bool MR_CALL
+mercury__array__do_unify__array_1_0(MR_Mercury_Type_Info type_info,
+	MR_Box x, MR_Box y)
+{
+	return mercury__array____Unify____array_1_0(
+		type_info, (MR_Array) x, (MR_Array) y);
+}
+
+bool MR_CALL
 mercury__array____Unify____array_1_0(MR_Mercury_Type_Info type_info,
 	MR_Array x, MR_Array y)
 {
 	return mercury__array__array_equal_2_p_0(type_info, x, y);
+}
+
+void MR_CALL
+mercury__array__do_compare__array_1_0(
+	MR_Mercury_Type_Info type_info, MR_Comparison_Result *result,
+	MR_Box x, MR_Box y)
+{
+	mercury__array____Compare____array_1_0(
+		type_info, result, (MR_Array) x, (MR_Array) y);
 }
 
 void MR_CALL
Index: runtime/mercury.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury.c,v
retrieving revision 1.18.2.1
diff -u -r1.18.2.1 mercury.c
--- runtime/mercury.c	2001/02/06 08:46:13	1.18.2.1
+++ runtime/mercury.c	2001/02/06 11:09:42
@@ -86,7 +86,6 @@
 	mercury__std_util__do_unify__type_desc_0_0;
 
 static MR_UnifyFunc_1
-	mercury__array__do_unify__array_1_0,
 	mercury__builtin__do_unify__tuple_0_0,
 	mercury__private_builtin__do_unify__type_ctor_info_1_0,
 	mercury__private_builtin__do_unify__type_info_1_0,
@@ -106,7 +105,6 @@
 	mercury__std_util__do_compare__type_desc_0_0;
 
 static MR_CompareFunc_1
-	mercury__array__do_compare__array_1_0,
 	mercury__builtin__do_compare__tuple_0_0,
 	mercury__private_builtin__do_compare__type_ctor_info_1_0,
 	mercury__private_builtin__do_compare__type_info_1_0,
@@ -122,53 +120,6 @@
 ** Define MR_TypeCtorInfos for the builtin types
 */
 
-#define MR_type_ctor_info_name(MODULE, TYPE, ARITY)			      \
-	MR_PASTE2(mercury__,						      \
-	MR_PASTE2(MODULE,						      \
-	MR_PASTE2(__,							      \
-	MR_PASTE2(MODULE,						      \
-	MR_PASTE2(__type_ctor_info_,					      \
-	MR_PASTE2(TYPE,							      \
-	MR_PASTE2(_,							      \
-	          ARITY)))))))
-
-#define MR_type_ctor_info_func_name(MODULE, TYPE, ARITY, FUNC)		      \
-	MR_PASTE2(mercury__,						      \
-	MR_PASTE2(MODULE,						      \
-	MR_PASTE2(__,							      \
-	MR_PASTE2(FUNC,							      \
-	MR_PASTE2(__,							      \
-	MR_PASTE2(TYPE,							      \
-	MR_PASTE2(_,							      \
-	MR_PASTE2(ARITY,						      \
-	          _0))))))))
-
-#define MR_special_func_type(NAME, ARITY) \
-	MR_PASTE2(MR_, MR_PASTE2(NAME, MR_PASTE2(Func_, ARITY)))
-
-#define MR_define_type_ctor_info(module, type, arity, type_rep)		      \
-	const struct MR_TypeCtorInfo_Struct				      \
-		MR_type_ctor_info_name(module, type, arity) =		      \
-	{								      \
-		arity,							      \
-		(MR_Box) MR_type_ctor_info_func_name(module, type, arity,     \
-				do_unify),				      \
-		(MR_Box) MR_type_ctor_info_func_name(module, type, arity,     \
-				do_unify),				      \
-		(MR_Box) MR_type_ctor_info_func_name(module, type, arity,     \
-				do_compare),				      \
-		type_rep,						      \
-		NULL,							      \
-		NULL,							      \
-		MR_STRINGIFY(module),					      \
-		MR_STRINGIFY(type),					      \
-		MR_RTTI_VERSION,					      \
-		{ 0 },							      \
-		{ 0 },							      \
-		-1,							      \
-		-1							      \
-	}
-
 MR_define_type_ctor_info(builtin, int, 0, MR_TYPECTOR_REP_INT);
 MR_define_type_ctor_info(builtin, string, 0, MR_TYPECTOR_REP_STRING);
 MR_define_type_ctor_info(builtin, float, 0, MR_TYPECTOR_REP_FLOAT);
@@ -178,8 +129,6 @@
 MR_define_type_ctor_info(builtin, pred, 0, MR_TYPECTOR_REP_PRED);
 MR_define_type_ctor_info(builtin, func, 0, MR_TYPECTOR_REP_PRED);
 MR_define_type_ctor_info(builtin, tuple, 0, MR_TYPECTOR_REP_TUPLE);
-MR_define_type_ctor_info(array, array, 1, MR_TYPECTOR_REP_ARRAY);
-MR_define_type_ctor_info(std_util, univ, 0, MR_TYPECTOR_REP_UNIV);
 MR_define_type_ctor_info(std_util, type_desc, 0, MR_TYPECTOR_REP_TYPEINFO);
 MR_define_type_ctor_info(private_builtin, type_ctor_info, 1,
 	MR_TYPECTOR_REP_TYPEINFO);
@@ -742,21 +691,6 @@
 }
 
 static bool MR_CALL
-mercury__array__do_unify__array_1_0(MR_Mercury_Type_Info type_info,
-	MR_Box x, MR_Box y)
-{
-	return mercury__array____Unify____array_1_0(
-		type_info, (MR_Array) x, (MR_Array) y);
-}
-
-static bool MR_CALL
-mercury__std_util__do_unify__univ_0_0(MR_Box x, MR_Box y)
-{
-	return mercury__std_util____Unify____univ_0_0(
-		(MR_Univ) x, (MR_Univ) y);
-}
-
-static bool MR_CALL
 mercury__std_util__do_unify__type_desc_0_0(MR_Box x, MR_Box y)
 {
 	return mercury__std_util____Unify____type_desc_0_0(
@@ -871,23 +805,6 @@
 {
 	mercury__builtin____Compare____tuple_0_0(
 		type_info, result, (MR_Tuple) x, (MR_Tuple) y);
-}
-
-static void MR_CALL
-mercury__array__do_compare__array_1_0(
-	MR_Mercury_Type_Info type_info, MR_Comparison_Result *result,
-	MR_Box x, MR_Box y)
-{
-	mercury__array____Compare____array_1_0(
-		type_info, result, (MR_Array) x, (MR_Array) y);
-}
-
-static void MR_CALL
-mercury__std_util__do_compare__univ_0_0(
-	MR_Comparison_Result *result, MR_Box x, MR_Box y)
-{
-	mercury__std_util____Compare____univ_0_0(
-		result, (MR_Univ) x, (MR_Univ) y);
 }
 
 static void MR_CALL
Index: runtime/mercury.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury.h,v
retrieving revision 1.29
diff -u -r1.29 mercury.h
--- runtime/mercury.h	2000/12/14 16:43:24	1.29
+++ runtime/mercury.h	2001/02/06 11:09:42
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 The University of Melbourne.
+** Copyright (C) 1999-2001 The University of Melbourne.
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
@@ -378,8 +378,6 @@
 bool MR_CALL mercury__builtin____Unify____pred_0_0(MR_Pred x, MR_Pred y); 
 bool MR_CALL mercury__builtin____Unify____tuple_0_0(
 	MR_Mercury_Type_Info type_info, MR_Tuple x, MR_Tuple y); 
-bool MR_CALL mercury__array____Unify____array_1_0(
-	MR_Mercury_Type_Info type_info, MR_Array x, MR_Array y);
 bool MR_CALL mercury__std_util____Unify____univ_0_0(MR_Univ x, MR_Univ y); 
 bool MR_CALL mercury__std_util____Unify____type_desc_0_0(
 	MR_Type_Desc x, MR_Type_Desc y); 
@@ -415,8 +413,6 @@
 void MR_CALL mercury__builtin____Compare____tuple_0_0(
 	MR_Mercury_Type_Info type_info, MR_Comparison_Result *result,
 	MR_Tuple x, MR_Tuple y); 
-void MR_CALL mercury__array____Compare____array_1_0(MR_Mercury_Type_Info
-	type_info, MR_Comparison_Result *result, MR_Array x, MR_Array y);
 void MR_CALL mercury__std_util____Compare____univ_0_0(
 	MR_Comparison_Result *result, MR_Univ x, MR_Univ y);
 void MR_CALL mercury__std_util____Compare____type_desc_0_0(
Index: runtime/mercury_type_info.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_type_info.h,v
retrieving revision 1.61
diff -u -r1.61 mercury_type_info.h
--- runtime/mercury_type_info.h	2000/12/18 07:42:58	1.61
+++ runtime/mercury_type_info.h	2001/02/06 11:09:43
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1995-2000 The University of Melbourne.
+** Copyright (C) 1995-2001 The University of Melbourne.
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
@@ -280,6 +280,61 @@
 
 #define MR_fill_in_tuple_type_info(arena, type_ctor_info, arity, vector) \
     MR_fill_in_higher_order_type_info(arena, type_ctor_info, arity, vector)
+
+/*
+** Used to define MR_TypeCtorInfos for the builtin types in the hlc grades.
+** This needs to be exported for use by the array type in the library.
+*/
+#ifdef MR_HIGHLEVEL_CODE
+
+#define MR_type_ctor_info_name(MODULE, TYPE, ARITY)			      \
+	MR_PASTE2(mercury__,						      \
+	MR_PASTE2(MODULE,						      \
+	MR_PASTE2(__,							      \
+	MR_PASTE2(MODULE,						      \
+	MR_PASTE2(__type_ctor_info_,					      \
+	MR_PASTE2(TYPE,							      \
+	MR_PASTE2(_,							      \
+	          ARITY)))))))
+
+#define MR_type_ctor_info_func_name(MODULE, TYPE, ARITY, FUNC)		      \
+	MR_PASTE2(mercury__,						      \
+	MR_PASTE2(MODULE,						      \
+	MR_PASTE2(__,							      \
+	MR_PASTE2(FUNC,							      \
+	MR_PASTE2(__,							      \
+	MR_PASTE2(TYPE,							      \
+	MR_PASTE2(_,							      \
+	MR_PASTE2(ARITY,						      \
+	          _0))))))))
+
+#define MR_special_func_type(NAME, ARITY) \
+	MR_PASTE2(MR_, MR_PASTE2(NAME, MR_PASTE2(Func_, ARITY)))
+
+#define MR_define_type_ctor_info(module, type, arity, type_rep)		      \
+	const struct MR_TypeCtorInfo_Struct				      \
+		MR_type_ctor_info_name(module, type, arity) =		      \
+	{								      \
+		arity,							      \
+		(MR_Box) MR_type_ctor_info_func_name(module, type, arity,     \
+				do_unify),				      \
+		(MR_Box) MR_type_ctor_info_func_name(module, type, arity,     \
+				do_unify),				      \
+		(MR_Box) MR_type_ctor_info_func_name(module, type, arity,     \
+				do_compare),				      \
+		type_rep,						      \
+		NULL,							      \
+		NULL,							      \
+		MR_STRINGIFY(module),					      \
+		MR_STRINGIFY(type),					      \
+		MR_RTTI_VERSION,					      \
+		{ 0 },							      \
+		{ 0 },							      \
+		-1,							      \
+		-1							      \
+	}
+
+#endif /* MR_HIGHLEVEL_CODE */
 
 /*---------------------------------------------------------------------------*/
 

--------------------------------------------------------------------------
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