cut_c simplifications

This commit is contained in:
Vitor Santos Costa 2015-02-14 11:35:45 +00:00
parent ada2ad44de
commit 63416fdc48
3 changed files with 36 additions and 45 deletions

View File

@ -1603,18 +1603,20 @@ YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code, struct cut_c_str *top)
{
CACHE_REGS
choiceptr oB = B;
Int val;
/* for slots to work */
yhandle_t CurSlot = Yap_StartSlots();
/* find out where we belong */
while (B->cp_b < (choiceptr)top)
B = B->cp_b;
PP = pe;
if (pe->PredFlags & (SWIEnvPredFlag|CArgsPredFlag)) {
Int val;
// SWI Emulation
CPredicateV codev = (CPredicateV)exec_code;
struct foreign_context *ctx = (struct foreign_context *)(&EXTRA_CBACK_ARG(pe->ArityOfPE,1));
CELL *args = B->cp_args;
B = oB;
PP = pe;
ctx->control = FRG_CUTTED;
ctx->engine = NULL; //(PL_local_data *)Yap_regp;
if (pe->PredFlags & CArgsPredFlag) {
@ -1622,6 +1624,11 @@ YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code, struct cut_c_str *top)
} else {
val = codev(Yap_InitSlots(pe->ArityOfPE, args),0,ctx);
}
} else {
// YAP Native
val = exec_code( PASS_REGS1 );
B = oB;
}
Yap_CloseSlots(CurSlot);
PP = NULL;
@ -1640,25 +1647,6 @@ YAP_ExecuteOnCut(PredEntry *pe, CPredicate exec_code, struct cut_c_str *top)
} else { /* TRUE */
return TRUE;
}
} else {
Int ret, CurSlot;
B = oB;
/* for slots to work */
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;
}
}

View File

@ -105,7 +105,7 @@ typedef struct regstore_t
yamop *CP_; /* 28 continuation program counter */
CELL *ENV_; /* 1 current environment */
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;
#endif
yamop *P_; /* 7 prolog machine program counter */

View File

@ -18,7 +18,10 @@ struct cut_c_str{
#define CUT_C_STR_SIZE ((sizeof(struct cut_c_str))/(sizeof(CELL)))
#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) \
{ \