go back to model where multifile cannot be in module 0.

This commit is contained in:
Vitor Santos Costa 2011-09-07 22:04:42 +02:00
parent 0febddf090
commit bf54802c49
3 changed files with 25 additions and 7 deletions

View File

@ -991,8 +991,14 @@ Yap_PredPropByFunctorNonThreadLocal(Functor f, Term cur_mod)
return Yap_NewPredPropByFunctor(f,cur_mod); return Yap_NewPredPropByFunctor(f,cur_mod);
if ((p->ModuleOfPred == cur_mod || !(p->ModuleOfPred))) { if ((p->ModuleOfPred == cur_mod || !(p->ModuleOfPred))) {
WRITE_UNLOCK(f->FRWLock); /* don't match multi-files */
return AbsPredProp(p); if (!(p->PredFlags & MultiFileFlag) ||
p->ModuleOfPred ||
!cur_mod ||
cur_mod == TermProlog) {
WRITE_UNLOCK(f->FRWLock);
return AbsPredProp(p);
}
} }
if (p->NextOfPE) { if (p->NextOfPE) {
UInt hash = PRED_HASH(f,cur_mod,PredHashTableSize); UInt hash = PRED_HASH(f,cur_mod,PredHashTableSize);
@ -1027,8 +1033,14 @@ Yap_PredPropByAtomNonThreadLocal(Atom at, Term cur_mod)
PredEntry *pe = RepPredProp(p0); PredEntry *pe = RepPredProp(p0);
if ( pe->KindOfPE == PEProp && if ( pe->KindOfPE == PEProp &&
(pe->ModuleOfPred == cur_mod || !pe->ModuleOfPred)) { (pe->ModuleOfPred == cur_mod || !pe->ModuleOfPred)) {
WRITE_UNLOCK(ae->ARWLock); /* don't match multi-files */
return(p0); if (!(pe->PredFlags & MultiFileFlag) ||
pe->ModuleOfPred ||
!cur_mod ||
cur_mod == TermProlog) {
WRITE_UNLOCK(ae->ARWLock);
return(p0);
}
} }
p0 = pe->NextOfPE; p0 = pe->NextOfPE;
} }

View File

@ -2136,9 +2136,9 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
PELOCK(20,p); PELOCK(20,p);
pflags = p->PredFlags; pflags = p->PredFlags;
/* we are redefining a prolog module predicate */ /* we are redefining a prolog module predicate */
if ((pflags & if ((pflags & (UserCPredFlag|CArgsPredFlag|NumberDBPredFlag|AtomDBPredFlag|TestPredFlag|AsmPredFlag|CPredFlag|BinaryPredFlag)) ||
(UserCPredFlag|CArgsPredFlag|NumberDBPredFlag|AtomDBPredFlag|TestPredFlag|AsmPredFlag|CPredFlag|BinaryPredFlag)) || (p->ModuleOfPred == PROLOG_MODULE &&
(p->ModuleOfPred == PROLOG_MODULE && mod != TermProlog && mod && !(p->PredFlags & (DynamicPredFlag|LogUpdatePredFlag|MultiFileFlag)))) { mod != TermProlog && mod) ) {
addcl_permission_error(RepAtom(at), Arity, FALSE); addcl_permission_error(RepAtom(at), Arity, FALSE);
UNLOCKPE(30,p); UNLOCKPE(30,p);
return TermNil; return TermNil;
@ -2884,6 +2884,9 @@ p_new_multifile( USES_REGS1 )
pe = RepPredProp(PredPropByFunc(Yap_MkFunctor(at, arity),mod)); pe = RepPredProp(PredPropByFunc(Yap_MkFunctor(at, arity),mod));
PELOCK(26,pe); PELOCK(26,pe);
pe->PredFlags |= MultiFileFlag; pe->PredFlags |= MultiFileFlag;
/* mutifile-predicates are weird, they do not seat really on the default module */
if (pe->ModuleOfPred == PROLOG_MODULE)
pe->ModuleOfPred = TermProlog;
if (!(pe->PredFlags & (DynamicPredFlag|LogUpdatePredFlag))) { if (!(pe->PredFlags & (DynamicPredFlag|LogUpdatePredFlag))) {
/* static */ /* static */
pe->PredFlags |= (SourcePredFlag|CompiledPredFlag); pe->PredFlags |= (SourcePredFlag|CompiledPredFlag);

View File

@ -906,6 +906,9 @@ read_pred(IOSTREAM *stream, Term mod) {
ap->src.OwnerFile = AtomAdjust(ap->src.OwnerFile); ap->src.OwnerFile = AtomAdjust(ap->src.OwnerFile);
} }
} }
/* multifile predicates cannot reside in module 0 */
if (flags & MultiFileFlag && ap->ModuleOfPred == PROLOG_MODULE)
ap->ModuleOfPred = TermProlog;
read_clauses(stream, ap, nclauses, flags); read_clauses(stream, ap, nclauses, flags);
} }