Merge /home/vsc/github/yap-6.3

This commit is contained in:
Vitor Santos Costa 2017-07-25 01:11:16 +01:00
commit 75befc69f7
35 changed files with 1060 additions and 1008 deletions

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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]);

View File

@ -116,7 +116,7 @@ ENDIF (WITH_PYTHON)
List (APPEND YLIBS $<TARGET_OBJECTS:Yapsqlite3> ) 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:Obj4Py> ) List (APPEND YLIBS $<TARGET_OBJECTS:Py4YAP> )
endif() endif()
endif() endif()

View File

@ -254,6 +254,7 @@ class X_API YAPPrologPredicate : public YAPPredicate {
public: public:
YAPPrologPredicate(YAPTerm t) : YAPPredicate(t){}; YAPPrologPredicate(YAPTerm t) : YAPPredicate(t){};
YAPPrologPredicate(const char *s, arity_t arity) : YAPPredicate(s, arity){}; YAPPrologPredicate(const char *s, arity_t arity) : YAPPredicate(s, arity){};
YAPPrologPredicate(YAPAtom s, arity_t arity) : YAPPredicate(s, arity){};
/// add a new clause /// add a new clause
bool assertClause(YAPTerm clause, bool last = true, bool assertClause(YAPTerm clause, bool last = true,
YAPTerm source = YAPTerm()); YAPTerm source = YAPTerm());

View File

@ -4,11 +4,10 @@
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 \
@ -27,8 +26,7 @@
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(); \
} \ } \
} }
@ -37,30 +35,29 @@
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 \
@ -68,8 +65,7 @@
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(); \
} \ } \
} }
@ -78,8 +74,7 @@
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
@ -89,17 +84,16 @@
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();
@ -109,17 +103,16 @@
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();
@ -130,16 +123,15 @@
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();
@ -148,15 +140,15 @@
#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 */
@ -169,7 +161,7 @@
#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 \
@ -180,16 +172,16 @@
#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(); \
@ -200,8 +192,7 @@
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
@ -212,12 +203,12 @@
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(); \
} }
@ -227,12 +218,12 @@
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(); \
} }
@ -241,11 +232,11 @@
#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(); \
} }
@ -258,12 +249,12 @@
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 */
@ -272,12 +263,12 @@
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 */
@ -285,11 +276,11 @@
#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 */
@ -304,8 +295,7 @@
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 \
@ -318,12 +308,11 @@
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 \
@ -331,49 +320,45 @@
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 \ #define DEALLOCATE_END \
ENDCACHE_Y_AS_ENV(); \ ENDCACHE_Y_AS_ENV(); \
GONext(); GONext();

View File

@ -1,4 +1,4 @@
set (Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.6 3.4 ) set (Python_ADDITIONAL_VERSIONS 3.7 3.6 ) #3.5 3.6 3.4 )
# PYTHONLIBS_FOUND - have the Python libs been found # PYTHONLIBS_FOUND - have the Python libs been found
@ -9,9 +9,9 @@ set (Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.6 3.4 )
# PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8) # PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8)
## ##
# #
if (WIN32) if (WIN320)
set (PYTHONLIBS_FOUND YES CACHE BOOL "MINGW/MSYS2" FORCE ) set (PYTHONLIBS_FOUND YES CACHE BOOL "MINGW/MSYS2" FORCE )
set (PYTHON_LIBRARY C:/msys64/mingw64/lib/libpython3.5m.dll.a CACHE FILEPATH "MINGW/MSYS2" FORCE ) set (PYTHON_LIBRARY C:/msys64/mingw64/lib/libpython3.6m.dll.a CACHE FILEPATH "MINGW/MSYS2" FORCE )
set (PYTHON_LIBRARIES C:/msys64/mingw64/lib/libpython3.5m.dll.a CACHE FILEPATH "MINGW/MSYS2" FORCE ) set (PYTHON_LIBRARIES C:/msys64/mingw64/lib/libpython3.5m.dll.a CACHE FILEPATH "MINGW/MSYS2" FORCE )
set (PYTHON_INCLUDE_PATH C:/msys64/mingw64/include/python3.5m CACHE PATH "MINGW/MSYS2" FORCE ) set (PYTHON_INCLUDE_PATH C:/msys64/mingw64/include/python3.5m CACHE PATH "MINGW/MSYS2" FORCE )
set (PYTHON_INCLUDE_DIRS C:/msys64/mingw64/include/python3.5m CACHE PATH "MINGW/MSYS2" FORCE ) set (PYTHON_INCLUDE_DIRS C:/msys64/mingw64/include/python3.5m CACHE PATH "MINGW/MSYS2" FORCE )

