[m-rev.] for review: handle EXCP nodes in wrong and missing answer diagnosis
Ian MacLarty
maclarty at cs.mu.OZ.AU
Fri Jan 7 12:34:42 AEDT 2005
I've made a few changes since my original posting:
I've added the following to the log:
Since unexpected_exception_children and wrong_answer_children are now
almost identical, replace them with one predicate contour_children.
And made the following code changes:
diff -u browser/declarative_tree.m browser/declarative_tree.m
--- browser/declarative_tree.m 4 Jan 2005 01:04:18 -0000
+++ browser/declarative_tree.m 6 Jan 2005 11:35:35 -0000
@@ -268,13 +268,13 @@
missing_answer_children(Store, PrecId, CallId, [],
Children)
;
- wrong_answer_children(Store, PrecId, CallId, [],
- Children)
+ contour_children(wrong_answer, Store, PrecId, CallId,
+ [], Children)
)
;
Node = excp(PrecId, CallId, _, _, _),
not_at_depth_limit(Store, CallId),
- unexpected_exception_children(Store, PrecId, CallId, [],
+ contour_children(exception, Store, PrecId, CallId, [],
Children)
).
@@ -299,32 +299,51 @@
call_node_from_id(Store, Ref, CallNode),
CallNode ^ call_at_max_depth = no.
-:- pred wrong_answer_children(S, R, R, list(edt_node(R)), list(edt_node(R)))
- <= annotated_trace(S, R).
-:- mode wrong_answer_children(in, in, in, in, out) is det.
+:- type contour_children_type
+ ---> wrong_answer
+ ; exception.
+
+:- pred contour_children(contour_children_type::in, S::in, R::in, R::in,
+ list(edt_node(R))::in, list(edt_node(R))::out) is det
+ <= annotated_trace(S, R).
-wrong_answer_children(Store, NodeId, StartId, Ns0, Ns) :-
+contour_children(ContourChildrenType, Store, NodeId, StartId, Ns0, Ns) :-
(
NodeId = StartId
->
Ns = Ns0
;
- wrong_answer_children_2(Store, NodeId, StartId, Ns0, Ns)
+ contour_children_2(ContourChildrenType, Store, NodeId, StartId,
+ Ns0, Ns)
).
-:- pred wrong_answer_children_2(S, R, R, list(edt_node(R)),
- list(edt_node(R))) <= annotated_trace(S, R).
-:- mode wrong_answer_children_2(in, in, in, in, out) is det.
+:- pred contour_children_2(contour_children_type::in, S::in, R::in, R::in,
+ list(edt_node(R))::in, list(edt_node(R))::out) is det
+ <= annotated_trace(S, R).
-wrong_answer_children_2(Store, NodeId, StartId, Ns0, Ns) :-
+contour_children_2(ContourChildrenType, Store, NodeId, StartId, Ns0, Ns) :-
det_trace_node_from_id(Store, NodeId, Node),
(
- ( Node = call(_, _, _, _, _, _, _, _, _)
- ; Node = neg(_, _, _)
- ; Node = cond(_, _, failed)
+ (
+ Node = call(_, _, _, _, _, _, _, _, _)
+ ;
+ %
+ % A non-failed NEGE could be encountered when gathering
+ % the children of an exception node, since the
+ % exception may have been thrown inside the negation.
+ %
+ (
+ ContourChildrenType = wrong_answer,
+ Node = neg(_, _, _)
+ ;
+ ContourChildrenType = exception,
+ Node = neg(_, _, failed)
+ )
+ ;
+ Node = cond(_, _, failed)
)
->
- throw(internal_error("wrong_answer_children_2",
+ throw(internal_error("contour_children_2",
"unexpected start of contour"))
;
( Node = exit(_, _, _, _, _, _)
@@ -367,7 +386,8 @@
% tell whether the call was in a negated context or
% backtracked over, so we have to assume the former.
%
- wrong_answer_children(Store, Prec, NestedStartId, Ns0, Ns1)
+ contour_children(ContourChildrenType, Store, Prec,
+ NestedStartId, Ns0, Ns1)
;
( Node = else(Prec, NestedStartId)
; Node = neg_succ(Prec, NestedStartId)
@@ -393,7 +413,7 @@
Ns1 = Ns0
),
Next = step_left_in_contour(Store, Node),
- wrong_answer_children(Store, Next, StartId, Ns1, Ns).
+ contour_children(ContourChildrenType, Store, Next, StartId, Ns1, Ns).
:- pred missing_answer_children(S, R, R, list(edt_node(R)), list(edt_node(R)))
<= annotated_trace(S, R).
@@ -438,7 +458,8 @@
%
% There is a nested successful context.
%
- wrong_answer_children(Store, Prec, NestedStartId, Ns0, Ns1)
+ contour_children(wrong_answer, Store, Prec,
+ NestedStartId, Ns0, Ns1)
;
( Node = else(Prec, NestedStartId)
; Node = neg_succ(Prec, NestedStartId)
@@ -461,100 +482,4 @@
missing_answer_children(Store, Next, StartId, Ns1, Ns).
-:- pred unexpected_exception_children(S, R, R, list(edt_node(R)),
- list(edt_node(R))) <= annotated_trace(S, R).
-:- mode unexpected_exception_children(in, in, in, in, out) is det.
-
-unexpected_exception_children(Store, NodeId, StartId, Ns0, Ns) :-
- (
- NodeId = StartId
- ->
- Ns = Ns0
- ;
- unexpected_exception_children_2(Store, NodeId, StartId, Ns0, Ns)
- ).
-
-:- pred unexpected_exception_children_2(S, R, R, list(edt_node(R)),
- list(edt_node(R))) <= annotated_trace(S, R).
-:- mode unexpected_exception_children_2(in, in, in, in, out) is det.
-
-unexpected_exception_children_2(Store, NodeId, StartId, Ns0, Ns) :-
- det_trace_node_from_id(Store, NodeId, Node),
- (
- ( Node = call(_, _, _, _, _, _, _, _, _)
- ; Node = neg(_, _, failed)
- ; Node = cond(_, _, failed)
- )
- ->
- throw(internal_error("unexpected_exception_children_2",
- "unexpected start of contour"))
- ;
- ( Node = exit(_, _, _, _, _, _)
- ; Node = excp(_, _, _, _, _)
- )
- ->
- %
- % Add a child for this node.
- %
- Ns1 = [dynamic(NodeId) | Ns0]
- ;
- Node = fail(_, CallId, _, _)
- ->
- %
- % Fail events can be reached here if there
- % were events missing due to a parent being
- % shallow traced. In this case, we can't tell
- % whether the call was in a negated context
- % or backtracked over, so we have to assume
- % the former.
- %
- % Fail events can also be reached here if the
- % parent was a variant of solutions/2.
- %
- % If this really is in a negated context, the start of
- % the context would be just before the entry to this
- % failed call, modulo any det/semidet code which
- % succeeded.
- %
- call_node_from_id(Store, CallId, Call),
- NestedStartId = Call ^ call_preceding,
- missing_answer_children(Store, NodeId, NestedStartId, Ns0, Ns1)
- ;
- Node = neg_fail(Prec, NestedStartId)
- ->
- %
- % There is a nested context. Neg_fail events can be
- % reached here if there were events missing due to a
- % parent being shallow traced. In this case, we can't
- % tell whether the call was in a negated context or
- % backtracked over, so we have to assume the former.
- %
- wrong_answer_children(Store, Prec, NestedStartId, Ns0, Ns1)
- ;
- ( Node = else(Prec, NestedStartId)
- ; Node = neg_succ(Prec, NestedStartId)
- )
- ->
- %
- % There is a nested context.
- %
- missing_answer_children(Store, Prec, NestedStartId, Ns0, Ns1)
- ;
- %
- % This handles the following cases:
- % redo, switch, first_disj, later_disj, and
- % then. Also handles neg and cond when the
- % status is anything other than failed.
- %
- % Redo events can be reached here if there
- % were missing events due to a shallow tracing.
- % In this case, we have to scan over the entire
- % previous contour, since there is no way to
- % tell how much of it was backtracked over.
- %
- Ns1 = Ns0
- ),
- Next = step_left_in_contour(Store, Node),
- unexpected_exception_children(Store, Next, StartId, Ns1, Ns).
-
%-----------------------------------------------------------------------------%
%
--------------------------------------------------------------------------
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