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

View File

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

View File

@ -906,6 +906,9 @@ read_pred(IOSTREAM *stream, Term mod) {
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);
}