View File

@ -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/customdoxygen.css \
@CMAKE_SOURCE_DIR@/docs/custom/pygments.css \ @CMAKE_SOURCE_DIR@/docs/custom/pygments.css \
@CMAKE_SOURCE_DIR@/docs/solarized-light.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

View File

@ -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.
@} @}

View File

@ -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 :-

View File

@ -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).
%% @} %% @}

View File

@ -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.

View File

@ -44,6 +44,8 @@
rb_key_fold/4, rb_key_fold/4,
list_to_rbtree/2, list_to_rbtree/2,
ord_list_to_rbtree/2, ord_list_to_rbtree/2,
keys_to_rbtree/2,
ord_keys_to_rbtree/2,
is_rbtree/1, is_rbtree/1,
rb_size/2, rb_size/2,
rb_in/3 rb_in/3
@ -148,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.
@ -610,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.
@ -646,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.
@ -666,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.
@ -1023,11 +1025,29 @@ keys(black(L,K,_,R),L0,Lf) :-
keys(R,L0,L1). keys(R,L0,L1).
%% list_to_rbtree(+L, -T) is det.
%
% T is the red-black tree corresponding to the mapping in list L.
keys_to_rbtree(List, T) :-
sort(List,Sorted),
ord_keys_to_rbtree(Sorted, T).
%% list_to_rbtree(+L, -T) is det. %% list_to_rbtree(+L, -T) is det.
% %
% T is the red-black tree corresponding to the mapping in list L. % T is the red-black tree corresponding to the mapping in list L.
list_to_rbtree(List, T) :- ord_keys_to_rbtree(List, T) :-
maplist(paux, List, Sorted),
ord_list_to_rbtree(Sorted, T).
paux(K, K-_).
%% list_to_rbtree(+L, -T) is det.
%
% T is the red-black tree corresponding to the mapping in list L.
list_to_rbtree(List, T) :-
sort(List,Sorted), sort(List,Sorted),
ord_list_to_rbtree(Sorted, T). ord_list_to_rbtree(Sorted, T).
@ -1434,4 +1454,3 @@ with _NewVal_. Fails if it cannot find _Key_ in _T_.
*/ */
%%! @} %%! @}

View File

@ -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 */
if (LOCAL_PrologMode & InterruptMode) {
Yap_external_signal(0, YAP_INT_SIGNAL);
LOCAL_PrologMode &= ~ConsoleGetcMode; LOCAL_PrologMode &= ~ConsoleGetcMode;
if (LOCAL_PrologMode & AbortMode) { if (rl_pending_signal()) {
Yap_Error(ABORT_EVENT, TermNil, ""); LOCAL_PrologMode |= InterruptMode;
LOCAL_ErrorMessage = "Abort";
return console_post_process_eof(s);
} }
if (LOCAL_PrologMode & InterruptMode) {
Yap_HandleSIGINT();
} 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);

View File

@ -317,7 +317,9 @@ 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)) {
return;
}
my_signal(s, ReceiveSignal); my_signal(s, ReceiveSignal);
switch (s) { switch (s) {
case SIGINT: case SIGINT:

View File

@ -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;
} }

View File

@ -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))

View File

@ -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)

View File

@ -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

View File

