mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-28 15:54:18 +00:00
Estimated hours taken: 25 (plus ? by zs) Bring the implementation up to date with the algorithm that is described in the paper (papers/decl_debug). Add some debugging infrastructure to the back end, which was used to debug this change. browser/declarative_execution.m: - Store the call sequence number in call nodes. - Store the previous redo (if there is one) in fail nodes. - Use a functor specifically for switches. - Use a pointer to the first disj event, instead of a pointer to the event before it. - Export two new predicates for dereferencing disj node ids. - Export (to C) a procedure for accessing the call sequence number, and a procedure for getting to the first disj event. - Split the scan_backwards function into two: step_left_in_context and find_prev_contour. browser/declarative_debugger.m: trace/mercury_trace_declarative.c: - Use the updated data structure. runtime/mercury_conf_param.h: - Add the configuration parameter MR_USE_DECL_STACK_SLOT, which makes the declarative debugger use stack slots reserved by the compiler to cache the location of the call node. trace/mercury_trace_declarative.h: trace/mercury_trace_declarative.c: - Use stack slot only if MR_USE_DECL_STACK_SLOT is defined. - If not using stack slot, use the new algorithm to search for a matching call or exit event. - Avoid using a global by passing the previous node to MR_trace_decl_* and returning the new node. - Rename MR_trace_call_node_answer to MR_trace_call_node_last_interface. - Update comments. browser/declarative_execution.m: trace/mercury_trace_declarative.c: - Added debugging output for various events of interest in the back end. It is activated when MR_DEBUG_DD_BACK_END is set. tests/debugger/declarative/aadebug.m: tests/debugger/declarative/aadebug.inp: tests/debugger/declarative/aadebug.exp: tests/debugger/declarative/aadebug.exp2: - Update this test to match the example in the paper. tests/debugger/declarative/propositional.inp: tests/debugger/declarative/propositional.exp: tests/debugger/declarative/propositional.exp2: - Update this test case so it gives a similar result in debugging grades to non-debugging grades. tests/debugger/declarative/app.exp2: tests/debugger/declarative/if_then_else.exp2: - Update test case results. tests/debugger/declarative/Mmakefile: tests/debugger/declarative/backtrack.m: tests/debugger/declarative/backtrack.inp: tests/debugger/declarative/backtrack.exp: - New test case.
36 lines
433 B
Mathematica
36 lines
433 B
Mathematica
:- module backtrack.
|
|
:- interface.
|
|
:- import_module io.
|
|
:- pred main(io__state::di, io__state::uo) is det.
|
|
:- implementation.
|
|
:- import_module std_util, int, bool.
|
|
|
|
main -->
|
|
{ p(1, R) },
|
|
io__write(R),
|
|
io__nl.
|
|
|
|
:- pred p(int::in, bool::out) is det.
|
|
|
|
p(N, R) :-
|
|
(
|
|
% some [M] (
|
|
M > 5,
|
|
q(N, M)
|
|
% )
|
|
->
|
|
R = yes
|
|
;
|
|
R = no
|
|
).
|
|
|
|
:- pred q(int::in, int::out) is nondet.
|
|
|
|
q(0, 0).
|
|
q(1, 1).
|
|
q(1, 2).
|
|
q(1, 3).
|
|
q(2, 2).
|
|
q(2, 4).
|
|
|