Merge branch 'master' of ../yap-6.2

This commit is contained in:
Vítor Santos Costa 2010-12-14 12:40:15 +00:00
commit 782fe00123
6 changed files with 36 additions and 21 deletions

View File

@ -2054,7 +2054,6 @@ YAP_RestartGoal(void)
{ {
int out; int out;
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
if (Yap_AllowRestart) { if (Yap_AllowRestart) {
P = (yamop *)FAILCODE; P = (yamop *)FAILCODE;
do_putcf = myputc; do_putcf = myputc;
@ -2650,6 +2649,8 @@ YAP_Init(YAP_init_args *yap_init)
/* first, initialise the saved state */ /* first, initialise the saved state */
Term t_goal = MkAtomTerm(AtomStartupSavedState); Term t_goal = MkAtomTerm(AtomStartupSavedState);
YAP_RunGoalOnce(t_goal); YAP_RunGoalOnce(t_goal);
Yap_InitYaamRegs();
/* reset stacks */
return YAP_BOOT_FROM_SAVED_CODE; return YAP_BOOT_FROM_SAVED_CODE;
} else { } else {
return YAP_BOOT_FROM_SAVED_STACKS; return YAP_BOOT_FROM_SAVED_STACKS;
@ -2681,6 +2682,8 @@ YAP_Init(YAP_init_args *yap_init)
fgoal = Yap_MkFunctor(Yap_LookupAtom("module"), 1); fgoal = Yap_MkFunctor(Yap_LookupAtom("module"), 1);
goal = Yap_MkApplTerm(fgoal, 1, as); goal = Yap_MkApplTerm(fgoal, 1, as);
YAP_RunGoalOnce(goal); YAP_RunGoalOnce(goal);
/* reset stacks */
Yap_InitYaamRegs();
} }
Yap_PutValue(Yap_FullLookupAtom("$live"), MkAtomTerm (Yap_FullLookupAtom("$true"))); Yap_PutValue(Yap_FullLookupAtom("$live"), MkAtomTerm (Yap_FullLookupAtom("$true")));
} }

View File

@ -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 collection is going up in the environment chain it doesn't get
confused */ confused */
EX = NULL; EX = NULL;
/* always have an empty slots for people to use */
CurSlot = 0;
Yap_StartSlots();
// sl = Yap_InitSlot(t); // sl = Yap_InitSlot(t);
YENV = ASP; YENV = ASP;
YENV[E_CP] = (CELL)P; YENV[E_CP] = (CELL)P;
@ -1644,6 +1641,7 @@ Yap_InitYaamRegs(void)
EX = NULL; EX = NULL;
init_stack(0, NULL, TRUE, NULL); init_stack(0, NULL, TRUE, NULL);
/* the first real choice-point will also have AP=FAIL */ /* the first real choice-point will also have AP=FAIL */
/* always have an empty slots for people to use */
CurSlot = 0; CurSlot = 0;
GlobalArena = TermNil; GlobalArena = TermNil;
h0var = MkVarTerm(); h0var = MkVarTerm();

View File

@ -189,7 +189,9 @@ goal_expansion(open_null_stream(A), system:swi_open_null_stream(A)) :- swi_io.
/* SWI specific */ /* SWI specific */
goal_expansion(is_stream(A), system:swi_is_stream(A)) :- swi_io. goal_expansion(is_stream(A), system:swi_is_stream(A)) :- swi_io.
goal_expansion(set_stream(A,B),system:swi_set_stream(A,B)) :- swi_io. goal_expansion(set_stream(A,B),system:swi_set_stream(A,B)) :- swi_io.
goal_expansion(with_output_to(A,B),system:swi_with_output_to(A,B)) :- swi_io. % careful: with_output_to/2 requires setting user_output, and this
% confuses emulation.
%goal_expansion(with_output_to(A,B),system:swi_with_output_to(A,B)) :- swi_io.
goal_expansion(set_prolog_IO(A,B,C), system:swi_set_prolog_IO(A,B,C)) :- swi_io. goal_expansion(set_prolog_IO(A,B,C), system:swi_set_prolog_IO(A,B,C)) :- swi_io.
goal_expansion(protocol(A), system:swi_protocol(A)) :- swi_io. goal_expansion(protocol(A), system:swi_protocol(A)) :- swi_io.
goal_expansion(protocola(A), system:swi_protocola(A)) :- swi_io. goal_expansion(protocola(A), system:swi_protocola(A)) :- swi_io.

View File

