This commit is contained in:
Vitor Santos Costa
2017-01-09 14:58:57 +00:00
parent 6778ea2975
commit 4db2a1fe7f
9 changed files with 53 additions and 47 deletions

View File

@@ -8,6 +8,14 @@ set (CXX_SOURCES
yapi.cpp
)
set (CXX_HEADERS
yapa.hh
yapdb.hh
yapi.h
yapie.hh
yapq.hh
- yapt.hh
-)
list(APPEND LIBYAP_SOURCES ${CXX_SOURCES} PARENT_SCOPE)

View File

@@ -1,9 +0,0 @@
set (CXX_SOURCES
yapa.hh
yapdb.hh
yapi.cpp
yapi.hh
yapie.hh
yapq.hh
yapt.hh
)

View File

@@ -194,16 +194,18 @@ Term &YAPTerm::operator[](arity_t i) {
// Functor f = FunctorOfTerm(t0);
// if (IsExtensionFunctor(f))
// return 0;
RECOVER_MACHINE_REGS();
return RepAppl(t0)[(i + 1)];
tf = RepAppl(t0)[(i + 1)];
} else if (IsPairTerm(t0)) {
if (i == 0)
tf = HeadOfTerm(t0);
else if (i == 1)
tf = TailOfTerm(t0);
RECOVER_MACHINE_REGS();
return RepPair(tf)[i];
tf = RepPair(tf)[i];
}
RECOVER_MACHINE_REGS();
Yap_Error(TYPE_ERROR_COMPOUND, tf, "");
throw YAPError();
}
Term &YAPListTerm::operator[](arity_t i) {
@@ -397,6 +399,8 @@ void YAPQuery::openQuery() {
bool YAPEngine::call(YAPPredicate ap, YAPTerm ts[]) {
CACHE_REGS
if (ap.ap == NULL)
return false;
BACKUP_MACHINE_REGS();
arity_t arity = ap.getArity();
bool result;
@@ -426,11 +430,13 @@ bool YAPEngine::call(YAPPredicate ap, YAPTerm ts[]) {
bool YAPEngine::goalt(YAPTerm Yt) { return Yt.term(); }
bool YAPEngine::goal(Term t) {
bool YAPEngine::mgoal(Term t, Term tmod) {
CACHE_REGS
BACKUP_MACHINE_REGS();
Term terr, tmod = CurrentModule, *ts = nullptr;
Term terr, *ts = nullptr;
PredEntry *ap = Yap_get_pred(t, tmod, "C++");
if (ap == nullptr)
return false;
arity_t arity = ap->ArityOfPE;
bool result;
jmp_buf q_env;
@@ -755,7 +761,7 @@ void YAPEngine::doInit(YAP_file_type_t BootMode) {
Yap_AndroidSz = 0;
#endif
yerror = YAPError();
YAPQuery initq = YAPQuery(YAPAtom("$init_system"));
if (initq.next()) {
initq.cut();

View File

@@ -180,7 +180,12 @@ public:
/// current directory for the engine
bool goalt(YAPTerm t);
/// current directory for the engine
bool goal(Term t);
bool mgoal(Term t, Term tmod);
/// current directory for the engine
bool goal(Term t) {
return mgoal(t, CurrentModule);
}
/// reset Prolog state
void reSet();
/// release: assune that there are no stack pointers, just release memory

View File

@@ -6,16 +6,7 @@
extern "C" {
Term YAP_ReadBuffer(const char *s, Term *tp);
#if defined(SWIGPYTHON) && 0
#include <Python.h>
extern Term pythonToYAP(PyObject *inp);
#define YAPTerm _YAPTERM
#elifndef HAVE_PYTHON_H
typdef struct { int no_python; } PyObject;
#else
#include <Python.h>
#endif
};
}
class YAPError;
@@ -55,14 +46,12 @@ public:
};
YAPTerm(Term tn) { mk(tn); };
YAPTerm(PyObject *inp) {
#ifdef SWIGPYTHON
YAPTerm(PyObject *inp) {
Term tinp = pythonToYAP(inp);
t = Yap_InitSlot(tinp);
#else
t = 0;
#endif
}
#endif
/// private method to convert from Term (internal YAP representation) to
/// YAPTerm
// do nothing constructor
@@ -96,7 +85,7 @@ public:
inline void bind(YAPTerm *b) { LOCAL_HandleBase[t] = b->term(); }
/// from YAPTerm to Term (internal YAP representation)
/// fetch a sub-term
Term &operator[](size_t n);
Term &operator[](arity_t n);
// const YAPTerm *vars();
/// this term is == to t1
virtual bool exactlyEqual(YAPTerm t1) {