improve SWI predicate calling: fix bug in non-deterministic calls.

This commit is contained in:
Vítor Santos Costa 2011-03-14 20:54:19 +00:00
parent ae702e6dd5
commit 839d612367
2 changed files with 12 additions and 6 deletions

View File

@ -2130,6 +2130,7 @@ PL_open_foreign_frame(void)
new->open = FALSE; new->open = FALSE;
new->cp = CP; new->cp = CP;
new->p = P; new->p = P;
new->b = (CELL)(LCL0-(CELL*)B);
new->slots = CurSlot; new->slots = CurSlot;
execution = new; execution = new;
{ {
@ -2157,8 +2158,8 @@ PL_close_foreign_frame(fid_t f)
CP = env->cp; CP = env->cp;
P = env->p; P = env->p;
CurSlot = env->slots; CurSlot = env->slots;
ASP = (CELL *)(B+1); B = (choiceptr)(LCL0-env->b);
B = B->cp_b; ASP = (CELL *)(LCL0-CurSlot);
execution = env->old; execution = env->old;
free(env); free(env);
} }
@ -2171,7 +2172,6 @@ backtrack(void)
Yap_absmi(0); Yap_absmi(0);
H = HB = B->cp_h; H = HB = B->cp_h;
TR = B->cp_tr; TR = B->cp_tr;
TR = B->cp_tr;
} }
X_API void X_API void
@ -2180,7 +2180,11 @@ PL_rewind_foreign_frame(fid_t f)
CACHE_REGS CACHE_REGS
open_query *env = (open_query *)f; open_query *env = (open_query *)f;
CurSlot = env->slots; CurSlot = env->slots;
while (B->cp_b != (choiceptr)(LCL0-env->b))
B = B->cp_b;
backtrack(); backtrack();
ASP = (CELL *)B;
Yap_StartSlots( PASS_REGS1 );
} }
X_API void X_API void
@ -2189,11 +2193,13 @@ PL_discard_foreign_frame(fid_t f)
CACHE_REGS CACHE_REGS
open_query *env = (open_query *)f; open_query *env = (open_query *)f;
CurSlot = env->slots; CurSlot = env->slots;
while (B->cp_b != (choiceptr)(LCL0-env->b))
B = B->cp_b;
backtrack(); backtrack();
CP = env->cp; CP = env->cp;
P = env->p; P = env->p;
execution = execution->old; execution = execution->old;
ASP = (CELL *)(B+1); ASP = LCL0-CurSlot;
B = B->cp_b; B = B->cp_b;
free(env); free(env);
} }
@ -2960,7 +2966,7 @@ term_t Yap_CvtTerm(term_t ts)
} }
} else if (f == FunctorDBRef) { } else if (f == FunctorDBRef) {
Term ta[0]; Term ta[0];
ta[0] = MkIntegerTerm(DBRefOfTerm(t)); ta[0] = MkIntegerTerm((Int)DBRefOfTerm(t));
return Yap_InitSlot(Yap_MkApplTerm(FunctorDBREF, 1, ta) PASS_REGS); return Yap_InitSlot(Yap_MkApplTerm(FunctorDBREF, 1, ta) PASS_REGS);
} }
} }

View File

@ -47,7 +47,7 @@ typedef struct open_query_struct {
int state; int state;
YAP_Term g; YAP_Term g;
yamop *p, *cp; yamop *p, *cp;
Int slots; Int slots, b;
jmp_buf env; jmp_buf env;
struct open_query_struct *old; struct open_query_struct *old;
} open_query; } open_query;