@ -478,11 +478,7 @@ X_API int PL_get_chars(term_t l, char **sp, unsigned flags)
} else { } else {
if (!(flags & (CVT_INTEGER|CVT_NUMBER|CVT_ATOMIC|CVT_WRITE|CVT_WRITE_CANONICAL|CVT_ALL))) if (!(flags & (CVT_INTEGER|CVT_NUMBER|CVT_ATOMIC|CVT_WRITE|CVT_WRITE_CANONICAL|CVT_ALL)))
return cv_error(flags); return cv_error(flags);
#if _WIN64 snprintf(tmp,SWI_BUF_SIZE,Int_FORMAT,IntegerOfTerm(t));
snprintf(tmp,SWI_BUF_SIZE,"%I64d",IntegerOfTerm(t));
#else
snprintf(tmp,SWI_BUF_SIZE,"%ld",IntegerOfTerm(t));
#endif
} }
} else if (IsPairTerm(t)) { } else if (IsPairTerm(t)) {
if (!(flags & (CVT_LIST|CVT_WRITE|CVT_WRITE_CANONICAL|CVT_ALL))) { if (!(flags & (CVT_LIST|CVT_WRITE|CVT_WRITE_CANONICAL|CVT_ALL))) {
@ -2578,12 +2574,7 @@ X_API qid_t PL_open_query(module_t ctx, int flags, predicate_t p, term_t t0)
Term t[2], m; Term t[2], m;
/* ignore flags and module for now */ /* ignore flags and module for now */
if (execution == NULL)
PL_open_foreign_frame(); PL_open_foreign_frame();
if (execution->open != 0) {
YAP_Error(0, 0L, "only one query at a time allowed\n");
return FALSE;
}
execution->open=1; execution->open=1;
execution->state=0; execution->state=0;
PredicateInfo((PredEntry *)p, &yname, &arity, &m); PredicateInfo((PredEntry *)p, &yname, &arity, &m);
@ -2617,13 +2608,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) X_API int PL_next_solution(qid_t qi)
{ {
int result; int result;
if (qi->open != 1) return 0; if (qi->open != 1) return 0;
if (setjmp(execution->env)) if (setjmp(execution->env))
return 0; return 0;
if (qi->state == 0) { if (qi->state == 0) {
result = YAP_RunGoal(qi->g); result = YAP_RunGoal(qi->g);
} else { } else {
Yap_AllowRestart = qi->open;
result = YAP_RestartGoal(); result = YAP_RestartGoal();
} }
qi->state = 1; qi->state = 1;
@ -2894,6 +2885,7 @@ PL_set_engine(PL_engine_t engine, PL_engine_t *old)
} }
return PL_ENGINE_SET; return PL_ENGINE_SET;
#else #else
if (old) *old = (PL_engine_t)&Yap_WLocal;
return FALSE; return FALSE;
#endif #endif
} }

View File

@ -316,6 +316,9 @@ expand_goal(G, NG) :-
'$do_expand'(G, M, NG), !. '$do_expand'(G, M, NG), !.
expand_goal(G, G). expand_goal(G, G).
'$do_expand'(G, _, G) :- var(G), !.
'$do_expand'(M:G, CurMod, M:GI) :- !,
'$do_expand'(G, M, GI).
'$do_expand'(G, CurMod, GI) :- '$do_expand'(G, CurMod, GI) :-
( (
'$pred_exists'(goal_expansion(G,GI), CurMod), '$pred_exists'(goal_expansion(G,GI), CurMod),
@ -323,7 +326,8 @@ expand_goal(G, G).
-> ->
true true
; ;
recorded('$dialect',swi,_), system:goal_expansion(G, GI) recorded('$dialect',swi,_),
system:goal_expansion(G, GI)
-> ->
true true
; ;
@ -332,7 +336,22 @@ expand_goal(G, G).
true true
; ;
user:goal_expansion(G, GI) user:goal_expansion(G, GI)
). ), !.
'$do_expand'(G, CurMod, NG) :-
'$is_metapredicate'(G,CurMod), !,
functor(G, Name, Arity),
prolog:'$meta_predicate'(Name,CurMod,Arity,PredDef),
G =.. [Name|GArgs],
PredDef =.. [Name|GDefs],
'$expand_args'(GArgs, CurMod, GDefs, NGArgs),
NG =.. [Name|NGArgs].
'$expand_args'([], _, [], []).
'$expand_args'(A.GArgs, CurMod, 0.GDefs, NA.NGArgs) :-
'$do_expand'(A, CurMod, NA), !,
'$expand_args'(GArgs, CurMod, GDefs, NGArgs).
'$expand_args'(A.GArgs, CurMod, _.GDefs, A.NGArgs) :-
'$expand_args'(GArgs, CurMod, GDefs, NGArgs).
% args are: % args are:
% goal to expand % goal to expand
@ -455,7 +474,7 @@ expand_goal(G, G).
'$install_meta_predicate'(P, M1) :- '$install_meta_predicate'(P, M1) :-
functor(P,F,N), functor(P,F,N),
( M1 = prolog -> M = _ ; M1 = M), ( M1 = prolog -> M = _ ; M1 = M),
( retractall('$meta_predicate'(F,M,N,_)), fail ; true), ( retractall(prolog:'$meta_predicate'(F,M,N,_)), fail ; true),
asserta(prolog:'$meta_predicate'(F,M,N,P)), asserta(prolog:'$meta_predicate'(F,M,N,P)),
'$flags'(P, M1, Fl, Fl), '$flags'(P, M1, Fl, Fl),
NFlags is Fl \/ 0x200000, NFlags is Fl \/ 0x200000,

View File

@ -212,7 +212,8 @@ assertz_static(C) :-
'$head_and_body'(C,H,B), '$head_and_body'(C,H,B),
'$assertat_d'(last,H,B,C0,Mod,_). '$assertat_d'(last,H,B,C0,Mod,_).
'$assertz_dynamic'(X,C,C0,Mod) :- '$assertz_dynamic'(X,C,C0,Mod) :-
'$head_and_body'(C,H,B), functor(H,N,A), '$head_and_body'(C,H,B),
functor(H,N,A),
('$check_if_reconsulted'(N,A) -> ('$check_if_reconsulted'(N,A) ->
true true
; ;