never do P=FAILCODE directly in the code.
This commit is contained in:
parent
9852f7781d
commit
8e1c8d723e
16
C/eval.c
16
C/eval.c
@ -46,11 +46,9 @@ Eval(Term t)
|
|||||||
ti[1] = MkIntegerTerm(0);
|
ti[1] = MkIntegerTerm(0);
|
||||||
/* error */
|
/* error */
|
||||||
terror = Yap_MkApplTerm(FunctorSlash, 2, ti);
|
terror = Yap_MkApplTerm(FunctorSlash, 2, ti);
|
||||||
Yap_ArithError(TYPE_ERROR_EVALUABLE, terror,
|
return Yap_ArithError(TYPE_ERROR_EVALUABLE, terror,
|
||||||
"atom %s for arithmetic expression",
|
"atom %s for arithmetic expression",
|
||||||
RepAtom(name)->StrOfAE);
|
RepAtom(name)->StrOfAE);
|
||||||
P = (yamop *)FAILCODE;
|
|
||||||
return 0L;
|
|
||||||
}
|
}
|
||||||
return Yap_eval_atom(p->FOfEE);
|
return Yap_eval_atom(p->FOfEE);
|
||||||
} else if (IsIntTerm(t)) {
|
} else if (IsIntTerm(t)) {
|
||||||
@ -67,10 +65,8 @@ Eval(Term t)
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if ((Atom)fun == AtomFoundVar) {
|
if ((Atom)fun == AtomFoundVar) {
|
||||||
Yap_ArithError(TYPE_ERROR_EVALUABLE, TermNil,
|
return Yap_ArithError(TYPE_ERROR_EVALUABLE, TermNil,
|
||||||
"cyclic term in arithmetic expression");
|
"cyclic term in arithmetic expression");
|
||||||
P = (yamop *)FAILCODE;
|
|
||||||
RERROR();
|
|
||||||
} else {
|
} else {
|
||||||
Int n = ArityOfFunctor(fun);
|
Int n = ArityOfFunctor(fun);
|
||||||
Atom name = NameOfFunctor(fun);
|
Atom name = NameOfFunctor(fun);
|
||||||
@ -84,11 +80,9 @@ Eval(Term t)
|
|||||||
ti[0] = t;
|
ti[0] = t;
|
||||||
ti[1] = MkIntegerTerm(n);
|
ti[1] = MkIntegerTerm(n);
|
||||||
t = Yap_MkApplTerm(FunctorSlash, 2, ti);
|
t = Yap_MkApplTerm(FunctorSlash, 2, ti);
|
||||||
Yap_ArithError(TYPE_ERROR_EVALUABLE, t,
|
return Yap_ArithError(TYPE_ERROR_EVALUABLE, t,
|
||||||
"functor %s/%d for arithmetic expression",
|
"functor %s/%d for arithmetic expression",
|
||||||
RepAtom(name)->StrOfAE,n);
|
RepAtom(name)->StrOfAE,n);
|
||||||
P = (yamop *)FAILCODE;
|
|
||||||
RERROR();
|
|
||||||
}
|
}
|
||||||
*RepAppl(t) = (CELL)AtomFoundVar;
|
*RepAppl(t) = (CELL)AtomFoundVar;
|
||||||
t1 = Eval(ArgOfTerm(1,t));
|
t1 = Eval(ArgOfTerm(1,t));
|
||||||
@ -110,10 +104,8 @@ Eval(Term t)
|
|||||||
}
|
}
|
||||||
} /* else if (IsPairTerm(t)) */ {
|
} /* else if (IsPairTerm(t)) */ {
|
||||||
if (TailOfTerm(t) != TermNil) {
|
if (TailOfTerm(t) != TermNil) {
|
||||||
Yap_ArithError(TYPE_ERROR_EVALUABLE, t,
|
return Yap_ArithError(TYPE_ERROR_EVALUABLE, t,
|
||||||
"string must contain a single character to be evaluated as an arithmetic expression");
|
"string must contain a single character to be evaluated as an arithmetic expression");
|
||||||
P = FAILCODE;
|
|
||||||
return 0L;
|
|
||||||
}
|
}
|
||||||
return Eval(HeadOfTerm(t));
|
return Eval(HeadOfTerm(t));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user