save exception term in database, so that it is clean separate from stacks. #116
This commit is contained in:
parent
9dff291be2
commit
4de6e48a33
34
C/exec.c
34
C/exec.c
@ -1463,8 +1463,8 @@ suspended_on_current_execution(Term t, Term t0)
|
|||||||
return t0 == ArgOfTerm(1, t1);
|
return t0 == ArgOfTerm(1, t1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Term
|
||||||
clean_trail(Term t, Term t0)
|
clean_trail(Term t, DBTerm *dbt, Term t0)
|
||||||
{
|
{
|
||||||
tr_fr_ptr pt1, pbase;
|
tr_fr_ptr pt1, pbase;
|
||||||
|
|
||||||
@ -1495,9 +1495,17 @@ clean_trail(Term t, Term t0)
|
|||||||
if (suspended_on_current_execution(val, t0)) {
|
if (suspended_on_current_execution(val, t0)) {
|
||||||
RESET_VARIABLE(&TrailTerm(pt1));
|
RESET_VARIABLE(&TrailTerm(pt1));
|
||||||
} else {
|
} else {
|
||||||
|
if (dbt) {
|
||||||
|
t = Yap_FetchTermFromDB(dbt);
|
||||||
|
if (t) {
|
||||||
|
B->cp_h = H;
|
||||||
|
} else {
|
||||||
|
t = MkAtomTerm(AtomDAbort);
|
||||||
|
}
|
||||||
|
}
|
||||||
Bind(pt, t);
|
Bind(pt, t);
|
||||||
Yap_WakeUp(pt);
|
Yap_WakeUp(pt);
|
||||||
return;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1516,6 +1524,15 @@ clean_trail(Term t, Term t0)
|
|||||||
#endif /* FROZEN_STACKS */
|
#endif /* FROZEN_STACKS */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (dbt) {
|
||||||
|
t = Yap_FetchTermFromDB(dbt);
|
||||||
|
if (t) {
|
||||||
|
B->cp_h = H;
|
||||||
|
} else {
|
||||||
|
t = MkAtomTerm(AtomDAbort);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1525,9 +1542,12 @@ JumpToEnv(Term t) {
|
|||||||
*catchpos = NEXTOP(PredHandleThrow->cs.p_code.TrueCodeOfPred,l);
|
*catchpos = NEXTOP(PredHandleThrow->cs.p_code.TrueCodeOfPred,l);
|
||||||
CELL *env;
|
CELL *env;
|
||||||
choiceptr first_func = NULL, B0 = B;
|
choiceptr first_func = NULL, B0 = B;
|
||||||
|
DBTerm *dbt;
|
||||||
|
|
||||||
if (!(t = Yap_SaveTerm(t)))
|
if (!(dbt = Yap_StoreTermInDB(t, -1))) {
|
||||||
return FALSE;
|
if (!(t = Yap_SaveTerm(t)))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
do {
|
do {
|
||||||
/* find the first choicepoint that may be a catch */
|
/* find the first choicepoint that may be a catch */
|
||||||
while (B != NULL && B->cp_ap != pos) {
|
while (B != NULL && B->cp_ap != pos) {
|
||||||
@ -1579,9 +1599,9 @@ JumpToEnv(Term t) {
|
|||||||
B->cp_h = H;
|
B->cp_h = H;
|
||||||
/* I could backtrack here, but it is easier to leave the unwinding
|
/* I could backtrack here, but it is easier to leave the unwinding
|
||||||
to the emulator */
|
to the emulator */
|
||||||
B->cp_a3 = t;
|
|
||||||
P = (yamop *)FAILCODE;
|
P = (yamop *)FAILCODE;
|
||||||
clean_trail(t, B->cp_a1);
|
t = clean_trail(t, dbt, B->cp_a1);
|
||||||
|
B->cp_a3 = t;
|
||||||
if (first_func != NULL) {
|
if (first_func != NULL) {
|
||||||
B = first_func;
|
B = first_func;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user