[m-dev.] for review: add MR_ to Word, Integer, String, etc...
Tyson Dowd
trd at cs.mu.OZ.AU
Wed Aug 2 17:45:40 AEST 2000
On 01-Aug-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
>
> > But I think the reference manual should be changed.
>
> I agree. It should be part of this change.
Done.
I've added this to the log message:
doc/reference_manual.texi:
Update the reference manual to talk about MR_Word, MR_String,
MR_Char, etc.
And the change is:
Index: doc/reference_manual.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/reference_manual.texi,v
retrieving revision 1.183
diff -u -r1.183 reference_manual.texi
--- doc/reference_manual.texi 2000/06/01 08:47:35 1.183
+++ doc/reference_manual.texi 2000/08/02 07:41:05
@@ -4335,7 +4335,7 @@
C function. For output arguments, the Mercury implementation will pass
to the C function an address in which to store the result.
If the Mercury procedure can fail, then its C function should return a
-truth value of type @samp{Integer} indicating success or failure:
+truth value of type @samp{MR_Integer} indicating success or failure:
non-zero indicates success, and zero indicates failure.
If the Mercury procedure is a Mercury function that cannot fail, and
the function result has an output mode, then the C function should
@@ -4838,19 +4838,20 @@
For each of the Mercury types @code{int}, @code{float}, @code{char},
and @code{string}, there is a C typedef for the corresponding type in C:
- at code{Integer}, @code{Float}, @code{Char}, and @code{String} respectively.
+ at code{MR_Integer}, @code{MR_Float}, @code{MR_Char},
+and @code{MR_String} respectively.
-In the current implementation, @samp{Integer} is a typedef for an
-integral type whose size is the same size as a pointer; @samp{Float} is
+In the current implementation, @samp{MR_Integer} is a typedef for an
+integral type whose size is the same size as a pointer; @samp{MR_Float} is
a typedef for @samp{double} (unless the program and the Mercury library
was compiled with @samp{-DUSE_SINGLE_PREC_FLOAT}, in which case it is
-a typedef for @samp{float}); @samp{Char} is a typedef for @samp{char};
-and @samp{String} is a typedef for @samp{Char *}.
+a typedef for @samp{float}); @samp{MR_Char} is a typedef for @samp{char};
+and @samp{MR_String} is a typedef for @samp{MR_Char *}.
Mercury variables of type @code{int}, @code{float}, @code{char}, or
@code{string} are passed to and from C as C variables whose type is
given by the corresponding typedef. Mercury variables of any other
-type are passed as a @samp{Word}, which in the current implementation
+type are passed as a @samp{MR_Word}, which in the current implementation
is a typedef for an unsigned type whose size is the same size as a pointer.
(Note: it would in fact be better for each Mercury type to map to a distinct
abstract type in C, since that would be more type-safe, and thus we may
@@ -5019,7 +5020,7 @@
@item @bullet{} @code{MR_trail_value()}
Prototype:
@example
-void MR_trail_value(Word *@var{address}, Word @var{value});
+void MR_trail_value(MR_Word *@var{address}, MR_Word @var{value});
@end example
Ensures that if future execution backtracks to the
@@ -5028,7 +5029,7 @@
@item @bullet{} @code{MR_trail_current_value()}
Prototype:
@example
-void MR_trail_current_value(Word *@var{address});
+void MR_trail_current_value(MR_Word *@var{address});
@end example
Ensures that if future execution backtracks to the
@@ -5068,7 +5069,7 @@
@} MR_untrail_reason;
void MR_trail_function(
- void (*@var{untrail_func})(Word, MR_untrail_reason),
+ void (*@var{untrail_func})(MR_Word, MR_untrail_reason),
void *@var{value}
);
@end example
@@ -5269,20 +5270,20 @@
"update_int_ref").
:- pragma c_header_code("
-typedef Word Mercury_IntRef;
-void new_int_ref(Mercury_IntRef *ref, Integer value);
+typedef MR_Word Mercury_IntRef;
+void new_int_ref(Mercury_IntRef *ref, MR_Integer value);
void update_int_ref(Mercury_IntRef ref0, Mercury_IntRef *ref,
- Integer *old_value, Integer new_value);
+ MR_Integer *old_value, MR_Integer new_value);
").
:- pragma c_code("
typedef struct @{
MR_ChoicepointId prev_choicepoint;
- Integer data;
+ MR_Integer data;
@} C_IntRef;
void
-new_int_ref(Mercury_IntRef *ref, Integer value)
+new_int_ref(Mercury_IntRef *ref, MR_Integer value)
@{
C_IntRef *x = malloc(sizeof(C_IntRef));
x->prev_choicepoint = MR_current_choicepoint_id();
@@ -5292,7 +5293,7 @@
void
update_int_ref(Mercury_IntRef ref0, Mercury_IntRef *ref,
- Integer *old_value, Integer new_value)
+ MR_Integer *old_value, MR_Integer new_value)
@{
C_IntRef *x = (C_IntRef *) ref0;
*old_value = x->data;
@@ -5303,10 +5304,10 @@
@{
/* trail both x->data and x->prev_choicepoint,
since we're about to update them both*/
- assert(sizeof(x->data) == sizeof(Word));
- assert(sizeof(x->prev_choicepoint) == sizeof(Word));
- MR_trail_current_value((Word *)&x->data);
- MR_trail_current_value((Word *)&x->prev_choicepoint);
+ assert(sizeof(x->data) == sizeof(MR_Word));
+ assert(sizeof(x->prev_choicepoint) == sizeof(MR_Word));
+ MR_trail_current_value((MR_Word *)&x->data);
+ MR_trail_current_value((MR_Word *)&x->prev_choicepoint);
/* update x->prev_choicepoint to indicate that
x->data's previous value has been trailed
@@ -5576,7 +5577,7 @@
@example
:- pragma c_header_code("#include <limits.h>").
-:- pragma c_header_code("Integer max;").
+:- pragma c_header_code("MR_Integer max;").
:- impure pred init_max is det.
:- pragma c_code(init_max,
--
Tyson Dowd #
# Surreal humour isn't everyone'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