@ -32,7 +32,9 @@ static PyObject *s_to_python(const char *s, bool eval, PyObject *p0) {
Py_INCREF(o); Py_INCREF(o);
return CHECKNULL(YAP_MkStringTerm(s), o); return CHECKNULL(YAP_MkStringTerm(s), o);
} else { } else {
PyObject *pobj = PyUnicode_DecodeUTF8(s, strlen(s), NULL); //char *ns = Py_Malloc(strlen(s)+1);
///strcpy(ns,s);
PyObject *pobj = PyUnicode_FromString(s);
return pobj; return pobj;
} }
} }
@ -150,19 +152,19 @@ PyObject *term_to_python(term_t t, bool eval, PyObject *o) {
out = PyList_New(len); out = PyList_New(len);
if (!out) { if (!out) {
PL_reset_term_refs(tail); PL_reset_term_refs(tail);
return CHECKNULL(t, Py_None); YAPPy_ThrowError(SYSTEM_ERROR_INTERNAL, t, "list->python");
} }
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
if (!PL_get_list(t, arg, t)) { if (!PL_get_list(t, arg, t)) {
PL_reset_term_refs(tail); PL_reset_term_refs(tail);
return Py_None; YAPPy_ThrowError(SYSTEM_ERROR_INTERNAL, t, "list->python");
} }
a = term_to_python(arg, eval, o); a = term_to_python(arg, eval, o);
if (a) { if (a) {
if (PyList_SetItem(out, i, a) < 0) { if (PyList_SetItem(out, i, a) < 0) {
PL_reset_term_refs(tail); PL_reset_term_refs(tail);
return Py_None; YAPPy_ThrowError(SYSTEM_ERROR_INTERNAL, t, "list->python");
} }
} }
} }
@ -170,11 +172,33 @@ PyObject *term_to_python(term_t t, bool eval, PyObject *o) {
return CHECKNULL(t, out); return CHECKNULL(t, out);
} else { } else {
functor_t fun; functor_t fun;
atom_t name;
int arity;
PyObject *rc; PyObject *rc;
if (!PL_get_functor(t, &fun)) { if (!PL_get_functor(t, &fun)) {
PL_reset_term_refs(tail); PL_reset_term_refs(tail);
return CHECKNULL(t, Py_None); YAPPy_ThrowError(SYSTEM_ERROR_INTERNAL, t, "list->python");
}
AOK(PL_get_name_arity(t, &name, &arity), NULL);
if (name == ATOM_t) {
int i;
rc = PyTuple_New(arity);
for (i = 0; i < len; i++) {
term_t arg = PL_new_term_ref();
if (!PL_get_arg(i+1, t, arg)) {
PL_reset_term_refs(arg);
YAPPy_ThrowError(SYSTEM_ERROR_INTERNAL, t, "t(...)->python");
}
PyObject *a = term_to_python(arg, eval, o);
if (a) {
if (PyTuple_SetItem(rc, i, a) < 0) {
PL_reset_term_refs(arg);
YAPPy_ThrowError(SYSTEM_ERROR_INTERNAL, t, "t(...)->python");
}
}
PL_reset_term_refs(arg);
}
} }
if (eval) if (eval)
rc = compound_to_pyeval(t, o); rc = compound_to_pyeval(t, o);
@ -185,7 +209,7 @@ PyObject *term_to_python(term_t t, bool eval, PyObject *o) {
} }
} }
} }
return CHECKNULL(t, Py_None); return Py_None;
} }
PyObject *yap_to_python(YAP_Term t, bool eval, PyObject *o) { PyObject *yap_to_python(YAP_Term t, bool eval, PyObject *o) {
@ -209,3 +233,7 @@ PyObject *deref_term_to_python(term_t t) {
} }
return term_to_python(t, false, NULL); return term_to_python(t, false, NULL);
} }
void YAPPy_ThrowError__(const char *file, const char *function, int lineno,
yap_error_number type, term_t where, ...);

