recursuve_calling
This commit is contained in:
parent
fda10395b8
commit
1739529c8b
@ -1323,11 +1323,10 @@ Int Yap_absmi(int inp) {
|
|||||||
#endif /* USE_THREADED_CODE */
|
#endif /* USE_THREADED_CODE */
|
||||||
|
|
||||||
#if PUSH_REGS
|
#if PUSH_REGS
|
||||||
old_regs = &Yap_REGS;
|
old_regs = Yap_regp;
|
||||||
|
|
||||||
/* done, let us now initialize this space */
|
/* done, let us now initialize this space */
|
||||||
init_absmi_regs(&absmi_regs);
|
init_absmi_regs(&absmi_regs);
|
||||||
|
|
||||||
/* the registers are all set up, let's swap */
|
/* the registers are all set up, let's swap */
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
pthread_setspecific(Yap_yaamregs_key, (const void *)&absmi_regs);
|
pthread_setspecific(Yap_yaamregs_key, (const void *)&absmi_regs);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#endif /* INDENT_CODE */
|
#endif /* INDENT_CODE */
|
||||||
|
|
||||||
BOp(Ystop, l);
|
BOp(Ystop, l);
|
||||||
LOCAL_CBorder = 0;
|
// LOCAL_CBorder = 0;
|
||||||
SET_ASP(YREG, E_CB * sizeof(CELL));
|
SET_ASP(YREG, E_CB * sizeof(CELL));
|
||||||
/* make sure ASP is initialized */
|
/* make sure ASP is initialized */
|
||||||
saveregs();
|
saveregs();
|
||||||
@ -23,9 +23,10 @@
|
|||||||
LOCAL_CBorder = 0;
|
LOCAL_CBorder = 0;
|
||||||
return 1;
|
return 1;
|
||||||
ENDBOp();
|
ENDBOp();
|
||||||
|
|
||||||
BOp(Nstop, e);
|
BOp(Nstop, e);
|
||||||
SET_ASP(YREG, E_CB * sizeof(CELL));
|
SET_ASP(YREG, E_CB * sizeof(CELL));
|
||||||
|
B = B->cp_b;
|
||||||
saveregs();
|
saveregs();
|
||||||
#if PUSH_REGS
|
#if PUSH_REGS
|
||||||
restore_absmi_regs(old_regs);
|
restore_absmi_regs(old_regs);
|
||||||
|
150
C/c_interface.c
150
C/c_interface.c
@ -1154,6 +1154,10 @@ static uintptr_t complete_exit(choiceptr ptr, int has_cp,
|
|||||||
X_API Int YAP_Execute(PredEntry *pe, CPredicate exec_code) {
|
X_API Int YAP_Execute(PredEntry *pe, CPredicate exec_code) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Int ret;
|
Int ret;
|
||||||
|
yamop *saved_p =P, *saved_cp = CP;
|
||||||
|
yhandle_t s0;
|
||||||
|
|
||||||
|
Int saved_b = LCL0-(CELL*)B, saved_e = LCL0-ENV;
|
||||||
Int OASP = LCL0 - (CELL *)B;
|
Int OASP = LCL0 - (CELL *)B;
|
||||||
// Term omod = CurrentModule;
|
// Term omod = CurrentModule;
|
||||||
// if (pe->PredFlags & CArgsPredFlag) {
|
// if (pe->PredFlags & CArgsPredFlag) {
|
||||||
@ -1164,21 +1168,25 @@ X_API Int YAP_Execute(PredEntry *pe, CPredicate exec_code) {
|
|||||||
struct foreign_context ctx;
|
struct foreign_context ctx;
|
||||||
|
|
||||||
ctx.engine = NULL;
|
ctx.engine = NULL;
|
||||||
yhandle_t s0 = Yap_InitSlots(pe->ArityOfPE, &ARG1);
|
s0 = Yap_InitSlots(pe->ArityOfPE, &ARG1);
|
||||||
PP = pe;
|
PP = pe;
|
||||||
ret = codev(s0, 0, &ctx);
|
ret = codev(s0, 0, &ctx);
|
||||||
} else if (pe->PredFlags & CArgsPredFlag) {
|
} else if (pe->PredFlags & CArgsPredFlag) {
|
||||||
PP = pe;
|
PP = pe;
|
||||||
|
s0 = Yap_CurrentHandle();
|
||||||
ret = execute_cargs(pe, exec_code PASS_REGS);
|
ret = execute_cargs(pe, exec_code PASS_REGS);
|
||||||
} else {
|
} else {
|
||||||
|
s0 = Yap_CurrentHandle();
|
||||||
PP = pe;
|
PP = pe;
|
||||||
ret = (exec_code)(PASS_REGS1);
|
ret = (exec_code)(PASS_REGS1);
|
||||||
}
|
}
|
||||||
PP = NULL;
|
PP = NULL;
|
||||||
// check for junk: open frames, etc */
|
// check for junk: open frames, etc */
|
||||||
|
Yap_closeGoal( ret, saved_p, saved_cp, saved_e, saved_b, s0, true);
|
||||||
|
return ret;
|
||||||
if (ret)
|
if (ret)
|
||||||
complete_exit(((choiceptr)(LCL0 - OASP)), FALSE, FALSE PASS_REGS);
|
complete_exit(((choiceptr)(LCL0 - OASP)), FALSE, FALSE PASS_REGS);
|
||||||
else
|
else
|
||||||
complete_fail(((choiceptr)(LCL0 - OASP)), FALSE PASS_REGS);
|
complete_fail(((choiceptr)(LCL0 - OASP)), FALSE PASS_REGS);
|
||||||
// CurrentModule = omod;
|
// CurrentModule = omod;
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
@ -1195,7 +1203,8 @@ X_API Int YAP_Execute(PredEntry *pe, CPredicate exec_code) {
|
|||||||
X_API Int YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code) {
|
X_API Int YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
CELL ocp = LCL0 - (CELL *)B;
|
CELL ocp = LCL0 - (CELL *)B;
|
||||||
/* for slots to work */
|
|
||||||
|
/* for slots to work */
|
||||||
Int CurSlot = Yap_StartSlots();
|
Int CurSlot = Yap_StartSlots();
|
||||||
if (pe->PredFlags &
|
if (pe->PredFlags &
|
||||||
(SWIEnvPredFlag | CArgsPredFlag | ModuleTransparentPredFlag)) {
|
(SWIEnvPredFlag | CArgsPredFlag | ModuleTransparentPredFlag)) {
|
||||||
@ -1213,30 +1222,29 @@ X_API Int YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code) {
|
|||||||
} else {
|
} else {
|
||||||
val = codev(Yap_InitSlots(pe->ArityOfPE, &ARG1), 0, ctx);
|
val = codev(Yap_InitSlots(pe->ArityOfPE, &ARG1), 0, ctx);
|
||||||
}
|
}
|
||||||
Yap_CloseSlots(CurSlot);
|
|
||||||
PP = NULL;
|
PP = NULL;
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
if (Yap_RaiseException()) {
|
if (Yap_RaiseException()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
return complete_fail(((choiceptr)(LCL0 - ocp)), TRUE PASS_REGS);
|
||||||
|
} else if (val == 1) { /* TRUE */
|
||||||
|
return complete_exit(((choiceptr)(LCL0 - ocp)), TRUE, FALSE PASS_REGS);
|
||||||
|
} else {
|
||||||
|
if ((val & REDO_PTR) == REDO_PTR)
|
||||||
|
ctx->context = (uintptr_t)(val & ~REDO_PTR);
|
||||||
|
else
|
||||||
|
ctx->context = (uintptr_t)((val & ~REDO_PTR) >> FRG_REDO_BITS);
|
||||||
|
/* fix dropped cps */
|
||||||
|
return complete_exit(((choiceptr)(LCL0 - ocp)), FALSE, FALSE PASS_REGS);
|
||||||
}
|
}
|
||||||
return complete_fail(((choiceptr)(LCL0 - ocp)), TRUE PASS_REGS);
|
|
||||||
} else if (val == 1) { /* TRUE */
|
|
||||||
return complete_exit(((choiceptr)(LCL0 - ocp)), TRUE, FALSE PASS_REGS);
|
|
||||||
} else {
|
|
||||||
if ((val & REDO_PTR) == REDO_PTR)
|
|
||||||
ctx->context = (uintptr_t)(val & ~REDO_PTR);
|
|
||||||
else
|
|
||||||
ctx->context = (uintptr_t)((val & ~REDO_PTR) >> FRG_REDO_BITS);
|
|
||||||
/* fix dropped cps */
|
|
||||||
return complete_exit(((choiceptr)(LCL0 - ocp)), FALSE, FALSE PASS_REGS);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Int ret = (exec_code)(PASS_REGS1);
|
Int ret = (exec_code)(PASS_REGS1);
|
||||||
Yap_CloseSlots(CurSlot);
|
Yap_CloseSlots(CurSlot);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
Yap_RaiseException();
|
Yap_RaiseException();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1756,8 +1764,8 @@ X_API bool YAP_EnterGoal(YAP_PredEntryPtr ape, CELL *ptr, YAP_dogoalinfo *dgi) {
|
|||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
PredEntry *pe = ape;
|
PredEntry *pe = ape;
|
||||||
bool out;
|
bool out;
|
||||||
fprintf(stderr,"EnterGoal: H=%ld ENV=%ld B=%ld TR=%ld P=%p CP=%p, Slots=%ld\n",HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, CP,
|
// fprintf(stderr,"EnterGoal: H=%ld ENV=%ld B=%ld TR=%ld P=%p CP=%p, Slots=%ld\n",HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, CP,
|
||||||
LOCAL_CurSlot);
|
// LOCAL_CurSlot);
|
||||||
|
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
LOCAL_ActiveError->errorNo = YAP_NO_ERROR;
|
LOCAL_ActiveError->errorNo = YAP_NO_ERROR;
|
||||||
@ -1822,7 +1830,7 @@ X_API bool YAP_RetryGoal(YAP_dogoalinfo *dgi) {
|
|||||||
out = Yap_exec_absmi(true, true );
|
out = Yap_exec_absmi(true, true );
|
||||||
if (out) {
|
if (out) {
|
||||||
dgi->EndSlot = LOCAL_CurSlot;
|
dgi->EndSlot = LOCAL_CurSlot;
|
||||||
dgi->b = myB;
|
dgi->b = LCL0-(CELL*)myB;
|
||||||
} else {
|
} else {
|
||||||
LOCAL_CurSlot =
|
LOCAL_CurSlot =
|
||||||
dgi->CurSlot; // ignore any slots created within the called goal
|
dgi->CurSlot; // ignore any slots created within the called goal
|
||||||
@ -1833,45 +1841,16 @@ X_API bool YAP_RetryGoal(YAP_dogoalinfo *dgi) {
|
|||||||
|
|
||||||
X_API bool YAP_LeaveGoal(bool successful, YAP_dogoalinfo *dgi) {
|
X_API bool YAP_LeaveGoal(bool successful, YAP_dogoalinfo *dgi) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
choiceptr myB, handler;
|
|
||||||
|
|
||||||
// fprintf(stderr,"LeaveGoal success=%ld: H=%d ENV=%p B=%ldd myB=%ldd TR=%ld
|
// fprintf(stderr,"LeaveGoal success=%ld: H=%d ENV=%p B=%ldd myB=%ldd TR=%ld
|
||||||
// P=%p CP=%p Slots=%ld\n",
|
// P=%p CP=%p Slots=%ld\n",
|
||||||
// successful,HR-H0,LCL0-ENV,LCL0-(CELL*)B,dgi->b0,(CELL*)TR-LCL0, P, CP,
|
// successful,HR-H0,LCL0-ENV,LCL0-(CELL*)B,dgi->b0,(CELL*)TR-LCL0, P, CP,
|
||||||
// LOCAL_CurSlot);
|
// LOCAL_CurSlot);
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
myB = (choiceptr)(LCL0 - dgi->b);
|
Yap_closeGoal(successful, dgi->p, dgi->cp, dgi->b, dgi->e, dgi->CurSlot, true);
|
||||||
if (LOCAL_PrologMode & AsyncIntMode) {
|
|
||||||
Yap_signal(YAP_FAIL_SIGNAL);
|
|
||||||
}
|
|
||||||
handler = B;
|
|
||||||
while (handler &&
|
|
||||||
LCL0 - LOCAL_CBorder > (CELL *)handler
|
|
||||||
//&& handler->cp_ap != NOCODE
|
|
||||||
&& handler->cp_b != NULL && handler != myB) {
|
|
||||||
if (handler < myB) {
|
|
||||||
handler->cp_ap = TRUSTFAILCODE;
|
|
||||||
}
|
|
||||||
B = handler;
|
|
||||||
handler = handler->cp_b;
|
|
||||||
if (successful) {
|
|
||||||
Yap_TrimTrail();
|
|
||||||
} else if (!(LOCAL_PrologMode & AsyncIntMode)) {
|
|
||||||
P = FAILCODE;
|
|
||||||
Yap_exec_absmi(true, YAP_EXEC_ABSMI);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (LOCAL_PrologMode & AsyncIntMode) {
|
|
||||||
Yap_signal(YAP_FAIL_SIGNAL);
|
|
||||||
}
|
|
||||||
P = dgi->p;
|
|
||||||
CP = dgi->cp;
|
|
||||||
ENV = LCL0-dgi->e;
|
|
||||||
ASP = LCL0-dgi->a;
|
|
||||||
B = (choiceptr)(LCL0-dgi->b)
|
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
fprintf(stderr,"LeftGoal success=%ld: H=%ld ENV=%ld B=%ld TR=%ld P=%p CP=%p, Slots=%ld\n", successful,HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P,
|
// fprintf(stderr,"LeftGoal success=%d: H=%ld ENV=%ld B=%ld TR=%ld P=%p CP=%p, Slots=%ld\n", successful,HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P,
|
||||||
CP, LOCAL_CurSlot);
|
// CP, LOCAL_CurSlot);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1963,12 +1942,15 @@ X_API Int YAP_RunGoalOnce(Term t) {
|
|||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Term out;
|
Term out;
|
||||||
yamop *old_CP = CP;
|
yamop *old_CP = CP;
|
||||||
|
yamop *old_P = P;
|
||||||
|
Int old_ENV = LCL0-ENV;
|
||||||
|
Int old_B =LCL0-(CELL*) B;
|
||||||
|
/* Int old_B = LCL0-(CELL*)B */;
|
||||||
Int oldPrologMode = LOCAL_PrologMode;
|
Int oldPrologMode = LOCAL_PrologMode;
|
||||||
yhandle_t CSlot;
|
yhandle_t h = Yap_CurrentHandle();
|
||||||
|
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
CSlot = Yap_StartSlots();
|
LOCAL_PrologMode = UserMode;
|
||||||
LOCAL_PrologMode = UserMode;
|
|
||||||
// Yap_heap_regs->yap_do_low_level_trace=true;
|
// Yap_heap_regs->yap_do_low_level_trace=true;
|
||||||
out = Yap_RunTopGoal(t, true);
|
out = Yap_RunTopGoal(t, true);
|
||||||
LOCAL_PrologMode = oldPrologMode;
|
LOCAL_PrologMode = oldPrologMode;
|
||||||
@ -1979,47 +1961,13 @@ X_API Int YAP_RunGoalOnce(Term t) {
|
|||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
// should we catch the exception or pass it through?
|
Yap_closeGoal( out, old_P, old_CP, old_ENV, old_B, h, true);
|
||||||
// We'll pass it through
|
|
||||||
// Yap_RaiseException();
|
|
||||||
if (out) {
|
|
||||||
choiceptr cut_pt, ob;
|
|
||||||
|
|
||||||
ob = NULL;
|
|
||||||
cut_pt = B;
|
|
||||||
while (cut_pt->cp_ap != NOCODE) {
|
|
||||||
/* make sure we prune C-choicepoints */
|
|
||||||
if (POP_CHOICE_POINT(cut_pt->cp_b)) {
|
|
||||||
POP_EXECUTE();
|
|
||||||
}
|
|
||||||
ob = cut_pt;
|
|
||||||
cut_pt = cut_pt->cp_b;
|
|
||||||
}
|
|
||||||
#ifdef YAPOR
|
|
||||||
CUT_prune_to(cut_pt);
|
|
||||||
#endif
|
|
||||||
if (ob) {
|
|
||||||
B = ob;
|
|
||||||
Yap_TrimTrail();
|
|
||||||
}
|
|
||||||
B = cut_pt;
|
|
||||||
} else {
|
|
||||||
Yap_CloseSlots(CSlot);
|
|
||||||
}
|
|
||||||
ASP = B->cp_env;
|
|
||||||
ENV = (CELL *)ASP[E_E];
|
|
||||||
B = (choiceptr)ASP[E_CB];
|
|
||||||
#ifdef DEPTH_LIMITxs
|
|
||||||
DEPTH = ASP[E_DEPTH];
|
|
||||||
#endif
|
|
||||||
P = (yamop *)ASP[E_CP];
|
|
||||||
CP = old_CP;
|
|
||||||
LOCAL_AllowRestart = FALSE;
|
|
||||||
RECOVER_MACHINE_REGS();
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API bool YAP_RestartGoal(void) {
|
|
||||||
|
X_API
|
||||||
|
bool YAP_RestartGoal(void) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
bool out;
|
bool out;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/************************************************************************\
|
/************************************************************************ \
|
||||||
* Cut & Commit Inst
|
* Cut & Commit Inst
|
||||||
|
|
||||||
ructions *
|
ructions *
|
||||||
|
@ -1254,7 +1254,7 @@ static Int is_callable(USES_REGS1) {
|
|||||||
// Term Context = Deref(ARG2);
|
// Term Context = Deref(ARG2);
|
||||||
while (true) {
|
while (true) {
|
||||||
if (IsVarTerm(G)) {
|
if (IsVarTerm(G)) {
|
||||||
Yap_ThrowError(INSTANTIATION_ERROR, G, NULL);
|
//Yap_ThrowError(INSTANTIATION_ERROR, G, NULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (IsApplTerm(G)) {
|
if (IsApplTerm(G)) {
|
||||||
|
153
C/exec.c
153
C/exec.c
@ -831,6 +831,7 @@ static void prune_inner_computation(choiceptr parent) {
|
|||||||
* @method complete_inner_computation
|
* @method complete_inner_computation
|
||||||
*/
|
*/
|
||||||
static void complete_inner_computation(choiceptr old_B) {
|
static void complete_inner_computation(choiceptr old_B) {
|
||||||
|
return;
|
||||||
choiceptr myB = B;
|
choiceptr myB = B;
|
||||||
if (myB == NULL) {
|
if (myB == NULL) {
|
||||||
return;
|
return;
|
||||||
@ -1062,9 +1063,7 @@ static Int cleanup_on_exit(USES_REGS1) {
|
|||||||
complete_pt[0] = TermExit;
|
complete_pt[0] = TermExit;
|
||||||
}
|
}
|
||||||
Yap_ignore(cleanup, false);
|
Yap_ignore(cleanup, false);
|
||||||
if (B0->cp_ap == NOCODE)
|
if (Yap_RaiseException()) {
|
||||||
B0->cp_ap = TRUSTFAILCODE;
|
|
||||||
if (Yap_RaiseException()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1097,7 +1096,7 @@ static Int _user_expand_goal(USES_REGS1) {
|
|||||||
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
pe->OpcodeOfPred != FAIL_OPCODE && pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||||
Yap_execute_pred(pe, NULL, false PASS_REGS)) {
|
Yap_execute_pred(pe, NULL, false PASS_REGS)) {
|
||||||
return complete_ge(true , omod, sl, creeping);
|
return complete_ge(true , omod, sl, creeping);
|
||||||
}
|
};
|
||||||
/* system:goal_expansion(A,B) */
|
/* system:goal_expansion(A,B) */
|
||||||
mg_args[0] = cmod;
|
mg_args[0] = cmod;
|
||||||
mg_args[1] = Yap_GetFromSlot(h1);
|
mg_args[1] = Yap_GetFromSlot(h1);
|
||||||
@ -1567,11 +1566,9 @@ static bool exec_absmi(bool top, yap_reset_t reset_mode USES_REGS) {
|
|||||||
/* can be called from anywhere, must reset registers,
|
/* can be called from anywhere, must reset registers,
|
||||||
*/
|
*/
|
||||||
// LOCAL_ActiveError = err_info;
|
// LOCAL_ActiveError = err_info;
|
||||||
while (B) {
|
if (B) {
|
||||||
LOCAL_ActiveError->errorNo = ABORT_EVENT;
|
LOCAL_ActiveError->errorNo = ABORT_EVENT;
|
||||||
pop_text_stack(i + 1);
|
Yap_JumpToEnv();
|
||||||
Yap_CloseSlots(sls);
|
|
||||||
Yap_JumpToEnv();
|
|
||||||
}
|
}
|
||||||
LOCAL_PrologMode = UserMode;
|
LOCAL_PrologMode = UserMode;
|
||||||
LOCAL_DoingUndefp = false;
|
LOCAL_DoingUndefp = false;
|
||||||
@ -1739,20 +1736,7 @@ void Yap_fail_all(choiceptr bb USES_REGS) {
|
|||||||
P = saved_p;
|
P = saved_p;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Yap_execute_pred(PredEntry *ppe, CELL *pt, bool pass_ex USES_REGS) {
|
void Yap_closeGoal(bool out, yamop *saved_p, yamop * saved_cp, Int saved_e, Int saved_b, yhandle_t bnd, bool pass_ex) {
|
||||||
yamop *saved_p, *saved_cp;
|
|
||||||
yamop *CodeAdr;
|
|
||||||
bool out;
|
|
||||||
|
|
||||||
saved_p = P;
|
|
||||||
saved_cp = CP;
|
|
||||||
LOCAL_PrologMode |= TopGoalMode;
|
|
||||||
|
|
||||||
PELOCK(81, ppe);
|
|
||||||
CodeAdr = ppe->CodeOfPred;
|
|
||||||
UNLOCK(ppe->PELock);
|
|
||||||
out = do_goal(CodeAdr, ppe->ArityOfPE, pt, false PASS_REGS);
|
|
||||||
|
|
||||||
if (out) {
|
if (out) {
|
||||||
choiceptr cut_B;
|
choiceptr cut_B;
|
||||||
/* we succeeded, let's prune */
|
/* we succeeded, let's prune */
|
||||||
@ -1764,69 +1748,89 @@ bool Yap_execute_pred(PredEntry *ppe, CELL *pt, bool pass_ex USES_REGS) {
|
|||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
if (B != cut_B) {
|
if (B != cut_B) {
|
||||||
|
|
||||||
while (B->cp_b < cut_B) {
|
while (B->cp_b < cut_B) {
|
||||||
B = B->cp_b;
|
if (B->cp_ap == NOCODE)
|
||||||
}
|
break;
|
||||||
|
B = B->cp_b;
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
abolish_incomplete_subgoals(B);
|
abolish_incomplete_subgoals(B);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
B = cut_B;
|
B = (choiceptr)(LCL0-saved_b);
|
||||||
CP = saved_cp;
|
CP = saved_cp;
|
||||||
P = saved_p;
|
P = saved_p;
|
||||||
ASP = ENV;
|
ASP = ENV;
|
||||||
|
ENV = LCL0-saved_e;
|
||||||
#ifdef DEPTH_LIMIT
|
#ifdef DEPTH_LIMIT
|
||||||
DEPTH = ENV[E_DEPTH];
|
DEPTH = ENV[E_DEPTH];
|
||||||
#endif
|
#endif
|
||||||
ENV = (CELL *)(ENV[E_E]);
|
|
||||||
/* we have failed, and usually we would backtrack to this B,
|
/* we have failed, and usually we would backtrack to this B,
|
||||||
trouble is, we may also have a delayed cut to do */
|
trouble is, we may also have a delayed cut to do */
|
||||||
if (B != NULL)
|
if (B != NULL) {
|
||||||
HB = B->cp_h;
|
HB = B->cp_h;
|
||||||
|
Yap_TrimTrail();
|
||||||
|
}
|
||||||
YENV = ENV;
|
YENV = ENV;
|
||||||
|
} else if (out == 0) {
|
||||||
|
/* ASP should be set to the top of the local stack when we
|
||||||
|
did the call */
|
||||||
|
choiceptr b0 =(choiceptr)(LCL0-saved_b);
|
||||||
|
while (B && B < b0 && B->cp_ap !=NOCODE) {
|
||||||
|
B->cp_ap = TRUSTFAILCODE;
|
||||||
|
B = B->cp_b;
|
||||||
|
}
|
||||||
|
if (B<b0) {
|
||||||
|
P = FAILCODE;
|
||||||
|
exec_absmi(true, YAP_EXEC_ABSMI PASS_REGS);
|
||||||
|
}
|
||||||
|
B = b0;
|
||||||
|
#ifdef DEPTH_LIMIT
|
||||||
|
DEPTH = B->cp_depth;
|
||||||
|
#endif
|
||||||
|
P = saved_p;
|
||||||
|
CP = saved_cp;
|
||||||
|
|
||||||
|
/* YENV should be set to the current environment */
|
||||||
|
YENV = ENV = LCL0-saved_e;
|
||||||
|
SET_BB(B);
|
||||||
|
HB = PROTECT_FROZEN_H(B);
|
||||||
|
} else {
|
||||||
|
Yap_ThrowError(SYSTEM_ERROR_INTERNAL, TermNil, "emulator crashed");
|
||||||
|
}
|
||||||
// should we catch the exception or pass it through?
|
// should we catch the exception or pass it through?
|
||||||
// We'll pass it through
|
// We'll pass it through
|
||||||
if ( Yap_HasException()) {
|
if ( Yap_HasException()) {
|
||||||
if (pass_ex &&
|
if (pass_ex) {
|
||||||
((LOCAL_PrologMode & BootMode) || !CurrentModule )) {
|
if ((LOCAL_PrologMode & BootMode) || !CurrentModule) {
|
||||||
Yap_ResetException(LOCAL_ActiveError);
|
Yap_ResetException(LOCAL_ActiveError);
|
||||||
} else {
|
} else {
|
||||||
Yap_RaiseException();
|
Yap_RaiseException();
|
||||||
}
|
}
|
||||||
return false;
|
} else {
|
||||||
|
Yap_ResetException(LOCAL_ActiveError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
}
|
||||||
} else if (out == 0) {
|
|
||||||
P = saved_p;
|
bool Yap_execute_pred(PredEntry *ppe, CELL *pt, bool pass_ex USES_REGS) {
|
||||||
CP = saved_cp;
|
yamop *saved_p, *saved_cp;
|
||||||
HR = B->cp_h;
|
yamop *CodeAdr;
|
||||||
#ifdef DEPTH_LIMIT
|
|
||||||
DEPTH = B->cp_depth;
|
yhandle_t curh = Yap_CurrentHandle( );
|
||||||
#endif
|
Int saved_b = LCL0-(CELL*)B, saved_e = LCL0-ENV;
|
||||||
/* ASP should be set to the top of the local stack when we
|
saved_p = P;
|
||||||
did the call */
|
saved_cp = CP;
|
||||||
ASP = B->cp_env;
|
LOCAL_PrologMode |= TopGoalMode;
|
||||||
/* YENV should be set to the current environment */
|
|
||||||
YENV = ENV = (CELL *)((B->cp_env)[E_E]);
|
PELOCK(81, ppe);
|
||||||
B = B->cp_b;
|
CodeAdr = ppe->CodeOfPred;
|
||||||
SET_BB(B);
|
UNLOCK(ppe->PELock);
|
||||||
HB = PROTECT_FROZEN_H(B);
|
bool out = do_goal(CodeAdr, ppe->ArityOfPE, pt, false PASS_REGS);
|
||||||
// should we catch the exception or pass it through?
|
Yap_closeGoal( out, saved_p, saved_cp, saved_e, saved_b, curh, pass_ex);
|
||||||
// We'll pass it through
|
return out;
|
||||||
if ( Yap_HasException()) {
|
|
||||||
if (pass_ex &&
|
|
||||||
((LOCAL_PrologMode & BootMode) || !CurrentModule )) {
|
|
||||||
Yap_ResetException(LOCAL_ActiveError);
|
|
||||||
} else {
|
|
||||||
Yap_RaiseException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
Yap_ThrowError(SYSTEM_ERROR_INTERNAL, TermNil, "emulator crashed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Yap_execute_goal(Term t, int nargs, Term mod, bool pass_ex) {
|
bool Yap_execute_goal(Term t, int nargs, Term mod, bool pass_ex) {
|
||||||
@ -2078,7 +2082,7 @@ static Int clean_ifcp(USES_REGS1) {
|
|||||||
}
|
}
|
||||||
B = B->cp_b;
|
B = B->cp_b;
|
||||||
HB = B->cp_h;
|
HB = B->cp_h;
|
||||||
} else {
|
} else if (pt0->cp_ap != NOCODE){
|
||||||
pt0->cp_ap = (yamop *)TRUSTFAILCODE;
|
pt0->cp_ap = (yamop *)TRUSTFAILCODE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -2129,11 +2133,18 @@ bool Yap_Reset(yap_reset_t mode, bool hard) {
|
|||||||
|
|
||||||
Yap_ResetException(worker_id);
|
Yap_ResetException(worker_id);
|
||||||
/* first, backtrack to the root */
|
/* first, backtrack to the root */
|
||||||
|
choiceptr ob;
|
||||||
|
|
||||||
while (B) {
|
while (B) {
|
||||||
P = FAILCODE;
|
ob = B;
|
||||||
Yap_exec_absmi(true, mode);
|
|
||||||
B = B->cp_b;
|
B = B->cp_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ob) {
|
||||||
|
B = ob;
|
||||||
|
P = FAILCODE;
|
||||||
|
Yap_exec_absmi(true, mode);
|
||||||
|
}
|
||||||
/* reinitialize the engine */
|
/* reinitialize the engine */
|
||||||
Yap_InitYaamRegs(worker_id, false);
|
Yap_InitYaamRegs(worker_id, false);
|
||||||
GLOBAL_Initialised = true;
|
GLOBAL_Initialised = true;
|
||||||
@ -2166,6 +2177,8 @@ bool is_cleanup_cp(choiceptr cp_b) {
|
|||||||
|
|
||||||
static Int JumpToEnv(USES_REGS1) {
|
static Int JumpToEnv(USES_REGS1) {
|
||||||
choiceptr handler = B;
|
choiceptr handler = B;
|
||||||
|
if (B->cp_ap == NOCODE)
|
||||||
|
return false;
|
||||||
/* just keep the throwm object away, we don't need to care about it
|
/* just keep the throwm object away, we don't need to care about it
|
||||||
*/
|
*/
|
||||||
/* careful, previous step may have caused a stack shift,
|
/* careful, previous step may have caused a stack shift,
|
||||||
@ -2175,7 +2188,7 @@ static Int JumpToEnv(USES_REGS1) {
|
|||||||
while (handler && Yap_PredForChoicePt(handler, NULL) != PredDollarCatch &&
|
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) {
|
handler->cp_b != NULL) {
|
||||||
handler->cp_ap = TRUSTFAILCODE;
|
handler->cp_ap = FAILCODE;
|
||||||
handler = handler->cp_b;
|
handler = handler->cp_b;
|
||||||
}
|
}
|
||||||
if (LOCAL_PrologMode & AsyncIntMode) {
|
if (LOCAL_PrologMode & AsyncIntMode) {
|
||||||
|
@ -207,7 +207,7 @@ extern Term Yap_RunTopGoal(Term, bool);
|
|||||||
extern bool Yap_execute_goal(Term, int, Term, bool);
|
extern bool Yap_execute_goal(Term, int, Term, bool);
|
||||||
extern bool Yap_exec_absmi(bool, yap_reset_t);
|
extern bool Yap_exec_absmi(bool, yap_reset_t);
|
||||||
extern void Yap_trust_last(void);
|
extern void Yap_trust_last(void);
|
||||||
|
extern void Yap_closeGoal(bool out, yamop *saved_p, yamop * saved_cp, Int saved_e, Int saved_b, yhandle_t hdl, bool pass_ex);
|
||||||
extern void Yap_PrepGoal(UInt, CELL *, choiceptr USES_REGS);
|
extern void Yap_PrepGoal(UInt, CELL *, choiceptr USES_REGS);
|
||||||
extern bool Yap_execute_pred(struct pred_entry *ppe, CELL *pt,
|
extern bool Yap_execute_pred(struct pred_entry *ppe, CELL *pt,
|
||||||
bool pass_exception USES_REGS);
|
bool pass_exception USES_REGS);
|
||||||
|
@ -15,7 +15,7 @@ cd $PREFIX/conda
|
|||||||
$CMAKE --build=. --target=install \
|
$CMAKE --build=. --target=install \
|
||||||
-DCMAKE_BUILD_TYPE=Debug \
|
-DCMAKE_BUILD_TYPE=Debug \
|
||||||
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
|
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
|
||||||
$RECIPE_DIR/..
|
$RECIPE_DIR/.. -DWITH_CUDD=NO -DWITH_GECODE=NO -DWITH_JAVA=NO -DWITH_RAPTOR=NO
|
||||||
|
|
||||||
make -j install
|
make -j install
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user