bag of changes
- spacing - exception handling should be seen carefully.
This commit is contained in:
parent
524a9ec738
commit
b13f742f02
104
C/exec.c
104
C/exec.c
@ -131,7 +131,7 @@ Yap_PredicateIndicator(Term t, Term mod)
|
||||
static Int
|
||||
CallError(yap_error_number err, Term t, Term mod USES_REGS)
|
||||
{
|
||||
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) {
|
||||
if (isoLanguageFlag()) {
|
||||
return(CallMetaCall(t, mod PASS_REGS));
|
||||
} else {
|
||||
if (err == TYPE_ERROR_CALLABLE) {
|
||||
@ -686,7 +686,7 @@ p_do_goal_expansion( USES_REGS1 )
|
||||
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion2, cmod) ) ) &&
|
||||
pe->OpcodeOfPred != FAIL_OPCODE &&
|
||||
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||
Yap_execute_pred(pe, NULL PASS_REGS) ) {
|
||||
Yap_execute_pred(pe, NULL PASS_REGS, false) ) {
|
||||
out = TRUE;
|
||||
ARG3 = ARG2;
|
||||
goto complete;
|
||||
@ -695,7 +695,7 @@ p_do_goal_expansion( USES_REGS1 )
|
||||
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion2, SYSTEM_MODULE ) ) ) &&
|
||||
pe->OpcodeOfPred != FAIL_OPCODE &&
|
||||
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||
Yap_execute_pred(pe, NULL PASS_REGS) ) {
|
||||
Yap_execute_pred(pe, NULL PASS_REGS, false) ) {
|
||||
out = TRUE;
|
||||
ARG3 = ARG2;
|
||||
goto complete;
|
||||
@ -706,7 +706,7 @@ p_do_goal_expansion( USES_REGS1 )
|
||||
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion, USER_MODULE ) ) ) &&
|
||||
pe->OpcodeOfPred != FAIL_OPCODE &&
|
||||
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||
Yap_execute_pred(pe, NULL PASS_REGS) ) {
|
||||
Yap_execute_pred(pe, NULL PASS_REGS, false) ) {
|
||||
out = TRUE;
|
||||
goto complete;
|
||||
}
|
||||
@ -716,7 +716,7 @@ p_do_goal_expansion( USES_REGS1 )
|
||||
(pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion2, USER_MODULE ) ) ) &&
|
||||
pe->OpcodeOfPred != FAIL_OPCODE &&
|
||||
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||
Yap_execute_pred(pe, NULL PASS_REGS) ) {
|
||||
Yap_execute_pred(pe, NULL PASS_REGS, false) ) {
|
||||
ARG3 = ARG2;
|
||||
out = TRUE;
|
||||
}
|
||||
@ -739,7 +739,7 @@ p_do_term_expansion( USES_REGS1 )
|
||||
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorTermExpansion, cmod) ) ) &&
|
||||
pe->OpcodeOfPred != FAIL_OPCODE &&
|
||||
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||
Yap_execute_pred(pe, NULL PASS_REGS) ) {
|
||||
Yap_execute_pred(pe, NULL PASS_REGS, false) ) {
|
||||
out = TRUE;
|
||||
goto complete;
|
||||
}
|
||||
@ -747,7 +747,7 @@ p_do_term_expansion( USES_REGS1 )
|
||||
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorTermExpansion, SYSTEM_MODULE ) ) ) &&
|
||||
pe->OpcodeOfPred != FAIL_OPCODE &&
|
||||
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||
Yap_execute_pred(pe, NULL PASS_REGS) ) {
|
||||
Yap_execute_pred(pe, NULL PASS_REGS, false) ) {
|
||||
out = TRUE;
|
||||
goto complete;
|
||||
}
|
||||
@ -756,7 +756,7 @@ p_do_term_expansion( USES_REGS1 )
|
||||
(pe = RepPredProp(Yap_GetPredPropByFunc(FunctorTermExpansion, USER_MODULE ) ) ) &&
|
||||
pe->OpcodeOfPred != FAIL_OPCODE &&
|
||||
pe->OpcodeOfPred != UNDEF_OPCODE &&
|
||||
Yap_execute_pred(pe, NULL PASS_REGS) ) {
|
||||
Yap_execute_pred(pe, NULL PASS_REGS, false) ) {
|
||||
out = TRUE;
|
||||
}
|
||||
complete:
|
||||
@ -1251,7 +1251,7 @@ Yap_fail_all( choiceptr bb USES_REGS )
|
||||
}
|
||||
|
||||
int
|
||||
Yap_execute_pred(PredEntry *ppe, CELL *pt USES_REGS)
|
||||
Yap_execute_pred(PredEntry *ppe, CELL *pt, bool pass_ex USES_REGS)
|
||||
{
|
||||
yamop *saved_p, *saved_cp;
|
||||
yamop *CodeAdr;
|
||||
@ -1305,6 +1305,14 @@ Yap_execute_pred(PredEntry *ppe, CELL *pt USES_REGS)
|
||||
if (B != NULL)
|
||||
HB = B->cp_h;
|
||||
YENV = ENV;
|
||||
// should we catch the exception or pass it through?
|
||||
// We'll pass it through
|
||||
if (EX && pass_ex) {
|
||||
Term ball = Yap_PopTermFromDB( EX );
|
||||
EX = NULL;
|
||||
Yap_JumpToEnv( ball );
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
} else if (out == 0) {
|
||||
P = saved_p;
|
||||
@ -1321,6 +1329,14 @@ Yap_execute_pred(PredEntry *ppe, CELL *pt USES_REGS)
|
||||
B = B->cp_b;
|
||||
SET_BB(B);
|
||||
HB = PROTECT_FROZEN_H(B);
|
||||
// should we catch the exception or pass it through?
|
||||
// We'll pass it through
|
||||
if (EX && pass_ex) {
|
||||
Term ball = Yap_PopTermFromDB( EX );
|
||||
EX = NULL;
|
||||
Yap_JumpToEnv( ball );
|
||||
return FALSE;
|
||||
}
|
||||
return(FALSE);
|
||||
} else {
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"emulator crashed");
|
||||
@ -1329,7 +1345,7 @@ Yap_execute_pred(PredEntry *ppe, CELL *pt USES_REGS)
|
||||
}
|
||||
|
||||
Int
|
||||
Yap_execute_goal(Term t, int nargs, Term mod)
|
||||
Yap_execute_goal(Term t, int nargs, Term mod, bool pass_ex)
|
||||
{
|
||||
CACHE_REGS
|
||||
Prop pe;
|
||||
@ -1364,7 +1380,7 @@ Yap_execute_goal(Term t, int nargs, Term mod)
|
||||
if (pe == NIL) {
|
||||
return CallMetaCall(t, mod PASS_REGS);
|
||||
}
|
||||
return Yap_execute_pred(ppe, pt PASS_REGS);
|
||||
return Yap_execute_pred(ppe, pt, pass_ex PASS_REGS);
|
||||
|
||||
}
|
||||
|
||||
@ -1447,6 +1463,7 @@ Yap_RunTopGoal(Term t)
|
||||
PELOCK(82,ppe);
|
||||
CodeAdr = ppe->CodeOfPred;
|
||||
UNLOCK(ppe->PELock);
|
||||
|
||||
#if !USE_SYSTEM_MALLOC
|
||||
if (LOCAL_TrailTop - HeapTop < 2048) {
|
||||
LOCAL_PrologMode = BootMode;
|
||||
@ -1616,6 +1633,39 @@ p_cut_up_to_next_disjunction( USES_REGS1 ) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool
|
||||
Yap_Reset(yap_reset_t mode)
|
||||
{
|
||||
CACHE_REGS
|
||||
int res = TRUE;
|
||||
|
||||
if (EX) {
|
||||
LOCAL_BallTerm = EX;
|
||||
}
|
||||
EX = NULL;
|
||||
Yap_ResetExceptionTerm( 0 );
|
||||
LOCAL_UncaughtThrow = FALSE;
|
||||
/* first, backtrack to the root */
|
||||
while (B->cp_b) {
|
||||
B = B->cp_b;
|
||||
}
|
||||
// B shoul lead to CP with _ystop0,,
|
||||
P = FAILCODE;
|
||||
res = Yap_exec_absmi( true, mode );
|
||||
/* reinitialise the engine */
|
||||
// Yap_InitYaamRegs( worker_id );
|
||||
GLOBAL_Initialised = true;
|
||||
ENV = LCL0;
|
||||
ASP = (CELL *)B;
|
||||
/* the first real choice-point will also have AP=FAIL */
|
||||
/* always have an empty slots for people to use */
|
||||
P = CP = YESCODE;
|
||||
// ensure that we have slots where we need them
|
||||
Yap_RebootSlots( worker_id );
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
static int is_cleanup_cp(choiceptr cp_b)
|
||||
{
|
||||
PredEntry *pe;
|
||||
@ -1659,38 +1709,13 @@ JumpToEnv(Term t USES_REGS) {
|
||||
env1 = ENV;
|
||||
do {
|
||||
/* find the first choicepoint that may be a catch */
|
||||
while (handler != NULL && handler->cp_ap != pos) {
|
||||
while (handler &&
|
||||
handler->cp_ap != pos) {
|
||||
/* we are already doing a catch */
|
||||
if (handler->cp_ap == catchpos) {
|
||||
P = (yamop *)FAILCODE;
|
||||
return TRUE;
|
||||
}
|
||||
/* we have a cleanup handler in the middle */
|
||||
if (is_cleanup_cp(handler)) {
|
||||
/* keep it around */
|
||||
if (previous == NULL) {
|
||||
B = handler;
|
||||
} else {
|
||||
previous->cp_b = handler;
|
||||
}
|
||||
previous = handler;
|
||||
#ifdef TABLING
|
||||
} else {
|
||||
if (handler->cp_ap != NOCODE) {
|
||||
abolish_incomplete_subgoals(handler);
|
||||
}
|
||||
#endif /* TABLING */
|
||||
}
|
||||
/* we reached C-Code */
|
||||
if (handler->cp_ap == NOCODE) {
|
||||
/* up to the C-code to deal with this! */
|
||||
LOCAL_UncaughtThrow = TRUE;
|
||||
if (previous == NULL)
|
||||
B = handler;
|
||||
else
|
||||
previous->cp_b = handler;
|
||||
EX = LOCAL_BallTerm;
|
||||
LOCAL_BallTerm = NULL;
|
||||
|
||||
P = (yamop *)FAILCODE;
|
||||
/* make sure failure will be seen at next port */
|
||||
if (LOCAL_PrologMode & AsyncIntMode) {
|
||||
@ -1791,7 +1816,6 @@ Yap_InitYaamRegs( int myworker_id )
|
||||
if (myworker_id) {
|
||||
REGSTORE *rs = REMOTE_ThreadHandle(myworker_id).default_yaam_regs;
|
||||
pthread_setspecific(Yap_yaamregs_key, (const void *)rs);
|
||||
REMOTE_PL_local_data_p(myworker_id)->reg_cache = rs;
|
||||
REMOTE_ThreadHandle(myworker_id).current_yaam_regs = rs;
|
||||
REFRESH_CACHE_REGS
|
||||
}
|
||||
|
Reference in New Issue
Block a user