View File

@ -698,7 +698,7 @@ static PyObject *structseq_repr(PyObject *iobj) {
PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) { PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
PyObject *o; PyObject *o;
#if PY_MAJOR_VERSION >= 30 #if PY_MAJOR_VERSION >= 3
PyTypeObject *typp; PyTypeObject *typp;
PyObject *key = PyUnicode_FromString(s); PyObject *key = PyUnicode_FromString(s);
if (py_F2P && PyDict_Contains(py_F2P, key)) { if (py_F2P && PyDict_Contains(py_F2P, key)) {
@ -729,7 +729,6 @@ PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
} }
o = PyStructSequence_New(typp); o = PyStructSequence_New(typp);
Py_INCREF(typp); Py_INCREF(typp);
fprintf(stderr, "<<< %p\n",typp);
arity_t i; arity_t i;
for (i = 0; i < arity; i++) { for (i = 0; i < arity; i++) {
PyObject *pArg = PyTuple_GET_ITEM(tuple, i); PyObject *pArg = PyTuple_GET_ITEM(tuple, i);
@ -750,7 +749,7 @@ PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
#endif #endif
} }
static PyObject *bip_range(term_t t) { static PyObject *bip_range(term_t t) {
long ilow = 0, ihigh = 0, istep = 1; long ilow = 0, ihigh = 0, istep = 1;
long bign; long bign;
Py_ssize_t i, n; Py_ssize_t i, n;
@ -805,9 +804,9 @@ static PyObject *bip_range(term_t t) {
ilow += istep; ilow += istep;
} }
return v; return v;
} }
static bool copy_to_dictionary(PyObject *dict, term_t targ, term_t taux, static bool copy_to_dictionary(PyObject *dict, term_t targ, term_t taux,
bool eval) { bool eval) {
PyObject *lhs, *rhs; PyObject *lhs, *rhs;
term_t tleft = PL_new_term_ref(), tright = PL_new_term_ref(); term_t tleft = PL_new_term_ref(), tright = PL_new_term_ref();
@ -841,9 +840,9 @@ static bool copy_to_dictionary(PyObject *dict, term_t targ, term_t taux,
// PyObject_Print(dict, stderr, 0); fprintf(stderr,"\n"); // PyObject_Print(dict, stderr, 0); fprintf(stderr,"\n");
// Py_DECREF(lhs); // Py_DECREF(lhs);
// Py_DECREF(rhs); // Py_DECREF(rhs);
} }
PyObject *compound_to_data(term_t t, PyObject *o, functor_t fun, bool exec) { PyObject *compound_to_data(term_t t, PyObject *o, functor_t fun, bool exec) {
atom_t name; atom_t name;
int len; int len;
@ -1016,9 +1015,9 @@ PyObject *compound_to_data(term_t t, PyObject *o, functor_t fun, bool exec) {
return dict; return dict;
} }
return o; return o;
} }
PyObject *compound_to_pytree(term_t t, PyObject *context) { PyObject *compound_to_pytree(term_t t, PyObject *context) {
PyObject *o = py_Main, *no; PyObject *o = py_Main, *no;
functor_t fun; functor_t fun;
atom_t name; atom_t name;
@ -1072,9 +1071,9 @@ PyObject *compound_to_pytree(term_t t, PyObject *context) {
} }
return term_to_nametuple(s, arity, out); return term_to_nametuple(s, arity, out);
} }
} }
PyObject *compound_to_pyeval(term_t t, PyObject *context) { PyObject *compound_to_pyeval(term_t t, PyObject *context) {
PyObject *o = NULL, *no; PyObject *o = NULL, *no;
atom_t name; atom_t name;
int arity; int arity;
@ -1239,4 +1238,4 @@ PyObject *compound_to_pyeval(term_t t, PyObject *context) {
return rc; return rc;
} }
} }

View File

