diff --git a/C/c_interface.c b/C/c_interface.c index 4ff55d9d6..eef287b9f 100755 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -2054,7 +2054,6 @@ YAP_RestartGoal(void) { int out; BACKUP_MACHINE_REGS(); - if (Yap_AllowRestart) { P = (yamop *)FAILCODE; do_putcf = myputc; @@ -2650,6 +2649,8 @@ YAP_Init(YAP_init_args *yap_init) /* first, initialise the saved state */ Term t_goal = MkAtomTerm(AtomStartupSavedState); YAP_RunGoalOnce(t_goal); + Yap_InitYaamRegs(); + /* reset stacks */ return YAP_BOOT_FROM_SAVED_CODE; } else { return YAP_BOOT_FROM_SAVED_STACKS; @@ -2681,6 +2682,8 @@ YAP_Init(YAP_init_args *yap_init) fgoal = Yap_MkFunctor(Yap_LookupAtom("module"), 1); goal = Yap_MkApplTerm(fgoal, 1, as); YAP_RunGoalOnce(goal); + /* reset stacks */ + Yap_InitYaamRegs(); } Yap_PutValue(Yap_FullLookupAtom("$live"), MkAtomTerm (Yap_FullLookupAtom("$true"))); } diff --git a/C/exec.c b/C/exec.c index ca5c9b1db..7850e88f5 100644 --- a/C/exec.c +++ b/C/exec.c @@ -1021,9 +1021,6 @@ init_stack(int arity, CELL *pt, int top, choiceptr saved_b) collection is going up in the environment chain it doesn't get confused */ EX = NULL; - /* always have an empty slots for people to use */ - CurSlot = 0; - Yap_StartSlots(); // sl = Yap_InitSlot(t); YENV = ASP; YENV[E_CP] = (CELL)P; @@ -1644,6 +1641,7 @@ Yap_InitYaamRegs(void) EX = NULL; init_stack(0, NULL, TRUE, NULL); /* the first real choice-point will also have AP=FAIL */ + /* always have an empty slots for people to use */ CurSlot = 0; GlobalArena = TermNil; h0var = MkVarTerm(); diff --git a/library/dialect/swi/fli/swi.c b/library/dialect/swi/fli/swi.c index 53ac71acf..611d567b5 100755 --- a/library/dialect/swi/fli/swi.c +++ b/library/dialect/swi/fli/swi.c @@ -2578,12 +2578,7 @@ X_API qid_t PL_open_query(module_t ctx, int flags, predicate_t p, term_t t0) Term t[2], m; /* ignore flags and module for now */ - if (execution == NULL) - PL_open_foreign_frame(); - if (execution->open != 0) { - YAP_Error(0, 0L, "only one query at a time allowed\n"); - return FALSE; - } + PL_open_foreign_frame(); execution->open=1; execution->state=0; PredicateInfo((PredEntry *)p, &yname, &arity, &m); @@ -2617,13 +2612,13 @@ X_API qid_t PL_open_query(module_t ctx, int flags, predicate_t p, term_t t0) X_API int PL_next_solution(qid_t qi) { int result; - if (qi->open != 1) return 0; if (setjmp(execution->env)) return 0; if (qi->state == 0) { result = YAP_RunGoal(qi->g); } else { + Yap_AllowRestart = qi->open; result = YAP_RestartGoal(); } qi->state = 1;