From 72fcd2befaf431e6fcd28acb7d583671783e898f Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sat, 30 Jul 2016 23:08:05 -0500 Subject: [PATCH] IndicatorOfPred --- C/adtdefs.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/C/adtdefs.c b/C/adtdefs.c index 05bc273c8..f9caf1dda 100755 --- a/C/adtdefs.c +++ b/C/adtdefs.c @@ -1389,3 +1389,37 @@ int Yap_AtomDecreaseHold(Atom at) { WRITE_UNLOCK(ae->ARWLock); return TRUE; } + +const char *IndicatorOfPred(PredEntry *pe) { + const char *mods; + Atom at; + arity_t arity; + if (pe->ModuleOfPred == IDB_MODULE) { + mods = "idb"; + if (pe->PredFlags & NumberDBPredFlag) { + snprintf(LOCAL_FileNameBuf, YAP_FILENAME_MAX, "idb:" UInt_FORMAT, + (Int)(pe->FunctorOfPred)); + return LOCAL_FileNameBuf; + } else if (pe->PredFlags & AtomDBPredFlag) { + at = (Atom)pe->FunctorOfPred; + arity = 0; + } else { + at = NameOfFunctor(pe->FunctorOfPred); + arity = ArityOfFunctor(pe->FunctorOfPred); + } + } else { + if (pe->ModuleOfPred == 0) + mods = "prolog"; + else + mods = RepAtom(AtomOfTerm(pe->ModuleOfPred))->StrOfAE; + arity = pe->ArityOfPE; + if (arity == 0) { + at = (Atom)pe->FunctorOfPred; + } else { + at = NameOfFunctor(pe->FunctorOfPred); + } + } + snprintf(LOCAL_FileNameBuf, YAP_FILENAME_MAX, "%s:%s/" UInt_FORMAT, mods, + RepAtom(at)->StrOfAE, arity); + return LOCAL_FileNameBuf; +}