iroutine to add new operator in certain module.

This commit is contained in:
Vitor Santos Costa 2011-08-31 13:54:52 -07:00
parent 9993ca2f3a
commit 083c88a91d

View File

@ -493,40 +493,37 @@ Yap_OpPropForModule(Atom a, Term mod)
CACHE_REGS CACHE_REGS
AtomEntry *ae = RepAtom(a); AtomEntry *ae = RepAtom(a);
PropEntry *pp; PropEntry *pp;
OpEntry *info; OpEntry *info = NULL;
if (mod == TermProlog) if (mod == TermProlog)
mod = PROLOG_MODULE; mod = PROLOG_MODULE;
WRITE_LOCK(ae->ARWLock); WRITE_LOCK(ae->ARWLock);
pp = RepProp(ae->PropsOfAE); pp = RepProp(ae->PropsOfAE);
while (!EndOfPAEntr(pp)) { while (!EndOfPAEntr(pp)) {
OpEntry *info = NULL;
if ( pp->KindOfPE == OpProperty) { if ( pp->KindOfPE == OpProperty) {
info = (OpEntry *)pp; info = (OpEntry *)pp;
if (info->OpModule == mod) if (info->OpModule == mod) {
WRITE_LOCK(info->OpRWLock);
WRITE_UNLOCK(ae->ARWLock);
return info; return info;
}
} }
pp = pp->NextOfPE;
} }
if (EndOfPAEntr(info)) { info = (OpEntry *) Yap_AllocAtomSpace(sizeof(OpEntry));
info = (OpEntry *) Yap_AllocAtomSpace(sizeof(OpEntry)); info->KindOfPE = Ord(OpProperty);
info->KindOfPE = Ord(OpProperty); info->OpModule = mod;
info->OpModule = mod; info->OpName = a;
info->OpName = a; LOCK(OpListLock);
LOCK(OpListLock); info->OpNext = OpList;
info->OpNext = OpList; OpList = info;
OpList = info; UNLOCK(OpListLock);
UNLOCK(OpListLock); AddPropToAtom(ae, (PropEntry *)info);
AddPropToAtom(ae, (PropEntry *)info); INIT_RWLOCK(info->OpRWLock);
INIT_RWLOCK(info->OpRWLock); WRITE_LOCK(info->OpRWLock);
WRITE_LOCK(info->OpRWLock); WRITE_UNLOCK(ae->ARWLock);
WRITE_UNLOCK(ae->ARWLock); info->Prefix = info->Infix = info->Posfix = 0;
info->Prefix = info->Infix = info->Posfix = 0; return info;
} else {
WRITE_LOCK(info->OpRWLock);
WRITE_UNLOCK(ae->ARWLock);
}
return NULL;
} }
OpEntry * OpEntry *