@ -24,64 +24,74 @@ SET_SOURCE_FILES_PROPERTIES(../../swig/yap.i PROPERTIES SWIG_MODULE_NAME yap)
if (WIN32) if (WIN32)
set (SYS_DLLS ${GMP_LIBRARIES}) set (SYS_DLLS ${GMP_LIBRARIES} c:/msys64/mingw64/bin/libgmp-10.dll)
set (SYS_DLLS c:/msys64/mingw64/bin/libgmp-10.dll)
endif() endif()
# inform we are compiling YAP # inform we are compiling YAP
# s used in MSYS # s used in MSYS
# #
# #
# INSTALL ( TARGETS ${SWIG_MODULE_Py2YAP_REAL_NAME} # INSTALL ( TARGETS ${SWIG_MODULE_Py2YAP_REAL_NAME}
# RUNTIME DESTINATION ${PYTHON_MODULE_PATH} # RUNTIME DESTINATION ${PYTHON_MODULE_PATH}
# ARCHIVE DESTINATION ${PYTHON_MODULE_PATH} # ARCHIVE DESTINATION ${PYTHON_MODULE_PATH}
# LIBRARY DESTINATION ${PYTHON_MODULE_PATH} # LIBRARY DESTINATION ${PYTHON_MODULE_PATH}
# ) # )
set (python_dlls $<TARGET_FILE:matrix> set (python_dlls ${SYS_DLLS}
$<TARGET_FILE:matrix>
$<TARGET_FILE:regexp> $<TARGET_FILE:regexp>
$<TARGET_FILE:yap_rl> $<TARGET_FILE:yap_rl>
$<TARGET_FILE:tries> $<TARGET_FILE:tries>
$<TARGET_FILE:itries> $<TARGET_FILE:itries>
$<TARGET_FILE:sys> $<TARGET_FILE:sys>
$<TARGET_FILE:yap_random> $<TARGET_FILE:yap_random>
) )
if (TARGET real) if (TARGET real)
list(APPEND python_dlls $<TARGET_FILE:real> list(APPEND python_dlls $<TARGET_FILE:real>
) )
endif() endif()
if (NOT WIN32) if (NOT WIN32)
list(APPEND python_dlls $<TARGET_FILE:YAP++> $<TARGET_FILE:Py4YAP> list(APPEND python_dlls $<TARGET_FILE:YAP++> $<TARGET_FILE:Py4YAP>
) )
endif() endif()
set (PL ${pl_library} ${PROLOG_SOURCES} ) set (PL ${pl_library} ${PROLOG_SOURCES} )
add_custom_target( YAP4PY_SETUP add_custom_target( YAP4PY_SETUP
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/packages/swig/yap.i ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E copy ${python_dlls} yap4py
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/config.h ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/libYap${CMAKE_SHARED_LIBRARY_SUFFIX} yap4py
COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/yap4py COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${CMAKE_CURRENT_BINARY_DIR}/yap4py
COMMAND ${CMAKE_COMMAND} -E copy ${python_dlls} ${SYS_DLLS} ${CMAKE_BINARY_DIR}/libYap${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${PYTHON_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/yap4py WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${PL} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog DEPENDS YAP4PY_SETUP_PL STARTUP ${python_dlls} libYap )
COMMAND ${CMAKE_COMMAND} -E copy ${pl_boot_library} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/pl
COMMAND ${CMAKE_COMMAND} -E copy ${pl_os_library} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/os add_custom_target( YAP4PY_SETUP_PL
DEPENDS YAP4PY_SETUP_DIRS STARTUP ${python_dlls} ${PYTHON_SOURCES} ${PROLOG_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/setup.py ${SWIG_MODULE_Py2YAP_REAL_NAME} ) COMMAND ${CMAKE_COMMAND} -E copy ${PL} yap4py/prolog
COMMAND ${CMAKE_COMMAND} -E copy ${pl_boot_library} yap4py/prolog/pl
COMMAND ${CMAKE_COMMAND} -E copy ${pl_os_library} yap4py/prolog/os
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/yap.i ${PYTHON_SOURCES} ${PL} ${pl_boot_library} ${pl_os_library} )
add_custom_target( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/yap.i
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/packages/swig/yap.i yap.i
COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_SOURCES} yap4py
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS YAP4PY_SETUP_DIRS ${PYTHON_SOURCES} )
add_custom_target( YAP4PY_SETUP_DIRS add_custom_target( YAP4PY_SETUP_DIRS
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py COMMAND ${CMAKE_COMMAND} -E make_directory yap4py
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog COMMAND ${CMAKE_COMMAND} -E make_directory yap4py/prolog
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/pl COMMAND ${CMAKE_COMMAND} -E make_directory yap4py/prolog/pl
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/os COMMAND ${CMAKE_COMMAND} -E make_directory yap4py/prolog/os
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
) )
add_custom_target( YAP4PY ALL add_custom_target( YAP4PY ALL
COMMAND ${PYTHON_EXECUTABLE} -m pip uninstall -y YAP4PY COMMAND ${PYTHON_EXECUTABLE} -m pip uninstall -y YAP4PY
COMMAND ${SWIG_EXECUTABLE} -python -modern -c++ -py3 -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}/OPTYap -I../../.. -o yap_wrap.cpp yap.i COMMAND ${SWIG_EXECUTABLE} -python -modern -c++ -py3 -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}/OPTYap -I../../.. -o yap_wrap.cpp yap.i
COMMAND ${PYTHON_EXECUTABLE} setup.py sdist bdist_wheel COMMAND ${PYTHON_EXECUTABLE} setup.py sdist bdist_wheel
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS YAP4PY_SETUP) DEPENDS YAP4PY_SETUP)

