Merge ssh://ssh.dcc.fc.up.pt:31064/home/vsc/yap

This commit is contained in:
Vitor Santos Costa 2018-07-03 00:08:30 +01:00
commit 48540ccc78
7 changed files with 69 additions and 21 deletions

View File

@ -288,13 +288,23 @@ X_API Term YAP_MkIntTerm(Int n) {
} }
X_API Term YAP_MkStringTerm(const char *n) { X_API Term YAP_MkStringTerm(const char *n) {
CACHE_REGS CACHE_REGS
Term I; Term I;
BACKUP_H(); BACKUP_H();
I = MkStringTerm(n); I = MkStringTerm(n);
RECOVER_H(); RECOVER_H();
return I; return I;
}
X_API Term YAP_MkCharPTerm( char *n) {
CACHE_REGS
Term I;
BACKUP_H();
I = MkStringTerm(n);
RECOVER_H();
return I;
} }
X_API Term YAP_MkUnsignedStringTerm(const unsigned char *n) { X_API Term YAP_MkUnsignedStringTerm(const unsigned char *n) {

View File

@ -189,14 +189,8 @@ YAPStringTerm::YAPStringTerm(char *s) { // build string
BACKUP_H(); BACKUP_H();
CACHE_REGS CACHE_REGS
seq_tv_t inp, out; Term ts = MkStringTerm(s);
inp.val.c = s; mk(ts);
inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_STRING;
if (Yap_CVT_Text(&inp, &out PASS_REGS))
mk(out.val.t);
else
t = 0L;
RECOVER_H(); RECOVER_H();
} }
@ -708,6 +702,7 @@ bool YAPQuery::next() {
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec "); __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec ");
if (q_state == 0) { if (q_state == 0) {
//Yap_do_low_level_trace = 1;
result = (bool)YAP_EnterGoal(ap, nullptr, &q_h); result = (bool)YAP_EnterGoal(ap, nullptr, &q_h);
} else { } else {
LOCAL_AllowRestart = q_open; LOCAL_AllowRestart = q_open;

View File

@ -106,6 +106,7 @@ X_API extern void YAP_UserBackCutCPredicate(const char *name,
X_API extern YAP_Term YAP_ReadBuffer(const char *s, YAP_Term *tp); X_API extern YAP_Term YAP_ReadBuffer(const char *s, YAP_Term *tp);
extern YAP_Term YAP_MkcharPTerm(char *s);
} }

View File

@ -178,6 +178,7 @@ public:
// const std::string *s = new std::string("startup.yss"); // const std::string *s = new std::string("startup.yss");
Embedded = true; Embedded = true;
install = false; install = false;
Yap_InitDefaults(this, nullptr, 0, nullptr); Yap_InitDefaults(this, nullptr, 0, nullptr);
#if YAP_PYTHON #if YAP_PYTHON
Embedded = true; Embedded = true;

View File

@ -27,6 +27,13 @@
class YAPError; class YAPError;
extern "C" {
X_API extern Term YAP_MkCharPTerm( char *n);
}
/** /**
* @brief Generic Prolog Term * @brief Generic Prolog Term
*/ */
@ -39,7 +46,7 @@ class X_API YAPTerm {
friend class YAPApplTerm; friend class YAPApplTerm;
friend class YAPListTerm; friend class YAPListTerm;
protected: protected:
yhandle_t t; /// handle to term, equivalent to term_t yhandle_t t; /// handle to term, equivalent to term_t
public: public:
@ -315,12 +322,18 @@ public:
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
return tf; return tf;
}; };
void putArg(int i, YAPTerm t) { void putArg(int i, Term targ) {
BACKUP_MACHINE_REGS(); //BACKUP_MACHINE_REGS();
Term t0 = gt(); Term t0 = gt();
RepAppl(t0)[i] = t.term(); RepAppl(t0)[i] = Deref(targ);
RECOVER_MACHINE_REGS(); //RECOVER_MACHINE_REGS();
}; };
void putArg(int i, YAPTerm t) {
//BACKUP_MACHINE_REGS();
Term t0 = gt();
RepAppl(t0)[i] = t.term();
//RECOVER_MACHINE_REGS();
};
virtual bool isVar() { return false; } /// type check for unbound virtual bool isVar() { return false; } /// type check for unbound
virtual bool isAtom() { return false; } /// type check for atom virtual bool isAtom() { return false; } /// type check for atom
virtual bool isInteger() { return false; } /// type check for integer virtual bool isInteger() { return false; } /// type check for integer

View File

@ -288,6 +288,8 @@ INLINE_ONLY bool IsLongIntTerm(Term t) {
/* extern Functor FunctorString; */ /* extern Functor FunctorString; */
#define MkStringTerm(i) __MkStringTerm((i)PASS_REGS) #define MkStringTerm(i) __MkStringTerm((i)PASS_REGS)
INLINE_ONLY Term __MkStringTerm(const char *s USES_REGS); INLINE_ONLY Term __MkStringTerm(const char *s USES_REGS);
@ -336,6 +338,31 @@ __MkUStringTerm(const unsigned char *s USES_REGS) {
return t; return t;
} }
#define MkCharPTerm(i) __MkCharPTerm((i)PASS_REGS)
INLINE_ONLY Term __MkCharPTerm(char *s USES_REGS);
INLINE_ONLY Term __MkCharPTerm(char *s USES_REGS) {
Term t = AbsAppl(HR);
size_t sz;
if ((s[0] == '\0')) {
sz = sizeof(CELL);
HR[0] = (CELL)FunctorString;
HR[1] = (CELL)sz;
HR[2] = 0;
} else {
sz = ALIGN_BY_TYPE(strlen((char *)s) + 1, CELL);
HR[0] = (CELL)FunctorString;
HR[1] = (CELL)sz;
strcpy((char *)(HR + 2), (const char *)s);
}
HR[2 + sz] = EndSpecials;
HR += 3 + sz;
return t;
}
INLINE_ONLY const unsigned char *UStringOfTerm(Term t); INLINE_ONLY const unsigned char *UStringOfTerm(Term t);
INLINE_ONLY const unsigned char *UStringOfTerm(Term t) { INLINE_ONLY const unsigned char *UStringOfTerm(Term t) {

View File

@ -40,6 +40,7 @@ class YAPEngine;
extern "C"{ extern "C"{
#include "Yap.h" #include "Yap.h"
X_API extern Term YAP_MkCharPTerm( char *n);
#ifdef SWIGPYTHON #ifdef SWIGPYTHON