Merge branch 'master' of git.dcc.fc.up.pt:yap-6.3
This commit is contained in:
@@ -12,8 +12,8 @@ typedef YAP_Int BPLONG;
|
||||
typedef YAP_UInt BPULONG;
|
||||
typedef BPLONG *BPLONG_PTR;
|
||||
|
||||
#define BP_TRUE TRUE
|
||||
#define BP_FALSE FALSE
|
||||
#define BP_TRUE 1
|
||||
#define BP_FALSE 0
|
||||
|
||||
//extern TERM bp_get_call_arg(int i, int arity);
|
||||
#define bp_get_call_arg( i, arity) YAP_A(i)
|
||||
@@ -169,7 +169,7 @@ INLINE_ONLY extern inline int
|
||||
bp_mount_query_term(TERM goal)
|
||||
{
|
||||
curr_toam_status = goal;
|
||||
return TRUE;
|
||||
return BP_TRUE;
|
||||
}
|
||||
|
||||
#endif /* BPROLOG_H */
|
||||
|
@@ -95,7 +95,7 @@ extern X_API Int YAP_PLArityOfSWIFunctor(functor_t at);
|
||||
/* This is silly, but let's keep it like that for now */
|
||||
X_API Int
|
||||
YAP_PLArityOfSWIFunctor(functor_t f) {
|
||||
if ((CELL)(f) & 2 && ((CELL)f) < N_SWI_FUNCTORS*4+2)
|
||||
if (((CELL)(f) & 2) && ((CELL)f) < N_SWI_FUNCTORS*4+2)
|
||||
return ArityOfFunctor(SWI_Functors[(CELL)f/4]);
|
||||
if (IsAtomTerm(f))
|
||||
return 0;
|
||||
@@ -1001,7 +1001,7 @@ X_API int PL_throw(term_t exception)
|
||||
{
|
||||
CACHE_REGS
|
||||
YAP_Throw(Yap_GetFromSlot(exception PASS_REGS));
|
||||
longjmp(LOCAL_execution->env, 0);
|
||||
longjmp(LOCAL_execution->q_env, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1315,6 +1315,7 @@ X_API int PL_unify_wchars(term_t t, int type, size_t len, const pl_wchar_t *char
|
||||
if (LOCAL_Error_TYPE && !Yap_SWIHandleError( "PL_unify_wchars" ))
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
@@ -2233,43 +2234,43 @@ X_API qid_t PL_open_query(module_t ctx, int flags, predicate_t p, term_t t0)
|
||||
t = Yap_AddressFromSlot(t0 PASS_REGS);
|
||||
|
||||
/* ignore flags and module for now */
|
||||
open_query *new = (open_query *)Yap_AllocCodeSpace(sizeof(open_query));
|
||||
qid_t new = (qid_t)Yap_AllocCodeSpace(sizeof(struct open_query_struct));
|
||||
LOCAL_execution = new;
|
||||
new->open=1;
|
||||
new->state=0;
|
||||
new->flags = flags;
|
||||
new->pe = (PredEntry *)p;
|
||||
new->g = t;
|
||||
return LOCAL_execution;
|
||||
new->q_open=1;
|
||||
new->q_state=0;
|
||||
new->q_flags = flags;
|
||||
new->q_pe = (PredEntry *)p;
|
||||
new->q_g = t;
|
||||
return new;
|
||||
}
|
||||
|
||||
X_API int PL_next_solution(qid_t qi)
|
||||
{
|
||||
CACHE_REGS
|
||||
int result;
|
||||
if (qi->open != 1) return 0;
|
||||
if (setjmp(LOCAL_execution->env))
|
||||
if (qi->q_open != 1) return 0;
|
||||
if (setjmp(LOCAL_execution->q_env))
|
||||
return 0;
|
||||
// don't forget, on success these guys must create slots
|
||||
if (qi->state == 0) {
|
||||
result = YAP_EnterGoal((YAP_PredEntryPtr)qi->pe, qi->g, &qi->h);
|
||||
if (qi->q_state == 0) {
|
||||
result = YAP_EnterGoal((YAP_PredEntryPtr)qi->q_pe, qi->q_g, &qi->q_h);
|
||||
} else {
|
||||
LOCAL_AllowRestart = qi->open;
|
||||
result = YAP_RetryGoal(&qi->h);
|
||||
LOCAL_AllowRestart = qi->q_open;
|
||||
result = YAP_RetryGoal(&qi->q_h);
|
||||
}
|
||||
qi->state = 1;
|
||||
qi->q_state = 1;
|
||||
if (result == 0) {
|
||||
YAP_LeaveGoal(FALSE, &qi->h);
|
||||
qi->open = 0;
|
||||
YAP_LeaveGoal(FALSE, &qi->q_h);
|
||||
qi->q_open = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
X_API void PL_cut_query(qid_t qi)
|
||||
{
|
||||
if (qi->open != 1 || qi->state == 0) return;
|
||||
YAP_LeaveGoal(FALSE, &qi->h);
|
||||
qi->open = 0;
|
||||
if (qi->q_open != 1 || qi->q_state == 0) return;
|
||||
YAP_LeaveGoal(FALSE, &qi->q_h);
|
||||
qi->q_open = 0;
|
||||
Yap_FreeCodeSpace( (char *)qi );
|
||||
}
|
||||
|
||||
@@ -2277,15 +2278,15 @@ X_API void PL_close_query(qid_t qi)
|
||||
{
|
||||
CACHE_REGS
|
||||
|
||||
if (EX && !(qi->flags & (PL_Q_CATCH_EXCEPTION))) {
|
||||
if (EX && !(qi->q_flags & (PL_Q_CATCH_EXCEPTION))) {
|
||||
EX = NULL;
|
||||
}
|
||||
/* need to implement backtracking here */
|
||||
if (qi->open != 1 || qi->state == 0) {
|
||||
if (qi->q_open != 1 || qi->q_state == 0) {
|
||||
return;
|
||||
}
|
||||
YAP_LeaveGoal(FALSE, &qi->h);
|
||||
qi->open = 0;
|
||||
YAP_LeaveGoal(FALSE, &qi->q_h);
|
||||
qi->q_open = 0;
|
||||
Yap_FreeCodeSpace( (char *)qi );
|
||||
}
|
||||
|
||||
@@ -2306,6 +2307,7 @@ X_API int PL_toplevel(void)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
X_API int PL_call(term_t tp, module_t m)
|
||||
|
@@ -2,14 +2,14 @@ void Yap_swi_install(void);
|
||||
void Yap_install_blobs(void);
|
||||
|
||||
typedef struct open_query_struct {
|
||||
int open;
|
||||
int state;
|
||||
YAP_Term *g;
|
||||
PredEntry *pe;
|
||||
yamop *p, *cp;
|
||||
jmp_buf env;
|
||||
int flags;
|
||||
YAP_dogoalinfo h;
|
||||
int q_open;
|
||||
int q_state;
|
||||
YAP_Term *q_g;
|
||||
PredEntry *q_pe;
|
||||
yamop *q_p, *q_cp;
|
||||
jmp_buf q_env;
|
||||
int q_flags;
|
||||
YAP_dogoalinfo q_h;
|
||||
} open_query;
|
||||
|
||||
#define addr_hash(V) (((CELL) (V)) >> 4 & (N_SWI_HASH-1))
|
||||
|
Reference in New Issue
Block a user