improve code to search for operator definitions.

This commit is contained in:
Vitor Santos Costa 2011-06-14 08:55:44 +01:00
parent 26c72dcfb1
commit ede482521d

View File

@ -493,41 +493,43 @@ Yap_GetOpProp(Atom a, op_type type USES_REGS)
{ /* look property list of atom a for kind */ { /* look property list of atom a for kind */
AtomEntry *ae = RepAtom(a); AtomEntry *ae = RepAtom(a);
PropEntry *pp; PropEntry *pp;
OpEntry *info = NULL;
READ_LOCK(ae->ARWLock); READ_LOCK(ae->ARWLock);
pp = RepProp(ae->PropsOfAE); pp = RepProp(ae->PropsOfAE);
while (!EndOfPAEntr(pp) && while (!EndOfPAEntr(pp)) {
( pp->KindOfPE != OpProperty || OpEntry *info = NULL;
((OpEntry *)pp)->OpModule != CurrentModule)) if ( pp->KindOfPE != OpProperty) {
pp = RepProp(pp->NextOfPE);
if ((info = (OpEntry *)pp)) {
if ((type == INFIX_OP && !info->Infix) ||
(type == POSFIX_OP && !info->Posfix) ||
(type == PREFIX_OP && !info->Prefix))
pp = RepProp(NIL);
}
if (EndOfPAEntr(pp)) {
pp = RepProp(ae->PropsOfAE);
while (!EndOfPAEntr(pp) &&
( pp->KindOfPE != OpProperty ||
((OpEntry *)pp)->OpModule != PROLOG_MODULE))
pp = RepProp(pp->NextOfPE); pp = RepProp(pp->NextOfPE);
if ((info = (OpEntry *)pp)) { continue;
if ((type == INFIX_OP && !info->Infix) || }
(type == POSFIX_OP && !info->Posfix) || info = (OpEntry *)pp;
(type == PREFIX_OP && !info->Prefix)) if (info->OpModule != CurrentModule &&
pp = RepProp(NIL); info->OpModule != PROLOG_MODULE) {
pp = RepProp(pp->NextOfPE);
continue;
}
if (type == INFIX_OP) {
if (!info->Infix) {
pp = RepProp(pp->NextOfPE);
continue;
}
} else if (type == POSFIX_OP) {
if (!info->Posfix) {
pp = RepProp(pp->NextOfPE);
continue;
}
} else {
if (!info->Prefix) {
pp = RepProp(pp->NextOfPE);
continue;
}
} }
}
if (!info) {
READ_UNLOCK(ae->ARWLock);
return NULL;
} else {
READ_LOCK(info->OpRWLock); READ_LOCK(info->OpRWLock);
READ_UNLOCK(ae->ARWLock); READ_UNLOCK(ae->ARWLock);
return info; return info;
} }
READ_UNLOCK(ae->ARWLock);
return NULL;
} }