Merge /home/vsc/github/yap-6.3
This commit is contained in:
commit
75befc69f7
@ -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)
|
||||
Yap_init_yapor_global_local_memory();
|
||||
#endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA */
|
||||
// GLOBAL_PrologShouldHandleInterrupts =
|
||||
// yap_init->PrologShouldHandleInterrupts &&
|
||||
if (!yap_init->Embedded) {
|
||||
GLOBAL_PrologShouldHandleInterrupts =
|
||||
~yap_init->PrologCannotHandleInterrupts;
|
||||
Yap_InitSysbits(0); /* init signal handling and time, required by later
|
||||
functions */
|
||||
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));
|
||||
}
|
||||
|
||||
/** @pred _X_ \== _Y_ is iso
|
||||
/** @pred X \== Y is iso
|
||||
|
||||
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); }
|
||||
|
||||
/** @pred _X_ @=< _Y_ is iso
|
||||
/** @pred X @=< Y is iso
|
||||
|
||||
|
||||
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); }
|
||||
|
||||
/** @pred _X_ @> _Y_ is iso
|
||||
/** @pred X @> Y is iso
|
||||
|
||||
|
||||
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; }
|
||||
|
||||
/** @pred _X_ @>= _Y_ is iso
|
||||
/** @pred X @>= Y is iso
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
@ -1658,7 +1658,7 @@ mark_environments(CELL_PTR gc_ENV, size_t size, CELL *pvbmap USES_REGS)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
mark_external_reference(saved_var PASS_REGS);
|
||||
mark_external_reference(saved_var PASS_REGS);
|
||||
}
|
||||
bmap <<= 1;
|
||||
currv++;
|
||||
|
14
C/signals.c
14
C/signals.c
@ -28,9 +28,9 @@ static char SccsId[] = "%W% %G%";
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#include "YapEval.h"
|
||||
#include "YapHeap.h"
|
||||
#include "Yatom.h"
|
||||
#include "YapEval.h"
|
||||
#include "yapio.h"
|
||||
#ifdef TABLING
|
||||
#include "tab.macros.h"
|
||||
@ -65,10 +65,8 @@ static yap_signals InteractSIGINT(int ch) {
|
||||
case 'a':
|
||||
/* abort computation */
|
||||
#if PUSH_REGS
|
||||
// restore_absmi_regs(&Yap_standard_regs);
|
||||
// restore_absmi_regs(&Yap_standard_regs);
|
||||
#endif
|
||||
LOCAL_RestartEnv = malloc( sizeof(sigjmp_buf) );
|
||||
siglongjmp(*LOCAL_RestartEnv, 4);
|
||||
return YAP_ABORT_SIGNAL;
|
||||
case 'b':
|
||||
/* 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
|
||||
the context of the main Prolog thread (trivial in Unix, but hard in WIN32)
|
||||
/**
|
||||
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).
|
||||
|
||||
|
||||
*/
|
||||
static yap_signals ProcessSIGINT(void) {
|
||||
CACHE_REGS
|
||||
|
@ -1155,9 +1155,12 @@ bool Yap_find_prolog_culprit(USES_REGS1) {
|
||||
|
||||
while (curCP != YESCODE) {
|
||||
curENV = (CELL *)(curENV[E_E]);
|
||||
if (curENV == NULL)
|
||||
if (curENV < ASP || curENV >= LCL0)
|
||||
break;
|
||||
pe = EnvPreg(curCP);
|
||||
if (pe==NULL) {
|
||||
pe = PredMetaCall;
|
||||
}
|
||||
if (pe->ModuleOfPred)
|
||||
return set_clause_info(curCP, pe);
|
||||
curCP = (yamop *)(curENV[E_CP]);
|
||||
|
@ -116,7 +116,7 @@ ENDIF (WITH_PYTHON)
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:Yapsqlite3> )
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:YAP++> )
|
||||
if (WITH_PYTHON )
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:Obj4Py> )
|
||||
List (APPEND YLIBS $<TARGET_OBJECTS:Py4YAP> )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -254,6 +254,7 @@ class X_API YAPPrologPredicate : public YAPPredicate {
|
||||
public:
|
||||
YAPPrologPredicate(YAPTerm t) : YAPPredicate(t){};
|
||||
YAPPrologPredicate(const char *s, arity_t arity) : YAPPredicate(s, arity){};
|
||||
YAPPrologPredicate(YAPAtom s, arity_t arity) : YAPPredicate(s, arity){};
|
||||
/// add a new clause
|
||||
bool assertClause(YAPTerm clause, bool last = true,
|
||||
YAPTerm source = YAPTerm());
|
||||
|
@ -1,379 +1,364 @@
|
||||
#define EXECUTE_INSTINIT \
|
||||
print_instruction((*_PREG), ON_NATIVE); \
|
||||
BLOCKADDRESS = (CELL)(*_PREG); \
|
||||
register CELL d0; \
|
||||
PredEntry *pt0; \
|
||||
register CELL *ENV_YREG = (YREG); \
|
||||
pt0 = (*_PREG)->u.pp.p;
|
||||
|
||||
#define EXECUTE_INSTINIT \
|
||||
print_instruction((*_PREG), ON_NATIVE); \
|
||||
BLOCKADDRESS = (CELL)(*_PREG); \
|
||||
register CELL d0; \
|
||||
PredEntry *pt0; \
|
||||
register CELL *ENV_YREG = (YREG); \
|
||||
pt0 = (*_PREG)->u.Osbpp.p;
|
||||
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
#define EXECUTE_LOW_LEVEL_TRACER \
|
||||
low_level_trace(enter_pred,pt0,XREGS+1);
|
||||
#define EXECUTE_LOW_LEVEL_TRACER low_level_trace(enter_pred, pt0, XREGS + 1);
|
||||
#endif
|
||||
|
||||
#define EXECUTE_POST_LOW_LEVEL_TRACER \
|
||||
CACHE_A1(); \
|
||||
ALWAYS_LOOKAHEAD(pt0->OpcodeOfPred); \
|
||||
d0 = (CELL)B;
|
||||
|
||||
#define EXECUTE_POST_NOCHECKING \
|
||||
(*_PREG) = pt0->CodeOfPred; \
|
||||
save_pc(); \
|
||||
ENV_YREG[E_CB] = d0;
|
||||
|
||||
#define EXECUTE_POST_LOW_LEVEL_TRACER \
|
||||
CACHE_A1(); \
|
||||
ALWAYS_LOOKAHEAD(pt0->OpcodeOfPred); \
|
||||
d0 = (CELL)B;
|
||||
|
||||
#define EXECUTE_POST_NOCHECKING \
|
||||
(*_PREG) = pt0->CodeOfPred; \
|
||||
save_pc(); \
|
||||
ENV_YREG[E_CB] = d0;
|
||||
|
||||
#ifdef DEPTH_LIMIT
|
||||
#define EXECUTE_DEPTH_MINOR \
|
||||
FAILED = 0; \
|
||||
if (pt0->ModuleOfPred) { \
|
||||
if (DEPTH == MkIntTerm(0)) { \
|
||||
YAAM_FAIL; \
|
||||
} \
|
||||
else { \
|
||||
DEPTH = RESET_DEPTH(); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define EXECUTE_DEPTH_MOFPRED \
|
||||
FAILED = 0; \
|
||||
DEPTH -= MkIntConstant(2);
|
||||
#define EXECUTE_DEPTH_MINOR \
|
||||
FAILED = 0; \
|
||||
if (pt0->ModuleOfPred) { \
|
||||
if (DEPTH == MkIntTerm(0)) { \
|
||||
YAAM_FAIL; \
|
||||
} else { \
|
||||
DEPTH = RESET_DEPTH(); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define EXECUTE_DEPTH_END \
|
||||
FAILED = 0;
|
||||
#define EXECUTE_DEPTH_MOFPRED \
|
||||
FAILED = 0; \
|
||||
DEPTH -= MkIntConstant(2);
|
||||
|
||||
#define EXECUTE_DEPTH_END FAILED = 0;
|
||||
#endif
|
||||
|
||||
#define EXECUTE_END_END \
|
||||
BLOCK = (CELL)EXECUTE_END_END; \
|
||||
if (!FAILED) { \
|
||||
ALWAYS_GONext(); \
|
||||
} \
|
||||
#define EXECUTE_END_END \
|
||||
BLOCK = (CELL)EXECUTE_END_END; \
|
||||
if (!FAILED) { \
|
||||
ALWAYS_GONext(); \
|
||||
}
|
||||
|
||||
#define DEXECUTE_INSTINIT \
|
||||
print_instruction((*_PREG), ON_NATIVE); \
|
||||
BLOCKADDRESS = (CELL)(*_PREG);
|
||||
|
||||
#define DEXECUTE_INSTINIT \
|
||||
print_instruction((*_PREG), ON_NATIVE); \
|
||||
BLOCKADDRESS = (CELL)(*_PREG); \
|
||||
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
#define DEXECUTE_LOW_LEVEL_TRACER \
|
||||
low_level_trace(enter_pred,(*_PREG)->u.pp.p,XREGS+1);
|
||||
#define DEXECUTE_LOW_LEVEL_TRACER \
|
||||
low_level_trace(enter_pred, (*_PREG)->u.Osbpp.p, XREGS + 1);
|
||||
#endif
|
||||
|
||||
#define DEXECUTE_POST_LOW_LEVEL_TRACER \
|
||||
CACHE_Y_AS_ENV(YREG); \
|
||||
PredEntry *pt0; \
|
||||
CACHE_A1(); \
|
||||
pt0 = (*_PREG)->u.pp.p;
|
||||
|
||||
#define DEXECUTE_POST_LOW_LEVEL_TRACER \
|
||||
CACHE_Y_AS_ENV(YREG); \
|
||||
PredEntry *pt0; \
|
||||
CACHE_A1(); \
|
||||
pt0 = (*_PREG)->u.Osbpp.p;
|
||||
|
||||
#ifdef DEPTH_LIMIT
|
||||
#define DEXECUTE_DEPTH_MINOR \
|
||||
FAILED = 0; \
|
||||
if (pt0->ModuleOfPred) { \
|
||||
if (DEPTH == MkIntTerm(0)) { \
|
||||
YAAM_FAIL; \
|
||||
} \
|
||||
else { \
|
||||
DEPTH = RESET_DEPTH(); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define DEXECUTE_DEPTH_MOFPRED \
|
||||
FAILED = 0; \
|
||||
DEPTH -= MkIntConstant(2);
|
||||
|
||||
#define DEXECUTE_DEPTH_END \
|
||||
FAILED = 0;
|
||||
#define DEXECUTE_DEPTH_MINOR \
|
||||
FAILED = 0; \
|
||||
if (pt0->ModuleOfPred) { \
|
||||
if (DEPTH == MkIntTerm(0)) { \
|
||||
YAAM_FAIL; \
|
||||
} else { \
|
||||
DEPTH = RESET_DEPTH(); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define DEXECUTE_DEPTH_MOFPRED \
|
||||
FAILED = 0; \
|
||||
DEPTH -= MkIntConstant(2);
|
||||
|
||||
#define DEXECUTE_DEPTH_END FAILED = 0;
|
||||
#endif
|
||||
|
||||
#ifdef FROZEN_STACKS
|
||||
#ifdef YAPOR_SBA
|
||||
#define DEXECUTE_END_END \
|
||||
BLOCK = (CELL)DEXECUTE_END_END; \
|
||||
if (!FAILED) { \
|
||||
(*_PREG) = pt0->CodeOfPred; \
|
||||
save_pc(); \
|
||||
(*_CPREG) = (yamop *) ENV_YREG[E_CP]; \
|
||||
ENV_YREG = ENV = (CELL *) ENV_YREG[E_E]; \
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) { \
|
||||
ENV_YREG = (CELL *) top_b; \
|
||||
} \
|
||||
else { \
|
||||
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL) B; \
|
||||
ALWAYS_GONext(); \
|
||||
} \
|
||||
ENDCACHE_Y_AS_ENV();
|
||||
#define DEXECUTE_END_END \
|
||||
BLOCK = (CELL)DEXECUTE_END_END; \
|
||||
if (!FAILED) { \
|
||||
(*_PREG) = pt0->CodeOfPred; \
|
||||
save_pc(); \
|
||||
(*_CPREG) = (yamop *)ENV_YREG[E_CP]; \
|
||||
ENV_YREG = ENV = (CELL *)ENV_YREG[E_E]; \
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||
if (ENV_YREG > (CELL *)top_b || ENV_YREG < HR) { \
|
||||
ENV_YREG = (CELL *)top_b; \
|
||||
} else { \
|
||||
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL)B; \
|
||||
ALWAYS_GONext(); \
|
||||
} \
|
||||
ENDCACHE_Y_AS_ENV();
|
||||
#else /* YAPOR_SBA */
|
||||
#define DEXECUTE_END_END \
|
||||
BLOCK = (CELL)DEXECUTE_END_END; \
|
||||
if (!FAILED) { \
|
||||
(*_PREG) = pt0->CodeOfPred; \
|
||||
save_pc(); \
|
||||
(*_CPREG) = (yamop *) ENV_YREG[E_CP]; \
|
||||
ENV_YREG = ENV = (CELL *) ENV_YREG[E_E]; \
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||
if (ENV_YREG > (CELL *) top_b) { \
|
||||
ENV_YREG = (CELL *) top_b; \
|
||||
} \
|
||||
else { \
|
||||
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL) B; \
|
||||
ALWAYS_GONext(); \
|
||||
} \
|
||||
ENDCACHE_Y_AS_ENV();
|
||||
#define DEXECUTE_END_END \
|
||||
BLOCK = (CELL)DEXECUTE_END_END; \
|
||||
if (!FAILED) { \
|
||||
(*_PREG) = pt0->CodeOfPred; \
|
||||
save_pc(); \
|
||||
(*_CPREG) = (yamop *)ENV_YREG[E_CP]; \
|
||||
ENV_YREG = ENV = (CELL *)ENV_YREG[E_E]; \
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||
if (ENV_YREG > (CELL *)top_b) { \
|
||||
ENV_YREG = (CELL *)top_b; \
|
||||
} else { \
|
||||
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL)B; \
|
||||
ALWAYS_GONext(); \
|
||||
} \
|
||||
ENDCACHE_Y_AS_ENV();
|
||||
#endif /* YAPOR_SBA */
|
||||
#else /* FROZEN_STACKS */
|
||||
#define DEXECUTE_END_END \
|
||||
BLOCK = (CELL)DEXECUTE_END_END; \
|
||||
if (!FAILED) { \
|
||||
(*_PREG) = pt0->CodeOfPred; \
|
||||
save_pc(); \
|
||||
(*_CPREG) = (yamop *) ENV_YREG[E_CP]; \
|
||||
ENV_YREG = ENV = (CELL *) ENV_YREG[E_E]; \
|
||||
if (ENV_YREG > (CELL *)B) { \
|
||||
ENV_YREG = (CELL *)B; \
|
||||
} \
|
||||
else { \
|
||||
ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size((*_CPREG))); \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL) B; \
|
||||
ALWAYS_GONext(); \
|
||||
} \
|
||||
ENDCACHE_Y_AS_ENV();
|
||||
#else /* FROZEN_STACKS */
|
||||
#define DEXECUTE_END_END \
|
||||
BLOCK = (CELL)DEXECUTE_END_END; \
|
||||
if (!FAILED) { \
|
||||
(*_PREG) = pt0->CodeOfPred; \
|
||||
save_pc(); \
|
||||
(*_CPREG) = (yamop *)ENV_YREG[E_CP]; \
|
||||
ENV_YREG = ENV = (CELL *)ENV_YREG[E_E]; \
|
||||
if (ENV_YREG > (CELL *)B) { \
|
||||
ENV_YREG = (CELL *)B; \
|
||||
} else { \
|
||||
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size((*_CPREG))); \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL)B; \
|
||||
ALWAYS_GONext(); \
|
||||
} \
|
||||
ENDCACHE_Y_AS_ENV();
|
||||
#endif /* FROZEN_STACKS */
|
||||
|
||||
#ifdef DEPTH_LIMIT
|
||||
#define FCALL_INST \
|
||||
CACHE_Y_AS_ENV(YREG); \
|
||||
ENV_YREG[E_CP] = (CELL) (*_CPREG); \
|
||||
ENV_YREG[E_E] = (CELL) ENV; \
|
||||
ENV_YREG[E_DEPTH] = DEPTH; \
|
||||
ENDCACHE_Y_AS_ENV();
|
||||
#define FCALL_INST \
|
||||
CACHE_Y_AS_ENV(YREG); \
|
||||
ENV_YREG[E_CP] = (CELL)(*_CPREG); \
|
||||
ENV_YREG[E_E] = (CELL)ENV; \
|
||||
ENV_YREG[E_DEPTH] = DEPTH; \
|
||||
ENDCACHE_Y_AS_ENV();
|
||||
#else /* DEPTH_LIMIT */
|
||||
#define FCALL_INST \
|
||||
CACHE_Y_AS_ENV(YREG); \
|
||||
ENV_YREG[E_CP] = (CELL) (*_CPREG); \
|
||||
ENV_YREG[E_E] = (CELL) ENV; \
|
||||
ENDCACHE_Y_AS_ENV();
|
||||
#define FCALL_INST \
|
||||
CACHE_Y_AS_ENV(YREG); \
|
||||
ENV_YREG[E_CP] = (CELL)(*_CPREG); \
|
||||
ENV_YREG[E_E] = (CELL)ENV; \
|
||||
ENDCACHE_Y_AS_ENV();
|
||||
#endif /* DEPTH_LIMIT */
|
||||
|
||||
#define CALL_INSTINIT \
|
||||
print_instruction((*_PREG), ON_NATIVE); \
|
||||
BLOCKADDRESS = (CELL)(*_PREG); \
|
||||
if (Yap_op_from_opcode((*_PREG)->opc) == _fcall) { \
|
||||
FCALL_INST; \
|
||||
}
|
||||
|
||||
|
||||
#define CALL_INSTINIT \
|
||||
print_instruction((*_PREG), ON_NATIVE); \
|
||||
BLOCKADDRESS = (CELL)(*_PREG); \
|
||||
if (Yap_op_from_opcode((*_PREG)->opc) == _fcall) { \
|
||||
FCALL_INST; \
|
||||
}
|
||||
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
#define CALL_LOW_LEVEL_TRACER \
|
||||
low_level_trace(enter_pred,(*_PREG)->u.Osbpp.p,XREGS+1);
|
||||
#define CALL_LOW_LEVEL_TRACER \
|
||||
low_level_trace(enter_pred, (*_PREG)->u.Osbpp.p, XREGS + 1);
|
||||
#endif
|
||||
|
||||
#define CALL_POST_LOW_LEVEL_TRACER \
|
||||
register CELL *ENV_YREG = (YREG); \
|
||||
PredEntry *pt; \
|
||||
pt = (*_PREG)->u.Osbpp.p; \
|
||||
CACHE_A1();
|
||||
|
||||
#define CALL_POST_NO_CHECKING \
|
||||
ENV = ENV_YREG; \
|
||||
ENV_YREG = (CELL *) (((char *) ENV_YREG) + (*_PREG)->u.Osbpp.s); \
|
||||
(*_CPREG) = NEXTOP((*_PREG), Osbpp); \
|
||||
(*_PREG) = pt->CodeOfPred; \
|
||||
save_pc(); \
|
||||
|
||||
#define CALL_POST_LOW_LEVEL_TRACER \
|
||||
register CELL *ENV_YREG = (YREG); \
|
||||
PredEntry *pt; \
|
||||
pt = (*_PREG)->u.Osbpp.p; \
|
||||
CACHE_A1();
|
||||
|
||||
#define CALL_POST_NO_CHECKING \
|
||||
ENV = ENV_YREG; \
|
||||
ENV_YREG = (CELL *)(((char *)ENV_YREG) + (*_PREG)->u.Osbpp.s); \
|
||||
(*_CPREG) = NEXTOP((*_PREG), Osbpp); \
|
||||
(*_PREG) = pt->CodeOfPred; \
|
||||
save_pc();
|
||||
|
||||
#ifdef DEPTH_LIMIT
|
||||
#define CALL_DEPTH_MINOR \
|
||||
FAILED = 0; \
|
||||
if (pt->ModuleOfPred) { \
|
||||
if (DEPTH == MkIntTerm(0)){ \
|
||||
YAAM_FAIL; \
|
||||
} else { \
|
||||
DEPTH = RESET_DEPTH(); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define CALL_DEPTH_MOFPRED \
|
||||
FAILED = 0; \
|
||||
DEPTH -= MkIntConstant(2);
|
||||
|
||||
#define CALL_DEPTH_END \
|
||||
FAILED = 0;
|
||||
#define CALL_DEPTH_MINOR \
|
||||
FAILED = 0; \
|
||||
if (pt->ModuleOfPred) { \
|
||||
if (DEPTH == MkIntTerm(0)) { \
|
||||
YAAM_FAIL; \
|
||||
} else { \
|
||||
DEPTH = RESET_DEPTH(); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define CALL_DEPTH_MOFPRED \
|
||||
FAILED = 0; \
|
||||
DEPTH -= MkIntConstant(2);
|
||||
|
||||
#define CALL_DEPTH_END FAILED = 0;
|
||||
#endif
|
||||
|
||||
#ifdef YAPOR
|
||||
#ifdef FROZEN_STACKS
|
||||
#ifdef YAPOR_SBA
|
||||
#define CALL_END_END \
|
||||
BLOCK = (CELL)CALL_END_END; \
|
||||
if (!FAILED) { \
|
||||
{ \
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) { \
|
||||
ENV_YREG = (CELL *) top_b; \
|
||||
} \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL) B; \
|
||||
SCH_check_requests(); \
|
||||
ALWAYS_GONext(); \
|
||||
#define CALL_END_END \
|
||||
BLOCK = (CELL)CALL_END_END; \
|
||||
if (!FAILED) { \
|
||||
{ \
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||
if (ENV_YREG > (CELL *)top_b || ENV_YREG < HR) { \
|
||||
ENV_YREG = (CELL *)top_b; \
|
||||
} \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL)B; \
|
||||
SCH_check_requests(); \
|
||||
ALWAYS_GONext(); \
|
||||
}
|
||||
#else /* YAPOR_SBA */
|
||||
#define CALL_END_END \
|
||||
BLOCK = (CELL)CALL_END_END; \
|
||||
if (!FAILED) { \
|
||||
{ \
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||
if (ENV_YREG > (CELL *) top_b) { \
|
||||
ENV_YREG = (CELL *) top_b; \
|
||||
} \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL) B; \
|
||||
SCH_check_requests(); \
|
||||
ALWAYS_GONext(); \
|
||||
#define CALL_END_END \
|
||||
BLOCK = (CELL)CALL_END_END; \
|
||||
if (!FAILED) { \
|
||||
{ \
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||
if (ENV_YREG > (CELL *)top_b) { \
|
||||
ENV_YREG = (CELL *)top_b; \
|
||||
} \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL)B; \
|
||||
SCH_check_requests(); \
|
||||
ALWAYS_GONext(); \
|
||||
}
|
||||
#endif /* YAPOR_SBA */
|
||||
#else /* FROZEN_STACKS */
|
||||
#define CALL_END_END \
|
||||
BLOCK = (CELL)CALL_END_END; \
|
||||
if (!FAILED) { \
|
||||
if (ENV_YREG > (CELL *) B) { \
|
||||
ENV_YREG = (CELL *) B; \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL) B; \
|
||||
SCH_check_requests(); \
|
||||
ALWAYS_GONext(); \
|
||||
#else /* FROZEN_STACKS */
|
||||
#define CALL_END_END \
|
||||
BLOCK = (CELL)CALL_END_END; \
|
||||
if (!FAILED) { \
|
||||
if (ENV_YREG > (CELL *)B) { \
|
||||
ENV_YREG = (CELL *)B; \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL)B; \
|
||||
SCH_check_requests(); \
|
||||
ALWAYS_GONext(); \
|
||||
}
|
||||
#endif /* FROZEN_STACKS */
|
||||
#else /* YAPOR */
|
||||
#else /* YAPOR */
|
||||
#ifdef FROZEN_STACKS
|
||||
#ifdef YAPOR_SBA
|
||||
#define CALL_END_END \
|
||||
BLOCK = (CELL)CALL_END_END; \
|
||||
if (!FAILED) { \
|
||||
{ \
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) { \
|
||||
ENV_YREG = (CELL *) top_b; \
|
||||
} \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL) B; \
|
||||
ALWAYS_GONext(); \
|
||||
#define CALL_END_END \
|
||||
BLOCK = (CELL)CALL_END_END; \
|
||||
if (!FAILED) { \
|
||||
{ \
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||
if (ENV_YREG > (CELL *)top_b || ENV_YREG < HR) { \
|
||||
ENV_YREG = (CELL *)top_b; \
|
||||
} \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL)B; \
|
||||
ALWAYS_GONext(); \
|
||||
}
|
||||
#else /* YAPOR_SBA */
|
||||
#define CALL_END_END \
|
||||
BLOCK = (CELL)CALL_END_END; \
|
||||
if (!FAILED) { \
|
||||
{ \
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||
if (ENV_YREG > (CELL *) top_b) { \
|
||||
ENV_YREG = (CELL *) top_b; \
|
||||
} \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL) B; \
|
||||
ALWAYS_GONext(); \
|
||||
#define CALL_END_END \
|
||||
BLOCK = (CELL)CALL_END_END; \
|
||||
if (!FAILED) { \
|
||||
{ \
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||
if (ENV_YREG > (CELL *)top_b) { \
|
||||
ENV_YREG = (CELL *)top_b; \
|
||||
} \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL)B; \
|
||||
ALWAYS_GONext(); \
|
||||
}
|
||||
#endif /* YAPOR_SBA */
|
||||
#else /* FROZEN_STACKS */
|
||||
#define CALL_END_END \
|
||||
BLOCK = (CELL)CALL_END_END; \
|
||||
if (!FAILED) { \
|
||||
if (ENV_YREG > (CELL *) B) { \
|
||||
ENV_YREG = (CELL *) B; \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL) B; \
|
||||
ALWAYS_GONext(); \
|
||||
#else /* FROZEN_STACKS */
|
||||
#define CALL_END_END \
|
||||
BLOCK = (CELL)CALL_END_END; \
|
||||
if (!FAILED) { \
|
||||
if (ENV_YREG > (CELL *)B) { \
|
||||
ENV_YREG = (CELL *)B; \
|
||||
} \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENV_YREG[E_CB] = (CELL)B; \
|
||||
ALWAYS_GONext(); \
|
||||
}
|
||||
#endif /* FROZEN_STACKS */
|
||||
#endif /* YAPOR */
|
||||
|
||||
#define PROCCEED_INSTINIT \
|
||||
print_instruction((*_PREG), ON_NATIVE); \
|
||||
BLOCKADDRESS = (CELL)(*_PREG); \
|
||||
CACHE_Y_AS_ENV(YREG); \
|
||||
(*_PREG) = (*_CPREG); \
|
||||
save_pc(); \
|
||||
ENV_YREG = ENV;
|
||||
|
||||
#define PROCCEED_INSTINIT \
|
||||
print_instruction((*_PREG), ON_NATIVE); \
|
||||
BLOCKADDRESS = (CELL)(*_PREG); \
|
||||
CACHE_Y_AS_ENV(YREG); \
|
||||
(*_PREG) = (*_CPREG); \
|
||||
save_pc(); \
|
||||
ENV_YREG = ENV;
|
||||
|
||||
#ifdef DEPTH_LIMIT
|
||||
#define PROCCEED_DEPTH \
|
||||
DEPTH = ENV_YREG[E_DEPTH];
|
||||
#define PROCCEED_DEPTH DEPTH = ENV_YREG[E_DEPTH];
|
||||
#endif
|
||||
|
||||
#define PROCCEED_END \
|
||||
BLOCK = (CELL)PROCCEED_END; \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENDCACHE_Y_AS_ENV(); \
|
||||
ALWAYS_GONext();
|
||||
#define PROCCEED_END \
|
||||
BLOCK = (CELL)PROCCEED_END; \
|
||||
WRITEBACK_Y_AS_ENV(); \
|
||||
ENDCACHE_Y_AS_ENV(); \
|
||||
ALWAYS_GONext();
|
||||
|
||||
#define ALLOCATE_INSTINIT \
|
||||
print_instruction((*_PREG), ON_NATIVE); \
|
||||
CACHE_Y_AS_ENV(YREG); \
|
||||
(*_PREG) = NEXTOP((*_PREG), e); \
|
||||
ENV_YREG[E_CP] = (CELL)(*_CPREG); \
|
||||
ENV_YREG[E_E] = (CELL)ENV;
|
||||
|
||||
#define ALLOCATE_INSTINIT \
|
||||
print_instruction((*_PREG), ON_NATIVE); \
|
||||
CACHE_Y_AS_ENV(YREG); \
|
||||
(*_PREG) = NEXTOP((*_PREG), e); \
|
||||
ENV_YREG[E_CP] = (CELL) (*_CPREG); \
|
||||
ENV_YREG[E_E] = (CELL) ENV;
|
||||
|
||||
#ifdef DEPTH_LIMIT
|
||||
#define ALLOCATE_DEPTH \
|
||||
ENV_YREG[E_DEPTH] = DEPTH;
|
||||
#define ALLOCATE_DEPTH ENV_YREG[E_DEPTH] = DEPTH;
|
||||
#endif
|
||||
|
||||
#define ALLOCATE_END \
|
||||
ENV = ENV_YREG; \
|
||||
ENDCACHE_Y_AS_ENV(); \
|
||||
GONext();
|
||||
#define ALLOCATE_END \
|
||||
ENV = ENV_YREG; \
|
||||
ENDCACHE_Y_AS_ENV(); \
|
||||
GONext();
|
||||
|
||||
#define DEALLOCATE_INSTINIT \
|
||||
print_instruction((*_PREG), ON_NATIVE); \
|
||||
#define DEALLOCATE_INSTINIT print_instruction((*_PREG), ON_NATIVE);
|
||||
|
||||
#define DEALLOCATE_POST_CHECK \
|
||||
CACHE_Y_AS_ENV(YREG); \
|
||||
(*_PREG) = NEXTOP((*_PREG), p); \
|
||||
(*_SREG) = YREG; \
|
||||
(*_CPREG) = (yamop *)ENV_YREG[E_CP]; \
|
||||
ENV = ENV_YREG = (CELL *)ENV_YREG[E_E];
|
||||
|
||||
#define DEALLOCATE_POST_CHECK \
|
||||
CACHE_Y_AS_ENV(YREG); \
|
||||
(*_PREG) = NEXTOP((*_PREG), p); \
|
||||
(*_SREG) = YREG; \
|
||||
(*_CPREG) = (yamop *) ENV_YREG[E_CP]; \
|
||||
ENV = ENV_YREG = (CELL *) ENV_YREG[E_E];
|
||||
|
||||
#ifdef DEPTH_LIMIT
|
||||
#define DEALLOCATE_DEPTH \
|
||||
DEPTH = ENV_YREG[E_DEPTH];
|
||||
#define DEALLOCATE_DEPTH DEPTH = ENV_YREG[E_DEPTH];
|
||||
#endif
|
||||
|
||||
#ifdef FROZEN_STACKS
|
||||
#ifdef YAPOR_SBA
|
||||
#define DEALLOCATE_FROZEN \
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||
if (ENV_YREG > (CELL *) top_b || ENV_YREG < HR) \
|
||||
ENV_YREG = (CELL *) top_b; \
|
||||
else \
|
||||
ENV_YREG = (CELL *)((CELL) ENV_YREG + ENV_Size(CPREG));
|
||||
#define DEALLOCATE_FROZEN \
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||
if (ENV_YREG > (CELL *)top_b || ENV_YREG < HR) \
|
||||
ENV_YREG = (CELL *)top_b; \
|
||||
else \
|
||||
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size(CPREG));
|
||||
#else /* YAPOR_SBA */
|
||||
#define DEALLOCATE_FROZEN \
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||
if (ENV_YREG > (CELL *) top_b) \
|
||||
ENV_YREG = (CELL *) top_b; \
|
||||
else \
|
||||
ENV_YREG = (CELL *)((CELL) ENV_YREG + ENV_Size(CPREG));
|
||||
#define DEALLOCATE_FROZEN \
|
||||
choiceptr top_b = PROTECT_FROZEN_B(B); \
|
||||
if (ENV_YREG > (CELL *)top_b) \
|
||||
ENV_YREG = (CELL *)top_b; \
|
||||
else \
|
||||
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size(CPREG));
|
||||
#endif /* YAPOR_SBA */
|
||||
#else /* FROZEN_STACKS */
|
||||
#define DEALLOCATE_FROZEN \
|
||||
if (ENV_YREG > (CELL *) B) \
|
||||
ENV_YREG = (CELL *) B; \
|
||||
else \
|
||||
ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size(CPREG));
|
||||
#else /* FROZEN_STACKS */
|
||||
#define DEALLOCATE_FROZEN \
|
||||
if (ENV_YREG > (CELL *)B) \
|
||||
ENV_YREG = (CELL *)B; \
|
||||
else \
|
||||
ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size(CPREG));
|
||||
#endif /* FROZEN_STACKS */
|
||||
|
||||
#define DEALLOCATE_POST_FROZEN \
|
||||
WRITEBACK_Y_AS_ENV();
|
||||
|
||||
#define DEALLOCATE_END \
|
||||
ENDCACHE_Y_AS_ENV(); \
|
||||
GONext();
|
||||
#define DEALLOCATE_POST_FROZEN WRITEBACK_Y_AS_ENV();
|
||||
|
||||
#define DEALLOCATE_END \
|
||||
ENDCACHE_Y_AS_ENV(); \
|
||||
GONext();
|
||||
|
@ -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
|
||||
@ -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)
|
||||
##
|
||||
#
|
||||
if (WIN32)
|
||||
if (WIN320)
|
||||
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_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 )
|
||||
|
@ -1153,9 +1153,10 @@ HTML_STYLESHEET =
|
||||
# list). For an example see the documentation.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
HTML_EXTRA_STYLESHEET = @CMAKE_SOURCE_DIR@/docs/custom/customdoxygen.css \
|
||||
@CMAKE_SOURCE_DIR@/docs/custom/pygments.css \
|
||||
@CMAKE_SOURCE_DIR@/docs/solarized-light.css
|
||||
HTML_EXTRA_STYLESHEET = \
|
||||
@CMAKE_SOURCE_DIR@/docs/custom/customdoxygen.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
|
||||
# other source files which should be copied to the HTML output directory. Note
|
||||
|
@ -29,7 +29,7 @@ interface.
|
||||
+ @ref sicsatts
|
||||
+ @ref New_Style_Attribute_Declarations
|
||||
+ @ref AttributedVariables_Builtins
|
||||
+ @ref corout
|
||||
+ @ref CohYroutining
|
||||
|
||||
### 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
|
||||
argument is bound.
|
||||
|
||||
|
||||
The following primitives can be used:
|
||||
|
||||
- freeze/2
|
||||
@ -385,6 +384,7 @@ The following primitives can be used:
|
||||
|
||||
- frozen/2
|
||||
|
||||
See @ref attscorouts for more details.
|
||||
|
||||
@}
|
||||
|
||||
|
@ -26,7 +26,8 @@
|
||||
`use_module(library(dbusage))` command.
|
||||
*/
|
||||
|
||||
/** @pred db_usage
|
||||
/** @pred db_usage
|
||||
|
||||
Give general overview of data-base usage in the system.
|
||||
*/
|
||||
db_usage :-
|
||||
|
@ -309,7 +309,7 @@ flag_group_chk(FlagGroup):-
|
||||
flag_type(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(atom, atom, true).
|
||||
flags_type_definition(atomic, atomic, true).
|
||||
@ -586,4 +586,4 @@ defined_flag(FlagName, FlagGroup, FlagType, DefaultValue, Description, Access, H
|
||||
nonvar(FlagName), nonvar(FlagGroup),
|
||||
'$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
|
||||
* taking the first solution. The _Tag_ must be an atom or a string.
|
||||
|
@ -3,10 +3,10 @@
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
|
||||
* @author Jan Wielemaker
|
||||
* @date Wed Nov 18 00:11:41 2015
|
||||
*
|
||||
*
|
||||
* @brief Red-Black trees
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@ -44,6 +44,8 @@
|
||||
rb_key_fold/4,
|
||||
list_to_rbtree/2,
|
||||
ord_list_to_rbtree/2,
|
||||
keys_to_rbtree/2,
|
||||
ord_keys_to_rbtree/2,
|
||||
is_rbtree/1,
|
||||
rb_size/2,
|
||||
rb_in/3
|
||||
@ -99,7 +101,7 @@ form colour(Left, Key, Value, Right), where _colour_ is one of =red= or
|
||||
% create an empty tree.
|
||||
%
|
||||
% Create a new Red-Black tree.
|
||||
%
|
||||
%
|
||||
% @deprecated Use rb_empty/1.
|
||||
|
||||
rb_new(t(Nil,Nil)) :- Nil = black('',_,_,'').
|
||||
@ -148,7 +150,7 @@ min(red(Right,_,_,_), Key, Val) :-
|
||||
min(black(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.
|
||||
|
||||
@ -185,7 +187,7 @@ next(<, K, _, _, NK, V, Tree, Candidate) :-
|
||||
next(NTree,K,NK,V,Candidate).
|
||||
next(=, _, _, _, NK, Val, Tree, Candidate) :-
|
||||
arg(4,Tree,NTree),
|
||||
(
|
||||
(
|
||||
min(NTree, NK, Val)
|
||||
-> true
|
||||
;
|
||||
@ -215,7 +217,7 @@ previous(<, K, KA, VA, NK, V, Tree, _) :-
|
||||
previous(NTree,K,NK,V,KA-VA).
|
||||
previous(=, _, _, _, K, Val, Tree, Candidate) :-
|
||||
arg(1,Tree,NTree),
|
||||
(
|
||||
(
|
||||
max(NTree, K, Val)
|
||||
-> true
|
||||
;
|
||||
@ -293,7 +295,7 @@ rewrite(Node, Key, OldVal, Val) :-
|
||||
compare(Cmp,Key0,Key),
|
||||
(
|
||||
Cmp == (=)
|
||||
->
|
||||
->
|
||||
OldVal = Val0,
|
||||
setarg(3, Node, Val)
|
||||
;
|
||||
@ -421,7 +423,7 @@ insert(Tree0,Key,Val,Nil,Tree) :-
|
||||
fix_root(TreeI,Tree).
|
||||
|
||||
%
|
||||
% Cormen et al present the algorithm as
|
||||
% Cormen et al present the algorithm as
|
||||
% (1) standard tree insertion;
|
||||
% (2) from the viewpoint of the newly inserted node:
|
||||
% partially fix the tree;
|
||||
@ -486,7 +488,7 @@ insert_new(Tree0,Key,Val,Nil,Tree) :-
|
||||
fix_root(TreeI,Tree).
|
||||
|
||||
%
|
||||
% actual insertion, copied from insert2
|
||||
% actual insertion, copied from insert2
|
||||
%
|
||||
insert_new_2(black('',_,_,''), K, V, Nil, T, Status) :- !,
|
||||
T = red(Nil,K,V,Nil),
|
||||
@ -610,8 +612,8 @@ pretty_print(black(L,K,_,R),D) :-
|
||||
rb_delete(t(Nil,T), K, t(Nil,NT)) :-
|
||||
delete(T, K, _, NT, _).
|
||||
|
||||
%% rb_delete(+T, +Key, -TN).
|
||||
%% rb_delete(+T, +Key, -Val, -TN).
|
||||
%% @pred rb_delete(+T, +Key, -TN).
|
||||
%% @pred rb_delete(+T, +Key, -Val, -TN).
|
||||
%
|
||||
% Delete element with key Key from the tree T, returning the value
|
||||
% Val associated with the key and a new tree TN.
|
||||
@ -646,7 +648,7 @@ delete(black(L,_,V,R), _, V, OUT, Flag) :-
|
||||
% K == K0,
|
||||
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,
|
||||
% 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).
|
||||
|
||||
|
||||
%% 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
|
||||
% Key, the value Val associated with the key and a new tree TN.
|
||||
@ -690,8 +692,8 @@ del_max(black(L,K0,V0,R), K, V, Nil, NT, Flag) :-
|
||||
delete_red_node(L1,L2,L1,done) :- L1 == L2, !.
|
||||
delete_red_node(black('',_,_,''),R,R,done) :- !.
|
||||
delete_red_node(L,black('',_,_,''),L,done) :- !.
|
||||
delete_red_node(L,R,OUT,Done) :-
|
||||
delete_next(R,NK,NV,NR,Done0),
|
||||
delete_red_node(L,R,OUT,Done) :-
|
||||
delete_next(R,NK,NV,NR,Done0),
|
||||
fixup_right(Done0,red(L,NK,NV,NR),OUT,Done).
|
||||
|
||||
|
||||
@ -964,8 +966,8 @@ partial_map(T,[],[],_,_,T) :- !.
|
||||
partial_map(black('',_,_,_),Map,Map,Nil,_,Nil) :- !.
|
||||
partial_map(red(L,K,V,R),Map,MapF,Nil,Goal,red(NL,K,NV,NR)) :-
|
||||
partial_map(L,Map,MapI,Nil,Goal,NL),
|
||||
(
|
||||
MapI == [] ->
|
||||
(
|
||||
MapI == [] ->
|
||||
NR = R, NV = V, MapF = []
|
||||
;
|
||||
MapI = [K1|MapR],
|
||||
@ -982,8 +984,8 @@ partial_map(red(L,K,V,R),Map,MapF,Nil,Goal,red(NL,K,NV,NR)) :-
|
||||
).
|
||||
partial_map(black(L,K,V,R),Map,MapF,Nil,Goal,black(NL,K,NV,NR)) :-
|
||||
partial_map(L,Map,MapI,Nil,Goal,NL),
|
||||
(
|
||||
MapI == [] ->
|
||||
(
|
||||
MapI == [] ->
|
||||
NR = R, NV = V, MapF = []
|
||||
;
|
||||
MapI = [K1|MapR],
|
||||
@ -1023,13 +1025,31 @@ keys(black(L,K,_,R),L0,Lf) :-
|
||||
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.
|
||||
%
|
||||
% T is the red-black tree corresponding to the mapping in list L.
|
||||
|
||||
list_to_rbtree(List, T) :-
|
||||
sort(List,Sorted),
|
||||
ord_list_to_rbtree(Sorted, 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),
|
||||
ord_list_to_rbtree(Sorted, T).
|
||||
|
||||
%% ord_list_to_rbtree(+L, -T) is det.
|
||||
%
|
||||
@ -1084,7 +1104,7 @@ size(black(L,_,_,R),Sz0,Szf) :-
|
||||
%% is_rbtree(?Term) is semidet.
|
||||
%
|
||||
% True if Term is a valid Red-Black tree.
|
||||
%
|
||||
%
|
||||
% @tbd Catch variables.
|
||||
is_rbtree(X) :-
|
||||
var(X), !, fail.
|
||||
@ -1111,7 +1131,7 @@ rbtree1(black(L,K,_,R)) :-
|
||||
check_rbtree(R,K,+inf,Bls).
|
||||
rbtree1(red(_,_,_,_)) :-
|
||||
throw(msg("root should be black",[])).
|
||||
|
||||
|
||||
|
||||
find_path_blacks(black('',_,_,''), Bls, Bls) :- !.
|
||||
find_path_blacks(black(L,_,_,_), Bls0, Bls) :-
|
||||
@ -1139,7 +1159,7 @@ check_height(Bls0,Min,Max) :-
|
||||
throw(msg("Unbalance ~d between ~w and ~w~n",[Bls0,Min,Max])).
|
||||
|
||||
check_val(K, Min, Max) :- ( K @> Min ; Min == -inf), (K @< Max ; Max == +inf), !.
|
||||
check_val(K, Min, Max) :-
|
||||
check_val(K, Min, Max) :-
|
||||
throw(msg("not ordered: ~w not between ~w and ~w~n",[K,Min,Max])).
|
||||
|
||||
check_red_child(black(_,_,_,_)).
|
||||
@ -1164,7 +1184,7 @@ test_pos :-
|
||||
clean_tree(1,N,T,_),
|
||||
bclean_tree(N,1,T,_),
|
||||
count(1,N,X), ( rb_delete(T,X,TF) -> true ; abort ),
|
||||
% pretty_print(TF),
|
||||
% pretty_print(TF),
|
||||
rbtree(TF),
|
||||
% format("done ~d~n",[X]),
|
||||
fail.
|
||||
@ -1210,7 +1230,7 @@ test_neg :-
|
||||
clean_tree(MSize,-1,T,_),
|
||||
bclean_tree(-1,MSize,T,_),
|
||||
count(1,Size,X), NX is -X, ( rb_delete(T,NX,TF) -> true ; abort ),
|
||||
% pretty_print(TF),
|
||||
% pretty_print(TF),
|
||||
rbtree(TF),
|
||||
% format("done ~d~n",[X]),
|
||||
fail.
|
||||
@ -1229,7 +1249,7 @@ build_ntree(X1,X,T0,TF) :-
|
||||
|
||||
|
||||
|
||||
/** @pred rb_apply(+ _T_,+ _Key_,+ _G_,- _TN_)
|
||||
/** @pred rb_apply(+ _T_,+ _Key_,+ _G_,- _TN_)
|
||||
|
||||
|
||||
If the value associated with key _Key_ is _Val0_ in _T_, and
|
||||
@ -1238,58 +1258,58 @@ if `call(G,Val0,ValF)` holds, then _TN_ differs from
|
||||
tree _TN_. Fails if it cannot find _Key_ in _T_, or if
|
||||
`call(G,Val0,ValF)` is not satisfiable.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_clone(+ _T_,+ _NT_,+ _Nodes_)
|
||||
/** @pred rb_clone(+ _T_,+ _NT_,+ _Nodes_)
|
||||
|
||||
|
||||
=Clone= the red-back tree into a new tree with the same keys as the
|
||||
original but with all values set to unbound values. _Nodes_ is a list
|
||||
containing all new nodes as pairs _K-V_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred 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
|
||||
_Key_, the value _Val_ associated with the key and a new tree
|
||||
_TN_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred 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_, the value _Val_ associated with the key and a new tree
|
||||
_TN_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_delete(+ _T_,+ _Key_,- _TN_)
|
||||
/** @pred rb_delete(+ _T_,+ _Key_,- _TN_)
|
||||
|
||||
|
||||
Delete element with key _Key_ from the tree _T_, returning a new
|
||||
tree _TN_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_delete(+ _T_,+ _Key_,- _Val_,- _TN_)
|
||||
|
||||
Delete element with key _Key_ from the tree _T_, returning the
|
||||
value _Val_ associated with the key and a new tree _TN_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_empty(? _T_)
|
||||
/** @pred rb_empty(? _T_)
|
||||
|
||||
|
||||
Succeeds if tree _T_ is empty.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_fold(+ _T_,+ _G_,+ _Acc0_, - _AccF_)
|
||||
/** @pred rb_fold(+ _T_,+ _G_,+ _Acc0_, - _AccF_)
|
||||
|
||||
|
||||
For all nodes _Key_ in the tree _T_, if the value
|
||||
@ -1299,9 +1319,9 @@ previous node in inorder, `call(G,VL,_,Acc0)` must hold, and if
|
||||
_VR_ is the value of the next node in inorder,
|
||||
`call(G,VR,Acc1,_)` must hold.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_insert(+ _T0_,+ _Key_,? _Value_,+ _TF_)
|
||||
/** @pred rb_insert(+ _T0_,+ _Key_,? _Value_,+ _TF_)
|
||||
|
||||
|
||||
Add an element with key _Key_ and _Value_ to the tree
|
||||
@ -1312,9 +1332,9 @@ Add a new element with key _Key_ and _Value_ to the tree
|
||||
_T0_ creating a new red-black tree _TF_. Fails is an element
|
||||
with _Key_ exists in the tree.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_key_fold(+ _T_,+ _G_,+ _Acc0_, - _AccF_)
|
||||
/** @pred rb_key_fold(+ _T_,+ _G_,+ _Acc0_, - _AccF_)
|
||||
|
||||
|
||||
For all nodes _Key_ in the tree _T_, if the value
|
||||
@ -1324,33 +1344,33 @@ previous node in inorder, `call(G,KeyL,VL,_,Acc0)` must hold, and if
|
||||
_VR_ is the value of the next node in inorder,
|
||||
`call(G,KeyR,VR,Acc1,_)` must hold.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_keys(+ _T_,+ _Keys_)
|
||||
/** @pred rb_keys(+ _T_,+ _Keys_)
|
||||
|
||||
|
||||
_Keys_ is an infix visit with all keys in tree _T_. Keys will be
|
||||
sorted, but may be duplicate.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_lookup(+ _Key_,- _Value_,+ _T_)
|
||||
/** @pred rb_lookup(+ _Key_,- _Value_,+ _T_)
|
||||
|
||||
|
||||
Backtrack through all elements with key _Key_ in the red-black tree
|
||||
_T_, returning for each the value _Value_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_lookupall(+ _Key_,- _Value_,+ _T_)
|
||||
/** @pred rb_lookupall(+ _Key_,- _Value_,+ _T_)
|
||||
|
||||
|
||||
Lookup all elements with key _Key_ in the red-black tree
|
||||
_T_, returning the value _Value_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_map(+ _T_,+ _G_,- _TN_)
|
||||
/** @pred rb_map(+ _T_,+ _G_,- _TN_)
|
||||
|
||||
|
||||
For all nodes _Key_ in the tree _T_, if the value associated with
|
||||
@ -1359,38 +1379,38 @@ key _Key_ is _Val0_ in tree _T_, and if
|
||||
in _TN_ is _ValF_. Fails if or if `call(G,Val0,ValF)` is not
|
||||
satisfiable for all _Var0_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_max(+ _T_,- _Key_,- _Value_)
|
||||
/** @pred rb_max(+ _T_,- _Key_,- _Value_)
|
||||
|
||||
|
||||
_Key_ is the maximal key in _T_, and is associated with _Val_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_min(+ _T_,- _Key_,- _Value_)
|
||||
/** @pred rb_min(+ _T_,- _Key_,- _Value_)
|
||||
|
||||
|
||||
_Key_ is the minimum key in _T_, and is associated with _Val_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_new(? _T_)
|
||||
/** @pred rb_new(? _T_)
|
||||
|
||||
|
||||
Create a new tree.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_next(+ _T_, + _Key_,- _Next_,- _Value_)
|
||||
/** @pred rb_next(+ _T_, + _Key_,- _Next_,- _Value_)
|
||||
|
||||
|
||||
_Next_ is the next element after _Key_ in _T_, and is
|
||||
associated with _Val_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_partial_map(+ _T_,+ _Keys_,+ _G_,- _TN_)
|
||||
/** @pred rb_partial_map(+ _T_,+ _Keys_,+ _G_,- _TN_)
|
||||
|
||||
|
||||
For all nodes _Key_ in _Keys_, if the value associated with key
|
||||
@ -1399,39 +1419,38 @@ holds, then the value associated with _Key_ in _TN_ is
|
||||
_ValF_. Fails if or if `call(G,Val0,ValF)` is not satisfiable
|
||||
for all _Var0_. Assumes keys are not repeated.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_previous(+ _T_, + _Key_,- _Previous_,- _Value_)
|
||||
/** @pred rb_previous(+ _T_, + _Key_,- _Previous_,- _Value_)
|
||||
|
||||
|
||||
_Previous_ is the previous element after _Key_ in _T_, and is
|
||||
associated with _Val_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_size(+ _T_,- _Size_)
|
||||
/** @pred rb_size(+ _T_,- _Size_)
|
||||
|
||||
|
||||
_Size_ is the number of elements in _T_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_update(+ _T_,+ _Key_,+ _NewVal_,- _TN_)
|
||||
/** @pred rb_update(+ _T_,+ _Key_,+ _NewVal_,- _TN_)
|
||||
|
||||
|
||||
Tree _TN_ is tree _T_, but with value for _Key_ associated
|
||||
with _NewVal_. Fails if it cannot find _Key_ in _T_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/** @pred rb_visit(+ _T_,- _Pairs_)
|
||||
/** @pred rb_visit(+ _T_,- _Pairs_)
|
||||
|
||||
|
||||
_Pairs_ is an infix visit of tree _T_, where each element of
|
||||
_Pairs_ is of the form _K_- _Val_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
%%! @}
|
||||
|
||||
%%! @}
|
||||
|
@ -18,7 +18,9 @@
|
||||
static char SccsId[] = "%W% %G%";
|
||||
#endif
|
||||
|
||||
/*
|
||||
/** @file readline.c
|
||||
*
|
||||
*
|
||||
* This file includes the interface to the readline library, if installed in the
|
||||
*system.
|
||||
*
|
||||
@ -339,22 +341,22 @@ static bool getLine(int inp) {
|
||||
/* window of vulnerability opened */
|
||||
LOCAL_PrologMode |= ConsoleGetcMode;
|
||||
if (Yap_DoPrompt(s)) { // no output so far
|
||||
rl_set_signals();
|
||||
myrl_line = (unsigned char *)readline(LOCAL_Prompt);
|
||||
s->stream_getc = ReadlineGetc;
|
||||
} else {
|
||||
rl_clear_signals();
|
||||
} else {
|
||||
rl_set_signals();
|
||||
myrl_line = (unsigned char *)readline(NULL);
|
||||
rl_clear_signals();
|
||||
}
|
||||
/* Do it the gnu way */
|
||||
LOCAL_PrologMode &= ~ConsoleGetcMode;
|
||||
if (rl_pending_signal()) {
|
||||
LOCAL_PrologMode |= InterruptMode;
|
||||
}
|
||||
if (LOCAL_PrologMode & InterruptMode) {
|
||||
Yap_external_signal(0, YAP_INT_SIGNAL);
|
||||
LOCAL_PrologMode &= ~ConsoleGetcMode;
|
||||
if (LOCAL_PrologMode & AbortMode) {
|
||||
Yap_Error(ABORT_EVENT, TermNil, "");
|
||||
LOCAL_ErrorMessage = "Abort";
|
||||
return console_post_process_eof(s);
|
||||
}
|
||||
Yap_HandleSIGINT();
|
||||
} else {
|
||||
LOCAL_PrologMode &= ~ConsoleGetcMode;
|
||||
LOCAL_newline = true;
|
||||
}
|
||||
strncpy(LOCAL_Prompt, RepAtom(LOCAL_AtPrompt)->StrOfAE, MAX_PROMPT);
|
||||
@ -437,7 +439,6 @@ int Yap_ReadlineForSIGINT(void) {
|
||||
int ch;
|
||||
StreamDesc *s = &GLOBAL_Stream[StdInStream];
|
||||
const unsigned char *myrl_line = s->u.irl.buf;
|
||||
|
||||
if ((LOCAL_PrologMode & ConsoleGetcMode) && myrl_line != NULL) {
|
||||
ch = myrl_line[0];
|
||||
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) {
|
||||
CACHE_REGS
|
||||
LOCAL_PrologMode |= InterruptMode;
|
||||
printf("11ooo\n");
|
||||
my_signal(s, ReceiveSignal);
|
||||
if (s == SIGINT && (LOCAL_PrologMode & ConsoleGetcMode)) {
|
||||
return;
|
||||
}
|
||||
my_signal(s, ReceiveSignal);
|
||||
switch (s) {
|
||||
case SIGINT:
|
||||
// always direct SIGINT to console
|
||||
|
@ -16,6 +16,7 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//=============================================================================
|
||||
|
||||
|
||||
static YAP_Term gecode_RM_NONE;
|
||||
static YAP_Term gecode_RM_CONSTANT;
|
||||
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)
|
||||
{
|
||||
return YAP_Error("SYSTEN_ERROR", TermNil, "Unsupported"); /*
|
||||
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
||||
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);
|
||||
when(*space,X2,X3,X4);
|
||||
return TRUE; */
|
||||
return false;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static YAP_Bool gecode_constraint_when_457(void)
|
||||
{
|
||||
return YAP_Error("SYSTEN_ERROR", TermNil, "Unsupported"); /*
|
||||
|
||||
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
||||
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)> X4 = gecode_std::function<void(Space&home)>_from_term(YAP_ARG4);
|
||||
std::function<void(Space&home)> X3 = gecode_StdFunctionSpace_from_term(YAP_ARG3);
|
||||
std::function<void(Space&home)> X4 = gecode_StdFunctionSpace_from_term(YAP_ARG4);
|
||||
when(*space,X2,X3,X4);
|
||||
return TRUE;*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static YAP_Bool gecode_constraint_cardinality_71(void)
|
||||
{
|
||||
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
||||
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);
|
||||
cardinality(*space,X2,X3,X4);
|
||||
return TRUE;
|
||||
@ -2247,7 +2244,7 @@ static YAP_Bool gecode_constraint_when_455(void)
|
||||
{
|
||||
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
||||
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);
|
||||
return TRUE;
|
||||
}
|
||||
@ -2888,11 +2885,10 @@ static YAP_Bool gecode_constraint_channel_74(void)
|
||||
|
||||
static YAP_Bool gecode_constraint_when_458(void)
|
||||
{
|
||||
|
||||
GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
|
||||
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)> X4 = gecode_std::function<void(Space&home)>_from_term(YAP_ARG4);
|
||||
std::function<void(Space&home)> X3 = gecode_StdFunctionSpace_from_term(YAP_ARG3);
|
||||
std::function<void(Space&home)> X4 = gecode_StdFunctionSpace_from_term(YAP_ARG4);
|
||||
IntPropLevel X5 = gecode_IntPropLevel_from_term(YAP_ARG5);
|
||||
when(*space,X2,X3,X4,X5);
|
||||
return TRUE;
|
||||
@ -3145,7 +3141,7 @@ static YAP_Bool gecode_constraint_binpacking_40(void)
|
||||
static YAP_Bool gecode_constraint_branch_1(void)
|
||||
{
|
||||
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);
|
||||
return TRUE;
|
||||
}
|
||||
@ -5174,3 +5170,4 @@ static YAP_Bool gecode_constraint_ite_254(void)
|
||||
ite(*space,X2,X3,X4,X5,X6);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -554,7 +554,11 @@ class YAPEnumImpl(object):
|
||||
print
|
||||
|
||||
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 "{"
|
||||
for x in self.ENUM:
|
||||
print " if (X==gecode_%s) return %s;" % (x,x)
|
||||
@ -563,11 +567,16 @@ class YAPEnumImpl(object):
|
||||
print
|
||||
|
||||
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):
|
||||
|
||||
def generate(self):
|
||||
generate_space_function();
|
||||
for c in enum_classes():
|
||||
class C(c,YAPEnumImpl): pass
|
||||
o = C()
|
||||
@ -576,6 +585,7 @@ class YAPEnumImplGenerator(object):
|
||||
class YAPEnumForwardGenerator(object):
|
||||
|
||||
def generate(self):
|
||||
generate_space_function_forward();
|
||||
for c in enum_classes():
|
||||
class C(c,YAPEnumImpl): pass
|
||||
o = C()
|
||||
@ -642,12 +652,16 @@ class CCDescriptor(object):
|
||||
has_space = True
|
||||
else:
|
||||
extra = ""
|
||||
t2 = t
|
||||
if t in ("IntVar","BoolVar","SetVar","FloatVar","IntVarArgs","BoolVarArgs","SetVarArgs","FloatVarArgs"):
|
||||
extra = "space,"
|
||||
if has_space == False:
|
||||
print " GenericSpace* space = gecode_Space_from_term(%s);" % a
|
||||
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)
|
||||
i += 1
|
||||
print " %s(%s);" % (self.name, ",".join(args))
|
||||
|
@ -186,6 +186,18 @@ static inline BoolAssign&
|
||||
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
|
||||
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_MAX;
|
||||
static YAP_Term gecode_FLOAT_VAR_DEGREE_SIZE_MAX;
|
||||
static YAP_Term gecode_FLOAT_VAR_DEGREE_SIZE_MIN;
|
||||
|
||||
static inline FloatVarBranch
|
||||
gecode_FloatVarBranch_from_term(YAP_Term t)
|
||||
@ -386,7 +399,6 @@ static YAP_Term gecode_BOOL_VAR_RND;
|
||||
if (YAP_IsAtomTerm(t)) {
|
||||
if ( t == gecode_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)
|
||||
return FLOAT_VAR_SIZE_MAX();
|
||||
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 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
|
||||
predicates defined in the Prolog program source code, or from predicates
|
||||
defined in database as relations.
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Name = 'John Doe',
|
||||
Number = 123456789 ?
|
||||
yes
|
||||
@ -92,9 +92,6 @@ The MYDDAS Data-base interface {#myddas}
|
||||
|
||||
|
||||
@pred db view(+,+,+).
|
||||
|
||||
|
||||
|
||||
@pred db view(+,+).
|
||||
|
||||
|
||||
@ -186,9 +183,6 @@ The MYDDAS Data-base interface {#myddas}
|
||||
|
||||
|
||||
@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(+,?).
|
||||
|
||||
|
||||
|
||||
|
||||
The prototype for this predicate is the following:
|
||||
otype for this predicate is the following:
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
?- 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)`.
|
||||
|
||||
@pred db_my_sql_mode(+Conn,?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
|
||||
<http://www.mysql.org>.
|
||||
b
|
||||
|
@ -32,7 +32,9 @@ static PyObject *s_to_python(const char *s, bool eval, PyObject *p0) {
|
||||
Py_INCREF(o);
|
||||
return CHECKNULL(YAP_MkStringTerm(s), o);
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
@ -149,43 +151,65 @@ PyObject *term_to_python(term_t t, bool eval, PyObject *o) {
|
||||
arg = tail;
|
||||
out = PyList_New(len);
|
||||
if (!out) {
|
||||
PL_reset_term_refs(tail);
|
||||
return CHECKNULL(t, Py_None);
|
||||
PL_reset_term_refs(tail);
|
||||
YAPPy_ThrowError(SYSTEM_ERROR_INTERNAL, t, "list->python");
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!PL_get_list(t, arg, t)) {
|
||||
PL_reset_term_refs(tail);
|
||||
return Py_None;
|
||||
}
|
||||
a = term_to_python(arg, eval, o);
|
||||
if (a) {
|
||||
if (PyList_SetItem(out, i, a) < 0) {
|
||||
PL_reset_term_refs(tail);
|
||||
return Py_None;
|
||||
}
|
||||
}
|
||||
if (!PL_get_list(t, arg, t)) {
|
||||
PL_reset_term_refs(tail);
|
||||
YAPPy_ThrowError(SYSTEM_ERROR_INTERNAL, t, "list->python");
|
||||
}
|
||||
a = term_to_python(arg, eval, o);
|
||||
if (a) {
|
||||
if (PyList_SetItem(out, i, a) < 0) {
|
||||
PL_reset_term_refs(tail);
|
||||
YAPPy_ThrowError(SYSTEM_ERROR_INTERNAL, t, "list->python");
|
||||
}
|
||||
}
|
||||
}
|
||||
PL_reset_term_refs(tail);
|
||||
return CHECKNULL(t, out);
|
||||
} else {
|
||||
functor_t fun;
|
||||
atom_t name;
|
||||
int arity;
|
||||
PyObject *rc;
|
||||
|
||||
if (!PL_get_functor(t, &fun)) {
|
||||
PL_reset_term_refs(tail);
|
||||
return CHECKNULL(t, Py_None);
|
||||
PL_reset_term_refs(tail);
|
||||
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)
|
||||
rc = compound_to_pyeval(t, o);
|
||||
rc = compound_to_pyeval(t, o);
|
||||
else
|
||||
rc = compound_to_pytree(t, o);
|
||||
rc = compound_to_pytree(t, o);
|
||||
PL_reset_term_refs(tail);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
}
|
||||
return CHECKNULL(t, Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
void YAPPy_ThrowError__(const char *file, const char *function, int lineno,
|
||||
yap_error_number type, term_t where, ...);
|
||||
|
@ -698,7 +698,7 @@ static PyObject *structseq_repr(PyObject *iobj) {
|
||||
|
||||
PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
|
||||
PyObject *o;
|
||||
#if PY_MAJOR_VERSION >= 30
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
PyTypeObject *typp;
|
||||
PyObject *key = PyUnicode_FromString(s);
|
||||
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);
|
||||
Py_INCREF(typp);
|
||||
fprintf(stderr, "<<< %p\n",typp);
|
||||
arity_t i;
|
||||
for (i = 0; i < arity; i++) {
|
||||
PyObject *pArg = PyTuple_GET_ITEM(tuple, i);
|
||||
@ -750,493 +749,493 @@ PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static PyObject *bip_range(term_t t) {
|
||||
long ilow = 0, ihigh = 0, istep = 1;
|
||||
long bign;
|
||||
Py_ssize_t i, n;
|
||||
int arity;
|
||||
atom_t name;
|
||||
term_t arg = PL_new_term_ref();
|
||||
static PyObject *bip_range(term_t t) {
|
||||
long ilow = 0, ihigh = 0, istep = 1;
|
||||
long bign;
|
||||
Py_ssize_t i, n;
|
||||
int arity;
|
||||
atom_t name;
|
||||
term_t arg = PL_new_term_ref();
|
||||
|
||||
PyObject *v;
|
||||
PyObject *v;
|
||||
|
||||
if (!PL_get_name_arity(t, &name, &arity))
|
||||
return NULL;
|
||||
AOK(PL_get_arg(1, t, arg), NULL);
|
||||
ilow = get_int(arg, true);
|
||||
if (arity == 1) {
|
||||
ihigh = ilow;
|
||||
ilow = 0;
|
||||
} else {
|
||||
AOK(PL_get_arg(2, t, arg), NULL);
|
||||
ihigh = get_int(arg, true);
|
||||
if (arity == 3) {
|
||||
AOK(PL_get_arg(3, t, arg), NULL);
|
||||
istep = get_int(arg, true);
|
||||
}
|
||||
}
|
||||
if (istep == 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "range() step argument must not be zero");
|
||||
return NULL;
|
||||
}
|
||||
if (istep > 0)
|
||||
bign = get_len_of_range(ilow, ihigh, istep);
|
||||
else
|
||||
bign = get_len_of_range(ihigh, ilow, -istep);
|
||||
n = (Py_ssize_t)bign;
|
||||
AOK(((bign >= 0 && (long)n == bign) || "range() result has too many items"),
|
||||
NULL);
|
||||
v = PyList_New(n);
|
||||
if (!PL_get_name_arity(t, &name, &arity))
|
||||
return NULL;
|
||||
AOK(PL_get_arg(1, t, arg), NULL);
|
||||
ilow = get_int(arg, true);
|
||||
if (arity == 1) {
|
||||
ihigh = ilow;
|
||||
ilow = 0;
|
||||
} else {
|
||||
AOK(PL_get_arg(2, t, arg), NULL);
|
||||
ihigh = get_int(arg, true);
|
||||
if (arity == 3) {
|
||||
AOK(PL_get_arg(3, t, arg), NULL);
|
||||
istep = get_int(arg, true);
|
||||
}
|
||||
}
|
||||
if (istep == 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "range() step argument must not be zero");
|
||||
return NULL;
|
||||
}
|
||||
if (istep > 0)
|
||||
bign = get_len_of_range(ilow, ihigh, istep);
|
||||
else
|
||||
bign = get_len_of_range(ihigh, ilow, -istep);
|
||||
n = (Py_ssize_t)bign;
|
||||
AOK(((bign >= 0 && (long)n == bign) || "range() result has too many items"),
|
||||
NULL);
|
||||
v = PyList_New(n);
|
||||
|
||||
if (v == NULL)
|
||||
return Py_None;
|
||||
for (i = 0; i < n; i++) {
|
||||
if (v == NULL)
|
||||
return Py_None;
|
||||
for (i = 0; i < n; i++) {
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
PyObject *w = PyInt_FromLong(ilow);
|
||||
PyObject *w = PyInt_FromLong(ilow);
|
||||
#else
|
||||
PyObject *w = PyLong_FromLong(ilow);
|
||||
PyObject *w = PyLong_FromLong(ilow);
|
||||
#endif
|
||||
if (w == NULL) {
|
||||
Py_DECREF(v);
|
||||
return NULL;
|
||||
}
|
||||
PyList_SET_ITEM(v, i, w);
|
||||
Py_INCREF(w);
|
||||
ilow += istep;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
if (w == NULL) {
|
||||
Py_DECREF(v);
|
||||
return NULL;
|
||||
}
|
||||
PyList_SET_ITEM(v, i, w);
|
||||
Py_INCREF(w);
|
||||
ilow += istep;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
static bool copy_to_dictionary(PyObject *dict, term_t targ, term_t taux,
|
||||
bool eval) {
|
||||
PyObject *lhs, *rhs;
|
||||
term_t tleft = PL_new_term_ref(), tright = PL_new_term_ref();
|
||||
static bool copy_to_dictionary(PyObject *dict, term_t targ, term_t taux,
|
||||
bool eval) {
|
||||
PyObject *lhs, *rhs;
|
||||
term_t tleft = PL_new_term_ref(), tright = PL_new_term_ref();
|
||||
|
||||
functor_t fun;
|
||||
functor_t fun;
|
||||
|
||||
AOK(PL_get_functor(targ, &fun), false);
|
||||
while (fun == FUNCTOR_comma2) {
|
||||
AOK(PL_get_arg(1, targ, tleft), false);
|
||||
if (!copy_to_dictionary(dict, tleft, taux, eval))
|
||||
return false;
|
||||
AOK(PL_get_arg(2, targ, targ), false);
|
||||
return copy_to_dictionary(dict, tright, taux, eval);
|
||||
}
|
||||
// PyObject_Print(dict, stderr, 0); fprintf(stderr,"\n");
|
||||
// Py_DECREF(lhs);
|
||||
// Py_DECREF(rhs);
|
||||
AOK(PL_get_functor(targ, &fun), false);
|
||||
while (fun == FUNCTOR_comma2) {
|
||||
AOK(PL_get_arg(1, targ, tleft), false);
|
||||
if (!copy_to_dictionary(dict, tleft, taux, eval))
|
||||
return false;
|
||||
AOK(PL_get_arg(2, targ, targ), false);
|
||||
return copy_to_dictionary(dict, tright, taux, eval);
|
||||
}
|
||||
// PyObject_Print(dict, stderr, 0); fprintf(stderr,"\n");
|
||||
// Py_DECREF(lhs);
|
||||
// Py_DECREF(rhs);
|
||||
|
||||
AOK(PL_get_arg(1, targ, tleft), false);
|
||||
lhs = atom_to_python_string(tleft);
|
||||
if (lhs == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
AOK(PL_get_arg(2, targ, tright), false);
|
||||
rhs = term_to_python(tright, eval, NULL);
|
||||
if (rhs == NULL) {
|
||||
PyErr_Print();
|
||||
return false;
|
||||
}
|
||||
return PyDict_SetItem(dict, lhs, rhs) >= 0;
|
||||
// PyObject_Print(dict, stderr, 0); fprintf(stderr,"\n");
|
||||
// Py_DECREF(lhs);
|
||||
// Py_DECREF(rhs);
|
||||
}
|
||||
AOK(PL_get_arg(1, targ, tleft), false);
|
||||
lhs = atom_to_python_string(tleft);
|
||||
if (lhs == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
AOK(PL_get_arg(2, targ, tright), false);
|
||||
rhs = term_to_python(tright, eval, NULL);
|
||||
if (rhs == NULL) {
|
||||
PyErr_Print();
|
||||
return false;
|
||||
}
|
||||
return PyDict_SetItem(dict, lhs, rhs) >= 0;
|
||||
// PyObject_Print(dict, stderr, 0); fprintf(stderr,"\n");
|
||||
// Py_DECREF(lhs);
|
||||
// Py_DECREF(rhs);
|
||||
}
|
||||
|
||||
PyObject *compound_to_data(term_t t, PyObject *o, functor_t fun, bool exec) {
|
||||
atom_t name;
|
||||
int len;
|
||||
PyObject *compound_to_data(term_t t, PyObject *o, functor_t fun, bool exec) {
|
||||
atom_t name;
|
||||
int len;
|
||||
|
||||
AOK(PL_get_name_arity(t, &name, &len), o);
|
||||
AOK(PL_get_name_arity(t, &name, &len), o);
|
||||
|
||||
if (fun == FUNCTOR_pointer1) {
|
||||
void *ptr;
|
||||
if (fun == FUNCTOR_pointer1) {
|
||||
void *ptr;
|
||||
|
||||
AOK(PL_get_arg(1, t, t), NULL);
|
||||
AOK(PL_get_pointer(t, &ptr), NULL)
|
||||
/* return __main__,s */
|
||||
return (PyObject *)ptr;
|
||||
}
|
||||
if (name == ATOM_t) {
|
||||
term_t targ = PL_new_term_ref();
|
||||
PyObject *out;
|
||||
int i;
|
||||
AOK(PL_get_arg(1, t, t), NULL);
|
||||
AOK(PL_get_pointer(t, &ptr), NULL)
|
||||
/* return __main__,s */
|
||||
return (PyObject *)ptr;
|
||||
}
|
||||
if (name == ATOM_t) {
|
||||
term_t targ = PL_new_term_ref();
|
||||
PyObject *out;
|
||||
int i;
|
||||
|
||||
out = PyTuple_New(len);
|
||||
DebugPrintf("Tuple %p\n", out);
|
||||
out = PyTuple_New(len);
|
||||
DebugPrintf("Tuple %p\n", out);
|
||||
|
||||
if (!out)
|
||||
return NULL;
|
||||
for (i = 0; i < len; i++) {
|
||||
AOK(PL_get_arg(i + 1, t, targ), NULL);
|
||||
PyErr_Clear();
|
||||
PyObject *oa = term_to_python(targ, true, o);
|
||||
bool rc = PyTuple_SET_ITEM(out, i, oa) == 0;
|
||||
if (rc) {
|
||||
PyErr_Print();
|
||||
}
|
||||
Py_INCREF(oa);
|
||||
}
|
||||
return out;
|
||||
} else if (fun == FUNCTOR_div2) {
|
||||
term_t targ = PL_new_term_ref();
|
||||
PyObject *lhs, *rhs;
|
||||
if (!out)
|
||||
return NULL;
|
||||
for (i = 0; i < len; i++) {
|
||||
AOK(PL_get_arg(i + 1, t, targ), NULL);
|
||||
PyErr_Clear();
|
||||
PyObject *oa = term_to_python(targ, true, o);
|
||||
bool rc = PyTuple_SET_ITEM(out, i, oa) == 0;
|
||||
if (rc) {
|
||||
PyErr_Print();
|
||||
}
|
||||
Py_INCREF(oa);
|
||||
}
|
||||
return out;
|
||||
} else if (fun == FUNCTOR_div2) {
|
||||
term_t targ = PL_new_term_ref();
|
||||
PyObject *lhs, *rhs;
|
||||
|
||||
AOK(PL_get_arg(1, t, targ), NULL);
|
||||
lhs = term_to_python(targ, true, NULL);
|
||||
if (!PyNumber_Check(lhs))
|
||||
return NULL;
|
||||
AOK(PL_get_arg(2, t, targ), NULL);
|
||||
rhs = term_to_python(targ, true, NULL);
|
||||
if (!PyNumber_Check(rhs))
|
||||
return NULL;
|
||||
AOK(PL_get_arg(1, t, targ), NULL);
|
||||
lhs = term_to_python(targ, true, NULL);
|
||||
if (!PyNumber_Check(lhs))
|
||||
return NULL;
|
||||
AOK(PL_get_arg(2, t, targ), NULL);
|
||||
rhs = term_to_python(targ, true, NULL);
|
||||
if (!PyNumber_Check(rhs))
|
||||
return NULL;
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
return PyNumber_Divide(lhs, rhs);
|
||||
return PyNumber_Divide(lhs, rhs);
|
||||
#else
|
||||
return PyNumber_TrueDivide(lhs, rhs);
|
||||
return PyNumber_TrueDivide(lhs, rhs);
|
||||
#endif
|
||||
}
|
||||
if (fun == FUNCTOR_sqbrackets2) {
|
||||
term_t targ = PL_new_term_ref(), trhs = PL_new_term_ref();
|
||||
PyObject *v;
|
||||
Py_ssize_t min, max;
|
||||
AOK(PL_get_arg(2, t, targ), NULL);
|
||||
v = term_to_python(targ, true, o);
|
||||
}
|
||||
if (fun == FUNCTOR_sqbrackets2) {
|
||||
term_t targ = PL_new_term_ref(), trhs = PL_new_term_ref();
|
||||
PyObject *v;
|
||||
Py_ssize_t min, max;
|
||||
AOK(PL_get_arg(2, t, targ), NULL);
|
||||
v = term_to_python(targ, true, o);
|
||||
|
||||
AOK(PL_get_arg(1, t, targ), NULL);
|
||||
AOK(PL_get_list(targ, trhs, targ), NULL);
|
||||
if (PL_is_functor(trhs, FUNCTOR_colon2)) {
|
||||
if (!PySequence_Check(v))
|
||||
return NULL;
|
||||
min = get_p_int(term_to_python(targ, true, NULL), 0);
|
||||
AOK(PL_get_arg(1, trhs, targ), NULL);
|
||||
if (PL_is_functor(targ, FUNCTOR_colon2)) {
|
||||
return NULL;
|
||||
}
|
||||
max = get_p_int(term_to_python(targ, true, o), PyObject_Size(v));
|
||||
return PySequence_GetSlice(v, min, max);
|
||||
} else {
|
||||
PyObject *ip = term_to_python(trhs, true, o);
|
||||
if (PySequence_Check(v)) {
|
||||
AOK(PL_get_arg(1, t, targ), NULL);
|
||||
AOK(PL_get_list(targ, trhs, targ), NULL);
|
||||
if (PL_is_functor(trhs, FUNCTOR_colon2)) {
|
||||
if (!PySequence_Check(v))
|
||||
return NULL;
|
||||
min = get_p_int(term_to_python(targ, true, NULL), 0);
|
||||
AOK(PL_get_arg(1, trhs, targ), NULL);
|
||||
if (PL_is_functor(targ, FUNCTOR_colon2)) {
|
||||
return NULL;
|
||||
}
|
||||
max = get_p_int(term_to_python(targ, true, o), PyObject_Size(v));
|
||||
return PySequence_GetSlice(v, min, max);
|
||||
} else {
|
||||
PyObject *ip = term_to_python(trhs, true, o);
|
||||
if (PySequence_Check(v)) {
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
if (PyLong_Check(ip) {
|
||||
min = PyLong_AsLong(ip);
|
||||
} else if (PyInt_Check(ip) {
|
||||
min = PyInt_asInt(ip);
|
||||
}
|
||||
if (PyLong_Check(ip) {
|
||||
min = PyLong_AsLong(ip);
|
||||
} else if (PyInt_Check(ip) {
|
||||
min = PyInt_asInt(ip);
|
||||
}
|
||||
#else
|
||||
if (PyLong_Check(ip)) {
|
||||
PyObject *o = PySequence_GetItem(v, PyLong_AsLong(ip));
|
||||
if (o == NULL)
|
||||
o = Py_None;
|
||||
if (CHECKNULL(t, o) == NULL)
|
||||
return NULL;
|
||||
Py_INCREF(o);
|
||||
return o;
|
||||
}
|
||||
if (PyLong_Check(ip)) {
|
||||
PyObject *o = PySequence_GetItem(v, PyLong_AsLong(ip));
|
||||
if (o == NULL)
|
||||
o = Py_None;
|
||||
if (CHECKNULL(t, o) == NULL)
|
||||
return NULL;
|
||||
Py_INCREF(o);
|
||||
return o;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
o = PyObject_GetItem(v, ip);
|
||||
if (o == NULL)
|
||||
o = Py_None;
|
||||
Py_INCREF(o);
|
||||
return o;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fun == FUNCTOR_dollar1) {
|
||||
char *s = NULL;
|
||||
term_t targ = PL_new_term_ref();
|
||||
AOK(PL_get_arg(1, t, targ), NULL);
|
||||
AOK(PL_get_atom_chars(targ, &s), NULL);
|
||||
/* return __main__,s */
|
||||
PyObject *o = PyObject_GetAttrString(py_Main, s);
|
||||
return o;
|
||||
}
|
||||
if (fun == FUNCTOR_brackets1) {
|
||||
AOK(PL_get_arg(1, t, t), NULL);
|
||||
return term_to_python(t, true, NULL);
|
||||
}
|
||||
if (fun == FUNCTOR_complex2) {
|
||||
term_t targ = PL_new_term_ref();
|
||||
PyObject *lhs, *rhs;
|
||||
double d1, d2;
|
||||
} else {
|
||||
o = PyObject_GetItem(v, ip);
|
||||
if (o == NULL)
|
||||
o = Py_None;
|
||||
Py_INCREF(o);
|
||||
return o;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fun == FUNCTOR_dollar1) {
|
||||
char *s = NULL;
|
||||
term_t targ = PL_new_term_ref();
|
||||
AOK(PL_get_arg(1, t, targ), NULL);
|
||||
AOK(PL_get_atom_chars(targ, &s), NULL);
|
||||
/* return __main__,s */
|
||||
PyObject *o = PyObject_GetAttrString(py_Main, s);
|
||||
return o;
|
||||
}
|
||||
if (fun == FUNCTOR_brackets1) {
|
||||
AOK(PL_get_arg(1, t, t), NULL);
|
||||
return term_to_python(t, true, NULL);
|
||||
}
|
||||
if (fun == FUNCTOR_complex2) {
|
||||
term_t targ = PL_new_term_ref();
|
||||
PyObject *lhs, *rhs;
|
||||
double d1, d2;
|
||||
|
||||
AOK(PL_get_arg(1, t, targ), NULL);
|
||||
lhs = term_to_python(targ, true, NULL);
|
||||
AOK(PyNumber_Check(lhs), NULL);
|
||||
if (PyFloat_Check(lhs)) {
|
||||
d1 = PyFloat_AsDouble(lhs);
|
||||
} else if (PyLong_Check(lhs)) {
|
||||
d1 = PyLong_AsLong(lhs);
|
||||
AOK(PL_get_arg(1, t, targ), NULL);
|
||||
lhs = term_to_python(targ, true, NULL);
|
||||
AOK(PyNumber_Check(lhs), NULL);
|
||||
if (PyFloat_Check(lhs)) {
|
||||
d1 = PyFloat_AsDouble(lhs);
|
||||
} else if (PyLong_Check(lhs)) {
|
||||
d1 = PyLong_AsLong(lhs);
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
} else if (PyInt_Check(lhs)) {
|
||||
d1 = PyInt_AsLong(lhs);
|
||||
} else if (PyInt_Check(lhs)) {
|
||||
d1 = PyInt_AsLong(lhs);
|
||||
#endif
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
AOK(PL_get_arg(2, t, targ), NULL);
|
||||
rhs = term_to_python(targ, true, NULL);
|
||||
AOK(PyNumber_Check(rhs), NULL);
|
||||
if (PyFloat_Check(rhs)) {
|
||||
d2 = PyFloat_AsDouble(rhs);
|
||||
} else if (PyLong_Check(rhs)) {
|
||||
d2 = PyLong_AsLong(rhs);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
AOK(PL_get_arg(2, t, targ), NULL);
|
||||
rhs = term_to_python(targ, true, NULL);
|
||||
AOK(PyNumber_Check(rhs), NULL);
|
||||
if (PyFloat_Check(rhs)) {
|
||||
d2 = PyFloat_AsDouble(rhs);
|
||||
} else if (PyLong_Check(rhs)) {
|
||||
d2 = PyLong_AsLong(rhs);
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
} else if (PyInt_Check(rhs)) {
|
||||
d2 = PyInt_AsLong(rhs);
|
||||
} else if (PyInt_Check(rhs)) {
|
||||
d2 = PyInt_AsLong(rhs);
|
||||
#endif
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PyComplex_FromDoubles(d1, d2);
|
||||
}
|
||||
if (fun == FUNCTOR_curly1) {
|
||||
term_t targ = PL_new_term_ref(), taux = PL_new_term_ref();
|
||||
PyObject *dict;
|
||||
return PyComplex_FromDoubles(d1, d2);
|
||||
}
|
||||
if (fun == FUNCTOR_curly1) {
|
||||
term_t targ = PL_new_term_ref(), taux = PL_new_term_ref();
|
||||
PyObject *dict;
|
||||
|
||||
AOK(PL_get_arg(1, t, t), NULL);
|
||||
if (!(dict = PyDict_New()))
|
||||
return NULL;
|
||||
DebugPrintf("Dict %p\n", dict);
|
||||
AOK(PL_get_arg(1, t, t), NULL);
|
||||
if (!(dict = PyDict_New()))
|
||||
return NULL;
|
||||
DebugPrintf("Dict %p\n", dict);
|
||||
|
||||
while (PL_is_functor(t, FUNCTOR_comma2)) {
|
||||
AOK(PL_get_arg(1, t, targ), NULL);
|
||||
AOK(PL_is_functor(targ, FUNCTOR_colon2), NULL);
|
||||
while (PL_is_functor(t, FUNCTOR_comma2)) {
|
||||
AOK(PL_get_arg(1, t, targ), NULL);
|
||||
AOK(PL_is_functor(targ, FUNCTOR_colon2), NULL);
|
||||
|
||||
AOK(copy_to_dictionary(dict, targ, taux, true), NULL);
|
||||
AOK(PL_get_arg(2, t, t), NULL);
|
||||
}
|
||||
AOK(copy_to_dictionary(dict, targ, taux, true), NULL);
|
||||
AOK(PL_get_arg(2, t, t), NULL);
|
||||
}
|
||||
|
||||
if (PL_is_functor(t, FUNCTOR_colon2)) {
|
||||
AOK(copy_to_dictionary(dict, t, taux, true), NULL);
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
if (PL_is_functor(t, FUNCTOR_colon2)) {
|
||||
AOK(copy_to_dictionary(dict, t, taux, true), NULL);
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
PyObject *compound_to_pytree(term_t t, PyObject *context) {
|
||||
PyObject *o = py_Main, *no;
|
||||
functor_t fun;
|
||||
atom_t name;
|
||||
int arity;
|
||||
PyObject *compound_to_pytree(term_t t, PyObject *context) {
|
||||
PyObject *o = py_Main, *no;
|
||||
functor_t fun;
|
||||
atom_t name;
|
||||
int arity;
|
||||
|
||||
o = find_obj(context, t, false);
|
||||
AOK(PL_get_name_arity(t, &name, &arity), NULL);
|
||||
if (arity == 0)
|
||||
return term_to_python(t, false, o);
|
||||
AOK(PL_get_functor(t, &fun), NULL);
|
||||
if ((no = compound_to_data(t, o, fun, false)) != o && no) {
|
||||
return no;
|
||||
}
|
||||
if (!arity) {
|
||||
char *s = NULL;
|
||||
o = find_obj(context, t, false);
|
||||
AOK(PL_get_name_arity(t, &name, &arity), NULL);
|
||||
if (arity == 0)
|
||||
return term_to_python(t, false, o);
|
||||
AOK(PL_get_functor(t, &fun), NULL);
|
||||
if ((no = compound_to_data(t, o, fun, false)) != o && no) {
|
||||
return no;
|
||||
}
|
||||
if (!arity) {
|
||||
char *s = NULL;
|
||||
|
||||
AOK(!PL_get_atom_chars(t, &s), NULL);
|
||||
// this should never happen
|
||||
return term_to_python(t, false, o);
|
||||
} else {
|
||||
const char *s;
|
||||
if (!(s = PL_atom_chars(name))) {
|
||||
return NULL;
|
||||
}
|
||||
term_t tleft;
|
||||
int i;
|
||||
PyObject *out = PyTuple_New(arity);
|
||||
DebugPrintf("Tuple %p\n", o);
|
||||
tleft = PL_new_term_ref();
|
||||
for (i = 0; i < arity; i++) {
|
||||
PyObject *pArg;
|
||||
AOK(PL_get_arg(i + 1, t, tleft), NULL);
|
||||
pArg = term_to_python(tleft, false, NULL);
|
||||
if (pArg) {
|
||||
/* pArg reference stolen here: */
|
||||
PyTuple_SET_ITEM(out, i, pArg);
|
||||
Py_INCREF(pArg);
|
||||
}
|
||||
}
|
||||
if (CHECKNULL(t, out) == NULL) {
|
||||
PyErr_Print();
|
||||
return NULL;
|
||||
}
|
||||
PyObject *c = lookupPySymbol(s, o, NULL);
|
||||
AOK(!PL_get_atom_chars(t, &s), NULL);
|
||||
// this should never happen
|
||||
return term_to_python(t, false, o);
|
||||
} else {
|
||||
const char *s;
|
||||
if (!(s = PL_atom_chars(name))) {
|
||||
return NULL;
|
||||
}
|
||||
term_t tleft;
|
||||
int i;
|
||||
PyObject *out = PyTuple_New(arity);
|
||||
DebugPrintf("Tuple %p\n", o);
|
||||
tleft = PL_new_term_ref();
|
||||
for (i = 0; i < arity; i++) {
|
||||
PyObject *pArg;
|
||||
AOK(PL_get_arg(i + 1, t, tleft), NULL);
|
||||
pArg = term_to_python(tleft, false, NULL);
|
||||
if (pArg) {
|
||||
/* pArg reference stolen here: */
|
||||
PyTuple_SET_ITEM(out, i, pArg);
|
||||
Py_INCREF(pArg);
|
||||
}
|
||||
}
|
||||
if (CHECKNULL(t, out) == NULL) {
|
||||
PyErr_Print();
|
||||
return NULL;
|
||||
}
|
||||
PyObject *c = lookupPySymbol(s, o, NULL);
|
||||
|
||||
if (c && PyCallable_Check(c)) {
|
||||
PyObject *n = PyTuple_New(arity);
|
||||
PyTuple_SET_ITEM(n, 0, c);
|
||||
PyTuple_SET_ITEM(n, 1, out);
|
||||
return n;
|
||||
}
|
||||
return term_to_nametuple(s, arity, out);
|
||||
}
|
||||
}
|
||||
if (c && PyCallable_Check(c)) {
|
||||
PyObject *n = PyTuple_New(arity);
|
||||
PyTuple_SET_ITEM(n, 0, c);
|
||||
PyTuple_SET_ITEM(n, 1, out);
|
||||
return n;
|
||||
}
|
||||
return term_to_nametuple(s, arity, out);
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *compound_to_pyeval(term_t t, PyObject *context) {
|
||||
PyObject *o = NULL, *no;
|
||||
atom_t name;
|
||||
int arity;
|
||||
functor_t fun;
|
||||
PyObject *compound_to_pyeval(term_t t, PyObject *context) {
|
||||
PyObject *o = NULL, *no;
|
||||
atom_t name;
|
||||
int arity;
|
||||
functor_t fun;
|
||||
|
||||
o = find_obj(context, t, true);
|
||||
AOK(PL_get_name_arity(t, &name, &arity), NULL);
|
||||
if (arity == 0)
|
||||
return term_to_python(t, true, o);
|
||||
if (!PL_get_functor(t, &fun))
|
||||
return NULL;
|
||||
if ((no = compound_to_data(t, o, fun, true)) != o && no) {
|
||||
return no;
|
||||
}
|
||||
if (fun == FUNCTOR_abs1) {
|
||||
return bip_abs(t);
|
||||
} else if (fun == FUNCTOR_all1) {
|
||||
return bip_all(t);
|
||||
} else if (fun == FUNCTOR_any1) {
|
||||
return bip_any(t);
|
||||
} else if (fun == FUNCTOR_bin1) {
|
||||
return bip_bin(t);
|
||||
} else if (fun == FUNCTOR_ord1) {
|
||||
return bip_ord(t);
|
||||
} else if (fun == FUNCTOR_int1) {
|
||||
return bip_int(t);
|
||||
} else if (fun == FUNCTOR_long1) {
|
||||
return bip_long(t);
|
||||
} else if (fun == FUNCTOR_float1) {
|
||||
return bip_float(t, true);
|
||||
} else if (fun == FUNCTOR_iter1) {
|
||||
return bip_iter(t);
|
||||
} else if (fun == FUNCTOR_range1 || fun == FUNCTOR_range2 ||
|
||||
fun == FUNCTOR_range3) {
|
||||
return bip_range(t);
|
||||
} else if (fun == FUNCTOR_sum1) {
|
||||
return bip_sum(t);
|
||||
}
|
||||
if (fun == FUNCTOR_len1) {
|
||||
term_t targ = PL_new_term_ref();
|
||||
PyObject *ptr;
|
||||
o = find_obj(context, t, true);
|
||||
AOK(PL_get_name_arity(t, &name, &arity), NULL);
|
||||
if (arity == 0)
|
||||
return term_to_python(t, true, o);
|
||||
if (!PL_get_functor(t, &fun))
|
||||
return NULL;
|
||||
if ((no = compound_to_data(t, o, fun, true)) != o && no) {
|
||||
return no;
|
||||
}
|
||||
if (fun == FUNCTOR_abs1) {
|
||||
return bip_abs(t);
|
||||
} else if (fun == FUNCTOR_all1) {
|
||||
return bip_all(t);
|
||||
} else if (fun == FUNCTOR_any1) {
|
||||
return bip_any(t);
|
||||
} else if (fun == FUNCTOR_bin1) {
|
||||
return bip_bin(t);
|
||||
} else if (fun == FUNCTOR_ord1) {
|
||||
return bip_ord(t);
|
||||
} else if (fun == FUNCTOR_int1) {
|
||||
return bip_int(t);
|
||||
} else if (fun == FUNCTOR_long1) {
|
||||
return bip_long(t);
|
||||
} else if (fun == FUNCTOR_float1) {
|
||||
return bip_float(t, true);
|
||||
} else if (fun == FUNCTOR_iter1) {
|
||||
return bip_iter(t);
|
||||
} else if (fun == FUNCTOR_range1 || fun == FUNCTOR_range2 ||
|
||||
fun == FUNCTOR_range3) {
|
||||
return bip_range(t);
|
||||
} else if (fun == FUNCTOR_sum1) {
|
||||
return bip_sum(t);
|
||||
}
|
||||
if (fun == FUNCTOR_len1) {
|
||||
term_t targ = PL_new_term_ref();
|
||||
PyObject *ptr;
|
||||
|
||||
AOK(PL_get_arg(1, t, targ), NULL);
|
||||
ptr = term_to_python(targ, true, NULL);
|
||||
return PyLong_FromLong(PyObject_Length(ptr));
|
||||
}
|
||||
if (fun == FUNCTOR_dir1) {
|
||||
term_t targ = PL_new_term_ref();
|
||||
PyObject *ptr;
|
||||
AOK(PL_get_arg(1, t, targ), NULL);
|
||||
ptr = term_to_python(targ, true, NULL);
|
||||
return PyLong_FromLong(PyObject_Length(ptr));
|
||||
}
|
||||
if (fun == FUNCTOR_dir1) {
|
||||
term_t targ = PL_new_term_ref();
|
||||
PyObject *ptr;
|
||||
|
||||
AOK(PL_get_arg(1, t, targ), NULL);
|
||||
ptr = term_to_python(targ, true, NULL);
|
||||
return PyObject_Dir(ptr);
|
||||
AOK(PL_get_arg(1, t, targ), NULL);
|
||||
ptr = term_to_python(targ, true, NULL);
|
||||
return PyObject_Dir(ptr);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
else if (fun == FUNCTOR_plus2) {
|
||||
term_t targ = PL_new_term_ref();
|
||||
PyObject *lhs, *rhs;
|
||||
else if (fun == FUNCTOR_plus2) {
|
||||
term_t targ = PL_new_term_ref();
|
||||
PyObject *lhs, *rhs;
|
||||
|
||||
if (!PL_get_arg(1, t, targ))
|
||||
return NULL;
|
||||
lhs = term_to_python(targ, true, NULL);
|
||||
AOK(PL_get_arg(2, t, targ), NULL);
|
||||
rhs = term_to_python(targ, true, NULL);
|
||||
if (PySequence_Check(lhs) && PySequence_Check(rhs)) {
|
||||
return PySequence_Concat(lhs, rhs);
|
||||
}
|
||||
if (!PyNumber_Check(lhs))
|
||||
return NULL;
|
||||
if (!PyNumber_Check(rhs))
|
||||
return NULL;
|
||||
return PyNumber_Add(lhs, rhs);
|
||||
} else if (fun == FUNCTOR_sub2) {
|
||||
term_t targ = PL_new_term_ref();
|
||||
PyObject *lhs, *rhs;
|
||||
if (!PL_get_arg(1, t, targ))
|
||||
return NULL;
|
||||
lhs = term_to_python(targ, true, NULL);
|
||||
AOK(PL_get_arg(2, t, targ), NULL);
|
||||
rhs = term_to_python(targ, true, NULL);
|
||||
if (PySequence_Check(lhs) && PySequence_Check(rhs)) {
|
||||
return PySequence_Concat(lhs, rhs);
|
||||
}
|
||||
if (!PyNumber_Check(lhs))
|
||||
return NULL;
|
||||
if (!PyNumber_Check(rhs))
|
||||
return NULL;
|
||||
return PyNumber_Add(lhs, rhs);
|
||||
} else if (fun == FUNCTOR_sub2) {
|
||||
term_t targ = PL_new_term_ref();
|
||||
PyObject *lhs, *rhs;
|
||||
|
||||
if (!PL_get_arg(1, t, targ))
|
||||
return NULL;
|
||||
lhs = term_to_python(targ, true, NULL);
|
||||
if (!PyNumber_Check(lhs))
|
||||
return NULL;
|
||||
if (!PL_get_arg(2, t, targ))
|
||||
return NULL;
|
||||
rhs = term_to_python(targ, true, NULL);
|
||||
if (!PyNumber_Check(rhs))
|
||||
return NULL;
|
||||
return PyNumber_Subtract(lhs, rhs);
|
||||
} else if (fun == FUNCTOR_mul2) {
|
||||
term_t targ = PL_new_term_ref();
|
||||
PyObject *lhs, *rhs;
|
||||
if (!PL_get_arg(1, t, targ))
|
||||
return NULL;
|
||||
lhs = term_to_python(targ, true, NULL);
|
||||
if (!PyNumber_Check(lhs))
|
||||
return NULL;
|
||||
if (!PL_get_arg(2, t, targ))
|
||||
return NULL;
|
||||
rhs = term_to_python(targ, true, NULL);
|
||||
if (!PyNumber_Check(rhs))
|
||||
return NULL;
|
||||
return PyNumber_Subtract(lhs, rhs);
|
||||
} else if (fun == FUNCTOR_mul2) {
|
||||
term_t targ = PL_new_term_ref();
|
||||
PyObject *lhs, *rhs;
|
||||
|
||||
AOK(PL_get_arg(1, t, targ), NULL);
|
||||
(lhs = term_to_python(targ, true, NULL));
|
||||
CHECKNULL(targ, lhs);
|
||||
AOK(PL_get_arg(2, t, targ), NULL);
|
||||
(rhs = term_to_python(targ, true, NULL));
|
||||
CHECKNULL(targ, rhs);
|
||||
if (PySequence_Check(lhs) && (
|
||||
AOK(PL_get_arg(1, t, targ), NULL);
|
||||
(lhs = term_to_python(targ, true, NULL));
|
||||
CHECKNULL(targ, lhs);
|
||||
AOK(PL_get_arg(2, t, targ), NULL);
|
||||
(rhs = term_to_python(targ, true, NULL));
|
||||
CHECKNULL(targ, rhs);
|
||||
if (PySequence_Check(lhs) && (
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
PyInt_Check(rhs) ||
|
||||
PyInt_Check(rhs) ||
|
||||
#endif
|
||||
PyLong_Check(rhs))) {
|
||||
return PySequence_Repeat(lhs, get_p_int(rhs, 0));
|
||||
}
|
||||
if (!PyNumber_Check(lhs) + !PyNumber_Check(rhs))
|
||||
return NULL;
|
||||
return PyNumber_Multiply(lhs, rhs);
|
||||
}
|
||||
if (!arity) {
|
||||
char *s = NULL;
|
||||
PyObject *pValue;
|
||||
PyLong_Check(rhs))) {
|
||||
return PySequence_Repeat(lhs, get_p_int(rhs, 0));
|
||||
}
|
||||
if (!PyNumber_Check(lhs) + !PyNumber_Check(rhs))
|
||||
return NULL;
|
||||
return PyNumber_Multiply(lhs, rhs);
|
||||
}
|
||||
if (!arity) {
|
||||
char *s = NULL;
|
||||
PyObject *pValue;
|
||||
|
||||
AOK(PL_get_atom_chars(t, &s), NULL);
|
||||
pValue = PyObject_GetAttrString(o, s);
|
||||
if (CHECKNULL(t, pValue) == NULL) {
|
||||
PyErr_Print();
|
||||
return NULL;
|
||||
}
|
||||
return pValue;
|
||||
} else {
|
||||
char *s = PL_atom_chars(name);
|
||||
o = lookupPySymbol(s, o, NULL);
|
||||
if (CHECKNULL(t, o) == NULL) {
|
||||
PyErr_Print();
|
||||
return NULL;
|
||||
}
|
||||
PyObject *pArgs = PyTuple_New(arity);
|
||||
DebugPrintf("Tuple %p\n", pArgs);
|
||||
int i;
|
||||
term_t tleft = PL_new_term_ref();
|
||||
for (i = 0; i < arity; i++) {
|
||||
PyObject *pArg;
|
||||
AOK(PL_get_arg(i + 1, t, tleft), NULL);
|
||||
/* ignore (_) */
|
||||
if (i == 0 && PL_is_variable(tleft)) {
|
||||
pArg = Py_None;
|
||||
} else {
|
||||
pArg = term_to_python(tleft, true, NULL);
|
||||
// PyObject_Print(pArg,fdopen(2,"w"),0);
|
||||
if (pArg == NULL) {
|
||||
pArg = Py_None;
|
||||
}
|
||||
/* pArg reference stolen here: */
|
||||
Py_INCREF(pArg);
|
||||
}
|
||||
AOK(PL_get_atom_chars(t, &s), NULL);
|
||||
pValue = PyObject_GetAttrString(o, s);
|
||||
if (CHECKNULL(t, pValue) == NULL) {
|
||||
PyErr_Print();
|
||||
return NULL;
|
||||
}
|
||||
return pValue;
|
||||
} else {
|
||||
char *s = PL_atom_chars(name);
|
||||
o = lookupPySymbol(s, o, NULL);
|
||||
if (CHECKNULL(t, o) == NULL) {
|
||||
PyErr_Print();
|
||||
return NULL;
|
||||
}
|
||||
PyObject *pArgs = PyTuple_New(arity);
|
||||
DebugPrintf("Tuple %p\n", pArgs);
|
||||
int i;
|
||||
term_t tleft = PL_new_term_ref();
|
||||
for (i = 0; i < arity; i++) {
|
||||
PyObject *pArg;
|
||||
AOK(PL_get_arg(i + 1, t, tleft), NULL);
|
||||
/* ignore (_) */
|
||||
if (i == 0 && PL_is_variable(tleft)) {
|
||||
pArg = Py_None;
|
||||
} else {
|
||||
pArg = term_to_python(tleft, true, NULL);
|
||||
// PyObject_Print(pArg,fdopen(2,"w"),0);
|
||||
if (pArg == NULL) {
|
||||
pArg = Py_None;
|
||||
}
|
||||
/* pArg reference stolen here: */
|
||||
Py_INCREF(pArg);
|
||||
}
|
||||
|
||||
PyTuple_SetItem(pArgs, i, pArg);
|
||||
}
|
||||
if (!PyCallable_Check(o)) {
|
||||
return term_to_nametuple(s, arity, pArgs);
|
||||
}
|
||||
PyObject *rc;
|
||||
PyTuple_SetItem(pArgs, i, pArg);
|
||||
}
|
||||
if (!PyCallable_Check(o)) {
|
||||
return term_to_nametuple(s, arity, pArgs);
|
||||
}
|
||||
PyObject *rc;
|
||||
|
||||
// PyObject_Print(pArgs, stderr, 0);
|
||||
// PyObject_Print(o, stderr, 0);
|
||||
CHECK_CALL(rc, t, PyObject_CallObject(o, pArgs));
|
||||
Py_DECREF(pArgs);
|
||||
Py_DECREF(o);
|
||||
DebugPrintf("CallObject %p\n", rc);
|
||||
// PyObject_Print(pArgs, stderr, 0);
|
||||
// PyObject_Print(o, stderr, 0);
|
||||
CHECK_CALL(rc, t, PyObject_CallObject(o, pArgs));
|
||||
Py_DECREF(pArgs);
|
||||
Py_DECREF(o);
|
||||
DebugPrintf("CallObject %p\n", rc);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
@ -24,78 +24,88 @@ SET_SOURCE_FILES_PROPERTIES(../../swig/yap.i PROPERTIES SWIG_MODULE_NAME yap)
|
||||
|
||||
if (WIN32)
|
||||
|
||||
set (SYS_DLLS ${GMP_LIBRARIES})
|
||||
|
||||
set (SYS_DLLS c:/msys64/mingw64/bin/libgmp-10.dll)
|
||||
set (SYS_DLLS ${GMP_LIBRARIES} c:/msys64/mingw64/bin/libgmp-10.dll)
|
||||
|
||||
endif()
|
||||
|
||||
# inform we are compiling YAP
|
||||
# s used in MSYS
|
||||
#
|
||||
#
|
||||
# INSTALL ( TARGETS ${SWIG_MODULE_Py2YAP_REAL_NAME}
|
||||
# RUNTIME DESTINATION ${PYTHON_MODULE_PATH}
|
||||
# ARCHIVE DESTINATION ${PYTHON_MODULE_PATH}
|
||||
# LIBRARY DESTINATION ${PYTHON_MODULE_PATH}
|
||||
# )
|
||||
# inform we are compiling YAP
|
||||
# s used in MSYS
|
||||
#
|
||||
#
|
||||
# INSTALL ( TARGETS ${SWIG_MODULE_Py2YAP_REAL_NAME}
|
||||
# RUNTIME DESTINATION ${PYTHON_MODULE_PATH}
|
||||
# ARCHIVE 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:yap_rl>
|
||||
$<TARGET_FILE:tries>
|
||||
$<TARGET_FILE:itries>
|
||||
$<TARGET_FILE:sys>
|
||||
$<TARGET_FILE:yap_random>
|
||||
)
|
||||
if (TARGET real)
|
||||
)
|
||||
if (TARGET real)
|
||||
list(APPEND python_dlls $<TARGET_FILE:real>
|
||||
)
|
||||
)
|
||||
endif()
|
||||
if (NOT WIN32)
|
||||
if (NOT WIN32)
|
||||
list(APPEND python_dlls $<TARGET_FILE:YAP++> $<TARGET_FILE:Py4YAP>
|
||||
)
|
||||
endif()
|
||||
)
|
||||
endif()
|
||||
|
||||
set (PL ${pl_library} ${PROLOG_SOURCES} )
|
||||
|
||||
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 ${CMAKE_BINARY_DIR}/config.h ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_SOURCES} ${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
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${PL} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog
|
||||
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
|
||||
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 ${python_dlls} yap4py
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/libYap${CMAKE_SHARED_LIBRARY_SUFFIX} yap4py
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${CMAKE_CURRENT_BINARY_DIR}/yap4py
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS YAP4PY_SETUP_PL STARTUP ${python_dlls} libYap )
|
||||
|
||||
add_custom_target( YAP4PY_SETUP_PL
|
||||
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
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/pl
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/os
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory yap4py
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory yap4py/prolog
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory yap4py/prolog/pl
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory yap4py/prolog/os
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
add_custom_target( YAP4PY ALL
|
||||
COMMAND ${PYTHON_EXECUTABLE} -m pip uninstall -y YAP4PY
|
||||
add_custom_target( YAP4PY ALL
|
||||
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 ${PYTHON_EXECUTABLE} setup.py sdist bdist_wheel
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DEPENDS YAP4PY_SETUP)
|
||||
|
||||
|
||||
|
||||
install(CODE "execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE} -m pip install --force --no-index -f packages/python/swig/dist YAP4PY
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})"
|
||||
DEPENDS Py4YAP ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${dlls} )
|
||||
COMMAND ${PYTHON_EXECUTABLE} -m pip install --force --no-index -f packages/python/swig/dist YAP4PY
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})"
|
||||
DEPENDS Py4YAP ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${dlls} )
|
||||
|
||||
install(FILES ${PROLOG_SOURCES} DESTINATION ${libpl})
|
||||
|
||||
|
||||
|
||||
if (WITH_DOCS AND DOXYGEN_FOUND)
|
||||
if (WITH_DOCS AND DOXYGEN_FOUND)
|
||||
|
||||
set(CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
|
||||
|
||||
@ -104,8 +114,8 @@ install(FILES ${PROLOG_SOURCES} DESTINATION ${libpl})
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/doc
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile.xml
|
||||
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
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ftdi1_doc.i
|
||||
|
@ -3,6 +3,8 @@
|
||||
See:
|
||||
https://packaging.python.org/en/latest/distributing.html
|
||||
https://github.com/pypa/sampleproject
|
||||
|
||||
|
||||
"""
|
||||
|
||||
# Always prefer setuptools over distutils
|
||||
|
@ -68,6 +68,8 @@ cplus = ['']
|
||||
bpy2yap = []
|
||||
native_sources = ['yap_wrap.cpp']
|
||||
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
|
||||
|
||||
@ -79,14 +81,14 @@ extensions = [Extension('_yap', native_sources,
|
||||
('_YAP_NOT_INSTALLED_', '1'),
|
||||
('YAP_PYTHON', '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',
|
||||
'-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}/os', '-I${CMAKE_SOURCE_DIR}/OPTYap', '-I../../..'],
|
||||
library_dirs=['../../..', '../../../CXX', '..', "${dlls}", "${bindir}", '.'],
|
||||
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=['../../..',
|
||||
'${GMP_INCLUDE_DIRS}',
|
||||
'${CMAKE_SOURCE_DIR}/H',
|
||||
|
@ -36,7 +36,7 @@ class EngineArgs( YAPEngineArgs ):
|
||||
def __init__(self, args=None,**kwargs):
|
||||
super().__init__()
|
||||
|
||||
|
||||
|
||||
class Predicate( YAPPredicate ):
|
||||
""" Interface to Generic Predicate"""
|
||||
|
||||
@ -49,7 +49,7 @@ class Predicate:
|
||||
else:
|
||||
self.p = YAPPredicate( name, len(self) )
|
||||
self.e = engine
|
||||
|
||||
|
||||
def goals( self, engine):
|
||||
self.e = engine
|
||||
|
||||
@ -82,12 +82,12 @@ class PrologTableIter:
|
||||
raise StopIteration()
|
||||
|
||||
|
||||
|
||||
|
||||
class PrologPredicate( YAPPrologPredicate ):
|
||||
""" Interface to Prolog Predicate"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
global engine, handler
|
||||
|
||||
yap_lib_path = os.path.dirname(__file__)
|
||||
@ -137,7 +137,7 @@ def answer(q):
|
||||
return False
|
||||
|
||||
def query_prolog(engine, s):
|
||||
import pdb; pdb.set_trace()
|
||||
# import pdb; pdb.set_trace()
|
||||
#
|
||||
# construct a query from a one-line string
|
||||
# q is opaque to Python
|
||||
@ -209,16 +209,8 @@ def live(**kwargs):
|
||||
#
|
||||
|
||||
def boot_yap(**kwargs):
|
||||
args = EngineArgs(**kwarg)
|
||||
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
|
||||
|
||||
return Engine(**kwargs)
|
||||
|
||||
if __name__ == "__main__":
|
||||
engine = boot_yap()
|
||||
handler = numbervars
|
||||
|
@ -55,7 +55,7 @@ all_attvars/1,
|
||||
:- 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
|
||||
_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
|
||||
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 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
|
||||
_QueryVars_. Although projection is constraint system dependent,
|
||||
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.
|
||||
|
||||
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_;
|
||||
@ -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
|
||||
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
|
||||
* @{
|
||||
|
16
pl/debug.yap
16
pl/debug.yap
@ -771,14 +771,14 @@ be lost.
|
||||
% set_prolog_flag(debug, OldDeb),
|
||||
% '$skipeol'(0'!), % '
|
||||
fail.
|
||||
'$action'(0'<,_,_,_,_,_) :- !, % <'Depth
|
||||
'$new_deb_depth',
|
||||
'$skipeol'(0'<),
|
||||
fail.
|
||||
'$action'(0'C,_,_,_,_,_) :-
|
||||
yap_flag(system_options, Opts),
|
||||
'$action'(0'<,_,_,_,_,_) :- !, % <'Depth
|
||||
'$new_deb_depth',
|
||||
'$skipeol'(0'<),
|
||||
fail.
|
||||
'$action'(0'C,_,_,_,_,_) :-
|
||||
yap_flag(system_options, Opts),
|
||||
lists:memberchk( call_tracer, Opts),
|
||||
!, % <'Depth
|
||||
!, % <'Depth
|
||||
'$skipeol'(0'C),
|
||||
'__NB_setval__'('$debug_jump',false).
|
||||
'$action'(0'^,_,_,G,_,_) :- !, % '
|
||||
@ -791,6 +791,7 @@ be lost.
|
||||
nodebug,
|
||||
abort.
|
||||
'$action'(0'b,_,_,_,_,_) :- !, % 'b break
|
||||
'$stop_creeping'(_),
|
||||
'$skipeol'(0'b),
|
||||
break,
|
||||
fail.
|
||||
@ -802,7 +803,6 @@ be lost.
|
||||
'$skipeol'(0'c),
|
||||
'__NB_setval__'('$debug_jump',false).
|
||||
'$action'(0'e,_,_,_,_,_) :- !, % 'e exit
|
||||
'$skipeol'(0'e),
|
||||
halt.
|
||||
'$action'(0'f,_,CallId,_,_,_) :- !, % 'f fail
|
||||
'$scan_number'(0'f, CallId, GoalId), %'f
|
||||
|
@ -18,9 +18,9 @@
|
||||
* @file flagd.ysp
|
||||
*
|
||||
* @defgroup Flags Yap Flags
|
||||
*n@{}
|
||||
* @{}
|
||||
* @ingroup builtins
|
||||
* @}@[ ]
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@
|
||||
unknown(_,error).
|
||||
|
||||
|
||||
/** @pred create_prolog_flag(+ _Flag_,+ _Value_,+ _Options_)
|
||||
/** @pred create_prolog_flag( +Flag, +Value, +Options)
|
||||
|
||||
Create a new YAP Prolog flag. _Options_ include
|
||||
|
||||
|
@ -789,4 +789,4 @@ module_state :-
|
||||
fail.
|
||||
module_state.
|
||||
|
||||
// @}
|
||||
%% @}
|
Reference in New Issue
Block a user