indicators
This commit is contained in:
parent
8d30742d8f
commit
5ff09fbf26
@ -120,7 +120,7 @@ bool Yap_Consulting(USES_REGS1) {
|
||||
* assertz are supported for static predicates no database predicates are
|
||||
* supportted for fast predicates
|
||||
*/
|
||||
1
|
||||
|
||||
/** Look for a predicate with same functor as t,
|
||||
create a new one of it cannot find it.
|
||||
*/
|
||||
|
53
C/exec.c
53
C/exec.c
@ -151,6 +151,49 @@ Term Yap_ExecuteCallMetaCall(Term g, Term mod) {
|
||||
return Yap_MkApplTerm(PredMetaCall->FunctorOfPred, 4, ts);
|
||||
}
|
||||
|
||||
PredEntry *Yap_get_pred(Term t, Term tmod, const char *pname) {
|
||||
Term t0 = t;
|
||||
|
||||
restart:
|
||||
if (IsVarTerm(t)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t0, pname);
|
||||
return NULL;
|
||||
} else if (IsAtomTerm(t)) {
|
||||
PredEntry *ap = RepPredProp(Yap_GetPredPropByAtom(AtomOfTerm(t), tmod));
|
||||
return ap;
|
||||
} else if (IsIntegerTerm(t) && tmod == IDB_MODULE) {
|
||||
return Yap_FindLUIntKey(IntegerOfTerm(t));
|
||||
} else if (IsPairTerm(t)) {
|
||||
t = Yap_MkApplTerm(FunctorCsult, 1, &t);
|
||||
goto restart;
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor fun = FunctorOfTerm(t);
|
||||
if (IsExtensionFunctor(fun)) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, Yap_TermToIndicator(t, tmod), pname);
|
||||
return NULL;
|
||||
}
|
||||
if (fun == FunctorModule) {
|
||||
Term tmod = ArgOfTerm(1, t);
|
||||
if (IsVarTerm(tmod)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, t0, pname);
|
||||
return NULL;
|
||||
}
|
||||
if (!IsAtomTerm(tmod)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, t0, pname);
|
||||
return NULL;
|
||||
}
|
||||
t = ArgOfTerm(2, t);
|
||||
goto restart;
|
||||
}
|
||||
PredEntry *ap = RepPredProp(Yap_GetPredPropByFunc(fun, tmod));
|
||||
return ap;
|
||||
} else {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, t0, pname);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Term Yap_TermToIndicator(Term t, Term mod) {
|
||||
CACHE_REGS
|
||||
// generate predicate indicator in this case
|
||||
@ -183,12 +226,12 @@ Term Yap_PredicateToIndicator(PredEntry *pe) {
|
||||
ti[0] = MkAtomTerm(NameOfFunctor(pe->FunctorOfPred));
|
||||
ti[1] = MkIntegerTerm(ArityOfFunctor(pe->FunctorOfPred));
|
||||
} else {
|
||||
ti[0] = t;
|
||||
ti[0] = MkAtomTerm((Atom)(pe->FunctorOfPred));
|
||||
ti[1] = MkIntTerm(0);
|
||||
}
|
||||
t = Yap_MkApplTerm(FunctorSlash, 2, ti);
|
||||
Term mod
|
||||
if (mod != TermUser and mod!= TermProlog) {
|
||||
Term t = Yap_MkApplTerm(FunctorSlash, 2, ti);
|
||||
Term mod = pe->ModuleOfPred;
|
||||
if (mod != TermUser && mod!= PROLOG_MODULE) {
|
||||
ti[0] = mod;
|
||||
ti[1] = t;
|
||||
return Yap_MkApplTerm(FunctorModule, 2, ti);
|
||||
@ -301,7 +344,7 @@ restart:
|
||||
} else if (IsIntegerTerm(t) && tmod == IDB_MODULE) {
|
||||
return Yap_FindLUIntKey(IntegerOfTerm(t));
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor fun = pe->FunctorOfPred;
|
||||
Functor fun = FunctorOfTerm(t);
|
||||
if (IsExtensionFunctor(fun)) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, Yap_TermToIndicator(t, tmod), pname);
|
||||
return NULL;
|
||||
|
@ -4152,7 +4152,7 @@ restart_index:
|
||||
}
|
||||
#if DEBUG
|
||||
if (GLOBAL_Option['i' - 'a' + 1]) {
|
||||
Yap_DebugWritexozoIndicator(ap);
|
||||
Yap_DebugWriteIndicator(ap);
|
||||
}
|
||||
#endif
|
||||
if ((labp = expand_index(&cint)) == NULL) {
|
||||
|
@ -90,7 +90,7 @@ static PredEntry *get_pred(Term t, Term tmod, char *pname) {
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor fun = FunctorOfTerm(t);
|
||||
if (IsExtensionFunctor(fun)) {
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, Yap_PredicateIndicator(t, tmod), pname);
|
||||
Yap_Error(TYPE_ERROR_CALLABLE, Yap_TermToIndicator(t, tmod), pname);
|
||||
return NULL;
|
||||
}
|
||||
if (fun == FunctorModule) {
|
||||
|
@ -82,7 +82,7 @@ restart:
|
||||
Functor fun = FunctorOfTerm(t);
|
||||
if (IsExtensionFunctor(fun)) {
|
||||
throw YAPError(SOURCE(), TYPE_ERROR_CALLABLE,
|
||||
Yap_PredicateIndicator(t, tmod), pname);
|
||||
Yap_TermToIndicator(t, tmod), pname);
|
||||
}
|
||||
if (fun == FunctorModule) {
|
||||
tmod = ArgOfTerm(1, t);
|
||||
|
Reference in New Issue
Block a user