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;
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")));
}

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
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();

View File

@ -189,7 +189,9 @@ goal_expansion(open_null_stream(A), system:swi_open_null_stream(A)) :- swi_io.
/* SWI specific */
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(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(protocol(A), system:swi_protocol(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 {
if (!(flags & (CVT_INTEGER|CVT_NUMBER|CVT_ATOMIC|CVT_WRITE|CVT_WRITE_CANONICAL|CVT_ALL)))
return cv_error(flags);
#if _WIN64
snprintf(tmp,SWI_BUF_SIZE,"%I64d",IntegerOfTerm(t));
#else
snprintf(tmp,SWI_BUF_SIZE,"%ld",IntegerOfTerm(t));
#endif
snprintf(tmp,SWI_BUF_SIZE,Int_FORMAT,IntegerOfTerm(t));
}
} else if (IsPairTerm(t)) {
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;
/* 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 +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)
{
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;
@ -2894,6 +2885,7 @@ PL_set_engine(PL_engine_t engine, PL_engine_t *old)
}
return PL_ENGINE_SET;
#else
if (old) *old = (PL_engine_t)&Yap_WLocal;
return FALSE;
#endif
}

View File

@ -316,6 +316,9 @@ expand_goal(G, NG) :-
'$do_expand'(G, M, NG), !.
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) :-
(
'$pred_exists'(goal_expansion(G,GI), CurMod),
@ -323,7 +326,8 @@ expand_goal(G, G).
->
true
;
recorded('$dialect',swi,_), system:goal_expansion(G, GI)
recorded('$dialect',swi,_),
system:goal_expansion(G, GI)
->
true
;
@ -332,7 +336,22 @@ expand_goal(G, G).
true
;
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:
% goal to expand
@ -455,7 +474,7 @@ expand_goal(G, G).
'$install_meta_predicate'(P, M1) :-
functor(P,F,N),
( 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)),
'$flags'(P, M1, Fl, Fl),
NFlags is Fl \/ 0x200000,

View File

@ -212,7 +212,8 @@ assertz_static(C) :-
'$head_and_body'(C,H,B),
'$assertat_d'(last,H,B,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) ->
true
;