call fixes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/************************************************************************* *
|
||||
/************************************************************************* *
|
||||
* YAP Prolog *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
@@ -1749,7 +1749,7 @@ X_API bool YAP_EnterGoal(YAP_PredEntryPtr ape, CELL *ptr, YAP_dogoalinfo *dgi) {
|
||||
dgi->p = P;
|
||||
dgi->cp = CP;
|
||||
dgi->b0 = LCL0 - (CELL *)B;
|
||||
dgi->CurSlot = LOCAL_CurSlot;
|
||||
printf("%ld\n", dgi->CurSlot);
|
||||
// ensure our current ENV receives current P.
|
||||
|
||||
Yap_PrepGoal(pe->ArityOfPE, nullptr, B PASS_REGS);
|
||||
@@ -1757,7 +1757,7 @@ X_API bool YAP_EnterGoal(YAP_PredEntryPtr ape, CELL *ptr, YAP_dogoalinfo *dgi) {
|
||||
// __android_log_print(ANDROID_LOG_INFO, "YAP ", "ap=%p %d %x %x args=%x,%x
|
||||
// slot=%d", pe, pe->CodeOfPred->opc, FAILCODE, Deref(ARG1), Deref(ARG2),
|
||||
// LOCAL_CurSlot);
|
||||
dgi->b = LCL0 - (CELL *)B;
|
||||
dgi->b_entry = LCL0 - (CELL *)B;
|
||||
dgi->h = HR - H0;
|
||||
dgi->tr = (CELL *)TR - LCL0;
|
||||
// fprintf(stderr,"PrepGoal: H=%d ENV=%p B=%d TR=%d P=%p CP=%p Slots=%d\n",
|
||||
@@ -1766,11 +1766,12 @@ X_API bool YAP_EnterGoal(YAP_PredEntryPtr ape, CELL *ptr, YAP_dogoalinfo *dgi) {
|
||||
// fprintf(stderr,"EnterGoal success=%d: H=%d ENV=%p B=%d TR=%d P=%p CP=%p
|
||||
// Slots=%d\n", out,HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P, CP,
|
||||
// LOCAL_CurSlot);
|
||||
dgi->b = LCL0 - (CELL *)B;
|
||||
dgi->b_exit = LCL0 - (CELL *)B;
|
||||
if (out) {
|
||||
dgi->EndSlot = LOCAL_CurSlot;
|
||||
Yap_StartSlots();
|
||||
} else {
|
||||
printf("%ld\n", dgi->CurSlot);
|
||||
LOCAL_CurSlot =
|
||||
dgi->CurSlot; // ignore any slots created within the called goal
|
||||
}
|
||||
@@ -1784,8 +1785,8 @@ X_API bool YAP_RetryGoal(YAP_dogoalinfo *dgi) {
|
||||
bool out;
|
||||
|
||||
BACKUP_MACHINE_REGS();
|
||||
myB = (choiceptr)(LCL0 - dgi->b);
|
||||
myB0 = (choiceptr)(LCL0 - dgi->b0);
|
||||
myB = (choiceptr)(LCL0 - dgi->b_exit);
|
||||
myB0 = (choiceptr)(LCL0 - dgi->b_entry);
|
||||
CP = myB->cp_cp;
|
||||
/* sanity check */
|
||||
if (B >= myB0) {
|
||||
@@ -1804,8 +1805,9 @@ X_API bool YAP_RetryGoal(YAP_dogoalinfo *dgi) {
|
||||
out = Yap_exec_absmi(true, true );
|
||||
if (out) {
|
||||
dgi->EndSlot = LOCAL_CurSlot;
|
||||
dgi->b = LCL0 - (CELL *)B;
|
||||
dgi->b_exit = LCL0 - (CELL *)B;
|
||||
} else {
|
||||
printf("F %ld\n", dgi->CurSlot);
|
||||
LOCAL_CurSlot =
|
||||
dgi->CurSlot; // ignore any slots created within the called goal
|
||||
}
|
||||
@@ -1815,39 +1817,28 @@ X_API bool YAP_RetryGoal(YAP_dogoalinfo *dgi) {
|
||||
|
||||
X_API bool YAP_LeaveGoal(bool successful, YAP_dogoalinfo *dgi) {
|
||||
CACHE_REGS
|
||||
choiceptr myB, handler;
|
||||
|
||||
// fprintf(stderr,"LeaveGoal success=%d: H=%d ENV=%p B=%ld myB=%ld TR=%d
|
||||
// P=%p CP=%p Slots=%d\n",
|
||||
// successful,HR-H0,LCL0-ENV,LCL0-(CELL*)B,dgi->b0,(CELL*)TR-LCL0, P, CP,
|
||||
// LOCAL_CurSlot);
|
||||
BACKUP_MACHINE_REGS();
|
||||
myB = (choiceptr)(LCL0 - dgi->b);
|
||||
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) {
|
||||
choiceptr nB = (choiceptr)(LCL0 - dgi->b_entry);
|
||||
if (B <= nB) {
|
||||
B = nB;
|
||||
}
|
||||
Yap_TrimTrail();
|
||||
} else if (!(LOCAL_PrologMode & AsyncIntMode)) {
|
||||
P = FAILCODE;
|
||||
Yap_exec_absmi(true, YAP_EXEC_ABSMI);
|
||||
}
|
||||
}
|
||||
if (LOCAL_PrologMode & AsyncIntMode) {
|
||||
B = B->cp_b;
|
||||
} else if (LOCAL_PrologMode & AsyncIntMode) {
|
||||
Yap_signal(YAP_FAIL_SIGNAL);
|
||||
}
|
||||
B = (choiceptr)(LCL0 - dgi->b0);
|
||||
P = dgi->p;
|
||||
CP = dgi->cp;
|
||||
LOCAL_CurSlot =
|
||||
dgi->CurSlot; // ignore any slots created within the called goal
|
||||
printf("L %ld\n", dgi->CurSlot);
|
||||
RECOVER_MACHINE_REGS();
|
||||
// fprintf(stderr,"LeftGoal success=%d: H=%d ENV=%p B=%d TR=%d P=%p CP=%p
|
||||
// Slots=%d\n", successful,HR-H0,LCL0-ENV,LCL0-(CELL*)B,(CELL*)TR-LCL0, P,
|
||||
@@ -1942,7 +1933,7 @@ X_API CELL *YAP_HeapStoreOpaqueTerm(Term t) {
|
||||
X_API Int YAP_RunGoalOnce(Term t) {
|
||||
CACHE_REGS
|
||||
Term out;
|
||||
yamop *old_CP = CP;
|
||||
yamop *old_CP = CP, *old_P = P;
|
||||
Int oldPrologMode = LOCAL_PrologMode;
|
||||
yhandle_t CSlot;
|
||||
|
||||
@@ -1989,10 +1980,10 @@ X_API Int YAP_RunGoalOnce(Term t) {
|
||||
ASP = B->cp_env;
|
||||
ENV = (CELL *)ASP[E_E];
|
||||
B = (choiceptr)ASP[E_CB];
|
||||
#ifdef DEPTH_LIMITxs
|
||||
#ifdef DEPTH_LIMIT
|
||||
DEPTH = ASP[E_DEPTH];
|
||||
#endif
|
||||
P = (yamop *)ASP[E_CP];
|
||||
P = old_P;
|
||||
CP = old_CP;
|
||||
LOCAL_AllowRestart = FALSE;
|
||||
RECOVER_MACHINE_REGS();
|
||||
@@ -2078,7 +2069,7 @@ X_API void YAP_PruneGoal(YAP_dogoalinfo *gi) {
|
||||
CACHE_REGS
|
||||
BACKUP_B();
|
||||
|
||||
choiceptr myB = (choiceptr)(LCL0 - gi->b);
|
||||
choiceptr myB = (choiceptr)(LCL0 - gi->b_entry);
|
||||
while (B != myB) {
|
||||
/* make sure we prune C-choicepoints */
|
||||
if (POP_CHOICE_POINT(B->cp_b)) {
|
||||
|
Reference in New Issue
Block a user