fix bad SWI functor :(

This commit is contained in:
Vitor Santos Costa 2010-12-02 12:10:03 +00:00
parent b02507ed22
commit 7e59179622
2 changed files with 17 additions and 17 deletions

View File

@ -50,12 +50,12 @@
extern X_API Int YAP_PLArityOfSWIFunctor(functor_t at);
X_API Int
YAP_PLArityOfSWIFunctor(functor_t at) {
if (IsAtomTerm(at))
YAP_PLArityOfSWIFunctor(functor_t f) {
if (IsAtomTerm(f))
return 0;
if ((CELL)(at) & 2)
return ArityOfFunctor(SWI_Functors[((CELL)at)/4]);
return ArityOfFunctor((Functor)at);
if ((CELL)f < N_SWI_FUNCTORS*(LowTagBits+1))
return ArityOfFunctor(SWI_Functors[(CELL)f/(LowTagBits+1)]);
return ArityOfFunctor((Functor)f);
}
void
@ -64,10 +64,10 @@ Yap_InitSWIHash(void)
int i, j;
memset(SWI_ReverseHash, 0, N_SWI_HASH*sizeof(swi_rev_hash));
for (i=0; i < N_SWI_ATOMS; i++) {
add_to_hash(i*2+1, (ADDR)SWI_Atoms[i]);
add_to_hash(i, (ADDR)SWI_Atoms[i]);
}
for (j=0; j < N_SWI_FUNCTORS; j++) {
add_to_hash((((CELL)(j))*4+2), (ADDR)SWI_Functors[j]);
add_to_hash(j, (ADDR)SWI_Functors[j]);
}
}

View File

@ -83,15 +83,15 @@ AtomToSWIAtom(Atom at)
{
atom_t ats;
if ((ats = in_hash((ADDR)at)))
return ats;
return (atom_t)((CELL)at*(LowTagBits+1));
return (atom_t)at;
}
static inline Atom
SWIAtomToAtom(atom_t at)
{
if ((CELL)at & 1)
return SWI_Atoms[at>>1];
if ((CELL)at < N_SWI_ATOMS*(LowTagBits+1))
return SWI_Atoms[((CELL)at)/(LowTagBits+1)];
return (Atom)at;
}
@ -110,17 +110,17 @@ FunctorToSWIFunctor(Functor at)
{
atom_t ats;
if ((ats = in_hash((ADDR)at)))
return (functor_t)ats;
return (functor_t)((CELL)at*(LowTagBits+1));
return (functor_t)at;
}
static inline Functor
SWIFunctorToFunctor(functor_t at)
SWIFunctorToFunctor(functor_t f)
{
if (IsAtomTerm(at))
return (Functor)at;
if ((CELL)(at) & 2)
return SWI_Functors[((CELL)at)/4];
return (Functor)at;
if (IsAtomTerm(f))
return (Functor)f;
if ((CELL)f < N_SWI_FUNCTORS*(LowTagBits+1))
return SWI_Functors[(CELL)f/(LowTagBits+1)];
return (Functor)f;
}