10#define YAP_CPP_DB_INTERFACE 1
49 Term t() {
return gt(); }
50 Term curModule() { CACHE_REGS
return Yap_CurrentModule(); }
57 Term term() {
return gt(); };
93 PredEntry *getPred(Term &t, Term &tm, CELL *&outp);
101 YAPPredicate(Term &to, Term &tmod, CELL *&ts,
const char *pname);
109 ap = getPred(t, tm, v);
117 ap = getPred(t, tm, v);
126 ap = getPred(tp, tm, v);
132 ap = getPred(tp, tm, v);
143 ap = RepPredProp(PredPropByFunc(f, mod));
154 const char *s = (
const char *)s0;
155 Term tnames = MkVarTerm(),
156 parameters = TermNil;
158 Yap_BufferToTermWithPrioBindings(s, parameters, tnames, strlen(s0)+1, 1200);
166 ap = getPred(tout, tm, nts);
167 tout = Yap_SaveTerm(tout);
183 ap = RepPredProp(PredPropByFunc(f.f, mod.term()));
189 ap = RepPredProp(PredPropByAtom(at.a, mod.term()));
200 Functor f = Yap_MkFunctor(at.a, arity);
201 ap = RepPredProp(PredPropByFunc(f, mod.term()));
203 ap = RepPredProp(PredPropByAtom(at.a, mod.term()));
213 inline YAPPredicate(
const std::string at, uintptr_t arity, std::string mod=
"") {
217 m = MkAtomTerm(Yap_LookupAtom(mod.c_str()));
220 ap = RepPredProp(PredPropByFunc(Yap_MkFunctor(Yap_LookupAtom(at.c_str()), arity),
227 ap = RepPredProp(PredPropByFunc(Yap_MkFunctor(Yap_LookupAtom(at), arity),
235 PredPropByFunc(Yap_MkFunctor(Yap_LookupAtom(at), arity), mod.term()));
241 ap = RepPredProp(PredPropByAtom(Yap_LookupAtom(at), mod.term()));
248 if (ap->ModuleOfPred == PROLOG_MODULE)
251 return YAPModule(AtomOfTerm(ap->ModuleOfPred));
261 return YAPAtom(NameOfFunctor(ap->FunctorOfPred));
270 Yap_ThrowError(DOMAIN_ERROR_OUT_OF_RANGE, MkIntTerm(0),
271 "YAPFunctor::functor");
278 arity_t
arity() {
return ap->ArityOfPE; }
293 bool assertClause(
YAPTerm clause,
bool last =
true,
296 bool assertFact(
YAPTerm *tuple,
bool last =
true);
298 void *retractClause(
YAPTerm skeleton,
bool all =
false);
312 YAPFLIP(YAP_UserCPred call, std::string name, YAP_Arity arity,
313 const std::string module = std::string(RepAtom(AtomOfTerm(CurrentModule))->StrOfAE), YAP_UserCPred retry = 0,
314 YAP_UserCPred cut = 0, YAP_Arity extra = 0,
bool test =
false)
315 :
YAPPredicate(name.c_str(), arity, MkAtomTerm(Yap_LookupAtom(module.c_str()))) {
317 YAP_UserBackCutCPredicate(name.c_str(), call, retry, cut, arity, extra);
320 YAP_UserCPredicate(name.c_str(), call, arity);
322 YAP_UserCPredicate(name.c_str(), call, arity);
327 bool backtrackable =
false)
330 Yap_InitCPredBackCut(name, arity, 0, 0, 0, 0, UserCPredFlag);
332 YAP_UserCPredicate(name, 0, arity);
335 bool addCall(CPredicate call) {
return Yap_AddCallToFli(ap, call); }
336 bool addRetry(CPredicate call) {
return Yap_AddRetryToFli(ap, call); }
337 bool addCut(CPredicate call) {
return Yap_AddCutToFli(ap, call); }
340 Term x(
int i) {
return XREGS[i]; }
345 bool output( Term t,
int i) {
return Yap_unify(XREGS[i], t); };
346 bool output(
YAPTerm t,
int i) {
return t.unify(XREGS[i]); };
349 bool ensureStorage(
size_t cells) {
return Yap_dogcl(cells*
sizeof(CELL) PASS_REGS); }
352 bool ensureStorage(
size_t cells, std::vector<Term> ts)
353 {
return Yap_dogcl(cells*
sizeof(CELL) PASS_REGS); };
@ source
If true maintain the source for all clauses.
YAPPredicate(YAPAtom at, YAPTerm mod)
Name/arity constructor for predicates.
YAPPredicate()
Empty constructor for predicates.
YAPPredicate(const char *at, uintptr_t arity)
char */arity constructor for predicates
YAPPredicate(YAPAtom at, uintptr_t arity, YAPModule mod)
Mod:Name/Arity constructor for predicates.
YAPTerm * nextClause()
return the Nth clause (if source is available)
YAPPredicate(Functor f, Term mod)
Functor constructor for predicates, is given a specific module.
YAPPredicate(PredEntry *pe)
Cast constructor for predicates, if we have the implementation data.
YAPPredicate(YAPTerm t, CELL *&v)
Term constructor for predicates.
YAPPredicate(const std::string at, uintptr_t arity, std::string mod="")
std::string/Arity constructor for predicates
YAPPredicate(const char *at, YAPTerm mod)
char */module constructor for predicates
YAPAtom name()
name of predicate
YAPPredicate(Term t, CELL *&v)
Term constructor for predicates.
YAPPredicate(YAPFunctor f, YAPTerm mod)
Functor constructor for predicates, is given a specific module.
YAPFunctor functor()
functor of predicate
YAPPredicate(const char *at, uintptr_t arity, YAPTerm mod)
char */module constructor for predicates
YAPModule module()
module of a predicate
YAPPredicate(const char *s0, Term &tout, YAPPairTerm *&names, CELL *&nts)
String constructor for predicates.
YAPPredicate(YAPFunctor f)
Functor constructor for predicates.
uintptr_t getArity()
arity of predicate
YAPModule A YAPModule describes a bare module, which in YAP is just a name.
YAPModuleProp A YAPModuleProp controls access to a module property.
take information on a Prolog error:
Atom A YAP data-base is a collection of atoms, where each atom has a name and a set of Properties.
YAPFunctor represents Prolog functors Name/Arity.
Prop A YAP Propery is ameta-class for everything one can in a atom.
Term Yap_CurrentModule()
current module for the engine
YAP Engine: takes care of the execution environment where we can go executing goals.
Term gt()
handle to term, equivalent to term_t
YAPTerm()
private method to convert from Term (internal YAP representation) to YAPTerm
virtual arity_t arity()
extract the arity of the term variables have arity 0
Atom Term Term Representation of an Atom.
Module property: low-level data used to manage modes.