fix exception

This commit is contained in:
Vítor Santos Costa 2018-04-16 22:51:34 +01:00
parent abb328abf0
commit 7bfe8aedbe
6 changed files with 19 additions and 16 deletions

View File

@ -551,7 +551,6 @@ static char tmpbuf[YAP_BUF_SIZE];
#include "YapErrors.h"
bool Yap_pushErrorContext(bool pass, yap_error_descriptor_t *new_error) {
yap_error_number err = LOCAL_ActiveError->errorNo;
memset(new_error, 0, sizeof(yap_error_descriptor_t));
new_error->top_error = LOCAL_ActiveError;
LOCAL_ActiveError = new_error;
@ -1029,7 +1028,10 @@ static Int get_exception(USES_REGS1) {
} else {
t = mkerrort(i->errorNo, TermNil, MkSysError(i));
}
return Yap_unify(t, ARG1);
while (B && B->cp_b && ! Yap_unify(t, B->cp_a2)) {
Yap_JumpToEnv();
}
return true;
}
return false;
}

View File

@ -148,8 +148,8 @@ static Term Eval(Term t USES_REGS) {
}
t2 = Eval(ArgOfTerm(2, t) PASS_REGS);
*RepAppl(t) = (CELL)fun;
LOCAL_ctx = ctx.p;
return Yap_eval_binary(p->FOfEE, t1, t2);
LOCAL_ctx = ctx.p;
return Yap_eval_binary(p->FOfEE, t1, t2);
}
} /* else if (IsPairTerm(t)) */
{
@ -208,8 +208,8 @@ static Int p_is(USES_REGS1) { /* X is Y */
}
do {
go = false;
out = Yap_InnerEval(Deref(ARG2));
Yap_CheckArithError();
out = Yap_Eval(t PASS_REGS);
go = Yap_CheckArithError();
} while (go);
return Yap_unify_constant(ARG1, out);
}

View File

@ -632,7 +632,7 @@ __Yap_Mk64IntegerTerm(YAP_LONG_LONG i USES_REGS) {
}
inline static Term add_int(Int i, Int j USES_REGS) {
#if defined(__clang__)
#if defined(__clang__) || defined(__GNUC__)
Int w;
if (!__builtin_add_overflow(i, j, &w))
RINT(w);

View File

@ -24,11 +24,13 @@ inline static int sub_overflow(Int x, Int i, Int j) {
}
inline static Term sub_int(Int i, Int j USES_REGS) {
#if defined(__clang__)
Int w;
if (!__builtin_sub_overflow(i,j,&w))
RINT(w);
return Yap_gmp_add_ints(i, j);
#if defined(__clang__ ) || defined(__GNUC__)
Int k;
if (__builtin_sub_overflow(i,j,&k)) {
return Yap_gmp_add_ints(i, j);
}
printf("%ld %ld %ld\n", i, j , k);
RINT(k);
#elif defined(__GNUC__)
Int w;
if (!__builtin_sub_overflow_p(i,j,w))

View File

@ -332,6 +332,7 @@ once(G) :-
'$meta_call'(C, M),
!.
(:- G) :- '$execute'(G), !.
(?- G) :- '$execute'(G).

View File

@ -965,10 +965,8 @@ catch(G, C, A) :-
).
'$catch'(_,C,A) :-
'$get_exception'(C),
!,
'$run_catch'(A, C).
'$catch'(_,_C,A) :-
throw(A).
%( C = C0 -> '$execute'(A) ; throw(A0) ).
'$run_catch'(C,A).
% variable throws are user-handled.
'$run_catch'(G,E) :-