[m-rev.] diff: avoid using TRUE and FALSE to initialise Mercury bools
Mark Brown
dougl at cs.mu.OZ.AU
Wed May 30 03:20:37 AEST 2001
Estimated hours taken: 0.5
Branches: main
trace/mercury_trace_browse.c:
trace/mercury_trace_browse.h:
trace/mercury_trace_internal.c:
Set the pretty printing flags (which represent Mercury bools) using
functions exported from Mercury code, rather than using TRUE and
FALSE. This removes the assumption that Mercury bools have the
same representation as C bools, which was causing a problem when
--reserve-tag was used.
Change the type of these flags to MR_Word. According to the
reference manual, this is the type Mercury bools have when passed
to C code.
browser/browser_info.m:
Export functions that construct Mercury bools.
Index: browser/browser_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/browser_info.m,v
retrieving revision 1.3
diff -u -r1.3 browser_info.m
--- browser/browser_info.m 2001/04/23 16:26:26 1.3
+++ browser/browser_info.m 2001/05/29 13:31:13
@@ -183,6 +183,19 @@
%
browser_info__set_param(P, B, A, no, no, no, no, format(Format)).
+ %
+ % The following exported functions allow C code to create
+ % Mercury values of type bool.
+ %
+
+:- func mercury_bool_yes = bool.
+:- pragma export(mercury_bool_yes = out, "ML_BROWSE_mercury_bool_yes").
+mercury_bool_yes = yes.
+
+:- func mercury_bool_no = bool.
+:- pragma export(mercury_bool_no = out, "ML_BROWSE_mercury_bool_no").
+mercury_bool_no = no.
+
%---------------------------------------------------------------------------%
browser_info__init(Term, MaybeFormat, State, Info) :-
Index: trace/mercury_trace_browse.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_browse.c,v
retrieving revision 1.20
diff -u -r1.20 mercury_trace_browse.c
--- trace/mercury_trace_browse.c 2001/04/23 16:26:38 1.20
+++ trace/mercury_trace_browse.c 2001/05/29 16:40:55
@@ -142,9 +142,9 @@
}
bool
-MR_trace_set_browser_param(MR_Bool print, MR_Bool browse, MR_Bool print_all,
- MR_Bool flat, MR_Bool raw_pretty, MR_Bool verbose,
- MR_Bool pretty, const char *param, const char *value)
+MR_trace_set_browser_param(MR_Word print, MR_Word browse, MR_Word print_all,
+ MR_Word flat, MR_Word raw_pretty, MR_Word verbose,
+ MR_Word pretty, const char *param, const char *value)
{
int depth, size, width, lines;
MR_Browse_Format new_format;
Index: trace/mercury_trace_browse.h
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_browse.h,v
retrieving revision 1.11
diff -u -r1.11 mercury_trace_browse.h
--- trace/mercury_trace_browse.h 2001/02/23 04:15:24 1.11
+++ trace/mercury_trace_browse.h 2001/05/29 16:40:28
@@ -59,9 +59,9 @@
/*
** Set browser parameters.
*/
-extern bool MR_trace_set_browser_param(MR_Bool print, MR_Bool browse,
- MR_Bool print_all, MR_Bool flat, MR_Bool raw_pretty,
- MR_Bool verbose, MR_Bool pretty, const char *param,
+extern bool MR_trace_set_browser_param(MR_Word print, MR_Word browse,
+ MR_Word print_all, MR_Word flat, MR_Word raw_pretty,
+ MR_Word verbose, MR_Word pretty, const char *param,
const char *value);
/*
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.103
diff -u -r1.103 mercury_trace_internal.c
--- trace/mercury_trace_internal.c 2001/05/07 02:57:09 1.103
+++ trace/mercury_trace_internal.c 2001/05/29 13:37:05
@@ -28,6 +28,7 @@
#include "mercury_trace_readline.h"
#include "mdb.browse.h"
+#include "mdb.browser_info.h"
#include "mdb.program_representation.h"
#include <stdio.h>
@@ -176,10 +177,10 @@
static bool MR_trace_options_format(MR_Browse_Format *format,
char ***words, int *word_count, const char *cat,
const char *item);
-static bool MR_trace_options_param_set(MR_Bool *print_set,
- MR_Bool *browse_set, MR_Bool *print_all_set,
- MR_Bool *flat_format, MR_Bool *raw_pretty_format,
- MR_Bool *verbose_format, MR_Bool *pretty_format,
+static bool MR_trace_options_param_set(MR_Word *print_set,
+ MR_Word *browse_set, MR_Word *print_all_set,
+ MR_Word *flat_format, MR_Word *raw_pretty_format,
+ MR_Word *verbose_format, MR_Word *pretty_format,
char ***words, int *word_count, const char *cat,
const char *item);
static void MR_trace_usage(const char *cat, const char *item);
@@ -1087,13 +1088,13 @@
}
} else if (streq(words[0], "set")) {
MR_Browse_Format format;
- MR_Bool print_set;
- MR_Bool browse_set;
- MR_Bool print_all_set;
- MR_Bool flat_format;
- MR_Bool raw_pretty_format;
- MR_Bool verbose_format;
- MR_Bool pretty_format;
+ MR_Word print_set;
+ MR_Word browse_set;
+ MR_Word print_all_set;
+ MR_Word flat_format;
+ MR_Word raw_pretty_format;
+ MR_Word verbose_format;
+ MR_Word pretty_format;
if (! MR_trace_options_param_set(&print_set, &browse_set,
&print_all_set, &flat_format,
@@ -2464,21 +2465,28 @@
};
static bool
-MR_trace_options_param_set(MR_Bool *print_set, MR_Bool *browse_set,
- MR_Bool *print_all_set, MR_Bool *flat_format,
- MR_Bool *raw_pretty_format, MR_Bool *verbose_format,
- MR_Bool *pretty_format, char ***words, int *word_count, const char *cat,
+MR_trace_options_param_set(MR_Word *print_set, MR_Word *browse_set,
+ MR_Word *print_all_set, MR_Word *flat_format,
+ MR_Word *raw_pretty_format, MR_Word *verbose_format,
+ MR_Word *pretty_format, char ***words, int *word_count, const char *cat,
const char *item)
{
int c;
+ MR_Word mercury_bool_yes;
+ MR_Word mercury_bool_no;
- *print_set = FALSE;
- *browse_set = FALSE;
- *print_all_set = FALSE;
- *flat_format = FALSE;
- *raw_pretty_format = FALSE;
- *verbose_format = FALSE;
- *pretty_format = FALSE;
+ MR_TRACE_CALL_MERCURY(
+ mercury_bool_yes = ML_BROWSE_mercury_bool_yes();
+ mercury_bool_no = ML_BROWSE_mercury_bool_no();
+ );
+
+ *print_set = mercury_bool_no;
+ *browse_set = mercury_bool_no;
+ *print_all_set = mercury_bool_no;
+ *flat_format = mercury_bool_no;
+ *raw_pretty_format = mercury_bool_no;
+ *verbose_format = mercury_bool_no;
+ *pretty_format = mercury_bool_no;
MR_optind = 0;
while ((c = MR_getopt_long(*word_count, *words, "PBAfrvp",
@@ -2487,31 +2495,31 @@
switch (c) {
case 'f':
- *flat_format = TRUE;
+ *flat_format = mercury_bool_yes;
break;
case 'r':
- *raw_pretty_format = TRUE;
+ *raw_pretty_format = mercury_bool_yes;
break;
case 'v':
- *verbose_format = TRUE;
+ *verbose_format = mercury_bool_yes;
break;
case 'p':
- *pretty_format = TRUE;
+ *pretty_format = mercury_bool_yes;
break;
case 'P':
- *print_set = TRUE;
+ *print_set = mercury_bool_yes;
break;
case 'B':
- *browse_set = TRUE;
+ *browse_set = mercury_bool_yes;
break;
case 'A':
- *print_all_set = TRUE;
+ *print_all_set = mercury_bool_yes;
break;
default:
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list