fix bad test faster interface to eval (obs from Jose Santos)
This commit is contained in:
parent
5fc26e1b45
commit
e86a995dd2
79
C/eval.c
79
C/eval.c
@ -42,6 +42,8 @@ Eval(Term t)
|
|||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
ArithError = TRUE;
|
ArithError = TRUE;
|
||||||
return Yap_ArithError(INSTANTIATION_ERROR,t,"in arithmetic");
|
return Yap_ArithError(INSTANTIATION_ERROR,t,"in arithmetic");
|
||||||
|
} else if (IsNumTerm(t)) {
|
||||||
|
return t;
|
||||||
} else if (IsAtomTerm(t)) {
|
} else if (IsAtomTerm(t)) {
|
||||||
ExpEntry *p;
|
ExpEntry *p;
|
||||||
Atom name = AtomOfTerm(t);
|
Atom name = AtomOfTerm(t);
|
||||||
@ -59,56 +61,43 @@ Eval(Term t)
|
|||||||
RepAtom(name)->StrOfAE);
|
RepAtom(name)->StrOfAE);
|
||||||
}
|
}
|
||||||
return Yap_eval_atom(p->FOfEE);
|
return Yap_eval_atom(p->FOfEE);
|
||||||
} else if (IsIntTerm(t)) {
|
|
||||||
return t;
|
|
||||||
} else if (IsApplTerm(t)) {
|
} else if (IsApplTerm(t)) {
|
||||||
Functor fun = FunctorOfTerm(t);
|
Functor fun = FunctorOfTerm(t);
|
||||||
switch ((CELL)fun) {
|
if ((Atom)fun == AtomFoundVar) {
|
||||||
case (CELL)FunctorLongInt:
|
return Yap_ArithError(TYPE_ERROR_EVALUABLE, TermNil,
|
||||||
case (CELL)FunctorDouble:
|
"cyclic term in arithmetic expression");
|
||||||
#ifdef USE_GMP
|
} else {
|
||||||
case (CELL)FunctorBigInt:
|
Int n = ArityOfFunctor(fun);
|
||||||
#endif
|
Atom name = NameOfFunctor(fun);
|
||||||
return t;
|
ExpEntry *p;
|
||||||
default:
|
Term t1, t2;
|
||||||
{
|
|
||||||
if ((Atom)fun == AtomFoundVar) {
|
|
||||||
return Yap_ArithError(TYPE_ERROR_EVALUABLE, TermNil,
|
|
||||||
"cyclic term in arithmetic expression");
|
|
||||||
} else {
|
|
||||||
Int n = ArityOfFunctor(fun);
|
|
||||||
Atom name = NameOfFunctor(fun);
|
|
||||||
ExpEntry *p;
|
|
||||||
Term t1, t2;
|
|
||||||
|
|
||||||
if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, n)))) {
|
if (EndOfPAEntr(p = RepExpProp(Yap_GetExpProp(name, n)))) {
|
||||||
Term ti[2];
|
Term ti[2];
|
||||||
|
|
||||||
/* error */
|
/* error */
|
||||||
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);
|
||||||
return 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);
|
||||||
}
|
|
||||||
*RepAppl(t) = (CELL)AtomFoundVar;
|
|
||||||
t1 = Eval(ArgOfTerm(1,t));
|
|
||||||
if (t1 == 0L) {
|
|
||||||
*RepAppl(t) = (CELL)fun;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (n == 1) {
|
|
||||||
*RepAppl(t) = (CELL)fun;
|
|
||||||
return Yap_eval_unary(p->FOfEE, t1);
|
|
||||||
}
|
|
||||||
t2 = Eval(ArgOfTerm(2,t));
|
|
||||||
*RepAppl(t) = (CELL)fun;
|
|
||||||
if (t2 == 0L)
|
|
||||||
return FALSE;
|
|
||||||
return Yap_eval_binary(p->FOfEE,t1,t2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
*RepAppl(t) = (CELL)AtomFoundVar;
|
||||||
|
t1 = Eval(ArgOfTerm(1,t));
|
||||||
|
if (t1 == 0L) {
|
||||||
|
*RepAppl(t) = (CELL)fun;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (n == 1) {
|
||||||
|
*RepAppl(t) = (CELL)fun;
|
||||||
|
return Yap_eval_unary(p->FOfEE, t1);
|
||||||
|
}
|
||||||
|
t2 = Eval(ArgOfTerm(2,t));
|
||||||
|
*RepAppl(t) = (CELL)fun;
|
||||||
|
if (t2 == 0L)
|
||||||
|
return FALSE;
|
||||||
|
return Yap_eval_binary(p->FOfEE,t1,t2);
|
||||||
}
|
}
|
||||||
} /* else if (IsPairTerm(t)) */ {
|
} /* else if (IsPairTerm(t)) */ {
|
||||||
if (TailOfTerm(t) != TermNil) {
|
if (TailOfTerm(t) != TermNil) {
|
||||||
|
@ -172,6 +172,8 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
|||||||
LOCK(Yap_heap_regs->low_level_trace_lock);
|
LOCK(Yap_heap_regs->low_level_trace_lock);
|
||||||
sc = Yap_heap_regs;
|
sc = Yap_heap_regs;
|
||||||
vsc_count++;
|
vsc_count++;
|
||||||
|
if (vsc_count < 77000)
|
||||||
|
return;
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
Yap_heap_regs->thread_handle[worker_id].thread_inst_count++;
|
Yap_heap_regs->thread_handle[worker_id].thread_inst_count++;
|
||||||
#endif
|
#endif
|
||||||
|
2
H/eval.h
2
H/eval.h
@ -175,7 +175,7 @@ Int STD_PROTO(Yap_ArithError,(yap_error_number,Term,char *msg, ...));
|
|||||||
inline EXTERN Term
|
inline EXTERN Term
|
||||||
Yap_Eval(Term t)
|
Yap_Eval(Term t)
|
||||||
{
|
{
|
||||||
if (t == 0L || !IsVarTerm(t) || IsNumTerm(t))
|
if (t == 0L || ( !IsVarTerm(t) && IsNumTerm(t) ))
|
||||||
return t;
|
return t;
|
||||||
return Yap_InnerEval(t);
|
return Yap_InnerEval(t);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user