fixes
This commit is contained in:
parent
7d85bbfa27
commit
d8b4d1c878
@ -1,4 +1,3 @@
|
||||
|
||||
/************************************************************************* *
|
||||
* YAP Prolog *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
@ -995,6 +994,10 @@ static Int execute_cargs(PredEntry *pe, CPredicate exec_code USES_REGS) {
|
||||
"YAP only supports SWI C-call with arity =< 10");
|
||||
return false;
|
||||
}
|
||||
arity_t i;
|
||||
for (i = 0; i < pe->ArityOfPE; i++) {
|
||||
XREGS[i+1] = Yap_GetFromSlot(a1+i);
|
||||
}
|
||||
Yap_RecoverSlots(pe->ArityOfPE, a1);
|
||||
return rc;
|
||||
}
|
||||
@ -1974,22 +1977,16 @@ X_API Int YAP_RunGoalOnce(Term t) {
|
||||
CACHE_REGS
|
||||
Term out;
|
||||
YAP_dogoalinfo gi;
|
||||
gi.p = P;
|
||||
gi.cp = CP;
|
||||
gi.b_top = LCL0-CellPtr(B);
|
||||
gi.CurSlot = Yap_CurrentHandle();
|
||||
gi.y = LCL0-YENV;
|
||||
gi.e = LCL0-ENV;
|
||||
Int oldPrologMode = LOCAL_PrologMode;
|
||||
yhandle_t CSlot;
|
||||
|
||||
BACKUP_MACHINE_REGS();
|
||||
CSlot = Yap_StartSlots();
|
||||
Yap_push_state(&gi PASS_REGS);
|
||||
LOCAL_PrologMode = UserMode;
|
||||
// Yap_heap_regs->yap_do_low_level_trace=true;
|
||||
out = Yap_RunTopGoal(t, &gi, true);
|
||||
LOCAL_PrologMode = oldPrologMode;
|
||||
// Yap_CloseSlots(CSlot);
|
||||
Yap_pop_state(out, &gi PASS_REGS);
|
||||
if (!(oldPrologMode & UserCCallMode)) {
|
||||
/* called from top-level */
|
||||
LOCAL_AllowRestart = FALSE;
|
||||
@ -1999,32 +1996,6 @@ X_API Int YAP_RunGoalOnce(Term t) {
|
||||
// should we catch the exception or pass it through?
|
||||
// We'll pass it through
|
||||
// Yap_RaiseException();
|
||||
if (out) {
|
||||
choiceptr cut_pt;
|
||||
|
||||
cut_pt = B;
|
||||
B = (choiceptr)(LCL0-gi.b_top);
|
||||
while (cut_pt->cp_ap != NOCODE && cut_pt < B) {
|
||||
/* make sure we prune C-choicepoints */
|
||||
cut_pt = cut_pt->cp_b;
|
||||
}
|
||||
B = cut_pt;
|
||||
Yap_TrimTrail();
|
||||
} else {
|
||||
Yap_CloseSlots(CSlot);
|
||||
}
|
||||
#ifdef YAPOR
|
||||
CUT_prune_to(cut_pt);
|
||||
#endif
|
||||
ENV = LCL0-gi.e;
|
||||
YENV = LCL0-gi.y;
|
||||
B = (choiceptr)(LCL0-gi.b_top);
|
||||
#ifdef DEPTH_LIMIT
|
||||
DEPTH = ENV[E_DEPTH];
|
||||
#endif
|
||||
P = gi.p;
|
||||
CP = gi.cp;
|
||||
SET_ASP(YENV, E_CB * sizeof(CELL));
|
||||
LOCAL_AllowRestart = FALSE;
|
||||
RECOVER_MACHINE_REGS();
|
||||
return out;
|
||||
|
14
C/exec.c
14
C/exec.c
@ -856,13 +856,7 @@ static void complete_inner_computation(choiceptr old_B, YAP_dogoalinfo *gi) {
|
||||
|
||||
static Int Yap_ignore(Term t, bool fail USES_REGS) {
|
||||
YAP_dogoalinfo gi;
|
||||
gi.p = P;
|
||||
gi.cp = CP;
|
||||
gi.b_top = LCL0-CellPtr(B);
|
||||
gi.CurSlot = Yap_CurrentHandle();
|
||||
gi.y = LCL0-YENV;
|
||||
gi.e = LCL0-ENV;
|
||||
// gi. = LCL0-YENV;
|
||||
Yap_push_state(&gi);
|
||||
yap_error_descriptor_t *ctx = malloc(sizeof(yap_error_descriptor_t));
|
||||
bool newxp = Yap_pushErrorContext(true, ctx);
|
||||
bool rc = Yap_RunTopGoal(t, &gi, false);
|
||||
@ -874,12 +868,6 @@ static Int Yap_ignore(Term t, bool fail USES_REGS) {
|
||||
prune_inner_computation(B0, &gi);
|
||||
}
|
||||
Yap_popErrorContext(newxp, true);
|
||||
ENV = LCL0-gi.e;
|
||||
B = (choiceptr)(LCL0-gi.b_top);
|
||||
SET_ASP(ENV, E_CB * sizeof(CELL));
|
||||
#ifdef DEPTH_LIMIT
|
||||
DEPTH = ASP[E_DEPTH];
|
||||
#endif
|
||||
P = gi.p;
|
||||
CP = gi.cp;
|
||||
//YENV?
|
||||
|
5
H/Regs.h
5
H/Regs.h
@ -681,8 +681,9 @@ CalculateStackGap( USES_REGS1 )
|
||||
|
||||
#define SET_ASP(Y,S) SET_ASP__(Y,S PASS_REGS)
|
||||
|
||||
static inline
|
||||
void SET_ASP__(CELL *yreg, Int sz USES_REGS) {
|
||||
INLINE_ONLY void SET_ASP__(CELL *yreg, Int sz USES_REGS);
|
||||
|
||||
INLINE_ONLY void SET_ASP__(CELL *yreg, Int sz USES_REGS) {
|
||||
ASP = (CELL *) (((char *) yreg) + sz);
|
||||
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
|
||||
ASP = (CELL *)PROTECT_FROZEN_B(B);
|
||||
|
@ -304,4 +304,35 @@ static inline Term Yap_PopHandle__(yhandle_t topHandle USES_REGS) {
|
||||
return Deref(LOCAL_HandleBase[topHandle]);
|
||||
}
|
||||
}
|
||||
INLINE_ONLY void Yap_push_state(YAP_dogoalinfo *gi USES_REGS);
|
||||
|
||||
INLINE_ONLY void Yap_push_state(YAP_dogoalinfo *gi USES_REGS)
|
||||
{
|
||||
gi->p = P;
|
||||
gi->cp = CP;
|
||||
gi->b_top = LCL0-CellPtr(B);
|
||||
gi->CurSlot = Yap_CurrentHandle();
|
||||
gi->y = LCL0-YENV;
|
||||
gi->e = LCL0-ENV;
|
||||
gi->a = LCL0-ASP;
|
||||
}
|
||||
|
||||
INLINE_ONLY void Yap_pop_state(bool out, YAP_dogoalinfo *gi USES_REGS);
|
||||
|
||||
INLINE_ONLY void Yap_pop_state(bool out, YAP_dogoalinfo *gi USES_REGS)
|
||||
{
|
||||
B = (choiceptr)(LCL0-gi->b_top);
|
||||
YENV = LCL0-gi->y;
|
||||
ENV = LCL0-gi->e;
|
||||
if (out) {
|
||||
Yap_TrimTrail();
|
||||
}
|
||||
ASP = LCL0-gi->a;
|
||||
Yap_CloseHandles(gi->CurSlot);
|
||||
SET_ASP(YENV, E_CB * sizeof(CELL));
|
||||
#ifdef DEPTH_LIMIT
|
||||
DEPTH = ENV[E_DEPTH];
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -2398,6 +2398,7 @@ Int (*Yap_traced_absmi)(void);
|
||||
extern JIT_Compiler *J;
|
||||
#endif
|
||||
|
||||
|
||||
extern NativeContext *NativeArea;
|
||||
extern IntermediatecodeContext *IntermediatecodeArea;
|
||||
|
||||
@ -2421,7 +2422,7 @@ extern yamop *headoftrace;
|
||||
#ifdef SHADOW_S
|
||||
#define PROCESS_INT(F, C) \
|
||||
BEGD(d0); \
|
||||
Yap_REGS.S_ = SREG; \
|
||||
Yap_REGSS_ = SREG; \
|
||||
saveregs(); \
|
||||
d0 = F(PASS_REGS1); \
|
||||
setregs(); \
|
||||
@ -2444,8 +2445,8 @@ extern yamop *headoftrace;
|
||||
FAIL(); \
|
||||
if (d0 == 2) \
|
||||
goto C; \
|
||||
JMPNext(); \
|
||||
ENDD(d0);
|
||||
JMPNext();\
|
||||
ENDD(d0);
|
||||
#endif
|
||||
|
||||
#define Yap_AsmError(e, d) \
|
||||
|
@ -577,4 +577,5 @@ static inline int do_cut(int i) {
|
||||
|
||||
#define cut_fail() return do_cut(FALSE)
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -138,7 +138,7 @@ typedef enum {
|
||||
|
||||
/* this should be opaque to the user */
|
||||
typedef struct goal_info {
|
||||
unsigned long b_top, b_bottom, m, e, y; //> choice-point at entry
|
||||
unsigned long b_top, b_bottom, m, e, y, a; //> choice-point at entry
|
||||
YAP_handle_t CurSlot; //> variables at entry
|
||||
YAP_handle_t EndSlot; //> variables at successful execution
|
||||
struct yami *p; //> Program Counter at entry
|
||||
|
@ -710,7 +710,7 @@ scanl_([H1|T1], [H2|T2], [H3|T3], [H4|T4], Goal, V, [VH|VT]) :-
|
||||
|
||||
goal_expansion(checklist(Meta, List), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -731,7 +731,7 @@ goal_expansion(checklist(Meta, List), Mod:Goal) :-
|
||||
|
||||
goal_expansion(maplist(Meta, List), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -752,7 +752,7 @@ goal_expansion(maplist(Meta, List), Mod:Goal) :-
|
||||
|
||||
goal_expansion(maplist(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -773,7 +773,7 @@ goal_expansion(maplist(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
|
||||
goal_expansion(maplist(Meta, L1, L2, L3), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -794,7 +794,7 @@ goal_expansion(maplist(Meta, L1, L2, L3), Mod:Goal) :-
|
||||
|
||||
goal_expansion(maplist(Meta, L1, L2, L3, L4), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -815,7 +815,7 @@ goal_expansion(maplist(Meta, L1, L2, L3, L4), Mod:Goal) :-
|
||||
|
||||
goal_expansion(maplist(Meta, L1, L2, L3, L4, L5), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -836,7 +836,7 @@ goal_expansion(maplist(Meta, L1, L2, L3, L4, L5), Mod:Goal) :-
|
||||
|
||||
goal_expansion(selectlist(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -859,7 +859,7 @@ goal_expansion(selectlist(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
|
||||
goal_expansion(selectlist(Meta, ListIn, ListIn1, ListOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -882,7 +882,7 @@ goal_expansion(selectlist(Meta, ListIn, ListIn1, ListOut), Mod:Goal) :-
|
||||
|
||||
goal_expansion(selectlists(Meta, ListIn, ListIn1, ListOut, ListOut1), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -906,7 +906,7 @@ goal_expansion(selectlists(Meta, ListIn, ListIn1, ListOut, ListOut1), Mod:Goal)
|
||||
% same as selectlist
|
||||
goal_expansion(include(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -929,7 +929,7 @@ goal_expansion(include(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
|
||||
goal_expansion(exclude(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -952,7 +952,7 @@ goal_expansion(exclude(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
|
||||
goal_expansion(partition(Meta, ListIn, List1, List2), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -975,7 +975,7 @@ goal_expansion(partition(Meta, ListIn, List1, List2), Mod:Goal) :-
|
||||
|
||||
goal_expansion(partition(Meta, ListIn, List1, List2, List3), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -1015,7 +1015,7 @@ goal_expansion(partition(Meta, ListIn, List1, List2, List3), Mod:Goal) :-
|
||||
|
||||
goal_expansion(convlist(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -1038,7 +1038,7 @@ goal_expansion(convlist(Meta, ListIn, ListOut), Mod:Goal) :-
|
||||
|
||||
goal_expansion(convlist(Meta, ListIn, ListExtra, ListOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -1061,7 +1061,7 @@ goal_expansion(convlist(Meta, ListIn, ListExtra, ListOut), Mod:Goal) :-
|
||||
|
||||
goal_expansion(sumlist(Meta, List, AccIn, AccOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -1082,7 +1082,7 @@ goal_expansion(sumlist(Meta, List, AccIn, AccOut), Mod:Goal) :-
|
||||
|
||||
goal_expansion(foldl(Meta, List, AccIn, AccOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -1103,7 +1103,7 @@ goal_expansion(foldl(Meta, List, AccIn, AccOut), Mod:Goal) :-
|
||||
|
||||
goal_expansion(foldl(Meta, List1, List2, AccIn, AccOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -1124,7 +1124,7 @@ goal_expansion(foldl(Meta, List1, List2, AccIn, AccOut), Mod:Goal) :-
|
||||
|
||||
goal_expansion(foldl(Meta, List1, List2, List3, AccIn, AccOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -1145,7 +1145,7 @@ goal_expansion(foldl(Meta, List1, List2, List3, AccIn, AccOut), Mod:Goal) :-
|
||||
|
||||
goal_expansion(foldl2(Meta, List, AccIn, AccOut, W0, W), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -1166,7 +1166,7 @@ goal_expansion(foldl2(Meta, List, AccIn, AccOut, W0, W), Mod:Goal) :-
|
||||
|
||||
goal_expansion(foldl2(Meta, List1, List2, AccIn, AccOut, W0, W), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -1187,7 +1187,7 @@ goal_expansion(foldl2(Meta, List1, List2, AccIn, AccOut, W0, W), Mod:Goal) :-
|
||||
|
||||
goal_expansion(foldl2(Meta, List1, List2, List3, AccIn, AccOut, W0, W), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -1208,7 +1208,7 @@ goal_expansion(foldl2(Meta, List1, List2, List3, AccIn, AccOut, W0, W), Mod:Goal
|
||||
|
||||
goal_expansion(foldl3(Meta, List, AccIn, AccOut, W0, W, X0, X), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -1229,7 +1229,7 @@ goal_expansion(foldl3(Meta, List, AccIn, AccOut, W0, W, X0, X), Mod:Goal) :-
|
||||
|
||||
goal_expansion(foldl4(Meta, List, AccIn, AccOut, W0, W, X0, X, Y0, Y), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -1250,7 +1250,7 @@ goal_expansion(foldl4(Meta, List, AccIn, AccOut, W0, W, X0, X, Y0, Y), Mod:Goal)
|
||||
|
||||
goal_expansion(mapnodes(Meta, InTerm, OutTerm), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -1282,7 +1282,7 @@ goal_expansion(mapnodes(Meta, InTerm, OutTerm), Mod:Goal) :-
|
||||
|
||||
goal_expansion(checknodes(Meta, Term), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
@ -1312,7 +1312,7 @@ goal_expansion(checknodes(Meta, Term), Mod:Goal) :-
|
||||
|
||||
goal_expansion(sumnodes(Meta, Term, AccIn, AccOut), Mod:Goal) :-
|
||||
goal_expansion_allowed,
|
||||
is_callable(Meta),
|
||||
callable(Meta),
|
||||
current_source_module(Mod,Mod),
|
||||
aux_preds(Meta, MetaVars, Pred, PredVars, Proto),
|
||||
!,
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/**
|
||||
* @file real.c
|
||||
* @date Sat May 19 13:44:04 2018
|
||||
|
@ -956,7 +956,7 @@ prolog:message( r_root ) -->
|
||||
|
||||
|
||||
eval_text( Text ) :-
|
||||
atomic_to_term( Text, Goal, VarNames ),
|
||||
atomic_to_term( Text, Goal, _VarNames ),
|
||||
call(user:Goal).
|
||||
|
||||
:- at_halt(halt_r).
|
||||
|
Reference in New Issue
Block a user