View File

@ -3,6 +3,8 @@
See: See:
https://packaging.python.org/en/latest/distributing.html https://packaging.python.org/en/latest/distributing.html
https://github.com/pypa/sampleproject https://github.com/pypa/sampleproject
""" """
# Always prefer setuptools over distutils # Always prefer setuptools over distutils

View File

@ -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}", '.'], library_dirs=['../../..', '../../../CXX', '..', "${dlls}", "${bindir}", '.'],
extra_link_args=my_extra_link_args, extra_link_args=my_extra_link_args,
libraries=['Yap','${PYTHON_LIBRARIES}','${GMP_LIBRARIES}']+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',

View File

@ -137,7 +137,7 @@ def answer(q):
return False return False
def query_prolog(engine, s): def query_prolog(engine, s):
import pdb; pdb.set_trace() # import pdb; pdb.set_trace()
# #
# construct a query from a one-line string # construct a query from a one-line string
# q is opaque to Python # q is opaque to Python
@ -209,15 +209,7 @@ def live(**kwargs):
# #
def boot_yap(**kwargs): def boot_yap(**kwargs):
args = EngineArgs(**kwarg) return Engine(**kwargs)
yap_lib_path = os.path.dirname(__file__)
args.setYapShareDir(os.path.join(yap_lib_path,"prolog"))
args.setYapLibDir(yap_lib_path)
args.setSavedState(os.path.join(yap_lib_path,"startup.yss"))
engine = YAPEngine(args)
engine.goal( set_prolog_flag('verbose', 'silent' ) )
engine.goal( use_module(library('yapi') ) )
return engine
if __name__ == "__main__": if __name__ == "__main__":
engine = boot_yap() engine = boot_yap()

View File

@ -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

View File

@ -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:

View File

@ -41,7 +41,7 @@
/** /**
* @defgroup corout Implementing Attributed Variables and Co-Routining * @defgroup attscorouts Implementing Attributed Variables and Co-Routining
* *
* @ingroup attributes * @ingroup attributes
* @{ * @{

View File

@ -771,11 +771,11 @@ 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
@ -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

View File

@ -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

View File

@ -789,4 +789,4 @@ module_state :-
fail. fail.
module_state. module_state.
// @} %% @}