cut_c simplifications
This commit is contained in:
parent
ada2ad44de
commit
63416fdc48
@ -1603,18 +1603,20 @@ YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code, struct cut_c_str *top)
|
|||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
choiceptr oB = B;
|
choiceptr oB = B;
|
||||||
|
Int val;
|
||||||
|
/* for slots to work */
|
||||||
yhandle_t CurSlot = Yap_StartSlots();
|
yhandle_t CurSlot = Yap_StartSlots();
|
||||||
/* find out where we belong */
|
/* find out where we belong */
|
||||||
while (B->cp_b < (choiceptr)top)
|
while (B->cp_b < (choiceptr)top)
|
||||||
B = B->cp_b;
|
B = B->cp_b;
|
||||||
|
PP = pe;
|
||||||
if (pe->PredFlags & (SWIEnvPredFlag|CArgsPredFlag)) {
|
if (pe->PredFlags & (SWIEnvPredFlag|CArgsPredFlag)) {
|
||||||
Int val;
|
// SWI Emulation
|
||||||
CPredicateV codev = (CPredicateV)exec_code;
|
CPredicateV codev = (CPredicateV)exec_code;
|
||||||
struct foreign_context *ctx = (struct foreign_context *)(&EXTRA_CBACK_ARG(pe->ArityOfPE,1));
|
struct foreign_context *ctx = (struct foreign_context *)(&EXTRA_CBACK_ARG(pe->ArityOfPE,1));
|
||||||
CELL *args = B->cp_args;
|
CELL *args = B->cp_args;
|
||||||
|
|
||||||
B = oB;
|
B = oB;
|
||||||
PP = pe;
|
|
||||||
ctx->control = FRG_CUTTED;
|
ctx->control = FRG_CUTTED;
|
||||||
ctx->engine = NULL; //(PL_local_data *)Yap_regp;
|
ctx->engine = NULL; //(PL_local_data *)Yap_regp;
|
||||||
if (pe->PredFlags & CArgsPredFlag) {
|
if (pe->PredFlags & CArgsPredFlag) {
|
||||||
@ -1622,43 +1624,29 @@ YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code, struct cut_c_str *top)
|
|||||||
} else {
|
} else {
|
||||||
val = codev(Yap_InitSlots(pe->ArityOfPE, args),0,ctx);
|
val = codev(Yap_InitSlots(pe->ArityOfPE, args),0,ctx);
|
||||||
}
|
}
|
||||||
Yap_CloseSlots(CurSlot);
|
|
||||||
|
|
||||||
PP = NULL;
|
|
||||||
// B = LCL0-(CELL*)oB;
|
|
||||||
if (val == 0) {
|
|
||||||
Term t;
|
|
||||||
|
|
||||||
LOCAL_BallTerm = EX;
|
|
||||||
EX = NULL;
|
|
||||||
if ((t = Yap_GetException())) {
|
|
||||||
cut_c_pop();
|
|
||||||
Yap_JumpToEnv(t);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
} else { /* TRUE */
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Int ret, CurSlot;
|
// YAP Native
|
||||||
B = oB;
|
val = exec_code( PASS_REGS1 );
|
||||||
/* for slots to work */
|
B = oB;
|
||||||
CurSlot = Yap_StartSlots( );
|
|
||||||
ret = (exec_code)( PASS_REGS1 );
|
|
||||||
Yap_CloseSlots(CurSlot);
|
|
||||||
if (!ret) {
|
|
||||||
Term t;
|
|
||||||
|
|
||||||
LOCAL_BallTerm = EX;
|
|
||||||
EX = NULL;
|
|
||||||
if ((t = Yap_GetException())) {
|
|
||||||
Yap_JumpToEnv(t);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
Yap_CloseSlots(CurSlot);
|
||||||
|
|
||||||
|
PP = NULL;
|
||||||
|
// B = LCL0-(CELL*)oB;
|
||||||
|
if (val == 0) {
|
||||||
|
Term t;
|
||||||
|
|
||||||
|
LOCAL_BallTerm = EX;
|
||||||
|
EX = NULL;
|
||||||
|
if ((t = Yap_GetException())) {
|
||||||
|
cut_c_pop();
|
||||||
|
Yap_JumpToEnv(t);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
} else { /* TRUE */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
2
H/Regs.h
2
H/Regs.h
@ -105,7 +105,7 @@ typedef struct regstore_t
|
|||||||
yamop *CP_; /* 28 continuation program counter */
|
yamop *CP_; /* 28 continuation program counter */
|
||||||
CELL *ENV_; /* 1 current environment */
|
CELL *ENV_; /* 1 current environment */
|
||||||
struct cut_c_str *CUT_C_TOP;
|
struct cut_c_str *CUT_C_TOP;
|
||||||
#if defined MYDDAS_ODBC || defined MYDDAS_MYSQL || defined MYDDAS_SQLITE3
|
#if defined USE_MYDDAS
|
||||||
struct myddas_global *MYDDAS_GLOBAL_POINTER;
|
struct myddas_global *MYDDAS_GLOBAL_POINTER;
|
||||||
#endif
|
#endif
|
||||||
yamop *P_; /* 7 prolog machine program counter */
|
yamop *P_; /* 7 prolog machine program counter */
|
||||||
|
17
H/cut_c.h
17
H/cut_c.h
@ -17,8 +17,11 @@ struct cut_c_str{
|
|||||||
|
|
||||||
#define CUT_C_STR_SIZE ((sizeof(struct cut_c_str))/(sizeof(CELL)))
|
#define CUT_C_STR_SIZE ((sizeof(struct cut_c_str))/(sizeof(CELL)))
|
||||||
|
|
||||||
#define EXTRA_CBACK_CUT_ARG(Type,Offset) \
|
#define EXTRA_CBACK_CUT_ARG(Type,Offset) \
|
||||||
((Type) (*(Type *)(((CELL *)Yap_REGS.CUT_C_TOP) - (((yamop *)Yap_REGS.CUT_C_TOP->try_userc_cut_yamop)->y_u.OtapFs.extra)) + (Offset-1)))
|
EXTRA_CBACK_ARG( PP->ArityOfPE, Offset )
|
||||||
|
|
||||||
|
#define CBACK_CUT_ARG(Offset) \
|
||||||
|
B->cp_args[ (Offset) - 1 ]
|
||||||
|
|
||||||
#define CUT_C_PUSH(YAMOP,S_YREG) \
|
#define CUT_C_PUSH(YAMOP,S_YREG) \
|
||||||
{ \
|
{ \
|
||||||
@ -36,11 +39,11 @@ struct cut_c_str{
|
|||||||
|
|
||||||
|
|
||||||
#define POP_EXECUTE() \
|
#define POP_EXECUTE() \
|
||||||
cut_c_str_ptr TOP = Yap_REGS.CUT_C_TOP; \
|
cut_c_str_ptr TOP = Yap_REGS.CUT_C_TOP; \
|
||||||
CPredicate func = (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->y_u.OtapFs.f; \
|
CPredicate func = (CPredicate)((yamop *)TOP->try_userc_cut_yamop)->y_u.OtapFs.f; \
|
||||||
PredEntry *pred = (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->y_u.OtapFs.p; \
|
PredEntry *pred = (PredEntry *)((yamop *)TOP->try_userc_cut_yamop)->y_u.OtapFs.p; \
|
||||||
YAP_ExecuteOnCut(pred, func, TOP); \
|
YAP_ExecuteOnCut(pred, func, TOP); \
|
||||||
cut_c_pop();
|
cut_c_pop();
|
||||||
|
|
||||||
|
|
||||||
/*Initializes CUT_C_TOP*/
|
/*Initializes CUT_C_TOP*/
|
||||||
|
Reference in New Issue
Block a user