mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-30 16:54:41 +00:00
Estimated hours taken: 14 Branches: main Include the reason why a question was asked in the information provided by the `info' command. This includes the place where a marked subterm was bound if the user marked a subterm in the previous question. browser/declarative_analyser.m Add a new type to record the reason why a question was asked. Keep this information with the last question asked in the analyser state, in case the user issues an `info' command. Display the reason when the user issues an `info' command. Change the behaviour of subterm dependency tracking slightly: if the binding node was previously skipped then ask about it anyway. The user can then see in which node the subterm was bound, which may help them in answering the previously skipped question. browser/declarative_edt.m Add two new methods to the mercury_edt typeclass. One to get the proc_label of a node and the other to convert an arg_pos to a user argument number with respect to an atom in a node. These are needed to display the question reason to the user in mdb.declarative_analyser. Add a new type to record the primitive operation that bound a subterm. browser/declarative_execution.m Add a predicate to convert an arg_pos into a user arg number. browser/declarative_oracle.m Fix a faulty comment. browser/declarative_tree.m Implement the new methods added to the mercury_edt typeclass. Return the type of primitive operation that bound a subterm. doc/user_guide.texi Document the fact that the reason is now also displayed when the `info' command is issued. tests/debugger/declarative/dependency.exp tests/debugger/declarative/dependency2.exp The type of primitive operation is now shown in the debugging output. tests/debugger/declarative/info.exp tests/debugger/declarative/info.inp tests/debugger/declarative/info.m Test the info command more thoroughly.
62 lines
963 B
Mathematica
62 lines
963 B
Mathematica
:- module info.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module int, list.
|
|
|
|
main(!IO) :-
|
|
(
|
|
info.last([1,2,3,4,5,6,7,8,9,10], A),
|
|
info.last([101,112,103,104,105,106,107,108], B)
|
|
->
|
|
q(0, "lala", C, D),
|
|
q(1, "lala", E, F),
|
|
io.write(A, !IO),
|
|
io.write(B, !IO),
|
|
io.write(C, !IO),
|
|
io.write(D, !IO),
|
|
io.write(E, !IO),
|
|
io.write(F, !IO)
|
|
;
|
|
true
|
|
).
|
|
|
|
:- pred q(int::in, T::in, t(t(t(T)))::out, int::out) is det.
|
|
|
|
q(N, X, Y, M) :-
|
|
( N = 0 ->
|
|
Y = f(N, X),
|
|
M = 2
|
|
;
|
|
M = fproc(N),
|
|
Y = t(t(t(X)))
|
|
).
|
|
|
|
:- pred last(list(T)::in, t(T)::out) is semidet.
|
|
|
|
info.last([H], t(H)).
|
|
info.last([_ , H2 | T], L) :-
|
|
info.last([H2 | T], L).
|
|
|
|
:- type t(T) ---> t(T).
|
|
|
|
:- func f(int, T) = t(t(t(T))).
|
|
|
|
f(_, X) = Y :-
|
|
Z = t(t(t(X))),
|
|
Y = Z.
|
|
|
|
:- func fproc(int) = int.
|
|
|
|
:- pragma foreign_proc("C", fproc(X::in) = (Y::out),
|
|
[will_not_call_mercury, thread_safe, promise_pure],
|
|
"
|
|
Y = X + 1;
|
|
").
|