Merge branch 'master' of git@git.dcc.fc.up.pt:yap-6.3

This commit is contained in:
Fabrizio Riguzzi 2014-10-16 17:23:22 +02:00
commit fa24b214af
15 changed files with 25787 additions and 4393 deletions

View File

@ -154,12 +154,12 @@ eval0(Int fi) {
case op_inf:
{
#ifdef _MSC_VER /* Microsoft's Visual C++ Compiler */
Yap_Error(TYPE_ERROR_EVALUABLE, TermNil, "evaluating infinity");
Yap_ArithError(TYPE_ERROR_EVALUABLE, TermNil, "evaluating infinity");
P = (yamop *)FAILCODE;
RERROR();
#else
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) {/* iso */
Yap_Error(TYPE_ERROR_EVALUABLE, TermNil, "evaluating infinity");
Yap_ArithError(TYPE_ERROR_EVALUABLE, TermNil, "evaluating infinity");
P = (yamop *)FAILCODE;
RERROR();
} else {
@ -170,13 +170,11 @@ eval0(Int fi) {
case op_nan:
{
#ifdef _MSC_VER /* Microsoft's Visual C++ Compi<ler */
Yap_Error(TYPE_ERROR_EVALUABLE, TermNil, "evaluating infinity");
P = (yamop *)FAILCODE;
Yap_ArithError(TYPE_ERROR_EVALUABLE, TermNil, "evaluating infinity");
RERROR();
#else
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) {/* iso */
Yap_Error(TYPE_ERROR_EVALUABLE, TermNil, "evaluating not-a-number");
P = (yamop *)FAILCODE;
Yap_ArithError(TYPE_ERROR_EVALUABLE, TermNil, "evaluating not-a-number");
RERROR();
} else {
RFLOAT(NAN);
@ -287,7 +285,7 @@ Yap_InitConstExps(void)
for (i = 0; i < sizeof(InitConstTab)/sizeof(InitConstEntry); ++i) {
AtomEntry *ae = RepAtom(Yap_LookupAtom(InitConstTab[i].OpName));
if (ae == NULL) {
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"at InitConstExps");
Yap_EvalError(OUT_OF_HEAP_ERROR,TermNil,"at InitConstExps");
return;
}
WRITE_LOCK(ae->ARWLock);

View File

@ -951,34 +951,40 @@ static InitUnEntry InitUnTab[] = {
{"random", op_random1}
};
Atom
Yap_NameOfUnaryOp(int i)
{
return Yap_LookupAtom(InitUnTab[i].OpName);
}
static Int
p_unary_is( USES_REGS1 )
{ /* X is Y */
Term t = Deref(ARG2);
Term top;
yap_error_number err;
LOCAL_mathn = 1;
if (IsVarTerm(t)) {
Yap_Error(INSTANTIATION_ERROR, ARG2, "X is Y");
Yap_EvalError(INSTANTIATION_ERROR, t, "unbound unary operator");
return FALSE;
}
Yap_ClearExs();
top = Yap_Eval(Deref(ARG3));
if (Yap_FoundArithError()) {
LOCAL_mathtt[0] = top;
return TRUE;
if ((err=Yap_FoundArithError())) {
Yap_EvalError(err,ARG3,"X is op(Y): error in Y ");
return FALSE;
}
if (IsIntTerm(t)) {
Term tout;
Int i;
LOCAL_mathop = i = IntegerOfTerm(t);
i = IntegerOfTerm(t);
tout = eval1(i, top PASS_REGS);
if (Yap_FoundArithError()) {
LOCAL_mathtt[0] = top;
LOCAL_mathop = i;
LOCAL_mathn = 1;
return TRUE;
if ((err=Yap_FoundArithError())) {
Functor f = Yap_MkFunctor( Yap_NameOfUnaryOp(i), 1 );
Term t = Yap_MkApplTerm( f, 1, &top );
Yap_EvalError(err, t ,"error in %s/1 ", RepAtom(NameOfFunctor(f))->StrOfAE);
return FALSE;
}
return Yap_unify_constant(ARG1,tout);
}
@ -988,26 +994,25 @@ p_unary_is( USES_REGS1 )
Term out;
if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, 1)))) {
Term ti[2];
/* error */
ti[0] = t;
ti[1] = MkIntTerm(1);
t = Yap_MkApplTerm(FunctorSlash, 2, ti);
Yap_Error(TYPE_ERROR_EVALUABLE, t,
Yap_EvalError(TYPE_ERROR_EVALUABLE, t,
"functor %s/%d for arithmetic expression",
RepAtom(name)->StrOfAE,1);
P = FAILCODE;
return(FALSE);
}
LOCAL_mathop = p->FOfEE;
out= eval1(p->FOfEE, top PASS_REGS);
if (Yap_FoundArithError()) {
LOCAL_mathtt[0] = top;
LOCAL_mathop = p->FOfEE;
LOCAL_mathn = 1;
return FALSE;
}
}
out= eval1(p->FOfEE, top PASS_REGS);
if ((err=Yap_FoundArithError())) {
Functor f = Yap_MkFunctor( name, 1 );
Term t = Yap_MkApplTerm( f, 1, &top );
Yap_EvalError(err, t ,"error in %s/1", RepAtom(name)->StrOfAE);
return FALSE;
}
return Yap_unify_constant(ARG1,out);
}
return(FALSE);
@ -1019,7 +1024,7 @@ p_unary_op_as_integer( USES_REGS1 )
Term t = Deref(ARG1);
if (IsVarTerm(t)) {
Yap_Error(INSTANTIATION_ERROR,t, "X is Y");
Yap_EvalError(INSTANTIATION_ERROR,t, "X is _Y");
return(FALSE);
}
if (IsIntTerm(t)) {
@ -1037,12 +1042,6 @@ p_unary_op_as_integer( USES_REGS1 )
return(FALSE);
}
Atom
Yap_NameOfUnaryOp(int i)
{
return Yap_LookupAtom(InitUnTab[i].OpName);
}
void
Yap_InitUnaryExps(void)
{
@ -1052,7 +1051,7 @@ Yap_InitUnaryExps(void)
for (i = 0; i < sizeof(InitUnTab)/sizeof(InitUnEntry); ++i) {
AtomEntry *ae = RepAtom(Yap_LookupAtom(InitUnTab[i].OpName));
if (ae == NULL) {
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"at InitUnaryExps");
Yap_EvalError(OUT_OF_HEAP_ERROR,TermNil,"at InitUnaryExps");
return;
}
WRITE_LOCK(ae->ARWLock);

View File

@ -1146,31 +1146,49 @@ p_binary_is( USES_REGS1 )
{ /* X is Y */
Term t = Deref(ARG2);
Term t1, t2;
yap_error_number err;
if (IsVarTerm(t)) {
Yap_ArithError(INSTANTIATION_ERROR,t, "X is Y");
Yap_ArithError(INSTANTIATION_ERROR,t, "VAR(X , Y)");
return(FALSE);
}
Yap_ClearExs();
t1 = Yap_Eval(Deref(ARG3));
if (Yap_FoundArithError()) {
LOCAL_mathtt[0] = t1;
return FALSE;
if ((err = Yap_FoundArithError())) {
Atom name;
if (IsIntTerm(t)) {
Int i = IntOfTerm(t);
name = Yap_NameOfBinaryOp(i);
} else {
name = AtomOfTerm(Deref(ARG2));
}
Yap_EvalError(err,ARG3,"X is ~s/2: error in first argument ", RepAtom(name)->StrOfAE);
return FALSE;
}
LOCAL_mathtt[0] = t1;
t2 = Yap_Eval(Deref(ARG4));
if (Yap_FoundArithError()) {
LOCAL_mathtt[0] = t2;
if ((err=Yap_FoundArithError())) {
Atom name;
if (IsIntTerm(t)) {
Int i = IntOfTerm(t);
name = Yap_NameOfBinaryOp(i);
} else {
name = AtomOfTerm(Deref(ARG2));
}
Yap_EvalError(err,ARG3,"X is ~s/2: error in first argument ", RepAtom(name)->StrOfAE);
return FALSE;
}
if (IsIntTerm(t)) {
Term tout = eval2(IntOfTerm(t), t1, t2 PASS_REGS);
Int i = IntOfTerm(t);
Term tout = eval2(i, t1, t2 PASS_REGS);
if (Yap_FoundArithError()) {
LOCAL_mathtt[0] = t1;
LOCAL_mathtt[1] = t2;
LOCAL_mathn = 2;
LOCAL_mathop = IntOfTerm(t);
return FALSE;
Term ts[2], terr;
Atom name = Yap_NameOfBinaryOp( i );
Functor f = Yap_MkFunctor( name, 2 );
ts[0] = t1;
ts[1] = t2;
terr = Yap_MkApplTerm( f, 2, ts );
Yap_EvalError(err, terr ,"error in ~s/2 ", RepAtom(name)->StrOfAE);
return FALSE;
}
return Yap_unify_constant(ARG1,tout);
}
@ -1186,7 +1204,7 @@ p_binary_is( USES_REGS1 )
ti[0] = t;
ti[1] = MkIntTerm(1);
t = Yap_MkApplTerm(FunctorSlash, 2, ti);
Yap_Error(TYPE_ERROR_EVALUABLE, t,
Yap_EvalError(TYPE_ERROR_EVALUABLE, t,
"functor %s/%d for arithmetic expression",
RepAtom(name)->StrOfAE,2);
P = FAILCODE;
@ -1194,10 +1212,12 @@ p_binary_is( USES_REGS1 )
}
out= eval2(p->FOfEE, t1, t2 PASS_REGS);
if (Yap_FoundArithError()) {
LOCAL_mathtt[0] = t1;
LOCAL_mathtt[1] = t2;
LOCAL_mathn = 2;
LOCAL_mathop = IntOfTerm(t);
Term ts[2], terr;
Functor f = Yap_MkFunctor( name, 2 );
ts[0] = t1;
ts[1] = t2;
terr = Yap_MkApplTerm( f, 2, ts );
Yap_EvalError(err, terr ,"error in ~s/2 ", RepAtom(name)->StrOfAE);
return FALSE;
}
return Yap_unify_constant(ARG1,out);
@ -1213,10 +1233,11 @@ do_arith23(arith2_op op USES_REGS)
Term t = Deref(ARG1);
Int out;
Term t1, t2;
yap_error_number err;
Yap_ClearExs();
if (IsVarTerm(t)) {
Yap_ArithError(INSTANTIATION_ERROR,t, "X is Y");
Yap_EvalError(INSTANTIATION_ERROR,t, "X is Y");
return(FALSE);
}
t1 = Yap_Eval(t);
@ -1226,12 +1247,14 @@ do_arith23(arith2_op op USES_REGS)
if (t2 == 0L)
return FALSE;
out= eval2(op, t1, t2 PASS_REGS);
if (Yap_FoundArithError()) {
LOCAL_mathtt[0] = t1;
LOCAL_mathtt[1] = t2;
LOCAL_mathn = 2;
LOCAL_mathop = op;
return FALSE;
if ((err=Yap_FoundArithError())) {
Term ts[2], t;
Functor f = Yap_MkFunctor( Yap_NameOfBinaryOp(op), 2 );
ts[0] = t1;
ts[1] = t2;
t = Yap_MkApplTerm( f, 2, ts );
Yap_EvalError(err, t ,"error in ~s(Y,Z) ",Yap_NameOfBinaryOp(op));
return FALSE;
}
return Yap_unify_constant(ARG3,out);
}
@ -1290,7 +1313,7 @@ p_binary_op_as_integer( USES_REGS1 )
Term t = Deref(ARG1);
if (IsVarTerm(t)) {
Yap_Error(INSTANTIATION_ERROR,t, "X is Y");
Yap_EvalError(INSTANTIATION_ERROR,t, "X is Y");
return(FALSE);
}
if (IsIntTerm(t)) {
@ -1324,7 +1347,7 @@ Yap_InitBinaryExps(void)
for (i = 0; i < sizeof(InitBinTab)/sizeof(InitBinEntry); ++i) {
AtomEntry *ae = RepAtom(Yap_LookupAtom(InitBinTab[i].OpName));
if (ae == NULL) {
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"at InitBinaryExps");
Yap_EvalError(OUT_OF_HEAP_ERROR,TermNil,"at InitBinaryExps");
return;
}
WRITE_LOCK(ae->ARWLock);

View File

@ -554,7 +554,8 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
int psize = YAP_BUF_SIZE;
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (where == 0L)
Yap_ClearExs();
if (where == 0L)
where = TermNil;
#if DEBUG_STRICT
if (Yap_heap_regs && !(LOCAL_PrologMode & BootMode))

113
C/eval.c
View File

@ -107,8 +107,15 @@ Eval(Term t USES_REGS)
if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, 0)))) {
/* error */
Term ti[2];
/* error */
ti[0] = t;
ti[1] = MkIntTerm(0);
t = Yap_MkApplTerm(FunctorSlash, 2, ti);
return Yap_ArithError(TYPE_ERROR_EVALUABLE, t,
"atom %s for arithmetic expression",
"atom %s in arithmetic expression",
RepAtom(name)->StrOfAE);
}
return Yap_eval_atom(p->FOfEE);
@ -214,27 +221,29 @@ static Int
p_is( USES_REGS1 )
{ /* X is Y */
Term out = 0L;
yap_error_number err;
Term t = Deref(ARG2);
if (IsVarTerm(t)) {
Yap_EvalError(INSTANTIATION_ERROR,t, "X is Y");
return(FALSE);
}
Yap_ClearExs();
while (!(out = Yap_InnerEval(Deref(ARG2)))) {
if (LOCAL_Error_TYPE == RESOURCE_ERROR_STACK) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, CP)) {
Yap_Error(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
return FALSE;
}
} else {
LOCAL_mathtt[0] = Deref(ARG2);
LOCAL_mathop = 0;
LOCAL_mathn = 0;
return FALSE;
do {
out = Yap_InnerEval(Deref(ARG2));
if ((err = Yap_FoundArithError()) == YAP_NO_ERROR)
break;
if (err == RESOURCE_ERROR_STACK) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, CP)) {
Yap_EvalError(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
return FALSE;
}
Yap_Error(LOCAL_Error_TYPE, LOCAL_mathtt[0], LOCAL_ErrorMessage);
return FALSE;
}
if (Yap_FoundArithError()) {
return TRUE;
}
} else {
Yap_EvalError(err, ARG2, "X is Exp");
return FALSE;
}
} while (TRUE);
return Yap_unify_constant(ARG1,out);
}
@ -256,20 +265,20 @@ p_isnan( USES_REGS1 )
if (LOCAL_Error_TYPE == RESOURCE_ERROR_STACK) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, CP)) {
Yap_Error(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
Yap_EvalError(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
Yap_EvalError(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
return FALSE;
}
}
if (IsVarTerm(out)) {
Yap_Error(INSTANTIATION_ERROR, out, "isnan/1");
Yap_EvalError(INSTANTIATION_ERROR, out, "isnan/1");
return FALSE;
}
if (!IsFloatTerm(out)) {
Yap_Error(TYPE_ERROR_FLOAT, out, "isnan/1");
Yap_EvalError(TYPE_ERROR_FLOAT, out, "isnan/1");
return FALSE;
}
return isnan(FloatOfTerm(out));
@ -291,20 +300,20 @@ p_isinf( USES_REGS1 )
if (LOCAL_Error_TYPE == RESOURCE_ERROR_STACK) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, CP)) {
Yap_Error(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
Yap_EvalError(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
Yap_EvalError(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
return FALSE;
}
}
if (IsVarTerm(out)) {
Yap_Error(INSTANTIATION_ERROR, out, "isinf/1");
Yap_EvalError(INSTANTIATION_ERROR, out, "isinf/1");
return FALSE;
}
if (!IsFloatTerm(out)) {
Yap_Error(TYPE_ERROR_FLOAT, out, "isinf/1");
Yap_EvalError(TYPE_ERROR_FLOAT, out, "isinf/1");
return FALSE;
}
return isinf(FloatOfTerm(out));
@ -345,11 +354,11 @@ p_logsum( USES_REGS1 )
if (LOCAL_Error_TYPE == RESOURCE_ERROR_STACK) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 1, ENV, CP)) {
Yap_Error(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
Yap_EvalError(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
Yap_EvalError(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -373,11 +382,11 @@ p_logsum( USES_REGS1 )
if (LOCAL_Error_TYPE == RESOURCE_ERROR_STACK) {
LOCAL_Error_TYPE = YAP_NO_ERROR;
if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, CP)) {
Yap_Error(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
Yap_EvalError(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
return FALSE;
}
} else {
Yap_Error(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
Yap_EvalError(LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
return FALSE;
}
}
@ -400,6 +409,8 @@ Yap_ArithError(yap_error_number type, Term where, char *format,...)
CACHE_REGS
va_list ap;
if (LOCAL_ArithError)
return 0L;
LOCAL_ArithError = TRUE;
LOCAL_Error_TYPE = type;
LOCAL_Error_Term = where;
@ -419,6 +430,32 @@ Yap_ArithError(yap_error_number type, Term where, char *format,...)
return 0L;
}
yamop *
Yap_EvalError(yap_error_number type, Term where, char *format,...)
{
CACHE_REGS
va_list ap;
if (LOCAL_ArithError) {
return Yap_Error( LOCAL_Error_TYPE, LOCAL_Error_Term, LOCAL_ErrorMessage);
}
if (!LOCAL_ErrorMessage)
LOCAL_ErrorMessage = LOCAL_ErrorSay;
va_start (ap, format);
if (format != NULL) {
#if HAVE_VSNPRINTF
(void) vsnprintf(LOCAL_ErrorMessage, MAX_ERROR_MSG_SIZE, format, ap);
#else
(void) vsprintf(LOCAL_ErrorMessage, format, ap);
#endif
} else {
LOCAL_ErrorMessage[0] = '\0';
}
va_end (ap);
return Yap_Error( type, where, LOCAL_ErrorMessage);
}
/**
@{
@ -478,23 +515,23 @@ init_between( USES_REGS1 )
Term t2 = Deref(ARG2);
if (IsVarTerm(t1)) {
Yap_Error(INSTANTIATION_ERROR, t1, "between/3");
Yap_EvalError(INSTANTIATION_ERROR, t1, "between/3");
return FALSE;
}
if (IsVarTerm(t2)) {
Yap_Error(INSTANTIATION_ERROR, t1, "between/3");
Yap_EvalError(INSTANTIATION_ERROR, t1, "between/3");
return FALSE;
}
if (!IsIntegerTerm(t1) &&
!IsBigIntTerm(t1)) {
Yap_Error(TYPE_ERROR_INTEGER, t1, "between/3");
Yap_EvalError(TYPE_ERROR_INTEGER, t1, "between/3");
return FALSE;
}
if (!IsIntegerTerm(t2) &&
!IsBigIntTerm(t2) &&
t2 != MkAtomTerm(AtomInf) &&
t2 != MkAtomTerm(AtomInfinity)) {
Yap_Error(TYPE_ERROR_INTEGER, t2, "between/3");
Yap_EvalError(TYPE_ERROR_INTEGER, t2, "between/3");
return FALSE;
}
if (IsIntegerTerm(t1) && IsIntegerTerm(t2)) {
@ -506,7 +543,7 @@ init_between( USES_REGS1 )
if (!IsVarTerm(t3)) {
if (!IsIntegerTerm(t3)) {
if (!IsBigIntTerm(t3)) {
Yap_Error(TYPE_ERROR_INTEGER, t3, "between/3");
Yap_EvalError(TYPE_ERROR_INTEGER, t3, "between/3");
return FALSE;
}
cut_fail();
@ -530,7 +567,7 @@ init_between( USES_REGS1 )
if (!IsVarTerm(t3)) {
if (!IsIntegerTerm(t3)) {
if (!IsBigIntTerm(t3)) {
Yap_Error(TYPE_ERROR_INTEGER, t3, "between/3");
Yap_EvalError(TYPE_ERROR_INTEGER, t3, "between/3");
return FALSE;
}
cut_fail();
@ -547,7 +584,7 @@ init_between( USES_REGS1 )
if (!IsVarTerm(t3)) {
if (!IsIntegerTerm(t3) && !IsBigIntTerm(t3)) {
Yap_Error(TYPE_ERROR_INTEGER, t3, "between/3");
Yap_EvalError(TYPE_ERROR_INTEGER, t3, "between/3");
return FALSE;
}
if (Yap_acmp(t3, t1 PASS_REGS) >= 0 && Yap_acmp(t2,t3 PASS_REGS) >= 0 && P != FAILCODE)

View File

@ -1427,39 +1427,39 @@ Yap_MathException__( USES_REGS1 )
feclearexcept(FE_ALL_EXCEPT);
if (raised & FE_OVERFLOW) {
LOCAL_matherror = EVALUATION_ERROR_FLOAT_OVERFLOW;
return EVALUATION_ERROR_FLOAT_OVERFLOW;
} else if (raised & (FE_INVALID|FE_INEXACT)) {
LOCAL_matherror = EVALUATION_ERROR_UNDEFINED;
return EVALUATION_ERROR_UNDEFINED;
} else if (raised & FE_DIVBYZERO) {
LOCAL_matherror = EVALUATION_ERROR_ZERO_DIVISOR;
return EVALUATION_ERROR_ZERO_DIVISOR;
} else if (raised & FE_UNDERFLOW) {
LOCAL_matherror = EVALUATION_ERROR_FLOAT_UNDERFLOW;
return EVALUATION_ERROR_FLOAT_UNDERFLOW;
} else {
LOCAL_matherror = EVALUATION_ERROR_UNDEFINED;
return EVALUATION_ERROR_UNDEFINED;
}
}
#elif (defined(__svr4__) || defined(__SVR4))
switch(sip->si_code) {
case FPE_INTDIV:
LOCAL_matherror = EVALUATION_ERROR_ZERO_DIVISOR;
return EVALUATION_ERROR_ZERO_DIVISOR;
break;
case FPE_INTOVF:
LOCAL_matherror = EVALUATION_ERROR_INT_OVERFLOW;
return EVALUATION_ERROR_INT_OVERFLOW;
break;
case FPE_FLTDIV:
LOCAL_matherror = EVALUATION_ERROR_ZERO_DIVISOR;
return EVALUATION_ERROR_ZERO_DIVISOR;
break;
case FPE_FLTOVF:
LOCAL_matherror = EVALUATION_ERROR_FLOAT_OVERFLOW;
return EVALUATION_ERROR_FLOAT_OVERFLOW;
break;
case FPE_FLTUND:
LOCAL_matherror = EVALUATION_ERROR_FLOAT_UNDERFLOW;
return EVALUATION_ERROR_FLOAT_UNDERFLOW;
break;
case FPE_FLTRES:
case FPE_FLTINV:
case FPE_FLTSUB:
default:
LOCAL_matherror = EVALUATION_ERROR_UNDEFINED;
return EVALUATION_ERROR_UNDEFINED;
}
set_fpu_exceptions(0);
#endif
@ -1470,24 +1470,10 @@ Yap_MathException__( USES_REGS1 )
static Int
p_fpe_error( USES_REGS1 )
{
if (LOCAL_mathn == 0) {
Yap_Error(LOCAL_matherror, LOCAL_mathtt[0], "arithmetic");
} else if (LOCAL_mathn == 1) {
Term t;
Functor f;
f = Yap_MkFunctor( Yap_NameOfUnaryOp(LOCAL_mathop), 1);
t = Yap_MkApplTerm(f, 1, LOCAL_mathtt);
Yap_Error(LOCAL_matherror, t, "arithmetic");
} else if (LOCAL_mathn == 2) {
Term t;
Functor f;
f = Yap_MkFunctor( Yap_NameOfBinaryOp(LOCAL_mathop), 2);
t = Yap_MkApplTerm(f, 2, LOCAL_mathtt);
Yap_Error(LOCAL_matherror, t, "arithmetic");
}
Yap_Error(LOCAL_matherror, LOCAL_mathtt, LOCAL_mathstring);
LOCAL_matherror = YAP_NO_ERROR;
LOCAL_mathtt = TermNil;
LOCAL_mathstring = NULL;
return FALSE;
}

View File

@ -308,10 +308,8 @@
#define REMOTE_matherror(wid) REMOTE(wid)->matherror_
#define LOCAL_mathtt LOCAL->mathtt_
#define REMOTE_mathtt(wid) REMOTE(wid)->mathtt_
#define LOCAL_mathn LOCAL->mathn_
#define REMOTE_mathn(wid) REMOTE(wid)->mathn_
#define LOCAL_mathop LOCAL->mathop_
#define REMOTE_mathop(wid) REMOTE(wid)->mathop_
#define LOCAL_mathstring LOCAL->mathstring_
#define REMOTE_mathstring(wid) REMOTE(wid)->mathstring_
#define LOCAL_CurrentError LOCAL->CurrentError_
#define REMOTE_CurrentError(wid) REMOTE(wid)->CurrentError_

View File

@ -365,6 +365,7 @@ Term Yap_eval_binary(Int,Term,Term);
Term Yap_InnerEval__(Term USES_REGS);
Int Yap_ArithError(yap_error_number,Term,char *msg, ...);
yamop* Yap_EvalError(yap_error_number,Term,char *msg, ...);
#include "inline-only.h"
@ -390,15 +391,12 @@ Yap_ClearExs(void)
feclearexcept(FE_ALL_EXCEPT);
}
inline static bool
inline static yap_error_number
Yap_FoundArithError__(USES_REGS1)
{
if (Yap_MathException() || LOCAL_Error_TYPE) {
Yap_external_signal( worker_id, YAP_FPE_SIGNAL );
regcache->P_ = FAILCODE;
return true;
}
return false;
if (LOCAL_Error_TYPE != YAP_NO_ERROR)
return LOCAL_Error_TYPE;
return Yap_MathException();
}
Atom Yap_NameOfUnaryOp(int i);

View File

@ -173,9 +173,8 @@ typedef struct worker_local {
struct db_globs* s_dbg_;
yap_error_number matherror_;
Term mathtt_[4];
Int mathn_;
Term mathop_;
Term mathtt_;
char* mathstring_;
yap_error_number CurrentError_;
int heap_overflows_;

View File

@ -174,8 +174,7 @@ static void InitWorker(int wid) {
REMOTE_matherror(wid) = YAP_NO_ERROR;
REMOTE_mathn(wid) = 0;
REMOTE_mathop(wid) = YAP_NO_ERROR;
REMOTE_mathstring(wid) = NULL;
REMOTE_CurrentError(wid) = YAP_NO_ERROR;
REMOTE_heap_overflows(wid) = 0;

View File

@ -188,7 +188,6 @@ static void RestoreWorker(int wid USES_REGS) {
#ifdef LOAD_DYLD
#endif

View File

@ -983,9 +983,6 @@
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION

29838
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -195,9 +195,8 @@ struct db_globs* s_dbg void
//eval.c
yap_error_number matherror =YAP_NO_ERROR
Term mathtt[4] void
Int mathn =0
int mathop =0
Term mathtt void
char* mathstring =NULL
yap_error_number CurrentError =YAP_NO_ERROR
//grow.c

View File

@ -45,6 +45,5 @@ mkdir -p packages/cplint/approx/simplecuddLPADs
AC_CONFIG_FILES([packages/cplint/Makefile])
AC_CONFIG_FILES([packages/cplint/approx/simplecuddLPADs/Makefile])
AC_CONFIG_FILES([packages/cplint/slipcase/Makefile])