jumping
This commit is contained in:
parent
fb5564f9d1
commit
470323da5c
22
C/errors.c
22
C/errors.c
@ -647,11 +647,14 @@ yamop *Yap_Error__(bool throw, const char *file, const char *function,
|
||||
yap_error_number err;
|
||||
|
||||
/* disallow recursive error handling */
|
||||
if (LOCAL_PrologMode & InErrorMode && (err = LOCAL_ActiveError->errorNo)) {
|
||||
fprintf(stderr, "%% ERROR %s %s WITHIN ERROR %s %s\n",
|
||||
if (LOCAL_PrologMode & InErrorMode &&
|
||||
((err = LOCAL_ActiveError->errorNo) ||
|
||||
( LOCAL_CommittedError->errorNo &&
|
||||
(err = LOCAL_CommittedError->errorNo)))) {
|
||||
fprintf(stderr, "%% ERROR %s %s WITHIN ERROR %s %s\n",
|
||||
Yap_errorClassName(Yap_errorClass(type)), Yap_errorName(type),
|
||||
Yap_errorClassName(Yap_errorClass(err)), Yap_errorName(err));
|
||||
Yap_RestartYap(1);
|
||||
return P;
|
||||
}
|
||||
if (LOCAL_DoingUndefp && type == EVALUATION_ERROR_UNDEFINED) {
|
||||
P = FAILCODE;
|
||||
@ -1002,6 +1005,7 @@ static Int get_exception(USES_REGS1) {
|
||||
Term t;
|
||||
|
||||
i = LOCAL_CommittedError;
|
||||
LOCAL_CommittedError = NULL;
|
||||
if (i && i->errorNo != YAP_NO_ERROR) {
|
||||
if (i->errorNo == THROW_EVENT)
|
||||
t = i->errorRawTerm;
|
||||
@ -1012,12 +1016,8 @@ static Int get_exception(USES_REGS1) {
|
||||
t = mkerrort(i->errorNo, TermNil, MkSysError(i));
|
||||
}
|
||||
Yap_ResetException(LOCAL_ActiveError);
|
||||
LOCAL_CommittedError = NULL;
|
||||
Int rc = Yap_unify(t, ARG1);
|
||||
return rc;
|
||||
}
|
||||
LOCAL_CommittedError = NULL;
|
||||
|
||||
return Yap_unify(t, ARG1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1091,8 +1091,8 @@ yap_error_descriptor_t *Yap_UserError(Term t, yap_error_descriptor_t *i) {
|
||||
Term hdtl = TailOfTerm(hd);
|
||||
if (hdhd == Termg) {
|
||||
Term n = ArgOfTerm(1,hdtl);
|
||||
|
||||
LOCAL_ActiveError->errorGoal = Yap_TermToBuffer(n, ENC_ISO_UTF8, Quote_illegal_f | Ignore_ops_f | Unfold_cyclics_f);
|
||||
|
||||
LOCAL_ActiveError->errorGoal = Yap_TermToBuffer(n, ENC_ISO_UTF8, Quote_illegal_f | Ignore_ops_f | Unfold_cyclics_f);
|
||||
}
|
||||
|
||||
}
|
||||
|
18
C/exec.c
18
C/exec.c
@ -948,7 +948,7 @@ static Int tag_cleanup(USES_REGS1) {
|
||||
|
||||
static Int cleanup_on_exit(USES_REGS1) {
|
||||
|
||||
choiceptr B0 = (choiceptr)(LCL0 - IntegerOfTerm(Deref(ARG1)));
|
||||
choiceptr B0 = (choiceptr)(LCL0 - IntegerOfTerm(Deref(ARG1))), bp;
|
||||
Term task = Deref(ARG2);
|
||||
bool box = ArgOfTerm(1, task) == TermTrue;
|
||||
Term cleanup = ArgOfTerm(3, task);
|
||||
@ -956,6 +956,7 @@ static Int cleanup_on_exit(USES_REGS1) {
|
||||
|
||||
while (B->cp_ap->opc == FAIL_OPCODE)
|
||||
B = B->cp_b;
|
||||
|
||||
if (complete) {
|
||||
return true;
|
||||
}
|
||||
@ -973,6 +974,14 @@ static Int cleanup_on_exit(USES_REGS1) {
|
||||
complete_pt[0] = TermExit;
|
||||
}
|
||||
Yap_ignore(cleanup, false);
|
||||
bp = B;
|
||||
while (bp && bp != B0) {
|
||||
if (bp->cp_ap == NOCODE &&
|
||||
bp->cp_b) {
|
||||
bp->cp_ap = TRUSTFAILCODE;
|
||||
}
|
||||
bp = bp->cp_b;
|
||||
}
|
||||
if (Yap_RaiseException()) {
|
||||
return false;
|
||||
}
|
||||
@ -2028,12 +2037,11 @@ static Int JumpToEnv(USES_REGS1) {
|
||||
// DBTerm *dbt = Yap_RefToException();
|
||||
while (handler
|
||||
&& Yap_PredForChoicePt(handler, NULL) != PredDollarCatch
|
||||
&& LOCAL_CBorder < LCL0 - (CELL *)handler
|
||||
&& handler->cp_ap != NOCODE
|
||||
//&& LOCAL_CBorder < LCL0 - (CELL *)handler
|
||||
//&& handler->cp_ap != NOCODE
|
||||
&& handler->cp_b != NULL
|
||||
) {
|
||||
//if (handler->cp_ap != NOCODE)
|
||||
// handler->cp_ap = TRUSTFAILCODE;
|
||||
handler->cp_ap = TRUSTFAILCODE;
|
||||
handler = handler->cp_b;
|
||||
}
|
||||
pop_text_stack(1);
|
||||
|
@ -302,7 +302,7 @@ addinfo( Desc) -->
|
||||
'$query_exception'(errorGoal, Desc, Call)
|
||||
}
|
||||
;
|
||||
[[h|p(M,Na,Ar,File,FilePos)g)](_)]]
|
||||
[h|p(M,Na,Ar,File,FilePos)]
|
||||
->
|
||||
[]
|
||||
).
|
||||
@ -805,7 +805,7 @@ print_lines( S, Prefixes, Key) -->
|
||||
!,
|
||||
{ nl(S),
|
||||
Prefixes = [PrefixS - Cmds|More],
|
||||
format(S, PrefixS, []Cmds)
|
||||
format(S, PrefixS, Cmds)
|
||||
},
|
||||
{
|
||||
More == []
|
||||
|
@ -308,6 +308,5 @@ read_sig.
|
||||
:- '$set_no_trace'('$Error'(_), prolog).
|
||||
:- '$set_no_trace'('$LoopError'(_,_), prolog).
|
||||
:- '$set_no_trace'('$TraceError'(_,_,_,_,_), prolog).
|
||||
:- '$set_no_trace'('$run_catch'(_,_), prolog).
|
||||
|
||||
%%! @}
|
||||
|
25
pl/top.yap
25
pl/top.yap
@ -965,30 +965,9 @@ catch(G, C, A) :-
|
||||
).
|
||||
'$catch'(_,C,A) :-
|
||||
'$get_exception'(C),
|
||||
'$run_catch'(A, C).
|
||||
'$execute'(A),
|
||||
'$true'.
|
||||
|
||||
% variable throws are user-handled.
|
||||
'$run_catch'(G,E) :-
|
||||
E = '$VAR'(_),
|
||||
!,
|
||||
call(G ).
|
||||
'$run_catch'(abort,_) :-
|
||||
abort.
|
||||
'$run_catch'('$Error'(E),E) :-
|
||||
!,
|
||||
'$LoopError'(E, top ).
|
||||
'$run_catch'('$LoopError'(E, Where),E) :-
|
||||
!,
|
||||
'$LoopError'(E, Where).
|
||||
'$run_catch'('$TraceError'(E, GoalNumber, G, Module, CalledFromDebugger),E) :-
|
||||
!,
|
||||
'$TraceError'(E, GoalNumber, G, Module, CalledFromDebugger).
|
||||
'$run_catch'(_Signal,E) :-
|
||||
functor( E, N, _),
|
||||
'$hidden_atom'(N), !,
|
||||
throw(E).
|
||||
'$run_catch'( Signal, _E) :-
|
||||
call( Signal ).
|
||||
|
||||
%
|
||||
% throw has to be *exactly* after system catch!
|
||||
|
Reference in New Issue
Block a user