[m-rev.] for review: allow tracking of input subterms through builtin_catch
Julien Fischer
juliensf at cs.mu.OZ.AU
Thu Dec 8 17:24:41 AEDT 2005
On Thu, 8 Dec 2005, Ian MacLarty wrote:
> For review by anyone.
>
> Estimated hours taken: 5
> Branches: main
>
> Allow input subterms to be tracked through builtin_catch. By making
I suggest: This is done by making a special case ...
> a special case of catch_impl, which is the only predicate that calls
> builtin_catch (we have to make catch_impl the special case, because
> builtin_catch doesn't generate any events, so has no node in the EDT).
>
> browser/declarative_tree.m:
> Break trace_dependency into two smaller predicates.
> If tracking an input to builtin_catch then return what we know
> the origin will be instead of invoking the usual subterm dependency
> tracking algorithm.
>
> library/exception.m:
> Note that the debugger assumes builtin_catch is only called from
> catch_impl.
>
> tests/debugger/declarative/Mmakefile:
> tests/debugger/declarative/track_through_catch.exp:
> tests/debugger/declarative/track_through_catch.inp:
> tests/debugger/declarative/track_through_catch.m:
> Test the change.
>
> Index: browser/declarative_tree.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/browser/declarative_tree.m,v
> retrieving revision 1.35
> diff -u -r1.35 declarative_tree.m
> --- browser/declarative_tree.m 7 Dec 2005 16:06:59 -0000 1.35
> +++ browser/declarative_tree.m 7 Dec 2005 21:12:25 -0000
...
> @@ -893,6 +868,67 @@
> Mode = subterm_out
> ).
>
> +:- pred trace_dependency_in_proc_rep(S::in, term_path::in,
> + start_loc(R)::in, int::in, int::in, R::in, maybe(goal_path)::in,
> + proc_rep::in, subterm_origin(edt_node(R))::out)
> + is det <= annotated_trace(S, R).
> +
> +trace_dependency_in_proc_rep(Store, TermPath, StartLoc, ArgNum,
> + TotalArgs, NodeId, StartPath, ProcRep, Origin) :-
> + det_trace_node_from_id(Store, NodeId, Node),
> + materialize_contour(Store, NodeId, Node, [], Contour0),
> + (
> + StartLoc = parent_goal(CallId, CallNode),
> + Contour = list.append(Contour0,
> + [CallId - CallNode])
> + ;
> + StartLoc = cur_goal,
> + Contour = Contour0
> + ),
> + ProcRep = proc_rep(HeadVars, GoalRep),
> + is_traced_grade(AllTraced),
> + MaybePrims = make_primitive_list(Store,
> + [goal_and_path(GoalRep, [])],
> + Contour, StartPath, ArgNum, TotalArgs,
> + HeadVars, AllTraced, []),
> + (
> + MaybePrims = yes(primitive_list_and_var(
> + Primitives, Var, MaybeClosure)),
> + %
> + % If the subterm is in a closure argument then the argument
> + % number of the closure argument is prefixed to the term path,
> + % since the closure is itself a term. This is done here
> + % because at the time of the closure call it is not easy to
> + % decide if the call is higher order or not, without repeating
> + % all the work done in make_primitive_list.
> + %
> + (
> + MaybeClosure = yes,
> + AdjustedTermPath = [ArgNum | TermPath]
> + ;
> + MaybeClosure = no,
> + AdjustedTermPath = TermPath
> + ),
> + traverse_primitives(Primitives, Var,
> + AdjustedTermPath, Store, ProcRep,
> + Origin)
> + ;
> + MaybePrims = no,
> + Origin = not_found
> + ).
> +
> + % proc_rep_is_catch_impl(ProcRep) is true if ProcRep is a
> + % representation of exception.catch_impl (the conserve
s/conserve/converse/
> + % is true assuming exception.builtin_catch is only called from
> + % exception.catch_impl).
> + %
> +:- pred proc_rep_is_catch_impl(proc_rep::in) is semidet.
> +
> +proc_rep_is_catch_impl(ProcRep) :-
> + ProcRep = proc_rep([A, B, C, D], atomic_goal_rep(_, "exception.m", _,
> + [D], plain_call_rep("exception", "builtin_catch",
> + [A, B, C, D]))).
> +
> :- pred find_chain_start(S::in, R::in, arg_pos::in, term_path::in,
> dependency_chain_start(R)::out) is det <= annotated_trace(S, R).
>
The looks fine otherwise.
Cheers,
Julien.
--------------------------------------------------------------------------
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