fix messup with functors that are atoms.

This commit is contained in:
Vítor Santos Costa 2010-05-19 17:17:05 +01:00
parent 2639e6c868
commit 6a433c33a1

View File

@ -155,8 +155,10 @@ FunctorToSWIFunctor(Functor at)
static inline Functor static inline Functor
SWIFunctorToFunctor(functor_t at) SWIFunctorToFunctor(functor_t at)
{ {
if ((CELL)at & 1) if (IsAtomTerm(at))
return SWI_Functors[at>>1]; return (Functor)at;
if (IsApplTerm(at))
return SWI_Functors[((CELL)RepAppl((CELL)at))/sizeof(CELL)];
return (Functor)at; return (Functor)at;
} }
@ -169,7 +171,7 @@ Yap_InitSWIHash(void)
add_to_hash(i*2+1, (ADDR)SWI_Atoms[i]); add_to_hash(i*2+1, (ADDR)SWI_Atoms[i]);
} }
for (j=0; j < N_SWI_FUNCTORS; j++) { for (j=0; j < N_SWI_FUNCTORS; j++) {
add_to_hash(j*2+1, (ADDR)SWI_Functors[j]); add_to_hash(AbsAppl((CELL *)(j*sizeof(CELL))), (ADDR)SWI_Functors[j]);
} }
} }