support for tabling of bignums and strings

This commit is contained in:
Vítor Santos Costa
2014-01-17 09:39:29 +00:00
parent f3e5639439
commit ccccf71ae1
15 changed files with 369 additions and 155 deletions

View File

@@ -54,24 +54,35 @@ Int unify(Term t0, Term t1)
EXTERN inline Int unify_constant(register Term a, register Term cons)
{
CELL *pt;
CELL *pt0, *pt1;
deref_head(a,unify_cons_unk);
unify_cons_nonvar:
{
if (a == cons) return(TRUE);
else if (IsApplTerm(a) && IsExtensionFunctor(FunctorOfTerm(a))) {
Functor fun = FunctorOfTerm(a);
if (fun == FunctorDouble)
return(IsFloatTerm(cons) && FloatOfTerm(a) == FloatOfTerm(cons));
else if (fun == FunctorLongInt) {
return(IsLongIntTerm(cons) && LongIntOfTerm(a) == LongIntOfTerm(cons));
#ifdef TERM_EXTENSIONS
} else if (IsAttachFunc(fun)) {
return(GLOBAL_attas[ExtFromFunctor(fun)].bind_op(SBIND,a,cons));
#endif /* TERM_EXTENSIONS */
} else
if (!IsApplTerm(cons) || FunctorOfTerm(cons) != fun)
return FALSE;
switch((CELL)fun) {
case (CELL)FunctorDBRef:
return(pt0 == pt1);
case (CELL)FunctorLongInt:
return(pt0[1] == pt1[1]);
case (CELL)FunctorString:
return(strcmp( (const char *)(pt0+2), (const char *)(pt1+2)) == 0);
case (CELL)FunctorDouble:
return(FloatOfTerm(AbsAppl(pt0)) == FloatOfTerm(AbsAppl(pt1)));
#ifdef USE_GMP
case (CELL)FunctorBigInt:
return(Yap_gmp_tcmp_big_big(AbsAppl(pt0),AbsAppl(pt0)) == 0);
#endif /* USE_GMP */
default:
return(FALSE);
/* no other factors are accepted as arguments */
} else return(FALSE);
}
}
/* no other factors are accepted as arguments */
return(FALSE);
}