attempt to improve error handliong in SWI emulation.
This commit is contained in:
parent
07b17f473a
commit
6617a63b7e
@ -1474,14 +1474,37 @@ YAP_Execute(PredEntry *pe, CPredicate exec_code)
|
|||||||
struct foreign_context ctx;
|
struct foreign_context ctx;
|
||||||
UInt i;
|
UInt i;
|
||||||
Int sl = 0;
|
Int sl = 0;
|
||||||
|
Int ret;
|
||||||
|
|
||||||
ctx.engine = NULL;
|
ctx.engine = NULL;
|
||||||
for (i=pe->ArityOfPE; i > 0; i--) {
|
for (i=pe->ArityOfPE; i > 0; i--) {
|
||||||
sl = Yap_InitSlot(XREGS[i]);
|
sl = Yap_InitSlot(XREGS[i]);
|
||||||
}
|
}
|
||||||
return ((codev)(sl,0,&ctx));
|
ret = ((codev)(sl,0,&ctx));
|
||||||
|
if (!ret) {
|
||||||
|
Term t;
|
||||||
|
|
||||||
|
BallTerm = EX;
|
||||||
|
EX = NULL;
|
||||||
|
if ((t = Yap_GetException())) {
|
||||||
|
Yap_JumpToEnv(t);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
if (pe->PredFlags & CArgsPredFlag) {
|
if (pe->PredFlags & CArgsPredFlag) {
|
||||||
Int out = execute_cargs(pe, exec_code);
|
Int out = execute_cargs(pe, exec_code);
|
||||||
|
if (!out) {
|
||||||
|
Term t;
|
||||||
|
|
||||||
|
BallTerm = EX;
|
||||||
|
EX = NULL;
|
||||||
|
if ((t = Yap_GetException())) {
|
||||||
|
Yap_JumpToEnv(t);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
return out;
|
return out;
|
||||||
} else {
|
} else {
|
||||||
return((exec_code)());
|
return((exec_code)());
|
||||||
@ -1510,6 +1533,14 @@ YAP_ExecuteFirst(PredEntry *pe, CPredicate exec_code)
|
|||||||
val = ((codev)((&ARG1)-LCL0,0,ctx));
|
val = ((codev)((&ARG1)-LCL0,0,ctx));
|
||||||
}
|
}
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
|
Term t;
|
||||||
|
|
||||||
|
BallTerm = EX;
|
||||||
|
EX = NULL;
|
||||||
|
if ((t = Yap_GetException())) {
|
||||||
|
Yap_JumpToEnv(t);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
cut_fail();
|
cut_fail();
|
||||||
} else if (val == 1) { /* TRUE */
|
} else if (val == 1) { /* TRUE */
|
||||||
cut_succeed();
|
cut_succeed();
|
||||||
@ -1541,7 +1572,16 @@ YAP_ExecuteNext(PredEntry *pe, CPredicate exec_code)
|
|||||||
val = ((codev)((&ARG1)-LCL0,0,ctx));
|
val = ((codev)((&ARG1)-LCL0,0,ctx));
|
||||||
}
|
}
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
|
Term t;
|
||||||
|
|
||||||
|
BallTerm = EX;
|
||||||
|
EX = NULL;
|
||||||
|
if ((t = Yap_GetException())) {
|
||||||
|
Yap_JumpToEnv(t);
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
cut_fail();
|
cut_fail();
|
||||||
|
}
|
||||||
} else if (val == 1) { /* TRUE */
|
} else if (val == 1) { /* TRUE */
|
||||||
cut_succeed();
|
cut_succeed();
|
||||||
} else {
|
} else {
|
||||||
|
8
C/exec.c
8
C/exec.c
@ -1710,8 +1710,8 @@ p_debug_on(void)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
Term
|
||||||
GetException(void)
|
Yap_GetException(void)
|
||||||
{
|
{
|
||||||
Term t = 0L;
|
Term t = 0L;
|
||||||
if (BallTerm) {
|
if (BallTerm) {
|
||||||
@ -1743,7 +1743,7 @@ p_reset_exception(void)
|
|||||||
{
|
{
|
||||||
Term t;
|
Term t;
|
||||||
EX = NULL;
|
EX = NULL;
|
||||||
t = GetException();
|
t = Yap_GetException();
|
||||||
if (!t)
|
if (!t)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return Yap_unify(t, ARG1);
|
return Yap_unify(t, ARG1);
|
||||||
@ -1759,7 +1759,7 @@ Yap_ResetExceptionTerm(void)
|
|||||||
static Int
|
static Int
|
||||||
p_get_exception(void)
|
p_get_exception(void)
|
||||||
{
|
{
|
||||||
Term t = GetException();
|
Term t = Yap_GetException();
|
||||||
if (!t)
|
if (!t)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return Yap_unify(t, ARG1);
|
return Yap_unify(t, ARG1);
|
||||||
|
@ -180,6 +180,7 @@ void STD_PROTO(Yap_ResetExceptionTerm,(void));
|
|||||||
Int STD_PROTO(Yap_execute_goal,(Term, int, Term));
|
Int STD_PROTO(Yap_execute_goal,(Term, int, Term));
|
||||||
int STD_PROTO(Yap_exec_absmi,(int));
|
int STD_PROTO(Yap_exec_absmi,(int));
|
||||||
void STD_PROTO(Yap_trust_last,(void));
|
void STD_PROTO(Yap_trust_last,(void));
|
||||||
|
Term STD_PROTO(Yap_GetException,(void));
|
||||||
|
|
||||||
/* gprof.c */
|
/* gprof.c */
|
||||||
void STD_PROTO(Yap_InitLowProf,(void));
|
void STD_PROTO(Yap_InitLowProf,(void));
|
||||||
|
@ -1271,7 +1271,7 @@ X_API int PL_put_variable(term_t t)
|
|||||||
|
|
||||||
X_API int PL_raise_exception(term_t exception)
|
X_API int PL_raise_exception(term_t exception)
|
||||||
{
|
{
|
||||||
YAP_Throw(Yap_GetFromSlot(exception));
|
EX = Yap_StoreTermInDB(Yap_GetFromSlot(exception),0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2763,13 +2763,6 @@ PL_free(void *obj)
|
|||||||
free(obj);
|
free(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
PL_error(const char *pred, int arity, const char *msg, int id, ...)
|
|
||||||
{
|
|
||||||
fprintf(stderr,"Internal PL_error Not implemented\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
X_API int
|
X_API int
|
||||||
PL_eval_expression_to_int64_ex(term_t t, int64_t *val)
|
PL_eval_expression_to_int64_ex(term_t t, int64_t *val)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user