[m-dev.] For review: fix problems in Morphine w.r.t. univ vars representation
Erwan Jahier
Erwan.Jahier at irisa.fr
Wed Feb 28 20:06:48 AEDT 2001
Estimated hours taken: 3
Morphine non-regression tests were failing because the function
MR_trace_make_var_list() in trace/mercury_trace_external.c now
returns a list of `univ_cons/1' that contains a term whereas it was
previously returning a list of `univ/1' containing a term and its type
separated by a semicolon.
extras/morphine/source/current_args.op:
Take into account the new behavior of MR_trace_make_var_list(), and
in particular, work around the fact that MR_trace_make_var_list()
no longer outputs variables type.
Also clean-up a little bit the code and rename a couple of
predicates.
extras/morphine/source/non-regression-tests/queens.exp:
Replace `univ' by `univ_cons' when necessary.
Update the `help' and `set' browser commands output.
Test the term browser with `data/3' rather than with `nodiag/3'
since its output is more interesting (i.e., it is a non-empty list).
extras/morphine/source/non-regression-tests/queens.in:
extras/morphine/source/non-regression-tests/queens.exp:
Improve the output a little bit (i.e., add `*** ' for the outputs
that come from `queens.in'; also add a few `nl').
Index: non-regression-tests/queens.exp
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/morphine/non-regression-tests/queens.exp,v
retrieving revision 1.4
diff -u -d -u -r1.4 queens.exp
--- non-regression-tests/queens.exp 2000/08/16 07:21:13 1.4
+++ non-regression-tests/queens.exp 2001/02/28 08:57:26
@@ -29,7 +29,7 @@
20: 10 [6] call nondet (predicate) {queens} queens: qperm([4, 5] {list__list(int)}, -)/2-0 []
[1, 3, 5, 2, 4]
End of connection with the traced program
-ok.
+*** the first 20 events: ok.
C = 11
C2 = 20
@@ -88,7 +88,7 @@
no (more) solution.
[morphine 3]: [1, 3, 5, 2, 4]
End of connection with the traced program
-toggle: ok.
+*** toggle: ok.
[morphine 4]:
**************************************************
**** Testing one by one variable retrieval...
@@ -99,7 +99,7 @@
[live_var_names_and_types(HeadVar__1, list:list(int)), live_var_names_and_types(HeadVar__2, list:list(int))]
[1, 2, 3, 4, 5][1, 3, 5, 2, 4]
End of connection with the traced program
-one by one variable retrieval: ok.
+*** one by one variable retrieval: ok.
List = [live_var_names_and_types("HeadVar__1", "list:list(int)"), live_var_names_and_types("HeadVar__2", "list:list(int)")]
VarName = "HeadVar__1"
@@ -148,7 +148,7 @@
queen - 0
predicate -> queens : queen / 2 - 0[1, 3, 5, 2, 4]
End of connection with the traced program
-current: ok.
+*** current: ok.
Name = Name
Value = Value
@@ -230,7 +230,7 @@
4: 3 [2] call queen([1, 2, 3, 4, 5], -) []
[1, 3, 5, 2, 4]
End of connection with the traced program
-retry: ok.
+*** retry: ok.
[morphine 7]:
**************************************************
**** Testing stack dumps...
@@ -243,7 +243,7 @@
Level 1: (chrono=1, call=1, depth=1) pred queens:main/2-0 (cc_multi)
[1, 3, 5, 2, 4]
End of connection with the traced program
-stack: ok.
+*** stack: ok.
Stack = [[level(0), detail(2, 2, 2), pred, proc("queens", "data", 1, 0), det("det")], [level(1), detail(1, 1, 1), pred, proc("queens", "main", 2, 0), det("cc_multi")]]
[morphine 8]:
@@ -252,8 +252,18 @@
run(./, queens, )
Start debugging queens program.
1: 1 [1] call main(state('<<c_pointer>>'), -) []
-397: 83 [8] exit nodiag(1, 5, []) []
-browser> 1
+ 3: 2 [2] exit data([1, 2, 3, 4, 5]) []
+browser> .
+1-1
+2-.
+ 1-2
+ 2-.
+ 1-3
+ 2-.
+ 1-4
+ 2-.
+ 1-5
+ 2-[]
browser> browser> Commands are:
ls [path] -- list subterm (expanded)
@@ -265,13 +275,13 @@
quit -- quit browser
SICStus Prolog style commands are:
p -- print
- < [n] -- set depth (default is 3)
- ^ [path] -- cd [path]
+ < n -- set depth
+ ^ [path] -- cd [path] (default is root)
? -- help
h -- help
-- settings:
--- size; depth; path; format (flat pretty verbose); clipx; clipy
+-- size; depth; path; format (flat pretty verbose); width; lines
-- Paths can be Unix-style or SICStus-style: /2/3/1 or ^2^3^1
browser> Commands are:
@@ -284,13 +294,13 @@
quit -- quit browser
SICStus Prolog style commands are:
p -- print
- < [n] -- set depth (default is 3)
- ^ [path] -- cd [path]
+ < n -- set depth
+ ^ [path] -- cd [path] (default is root)
? -- help
h -- help
-- settings:
--- size; depth; path; format (flat pretty verbose); clipx; clipy
+-- size; depth; path; format (flat pretty verbose); width; lines
-- Paths can be Unix-style or SICStus-style: /2/3/1 or ^2^3^1
browser> Commands are:
@@ -303,32 +313,34 @@
quit -- quit browser
SICStus Prolog style commands are:
p -- print
- < [n] -- set depth (default is 3)
- ^ [path] -- cd [path]
+ < n -- set depth
+ ^ [path] -- cd [path] (default is root)
? -- help
h -- help
-- settings:
--- size; depth; path; format (flat pretty verbose); clipx; clipy
+-- size; depth; path; format (flat pretty verbose); width; lines
-- Paths can be Unix-style or SICStus-style: /2/3/1 or ^2^3^1
-browser> Max depth is: 3
-Max size is: 10
-X clip is: 79
+browser> Max depth is: 10
+Max size is: 30
+X clip is: 80
Y clip is: 25
Current path is: /
-Print format is verbose
+Ls format is verbose
+Print format is flat
browser> browser> browser> Max depth is: 2
-Max size is: 10
-X clip is: 79
+Max size is: 30
+X clip is: 80
Y clip is: 25
Current path is: /
+Ls format is pretty
Print format is pretty
-browser> 1
-browser> 1
+browser> .(1, .(2, ./2))
+browser> .(1, .(2, ./2))
browser> [1, 3, 5, 2, 4]
End of connection with the traced program
-browser: ok.
+*** browser: ok.
[morphine 9]:
**************************************************
**** Testing collect...
@@ -337,9 +349,10 @@
1: 1 [1] call main(state('<<c_pointer>>'), -) []
[1, 3, 5, 2, 4]
End of connection with the traced program
-[sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ([4] : list : list(int)), univ(state('<<c_pointer>>') : io : state)]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ([2, 4] : list : list(int)), univ(state('<<c_pointer>>') : io : state)]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ([5, 2, 4] : list : list(int)), univ(state('<<c_pointer>>') : io : state)]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ([3, 5, 2, 4] : list : list(int)), univ(state('<<c_pointer>>') : io : state)]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ([1, 3, 5, 2, 4] : list : list(int)), univ(state('<<c_pointer>>') : io : state)]), sol(proc(predicate, "queens", "print_list", 3, 0), [univ([1, 3, 5, 2, 4] : list : list(int)), univ(state('<<c_pointer>>') : io : state)]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(4 : int), univ(1 : int), univ([] : list : l!
ist(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([4] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(2 : int), univ(2 : int), univ([] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(2 : int), univ(1 : int), univ([4] : list : list(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([2, 4] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(5 : int), univ(3 : int), univ([] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(5 : int), univ(2 : int), univ([4] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(5 : int), univ(1 : int), univ([2, 4] : list : list(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([5, 2, 4] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(3 : int), univ(4 : int), univ([] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(3 : int), univ(3 : !
int), univ([4] : list : list(int))]), sol(proc(predicate, "queens", "n
odiag", 3, 0), [univ(3 : int), univ(2 : int), univ([2, 4] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(3 : int), univ(1 : int), univ([5, 2, 4] : list : list(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([3, 5, 2, 4] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(3 : int), univ([2, 4] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(2 : int), univ([5, 2, 4] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(1 : int), univ([3, 5, 2, 4] : list : list(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([1, 3, 5, 2, 4] : list : list(int))]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ([2, 4] : list : list(int))]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ([2, 4] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(3 : int), univ(1 : int), univ([4, 5, 2] : list :!
list(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([3, 4, 5, 2] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(4 : int), univ([2] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(3 : int), univ([5, 2] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(2 : int), univ([4, 5, 2] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(1 : int), univ([3, 4, 5, 2] : list : list(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([1, 3, 4, 5, 2] : list : list(int))]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ([2] : list : list(int))]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ([2] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(4 : int), univ([5] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(!
3 : int), univ([2, 5] : list : list(int))]), sol(proc(predicate, "quee
ns", "nodiag", 3, 0), [univ(1 : int), univ(2 : int), univ([4, 2, 5] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(1 : int), univ([3, 4, 2, 5] : list : list(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([1, 3, 4, 2, 5] : list : list(int))]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ([2, 5] : list : list(int))]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ([2, 5] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(3 : int), univ(1 : int), univ([2, 5, 4] : list : list(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([3, 2, 5, 4] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(5 : int), univ([] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(4 : int), univ([4] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(3 : int), univ([5, 4] : list : li!
st(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(2 : int), univ([2, 5, 4] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(1 : int), univ([3, 2, 5, 4] : list : list(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([1, 3, 2, 5, 4] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(3 : int), univ([4, 5] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(2 : int), univ([2, 4, 5] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(1 : int), univ([3, 2, 4, 5] : list : list(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([1, 3, 2, 4, 5] : list : list(int))]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ([2, 4, 5] : list : list(int))]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ([2, 4, 5] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3!
, 0), [univ(1 : int), univ(1 : int), univ([2, 5, 4, 3] : list : list(i
nt))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([1, 2, 5, 4, 3] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(1 : int), univ([2, 5, 3, 4] : list : list(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([1, 2, 5, 3, 4] : list : list(int))]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ([3, 4] : list : list(int))]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ([3, 4] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(1 : int), univ([2, 4, 5, 3] : list : list(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([1, 2, 4, 5, 3] : list : list(int))]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ([3] : list : list(int))]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ([3] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(1 : int), univ([2, 4, 3, 5] : list : list(int))]), sol(proc(predicate, "queens"!
, "safe", 1, 0), [univ([1, 2, 4, 3, 5] : list : list(int))]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ([3, 5] : list : list(int))]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ([3, 5] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(1 : int), univ([2, 3, 5, 4] : list : list(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([1, 2, 3, 5, 4] : list : list(int))]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ([4] : list : list(int))]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ([4] : list : list(int))]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ([] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(1 : int), univ(1 : int), univ([2, 3, 4, 5] : list : list(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([1, 2, 3, 4, 5] : list : list(int))]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ([] : list : list(int))]), sol(proc(predicate, "que!
ens", "qdelete", 3, 0), [univ([5] : list : list(int))]), sol(proc(pred
icate, "queens", "qperm", 2, 0), [univ([5] : list : list(int))]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ([4, 5] : list : list(int))]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ([4, 5] : list : list(int))]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ([3, 4, 5] : list : list(int))]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ([3, 4, 5] : list : list(int))]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ([2, 3, 4, 5] : list : list(int))]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ([2, 3, 4, 5] : list : list(int))]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ([1, 2, 3, 4, 5] : list : list(int))]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ([1, 2, 3, 4, 5] : list : list(int))]), sol(proc(predicate, "queens", "queen", 2, 0), [univ([1, 2, 3, 4, 5] : list : list(int))]), sol(proc(predicate, "queens", "data", 1, 0), []), sol(proc(predicate, "queens", "main", 2, 0), [univ(state('<<c_pointer>>') : io : s!
tate)])]collect: ok.
+[sol(proc(predicate, "queens", "main", 2, 0), [univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list", 3, 0), [univ_cons([1, 3, 5, 2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([1, 3, 5, 2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([3, 5, 2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([5, 2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "queen", 2, 0), [univ_cons([1, 2, 3, 4, 5]), univ_cons([1, 3, 5, 2, 4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([1, 3, 5, 2, 4])]), sol(proc(predicate, "queens", "safe", 1, !
0), [univ_cons([3, 5, 2, 4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([5, 2, 4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([2, 4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(4), univ_cons(1), univ_cons([])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(2), univ_cons(1), univ_cons([4])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(2), univ_cons(2), univ_cons([])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(5), univ_cons(1), univ_cons([2, 4])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(5), univ_cons(2), univ_cons([4])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(5), univ_cons(3), univ_cons([])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(3), univ_cons(1), univ_cons([5, 2, 4])]), sol(proc(predicate, "queens"!
, "nodiag", 3, 0), [univ_cons(3), univ_cons(2), univ_cons([2, 4])]), s
ol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(3), univ_cons(3), univ_cons([4])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(3), univ_cons(4), univ_cons([])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(1), univ_cons(1), univ_cons([3, 5, 2, 4])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(1), univ_cons(2), univ_cons([5, 2, 4])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(1), univ_cons(3), univ_cons([2, 4])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([1, 2, 3, 4, 5]), univ_cons([1, 3, 5, 2, 4])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 3, 4, 5]), univ_cons([3, 5, 2, 4])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 4, 5]), univ_cons([5, 2, 4])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 4]), univ_cons([2, 4])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(2), univ_cons([2, 4]), univ_cons([4])]), sol(proc(predicate,!
"queens", "qdelete", 3, 0), [univ_cons(5), univ_cons([2, 4, 5]), univ_cons([2, 4])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(1), univ_cons(1), univ_cons([3, 4, 5, 2])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(1), univ_cons(2), univ_cons([4, 5, 2])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(1), univ_cons(3), univ_cons([5, 2])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(1), univ_cons(4), univ_cons([2])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([1, 2, 3, 4, 5]), univ_cons([1, 3, 4, 5, 2])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 3, 4, 5]), univ_cons([3, 4, 5, 2])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 4, 5]), univ_cons([4, 5, 2])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 5]), univ_cons([5, 2])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2]), univ_cons([2])]), sol(proc(predicate, "queens", "qdelete", 3!
, 0), [univ_cons(2), univ_cons([2]), univ_cons([])]), sol(proc(predica
te, "queens", "qdelete", 3, 0), [univ_cons(5), univ_cons([2, 5]), univ_cons([2])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([1, 2, 3, 4, 5]), univ_cons([1, 3, 4, 2, 5])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 3, 4, 5]), univ_cons([3, 4, 2, 5])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 4, 5]), univ_cons([4, 2, 5])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 5]), univ_cons([2, 5])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(2), univ_cons([2, 5]), univ_cons([5])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(4), univ_cons([2, 4, 5]), univ_cons([2, 5])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(1), univ_cons(1), univ_cons([3, 2, 5, 4])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(1), univ_cons(2), univ_cons([2, 5, 4])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(1), univ_cons(3), univ_cons([5, 4])]), sol(proc(predic!
ate, "queens", "nodiag", 3, 0), [univ_cons(1), univ_cons(4), univ_cons([4])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(1), univ_cons(5), univ_cons([])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([1, 2, 3, 4, 5]), univ_cons([1, 3, 2, 5, 4])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 3, 4, 5]), univ_cons([3, 2, 5, 4])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 4, 5]), univ_cons([2, 5, 4])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([1, 2, 3, 4, 5]), univ_cons([1, 3, 2, 4, 5])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 3, 4, 5]), univ_cons([3, 2, 4, 5])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 4, 5]), univ_cons([2, 4, 5])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(2), univ_cons([2, 4, 5]), univ_cons([4, 5])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(3), univ_cons([2, 3, 4, 5]), univ_cons([2, 4, 5])]), sol(!
proc(predicate, "queens", "qperm", 2, 0), [univ_cons([1, 2, 3, 4, 5]),
univ_cons([1, 2, 5, 4, 3])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 3, 4, 5]), univ_cons([2, 5, 4, 3])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([3, 4, 5]), univ_cons([5, 4, 3])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([3, 4]), univ_cons([4, 3])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(4), univ_cons([3, 4]), univ_cons([3])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([1, 2, 3, 4, 5]), univ_cons([1, 2, 5, 3, 4])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 3, 4, 5]), univ_cons([2, 5, 3, 4])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([3, 4, 5]), univ_cons([5, 3, 4])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([3, 4]), univ_cons([3, 4])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(3), univ_cons([3, 4]), univ_cons([4])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(5), univ_cons([3, 4, 5]), univ_cons(!
[3, 4])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([1, 2, 3, 4, 5]), univ_cons([1, 2, 4, 5, 3])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 3, 4, 5]), univ_cons([2, 4, 5, 3])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([3, 4, 5]), univ_cons([4, 5, 3])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([3, 5]), univ_cons([5, 3])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([3]), univ_cons([3])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(3), univ_cons([3]), univ_cons([])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(5), univ_cons([3, 5]), univ_cons([3])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([1, 2, 3, 4, 5]), univ_cons([1, 2, 4, 3, 5])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 3, 4, 5]), univ_cons([2, 4, 3, 5])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([3, 4, 5]), univ_cons([4, 3, 5])]), sol(proc(predicate,!
"queens", "qperm", 2, 0), [univ_cons([3, 5]), univ_cons([3, 5])]), so
l(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(3), univ_cons([3, 5]), univ_cons([5])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(4), univ_cons([3, 4, 5]), univ_cons([3, 5])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([1, 2, 3, 4, 5]), univ_cons([1, 2, 3, 5, 4])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([2, 3, 4, 5]), univ_cons([2, 3, 5, 4])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([3, 4, 5]), univ_cons([3, 5, 4])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([4, 5]), univ_cons([5, 4])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([4]), univ_cons([4])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(4), univ_cons([4]), univ_cons([])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(5), univ_cons([4, 5]), univ_cons([4])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([1, 2, 3, 4, 5]), univ_cons([1, 2, 3, 4, 5])]), sol(proc(predicate,!
"queens", "qperm", 2, 0), [univ_cons([2, 3, 4, 5]), univ_cons([2, 3, 4, 5])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([3, 4, 5]), univ_cons([3, 4, 5])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([4, 5]), univ_cons([4, 5])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([5]), univ_cons([5])]), sol(proc(predicate, "queens", "qperm", 2, 0), [univ_cons([]), univ_cons([])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(5), univ_cons([5]), univ_cons([])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(4), univ_cons([4, 5]), univ_cons([5])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(3), univ_cons([3, 4, 5]), univ_cons([4, 5])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(2), univ_cons([2, 3, 4, 5]), univ_cons([3, 4, 5])]), sol(proc(predicate, "queens", "qdelete", 3, 0), [univ_cons(1), univ_cons([1, 2, 3, 4, 5]), univ_cons([2, 3, 4, 5])]), sol(proc(predicate, "queens", "data"!
, 1, 0), [univ_cons([1, 2, 3, 4, 5])])]
+*** collect: ok.
-Result = [sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ([4] : list : list(int)), univ(state('<<c_pointer>>') : io : state)]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ([2, 4] : list : list(int)), univ(state('<<c_pointer>>') : io : state)]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ([5, 2, 4] : list : list(int)), univ(state('<<c_pointer>>') : io : state)]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ([3, 5, 2, 4] : list : list(int)), univ(state('<<c_pointer>>') : io : state)]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ([1, 3, 5, 2, 4] : list : list(int)), univ(state('<<c_pointer>>') : io : state)]), sol(proc(predicate, "queens", "print_list", 3, 0), [univ([1, 3, 5, 2, 4] : list : list(int)), univ(state('<<c_pointer>>') : io : state)]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(4 : int), univ(1 : int), univ([] :!
list : list(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([4] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(2 : int), univ(2 : int), univ([] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(2 : int), univ(1 : int), univ([4] : list : list(int))]), sol(proc(predicate, "queens", "safe", 1, 0), [univ([2, 4] : list : list(int))]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(5 : int), univ(3 : int), univ([] : ... : ...)]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(5 : int), univ(2 : int), univ(... : ...)]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(5 : int), univ(... : ...), univ(...)]), sol(proc(predicate, "queens", "safe", 1, 0), [univ(... : ...)]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ(...), ...]), sol(proc(...), [...]), sol(...), ...] More? (;)
+Result = [sol(proc(predicate, "queens", "main", 2, 0), [univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list", 3, 0), [univ_cons([1, 3, 5, 2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([1, 3, 5, 2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([3, 5, 2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([5, 2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([2, 4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "print_list_2", 3, 0), [univ_cons([4]), univ_cons(state('<<c_pointer>>'))]), sol(proc(predicate, "queens", "queen", 2, 0), [univ_cons([1, 2, 3, 4, 5]), univ_cons([1, 3, 5, 2, 4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([1, 3, 5, 2, 4])]), sol(proc(predicate, "queens", "s!
afe", 1, 0), [univ_cons([3, 5, 2, 4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([5, 2, 4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([2, 4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([4])]), sol(proc(predicate, "queens", "safe", 1, 0), [univ_cons([])]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(4), univ_cons(1), univ_cons(...)]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(2), univ_cons(...), ...]), sol(proc(predicate, "queens", "nodiag", 3, 0), [univ_cons(...), ...]), sol(proc(...), [...]), sol(...), ...] More? (;)
[morphine 10]:
**************************************************
**** Testing other Morphine commands...
@@ -370,7 +383,7 @@
type of command : opium
scenario : help (GloLoc in morphine)
-ok.
+*** other Morphine commands: ok.
**************************************************
[morphine 11]:
bye
Index: non-regression-tests/queens.in
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/morphine/non-regression-tests/queens.in,v
retrieving revision 1.4
diff -u -d -u -r1.4 queens.in
--- non-regression-tests/queens.in 2000/08/16 08:50:48 1.4
+++ non-regression-tests/queens.in 2001/02/28 08:57:26
@@ -15,7 +15,7 @@
current(chrono=C2),
C2 >= 20, !,
no_trace,
- write("ok.\n").
+ write("*** the first 20 events: ok.\n").
write("\n**************************************************"),
write("\n**** Testing toggle/1...\n"),
@@ -33,7 +33,7 @@
print_event,
fail.
no_trace,
- write("toggle: ok.\n").
+ write("*** toggle: ok.\n").
write("\n**************************************************"),
write("\n**** Testing one by one variable retrieval...\n"),
@@ -45,7 +45,7 @@
current_live_var(VarName, Var, _),
write_trace(Var), !,
no_trace,
- write("one by one variable retrieval: ok.\n").
+ write("*** one by one variable retrieval: ok.\n").
write("\n**************************************************"),
write("\n**** Testing current...\n"),
@@ -147,7 +147,7 @@
current(proc = P16), nl,
write(P16), !,
no_trace,
- write("current: ok.\n").
+ write("*** current: ok.\n").
write("\n**************************************************"),
write("\n**** Testing retry/1...\n"),
@@ -155,7 +155,7 @@
fget(name = queen and port = exit),
retry, !,
no_trace,
- write("retry: ok.\n").
+ write("*** retry: ok.\n").
write("\n**************************************************"),
write("\n**** Testing stack dumps...\n"),
@@ -164,17 +164,18 @@
current(stack = Stack),
stack, !,
no_trace,
- write("stack: ok.\n").
+ write("*** stack: ok.\n").
write("\n**************************************************"),
write("\n**** Testing the term browser...\n"),
rerun,
- fget(name = nodiag and port = exit),
+ fget(name = data and port = exit),
open("browse.in", read, browse_stream),
set_stream(input, browse_stream),
browse("HeadVar__1"),
+ close(browse_stream),
no_trace,
- write("browser: ok.\n").
+ write("*** browser: ok.\n").
write("\n**************************************************"),
write("\n**** Testing collect...\n"),
@@ -182,7 +183,7 @@
set_parameter(collect_arg, [yes]),
collect(solutions, Result),
writeq(Result),
- write("collect: ok.\n").
+ write("\n*** collect: ok.\n").
write("\n**************************************************"),
write("\n**** Testing other Morphine commands...\n"),
@@ -190,6 +191,6 @@
apropos(man),
write("man(apropos)"), nl,
man(apropos),
- write("ok.\n"),
+ write("*** other Morphine commands: ok.\n"),
write("**************************************************\n").
Index: source/current_arg.op
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/morphine/source/current_arg.op,v
retrieving revision 1.4
diff -u -d -u -r1.4 current_arg.op
--- source/current_arg.op 1999/12/20 14:44:12 1.4
+++ source/current_arg.op 2001/02/28 08:57:27
@@ -61,7 +61,7 @@
!
;
integer_to_headvar(N, HeadVar__N),
- current_live_var(ListVarNames, HeadVar__N, RetrievedArg, _Type),
+ current_live_var2(ListVarNames, HeadVar__N, RetrievedArg, _, _),
Arg = RetrievedArg
),
N1 is N + 1,
@@ -233,29 +233,31 @@
% here the live variables that are arguments of the current
% predicate (which internal name is of the form "HeadVar__i") from
% the other live variables.
- separate_live_args_from_live_var(ListLiveVar, ListName,
- ListArg, ListArgName, ListOtherVar , ListOtherVarName),
+ current_live_var_names_and_types_ll(_, ListVarType),
+ split_list_of_live_args_and_vars(ListVarType, ListName,
+ ListArgType, _, ListOtherVarType, _),
+ split_list_of_live_args_and_vars(ListLiveVar, ListName,
+ ListArg, ListArgName, ListOtherVar, ListOtherVarName),
synthetise_list_univ_and_list_string(ListOtherVar, ListOtherVarName,
- ListOtherLiveVarRetrieved),
+ ListOtherVarType, ListOtherLiveVarRetrieved),
synthetise_list_univ_and_list_string(ListArg, ListArgName,
- ListLiveArgRetrieved).
+ ListArgType, ListLiveArgRetrieved).
-%:- pred separate_live_args_from_live_var(list(univ), list(string),
+%:- pred split_list_of_live_args_and_vars(list(univ), list(string),
% list(univ), list(string), list(univ), list(string) ).
-%:- mode separate_live_args_from_live_var(in, in, out, out, out, out) is det.
- % Separates live arguments of the current predicate from other live
- % variables.
- % The list in input contains a list of 'univ(value - type)' that
- % describes
- % live variables and a list of string of their corresponding internal
- % variable name. When the variable name begins with "HeadVar__", we put
- % its corresponding variable in the first output; and we put them
- % on the second output list otherwise.
-separate_live_args_from_live_var([], [], [], [], [], []).
-separate_live_args_from_live_var([Var | TailVar], [VarName | TailVarName],
+%:- mode split_list_of_live_args_and_vars(in, in, out, out, out, out) is det.
+ % Splits live arguments from other live variables.
+ % split_list_of_live_args_and_vars(L1, L2, L3, L4, L5, L6)
+ % splits the elements of the lists in input (L1 and L2) into L3, L4 and
+ % L5, L6 respectively. L2 contains Mercury variable internal names;
+ % for names beginning with "HeadVar__", the corresponding elements
+ % of L1 and L2 are put in L3 and L5; otherwise, they are put in L4
+ % and L6.
+split_list_of_live_args_and_vars([], [], [], [], [], []).
+split_list_of_live_args_and_vars([Var | TailVar], [VarName | TailVarName],
ListArg, ListArgName, ListOtherVar , ListOtherVarName) :-
- separate_live_args_from_live_var(TailVar, TailVarName,
+ split_list_of_live_args_and_vars(TailVar, TailVarName,
TailListArg, TailListArgName,
TailListOtherVar, TailListOtherVarName),
( append_strings("HeadVar__", _, VarName) ->
@@ -276,9 +278,11 @@
% Take a list of univ and a list of string of the same size and
% synthetize it into a list of live_var.
-synthetise_list_univ_and_list_string(L1, L2, Lout) :-
+synthetise_list_univ_and_list_string(UnivList, VarNameList, VarTypeList,
+ Lout) :-
(
- synthetise_list_univ_and_list_string2(L1, L2, Lout),
+ synthetise_list_univ_and_list_string2(UnivList, VarNameList,
+ VarTypeList, Lout),
!
;
write("\nSoftware error in Morphine: "),
@@ -286,21 +290,23 @@
abort
).
-synthetise_list_univ_and_list_string2(X, [Name | TailName], ListArgLive) :-
+synthetise_list_univ_and_list_string2(X, [Name | TailName],
+ [TypeStr|TailType], ListArgLive) :-
(
- X = [univ(Arg:Type) | TailArg],
- !
+ X = [univ_cons(Arg) | TailArg],
+ !
;
- X = [_| TailArg],
- Arg = 'error',
- Type = 'error',
- write("***** Can't retrieve that type of argument. "),
- write("This is a bug in Morphine...\n")
+ X = [_| TailArg],
+ Arg = 'error',
+ write("\n***** Can't retrieve that type of argument. "),
+ write("This is a bug in Morphine...\n")
),
- synthetise_list_univ_and_list_string2(TailArg, TailName, ListArgLeft),
+ synthetise_list_univ_and_list_string2(TailArg, TailName, TailType,
+ ListArgLeft),
+ term_string(Type, TypeStr),
ListArgLive = [live_var(Name, Arg, Type) | ListArgLeft].
-synthetise_list_univ_and_list_string2([], [], []).
+synthetise_list_univ_and_list_string2([], [], [], []).
% :- pred current_vars_ll(list(univ), list(string)).
% :- mode current_vars_ll(out, out) is det.
@@ -351,15 +357,32 @@
;
VarName = VarId
),
- current_live_var_names_and_types_ll(ListVarNames, _),
- current_live_var(ListVarNames, VarName, VarValue, VarType).
+ current_live_var_names_and_types_ll(ListVarNames, ListVarTypes),
+ current_live_var2(ListVarNames, ListVarTypes, VarName, VarValue,
+ VarType).
-current_live_var(ListVarNames, VarNames, Value, Type) :-
- member(VarNames, ListVarNames),
- get_internal_number(VarNames, ListVarNames, InternalNumber),
+current_live_var2(ListVarNames, ListVarTypes, VarName, Value, Type) :-
+ member(VarName, ListVarNames),
+ get_internal_number(VarName, ListVarNames, InternalNumber),
current_nth_var_ll(InternalNumber, X),
- X = univ(Value : Type).
+ get_type_from_list_vars(VarName, ListVarNames, ListVarTypes, Type),
+ X = univ_cons(Value).
+
+% :- pred get_type_from_list_vars(string, list(string), list(string), string).
+% :- mode get_type_from_list_vars(in, in, in, out) is det.
+ % if ListVarNames is a list of variable names and ListVarTypes is the
+ % list of their corresponding type (in the same order), then
+ % get_type_from_list_vars(VarName, ListVarNames, ListVarTypes, Type)
+ % outputs in Type the type of VarName.
+get_type_from_list_vars(Name, [VarName|TVarName], [VarType|TVarType], Type) :-
+ ( Name = VarName ->
+ term_string(Type, VarType)
+ ;
+ get_type_from_list_vars(Name, TVarName, TVarType, Type)
+ ).
+get_type_from_list_vars(_, [], [], 'bad_type').
+ % Should never occur.
get_internal_number(VarNames, ListVarNames, InternalNumber) :-
% This predicate unifies InternalNumber with the rank of VarNames in
--
R1.
--------------------------------------------------------------------------
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