Merge branch 'master' of https://github.com/vscosta/yap-6.3
This commit is contained in:
commit
675ce8c77b
@ -2390,9 +2390,9 @@ X_API YAP_file_type_t YAP_Init(YAP_init_args *yap_init) {
|
|||||||
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
|
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
|
||||||
Yap_init_yapor_global_local_memory();
|
Yap_init_yapor_global_local_memory();
|
||||||
#endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA */
|
#endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA */
|
||||||
// GLOBAL_PrologShouldHandleInterrupts =
|
|
||||||
// yap_init->PrologShouldHandleInterrupts &&
|
|
||||||
if (!yap_init->Embedded) {
|
if (!yap_init->Embedded) {
|
||||||
|
GLOBAL_PrologShouldHandleInterrupts =
|
||||||
|
~yap_init->PrologCannotHandleInterrupts;
|
||||||
Yap_InitSysbits(0); /* init signal handling and time, required by later
|
Yap_InitSysbits(0); /* init signal handling and time, required by later
|
||||||
functions */
|
functions */
|
||||||
GLOBAL_argv = yap_init->Argv;
|
GLOBAL_argv = yap_init->Argv;
|
||||||
|
14
C/cmppreds.c
14
C/cmppreds.c
@ -540,7 +540,7 @@ Int p_compare(USES_REGS1) { /* compare(?Op,?T1,?T2) */
|
|||||||
return Yap_unify_constant(ARG1, MkAtomTerm(p));
|
return Yap_unify_constant(ARG1, MkAtomTerm(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @pred _X_ \== _Y_ is iso
|
/** @pred X \== Y is iso
|
||||||
|
|
||||||
Terms _X_ and _Y_ are not strictly identical.
|
Terms _X_ and _Y_ are not strictly identical.
|
||||||
*/
|
*/
|
||||||
@ -548,7 +548,7 @@ static Int a_noteq(Term t1, Term t2) { return (compare(t1, t2) != 0); }
|
|||||||
|
|
||||||
static Int a_gen_lt(Term t1, Term t2) { return (compare(t1, t2) < 0); }
|
static Int a_gen_lt(Term t1, Term t2) { return (compare(t1, t2) < 0); }
|
||||||
|
|
||||||
/** @pred _X_ @=< _Y_ is iso
|
/** @pred X @=< Y is iso
|
||||||
|
|
||||||
|
|
||||||
Term _X_ does not follow term _Y_ in the standard order.
|
Term _X_ does not follow term _Y_ in the standard order.
|
||||||
@ -556,14 +556,14 @@ Term _X_ does not follow term _Y_ in the standard order.
|
|||||||
*/
|
*/
|
||||||
static Int a_gen_le(Term t1, Term t2) { return (compare(t1, t2) <= 0); }
|
static Int a_gen_le(Term t1, Term t2) { return (compare(t1, t2) <= 0); }
|
||||||
|
|
||||||
/** @pred _X_ @> _Y_ is iso
|
/** @pred X @> Y is iso
|
||||||
|
|
||||||
|
|
||||||
Term _X_ does not follow term _Y_ in the standard order
|
Term _X_ does not follow term _Y_ in the standard order
|
||||||
*/
|
*/
|
||||||
static Int a_gen_gt(Term t1, Term t2) { return compare(t1, t2) > 0; }
|
static Int a_gen_gt(Term t1, Term t2) { return compare(t1, t2) > 0; }
|
||||||
|
|
||||||
/** @pred _X_ @>= _Y_ is iso
|
/** @pred X @>= Y is iso
|
||||||
|
|
||||||
Term _X_ does not precede term _Y_ in the standard order.
|
Term _X_ does not precede term _Y_ in the standard order.
|
||||||
*/
|
*/
|
||||||
@ -778,7 +778,7 @@ static Int a_gt(Term t1, Term t2) { /* A > B */
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@pred +_X_ >= +_Y_ is iso
|
@pred +X >= +Y is iso
|
||||||
Greater than or equal to arithmetic expressions
|
Greater than or equal to arithmetic expressions
|
||||||
|
|
||||||
The value of the expression _X_ is greater than or equal to the
|
The value of the expression _X_ is greater than or equal to the
|
||||||
@ -791,7 +791,7 @@ static Int a_ge(Term t1, Term t2) { /* A >= B */
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@pred +_X_ \< +_Y_ is iso
|
@pred +X < +Y is iso
|
||||||
Lesser than arithmetic expressions
|
Lesser than arithmetic expressions
|
||||||
|
|
||||||
The value of the expression _X_ is less than the value of expression
|
The value of the expression _X_ is less than the value of expression
|
||||||
@ -806,7 +806,7 @@ static Int a_lt(Term t1, Term t2) { /* A < B */
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@pred _X_ =< + _Y_
|
@pred +X =< +Y
|
||||||
Lesser than or equal to arithmetic expressions
|
Lesser than or equal to arithmetic expressions
|
||||||
|
|
||||||
|
|
||||||
|
@ -1658,7 +1658,7 @@ mark_environments(CELL_PTR gc_ENV, size_t size, CELL *pvbmap USES_REGS)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
mark_external_reference(saved_var PASS_REGS);
|
mark_external_reference(saved_var PASS_REGS);
|
||||||
}
|
}
|
||||||
bmap <<= 1;
|
bmap <<= 1;
|
||||||
currv++;
|
currv++;
|
||||||
|
@ -871,7 +871,7 @@ static int num_send_error_message(char s[]) {
|
|||||||
|
|
||||||
#define number_overflow() \
|
#define number_overflow() \
|
||||||
{ \
|
{ \
|
||||||
size_t nsz = min(max_size * 2, max_size); \
|
size_t nsz = Yap_Min(max_size * 2, max_size); \
|
||||||
char *nbuf; \
|
char *nbuf; \
|
||||||
\
|
\
|
||||||
if (buf == buf0) { \
|
if (buf == buf0) { \
|
||||||
@ -1406,7 +1406,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments,
|
|||||||
for (; chtype(ch) <= NU; ch = getchr(inp_stream)) {
|
for (; chtype(ch) <= NU; ch = getchr(inp_stream)) {
|
||||||
if (charp == TokImage + (sz - 1)) {
|
if (charp == TokImage + (sz - 1)) {
|
||||||
unsigned char *p0 = TokImage;
|
unsigned char *p0 = TokImage;
|
||||||
sz = min(sz * 2, sz + MBYTE);
|
sz = Yap_Min(sz * 2, sz + MBYTE);
|
||||||
TokImage = Realloc(p0, sz);
|
TokImage = Realloc(p0, sz);
|
||||||
if (TokImage == NULL) {
|
if (TokImage == NULL) {
|
||||||
return CodeSpaceError(t, p, l);
|
return CodeSpaceError(t, p, l);
|
||||||
@ -1560,7 +1560,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments,
|
|||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
if (charp > TokImage + (sz - 1)) {
|
if (charp > TokImage + (sz - 1)) {
|
||||||
TokImage = Realloc(TokImage, min(sz * 2, sz + MBYTE));
|
TokImage = Realloc(TokImage, Yap_Min(sz * 2, sz + MBYTE));
|
||||||
if (TokImage == NULL) {
|
if (TokImage == NULL) {
|
||||||
return CodeSpaceError(t, p, l);
|
return CodeSpaceError(t, p, l);
|
||||||
}
|
}
|
||||||
@ -1735,7 +1735,7 @@ TokEntry *Yap_tokenizer(struct stream_desc *inp_stream, bool store_comments,
|
|||||||
add_ch_to_buff(och);
|
add_ch_to_buff(och);
|
||||||
for (; chtype(ch) == SY; ch = getchr(inp_stream)) {
|
for (; chtype(ch) == SY; ch = getchr(inp_stream)) {
|
||||||
if (charp >= TokImage + (sz - 10)) {
|
if (charp >= TokImage + (sz - 10)) {
|
||||||
sz = min(sz * 2, sz + MBYTE);
|
sz = Yap_Min(sz * 2, sz + MBYTE);
|
||||||
TokImage = Realloc(TokImage, sz);
|
TokImage = Realloc(TokImage, sz);
|
||||||
if (!TokImage)
|
if (!TokImage)
|
||||||
return CodeSpaceError(t, p, l);
|
return CodeSpaceError(t, p, l);
|
||||||
|
14
C/signals.c
14
C/signals.c
@ -28,9 +28,9 @@ static char SccsId[] = "%W% %G%";
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include "YapEval.h"
|
||||||
#include "YapHeap.h"
|
#include "YapHeap.h"
|
||||||
#include "Yatom.h"
|
#include "Yatom.h"
|
||||||
#include "YapEval.h"
|
|
||||||
#include "yapio.h"
|
#include "yapio.h"
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
#include "tab.macros.h"
|
#include "tab.macros.h"
|
||||||
@ -65,10 +65,8 @@ static yap_signals InteractSIGINT(int ch) {
|
|||||||
case 'a':
|
case 'a':
|
||||||
/* abort computation */
|
/* abort computation */
|
||||||
#if PUSH_REGS
|
#if PUSH_REGS
|
||||||
// restore_absmi_regs(&Yap_standard_regs);
|
// restore_absmi_regs(&Yap_standard_regs);
|
||||||
#endif
|
#endif
|
||||||
LOCAL_RestartEnv = malloc( sizeof(sigjmp_buf) );
|
|
||||||
siglongjmp(*LOCAL_RestartEnv, 4);
|
|
||||||
return YAP_ABORT_SIGNAL;
|
return YAP_ABORT_SIGNAL;
|
||||||
case 'b':
|
case 'b':
|
||||||
/* continue */
|
/* continue */
|
||||||
@ -112,9 +110,11 @@ static yap_signals InteractSIGINT(int ch) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
This function talks to the user about a signal. We assume we are in
|
This function interacts with the user about a signal. We assume we are in
|
||||||
the context of the main Prolog thread (trivial in Unix, but hard in WIN32)
|
the context of the main Prolog thread (trivial in Unix, but hard in WIN32).
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static yap_signals ProcessSIGINT(void) {
|
static yap_signals ProcessSIGINT(void) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
|
@ -1155,9 +1155,12 @@ bool Yap_find_prolog_culprit(USES_REGS1) {
|
|||||||
|
|
||||||
while (curCP != YESCODE) {
|
while (curCP != YESCODE) {
|
||||||
curENV = (CELL *)(curENV[E_E]);
|
curENV = (CELL *)(curENV[E_E]);
|
||||||
if (curENV == NULL)
|
if (curENV < ASP || curENV >= LCL0)
|
||||||
break;
|
break;
|
||||||
pe = EnvPreg(curCP);
|
pe = EnvPreg(curCP);
|
||||||
|
if (pe==NULL) {
|
||||||
|
pe = PredMetaCall;
|
||||||
|
}
|
||||||
if (pe->ModuleOfPred)
|
if (pe->ModuleOfPred)
|
||||||
return set_clause_info(curCP, pe);
|
return set_clause_info(curCP, pe);
|
||||||
curCP = (yamop *)(curENV[E_CP]);
|
curCP = (yamop *)(curENV[E_CP]);
|
||||||
|
@ -91,12 +91,12 @@ endif()
|
|||||||
|
|
||||||
OPTION (WITH_SWIG " Enable SWIG interfaces to foreign languages" ON)
|
OPTION (WITH_SWIG " Enable SWIG interfaces to foreign languages" ON)
|
||||||
|
|
||||||
IF (WITH_SWIG)
|
IF (WITH_SWIG OR ANDROID)
|
||||||
find_host_package (SWIG)
|
find_host_package (SWIG)
|
||||||
macro_log_feature (SWIG_FOUND "Swig"
|
macro_log_feature (SWIG_FOUND "Swig"
|
||||||
"Use SWIG Interface Generator "
|
"Use SWIG Interface Generator "
|
||||||
"http://www.swig.org" ON)
|
"http://www.swig.org" ON)
|
||||||
ENDIF (WITH_SWIG)
|
ENDIF (WITH_SWIG OR ANDROID)
|
||||||
|
|
||||||
option (WITH_PYTHON
|
option (WITH_PYTHON
|
||||||
"Allow Python->YAP and YAP->Python" ON)
|
"Allow Python->YAP and YAP->Python" ON)
|
||||||
@ -106,37 +106,20 @@ IF (WITH_PYTHON)
|
|||||||
ENDIF (WITH_PYTHON)
|
ENDIF (WITH_PYTHON)
|
||||||
|
|
||||||
|
|
||||||
IF (SWIG_FOUND)
|
|
||||||
add_subDIRECTORY (packages/swig NO_POLICY_SCOPE)
|
|
||||||
ENDIF(SWIG_FOUND)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (ANDROID)
|
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(os)
|
|
||||||
ADD_SUBDIRECTORY(OPTYap)
|
|
||||||
ADD_SUBDIRECTORY(packages/myddas)
|
|
||||||
ADD_SUBDIRECTORY(utf8proc)
|
|
||||||
ADD_SUBDIRECTORY(CXX)
|
|
||||||
|
|
||||||
|
|
||||||
else()
|
|
||||||
|
|
||||||
List (APPEND YLIBS $<TARGET_OBJECTS:libOPTYap> )
|
List (APPEND YLIBS $<TARGET_OBJECTS:libOPTYap> )
|
||||||
List (APPEND YLIBS $<TARGET_OBJECTS:libYAPOs> )
|
List (APPEND YLIBS $<TARGET_OBJECTS:libYAPOs> )
|
||||||
List (APPEND YLIBS $<TARGET_OBJECTS:utf8proc> )
|
List (APPEND YLIBS $<TARGET_OBJECTS:utf8proc> )
|
||||||
List (APPEND YLIBS $<TARGET_OBJECTS:myddas> )
|
List (APPEND YLIBS $<TARGET_OBJECTS:myddas> )
|
||||||
List (APPEND YLIBS $<TARGET_OBJECTS:Yapsqlite3> )
|
|
||||||
List (APPEND YLIBS $<TARGET_OBJECTS:libswi> )
|
List (APPEND YLIBS $<TARGET_OBJECTS:libswi> )
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
List (APPEND YLIBS $<TARGET_OBJECTS:Yapsqlite3> )
|
||||||
List (APPEND YLIBS $<TARGET_OBJECTS:YAP++> )
|
List (APPEND YLIBS $<TARGET_OBJECTS:YAP++> )
|
||||||
if (WITH_PYTHON )
|
if (WITH_PYTHON )
|
||||||
List (APPEND YLIBS $<TARGET_OBJECTS:Py4YAP> )
|
List (APPEND YLIBS $<TARGET_OBJECTS:Py4YAP> )
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -167,8 +150,6 @@ if (USE_READLINE)
|
|||||||
endif (USE_READLINE)
|
endif (USE_READLINE)
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
add_dependencies(libYap plmyddas )
|
|
||||||
|
|
||||||
target_link_libraries(libYap android log)
|
target_link_libraries(libYap android log)
|
||||||
|
|
||||||
endif ()
|
endif ()
|
||||||
@ -192,4 +173,9 @@ if (PYTHONLIBS_FOUND AND SWIG_FOUND)
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
IF (SWIG_FOUND OR ANDROID)
|
||||||
|
add_subDIRECTORY (packages/swig NO_POLICY_SCOPE)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
include(Config NO_POLICY_SCOPE)
|
include(Config NO_POLICY_SCOPE)
|
||||||
|
168
CXX/yapi.cpp
168
CXX/yapi.cpp
@ -27,12 +27,14 @@ X_API void YAP_UserBackCPredicate(const char *, YAP_UserCPred, YAP_UserCPred,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static YAPEngine *curren;
|
||||||
|
|
||||||
YAPAtomTerm::YAPAtomTerm(char *s)
|
YAPAtomTerm::YAPAtomTerm(char *s)
|
||||||
{ // build string
|
{ // build string
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
seq_tv_t inp, out;
|
seq_tv_t inp, out;
|
||||||
inp.val.c = s;
|
inp.val.c = s;
|
||||||
inp.type = YAP_STRING_CHARS;
|
inp.type = YAP_STRING_CHARS;
|
||||||
out.type = YAP_STRING_ATOM;
|
out.type = YAP_STRING_ATOM;
|
||||||
@ -187,6 +189,7 @@ YAPApplTerm::YAPApplTerm(std::string f, std::vector<YAPTerm> ts)
|
|||||||
mk(o);
|
mk(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
YAPApplTerm::YAPApplTerm(YAPFunctor f) : YAPTerm()
|
YAPApplTerm::YAPApplTerm(YAPFunctor f) : YAPTerm()
|
||||||
{
|
{
|
||||||
BACKUP_H();
|
BACKUP_H();
|
||||||
@ -633,20 +636,20 @@ YAPQuery::YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm ts[])
|
|||||||
/* ignore flags for now */
|
/* ignore flags for now */
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
Term *nts;
|
Term *nts;
|
||||||
Term goal;
|
Term tgoal;
|
||||||
|
|
||||||
if ( ts) {
|
if ( ts) {
|
||||||
|
|
||||||
goal = YAPApplTerm(f, ts).term();
|
goal = new YAPApplTerm(f, ts);
|
||||||
nts = RepAppl(goal)+1;
|
nts = RepAppl(goal->term())+1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
goal = MkVarTerm();
|
goal = new YAPVarTerm();
|
||||||
nts = nullptr;
|
nts = nullptr;
|
||||||
}
|
}
|
||||||
openQuery(goal, nts);
|
openQuery(goal->term(), nts);
|
||||||
names = YAPPairTerm( TermNil );
|
names = new YAPPairTerm();
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -655,12 +658,13 @@ YAPQuery::YAPQuery(YAPFunctor f, YAPTerm ts[]) : YAPPredicate(f) {
|
|||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
CELL *nts;
|
CELL *nts;
|
||||||
if (ts) {
|
if (ts) {
|
||||||
goal = YAPApplTerm(f, nts);
|
tgoal = YAPApplTerm(f, nts);
|
||||||
} else {
|
} else {
|
||||||
goal = YAPVarTerm();
|
tgoal = YAPVarTerm();
|
||||||
nts = nullptr;
|
nts = nullptr;
|
||||||
}
|
}
|
||||||
names = YAPPairTerm( TermNil );
|
*names = new YAPPairTerm();
|
||||||
|
*goal = new YAPTerm(tgoal);
|
||||||
openQuery(goal.term(), nts);
|
openQuery(goal.term(), nts);
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
}
|
}
|
||||||
@ -671,19 +675,19 @@ YAPQuery::YAPQuery(YAPTerm t) : YAPPredicate(t)
|
|||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
CELL *nts;
|
CELL *nts;
|
||||||
Term tt = t.term();
|
Term tt = t.term();
|
||||||
goal = t;
|
|
||||||
if (IsApplTerm(tt)) {
|
if (IsApplTerm(tt)) {
|
||||||
Functor f = FunctorOfTerm(tt);
|
Functor f = FunctorOfTerm(tt);
|
||||||
if (IsExtensionFunctor(f))
|
if (IsExtensionFunctor(f))
|
||||||
nts = nullptr;
|
nts = nullptr;
|
||||||
nts = RepAppl(goal.term())+1;
|
nts = RepAppl(tt)+1;
|
||||||
} else if (IsPairTerm(tt)) {
|
} else if (IsPairTerm(tt)) {
|
||||||
nts = RepPair(tt);
|
nts = RepPair(tt);
|
||||||
} else {
|
} else {
|
||||||
nts = nullptr;
|
nts = nullptr;
|
||||||
}
|
}
|
||||||
openQuery(tt, nts);
|
openQuery(tt, nts);
|
||||||
names = YAPPairTerm( TermNil );
|
names = new YAPPairTerm();
|
||||||
|
goal = new YAPTerm(t);
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,15 +696,15 @@ YAPQuery::YAPQuery(YAPPredicate p, YAPTerm ts[]) : YAPPredicate(p.ap) {
|
|||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
arity_t arity = p.ap->ArityOfPE;
|
arity_t arity = p.ap->ArityOfPE;
|
||||||
if (arity) {
|
if (arity) {
|
||||||
goal = YAPApplTerm(YAPFunctor(p.ap->FunctorOfPred), ts).term();
|
goal = new YAPApplTerm(YAPFunctor(p.ap->FunctorOfPred), ts);
|
||||||
for (arity_t i =0; i < arity; i++)
|
for (arity_t i =0; i < arity; i++) {
|
||||||
XREGS[i+1]=ts[i].term();
|
XREGS[i + 1] = ts[i].term();
|
||||||
openQuery(goal.term(), nullptr);
|
}
|
||||||
} else {
|
} else {
|
||||||
goal = YAPAtomTerm((Atom)(p.ap->FunctorOfPred));
|
goal = new YAPAtomTerm((Atom)(p.ap->FunctorOfPred));
|
||||||
openQuery(goal.term(), nullptr);
|
|
||||||
}
|
}
|
||||||
names = TermNil;
|
openQuery(goal->term(), nullptr);
|
||||||
|
names = new YAPPairTerm();
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -709,6 +713,11 @@ bool YAPQuery::next()
|
|||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
bool result = false;
|
bool result = false;
|
||||||
Term terr;
|
Term terr;
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "next %d %ld",
|
||||||
|
q_state, LOCAL_CurSlot);
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "next %d %s %ld",
|
||||||
|
q_state, names->text(), LOCAL_CurSlot);
|
||||||
|
|
||||||
if (ap == NULL || ap->OpcodeOfPred == UNDEF_OPCODE) {
|
if (ap == NULL || ap->OpcodeOfPred == UNDEF_OPCODE) {
|
||||||
ap = rewriteUndefQuery();
|
ap = rewriteUndefQuery();
|
||||||
}
|
}
|
||||||
@ -718,7 +727,7 @@ bool YAPQuery::next()
|
|||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
if (!q_open)
|
if (!q_open)
|
||||||
return false;
|
return false;
|
||||||
if (sigsetjmp(q_env, false))
|
if (false && sigsetjmp(q_env, false))
|
||||||
{
|
{
|
||||||
throw YAPError();
|
throw YAPError();
|
||||||
}
|
}
|
||||||
@ -736,57 +745,57 @@ bool YAPQuery::next()
|
|||||||
}
|
}
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "vnames %d %s %ld",
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "names %d %s %ld",
|
||||||
q_state, vnames.text(), LOCAL_CurSlot);
|
q_state, names->text(), LOCAL_CurSlot);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "fail");
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "fail");
|
||||||
}
|
}
|
||||||
q_state = 1;
|
q_state = 1;
|
||||||
if ((terr = Yap_GetException()))
|
if ((terr = Yap_GetException()))
|
||||||
{
|
|
||||||
if ((terr = Yap_GetException()))
|
|
||||||
{
|
{
|
||||||
throw YAPError();
|
if ((terr = Yap_GetException()))
|
||||||
|
{
|
||||||
|
throw YAPError();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "out %d", result);
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "out %d", result);
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
YAP_LeaveGoal(false, &q_h);
|
YAP_LeaveGoal(false, &q_h);
|
||||||
Yap_CloseHandles(q_handles);
|
Yap_CloseHandles(q_handles);
|
||||||
q_open = false;
|
q_open = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
q_handles = Yap_StartSlots();
|
q_handles = Yap_StartSlots();
|
||||||
}
|
}
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
catch (YAPError e)
|
catch (YAPError e)
|
||||||
{
|
{
|
||||||
q_open = false;
|
q_open = false;
|
||||||
Yap_PopTermFromDB(LOCAL_ActiveError->errorTerm);
|
Yap_PopTermFromDB(LOCAL_ActiveError->errorTerm);
|
||||||
memset(LOCAL_ActiveError, 0, sizeof(*LOCAL_ActiveError));
|
memset(LOCAL_ActiveError, 0, sizeof(*LOCAL_ActiveError));
|
||||||
YAP_LeaveGoal(false, &q_h);
|
YAP_LeaveGoal(false, &q_h);
|
||||||
Yap_CloseHandles(q_handles);
|
Yap_CloseHandles(q_handles);
|
||||||
q_open = false;
|
q_open = false;
|
||||||
std::cerr << "Exception received by " << __func__ << "( " << YAPTerm(terr).text() << ").\n Forwarded...\n\n";
|
std::cerr << "Exception received by " << __func__ << "( " << YAPTerm(terr).text() << ").\n Forwarded...\n\n";
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PredEntry *
|
PredEntry *
|
||||||
YAPQuery::rewriteUndefQuery()
|
YAPQuery::rewriteUndefQuery()
|
||||||
{
|
{
|
||||||
Term ts[3];
|
Term ts[3];
|
||||||
ARG1 = ts[0] = goal.term();
|
ARG1 = ts[0] = goal->term();
|
||||||
ARG2 = ts[1] = ap->ModuleOfPred;
|
ARG2 = ts[1] = ap->ModuleOfPred;
|
||||||
ARG3 = ts[2] = Yap_cp_as_integer(B PASS_REGS);
|
ARG3 = ts[2] = Yap_cp_as_integer(B PASS_REGS);
|
||||||
goal = YAPApplTerm(FunctorUndefinedQuery, ts);
|
goal = new YAPApplTerm(FunctorUndefinedQuery, ts);
|
||||||
return ap = PredUndefinedQuery;
|
return ap = PredUndefinedQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -868,39 +877,6 @@ JNIEXPORT jint JNICALL JNI_MySQLOnLoad(JavaVM *vm, void *reserved)
|
|||||||
return JNI_VERSION_1_6;
|
return JNI_VERSION_1_6;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *Yap_AndroidBufp;
|
|
||||||
|
|
||||||
static size_t Yap_AndroidMax, Yap_AndroidSz;
|
|
||||||
|
|
||||||
extern void (*Yap_DisplayWithJava)(int c);
|
|
||||||
|
|
||||||
void Yap_displayWithJava(int c)
|
|
||||||
{
|
|
||||||
char *ptr = Yap_AndroidBufp;
|
|
||||||
if (!ptr)
|
|
||||||
ptr = Yap_AndroidBufp = (char *)malloc(Yap_AndroidSz);
|
|
||||||
ptr[Yap_AndroidSz++] = c;
|
|
||||||
if (Yap_AndroidMax - 1 == Yap_AndroidSz)
|
|
||||||
{
|
|
||||||
if (Yap_AndroidMax < 32 * 1024)
|
|
||||||
{
|
|
||||||
Yap_AndroidMax *= 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Yap_AndroidMax += 32 * 1024;
|
|
||||||
}
|
|
||||||
Yap_AndroidBufp = (char *)realloc(ptr, Yap_AndroidMax);
|
|
||||||
}
|
|
||||||
Yap_AndroidBufp[Yap_AndroidSz] = '\0';
|
|
||||||
if (c == '\n')
|
|
||||||
{
|
|
||||||
Yap_AndroidBufp[Yap_AndroidSz] = '\0';
|
|
||||||
curren->run(Yap_AndroidBufp);
|
|
||||||
Yap_AndroidSz = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -913,22 +889,18 @@ void YAPEngine::doInit(YAP_file_type_t BootMode)
|
|||||||
/* Begin preprocessor code */
|
/* Begin preprocessor code */
|
||||||
/* live */
|
/* live */
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "initialize_prolog");
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "initialize_prolog");
|
||||||
#if __ANDROID__
|
curren = this;
|
||||||
Yap_AndroidBufp = (char *)malloc(Yap_AndroidMax = 4096);
|
|
||||||
Yap_AndroidBufp[0] = '\0';
|
|
||||||
Yap_AndroidSz = 0;
|
|
||||||
#endif
|
|
||||||
//yerror = YAPError();
|
//yerror = YAPError();
|
||||||
#if YAP_PYTHON
|
#if YAP_PYTHON
|
||||||
do_init_python();
|
do_init_python();
|
||||||
#endif
|
#endif
|
||||||
YAP_PredEntryPtr p = YAP_AtomToPred( YAP_LookupAtom("initialize_prolog") );
|
YAP_PredEntryPtr p = YAP_AtomToPred( YAP_LookupAtom("initialize_prolog") );
|
||||||
YAPQuery initq = YAPQuery(YAPPredicate(p), nullptr);
|
YAPQuery initq = YAPQuery(YAPPredicate(p), nullptr);
|
||||||
if (initq.next())
|
if (initq.next())
|
||||||
{
|
{
|
||||||
initq.cut();
|
initq.cut();
|
||||||
}
|
}
|
||||||
CurrentModule = TermUser;
|
CurrentModule = TermUser;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
85
CXX/yapq.hh
85
CXX/yapq.hh
@ -41,8 +41,8 @@ class X_API YAPQuery : public YAPPredicate
|
|||||||
int q_flags;
|
int q_flags;
|
||||||
YAP_dogoalinfo q_h;
|
YAP_dogoalinfo q_h;
|
||||||
YAPQuery *oq;
|
YAPQuery *oq;
|
||||||
YAPPairTerm names;
|
YAPPairTerm *names;
|
||||||
YAPTerm goal;
|
YAPTerm *goal;
|
||||||
// temporaries
|
// temporaries
|
||||||
Term tnames, tgoal ;
|
Term tnames, tgoal ;
|
||||||
|
|
||||||
@ -55,6 +55,8 @@ class X_API YAPQuery : public YAPPredicate
|
|||||||
q_p = P;
|
q_p = P;
|
||||||
q_cp = CP;
|
q_cp = CP;
|
||||||
// make sure this is safe
|
// make sure this is safe
|
||||||
|
names = new YAPPairTerm();
|
||||||
|
goal = new YAPTerm();
|
||||||
q_handles = LOCAL_CurSlot;
|
q_handles = LOCAL_CurSlot;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -97,8 +99,7 @@ YAPQuery() {
|
|||||||
LOCAL_CurSlot);
|
LOCAL_CurSlot);
|
||||||
if (!ap)
|
if (!ap)
|
||||||
return;
|
return;
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "%s", vnames.text());
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "ŸAPQuery");
|
||||||
goal = YAPTerm(tgoal);
|
|
||||||
if (IsPairTerm(tgoal)) {
|
if (IsPairTerm(tgoal)) {
|
||||||
qt = RepPair(tgoal);
|
qt = RepPair(tgoal);
|
||||||
tgoal = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("consult"), 1),1,qt);
|
tgoal = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("consult"), 1),1,qt);
|
||||||
@ -108,8 +109,11 @@ YAPQuery() {
|
|||||||
qt = RepAppl(tgoal)+1;
|
qt = RepAppl(tgoal)+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
names = YAPPairTerm(tnames);
|
names = new YAPPairTerm();
|
||||||
openQuery(tgoal, qt);
|
goal = new YAPTerm(tgoal);
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "names %d %s %ld",
|
||||||
|
q_state, names->text(), LOCAL_CurSlot);
|
||||||
|
openQuery(tgoal, qt);
|
||||||
};
|
};
|
||||||
// inline YAPQuery() : YAPPredicate(s, tgoal, tnames)
|
// inline YAPQuery() : YAPPredicate(s, tgoal, tnames)
|
||||||
// {
|
// {
|
||||||
@ -117,7 +121,7 @@ YAPQuery() {
|
|||||||
// LOCAL_CurSlot);
|
// LOCAL_CurSlot);
|
||||||
// if (!ap)
|
// if (!ap)
|
||||||
// return;
|
// return;
|
||||||
// __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "%s", vnames.text());
|
// __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "%s", names->text());
|
||||||
// goal = YAPTerm(tgoal);
|
// goal = YAPTerm(tgoal);
|
||||||
// names = YAPPairTerm(tnames);
|
// names = YAPPairTerm(tnames);
|
||||||
// openQuery(tgoal);
|
// openQuery(tgoal);
|
||||||
@ -130,40 +134,39 @@ YAPQuery() {
|
|||||||
/// set flags for query execution, currently only for exception handling
|
/// set flags for query execution, currently only for exception handling
|
||||||
void setFlag(int flag) { q_flags |= flag; }
|
void setFlag(int flag) { q_flags |= flag; }
|
||||||
/// reset flags for query execution, currently only for exception handling
|
/// reset flags for query execution, currently only for exception handling
|
||||||
void resetFlag(int flag) { q_flags &= ~flag; }
|
void resetFlag(int flag) { q_flags &= ~flag; }
|
||||||
/// first query
|
/// first query
|
||||||
///
|
///
|
||||||
/// actually implemented by calling the next();
|
/// actually implemented by calling the next();
|
||||||
inline bool first() { return next(); }
|
inline bool first() { return next(); }
|
||||||
/// ask for the next solution of the current query
|
/// ask for the next solution of the current query
|
||||||
/// same call for every solution
|
/// same call for every solution
|
||||||
bool next();
|
bool next();
|
||||||
/// does this query have open choice-points?
|
/// does this query have open choice-points?
|
||||||
/// or is it deterministic?
|
/// or is it deterministic?
|
||||||
bool deterministic();
|
bool deterministic();
|
||||||
/// represent the top-goal
|
/// represent the top-goal
|
||||||
const char *text();
|
const char *text();
|
||||||
/// remove alternatives in the current search space, and finish the current
|
/// remove alternatives in the current search space, and finish tnamedyaphe current
|
||||||
/// query
|
/// query
|
||||||
/// finish the current query: undo all bindings.
|
/// finish the current query: undo all bindings.
|
||||||
void close();
|
void close();
|
||||||
/// query variables.
|
/// query variables.
|
||||||
void cut();
|
void cut();
|
||||||
Term namedVars() {return names.term(); };
|
|
||||||
/// query variables, but copied out
|
Term namedVars() {return names->term(); };
|
||||||
std::vector<Term> namedVarsVector() {
|
YAPPairTerm * namedYAPVars() {return names; };
|
||||||
return names.listToArray(); };
|
/// query variables, but copied out
|
||||||
/// convert a ref to a binding.
|
YAPTerm getTerm(yhandle_t t);
|
||||||
YAPTerm getTerm(yhandle_t t);
|
/// simple YAP Query;
|
||||||
/// simple YAP Query;
|
/// just calls YAP and reports success or failure, Useful when we just
|
||||||
/// just calls YAP and reports success or failure, Useful when we just
|
/// want things done, eg YAPCommand("load_files(library(lists), )")
|
||||||
/// want things done, eg YAPCommand("load_files(library(lists), )")
|
inline bool command()
|
||||||
inline bool command()
|
{
|
||||||
{
|
bool rc = next();
|
||||||
bool rc = next();
|
close();
|
||||||
close();
|
return rc;
|
||||||
return rc;
|
};
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Java support
|
// Java support
|
||||||
|
869
CXX/yapt.hh
869
CXX/yapt.hh
File diff suppressed because it is too large
Load Diff
@ -179,15 +179,15 @@ INLINE_ONLY inline EXTERN void Yap_PutInHandle__(yhandle_t slot,
|
|||||||
LOCAL_HandleBase[slot] = t;
|
LOCAL_HandleBase[slot] = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef max
|
#ifndef Yap_Max
|
||||||
#define max(X, Y) (X > Y ? X : Y)
|
#define Yap_Max(X, Y) (X > Y ? X : Y)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ensure_handles ensure_slots
|
#define ensure_handles ensure_slots
|
||||||
INLINE_ONLY inline EXTERN void ensure_slots(int N USES_REGS) {
|
INLINE_ONLY inline EXTERN void ensure_slots(int N USES_REGS) {
|
||||||
if (LOCAL_CurHandle + N >= LOCAL_NHandles) {
|
if (LOCAL_CurHandle + N >= LOCAL_NHandles) {
|
||||||
size_t inc = max(16 * 1024, LOCAL_NHandles / 2); // measured in cells
|
size_t inc = Yap_Max(16 * 1024, LOCAL_NHandles / 2); // measured in cells
|
||||||
inc = max(inc, (size_t)N + 16); // measured in cells
|
inc = Yap_Max(inc, (size_t)N + 16); // measured in cells
|
||||||
LOCAL_HandleBase = (CELL *)realloc(LOCAL_HandleBase,
|
LOCAL_HandleBase = (CELL *)realloc(LOCAL_HandleBase,
|
||||||
(inc + LOCAL_NHandles) * sizeof(CELL));
|
(inc + LOCAL_NHandles) * sizeof(CELL));
|
||||||
LOCAL_NHandles += inc;
|
LOCAL_NHandles += inc;
|
||||||
|
@ -59,8 +59,9 @@ extern int pop_text_stack(int lvl USES_REGS);
|
|||||||
extern void *protected_pop_text_stack(int lvl, void *safe, bool tmp,
|
extern void *protected_pop_text_stack(int lvl, void *safe, bool tmp,
|
||||||
size_t sz USES_REGS);
|
size_t sz USES_REGS);
|
||||||
|
|
||||||
#ifndef min
|
#ifndef Yap_Min
|
||||||
#define min(x, y) (x < y ? x : y)
|
#define Yap_Min(x, y) (x < y ? x : y)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MBYTE (1024 * 1024)
|
#define MBYTE (1024 * 1024)
|
||||||
|
@ -1,379 +1,364 @@
|
|||||||
#define EXECUTE_INSTINIT \
|
#define EXECUTE_INSTINIT \
|
||||||
print_instruction((*_PREG), ON_NATIVE); \
|
print_instruction((*_PREG), ON_NATIVE); \
|
||||||
BLOCKADDRESS = (CELL)(*_PREG); \
|
BLOCKADDRESS = (CELL)(*_PREG); \
|
||||||
register CELL d0; \
|
register CELL d0; \
|
||||||
PredEntry *pt0; \
|
PredEntry *pt0; \
|
||||||
register CELL *ENV_YREG = (YREG); \
|
register CELL *ENV_YREG = (YREG); \
|
||||||
pt0 = (*_PREG)->u.pp.p;
|
pt0 = (*_PREG)->u.Osbpp.p;
|
||||||
|
|
||||||
#ifdef LOW_LEVEL_TRACER
|
#ifdef LOW_LEVEL_TRACER
|
||||||
#define EXECUTE_LOW_LEVEL_TRACER \
|
#define EXECUTE_LOW_LEVEL_TRACER low_level_trace(enter_pred, pt0, XREGS + 1);
|
||||||
low_level_trace(enter_pred,pt0,XREGS+1);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define EXECUTE_POST_LOW_LEVEL_TRACER \
|
#define EXECUTE_POST_LOW_LEVEL_TRACER \
|
||||||
CACHE_A1(); \
|
CACHE_A1(); \
|
||||||
ALWAYS_LOOKAHEAD(pt0->OpcodeOfPred); \
|
ALWAYS_LOOKAHEAD(pt0->OpcodeOfPred); \
|
||||||
d0 = (CELL)B;
|
d0 = (CELL)B;
|
||||||
|
|
||||||
#define EXECUTE_POST_NOCHECKING \
|
#define EXECUTE_POST_NOCHECKING \
|
||||||
(*_PREG) = pt0->CodeOfPred; \
|
(*_PREG) = pt0->CodeOfPred; \
|
||||||
save_pc(); \
|
save_pc(); \
|
||||||
ENV_YREG[E_CB] = d0;
|
ENV_YREG[E_CB] = d0;
|
||||||
|
|
||||||
#ifdef DEPTH_LIMIT
|
#ifdef DEPTH_LIMIT
|
||||||
#define EXECUTE_DEPTH_MINOR \
|
#define EXECUTE_DEPTH_MINOR \
|
||||||
FAILED = 0; \
|
FAILED = 0; \
|
||||||
if (pt0->ModuleOfPred) { \
|
if (pt0->ModuleOfPred) { \
|
||||||
if (DEPTH == MkIntTerm(0)) { \
|
if (DEPTH == MkIntTerm(0)) { \
|
||||||
YAAM_FAIL; \
|
YAAM_FAIL; \
|
||||||
} \
|
} else { \
|
||||||
else { \
|
DEPTH = RESET_DEPTH(); \
|
||||||
DEPTH = RESET_DEPTH(); \
|
} \
|
||||||
} \
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#define EXECUTE_DEPTH_MOFPRED \
|
#define EXECUTE_DEPTH_MOFPRED \
|
||||||
FAILED = 0; \
|
FAILED = 0; \
|
||||||
DEPTH -= MkIntConstant(2);
|
DEPTH -= MkIntConstant(2);
|
||||||
|
|
||||||
#define EXECUTE_DEPTH_END \
|
#define EXECUTE_DEPTH_END FAILED = 0;
|
||||||
FAILED = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define EXECUTE_END_END \
|
#define EXECUTE_END_END \
|
||||||
BLOCK = (CELL)EXECUTE_END_END; \
|
BLOCK = (CELL)EXECUTE_END_END; \
|
||||||
if (!FAILED) { \
|
if (!FAILED) { \
|
||||||
ALWAYS_GONext(); \
|
ALWAYS_GONext(); \
|
||||||
} \
|
}
|
||||||
|
|
||||||
#define DEXECUTE_INSTINIT \
|
#define DEXECUTE_INSTINIT \
|
||||||
print_instruction((*_PREG), ON_NATIVE); \
|
print_instruction((*_PREG), ON_NATIVE); \
|
||||||
BLOCKADDRESS = (CELL)(*_PREG); \
|
BLOCKADDRESS = (CELL)(*_PREG);
|
||||||
|
|
||||||
#ifdef LOW_LEVEL_TRACER
|
#ifdef LOW_LEVEL_TRACER
|
||||||
#define DEXECUTE_LOW_LEVEL_TRACER \
|
#define DEXECUTE_LOW_LEVEL_TRACER \
|
||||||
low_level_trace(enter_pred,(*_PREG)->u.pp.p,XREGS+1);
|
low_level_trace(enter_pred, (*_PREG)->u.Osbpp.p, XREGS + 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEXECUTE_POST_LOW_LEVEL_TRACER \
|
#define DEXECUTE_POST_LOW_LEVEL_TRACER \
|
||||||
CACHE_Y_AS_ENV(YREG); \
|
CACHE_Y_AS_ENV(YREG); \
|
||||||
PredEntry *pt0; \
|
PredEntry *pt0; \
|
||||||
CACHE_A1(); \
|
CACHE_A1(); \
|
||||||
pt0 = (*_PREG)->u.pp.p;
|
pt0 = (*_PREG)->u.Osbpp.p;
|
||||||
|
|
||||||
#ifdef DEPTH_LIMIT
|
#ifdef DEPTH_LIMIT
|
||||||
#define DEXECUTE_DEPTH_MINOR \
|
#define DEXECUTE_DEPTH_MINOR \
|
||||||
FAILED = 0; \
|
FAILED = 0; \
|
||||||
if (pt0->ModuleOfPred) { \
|
if (pt0->ModuleOfPred) { \
|
||||||
if (DEPTH == MkIntTerm(0)) { \
|
if (DEPTH == MkIntTerm(0)) { \
|
||||||
YAAM_FAIL; \
|
YAAM_FAIL; \
|
||||||
} \
|
} else { \
|
||||||
else { \
|
DEPTH = RESET_DEPTH(); \
|
||||||
DEPTH = RESET_DEPTH(); \
|
} \
|
||||||
} \
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#define DEXECUTE_DEPTH_MOFPRED \
|
#define DEXECUTE_DEPTH_MOFPRED \
|
||||||
FAILED = 0; \
|
FAILED = 0; \
|
||||||
DEPTH -= MkIntConstant(2);
|
DEPTH -= MkIntConstant(2);
|
||||||
|
|
||||||
#define DEXECUTE_DEPTH_END \
|
#define DEXECUTE_DEPTH_END FAILED = 0;
|
||||||
FAILED = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FROZEN_STACKS
|
#ifdef FROZEN_STACKS
|
||||||
#ifdef YAPOR_SBA
|
#ifdef YAPOR_SBA
|
||||||
#define DEXECUTE_END_END \
|
#define DEXECUTE_END_END \
|
||||||
BLOCK = (CELL)DEXECUTE_END_END; \
|
BLOCK = (CELL)DEXECUTE_END_END; \
|
||||||
if (!FAILED) { \
|
if (!FAILED) { \
|
||||||
(*_PREG) = pt0->CodeOfPred; \
|
(*_PREG) = pt0->CodeOfPred; \
|
||||||
save_pc(); \
|
save_pc(); \
|
||||||
(*_CPREG) = (yamop *) ENV_YREG[E_CP]; \
|
(*_CPREG) = (yamop *)ENV_YREG[E_CP]; \
|
||||||
ENV_YREG = ENV = (CELL *) ENV_YREG[E_E]; \
|
ENV_YREG = ENV = (CELL *)ENV_YREG[E_E]; \
|
||||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||||
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) { \
|
if (ENV_YREG > (CELL *)top_b || ENV_YREG < HR) { \
|
||||||
ENV_YREG = (CELL *) top_b; \
|
ENV_YREG = (CELL *)top_b; \
|
||||||
} \
|
} else { \
|
||||||
else { \
|
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \
|
||||||
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \
|
} \
|
||||||
} \
|
WRITEBACK_Y_AS_ENV(); \
|
||||||
WRITEBACK_Y_AS_ENV(); \
|
ENV_YREG[E_CB] = (CELL)B; \
|
||||||
ENV_YREG[E_CB] = (CELL) B; \
|
ALWAYS_GONext(); \
|
||||||
ALWAYS_GONext(); \
|
} \
|
||||||
} \
|
ENDCACHE_Y_AS_ENV();
|
||||||
ENDCACHE_Y_AS_ENV();
|
|
||||||
#else /* YAPOR_SBA */
|
#else /* YAPOR_SBA */
|
||||||
#define DEXECUTE_END_END \
|
#define DEXECUTE_END_END \
|
||||||
BLOCK = (CELL)DEXECUTE_END_END; \
|
BLOCK = (CELL)DEXECUTE_END_END; \
|
||||||
if (!FAILED) { \
|
if (!FAILED) { \
|
||||||
(*_PREG) = pt0->CodeOfPred; \
|
(*_PREG) = pt0->CodeOfPred; \
|
||||||
save_pc(); \
|
save_pc(); \
|
||||||
(*_CPREG) = (yamop *) ENV_YREG[E_CP]; \
|
(*_CPREG) = (yamop *)ENV_YREG[E_CP]; \
|
||||||
ENV_YREG = ENV = (CELL *) ENV_YREG[E_E]; \
|
ENV_YREG = ENV = (CELL *)ENV_YREG[E_E]; \
|
||||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||||
if (ENV_YREG > (CELL *) top_b) { \
|
if (ENV_YREG > (CELL *)top_b) { \
|
||||||
ENV_YREG = (CELL *) top_b; \
|
ENV_YREG = (CELL *)top_b; \
|
||||||
} \
|
} else { \
|
||||||
else { \
|
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \
|
||||||
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \
|
} \
|
||||||
} \
|
WRITEBACK_Y_AS_ENV(); \
|
||||||
WRITEBACK_Y_AS_ENV(); \
|
ENV_YREG[E_CB] = (CELL)B; \
|
||||||
ENV_YREG[E_CB] = (CELL) B; \
|
ALWAYS_GONext(); \
|
||||||
ALWAYS_GONext(); \
|
} \
|
||||||
} \
|
ENDCACHE_Y_AS_ENV();
|
||||||
ENDCACHE_Y_AS_ENV();
|
|
||||||
#endif /* YAPOR_SBA */
|
#endif /* YAPOR_SBA */
|
||||||
#else /* FROZEN_STACKS */
|
#else /* FROZEN_STACKS */
|
||||||
#define DEXECUTE_END_END \
|
#define DEXECUTE_END_END \
|
||||||
BLOCK = (CELL)DEXECUTE_END_END; \
|
BLOCK = (CELL)DEXECUTE_END_END; \
|
||||||
if (!FAILED) { \
|
if (!FAILED) { \
|
||||||
(*_PREG) = pt0->CodeOfPred; \
|
(*_PREG) = pt0->CodeOfPred; \
|
||||||
save_pc(); \
|
save_pc(); \
|
||||||
(*_CPREG) = (yamop *) ENV_YREG[E_CP]; \
|
(*_CPREG) = (yamop *)ENV_YREG[E_CP]; \
|
||||||
ENV_YREG = ENV = (CELL *) ENV_YREG[E_E]; \
|
ENV_YREG = ENV = (CELL *)ENV_YREG[E_E]; \
|
||||||
if (ENV_YREG > (CELL *)B) { \
|
if (ENV_YREG > (CELL *)B) { \
|
||||||
ENV_YREG = (CELL *)B; \
|
ENV_YREG = (CELL *)B; \
|
||||||
} \
|
} else { \
|
||||||
else { \
|
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \
|
||||||
ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size((*_CPREG))); \
|
} \
|
||||||
} \
|
WRITEBACK_Y_AS_ENV(); \
|
||||||
WRITEBACK_Y_AS_ENV(); \
|
ENV_YREG[E_CB] = (CELL)B; \
|
||||||
ENV_YREG[E_CB] = (CELL) B; \
|
ALWAYS_GONext(); \
|
||||||
ALWAYS_GONext(); \
|
} \
|
||||||
} \
|
ENDCACHE_Y_AS_ENV();
|
||||||
ENDCACHE_Y_AS_ENV();
|
|
||||||
#endif /* FROZEN_STACKS */
|
#endif /* FROZEN_STACKS */
|
||||||
|
|
||||||
#ifdef DEPTH_LIMIT
|
#ifdef DEPTH_LIMIT
|
||||||
#define FCALL_INST \
|
#define FCALL_INST \
|
||||||
CACHE_Y_AS_ENV(YREG); \
|
CACHE_Y_AS_ENV(YREG); \
|
||||||
ENV_YREG[E_CP] = (CELL) (*_CPREG); \
|
ENV_YREG[E_CP] = (CELL)(*_CPREG); \
|
||||||
ENV_YREG[E_E] = (CELL) ENV; \
|
ENV_YREG[E_E] = (CELL)ENV; \
|
||||||
ENV_YREG[E_DEPTH] = DEPTH; \
|
ENV_YREG[E_DEPTH] = DEPTH; \
|
||||||
ENDCACHE_Y_AS_ENV();
|
ENDCACHE_Y_AS_ENV();
|
||||||
#else /* DEPTH_LIMIT */
|
#else /* DEPTH_LIMIT */
|
||||||
#define FCALL_INST \
|
#define FCALL_INST \
|
||||||
CACHE_Y_AS_ENV(YREG); \
|
CACHE_Y_AS_ENV(YREG); \
|
||||||
ENV_YREG[E_CP] = (CELL) (*_CPREG); \
|
ENV_YREG[E_CP] = (CELL)(*_CPREG); \
|
||||||
ENV_YREG[E_E] = (CELL) ENV; \
|
ENV_YREG[E_E] = (CELL)ENV; \
|
||||||
ENDCACHE_Y_AS_ENV();
|
ENDCACHE_Y_AS_ENV();
|
||||||
#endif /* DEPTH_LIMIT */
|
#endif /* DEPTH_LIMIT */
|
||||||
|
|
||||||
#define CALL_INSTINIT \
|
#define CALL_INSTINIT \
|
||||||
print_instruction((*_PREG), ON_NATIVE); \
|
print_instruction((*_PREG), ON_NATIVE); \
|
||||||
BLOCKADDRESS = (CELL)(*_PREG); \
|
BLOCKADDRESS = (CELL)(*_PREG); \
|
||||||
if (Yap_op_from_opcode((*_PREG)->opc) == _fcall) { \
|
if (Yap_op_from_opcode((*_PREG)->opc) == _fcall) { \
|
||||||
FCALL_INST; \
|
FCALL_INST; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LOW_LEVEL_TRACER
|
#ifdef LOW_LEVEL_TRACER
|
||||||
#define CALL_LOW_LEVEL_TRACER \
|
#define CALL_LOW_LEVEL_TRACER \
|
||||||
low_level_trace(enter_pred,(*_PREG)->u.Osbpp.p,XREGS+1);
|
low_level_trace(enter_pred, (*_PREG)->u.Osbpp.p, XREGS + 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CALL_POST_LOW_LEVEL_TRACER \
|
#define CALL_POST_LOW_LEVEL_TRACER \
|
||||||
register CELL *ENV_YREG = (YREG); \
|
register CELL *ENV_YREG = (YREG); \
|
||||||
PredEntry *pt; \
|
PredEntry *pt; \
|
||||||
pt = (*_PREG)->u.Osbpp.p; \
|
pt = (*_PREG)->u.Osbpp.p; \
|
||||||
CACHE_A1();
|
CACHE_A1();
|
||||||
|
|
||||||
#define CALL_POST_NO_CHECKING \
|
#define CALL_POST_NO_CHECKING \
|
||||||
ENV = ENV_YREG; \
|
ENV = ENV_YREG; \
|
||||||
ENV_YREG = (CELL *) (((char *) ENV_YREG) + (*_PREG)->u.Osbpp.s); \
|
ENV_YREG = (CELL *)(((char *)ENV_YREG) + (*_PREG)->u.Osbpp.s); \
|
||||||
(*_CPREG) = NEXTOP((*_PREG), Osbpp); \
|
(*_CPREG) = NEXTOP((*_PREG), Osbpp); \
|
||||||
(*_PREG) = pt->CodeOfPred; \
|
(*_PREG) = pt->CodeOfPred; \
|
||||||
save_pc(); \
|
save_pc();
|
||||||
|
|
||||||
#ifdef DEPTH_LIMIT
|
#ifdef DEPTH_LIMIT
|
||||||
#define CALL_DEPTH_MINOR \
|
#define CALL_DEPTH_MINOR \
|
||||||
FAILED = 0; \
|
FAILED = 0; \
|
||||||
if (pt->ModuleOfPred) { \
|
if (pt->ModuleOfPred) { \
|
||||||
if (DEPTH == MkIntTerm(0)){ \
|
if (DEPTH == MkIntTerm(0)) { \
|
||||||
YAAM_FAIL; \
|
YAAM_FAIL; \
|
||||||
} else { \
|
} else { \
|
||||||
DEPTH = RESET_DEPTH(); \
|
DEPTH = RESET_DEPTH(); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CALL_DEPTH_MOFPRED \
|
#define CALL_DEPTH_MOFPRED \
|
||||||
FAILED = 0; \
|
FAILED = 0; \
|
||||||
DEPTH -= MkIntConstant(2);
|
DEPTH -= MkIntConstant(2);
|
||||||
|
|
||||||
#define CALL_DEPTH_END \
|
#define CALL_DEPTH_END FAILED = 0;
|
||||||
FAILED = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
#ifdef FROZEN_STACKS
|
#ifdef FROZEN_STACKS
|
||||||
#ifdef YAPOR_SBA
|
#ifdef YAPOR_SBA
|
||||||
#define CALL_END_END \
|
#define CALL_END_END \
|
||||||
BLOCK = (CELL)CALL_END_END; \
|
BLOCK = (CELL)CALL_END_END; \
|
||||||
if (!FAILED) { \
|
if (!FAILED) { \
|
||||||
{ \
|
{ \
|
||||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||||
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) { \
|
if (ENV_YREG > (CELL *)top_b || ENV_YREG < HR) { \
|
||||||
ENV_YREG = (CELL *) top_b; \
|
ENV_YREG = (CELL *)top_b; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
WRITEBACK_Y_AS_ENV(); \
|
WRITEBACK_Y_AS_ENV(); \
|
||||||
ENV_YREG[E_CB] = (CELL) B; \
|
ENV_YREG[E_CB] = (CELL)B; \
|
||||||
SCH_check_requests(); \
|
SCH_check_requests(); \
|
||||||
ALWAYS_GONext(); \
|
ALWAYS_GONext(); \
|
||||||
}
|
}
|
||||||
#else /* YAPOR_SBA */
|
#else /* YAPOR_SBA */
|
||||||
#define CALL_END_END \
|
#define CALL_END_END \
|
||||||
BLOCK = (CELL)CALL_END_END; \
|
BLOCK = (CELL)CALL_END_END; \
|
||||||
if (!FAILED) { \
|
if (!FAILED) { \
|
||||||
{ \
|
{ \
|
||||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||||
if (ENV_YREG > (CELL *) top_b) { \
|
if (ENV_YREG > (CELL *)top_b) { \
|
||||||
ENV_YREG = (CELL *) top_b; \
|
ENV_YREG = (CELL *)top_b; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
WRITEBACK_Y_AS_ENV(); \
|
WRITEBACK_Y_AS_ENV(); \
|
||||||
ENV_YREG[E_CB] = (CELL) B; \
|
ENV_YREG[E_CB] = (CELL)B; \
|
||||||
SCH_check_requests(); \
|
SCH_check_requests(); \
|
||||||
ALWAYS_GONext(); \
|
ALWAYS_GONext(); \
|
||||||
}
|
}
|
||||||
#endif /* YAPOR_SBA */
|
#endif /* YAPOR_SBA */
|
||||||
#else /* FROZEN_STACKS */
|
#else /* FROZEN_STACKS */
|
||||||
#define CALL_END_END \
|
#define CALL_END_END \
|
||||||
BLOCK = (CELL)CALL_END_END; \
|
BLOCK = (CELL)CALL_END_END; \
|
||||||
if (!FAILED) { \
|
if (!FAILED) { \
|
||||||
if (ENV_YREG > (CELL *) B) { \
|
if (ENV_YREG > (CELL *)B) { \
|
||||||
ENV_YREG = (CELL *) B; \
|
ENV_YREG = (CELL *)B; \
|
||||||
} \
|
} \
|
||||||
WRITEBACK_Y_AS_ENV(); \
|
WRITEBACK_Y_AS_ENV(); \
|
||||||
ENV_YREG[E_CB] = (CELL) B; \
|
ENV_YREG[E_CB] = (CELL)B; \
|
||||||
SCH_check_requests(); \
|
SCH_check_requests(); \
|
||||||
ALWAYS_GONext(); \
|
ALWAYS_GONext(); \
|
||||||
}
|
}
|
||||||
#endif /* FROZEN_STACKS */
|
#endif /* FROZEN_STACKS */
|
||||||
#else /* YAPOR */
|
#else /* YAPOR */
|
||||||
#ifdef FROZEN_STACKS
|
#ifdef FROZEN_STACKS
|
||||||
#ifdef YAPOR_SBA
|
#ifdef YAPOR_SBA
|
||||||
#define CALL_END_END \
|
#define CALL_END_END \
|
||||||
BLOCK = (CELL)CALL_END_END; \
|
BLOCK = (CELL)CALL_END_END; \
|
||||||
if (!FAILED) { \
|
if (!FAILED) { \
|
||||||
{ \
|
{ \
|
||||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||||
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) { \
|
if (ENV_YREG > (CELL *)top_b || ENV_YREG < HR) { \
|
||||||
ENV_YREG = (CELL *) top_b; \
|
ENV_YREG = (CELL *)top_b; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
WRITEBACK_Y_AS_ENV(); \
|
WRITEBACK_Y_AS_ENV(); \
|
||||||
ENV_YREG[E_CB] = (CELL) B; \
|
ENV_YREG[E_CB] = (CELL)B; \
|
||||||
ALWAYS_GONext(); \
|
ALWAYS_GONext(); \
|
||||||
}
|
}
|
||||||
#else /* YAPOR_SBA */
|
#else /* YAPOR_SBA */
|
||||||
#define CALL_END_END \
|
#define CALL_END_END \
|
||||||
BLOCK = (CELL)CALL_END_END; \
|
BLOCK = (CELL)CALL_END_END; \
|
||||||
if (!FAILED) { \
|
if (!FAILED) { \
|
||||||
{ \
|
{ \
|
||||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||||
if (ENV_YREG > (CELL *) top_b) { \
|
if (ENV_YREG > (CELL *)top_b) { \
|
||||||
ENV_YREG = (CELL *) top_b; \
|
ENV_YREG = (CELL *)top_b; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
WRITEBACK_Y_AS_ENV(); \
|
WRITEBACK_Y_AS_ENV(); \
|
||||||
ENV_YREG[E_CB] = (CELL) B; \
|
ENV_YREG[E_CB] = (CELL)B; \
|
||||||
ALWAYS_GONext(); \
|
ALWAYS_GONext(); \
|
||||||
}
|
}
|
||||||
#endif /* YAPOR_SBA */
|
#endif /* YAPOR_SBA */
|
||||||
#else /* FROZEN_STACKS */
|
#else /* FROZEN_STACKS */
|
||||||
#define CALL_END_END \
|
#define CALL_END_END \
|
||||||
BLOCK = (CELL)CALL_END_END; \
|
BLOCK = (CELL)CALL_END_END; \
|
||||||
if (!FAILED) { \
|
if (!FAILED) { \
|
||||||
if (ENV_YREG > (CELL *) B) { \
|
if (ENV_YREG > (CELL *)B) { \
|
||||||
ENV_YREG = (CELL *) B; \
|
ENV_YREG = (CELL *)B; \
|
||||||
} \
|
} \
|
||||||
WRITEBACK_Y_AS_ENV(); \
|
WRITEBACK_Y_AS_ENV(); \
|
||||||
ENV_YREG[E_CB] = (CELL) B; \
|
ENV_YREG[E_CB] = (CELL)B; \
|
||||||
ALWAYS_GONext(); \
|
ALWAYS_GONext(); \
|
||||||
}
|
}
|
||||||
#endif /* FROZEN_STACKS */
|
#endif /* FROZEN_STACKS */
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
|
||||||
#define PROCCEED_INSTINIT \
|
#define PROCCEED_INSTINIT \
|
||||||
print_instruction((*_PREG), ON_NATIVE); \
|
print_instruction((*_PREG), ON_NATIVE); \
|
||||||
BLOCKADDRESS = (CELL)(*_PREG); \
|
BLOCKADDRESS = (CELL)(*_PREG); \
|
||||||
CACHE_Y_AS_ENV(YREG); \
|
CACHE_Y_AS_ENV(YREG); \
|
||||||
(*_PREG) = (*_CPREG); \
|
(*_PREG) = (*_CPREG); \
|
||||||
save_pc(); \
|
save_pc(); \
|
||||||
ENV_YREG = ENV;
|
ENV_YREG = ENV;
|
||||||
|
|
||||||
#ifdef DEPTH_LIMIT
|
#ifdef DEPTH_LIMIT
|
||||||
#define PROCCEED_DEPTH \
|
#define PROCCEED_DEPTH DEPTH = ENV_YREG[E_DEPTH];
|
||||||
DEPTH = ENV_YREG[E_DEPTH];
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PROCCEED_END \
|
#define PROCCEED_END \
|
||||||
BLOCK = (CELL)PROCCEED_END; \
|
BLOCK = (CELL)PROCCEED_END; \
|
||||||
WRITEBACK_Y_AS_ENV(); \
|
WRITEBACK_Y_AS_ENV(); \
|
||||||
ENDCACHE_Y_AS_ENV(); \
|
ENDCACHE_Y_AS_ENV(); \
|
||||||
ALWAYS_GONext();
|
ALWAYS_GONext();
|
||||||
|
|
||||||
#define ALLOCATE_INSTINIT \
|
#define ALLOCATE_INSTINIT \
|
||||||
print_instruction((*_PREG), ON_NATIVE); \
|
print_instruction((*_PREG), ON_NATIVE); \
|
||||||
CACHE_Y_AS_ENV(YREG); \
|
CACHE_Y_AS_ENV(YREG); \
|
||||||
(*_PREG) = NEXTOP((*_PREG), e); \
|
(*_PREG) = NEXTOP((*_PREG), e); \
|
||||||
ENV_YREG[E_CP] = (CELL) (*_CPREG); \
|
ENV_YREG[E_CP] = (CELL)(*_CPREG); \
|
||||||
ENV_YREG[E_E] = (CELL) ENV;
|
ENV_YREG[E_E] = (CELL)ENV;
|
||||||
|
|
||||||
#ifdef DEPTH_LIMIT
|
#ifdef DEPTH_LIMIT
|
||||||
#define ALLOCATE_DEPTH \
|
#define ALLOCATE_DEPTH ENV_YREG[E_DEPTH] = DEPTH;
|
||||||
ENV_YREG[E_DEPTH] = DEPTH;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ALLOCATE_END \
|
#define ALLOCATE_END \
|
||||||
ENV = ENV_YREG; \
|
ENV = ENV_YREG; \
|
||||||
ENDCACHE_Y_AS_ENV(); \
|
ENDCACHE_Y_AS_ENV(); \
|
||||||
GONext();
|
GONext();
|
||||||
|
|
||||||
#define DEALLOCATE_INSTINIT \
|
#define DEALLOCATE_INSTINIT print_instruction((*_PREG), ON_NATIVE);
|
||||||
print_instruction((*_PREG), ON_NATIVE); \
|
|
||||||
|
|
||||||
#define DEALLOCATE_POST_CHECK \
|
#define DEALLOCATE_POST_CHECK \
|
||||||
CACHE_Y_AS_ENV(YREG); \
|
CACHE_Y_AS_ENV(YREG); \
|
||||||
(*_PREG) = NEXTOP((*_PREG), p); \
|
(*_PREG) = NEXTOP((*_PREG), p); \
|
||||||
(*_SREG) = YREG; \
|
(*_SREG) = YREG; \
|
||||||
(*_CPREG) = (yamop *) ENV_YREG[E_CP]; \
|
(*_CPREG) = (yamop *)ENV_YREG[E_CP]; \
|
||||||
ENV = ENV_YREG = (CELL *) ENV_YREG[E_E];
|
ENV = ENV_YREG = (CELL *)ENV_YREG[E_E];
|
||||||
|
|
||||||
#ifdef DEPTH_LIMIT
|
#ifdef DEPTH_LIMIT
|
||||||
#define DEALLOCATE_DEPTH \
|
#define DEALLOCATE_DEPTH DEPTH = ENV_YREG[E_DEPTH];
|
||||||
DEPTH = ENV_YREG[E_DEPTH];
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FROZEN_STACKS
|
#ifdef FROZEN_STACKS
|
||||||
#ifdef YAPOR_SBA
|
#ifdef YAPOR_SBA
|
||||||
#define DEALLOCATE_FROZEN \
|
#define DEALLOCATE_FROZEN \
|
||||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||||
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) \
|
if (ENV_YREG > (CELL *)top_b || ENV_YREG < HR) \
|
||||||
ENV_YREG = (CELL *) top_b; \
|
ENV_YREG = (CELL *)top_b; \
|
||||||
else \
|
else \
|
||||||
ENV_YREG = (CELL *)((CELL) ENV_YREG + ENV_Size(CPREG));
|
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size(CPREG));
|
||||||
#else /* YAPOR_SBA */
|
#else /* YAPOR_SBA */
|
||||||
#define DEALLOCATE_FROZEN \
|
#define DEALLOCATE_FROZEN \
|
||||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||||
if (ENV_YREG > (CELL *) top_b) \
|
if (ENV_YREG > (CELL *)top_b) \
|
||||||
ENV_YREG = (CELL *) top_b; \
|
ENV_YREG = (CELL *)top_b; \
|
||||||
else \
|
else \
|
||||||
ENV_YREG = (CELL *)((CELL) ENV_YREG + ENV_Size(CPREG));
|
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size(CPREG));
|
||||||
#endif /* YAPOR_SBA */
|
#endif /* YAPOR_SBA */
|
||||||
#else /* FROZEN_STACKS */
|
#else /* FROZEN_STACKS */
|
||||||
#define DEALLOCATE_FROZEN \
|
#define DEALLOCATE_FROZEN \
|
||||||
if (ENV_YREG > (CELL *) B) \
|
if (ENV_YREG > (CELL *)B) \
|
||||||
ENV_YREG = (CELL *) B; \
|
ENV_YREG = (CELL *)B; \
|
||||||
else \
|
else \
|
||||||
ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size(CPREG));
|
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size(CPREG));
|
||||||
#endif /* FROZEN_STACKS */
|
#endif /* FROZEN_STACKS */
|
||||||
|
|
||||||
#define DEALLOCATE_POST_FROZEN \
|
#define DEALLOCATE_POST_FROZEN WRITEBACK_Y_AS_ENV();
|
||||||
WRITEBACK_Y_AS_ENV();
|
|
||||||
|
|
||||||
#define DEALLOCATE_END \
|
|
||||||
ENDCACHE_Y_AS_ENV(); \
|
|
||||||
GONext();
|
|
||||||
|
|
||||||
|
#define DEALLOCATE_END \
|
||||||
|
ENDCACHE_Y_AS_ENV(); \
|
||||||
|
GONext();
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
# GMP_LIBRARY_DLL - library DLL to install. Only available on WIN32.
|
# GMP_LIBRARY_DLL - library DLL to install. Only available on WIN32.
|
||||||
# GMP_LIBRARIES_DIR - the directory the library we link with is found in.
|
# GMP_LIBRARIES_DIR - the directory the library we link with is found in.
|
||||||
|
|
||||||
|
message( "xxxxx ${ANDROID_ABI} yyyyy ${CMAKE_CURRENT_DIR} zzzzzzzzzz" )
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
set( GMP_ROOT ${CMAKE_SOURCE_DIR}/../gmp/${ANDROID_ABI} )
|
set( GMP_ROOT ${CMAKE_SOURCE_DIR}/../gmp/${ANDROID_ABI} )
|
||||||
set (GMP_FOUND ON)
|
set (GMP_FOUND ON)
|
||||||
@ -26,7 +28,8 @@ if(MSVC)
|
|||||||
${CMAKE_SOURCE_DIR}/../tools/mpird/lib
|
${CMAKE_SOURCE_DIR}/../tools/mpird/lib
|
||||||
${CMAKE_SOURCE_DIR}/../mpir/lib
|
${CMAKE_SOURCE_DIR}/../mpir/lib
|
||||||
${CMAKE_SOURCE_DIR}/../mpird/lib
|
${CMAKE_SOURCE_DIR}/../mpird/lib
|
||||||
$ENV{PROGRAMFILES}/mpir/lib
|
|
||||||
|
$ENV{PROGRAMFILES}/mpir/lib
|
||||||
$ENV{PROGRAMFILES}/mpird/lib
|
$ENV{PROGRAMFILES}/mpird/lib
|
||||||
$ENV{HOME}/mpir/lib
|
$ENV{HOME}/mpir/lib
|
||||||
$ENV{HOME}/mpird/lib
|
$ENV{HOME}/mpird/lib
|
||||||
|
@ -7,7 +7,7 @@ if (POLICY CMP0042)
|
|||||||
cmake_policy( SET CMP0042 NEW)
|
cmake_policy( SET CMP0042 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID_OLD)
|
||||||
macro ( MY_add_custom_target)
|
macro ( MY_add_custom_target)
|
||||||
endmacro()
|
endmacro()
|
||||||
else()
|
else()
|
||||||
@ -17,7 +17,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID_OLD)
|
||||||
macro ( add_component arg1)
|
macro ( add_component arg1)
|
||||||
foreach(item ${ARGN})
|
foreach(item ${ARGN})
|
||||||
get_filename_component(i ${item} ABSOLUTE)
|
get_filename_component(i ${item} ABSOLUTE)
|
||||||
@ -41,7 +41,7 @@ else()
|
|||||||
endmacro()
|
endmacro()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID_OLD)
|
||||||
macro ( MY_add_dependencies)
|
macro ( MY_add_dependencies)
|
||||||
endmacro()
|
endmacro()
|
||||||
else()
|
else()
|
||||||
@ -50,7 +50,7 @@ else()
|
|||||||
endmacro()
|
endmacro()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID_OLD)
|
||||||
macro ( MY_add_library)
|
macro ( MY_add_library)
|
||||||
endmacro()
|
endmacro()
|
||||||
else()
|
else()
|
||||||
@ -68,7 +68,7 @@ else()
|
|||||||
endmacro()
|
endmacro()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID_OLD)
|
||||||
macro ( MY_include)
|
macro ( MY_include)
|
||||||
endmacro()
|
endmacro()
|
||||||
else()
|
else()
|
||||||
@ -86,7 +86,7 @@ else()
|
|||||||
endmacro()
|
endmacro()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID_OLD)
|
||||||
macro ( MY_set_target_properties)
|
macro ( MY_set_target_properties)
|
||||||
endmacro()
|
endmacro()
|
||||||
else()
|
else()
|
||||||
@ -95,7 +95,7 @@ else()
|
|||||||
endmacro()
|
endmacro()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID_OLD)
|
||||||
macro ( MY_target_link_libraries)
|
macro ( MY_target_link_libraries)
|
||||||
endmacro()
|
endmacro()
|
||||||
else()
|
else()
|
||||||
|
@ -1153,9 +1153,10 @@ HTML_STYLESHEET =
|
|||||||
# list). For an example see the documentation.
|
# list). For an example see the documentation.
|
||||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||||
|
|
||||||
HTML_EXTRA_STYLESHEET = @CMAKE_SOURCE_DIR@/docs/custom/customdoxygen.css \
|
HTML_EXTRA_STYLESHEET = \
|
||||||
@CMAKE_SOURCE_DIR@/docs/custom/pygments.css \
|
@CMAKE_SOURCE_DIR@/docs/custom/customdoxygen.css \
|
||||||
@CMAKE_SOURCE_DIR@/docs/solarized-light.css
|
@CMAKE_SOURCE_DIR@/docs/custom/pygments.css \
|
||||||
|
@CMAKE_SOURCE_DIR@/docs/custom/solarized-light.css \
|
||||||
|
|
||||||
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
|
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
|
||||||
# other source files which should be copied to the HTML output directory. Note
|
# other source files which should be copied to the HTML output directory. Note
|
||||||
|
@ -29,7 +29,7 @@ interface.
|
|||||||
+ @ref sicsatts
|
+ @ref sicsatts
|
||||||
+ @ref New_Style_Attribute_Declarations
|
+ @ref New_Style_Attribute_Declarations
|
||||||
+ @ref AttributedVariables_Builtins
|
+ @ref AttributedVariables_Builtins
|
||||||
+ @ref corout
|
+ @ref CohYroutining
|
||||||
|
|
||||||
### SICStus Style attribute declarations. {#SICS_attributes}
|
### SICStus Style attribute declarations. {#SICS_attributes}
|
||||||
|
|
||||||
@ -374,7 +374,6 @@ The argument to `wait/1` is a predicate descriptor or a conjunction
|
|||||||
of these predicates. These predicates will suspend until their first
|
of these predicates. These predicates will suspend until their first
|
||||||
argument is bound.
|
argument is bound.
|
||||||
|
|
||||||
|
|
||||||
The following primitives can be used:
|
The following primitives can be used:
|
||||||
|
|
||||||
- freeze/2
|
- freeze/2
|
||||||
@ -385,6 +384,7 @@ The following primitives can be used:
|
|||||||
|
|
||||||
- frozen/2
|
- frozen/2
|
||||||
|
|
||||||
|
See @ref attscorouts for more details.
|
||||||
|
|
||||||
@}
|
@}
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <encoding.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
dev_t st_dev; /* ID of device containing file */
|
dev_t st_dev; /* ID of device containing file */
|
||||||
mode_t st_mode; /* Mode of file (see below) */
|
mode_t st_mode; /* Mode of file (see below) */
|
||||||
@ -47,6 +49,7 @@ typedef struct {
|
|||||||
#endif
|
#endif
|
||||||
} vfs_stat;
|
} vfs_stat;
|
||||||
|
|
||||||
|
|
||||||
typedef enum vfs_flags {
|
typedef enum vfs_flags {
|
||||||
VFS_CAN_WRITE = 0x1, /// we can write to files in this space
|
VFS_CAN_WRITE = 0x1, /// we can write to files in this space
|
||||||
VFS_CAN_EXEC = 0x2, /// we can execute files in this space
|
VFS_CAN_EXEC = 0x2, /// we can execute files in this space
|
||||||
@ -62,7 +65,7 @@ typedef union {
|
|||||||
size_t sz;
|
size_t sz;
|
||||||
void *pt;
|
void *pt;
|
||||||
uintptr_t scalar;
|
uintptr_t scalar;
|
||||||
#if __ANDROID__
|
#if __ANDROID__0
|
||||||
AAssetManager *mgr;
|
AAssetManager *mgr;
|
||||||
AAsset *asset;
|
AAsset *asset;
|
||||||
#endif
|
#endif
|
||||||
@ -108,6 +111,10 @@ typedef struct vfs {
|
|||||||
|
|
||||||
extern VFS_t *GLOBAL_VFS;
|
extern VFS_t *GLOBAL_VFS;
|
||||||
|
|
||||||
|
extern void init_android_stream(void);
|
||||||
|
|
||||||
|
extern void Yap_InitStdStream(int sno, SMALLUNSGN flags, FILE *file, VFS_t *vfsp);
|
||||||
|
|
||||||
static inline VFS_t *vfs_owner(const char *fname) {
|
static inline VFS_t *vfs_owner(const char *fname) {
|
||||||
VFS_t *me = GLOBAL_VFS;
|
VFS_t *me = GLOBAL_VFS;
|
||||||
int d;
|
int d;
|
||||||
|
12
libYap.cmake
12
libYap.cmake
@ -92,12 +92,12 @@ list(APPEND YAP_SYSTEM_OPTIONS "thread support")
|
|||||||
# we use the nice UTF-8 package
|
# we use the nice UTF-8 package
|
||||||
#available at the Julia project
|
#available at the Julia project
|
||||||
|
|
||||||
MY_ADD_SUBDIRECTORY ( os )
|
ADD_SUBDIRECTORY ( os )
|
||||||
MY_ADD_SUBDIRECTORY ( OPTYap )
|
ADD_SUBDIRECTORY ( OPTYap )
|
||||||
MY_ADD_SUBDIRECTORY ( packages/myddas )
|
ADD_SUBDIRECTORY ( packages/myddas )
|
||||||
MY_ADD_SUBDIRECTORY ( utf8proc )
|
ADD_SUBDIRECTORY ( utf8proc )
|
||||||
MY_ADD_SUBDIRECTORY ( library/dialect/swi/fli )
|
ADD_SUBDIRECTORY ( library/dialect/swi/fli )
|
||||||
MY_ADD_SUBDIRECTORY ( CXX )
|
ADD_SUBDIRECTORY ( CXX )
|
||||||
|
|
||||||
if (READLINE_LIBS)
|
if (READLINE_LIBS)
|
||||||
target_link_libraries(libYap ${READLINE_LIBS} )
|
target_link_libraries(libYap ${READLINE_LIBS} )
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/** @pred db_usage
|
/** @pred db_usage
|
||||||
|
|
||||||
Give general overview of data-base usage in the system.
|
Give general overview of data-base usage in the system.
|
||||||
*/
|
*/
|
||||||
db_usage :-
|
db_usage :-
|
||||||
|
@ -309,7 +309,7 @@ flag_group_chk(FlagGroup):-
|
|||||||
flag_type(Type):-
|
flag_type(Type):-
|
||||||
flags_type_definition(Type, _, _).
|
flags_type_definition(Type, _, _).
|
||||||
|
|
||||||
% flags_type_definition(TypeName, TypeHandler, TypeValidator).
|
%% @pred flags_type_definition(TypeName, TypeHandler, TypeValidator).
|
||||||
flags_type_definition(nonvar, nonvar, true).
|
flags_type_definition(nonvar, nonvar, true).
|
||||||
flags_type_definition(atom, atom, true).
|
flags_type_definition(atom, atom, true).
|
||||||
flags_type_definition(atomic, atomic, true).
|
flags_type_definition(atomic, atomic, true).
|
||||||
@ -586,4 +586,4 @@ defined_flag(FlagName, FlagGroup, FlagType, DefaultValue, Description, Access, H
|
|||||||
nonvar(FlagName), nonvar(FlagGroup),
|
nonvar(FlagName), nonvar(FlagGroup),
|
||||||
'$defined_flag$'(FlagName, FlagGroup, FlagType, DefaultValue, Description, Access, Handler).
|
'$defined_flag$'(FlagName, FlagGroup, FlagType, DefaultValue, Description, Access, Handler).
|
||||||
|
|
||||||
%% @}
|
%% @}
|
||||||
|
@ -147,7 +147,7 @@ open_log(F) :-
|
|||||||
).
|
).
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @pred `<--`( +Tag , :Goal )
|
* @pred +Tag <-- :Goal
|
||||||
*
|
*
|
||||||
* @param [in] output goal _Goal_ before and after being evaluated, but only
|
* @param [in] output goal _Goal_ before and after being evaluated, but only
|
||||||
* taking the first solution. The _Tag_ must be an atom or a string.
|
* taking the first solution. The _Tag_ must be an atom or a string.
|
||||||
|
@ -150,7 +150,7 @@ min(red(Right,_,_,_), Key, Val) :-
|
|||||||
min(black(Right,_,_,_), Key, Val) :-
|
min(black(Right,_,_,_), Key, Val) :-
|
||||||
min(Right,Key,Val).
|
min(Right,Key,Val).
|
||||||
|
|
||||||
%% @pred rb_max(+T, -Key, -Value) is semidet.
|
%% @pred rb_max( +T, -Key, -Value) is semidet.
|
||||||
%
|
%
|
||||||
% Key is the maximal key in T, and is associated with Val.
|
% Key is the maximal key in T, and is associated with Val.
|
||||||
|
|
||||||
@ -612,8 +612,8 @@ pretty_print(black(L,K,_,R),D) :-
|
|||||||
rb_delete(t(Nil,T), K, t(Nil,NT)) :-
|
rb_delete(t(Nil,T), K, t(Nil,NT)) :-
|
||||||
delete(T, K, _, NT, _).
|
delete(T, K, _, NT, _).
|
||||||
|
|
||||||
%% rb_delete(+T, +Key, -TN).
|
%% @pred rb_delete(+T, +Key, -TN).
|
||||||
%% rb_delete(+T, +Key, -Val, -TN).
|
%% @pred rb_delete(+T, +Key, -Val, -TN).
|
||||||
%
|
%
|
||||||
% Delete element with key Key from the tree T, returning the value
|
% Delete element with key Key from the tree T, returning the value
|
||||||
% Val associated with the key and a new tree TN.
|
% Val associated with the key and a new tree TN.
|
||||||
@ -648,7 +648,7 @@ delete(black(L,_,V,R), _, V, OUT, Flag) :-
|
|||||||
% K == K0,
|
% K == K0,
|
||||||
delete_black_node(L,R,OUT,Flag).
|
delete_black_node(L,R,OUT,Flag).
|
||||||
|
|
||||||
%% rb_del_min(+T, -Key, -Val, -TN)
|
%% @pred rb_del_min(+T, -Key, -Val, -TN)
|
||||||
%
|
%
|
||||||
% Delete the least element from the tree T, returning the key Key,
|
% Delete the least element from the tree T, returning the key Key,
|
||||||
% the value Val associated with the key and a new tree TN.
|
% the value Val associated with the key and a new tree TN.
|
||||||
@ -668,7 +668,7 @@ del_min(black(L,K0,V0,R), K, V, Nil, NT, Flag) :-
|
|||||||
fixup_left(Flag0,black(NL,K0,V0,R),NT, Flag).
|
fixup_left(Flag0,black(NL,K0,V0,R),NT, Flag).
|
||||||
|
|
||||||
|
|
||||||
%% rb_del_max(+T, -Key, -Val, -TN)
|
%% @pred rb_del_max( +T, -Key, -Val, -TN)
|
||||||
%
|
%
|
||||||
% Delete the largest element from the tree T, returning the key
|
% Delete the largest element from the tree T, returning the key
|
||||||
% Key, the value Val associated with the key and a new tree TN.
|
% Key, the value Val associated with the key and a new tree TN.
|
||||||
|
@ -33,7 +33,7 @@ static char SccsId[] = "%W% %G%";
|
|||||||
// for native asset manager
|
// for native asset manager
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#if __ANDROID__
|
#if __ANDROID__0
|
||||||
|
|
||||||
|
|
||||||
static AAssetManager * getMgr(struct vfs *me)
|
static AAssetManager * getMgr(struct vfs *me)
|
||||||
@ -212,7 +212,7 @@ VFS_t *
|
|||||||
Yap_InitAssetManager(void)
|
Yap_InitAssetManager(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if __ANDROID__
|
#if __ANDROID__O
|
||||||
VFS_t *me;
|
VFS_t *me;
|
||||||
/* init standard VFS */
|
/* init standard VFS */
|
||||||
me = (VFS_t *)Yap_AllocCodeSpace(sizeof(struct vfs));
|
me = (VFS_t *)Yap_AllocCodeSpace(sizeof(struct vfs));
|
||||||
|
20
os/iopreds.c
20
os/iopreds.c
@ -285,7 +285,7 @@ static void InitFileIO(StreamDesc *s) {
|
|||||||
Yap_DefaultStreamOps(s);
|
Yap_DefaultStreamOps(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InitStdStream(int sno, SMALLUNSGN flags, FILE *file, void *vfsp) {
|
static void InitStdStream(int sno, SMALLUNSGN flags, FILE *file, VFS_t *vfsp) {
|
||||||
StreamDesc *s = &GLOBAL_Stream[sno];
|
StreamDesc *s = &GLOBAL_Stream[sno];
|
||||||
s->file = file;
|
s->file = file;
|
||||||
s->status = flags;
|
s->status = flags;
|
||||||
@ -295,7 +295,15 @@ static void InitStdStream(int sno, SMALLUNSGN flags, FILE *file, void *vfsp) {
|
|||||||
s->vfs = vfsp;
|
s->vfs = vfsp;
|
||||||
s->encoding = ENC_ISO_UTF8;
|
s->encoding = ENC_ISO_UTF8;
|
||||||
INIT_LOCK(s->streamlock);
|
INIT_LOCK(s->streamlock);
|
||||||
|
if (vfsp != NULL) {
|
||||||
|
s->u.private_data = vfsp->open(vfsp->name, (sno == StdInStream ? "read" : "write" ));
|
||||||
|
if (s->u.private_data == NULL) {
|
||||||
|
(PlIOError(EXISTENCE_ERROR_SOURCE_SINK, MkIntTerm(sno), "%s", vfsp->name));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
unix_upd_stream_info(s);
|
unix_upd_stream_info(s);
|
||||||
|
}
|
||||||
/* Getting streams to prompt is a mess because we need for cooperation
|
/* Getting streams to prompt is a mess because we need for cooperation
|
||||||
between readers and writers to the stream :-(
|
between readers and writers to the stream :-(
|
||||||
*/
|
*/
|
||||||
@ -326,6 +334,11 @@ static void InitStdStream(int sno, SMALLUNSGN flags, FILE *file, void *vfsp) {
|
|||||||
#endif /* HAVE_SETBUF */
|
#endif /* HAVE_SETBUF */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Yap_InitStdStream(int sno, SMALLUNSGN flags, FILE *file, VFS_t *vfsp) {
|
||||||
|
InitStdStream(sno, flags, file, vfsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Term Yap_StreamUserName(int sno) {
|
Term Yap_StreamUserName(int sno) {
|
||||||
Term atname;
|
Term atname;
|
||||||
StreamDesc *s = &GLOBAL_Stream[sno];
|
StreamDesc *s = &GLOBAL_Stream[sno];
|
||||||
@ -341,13 +354,13 @@ static void InitStdStreams(void) {
|
|||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
if (LOCAL_sockets_io) {
|
if (LOCAL_sockets_io) {
|
||||||
InitStdStream(StdInStream, Input_Stream_f, NULL, NULL);
|
InitStdStream(StdInStream, Input_Stream_f, NULL, NULL);
|
||||||
InitStdStream(StdOutStream, Output_Stream_f, NULL, NULL);
|
InitStdStream(StdOutStream, Output_Stream_f, NULL, NULL);
|
||||||
InitStdStream(StdErrStream, Output_Stream_f, NULL, NULL);
|
InitStdStream(StdErrStream, Output_Stream_f, NULL, NULL);
|
||||||
} else {
|
} else {
|
||||||
InitStdStream(StdInStream, Input_Stream_f, stdin, NULL);
|
InitStdStream(StdInStream, Input_Stream_f, stdin, NULL);
|
||||||
InitStdStream(StdOutStream, Output_Stream_f, stdout, NULL);
|
InitStdStream(StdOutStream, Output_Stream_f, stdout, NULL);
|
||||||
InitStdStream(StdErrStream, Output_Stream_f, stderr, NULL);
|
InitStdStream(StdErrStream, Output_Stream_f, stderr, NULL);
|
||||||
}
|
}
|
||||||
GLOBAL_Stream[StdInStream].name = Yap_LookupAtom("user_input");
|
GLOBAL_Stream[StdInStream].name = Yap_LookupAtom("user_input");
|
||||||
GLOBAL_Stream[StdOutStream].name = Yap_LookupAtom("user_output");
|
GLOBAL_Stream[StdOutStream].name = Yap_LookupAtom("user_output");
|
||||||
GLOBAL_Stream[StdErrStream].name = Yap_LookupAtom("user_error");
|
GLOBAL_Stream[StdErrStream].name = Yap_LookupAtom("user_error");
|
||||||
@ -1070,6 +1083,7 @@ bool Yap_initStream(int sno, FILE *fd, const char *name, Term file_name,
|
|||||||
st->encoding = encoding;
|
st->encoding = encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
char buf[YAP_FILENAME_MAX + 1];
|
char buf[YAP_FILENAME_MAX + 1];
|
||||||
name = Yap_guessFileName(fd, sno, buf, YAP_FILENAME_MAX);
|
name = Yap_guessFileName(fd, sno, buf, YAP_FILENAME_MAX);
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
static char SccsId[] = "%W% %G%";
|
static char SccsId[] = "%W% %G%";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/** @file readline.c
|
||||||
|
*
|
||||||
|
*
|
||||||
* This file includes the interface to the readline library, if installed in the
|
* This file includes the interface to the readline library, if installed in the
|
||||||
*system.
|
*system.
|
||||||
*
|
*
|
||||||
@ -339,22 +341,22 @@ static bool getLine(int inp) {
|
|||||||
/* window of vulnerability opened */
|
/* window of vulnerability opened */
|
||||||
LOCAL_PrologMode |= ConsoleGetcMode;
|
LOCAL_PrologMode |= ConsoleGetcMode;
|
||||||
if (Yap_DoPrompt(s)) { // no output so far
|
if (Yap_DoPrompt(s)) { // no output so far
|
||||||
|
rl_set_signals();
|
||||||
myrl_line = (unsigned char *)readline(LOCAL_Prompt);
|
myrl_line = (unsigned char *)readline(LOCAL_Prompt);
|
||||||
s->stream_getc = ReadlineGetc;
|
rl_clear_signals();
|
||||||
} else {
|
} else {
|
||||||
|
rl_set_signals();
|
||||||
myrl_line = (unsigned char *)readline(NULL);
|
myrl_line = (unsigned char *)readline(NULL);
|
||||||
|
rl_clear_signals();
|
||||||
}
|
}
|
||||||
/* Do it the gnu way */
|
/* Do it the gnu way */
|
||||||
|
LOCAL_PrologMode &= ~ConsoleGetcMode;
|
||||||
|
if (rl_pending_signal()) {
|
||||||
|
LOCAL_PrologMode |= InterruptMode;
|
||||||
|
}
|
||||||
if (LOCAL_PrologMode & InterruptMode) {
|
if (LOCAL_PrologMode & InterruptMode) {
|
||||||
Yap_external_signal(0, YAP_INT_SIGNAL);
|
Yap_HandleSIGINT();
|
||||||
LOCAL_PrologMode &= ~ConsoleGetcMode;
|
|
||||||
if (LOCAL_PrologMode & AbortMode) {
|
|
||||||
Yap_Error(ABORT_EVENT, TermNil, "");
|
|
||||||
LOCAL_ErrorMessage = "Abort";
|
|
||||||
return console_post_process_eof(s);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
LOCAL_PrologMode &= ~ConsoleGetcMode;
|
|
||||||
LOCAL_newline = true;
|
LOCAL_newline = true;
|
||||||
}
|
}
|
||||||
strncpy(LOCAL_Prompt, RepAtom(LOCAL_AtPrompt)->StrOfAE, MAX_PROMPT);
|
strncpy(LOCAL_Prompt, RepAtom(LOCAL_AtPrompt)->StrOfAE, MAX_PROMPT);
|
||||||
@ -437,7 +439,6 @@ int Yap_ReadlineForSIGINT(void) {
|
|||||||
int ch;
|
int ch;
|
||||||
StreamDesc *s = &GLOBAL_Stream[StdInStream];
|
StreamDesc *s = &GLOBAL_Stream[StdInStream];
|
||||||
const unsigned char *myrl_line = s->u.irl.buf;
|
const unsigned char *myrl_line = s->u.irl.buf;
|
||||||
|
|
||||||
if ((LOCAL_PrologMode & ConsoleGetcMode) && myrl_line != NULL) {
|
if ((LOCAL_PrologMode & ConsoleGetcMode) && myrl_line != NULL) {
|
||||||
ch = myrl_line[0];
|
ch = myrl_line[0];
|
||||||
free((void *)myrl_line);
|
free((void *)myrl_line);
|
||||||
|
6
os/sig.c
6
os/sig.c
@ -317,8 +317,10 @@ static bool set_fpu_exceptions(Term flag) {
|
|||||||
static void ReceiveSignal(int s, void *x, void *y) {
|
static void ReceiveSignal(int s, void *x, void *y) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
LOCAL_PrologMode |= InterruptMode;
|
LOCAL_PrologMode |= InterruptMode;
|
||||||
printf("11ooo\n");
|
if (s == SIGINT && (LOCAL_PrologMode & ConsoleGetcMode)) {
|
||||||
my_signal(s, ReceiveSignal);
|
return;
|
||||||
|
}
|
||||||
|
my_signal(s, ReceiveSignal);
|
||||||
switch (s) {
|
switch (s) {
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
// always direct SIGINT to console
|
// always direct SIGINT to console
|
||||||
|
@ -281,7 +281,7 @@ has_reposition(int sno,
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *Yap_guessFileName(FILE *file, int sno, char *nameb, size_t max) {
|
char *Yap_guessFileName(FILE *file, int sno, char *nameb, size_t max) {
|
||||||
size_t maxs = max(255, max);
|
size_t maxs = Yap_Max(255, max);
|
||||||
if (!nameb) {
|
if (!nameb) {
|
||||||
nameb = malloc(maxs + 1);
|
nameb = malloc(maxs + 1);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
|
|
||||||
static YAP_Term gecode_RM_NONE;
|
static YAP_Term gecode_RM_NONE;
|
||||||
static YAP_Term gecode_RM_CONSTANT;
|
static YAP_Term gecode_RM_CONSTANT;
|
||||||
static YAP_Term gecode_RM_LINEAR;
|
static YAP_Term gecode_RM_LINEAR;
|
||||||
@ -1397,33 +1398,29 @@ static YAP_Bool gecode_constraint_min_313(void)
|
|||||||
|
|
||||||
static YAP_Bool gecode_constraint_when_456(void)
|
static YAP_Bool gecode_constraint_when_456(void)
|
||||||
{
|
{
|
||||||
return YAP_Error("SYSTEN_ERROR", TermNil, "Unsupported"); /*
|
|
||||||
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
||||||
BoolVar X2 = gecode_BoolVar_from_term(space,YAP_ARG2);
|
BoolVar X2 = gecode_BoolVar_from_term(space,YAP_ARG2);
|
||||||
std::function<void(Space&home)> X3 = gecode_std::function<void(Space&home)>_from_term(YAP_ARG3);
|
std::function<void(Space&home)> X3 = gecode_StdFunctionSpace_from_term(YAP_ARG3);
|
||||||
IntPropLevel X4 = gecode_IntPropLevel_from_term(YAP_ARG4);
|
IntPropLevel X4 = gecode_IntPropLevel_from_term(YAP_ARG4);
|
||||||
when(*space,X2,X3,X4);
|
when(*space,X2,X3,X4);
|
||||||
return TRUE; */
|
return TRUE;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static YAP_Bool gecode_constraint_when_457(void)
|
static YAP_Bool gecode_constraint_when_457(void)
|
||||||
{
|
{
|
||||||
return YAP_Error("SYSTEN_ERROR", TermNil, "Unsupported"); /*
|
|
||||||
|
|
||||||
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
||||||
BoolVar X2 = gecode_BoolVar_from_term(space,YAP_ARG2);
|
BoolVar X2 = gecode_BoolVar_from_term(space,YAP_ARG2);
|
||||||
std::function<void(Space&home)> X3 = gecode_std::function<void(Space&home)>_from_term(YAP_ARG3);
|
std::function<void(Space&home)> X3 = gecode_StdFunctionSpace_from_term(YAP_ARG3);
|
||||||
std::function<void(Space&home)> X4 = gecode_std::function<void(Space&home)>_from_term(YAP_ARG4);
|
std::function<void(Space&home)> X4 = gecode_StdFunctionSpace_from_term(YAP_ARG4);
|
||||||
when(*space,X2,X3,X4);
|
when(*space,X2,X3,X4);
|
||||||
return TRUE;*/
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static YAP_Bool gecode_constraint_cardinality_71(void)
|
static YAP_Bool gecode_constraint_cardinality_71(void)
|
||||||
{
|
{
|
||||||
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
||||||
SetVarArgs X2 = gecode_SetVarArgs_from_term(space,YAP_ARG2);
|
SetVarArgs X2 = gecode_SetVarArgs_from_term(space,YAP_ARG2);
|
||||||
int X3 = gecode_int_from_term(YAP_ARG3)289;
|
int X3 = gecode_int_from_term(YAP_ARG3);
|
||||||
int X4 = gecode_int_from_term(YAP_ARG4);
|
int X4 = gecode_int_from_term(YAP_ARG4);
|
||||||
cardinality(*space,X2,X3,X4);
|
cardinality(*space,X2,X3,X4);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -2247,7 +2244,7 @@ static YAP_Bool gecode_constraint_when_455(void)
|
|||||||
{
|
{
|
||||||
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
||||||
BoolVar X2 = gecode_BoolVar_from_term(space,YAP_ARG2);
|
BoolVar X2 = gecode_BoolVar_from_term(space,YAP_ARG2);
|
||||||
std::function<void(Space&home)> X3 = gecode_std::function<void(Space&home)>_from_term(YAP_ARG3);
|
std::function<void(Space&home)> X3 = gecode_StdFunctionSpace_from_term(YAP_ARG3);
|
||||||
when(*space,X2,X3);
|
when(*space,X2,X3);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -2888,11 +2885,10 @@ static YAP_Bool gecode_constraint_channel_74(void)
|
|||||||
|
|
||||||
static YAP_Bool gecode_constraint_when_458(void)
|
static YAP_Bool gecode_constraint_when_458(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
||||||
BoolVar X2 = gecode_BoolVar_from_term(space,YAP_ARG2);
|
BoolVar X2 = gecode_BoolVar_from_term(space,YAP_ARG2);
|
||||||
std::function<void(Space&home)> X3 = gecode_std::function<void(Space&home)>_from_term(YAP_ARG3);
|
std::function<void(Space&home)> X3 = gecode_StdFunctionSpace_from_term(YAP_ARG3);
|
||||||
std::function<void(Space&home)> X4 = gecode_std::function<void(Space&home)>_from_term(YAP_ARG4);
|
std::function<void(Space&home)> X4 = gecode_StdFunctionSpace_from_term(YAP_ARG4);
|
||||||
IntPropLevel X5 = gecode_IntPropLevel_from_term(YAP_ARG5);
|
IntPropLevel X5 = gecode_IntPropLevel_from_term(YAP_ARG5);
|
||||||
when(*space,X2,X3,X4,X5);
|
when(*space,X2,X3,X4,X5);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -3145,7 +3141,7 @@ static YAP_Bool gecode_constraint_binpacking_40(void)
|
|||||||
static YAP_Bool gecode_constraint_branch_1(void)
|
static YAP_Bool gecode_constraint_branch_1(void)
|
||||||
{
|
{
|
||||||
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
||||||
std::function<void(Space&home)> X2 = gecode_std::function<void(Space&home)>_from_term(YAP_ARG2);
|
std::function<void(Space&home)> X2 = gecode_StdFunctionSpace_from_term(YAP_ARG2);
|
||||||
branch(*space,X2);
|
branch(*space,X2);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -5174,3 +5170,4 @@ static YAP_Bool gecode_constraint_ite_254(void)
|
|||||||
ite(*space,X2,X3,X4,X5,X6);
|
ite(*space,X2,X3,X4,X5,X6);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,7 +554,11 @@ class YAPEnumImpl(object):
|
|||||||
print
|
print
|
||||||
|
|
||||||
def _generate_from_term(self):
|
def _generate_from_term(self):
|
||||||
print "static %s gecode_%s_from_term(YAP_Term X)" % (self.TYPE,self.TYPE)
|
if self.TYPE == "std::function<void(Space&home)>":
|
||||||
|
t2 = "StdFunctionSpace"
|
||||||
|
else:
|
||||||
|
t2 = self.TYPE
|
||||||
|
print "static %s gecode_%s_from_term(YAP_Term X)" % (self.TYPE,t2)
|
||||||
print "{"
|
print "{"
|
||||||
for x in self.ENUM:
|
for x in self.ENUM:
|
||||||
print " if (X==gecode_%s) return %s;" % (x,x)
|
print " if (X==gecode_%s) return %s;" % (x,x)
|
||||||
@ -563,11 +567,16 @@ class YAPEnumImpl(object):
|
|||||||
print
|
print
|
||||||
|
|
||||||
def _generate_from_term_forward_decl(self):
|
def _generate_from_term_forward_decl(self):
|
||||||
print "static %s gecode_%s_from_term(YAP_Term);" % (self.TYPE,self.TYPE)
|
if self.TYPE == "std::function<void(Space&home)>":
|
||||||
|
t2 = "StdFunctionSpace"
|
||||||
|
else:
|
||||||
|
t2 = self.TYPE
|
||||||
|
print "static %s gecode_%s_from_term(YAP_Term);" % (self.TYPE,t2)
|
||||||
|
|
||||||
class YAPEnumImplGenerator(object):
|
class YAPEnumImplGenerator(object):
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
|
generate_space_function();
|
||||||
for c in enum_classes():
|
for c in enum_classes():
|
||||||
class C(c,YAPEnumImpl): pass
|
class C(c,YAPEnumImpl): pass
|
||||||
o = C()
|
o = C()
|
||||||
@ -576,6 +585,7 @@ class YAPEnumImplGenerator(object):
|
|||||||
class YAPEnumForwardGenerator(object):
|
class YAPEnumForwardGenerator(object):
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
|
generate_space_function_forward();
|
||||||
for c in enum_classes():
|
for c in enum_classes():
|
||||||
class C(c,YAPEnumImpl): pass
|
class C(c,YAPEnumImpl): pass
|
||||||
o = C()
|
o = C()
|
||||||
@ -642,12 +652,16 @@ class CCDescriptor(object):
|
|||||||
has_space = True
|
has_space = True
|
||||||
else:
|
else:
|
||||||
extra = ""
|
extra = ""
|
||||||
|
t2 = t
|
||||||
if t in ("IntVar","BoolVar","SetVar","FloatVar","IntVarArgs","BoolVarArgs","SetVarArgs","FloatVarArgs"):
|
if t in ("IntVar","BoolVar","SetVar","FloatVar","IntVarArgs","BoolVarArgs","SetVarArgs","FloatVarArgs"):
|
||||||
extra = "space,"
|
extra = "space,"
|
||||||
if has_space == False:
|
if has_space == False:
|
||||||
print " GenericSpace* space = gecode_Space_from_term(%s);" % a
|
print " GenericSpace* space = gecode_Space_from_term(%s);" % a
|
||||||
has_space = True
|
has_space = True
|
||||||
print " %s %s = gecode_%s_from_term(%s%s);" % (t,v,t,extra,a)
|
else:
|
||||||
|
if t == "std::function<void(Space&home)>":
|
||||||
|
t2 = "StdFunctionSpace"
|
||||||
|
print " %s %s = gecode_%s_from_term(%s%s);" % (t,v,t2,extra,a)
|
||||||
args.append(v)
|
args.append(v)
|
||||||
i += 1
|
i += 1
|
||||||
print " %s(%s);" % (self.name, ",".join(args))
|
print " %s(%s);" % (self.name, ",".join(args))
|
||||||
|
@ -186,6 +186,18 @@ static inline BoolAssign&
|
|||||||
return *(DFA *) YAP_OpaqueObjectFromTerm(t);
|
return *(DFA *) YAP_OpaqueObjectFromTerm(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline Rnd&
|
||||||
|
gecode_Rnd_from_term(YAP_Term t)
|
||||||
|
{
|
||||||
|
return *(Rnd *) YAP_OpaqueObjectFromTerm(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline std::function<void(Space&home)>&
|
||||||
|
gecode_StdFunctionSpace_from_term(YAP_Term t)
|
||||||
|
{
|
||||||
|
return *(std::function<void(Space&home)> *) YAP_OpaqueObjectFromTerm(t);
|
||||||
|
}
|
||||||
|
|
||||||
static inline FloatNum
|
static inline FloatNum
|
||||||
gecode_FloatNum_from_term(YAP_Term t)
|
gecode_FloatNum_from_term(YAP_Term t)
|
||||||
{
|
{
|
||||||
@ -379,6 +391,7 @@ static YAP_Term gecode_BOOL_VAR_RND;
|
|||||||
static YAP_Term gecode_FLOAT_VAR_SIZE_MIN;
|
static YAP_Term gecode_FLOAT_VAR_SIZE_MIN;
|
||||||
static YAP_Term gecode_FLOAT_VAR_SIZE_MAX;
|
static YAP_Term gecode_FLOAT_VAR_SIZE_MAX;
|
||||||
static YAP_Term gecode_FLOAT_VAR_DEGREE_SIZE_MAX;
|
static YAP_Term gecode_FLOAT_VAR_DEGREE_SIZE_MAX;
|
||||||
|
static YAP_Term gecode_FLOAT_VAR_DEGREE_SIZE_MIN;
|
||||||
|
|
||||||
static inline FloatVarBranch
|
static inline FloatVarBranch
|
||||||
gecode_FloatVarBranch_from_term(YAP_Term t)
|
gecode_FloatVarBranch_from_term(YAP_Term t)
|
||||||
@ -386,7 +399,6 @@ static YAP_Term gecode_BOOL_VAR_RND;
|
|||||||
if (YAP_IsAtomTerm(t)) {
|
if (YAP_IsAtomTerm(t)) {
|
||||||
if ( t == gecode_FLOAT_VAR_SIZE_MIN)
|
if ( t == gecode_FLOAT_VAR_SIZE_MIN)
|
||||||
return FLOAT_VAR_SIZE_MIN();
|
return FLOAT_VAR_SIZE_MIN();
|
||||||
static YAP_Term gecode_FLOAT_VAR_DEGREE_SIZE_MIN;
|
|
||||||
if ( t == gecode_FLOAT_VAR_SIZE_MAX)
|
if ( t == gecode_FLOAT_VAR_SIZE_MAX)
|
||||||
return FLOAT_VAR_SIZE_MAX();
|
return FLOAT_VAR_SIZE_MAX();
|
||||||
if ( t == gecode_FLOAT_VAR_NONE)
|
if ( t == gecode_FLOAT_VAR_NONE)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
The MYDDAS Data-base interface {#myddas}
|
|
||||||
===============================
|
## The MYDDAS Data-base interface {#myddas}
|
||||||
|
|
||||||
The MYDDAS database project was developed within a FCT project aiming at
|
The MYDDAS database project was developed within a FCT project aiming at
|
||||||
the development of a highly efficient deductive database system, based
|
the development of a highly efficient deductive database system, based
|
||||||
@ -63,8 +63,8 @@ The MYDDAS Data-base interface {#myddas}
|
|||||||
Prolog cut operator, which has exactly the same behaviour from
|
Prolog cut operator, which has exactly the same behaviour from
|
||||||
predicates defined in the Prolog program source code, or from predicates
|
predicates defined in the Prolog program source code, or from predicates
|
||||||
defined in database as relations.
|
defined in database as relations.
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Name = 'John Doe',
|
Name = 'John Doe',
|
||||||
Number = 123456789 ?
|
Number = 123456789 ?
|
||||||
yes
|
yes
|
||||||
@ -92,9 +92,6 @@ The MYDDAS Data-base interface {#myddas}
|
|||||||
|
|
||||||
|
|
||||||
@pred db view(+,+,+).
|
@pred db view(+,+,+).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pred db view(+,+).
|
@pred db view(+,+).
|
||||||
|
|
||||||
|
|
||||||
@ -186,9 +183,6 @@ The MYDDAS Data-base interface {#myddas}
|
|||||||
|
|
||||||
|
|
||||||
@pred db_sql(+,+,?).
|
@pred db_sql(+,+,?).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pred db_sql(+,?).
|
@pred db_sql(+,?).
|
||||||
|
|
||||||
|
|
||||||
@ -284,15 +278,7 @@ The MYDDAS Data-base interface {#myddas}
|
|||||||
|
|
||||||
|
|
||||||
@pred db_get_attributes_types(+,+,?).
|
@pred db_get_attributes_types(+,+,?).
|
||||||
|
otype for this predicate is the following:
|
||||||
|
|
||||||
|
|
||||||
@pred db_get_attributes_types(+,?).
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
The prototype for this predicate is the following:
|
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
?- db_get_attributes_types(Conn,RelationName,ListOfFields).
|
?- db_get_attributes_types(Conn,RelationName,ListOfFields).
|
||||||
@ -552,9 +538,6 @@ The MYDDAS Data-base interface {#myddas}
|
|||||||
this by doing again `db_my_result_set(store_result)`.
|
this by doing again `db_my_result_set(store_result)`.
|
||||||
|
|
||||||
@pred db_my_sql_mode(+Conn,?SQL_Mode).
|
@pred db_my_sql_mode(+Conn,?SQL_Mode).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pred db_my_sql_mode(?SQL_Mode).
|
@pred db_my_sql_mode(?SQL_Mode).
|
||||||
|
|
||||||
|
|
||||||
@ -570,4 +553,4 @@ The MYDDAS Data-base interface {#myddas}
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
You can see the available SQL Modes at the MySQL homepage at
|
You can see the available SQL Modes at the MySQL homepage at
|
||||||
<http://www.mysql.org>.
|
<http://www.mysql.org>.
|
||||||
b
|
|
@ -685,7 +685,7 @@ void init_myddas(void) {
|
|||||||
#if defined MYDDAS_ODBC
|
#if defined MYDDAS_ODBC
|
||||||
Yap_InitBackMYDDAS_ODBCPreds();
|
Yap_InitBackMYDDAS_ODBCPreds();
|
||||||
#endif
|
#endif
|
||||||
#if defined MYDDAS_SQLITE3
|
#if WIN32
|
||||||
Yap_InitBackMYDDAS_SQLITE3Preds();
|
Yap_InitBackMYDDAS_SQLITE3Preds();
|
||||||
#endif
|
#endif
|
||||||
#if defined USE_MYDDAS
|
#if defined USE_MYDDAS
|
||||||
@ -697,7 +697,7 @@ void init_myddas(void) {
|
|||||||
#if defined MYDDAS_ODBC
|
#if defined MYDDAS_ODBC
|
||||||
Yap_InitMYDDAS_ODBCPreds();
|
Yap_InitMYDDAS_ODBCPreds();
|
||||||
#endif
|
#endif
|
||||||
#if defined MYDDAS_SQLITE3
|
#if WIN32
|
||||||
Yap_InitMYDDAS_SQLITE3Preds();
|
Yap_InitMYDDAS_SQLITE3Preds();
|
||||||
#endif
|
#endif
|
||||||
#if defined USE_MYDDAS
|
#if defined USE_MYDDAS
|
||||||
|
@ -39,11 +39,17 @@ function(cpp_compile output filename)
|
|||||||
set_source_files_properties(${outfile} PROPERTIES GENERATED TRUE)
|
set_source_files_properties(${outfile} PROPERTIES GENERATED TRUE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
if (ANDROID)
|
||||||
|
set (MYDDAS_PL_OUTDIR ${YAP_APP_DIR}/src/generated/assets/Yap} )
|
||||||
|
else()
|
||||||
|
set (MYDDAS_PL_OUTDIR ${CMAKE_CURRENT_BINARY_DIR} )
|
||||||
|
endif()
|
||||||
|
|
||||||
function(cpp_driver output dbms filename)
|
function(cpp_driver output dbms filename)
|
||||||
if (0)
|
if (0)
|
||||||
set(outfile ${libpl}/myddas_${dbms}.yap)
|
set(outfile ${MYDDAS_PL_OUTDIR}/myddas_${dbms}.yap)
|
||||||
else()
|
else()
|
||||||
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/myddas_${dbms}.yap)
|
set(outfile ${MYDDAS_PL_OUTDIR}/myddas_${dbms}.yap)
|
||||||
endif()
|
endif()
|
||||||
set(${output} ${${output}} ${outfile} PARENT_SCOPE)
|
set(${output} ${${output}} ${outfile} PARENT_SCOPE)
|
||||||
IF (MSVC)
|
IF (MSVC)
|
||||||
@ -74,3 +80,4 @@ add_custom_target(plmyddas ALL DEPENDS ${MYDDAS_YAP} )
|
|||||||
install(FILES ${MYDDAS_YAP}
|
install(FILES ${MYDDAS_YAP}
|
||||||
DESTINATION ${libpl}
|
DESTINATION ${libpl}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,14 +40,14 @@ src/Android/jni/sqlite/android_database_SQLiteConnection.cpp
|
|||||||
src/Android/jni/sqlite/android_database_SQLiteDebug.cpp
|
src/Android/jni/sqlite/android_database_SQLiteDebug.cpp
|
||||||
src/Android/jni/sqlite/android_database_SQLiteGlobal.cpp
|
src/Android/jni/sqlite/android_database_SQLiteGlobal.cpp
|
||||||
src/Android/jni/sqlite/nativehelper/jni.h
|
src/Android/jni/sqlite/nativehelper/jni.h
|
||||||
src/Android/jni/sqlite/nativehelper/jniConstants.h
|
src/Android/jni/sqlite/nativehelper/JniConstants.h
|
||||||
src/Android/jni/sqlite/nativehelper/JNIHelp.h
|
src/Android/jni/sqlite/nativehelper/JNIHelp.h
|
||||||
src/Android/jni/sqlite/nativehelper/ScopedLocalRef.h
|
src/Android/jni/sqlite/nativehelper/ScopedLocalRef.h
|
||||||
)
|
)
|
||||||
|
|
||||||
endif (ANDROID)
|
endif (ANDROID)
|
||||||
|
|
||||||
add_component( Yapsqlite3
|
add_library( Yapsqlite3 SHARED
|
||||||
${YAPSQLITE3_SOURCES} )
|
${YAPSQLITE3_SOURCES} )
|
||||||
|
|
||||||
MY_set_target_properties(Yapsqlite3
|
MY_set_target_properties(Yapsqlite3
|
||||||
@ -56,3 +56,9 @@ add_component( Yapsqlite3
|
|||||||
# SOVERSION ${LIBYAPTAI_MAJOR_VERSION}.${LIBYAPTAI_MINOR_VERSION}
|
# SOVERSION ${LIBYAPTAI_MAJOR_VERSION}.${LIBYAPTAI_MINOR_VERSION}
|
||||||
POSITION_INDEPENDENT_CODE TRUE
|
POSITION_INDEPENDENT_CODE TRUE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if (ANDROID)
|
||||||
|
target_link_libraries(Yapsqlite3 android log)
|
||||||
|
|
||||||
|
endif ()
|
@ -658,6 +658,17 @@ void init_sqlite3( void )
|
|||||||
Yap_InitBackMYDDAS_SQLITE3Preds();
|
Yap_InitBackMYDDAS_SQLITE3Preds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if _ANDROID_
|
||||||
|
JNIEXPORT void JNICALL
|
||||||
|
lib_yap_up_pt_init_sqlite(JNIEnv *env);
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL
|
||||||
|
lib_yap_up_pt_init_sqlite(JNIEnv *env)
|
||||||
|
{
|
||||||
|
init_sqlite3();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
@ -360,23 +360,22 @@ static jlong nativePrepareStatement(JNIEnv *env, jclass clazz,
|
|||||||
int err = sqlite3_prepare16_v2(connection->db, sql, sqlLength * sizeof(jchar),
|
int err = sqlite3_prepare16_v2(connection->db, sql, sqlLength * sizeof(jchar),
|
||||||
&statement, NULL);
|
&statement, NULL);
|
||||||
env->ReleaseStringCritical(sqlString, sql);
|
env->ReleaseStringCritical(sqlString, sql);
|
||||||
|
#if 0
|
||||||
if (err != SQLITE_OK) {
|
if (err != SQLITE_OK) {
|
||||||
// Error messages like 'near ")": syntax error' are not
|
// Error messages like 'near ")": syntax error' are not
|
||||||
// always helpful enough, so construct an error string that
|
// always helpful enough, so construct an error string that
|
||||||
// includes the query itself.
|
// includes the query itself.
|
||||||
const char *query = env->GetStringUTFChars(sqlString, NULL);
|
const char *query = env->GetStringUTFChars(sqlString, NULL);
|
||||||
char *message = (char *)malloc(strlen(query) + 50);
|
char *message[512];
|
||||||
if (message) {
|
if (message) {
|
||||||
strcpy(message, ", while compiling: "); // less than 50 chars
|
strcpy(message, ", while compiling: "); // less than 50 chars
|
||||||
strcat(message, query);
|
strcat(message, query);
|
||||||
}
|
}
|
||||||
env->ReleaseStringUTFChars(sqlString, query);
|
env->ReleaseStringUTFChars(sqlString, query);
|
||||||
throw_sqlite3_exception(env, connection->db, message);
|
throw_sqlite3_exception(env, connection->db, message);
|
||||||
free(message);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
ALOGV("Prepared statement %p on connection %p", statement, connection->db);
|
ALOGV("Prepared statement %p on connection %p", statement, connection->db);
|
||||||
return reinterpret_cast<jlong>(statement);
|
return reinterpret_cast<jlong>(statement);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@ add_library (YAPPython SHARED pyload.c ${PYTHON_HEADERS} )
|
|||||||
if (WIN32)
|
if (WIN32)
|
||||||
add_library (Py4YAP OBJECT ${PYTHON_SOURCES} ${PYTHON_HEADERS})
|
add_library (Py4YAP OBJECT ${PYTHON_SOURCES} ${PYTHON_HEADERS})
|
||||||
|
|
||||||
|
target_link_libraries(YAPPython libYap ${PYTHON_LIBRARIES})
|
||||||
|
|
||||||
else()
|
else()
|
||||||
add_library (Py4YAP SHARED ${PYTHON_SOURCES} ${PYTHON_HEADERS})
|
add_library (Py4YAP SHARED ${PYTHON_SOURCES} ${PYTHON_HEADERS})
|
||||||
|
|
||||||
@ -21,7 +23,6 @@ add_library (Py4YAP SHARED ${PYTHON_SOURCES} ${PYTHON_HEADERS})
|
|||||||
set_property(TARGET Py4YAP PROPERTY CXX_STANDARD_REQUIRED ON)
|
set_property(TARGET Py4YAP PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
target_link_libraries(Py4YAP libYap ${PYTHON_LIBRARIES})
|
target_link_libraries(Py4YAP libYap ${PYTHON_LIBRARIES})
|
||||||
target_link_libraries(YAPPython Py4YAP)
|
|
||||||
|
|
||||||
MY_install(TARGETS Py4YAP
|
MY_install(TARGETS Py4YAP
|
||||||
LIBRARY DESTINATION ${libdir}
|
LIBRARY DESTINATION ${libdir}
|
||||||
@ -33,7 +34,6 @@ endif()
|
|||||||
# arithmetic hassle.
|
# arithmetic hassle.
|
||||||
set_property(TARGET YAPPython PROPERTY CXX_STANDARD_REQUIRED ON)
|
set_property(TARGET YAPPython PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
target_link_libraries(YAPPython libYap ${PYTHON_LIBRARIES})
|
|
||||||
|
|
||||||
set_property( SOURCE ${PYTHON_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 _GNU_SOURCE=1)
|
set_property( SOURCE ${PYTHON_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 _GNU_SOURCE=1)
|
||||||
|
|
||||||
|
@ -122,8 +122,8 @@ if (WITH_DOCS AND DOXYGEN_FOUND)
|
|||||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/doc
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/doc
|
||||||
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile.xml
|
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile.xml
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
DEPENDS ${c_headers};${c_sources};${cpp_sources};${cpp_headers}
|
DEPENDS ${c_headers};${c_sources};${cpp_sources};${cpp_headers}
|
||||||
)
|
)
|
||||||
|
|
||||||
# generate .i from doxygen .xml
|
# generate .i from doxygen .xml
|
||||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ftdi1_doc.i
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ftdi1_doc.i
|
||||||
|
@ -20,6 +20,7 @@ else:
|
|||||||
dll = glob.glob(os.path.join(yap_lib_path,dll))[0]
|
dll = glob.glob(os.path.join(yap_lib_path,dll))[0]
|
||||||
dll = os.path.abspath(dll)
|
dll = os.path.abspath(dll)
|
||||||
ctypes.CDLL(dll, mode=ctypes.RTLD_GLOBAL)
|
ctypes.CDLL(dll, mode=ctypes.RTLD_GLOBAL)
|
||||||
load('libYap*')
|
if platform.system() == 'Apple'::
|
||||||
load('libYAP+*')
|
load('libYap*')
|
||||||
load('libPy4YAP*')
|
load('libYAP+*')
|
||||||
|
load('libPy4YAP*')
|
||||||
|
@ -68,6 +68,8 @@ cplus = ['']
|
|||||||
bpy2yap = []
|
bpy2yap = []
|
||||||
native_sources = ['yap_wrap.cpp']
|
native_sources = ['yap_wrap.cpp']
|
||||||
here = path.abspath(path.dirname(__file__))
|
here = path.abspath(path.dirname(__file__))
|
||||||
|
gmp_dir = path.abspath(path.dirname("${GMP_LIBRARIES}"))
|
||||||
|
python_libdir = path.abspath(path.dirname("${PYTHON_LIBRARIES}"))
|
||||||
|
|
||||||
# Get the long description from the README file
|
# Get the long description from the README file
|
||||||
|
|
||||||
@ -79,14 +81,14 @@ extensions = [Extension('_yap', native_sources,
|
|||||||
('_YAP_NOT_INSTALLED_', '1'),
|
('_YAP_NOT_INSTALLED_', '1'),
|
||||||
('YAP_PYTHON', '1'),
|
('YAP_PYTHON', '1'),
|
||||||
('_GNU_SOURCE', '1')],
|
('_GNU_SOURCE', '1')],
|
||||||
runtime_library_dirs=['yap4py', '${libdir}', '${bindir}'],
|
runtime_library_dirs=['yap4py', '${libdir}', '${bindir}', '${gmp_dir}', '${python_libdir}'],
|
||||||
swig_opts=['-modern', '-c++', '-py3',
|
swig_opts=['-modern', '-c++', '-py3',
|
||||||
'-DX_API', '-I${CMAKE_SOURCE_DIR}/CXX', '-I${CMAKE_SOURCE_DIR}/include',
|
'-DX_API', '-I${CMAKE_SOURCE_DIR}/CXX', '-I${CMAKE_SOURCE_DIR}/include',
|
||||||
'-I${CMAKE_SOURCE_DIR}/H', '-I${CMAKE_SOURCE_DIR}/H/generated',
|
'-I${CMAKE_SOURCE_DIR}/H', '-I${CMAKE_SOURCE_DIR}/H/generated',
|
||||||
'-I${CMAKE_SOURCE_DIR}/os', '-I${CMAKE_SOURCE_DIR}/OPTYap', '-I../../..'],
|
'-I${CMAKE_SOURCE_DIR}/os', '-I${CMAKE_SOURCE_DIR}/OPTYap', '-I../../..'],
|
||||||
library_dirs=['../../..', '../../../CXX', '..', "${dlls}", "${bindir}", 'c:/Anaconda3'],
|
library_dirs=['../../..', '../../../CXX', '..', "${dlls}", "${bindir}", 'c:/Anaconda3'],
|
||||||
extra_link_args=my_extra_link_args,
|
extra_link_args=my_extra_link_args,
|
||||||
libraries=['Yap','YAPPython','python3','yap']+win_libs+local_libs,
|
libraries=['Yap','gmp']+win_libs+local_libs,
|
||||||
include_dirs=['../../..',
|
include_dirs=['../../..',
|
||||||
'${GMP_INCLUDE_DIRS}',
|
'${GMP_INCLUDE_DIRS}',
|
||||||
'${CMAKE_SOURCE_DIR}/H',
|
'${CMAKE_SOURCE_DIR}/H',
|
||||||
|
@ -8,12 +8,14 @@
|
|||||||
|
|
||||||
# This is a CMake example for Python and Java
|
# This is a CMake example for Python and Java
|
||||||
|
|
||||||
|
set (SOURCES yap.i)
|
||||||
|
|
||||||
INCLUDE(${SWIG_USE_FILE})
|
INCLUDE(${SWIG_USE_FILE})
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
add_subdirectory(android)
|
add_subdirectory(android)
|
||||||
else(ANDROID)
|
else(ANDROID)
|
||||||
# add_subdirectory(java)
|
add_subdirectory(java)
|
||||||
endif(ANDROID)
|
endif(ANDROID)
|
||||||
|
|
||||||
set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS SWIGYAP=1)
|
set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS SWIGYAP=1)
|
||||||
|
@ -1,21 +1,72 @@
|
|||||||
|
|
||||||
# This is a CMake example for Python and Java
|
# This is a CMake file for SWIG and Android
|
||||||
|
|
||||||
|
FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/java/pt/up/yap/lib )
|
||||||
|
FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/assets)
|
||||||
|
set(CMAKE_SWIG_OUTDIR ${YAP_APP_DIR}/src/generated/java/pt/up/yap/lib )
|
||||||
|
set( SWIG_MODULE_NAME pt.up.yap.lib )
|
||||||
|
set ( pllib ${YAP_APP_DIR}/src/generated/assets/Yap )
|
||||||
|
|
||||||
set(CMAKE_SWIG_OUTDIR ${YAP_APP_DIR}/app/src/main/java/pt/up/yap/lib )
|
set ( SWIG_SOURCES ${CMAKE_SOURCE_DIR}/packages/swig/yap.i )
|
||||||
|
|
||||||
set ( SWIG_SOURCES ../yap.i )
|
|
||||||
SET_SOURCE_FILES_PROPERTIES(${SWIG_SOURCES} PROPERTIES CPLUSPLUS ON)
|
SET_SOURCE_FILES_PROPERTIES(${SWIG_SOURCES} PROPERTIES CPLUSPLUS ON)
|
||||||
|
|
||||||
include_directories (
|
include_directories (
|
||||||
${CMAKE_SOURCE_DIR}/CXX
|
${CMAKE_SOURCE_DIR}/CXX
|
||||||
)
|
)
|
||||||
|
set( GMP_ROOT ${CMAKE_SOURCE_DIR}/../gmp/${ANDROID_ABI} )
|
||||||
|
set (GMP_INCLUDE_DIRS ${GMP_ROOT})
|
||||||
|
set (GMP_LIBRARIES ${GMP_ROOT}/libgmp.so)
|
||||||
|
|
||||||
|
|
||||||
add_custom_command (OUTPUT yap_swig.cpp
|
add_custom_command (OUTPUT yap_swig.cpp
|
||||||
COMMAND ${SWIG} -java -outdir ${CMAKE_SWIG_OUTDIR} -outcurrentdir -addextern -I${CMAKE_SOURCE_DIR}/CXX ${SWIG_SOURCES} -o yap_swig.cpp
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}
|
||||||
)
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}/pl
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}/os
|
||||||
|
|
||||||
add_custom_target ( swig ALL
|
COMMAND ${CMAKE_COMMAND} -E copy ${pl_library} ${pllib}
|
||||||
DEPENDS yap_swig.cpp
|
COMMAND ${CMAKE_COMMAND} -E copy ${pl_boot_library} ${pllib}/pl
|
||||||
)
|
COMMAND ${CMAKE_COMMAND} -E copy ${pl_os_library} ${pllib}/os
|
||||||
|
COMMAND ${SWIG_EXECUTABLE} -c++ -java -package ${SWIG_MODULE_NAME} -outdir ${CMAKE_SWIG_OUTDIR} -outcurrentdir -addextern -I${CMAKE_SOURCE_DIR}/CXX -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/H -I${CMAKE_SOURCE_DIR}/os -I${CMAKE_SOURCE_DIR}/OPTYap -I${CMAKE_BINARY_DIR} -I${GMP_INCLUDE_DIRS} -DX_API="" -o yap_swig.cpp ${SWIG_SOURCES}
|
||||||
|
DEPENDS ${SWIG_SOURCES} YAP++
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_command (OUTPUT swig_streamer.cpp
|
||||||
|
COMMAND ${SWIG_EXECUTABLE} -c++ -java -package ${SWIG_MODULE_NAME} -outdir ${CMAKE_SWIG_OUTDIR} -outcurrentdir -addextern -I${CMAKE_CURRENT_SOURCE_DIR} -o swig_streamer.cpp streamer.i
|
||||||
|
DEPENDS streamer.i
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# GMP_FOUND - true if GMP/MPIR was found
|
||||||
|
# GMP_INCLUDE_DIRS - include search path
|
||||||
|
# GMP_LIBRARIES - libraries to link with
|
||||||
|
#config.h needs this (TODO: change in code latter)
|
||||||
|
include_directories( .;${GMP_INCLUDE_DIRS};${CMAKE_SOURCE_DIR}/include;${CMAKE_SOURCE_DIR}/H;${CMAKE_SOURCE_DIR}/H/generated;${CMAKE_SOURCE_DIR}/os;${CMAKE_SOURCE_DIR}/OPTYap;${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR} )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
add_library (YAPJava SHARED
|
||||||
|
yap_swig.cpp swig_streamer.cpp streamer.cpp streamer.h
|
||||||
|
)
|
||||||
|
target_link_libraries(YAPJava ${GMP_LIBRARIES} )
|
||||||
|
|
||||||
|
|
||||||
|
target_link_libraries( YAPJava YAP++ libYap android log)
|
||||||
|
|
||||||
|
if (FALSE)
|
||||||
|
|
||||||
|
set (SWIG_ADD_MODULE YAPJava SHARED CPLUPLUS ${SWIG_SOURCES} )
|
||||||
|
# Define swig module with given name and specified language
|
||||||
|
|
||||||
|
|
||||||
|
set (SWIG_LINK_LIBRARIES YAPJava YAP++ libYAP )
|
||||||
|
#- Link libraries to swig module
|
||||||
|
|
||||||
|
|
||||||
|
add_library (YAPJavaTop SHARED
|
||||||
|
main.cpp main.h
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries( YAPJavaTop ${SWIG_MODULE_${YAPJava}_REAL_NAME} YAP++ libYap android)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
@ -92,7 +92,10 @@ class JavaYAP {
|
|||||||
|
|
||||||
public static void main(String args[])
|
public static void main(String args[])
|
||||||
{
|
{
|
||||||
System.loadLibrary("Native");
|
System.loadLibrary("gmp");
|
||||||
|
System.loadLibrary("Yap");
|
||||||
|
System.loadLibrary("YAP++");
|
||||||
|
System.loadLibrary("JAVAYap");
|
||||||
|
|
||||||
JavaYAP y = new JavaYAP();
|
JavaYAP y = new JavaYAP();
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
// supports Java and Python
|
||||||
|
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <gmpxx.h>
|
#include <gmpxx.h>
|
||||||
|
|
||||||
extern "C"{
|
extern "C"{
|
||||||
#ifdef SWIGPYTHON
|
#ifdef SWIGPYTHON
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
@ -22,11 +23,7 @@
|
|||||||
%include std_string.i
|
%include std_string.i
|
||||||
%include std_vector.i
|
%include std_vector.i
|
||||||
|
|
||||||
namespace std {
|
|
||||||
%template(vectort) vector<Term>;
|
|
||||||
};
|
|
||||||
|
|
||||||
%feature("novaluewrapper") std::vector<Term>;
|
|
||||||
|
|
||||||
%ignore *::operator[];
|
%ignore *::operator[];
|
||||||
|
|
||||||
@ -255,148 +252,87 @@ case DOMAIN_ERROR_NOT_LESS_THAN_ZERO:
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// Language independent exception handler
|
%typemap(in) arity_t { (jlong)($input); }
|
||||||
%include exception.i
|
|
||||||
|
|
||||||
%exception {
|
%typecheck(2) Int { $1 = PyLong_Check($input); }
|
||||||
try {
|
%typecheck(3) double { $1 = PyFloat_Check($input); }
|
||||||
$action
|
%typecheck(2) const char * { $1 = PyUnicode_Check($input); }
|
||||||
} catch (YAPError e) {
|
|
||||||
yap_error_number en = e.getID();
|
%typecheck(1) Term { $1 = !PyUnicode_Check($input); }
|
||||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
%typecheck(1) YAP_Term { $1 = PyUnicode_Check($input); }
|
||||||
switch (e.getErrorClass()) {
|
|
||||||
case YAPC_NO_ERROR:
|
%typecheck(0) YAPTerm { $1 = !PyUnicode_Check($input); }
|
||||||
break;
|
|
||||||
/// bad domain, "first argument often is the predicate.
|
|
||||||
case DOMAIN_ERROR: {
|
%typemap(in) jlong %{
|
||||||
switch (en) {
|
$1 = (jlong)$input;
|
||||||
case DOMAIN_ERROR_OUT_OF_RANGE:
|
%}
|
||||||
case DOMAIN_ERROR_NOT_LESS_THAN_ZERO:
|
|
||||||
SWIG_exception(SWIG_IndexError, e.text());
|
%typemap(out) arity_t { *(jlong *)&$result = $1; }
|
||||||
break;
|
|
||||||
case DOMAIN_ERROR_CLOSE_OPTION:
|
// Language independent exception handler
|
||||||
case DOMAIN_ERROR_ENCODING:
|
// simplified version
|
||||||
case DOMAIN_ERROR_PROLOG_FLAG:
|
%include <exception.i>
|
||||||
case DOMAIN_ERROR_ABSOLUTE_FILE_NAME_OPTION:
|
|
||||||
case DOMAIN_ERROR_READ_OPTION:
|
%exception {
|
||||||
case DOMAIN_ERROR_SET_STREAM_OPTION:
|
try {
|
||||||
SWIG_exception(SWIG_AttributeError, e.text());
|
$action
|
||||||
break;
|
} catch (const std::out_of_range& e) {
|
||||||
case DOMAIN_ERROR_FILE_ERRORS:
|
SWIG_exception(SWIG_IndexError, e.what());
|
||||||
case DOMAIN_ERROR_FILE_TYPE:
|
} catch (const std::exception& e) {
|
||||||
case DOMAIN_ERROR_IO_MODE:
|
SWIG_exception(SWIG_RuntimeError, e.what());
|
||||||
case DOMAIN_ERROR_SOURCE_SINK:
|
} catch (...) {
|
||||||
case DOMAIN_ERROR_STREAM_POSITION:
|
SWIG_exception(SWIG_RuntimeError, "unknown exception");
|
||||||
SWIG_exception(SWIG_IOError, e.text());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SWIG_exception(SWIG_ValueError, e.text());
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
/// bad arithmetic
|
|
||||||
case EVALUATION_ERROR: {
|
|
||||||
switch (en) {
|
|
||||||
case EVALUATION_ERROR_FLOAT_OVERFLOW:
|
|
||||||
case EVALUATION_ERROR_FLOAT_UNDERFLOW:
|
|
||||||
case EVALUATION_ERROR_INT_OVERFLOW:
|
|
||||||
case EVALUATION_ERROR_UNDERFLOW:
|
|
||||||
SWIG_exception(SWIG_OverflowError, e.text());
|
|
||||||
break;
|
|
||||||
case EVALUATION_ERROR_ZERO_DIVISOR:
|
|
||||||
SWIG_exception(SWIG_DivisionByZero, e.text());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SWIG_exception(SWIG_RuntimeError, e.text());
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
/// missing object (I/O mostly)
|
|
||||||
case EXISTENCE_ERROR:
|
|
||||||
SWIG_exception(SWIG_RuntimeError, e.text());
|
|
||||||
break;
|
|
||||||
/// should be bound
|
|
||||||
case INSTANTIATION_ERROR_CLASS:
|
|
||||||
SWIG_exception(SWIG_RuntimeError, e.text());
|
|
||||||
break;
|
|
||||||
/// bad access, I/O
|
|
||||||
case PERMISSION_ERROR: {
|
|
||||||
switch (en) {
|
|
||||||
case PERMISSION_ERROR_INPUT_BINARY_STREAM:
|
|
||||||
case PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM:
|
|
||||||
case PERMISSION_ERROR_INPUT_STREAM:
|
|
||||||
case PERMISSION_ERROR_INPUT_TEXT_STREAM:
|
|
||||||
case PERMISSION_ERROR_OPEN_SOURCE_SINK:
|
|
||||||
case PERMISSION_ERROR_OUTPUT_BINARY_STREAM:
|
|
||||||
case PERMISSION_ERROR_REPOSITION_STREAM:
|
|
||||||
case PERMISSION_ERROR_OUTPUT_STREAM:
|
|
||||||
case PERMISSION_ERROR_OUTPUT_TEXT_STREAM:
|
|
||||||
SWIG_exception(SWIG_OverflowError, e.text());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SWIG_exception(SWIG_RuntimeError, e.text());
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
/// something that could not be represented into a type
|
|
||||||
case REPRESENTATION_ERROR:
|
|
||||||
SWIG_exception(SWIG_RuntimeError, e.text());
|
|
||||||
break;
|
|
||||||
/// not enough ....
|
|
||||||
case RESOURCE_ERROR:
|
|
||||||
SWIG_exception(SWIG_RuntimeError, e.text());
|
|
||||||
break;
|
|
||||||
/// bad text
|
|
||||||
case SYNTAX_ERROR_CLASS:
|
|
||||||
SWIG_exception(SWIG_SyntaxError, e.text());
|
|
||||||
break;
|
|
||||||
/// OS or internal
|
|
||||||
case SYSTEM_ERROR_CLASS:
|
|
||||||
SWIG_exception(SWIG_RuntimeError, e.text());
|
|
||||||
break;
|
|
||||||
/// bad typing
|
|
||||||
case TYPE_ERROR:
|
|
||||||
SWIG_exception(SWIG_TypeError, e.text());
|
|
||||||
break;
|
|
||||||
/// should be unbound
|
|
||||||
case UNINSTANTIATION_ERROR_CLASS:
|
|
||||||
SWIG_exception(SWIG_RuntimeError, e.text());
|
|
||||||
break;
|
|
||||||
/// escape hatch
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
%{
|
%{
|
||||||
/* Put header files here or function declarations like below */
|
/* Put header files here or function declarations like below */
|
||||||
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
#if THREADS
|
#if THREADS
|
||||||
#define Yap_regp regcache
|
#define Yap_regp regcache
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// we cannot consult YapInterface.h, that conflicts with what we
|
// we cannot consult YapInterface.h, that conflicts with what we
|
||||||
// declare, though
|
// declare, though
|
||||||
// it shouldn't
|
// it shouldn't
|
||||||
}
|
}
|
||||||
|
|
||||||
%}
|
extern void init_sqlite();
|
||||||
|
|
||||||
/* turn on director wrapping Callback */
|
%}
|
||||||
%feature("director") YAPCallback;
|
|
||||||
|
|
||||||
%include "yapa.hh"
|
|
||||||
|
|
||||||
%include "yapie.hh"
|
/* turn on director wrapping Callback */
|
||||||
|
//%feature("director") YAPCallback;
|
||||||
|
|
||||||
%include "yapt.hh"
|
%include "yapa.hh"
|
||||||
|
|
||||||
%include "yapdb.hh"
|
%include "yapie.hh"
|
||||||
|
|
||||||
%include "yapq.hh"
|
%include "yapt.hh"
|
||||||
|
|
||||||
%init %{
|
%include "yapdb.hh"
|
||||||
%}
|
|
||||||
|
%include "yapq.hh"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
|
||||||
|
%template(TermVector) vector<Term>;
|
||||||
|
%feature("novaluewrapper") vector<Term>;
|
||||||
|
|
||||||
|
//%template(YAPTermVector) vector<YAPTerm>;
|
||||||
|
//%feature("novaluewrapper") vector<YAPTerm>;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
%init %{
|
||||||
|
%}
|
||||||
|
@ -55,7 +55,7 @@ all_attvars/1,
|
|||||||
:- dynamic attributed_module/3.
|
:- dynamic attributed_module/3.
|
||||||
|
|
||||||
|
|
||||||
/** @pred get_attr(+ _Var_,+ _Module_,- _Value_)
|
/** @pred get_attr( + Var,+ Module,- Value)
|
||||||
|
|
||||||
Request the current _value_ for the attribute named _Module_. If
|
Request the current _value_ for the attribute named _Module_. If
|
||||||
_Var_ is not an attributed variable or the named attribute is not
|
_Var_ is not an attributed variable or the named attribute is not
|
||||||
@ -339,7 +339,7 @@ printing and other special purpose operations.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @pred _Module_:attribute_goal( _-Var_, _-Goal_)
|
/** @pred Module:attribute_goal( -Var, Goal)
|
||||||
|
|
||||||
User-defined procedure, called to convert the attributes in _Var_ to
|
User-defined procedure, called to convert the attributes in _Var_ to
|
||||||
a _Goal_. Should fail when no interpretation is available.
|
a _Goal_. Should fail when no interpretation is available.
|
||||||
@ -469,11 +469,11 @@ att_vars([_|LGs], AttVars) :-
|
|||||||
% make sure we set the suspended goal list to its previous state!
|
% make sure we set the suspended goal list to its previous state!
|
||||||
% make sure we have installed a SICStus like constraint solver.
|
% make sure we have installed a SICStus like constraint solver.
|
||||||
|
|
||||||
/** @pred _Module_:project_attributes(+AttrVars, +Goal)
|
/** @pred Module:project_attributes( +AttrVars, +Goal)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Given a goal _Goa]l_ with variables _QueryVars_ and list of attributed
|
Given a goal _Goal_ with variables _QueryVars_ and list of attributed
|
||||||
variables _AttrVars_, project all attributes in _AttrVars_ to
|
variables _AttrVars_, project all attributes in _AttrVars_ to
|
||||||
_QueryVars_. Although projection is constraint system dependent,
|
_QueryVars_. Although projection is constraint system dependent,
|
||||||
typically this will involve expressing all constraints in terms of
|
typically this will involve expressing all constraints in terms of
|
||||||
|
@ -41,7 +41,7 @@ should be read as "p( _X_) if q( _X_) or r( _X_)".
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @pred \+ :_P_ is iso
|
/** @pred \+ 0:P is iso
|
||||||
Negation by failure.
|
Negation by failure.
|
||||||
|
|
||||||
Goal _P_ is not provable. The execution of this predicate fails if
|
Goal _P_ is not provable. The execution of this predicate fails if
|
||||||
@ -68,7 +68,7 @@ If _P_ includes cuts, the cuts are defined to be scoped by _P_: they cannot cut
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @pred :_Condition__ -> :_Action_ is iso
|
/** @pred 0:Condition -> 0:Action is iso
|
||||||
|
|
||||||
|
|
||||||
@short If _Condition__ has a solution, call _Action_;
|
@short If _Condition__ has a solution, call _Action_;
|
||||||
@ -119,7 +119,7 @@ arguments.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @pred :_Condition_ *-> :_Action_ is iso
|
/** @pred 0:Condition *-> 0:Action is iso
|
||||||
|
|
||||||
This construct implements the so-called <em>soft-cut</em>. The control is
|
This construct implements the so-called <em>soft-cut</em>. The control is
|
||||||
defined as follows:
|
defined as follows:
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup corout Implementing Attributed Variables and Co-Routining
|
* @defgroup attscorouts Implementing Attributed Variables and Co-Routining
|
||||||
*
|
*
|
||||||
* @ingroup attributes
|
* @ingroup attributes
|
||||||
* @{
|
* @{
|
||||||
|
16
pl/debug.yap
16
pl/debug.yap
@ -771,14 +771,14 @@ be lost.
|
|||||||
% set_prolog_flag(debug, OldDeb),
|
% set_prolog_flag(debug, OldDeb),
|
||||||
% '$skipeol'(0'!), % '
|
% '$skipeol'(0'!), % '
|
||||||
fail.
|
fail.
|
||||||
'$action'(0'<,_,_,_,_,_) :- !, % <'Depth
|
'$action'(0'<,_,_,_,_,_) :- !, % <'Depth
|
||||||
'$new_deb_depth',
|
'$new_deb_depth',
|
||||||
'$skipeol'(0'<),
|
'$skipeol'(0'<),
|
||||||
fail.
|
fail.
|
||||||
'$action'(0'C,_,_,_,_,_) :-
|
'$action'(0'C,_,_,_,_,_) :-
|
||||||
yap_flag(system_options, Opts),
|
yap_flag(system_options, Opts),
|
||||||
lists:memberchk( call_tracer, Opts),
|
lists:memberchk( call_tracer, Opts),
|
||||||
!, % <'Depth
|
!, % <'Depth
|
||||||
'$skipeol'(0'C),
|
'$skipeol'(0'C),
|
||||||
'__NB_setval__'('$debug_jump',false).
|
'__NB_setval__'('$debug_jump',false).
|
||||||
'$action'(0'^,_,_,G,_,_) :- !, % '
|
'$action'(0'^,_,_,G,_,_) :- !, % '
|
||||||
@ -791,6 +791,7 @@ be lost.
|
|||||||
nodebug,
|
nodebug,
|
||||||
abort.
|
abort.
|
||||||
'$action'(0'b,_,_,_,_,_) :- !, % 'b break
|
'$action'(0'b,_,_,_,_,_) :- !, % 'b break
|
||||||
|
'$stop_creeping'(_),
|
||||||
'$skipeol'(0'b),
|
'$skipeol'(0'b),
|
||||||
break,
|
break,
|
||||||
fail.
|
fail.
|
||||||
@ -802,7 +803,6 @@ be lost.
|
|||||||
'$skipeol'(0'c),
|
'$skipeol'(0'c),
|
||||||
'__NB_setval__'('$debug_jump',false).
|
'__NB_setval__'('$debug_jump',false).
|
||||||
'$action'(0'e,_,_,_,_,_) :- !, % 'e exit
|
'$action'(0'e,_,_,_,_,_) :- !, % 'e exit
|
||||||
'$skipeol'(0'e),
|
|
||||||
halt.
|
halt.
|
||||||
'$action'(0'f,_,CallId,_,_,_) :- !, % 'f fail
|
'$action'(0'f,_,CallId,_,_,_) :- !, % 'f fail
|
||||||
'$scan_number'(0'f, CallId, GoalId), %'f
|
'$scan_number'(0'f, CallId, GoalId), %'f
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
* @file flagd.ysp
|
* @file flagd.ysp
|
||||||
*
|
*
|
||||||
* @defgroup Flags Yap Flags
|
* @defgroup Flags Yap Flags
|
||||||
*n@{}
|
* @{}
|
||||||
* @ingroup builtins
|
* @ingroup builtins
|
||||||
* @}@[ ]
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -79,7 +79,7 @@
|
|||||||
unknown(_,error).
|
unknown(_,error).
|
||||||
|
|
||||||
|
|
||||||
/** @pred create_prolog_flag(+ _Flag_,+ _Value_,+ _Options_)
|
/** @pred create_prolog_flag( +Flag, +Value, +Options)
|
||||||
|
|
||||||
Create a new YAP Prolog flag. _Options_ include
|
Create a new YAP Prolog flag. _Options_ include
|
||||||
|
|
||||||
|
@ -36,15 +36,12 @@ set (LIBRARY_PL
|
|||||||
dcg/basics.pl
|
dcg/basics.pl
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
add_to_group( pl_library LIBRARY_PL )
|
add_to_group( pl_library LIBRARY_PL )
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
file(INSTALL ${LIBRARY_PL} DESTINATION ${libpl})
|
file(INSTALL ${LIBRARY_PL} DESTINATION ${libpl})
|
||||||
else()
|
else()
|
||||||
|
|
||||||
install(FILES ${LIBRARY_PL}
|
|
||||||
DESTINATION ${libpl}
|
DESTINATION ${libpl}
|
||||||
)
|
)
|
||||||
|
|
||||||
endif()
|
|
||||||
|
Reference in New Issue
Block a user