[m-dev.] diff: MLDS back-end: more std library changes
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Mar 10 11:37:26 AEDT 2000
Estimated hours taken: 4
Some modifications to the standard library code to
get it to compile with `--high-level-code'.
(For a couple of files, namely std_util.m and
store.m, `-O0' is also needed.)
library/array.m:
library/benchmarking.m:
library/io.m:
library/private_builtin.m:
library/std_util.m:
library/store.m:
Add `#include' declarations that are needed when compiling
with --high-level-code.
Wrap `#ifndef MR_HIGHLEVEL_CODE' around definitions
of low-level C code that doesn't compile with --high-level-code.
library/exception.m:
library/std_util.m:
Add multiple inclusion guards to all the typedefs defined
inside `pragma c_header_code'.
This is necessary since each `pragma c_header_code' fragment
can be included in several automatically-generated header
files which all get included by a single C file.
library/builtin.m:
Implement copy/2 for --high-level-code.
Workspace: /d-drive/home/hg/fjh/mercury
Index: library/array.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/array.m,v
retrieving revision 1.67
diff -u -d -r1.67 array.m
--- library/array.m 2000/01/19 09:45:16 1.67
+++ library/array.m 2000/03/10 00:31:47
@@ -271,6 +271,8 @@
:- pragma c_code("
+#ifndef MR_HIGHLEVEL_CODE
+
MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(array, array, 1, MR_TYPECTOR_REP_ARRAY);
Declare_entry(mercury__array__array_equal_2_0);
@@ -314,6 +316,8 @@
array__array_1_0);
}
+#endif /* ! MR_HIGHLEVEL_CODE */
+
").
%-----------------------------------------------------------------------------%
@@ -371,6 +375,11 @@
).
%-----------------------------------------------------------------------------%
+
+:- pragma c_header_code("
+#include ""mercury_library_types.h"" /* for MR_ArrayType */
+#include ""mercury_misc.h"" /* for fatal_error() */
+").
:- pragma c_header_code("
MR_ArrayType *ML_make_array(Integer size, Word item);
Index: library/benchmarking.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/benchmarking.m,v
retrieving revision 1.31
diff -u -d -r1.31 benchmarking.m
--- library/benchmarking.m 1999/12/30 14:45:56 1.31
+++ library/benchmarking.m 2000/03/09 12:29:14
@@ -60,6 +60,7 @@
:- pragma c_header_code("
#include ""mercury_timing.h""
+#include ""mercury_heap.h""
extern void ML_report_stats(void);
Index: library/builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/builtin.m,v
retrieving revision 1.27
diff -u -d -r1.27 builtin.m
--- library/builtin.m 2000/01/19 09:45:17 1.27
+++ library/builtin.m 2000/03/09 12:46:16
@@ -400,6 +400,23 @@
:- pragma c_header_code("#include ""mercury_deep_copy.h""").
:- pragma c_code("
+
+#ifdef MR_HIGHLEVEL_CODE
+
+void
+mercury__builtin__copy_2_p_0(Word type_info, MR_Box value, MR_Box * copy)
+{
+ *copy = deep_copy(&value, (Word *) type_info, NULL, NULL);
+}
+
+void
+mercury__builtin__copy_2_p_1(Word type_info, MR_Box x, MR_Box * y)
+{
+ mercury__builtin__copy_2_p_0(type_info, x, y);
+}
+
+#else /* ! MR_HIGHLEVEL_CODE */
+
Define_extern_entry(mercury__copy_2_0);
Define_extern_entry(mercury__copy_2_1);
@@ -444,6 +461,7 @@
copy_module();
}
+#endif /* ! MR_HIGHLEVEL_CODE */
").
%-----------------------------------------------------------------------------%
@@ -452,6 +470,8 @@
:- pragma c_code("
+#ifndef MR_HIGHLEVEL_CODE
+
MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_PRED(builtin, c_pointer, 0,
MR_TYPECTOR_REP_C_POINTER,
mercury____Unify___builtin__c_pointer_0_0,
@@ -502,6 +522,8 @@
mercury_data_builtin__type_ctor_info_c_pointer_0,
builtin__c_pointer_0_0);
}
+
+#endif /* ! MR_HIGHLEVEL_CODE */
").
Index: library/exception.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/exception.m,v
retrieving revision 1.14
diff -u -d -r1.14 exception.m
--- library/exception.m 2000/03/09 11:52:14 1.14
+++ library/exception.m 2000/03/10 00:33:00
@@ -207,9 +207,15 @@
% the C interface, since Mercury doesn't allow different code for different
% modes.
-% The enumeration constants in this enum must be in the same order as the
-% functors in the Mercury type `determinism' defined above.
:- pragma c_header_code("
+/* The `#ifndef ... #define ... #endif' guards against multiple inclusion */
+#ifndef ML_DETERMINISM_GUARD
+#define ML_DETERMINISM_GUARD
+ /*
+ ** The enumeration constants in this enum must be in the same
+ ** order as the functors in the Mercury type `determinism'
+ ** defined above.
+ */
typedef enum {
ML_DET,
ML_SEMIDET,
@@ -220,6 +226,7 @@
ML_ERRONEOUS,
ML_FAILURE
} ML_Determinism;
+#endif
").
:- pragma c_code(
Index: library/io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.194
diff -u -d -r1.194 io.m
--- library/io.m 2000/02/04 02:12:09 1.194
+++ library/io.m 2000/03/09 11:57:38
@@ -2647,6 +2647,9 @@
#include ""mercury_init.h""
#include ""mercury_wrapper.h""
#include ""mercury_type_info.h""
+#include ""mercury_library_types.h""
+#include ""mercury_heap.h""
+#include ""mercury_misc.h""
#include <stdio.h>
#include <stdlib.h>
Index: library/private_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/private_builtin.m,v
retrieving revision 1.39
diff -u -d -r1.39 private_builtin.m
--- library/private_builtin.m 2000/01/19 09:45:17 1.39
+++ library/private_builtin.m 2000/03/09 12:39:02
@@ -280,6 +280,8 @@
:- pragma c_code("
+#ifndef MR_HIGHLEVEL_CODE
+
/*
** For most purposes, type_ctor_info can be treated just like
** type_info. The code that handles type_infos can also handle
@@ -384,6 +386,8 @@
private_builtin__typeclass_info_1_0);
}
+#endif /* ! MR_HIGHLEVEL_CODE */
+
").
:- pragma c_code(type_info_from_typeclass_info(TypeClassInfo::in, Index::in,
@@ -832,7 +836,7 @@
table->MR_subgoal = subgoal;
}
T = T0;
-#endif
+#endif /* MR_USE_MINIMAL_MODEL */
").
% The definitions of these two predicates are in the runtime system,
@@ -1103,6 +1107,8 @@
:- implementation.
:- pragma c_header_code("
+
+#include ""mercury_misc.h"" /* for fatal_error(); */
extern MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
mercury_data___type_ctor_info_int_0;
Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.178
diff -u -d -r1.178 std_util.m
--- library/std_util.m 2000/01/19 09:45:18 1.178
+++ library/std_util.m 2000/03/09 13:35:24
@@ -931,6 +931,9 @@
*/
#include ""mercury_type_info.h""
+#include ""mercury_heap.h"" /* for incr_hp_msg() etc. */
+#include ""mercury_misc.h"" /* for fatal_error() */
+#include ""mercury_string.h"" /* for MR_make_aligned_string() */
").
@@ -984,6 +987,8 @@
:- pragma c_code("
+#ifndef MR_HIGHLEVEL_CODE
+
MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(std_util, type_info, 0,
MR_TYPECTOR_REP_C_POINTER);
MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(std_util, univ, 0,
@@ -1154,6 +1159,8 @@
std_util__type_info_0_0);
}
+#endif /* ! MR_HIGHLEVEL_CODE */
+
").
%-----------------------------------------------------------------------------%
@@ -1164,6 +1171,9 @@
:- pragma c_header_code("
+/* The `#ifndef ... #define ... #endif' guards against multiple inclusion */
+#ifndef ML_CONSTRUCT_INFO_GUARD
+#define ML_CONSTRUCT_INFO_GUARD
typedef struct ML_Construct_Info_Struct {
int vector_type;
int arity;
@@ -1173,6 +1183,7 @@
Word secondary_tag;
ConstString functor_name;
} ML_Construct_Info;
+#endif
int ML_get_num_functors(Word type_info);
Word ML_copy_argument_typeinfos(int arity, Word type_info,
@@ -2024,6 +2035,9 @@
* (that is, they should not be relied on to remain unchanged).
*/
+/* The `#ifndef ... #define ... #endif' guards against multiple inclusion */
+#ifndef ML_EXPAND_INFO_GUARD
+#define ML_EXPAND_INFO_GUARD
typedef struct ML_Expand_Info_Struct {
ConstString functor;
int arity;
@@ -2034,6 +2048,7 @@
bool need_functor;
bool need_args;
} ML_Expand_Info;
+#endif
/* Prototypes */
Index: library/store.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/store.m,v
retrieving revision 1.18
diff -u -d -r1.18 store.m
--- library/store.m 1999/12/15 17:21:56 1.18
+++ library/store.m 2000/03/09 12:00:40
@@ -304,6 +304,8 @@
:- pragma c_header_code("
#include ""mercury_type_info.h""
+ #include ""mercury_heap.h""
+ #include ""mercury_misc.h"" /* for fatal_error() */
/* ML_arg() is defined in std_util.m */
bool ML_arg(Word term_type_info, Word *term, Word argument_index,
--
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.
--------------------------------------------------------------------------
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