add warning of discontiguous and multiple file predicates
This commit is contained in:
parent
4e76d86083
commit
b7a1e464ef
4
.gitignore
vendored
4
.gitignore
vendored
@ -64,3 +64,7 @@ cmake_clean.cmake
|
|||||||
Makefile
|
Makefile
|
||||||
|
|
||||||
C/myabsmi.c
|
C/myabsmi.c
|
||||||
|
|
||||||
|
*.ctags#
|
||||||
|
|
||||||
|
*.hs
|
||||||
|
54
C/cdmgr.c
54
C/cdmgr.c
@ -2010,7 +2010,6 @@ not_was_reconsulted(PredEntry *p, Term t, int mode)
|
|||||||
|
|
||||||
if (p == LOCAL_LastAssertedPred)
|
if (p == LOCAL_LastAssertedPred)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
LOCAL_LastAssertedPred = p;
|
|
||||||
if (!LOCAL_ConsultSp) {
|
if (!LOCAL_ConsultSp) {
|
||||||
InitConsultStack();
|
InitConsultStack();
|
||||||
}
|
}
|
||||||
@ -2022,7 +2021,8 @@ not_was_reconsulted(PredEntry *p, Term t, int mode)
|
|||||||
fp = LOCAL_ConsultBase;
|
fp = LOCAL_ConsultBase;
|
||||||
}
|
}
|
||||||
if (fp != LOCAL_ConsultBase) {
|
if (fp != LOCAL_ConsultBase) {
|
||||||
return FALSE;
|
LOCAL_LastAssertedPred = p;
|
||||||
|
return false; /* careful */
|
||||||
} else if (mode) { // consulting again a predicate in the original file.
|
} else if (mode) { // consulting again a predicate in the original file.
|
||||||
if ((p->cs.p_code.NOfClauses &&
|
if ((p->cs.p_code.NOfClauses &&
|
||||||
p->src.OwnerFile == Yap_ConsultingFile( PASS_REGS1 ) &&
|
p->src.OwnerFile == Yap_ConsultingFile( PASS_REGS1 ) &&
|
||||||
@ -2032,9 +2032,7 @@ not_was_reconsulted(PredEntry *p, Term t, int mode)
|
|||||||
//if (p->ArityOfPE)
|
//if (p->ArityOfPE)
|
||||||
// printf("+ %s %s %d\n",NameOfFunctor(p->FunctorOfPred)->StrOfAE,p->src.OwnerFile->StrOfAE, p->cs.p_code.NOfClauses);
|
// printf("+ %s %s %d\n",NameOfFunctor(p->FunctorOfPred)->StrOfAE,p->src.OwnerFile->StrOfAE, p->cs.p_code.NOfClauses);
|
||||||
retract_all(p, static_in_use(p,TRUE));
|
retract_all(p, static_in_use(p,TRUE));
|
||||||
return TRUE;
|
}
|
||||||
}
|
|
||||||
// else if (p->ArityOfPE && p->cs.p_code.NOfClauses)
|
|
||||||
// printf("- %s %s\n",NameOfFunctor(p->FunctorOfPred)->StrOfAE,p->src.OwnerFile->StrOfAE);
|
// printf("- %s %s\n",NameOfFunctor(p->FunctorOfPred)->StrOfAE,p->src.OwnerFile->StrOfAE);
|
||||||
}
|
}
|
||||||
if (mode) {
|
if (mode) {
|
||||||
@ -2049,6 +2047,7 @@ not_was_reconsulted(PredEntry *p, Term t, int mode)
|
|||||||
}
|
}
|
||||||
p->src.OwnerFile = Yap_ConsultingFile( PASS_REGS1 );
|
p->src.OwnerFile = Yap_ConsultingFile( PASS_REGS1 );
|
||||||
}
|
}
|
||||||
|
LOCAL_LastAssertedPred = p;
|
||||||
return TRUE; /* careful */
|
return TRUE; /* careful */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2122,36 +2121,41 @@ PredEntry * Yap_PredFromClause( Term t USES_REGS )
|
|||||||
RepPredProp(Yap_GetPredPropByAtom(AtomOfTerm(t), cmod));
|
RepPredProp(Yap_GetPredPropByAtom(AtomOfTerm(t), cmod));
|
||||||
}
|
}
|
||||||
// ints, lists
|
// ints, lists
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
bool
|
||||||
Yap_discontiguous( PredEntry *ap USES_REGS )
|
Yap_discontiguous( PredEntry *ap USES_REGS )
|
||||||
{
|
{
|
||||||
register consult_obj *fp;
|
register consult_obj *fp;
|
||||||
|
|
||||||
if (ap->PredFlags & (DiscontiguousPredFlag|MultiFileFlag))
|
if (ap->PredFlags & (DiscontiguousPredFlag|MultiFileFlag))
|
||||||
return FALSE;
|
return false;
|
||||||
if (!LOCAL_ConsultSp) {
|
if (!LOCAL_ConsultSp) {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
if (ap == LOCAL_LastAssertedPred)
|
if (ap == LOCAL_LastAssertedPred)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (ap->cs.p_code.NOfClauses) {
|
if (ap->cs.p_code.NOfClauses) {
|
||||||
for (fp = LOCAL_ConsultSp; fp < LOCAL_ConsultBase; ++fp)
|
for (fp = LOCAL_ConsultSp; fp < LOCAL_ConsultBase; ++fp)
|
||||||
if (fp->p == AbsPredProp(ap))
|
if (fp->p == AbsPredProp(ap))
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
bool
|
||||||
Yap_multiple( PredEntry *ap USES_REGS )
|
Yap_multiple( PredEntry *ap USES_REGS )
|
||||||
{
|
{
|
||||||
|
register consult_obj *fp;
|
||||||
|
|
||||||
if (ap->PredFlags & MultiFileFlag)
|
if (ap->PredFlags & MultiFileFlag)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (ap == LOCAL_LastAssertedPred)
|
for (fp = LOCAL_ConsultSp; fp < LOCAL_ConsultBase; ++fp)
|
||||||
return FALSE;
|
if (fp->p == AbsPredProp(ap)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return
|
return
|
||||||
ap->cs.p_code.NOfClauses > 0 &&
|
ap->cs.p_code.NOfClauses > 0 &&
|
||||||
Yap_ConsultingFile( PASS_REGS1 ) != ap->src.OwnerFile;
|
Yap_ConsultingFile( PASS_REGS1 ) != ap->src.OwnerFile;
|
||||||
@ -2370,6 +2374,20 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
|
|||||||
if (pflags & (SpiedPredFlag|CountPredFlag|ProfiledPredFlag))
|
if (pflags & (SpiedPredFlag|CountPredFlag|ProfiledPredFlag))
|
||||||
spy_flag = TRUE;
|
spy_flag = TRUE;
|
||||||
goal_expansion_support(p, tf);
|
goal_expansion_support(p, tf);
|
||||||
|
if (Yap_discontiguous( p ) ) {
|
||||||
|
Term disc[2];
|
||||||
|
disc[0] = MkIntegerTerm( Yap_source_line_no() );
|
||||||
|
disc[1] = t;
|
||||||
|
Yap_PrintWarning(
|
||||||
|
Yap_MkApplTerm(Yap_MkFunctor(AtomDiscontiguous, 2), 2, disc));
|
||||||
|
} else if (Yap_multiple( p PASS_REGS ) ) {
|
||||||
|
Term redef[3];
|
||||||
|
redef[0] = MkIntegerTerm( Yap_source_line_no() );
|
||||||
|
redef[1] = t;
|
||||||
|
redef[2] = MkAtomTerm(p->src.OwnerFile);
|
||||||
|
Yap_PrintWarning(
|
||||||
|
Yap_MkApplTerm(Yap_MkFunctor(AtomMultiple, 3), 3, redef));
|
||||||
|
}
|
||||||
if (mode == consult)
|
if (mode == consult)
|
||||||
not_was_reconsulted(p, t, TRUE);
|
not_was_reconsulted(p, t, TRUE);
|
||||||
/* always check if we have a valid error first */
|
/* always check if we have a valid error first */
|
||||||
@ -6365,9 +6383,10 @@ p_instance_property( USES_REGS1 )
|
|||||||
if (op == CL_PROP_LINE) {
|
if (op == CL_PROP_LINE) {
|
||||||
if (cl->ClFlags & FactMask) {
|
if (cl->ClFlags & FactMask) {
|
||||||
return Yap_unify(ARG3, MkIntTerm(cl->usc.ClLine));
|
return Yap_unify(ARG3, MkIntTerm(cl->usc.ClLine));
|
||||||
} else {
|
} else if (cl->ClFlags & SrcMask) {
|
||||||
return Yap_unify(ARG3, MkIntTerm(cl->usc.ClSource->ag.line_number));
|
return Yap_unify(ARG3, MkIntTerm(cl->usc.ClSource->ag.line_number));
|
||||||
}
|
} else
|
||||||
|
return MkIntTerm(0);
|
||||||
}
|
}
|
||||||
} else if (FunctorOfTerm(t1) == FunctorMegaClause) {
|
} else if (FunctorOfTerm(t1) == FunctorMegaClause) {
|
||||||
PredEntry *ap = (PredEntry *)IntegerOfTerm(ArgOfTerm(1, t1));
|
PredEntry *ap = (PredEntry *)IntegerOfTerm(ArgOfTerm(1, t1));
|
||||||
@ -6457,9 +6476,10 @@ p_instance_property( USES_REGS1 )
|
|||||||
if (op == CL_PROP_LINE) {
|
if (op == CL_PROP_LINE) {
|
||||||
if (cl->ClFlags & FactMask) {
|
if (cl->ClFlags & FactMask) {
|
||||||
return Yap_unify(ARG3, MkIntTerm(cl->lusl.ClLine));
|
return Yap_unify(ARG3, MkIntTerm(cl->lusl.ClLine));
|
||||||
} else {
|
} else if (cl->ClFlags & SrcMask){
|
||||||
return Yap_unify(ARG3, MkIntTerm(cl->lusl.ClSource->ag.line_number));
|
return Yap_unify(ARG3, MkIntTerm(cl->lusl.ClSource->ag.line_number));
|
||||||
}
|
} else
|
||||||
|
return MkIntTerm(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Reference in New Issue
Block a user