diff: clpr/dump.m impurity decls
Fergus Henderson
fjh at cs.mu.oz.au
Fri Dec 12 08:21:57 AEDT 1997
extras/clpr/dump.m:
Add impurity declarations.
Fix up some old `pragma(c_code, ...)' declarations.
Index: dump.m
===================================================================
RCS file: /home/mercury1/repository/clpr/dump.m,v
retrieving revision 1.11
diff -u -u -r1.11 dump.m
--- dump.m 1997/09/23 16:03:56 1.11
+++ dump.m 1997/12/11 21:10:03
@@ -40,14 +40,14 @@
% "_v<N>", where <N> is an integer.
% XXX this one is a non-logical hack, use only for debugging
-:- pred unsafe_dump(list(cfloat)::list_ca, list(string)::in) is det.
+:- impure pred unsafe_dump(list(cfloat)::list_ca, list(string)::in) is det.
% XXX this one is a non-logical hack, use only for debugging
-:- pred unsafe_dump_cfloat(cfloat::ca) is det.
+:- impure pred unsafe_dump_cfloat(cfloat::ca) is det.
% for debugging only... this pred (non-logically) dumps the CLP(R)
% tableaus to standard error at runtime.
-:- pred unsafe_dump_tableaus is det.
+:- impure pred unsafe_dump_tableaus is det.
%-----------------------------------------------------------------------------%
:- implementation.
@@ -56,7 +56,7 @@
:- pragma c_header_code("#include ""clpr/solver.h""").
:- pragma c_header_code("#include ""clpr/clpr_misc.h""").
-:- pragma c_code(dump_cfloat(Svar::ca, IO0::di, IO::uo),
+:- pragma c_code(dump_cfloat(Svar::ca, IO0::di, IO::uo), will_not_call_mercury,
"{
double val;
if (is_ground(Svar, &val)) {
@@ -68,7 +68,7 @@
}").
-:- pragma c_code(unsafe_dump_cfloat(Svar::ca),
+:- pragma c_code(unsafe_dump_cfloat(Svar::ca), will_not_call_mercury,
"{
double val;
if (is_ground(Svar, &val)) {
@@ -79,10 +79,11 @@
}").
% WARNING: The implementation of this predicate is non-logical.
+:- pragma promise_pure(dump_one_solution/3).
dump_one_solution(Pred) -->
( { call(Pred, Vars, VarNames) } ->
- { unsafe_dump(Vars, VarNames) }
+ { impure unsafe_dump(Vars, VarNames) }
;
io__write_string("No solution.\n")
).
@@ -111,8 +112,8 @@
% convert the mercury list of strings to the required
% CLP(R) representation
dump__mercury_string_list_to_clpr_dump_string(Names, CLPRNames),
- dump__do_dump(CLPRVars, CLPRNames),
- dump__free(CLPRVars, CLPRNames)
+ impure dump__do_dump(CLPRVars, CLPRNames),
+ impure dump__free(CLPRVars, CLPRNames)
;
error("list length mismatch in dump")
).
@@ -141,7 +142,7 @@
:- pragma c_header_code("#include ""clpr/compile.h""").
:- pred dump__get_clpr_empty_list(c_pointer::out) is det.
-:- pragma c_code(dump__get_clpr_empty_list(Empty::out),
+:- pragma c_code(dump__get_clpr_empty_list(Empty::out), will_not_call_mercury,
"
Empty = addtag(CLPR_TAG_NIL, 0);
"
@@ -149,7 +150,8 @@
:- pred dump__make_clpr_cfloat_list(cfloat::ca, c_pointer::in, c_pointer::out)
is det.
-:- pragma(c_code, dump__make_clpr_cfloat_list(Head::ca, Tail::in, TheList::out),
+:- pragma c_code(dump__make_clpr_cfloat_list(Head::ca, Tail::in, TheList::out),
+ will_not_call_mercury,
"
{
CLPR_int *HeadPtr;
@@ -187,7 +189,9 @@
Result is Length + TheRest.
:- pred dump__allocate_clpr_string(int::in, c_pointer::out) is det.
-:- pragma(c_code, dump__allocate_clpr_string(Length::in, CLPRString::out), "{
+:- pragma c_code(dump__allocate_clpr_string(Length::in, CLPRString::out),
+ will_not_call_mercury,
+"{
char *s;
if ((s = malloc(Length * sizeof(char))) == NULL)
fatal_error(""malloc() failed in dump__allocate_clpr_string"");
@@ -205,8 +209,8 @@
:- pred dump__add_single_string(string::in, c_pointer::in, int::in,
c_pointer::out) is det.
-:- pragma(c_code, dump__add_single_string(TheString::in, CLPRString0::in,
- Index::in, CLPRString::out),
+:- pragma c_code(dump__add_single_string(TheString::in, CLPRString0::in,
+ Index::in, CLPRString::out), will_not_call_mercury,
"
{
char *CLPRTmp, *StringTmp;
@@ -223,13 +227,13 @@
"
).
-:- pragma(c_header_code, "extern void dump1(FILE *, CLPR_int *, char *);").
-:- pred dump__do_dump(c_pointer::in, c_pointer::in) is det.
-:- pragma(c_code, dump__do_dump(Vars::in, Names::in),
+:- pragma c_header_code("extern void dump1(FILE *, CLPR_int *, char *);").
+:- impure pred dump__do_dump(c_pointer::in, c_pointer::in) is det.
+:- pragma c_code(dump__do_dump(Vars::in, Names::in), will_not_call_mercury,
"dump1(stdout, (CLPR_int *)&Vars, (char *)Names);").
-:- pragma(c_header_code, "static void free_clpr_list_mem(Word list);").
-:- pragma(c_code, "
+:- pragma c_header_code("static void free_clpr_list_mem(Word list);").
+:- pragma c_code("
static void free_clpr_list_mem(Word list)
{
if (CLPR_tag(list) == CLPR_TAG_CONS) {
@@ -239,11 +243,11 @@
}
}
- ").
+").
% Free our dynamically allocated memory.
-:- pred dump__free(c_pointer::in, c_pointer::in) is det.
-:- pragma(c_code, dump__free(Vars::in, TheString::in),
+:- impure pred dump__free(c_pointer::in, c_pointer::in) is det.
+:- pragma c_code(dump__free(Vars::in, TheString::in), will_not_call_mercury,
"
free_clpr_list_mem(Vars);
free((char *) TheString);
cvs diff: Diffing clpr
cvs diff: Diffing samples
--
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.
More information about the developers
mailing list