fix slot at init

This commit is contained in:
Vitor Santos Costa 2015-02-09 10:20:19 +00:00
parent 2ca29d208f
commit 5a7602dfff
1 changed files with 10 additions and 7 deletions

View File

@ -2790,7 +2790,6 @@ do_bootfile (char *bootfilename USES_REGS)
Term term_end_of_file = MkAtomTerm(AtomEof); Term term_end_of_file = MkAtomTerm(AtomEof);
Term term_true = YAP_MkAtomTerm(AtomTrue); Term term_true = YAP_MkAtomTerm(AtomTrue);
Functor functor_query = Yap_MkFunctor(Yap_LookupAtom("?-"),1); Functor functor_query = Yap_MkFunctor(Yap_LookupAtom("?-"),1);
yhandle_t CurSlot = Yap_StartSlots();
/* consult boot.pl */ /* consult boot.pl */
/* the consult mode does not matter here, really */ /* the consult mode does not matter here, really */
@ -2807,10 +2806,10 @@ do_bootfile (char *bootfilename USES_REGS)
while (!eof_found) while (!eof_found)
{ {
CACHE_REGS CACHE_REGS
Yap_StartSlots( ); yhandle_t CurSlot = Yap_StartSlots( );
t = YAP_Read(bootfile); t = YAP_Read(bootfile);
Yap_CloseSlots(CurSlot);
if (eof_found) { if (eof_found) {
Yap_CloseSlots(CurSlot);
break; break;
} }
if (t == 0) if (t == 0)
@ -2820,14 +2819,17 @@ do_bootfile (char *bootfilename USES_REGS)
} }
if (YAP_IsVarTerm (t) || t == TermNil) if (YAP_IsVarTerm (t) || t == TermNil)
{ {
Yap_CloseSlots(CurSlot);
continue; continue;
} }
else if (t == term_true) else if (t == term_true)
{ {
Yap_CloseSlots(CurSlot);
Yap_exit(0); Yap_exit(0);
} }
else if (t == term_end_of_file) else if (t == term_end_of_file)
{ {
Yap_CloseSlots(CurSlot);
break; break;
} }
else if (YAP_IsPairTerm (t)) else if (YAP_IsPairTerm (t))
@ -2845,6 +2847,7 @@ do_bootfile (char *bootfilename USES_REGS)
if (ErrorMessage) if (ErrorMessage)
fprintf(stderr, "%s", ErrorMessage); fprintf(stderr, "%s", ErrorMessage);
} }
Yap_CloseSlots(CurSlot);
/* do backtrack */ /* do backtrack */
YAP_Reset( YAP_FULL_RESET ); YAP_Reset( YAP_FULL_RESET );
} }