merge
This commit is contained in:
commit
1c4e272b1d
56
C/absmi.c
56
C/absmi.c
@ -916,24 +916,26 @@ static int interrupt_dexecute(USES_REGS1) {
|
||||
|
||||
static void undef_goal(USES_REGS1) {
|
||||
PredEntry *pe = PredFromDefCode(P);
|
||||
BEGD(d0);
|
||||
/* avoid trouble with undefined dynamic procedures */
|
||||
/* I assume they were not locked beforehand */
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
/* avoid trouble with undefined dynamic procedures */
|
||||
/* I assume they were not locked beforehand */
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (!PP) {
|
||||
PELOCK(19, pe);
|
||||
PP = pe;
|
||||
}
|
||||
#endif
|
||||
if (pe->PredFlags & (DynamicPredFlag | LogUpdatePredFlag | MultiFileFlag) ) {
|
||||
BACKUP_MACHINE_REGS();
|
||||
if (pe->PredFlags & (DynamicPredFlag | LogUpdatePredFlag | MultiFileFlag) ) {
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
UNLOCKPE(19, PP);
|
||||
PP = NULL;
|
||||
#endif
|
||||
CalculateStackGap(PASS_REGS1);
|
||||
P = FAILCODE;
|
||||
RECOVER_MACHINE_REGS();
|
||||
return;
|
||||
}
|
||||
#if DEBUG
|
||||
if (UndefCode == NULL || UndefCode->OpcodeOfPred == UNDEF_OPCODE) {
|
||||
fprintf(stderr,"call to undefined Predicates %s ->", IndicatorOfPred(pe));
|
||||
Yap_DebugPlWriteln(ARG1);
|
||||
@ -946,16 +948,28 @@ static void undef_goal(USES_REGS1) {
|
||||
#endif
|
||||
CalculateStackGap(PASS_REGS1);
|
||||
P = FAILCODE;
|
||||
RECOVER_MACHINE_REGS();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
UNLOCKPE(19, PP);
|
||||
PP = NULL;
|
||||
#endif
|
||||
if (pe->ArityOfPE == 0) {
|
||||
d0 = MkAtomTerm((Atom)(pe->FunctorOfPred));
|
||||
#endif
|
||||
CELL o = AbsPair(HR);
|
||||
if (pe->ModuleOfPred == PROLOG_MODULE) {
|
||||
if (CurrentModule == PROLOG_MODULE)
|
||||
HR[0] = TermProlog;
|
||||
else
|
||||
HR[0] = CurrentModule;
|
||||
} else {
|
||||
d0 = AbsAppl(HR);
|
||||
HR[0] = Yap_Module_Name(pe);
|
||||
}
|
||||
HR += 2;
|
||||
if (pe->ArityOfPE == 0) {
|
||||
HR[-1] = MkAtomTerm((Atom)(pe->FunctorOfPred));
|
||||
} else {
|
||||
HR[-1] = AbsAppl(HR);
|
||||
*HR++ = (CELL)pe->FunctorOfPred;
|
||||
CELL *ip=HR;
|
||||
UInt imax = pe->ArityOfPE;
|
||||
@ -984,30 +998,20 @@ static void undef_goal(USES_REGS1) {
|
||||
ENDD(d1);
|
||||
}
|
||||
}
|
||||
ARG1 = AbsPair(HR);
|
||||
HR[1] = d0;
|
||||
ENDD(d0);
|
||||
if (pe->ModuleOfPred == PROLOG_MODULE) {
|
||||
if (CurrentModule == PROLOG_MODULE)
|
||||
HR[0] = TermProlog;
|
||||
else
|
||||
HR[0] = CurrentModule;
|
||||
} else {
|
||||
HR[0] = Yap_Module_Name(pe);
|
||||
}
|
||||
ARG2 = Yap_getUnknownModule(Yap_GetModuleEntry(HR[0]));
|
||||
HR += 2;
|
||||
ARG1 = o;
|
||||
ARG2 = MkVarTerm();
|
||||
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
if (Yap_do_low_level_trace)
|
||||
low_level_trace(enter_pred, UndefCode, XREGS + 1);
|
||||
#endif /* LOW_LEVEL_TRACE */
|
||||
P = UndefCode->CodeOfPred;
|
||||
RECOVER_MACHINE_REGS();
|
||||
}
|
||||
|
||||
static void spy_goal(USES_REGS1) {
|
||||
PredEntry *pe = PredFromDefCode(P);
|
||||
|
||||
BACKUP_MACHINE_REGS();
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
if (!PP) {
|
||||
PELOCK(14, pe);
|
||||
@ -1027,6 +1031,7 @@ static void spy_goal(USES_REGS1) {
|
||||
PP = NULL;
|
||||
}
|
||||
#endif
|
||||
RECOVER_MACHINE_REGS();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1044,6 +1049,7 @@ static void spy_goal(USES_REGS1) {
|
||||
}
|
||||
#endif
|
||||
Yap_NilError(CALL_COUNTER_UNDERFLOW_EVENT, "");
|
||||
RECOVER_MACHINE_REGS();
|
||||
return;
|
||||
}
|
||||
LOCAL_PredEntriesCounter--;
|
||||
@ -1055,6 +1061,7 @@ static void spy_goal(USES_REGS1) {
|
||||
}
|
||||
#endif
|
||||
Yap_NilError(PRED_ENTRY_COUNTER_UNDERFLOW_EVENT, "");
|
||||
RECOVER_MACHINE_REGS();
|
||||
return;
|
||||
}
|
||||
if ((pe->PredFlags & (CountPredFlag | ProfiledPredFlag | SpiedPredFlag)) ==
|
||||
@ -1066,6 +1073,7 @@ static void spy_goal(USES_REGS1) {
|
||||
}
|
||||
#endif
|
||||
P = pe->cs.p_code.TrueCodeOfPred;
|
||||
RECOVER_MACHINE_REGS();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1084,6 +1092,7 @@ static void spy_goal(USES_REGS1) {
|
||||
PP = NULL;
|
||||
}
|
||||
#endif
|
||||
RECOVER_MACHINE_REGS();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1153,6 +1162,7 @@ static void spy_goal(USES_REGS1) {
|
||||
low_level_trace(enter_pred, pt0, XREGS + 1);
|
||||
#endif /* LOW_LEVEL_TRACE */
|
||||
}
|
||||
RECOVER_MACHINE_REGS();
|
||||
}
|
||||
|
||||
Int Yap_absmi(int inp) {
|
||||
|
25
C/alloc.c
25
C/alloc.c
@ -378,16 +378,6 @@ ADDR Yap_ExpandPreAllocCodeSpace(UInt sz0, void *cip, int safe) {
|
||||
|
||||
struct various_codes *Yap_heap_regs;
|
||||
|
||||
static void InitHeap(void) {
|
||||
Yap_heap_regs =
|
||||
(struct various_codes *)calloc(1, sizeof(struct various_codes));
|
||||
}
|
||||
|
||||
void Yap_InitHeap(void *heap_addr) {
|
||||
InitHeap();
|
||||
Yap_HoleSize = 0;
|
||||
HeapMax = 0;
|
||||
}
|
||||
|
||||
// get an approximation to total memory data-base size.
|
||||
size_t Yap_HeapUsed(void)
|
||||
@ -400,9 +390,9 @@ void Yap_InitHeap(void *heap_addr) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static void InitExStacks(int wid, int Trail, int Stack) {
|
||||
static void InitExStacks(int wid, size_t Trail, size_t Stack) {
|
||||
CACHE_REGS
|
||||
UInt pm, sa;
|
||||
size_t pm, sa;
|
||||
|
||||
/* sanity checking for data areas */
|
||||
if (Trail < MinTrailSpace)
|
||||
@ -428,7 +418,7 @@ static void InitExStacks(int wid, int Trail, int Stack) {
|
||||
|
||||
#if DEBUG
|
||||
if (Yap_output_msg) {
|
||||
UInt ta;
|
||||
size_t ta;
|
||||
|
||||
fprintf(stderr,
|
||||
"HeapBase = %p GlobalBase = %p\n LocalBase = %p TrailTop = %p\n",
|
||||
@ -443,7 +433,7 @@ static void InitExStacks(int wid, int Trail, int Stack) {
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
|
||||
void Yap_InitExStacks(int wid, int Trail, int Stack) {
|
||||
void Yap_InitExStacks(int wid, size_t Trail, size_t Stack) {
|
||||
InitExStacks(wid, Trail, Stack);
|
||||
}
|
||||
|
||||
@ -464,7 +454,12 @@ void Yap_KillStacks(int wid) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void Yap_InitMemory(UInt Trail, UInt Heap, UInt Stack) { InitHeap(); }
|
||||
void Yap_InitMemory(size_t Trail, size_t Heap, size_t Stack) {
|
||||
Yap_HoleSize = 0;
|
||||
HeapMax = 0;
|
||||
Yap_heap_regs =
|
||||
(struct various_codes *)calloc(1, sizeof(struct various_codes));
|
||||
}
|
||||
|
||||
int Yap_ExtendWorkSpace(Int s) {
|
||||
CACHE_REGS
|
||||
|
@ -101,7 +101,7 @@ X_API int YAP_Reset(yap_reset_t mode, bool reset_global);
|
||||
#define X_API __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
#define BootFilePath NULL
|
||||
#define SOURCEBOOTPath NULL
|
||||
#if __ANDROID__
|
||||
#define BOOT_FROM_SAVED_STATE true
|
||||
#endif
|
||||
@ -1725,6 +1725,7 @@ X_API YAP_PredEntryPtr YAP_AtomToPredInModule(YAP_Atom at, Term mod) {
|
||||
return RepPredProp(PredPropByAtom(at, mod));
|
||||
}
|
||||
|
||||
/*
|
||||
static int run_emulator(USES_REGS1) {
|
||||
int out;
|
||||
|
||||
@ -1732,6 +1733,7 @@ static int run_emulator(USES_REGS1) {
|
||||
LOCAL_PrologMode |= UserCCallMode;
|
||||
return out;
|
||||
}
|
||||
*/
|
||||
|
||||
X_API bool YAP_EnterGoal(YAP_PredEntryPtr ape, CELL *ptr, YAP_dogoalinfo *dgi) {
|
||||
CACHE_REGS
|
||||
@ -1799,7 +1801,7 @@ X_API bool YAP_RetryGoal(YAP_dogoalinfo *dgi) {
|
||||
/* make sure we didn't leave live slots when we backtrack */
|
||||
ASP = (CELL *)B;
|
||||
LOCAL_CurSlot = dgi->EndSlot;
|
||||
out = run_emulator(PASS_REGS1);
|
||||
out = Yap_exec_absmi(true, true );
|
||||
if (out) {
|
||||
dgi->EndSlot = LOCAL_CurSlot;
|
||||
dgi->b = LCL0 - (CELL *)B;
|
||||
@ -2114,7 +2116,7 @@ X_API int YAP_InitConsult(int mode, const char *fname, char **full,
|
||||
mode = YAP_CONSULT_MODE;
|
||||
}
|
||||
if (fname == NULL || fname[0] == '\0') {
|
||||
fl = Yap_BOOTFILE;
|
||||
fl = Yap_SOURCEBOOT;
|
||||
}
|
||||
if (!fname || !(fl = Yap_AbsoluteFile(fname, true)) || !fl[0]) {
|
||||
__android_log_print(
|
||||
@ -2210,8 +2212,10 @@ X_API Term YAP_ReadClauseFromStream(int sno, Term vs, Term pos) {
|
||||
BACKUP_MACHINE_REGS();
|
||||
Term t = Yap_read_term(
|
||||
sno,
|
||||
MkPairTerm(Yap_MkApplTerm(Yap_MkFunctor(AtomVariableNames, 1), 1, &vs),
|
||||
MkPairTerm(Yap_MkApplTerm(Yap_MkFunctor(AtomTermPosition, 1),
|
||||
MkPairTerm(
|
||||
Yap_MkApplTerm(Yap_MkFunctor(AtomVariableNames, 1), 1, &vs),
|
||||
MkPairTerm(
|
||||
Yap_MkApplTerm(Yap_MkFunctor(AtomTermPosition, 1),
|
||||
1, &pos),
|
||||
TermNil)),
|
||||
true);
|
||||
@ -2249,7 +2253,7 @@ X_API char *YAP_WriteBuffer(Term t, char *buf, size_t sze, int flags) {
|
||||
inp.val.t = t;
|
||||
inp.type = YAP_STRING_TERM | YAP_STRING_DATUM;
|
||||
out.type = YAP_STRING_CHARS;
|
||||
out.val.c = buf;
|
||||
out.val.c = NULL;
|
||||
out.max = sze - 1;
|
||||
out.enc = LOCAL_encoding;
|
||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS)) {
|
||||
@ -2261,9 +2265,14 @@ X_API char *YAP_WriteBuffer(Term t, char *buf, size_t sze, int flags) {
|
||||
if (buf == out.val.c) {
|
||||
return buf;
|
||||
} else {
|
||||
return pop_output_text_stack(l, out.val.c);
|
||||
if ( strlen(out.val.c ) < sze) {
|
||||
strcpy( buf, out.val.c);
|
||||
pop_text_stack(l);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
return out.val.c = pop_output_text_stack(l,buf);
|
||||
}
|
||||
|
||||
/// write a a term to n user-provided buffer: make sure not tp
|
||||
|
@ -2536,7 +2536,7 @@ static Int
|
||||
// pe = Yap_get_pred(t1, Deref(ARG2), "system_predicate");
|
||||
// if (!pe)
|
||||
pe = Yap_get_pred(t1, Deref(ARG2), "system_predicate");
|
||||
// if (!pe) pe = Yap_get_pred(t1, USER_MODULE, "system_predicate");
|
||||
// if (!pe) pe = Yap_get_pred(t1, Deref(ARG2), "system_predicate");
|
||||
if (EndOfPAEntr(pe))
|
||||
return FALSE;
|
||||
return (pe->ModuleOfPred == 0);
|
||||
|
@ -4000,7 +4000,7 @@ static void EraseLogUpdCl(LogUpdClause *clau) {
|
||||
if (ap->cs.p_code.NOfClauses > 1) {
|
||||
if (ap->TimeStampOfPred >= TIMESTAMP_RESET)
|
||||
Yap_UpdateTimestamps(ap);
|
||||
++ap->TimeStampOfPred;
|
||||
++(ap->TimeStampOfPred);
|
||||
/* fprintf(stderr,"-
|
||||
* %x--%d--%ul\n",ap,ap->TimeStampOfPred,ap->ArityOfPE);*/
|
||||
ap->LastCallOfPred = LUCALL_RETRACT;
|
||||
@ -4017,7 +4017,7 @@ static void EraseLogUpdCl(LogUpdClause *clau) {
|
||||
ap->LastCallOfPred = LUCALL_ASSERT;
|
||||
}
|
||||
}
|
||||
clau->ClTimeEnd = ap->TimeStampOfPred;
|
||||
//clau->ClTimeEnd = ap->TimeStampOfPred;
|
||||
Yap_RemoveClauseFromIndex(ap, clau->ClCode);
|
||||
/* release the extra reference */
|
||||
}
|
||||
|
60
C/errors.c
60
C/errors.c
@ -41,8 +41,8 @@
|
||||
|
||||
#define set_key_i(k, ks, q, i, t) \
|
||||
if (strcmp(ks, q) == 0) { \
|
||||
i->k = IsIntegerTerm(t) ? IntegerOfTerm(t) : 0; \
|
||||
return IsIntegerTerm(t); \
|
||||
i->k = IsIntegerTerm(t) ? IntegerOfTerm(t) : 0; \
|
||||
return IsIntegerTerm(t); \
|
||||
}
|
||||
|
||||
#define set_key_s(k, ks, q, i, t) \
|
||||
@ -99,7 +99,7 @@ if (strcmp(ks, q) == 0) { \
|
||||
|
||||
#define query_key_s(k, ks, q, i) \
|
||||
if (strcmp(ks, q) == 0 ) \
|
||||
{ if (i->k) return MkAtomTerm(Yap_LookupAtom(i->k)); else return TermNil; }
|
||||
{ if (i->k) return MkAtomTerm(Yap_LookupAtom(i->k)); else return TermEmptyAtom; }
|
||||
|
||||
|
||||
#define query_key_t(k, ks, q, i) \
|
||||
@ -1258,15 +1258,25 @@ static Int is_callable(USES_REGS1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static Int is_predicate_indicator(USES_REGS1) {
|
||||
/**
|
||||
* @pred is_predicate_indicator( Term, Module, Name, Arity )
|
||||
*
|
||||
* This predicates can be used to verify if Term is a predicate indicator, that is of the form:
|
||||
* + Name/Arity
|
||||
* + Name//Arity-2
|
||||
* + Module:Name/Arity
|
||||
* + Module:Name//Arity-2
|
||||
*
|
||||
* if it is, it will extract the predicate's module, name, and arity.
|
||||
*/
|
||||
static Int get_predicate_indicator(USES_REGS1) {
|
||||
Term G = Deref(ARG1);
|
||||
// Term Context = Deref(ARG2);
|
||||
Term mod = CurrentModule;
|
||||
|
||||
G = Yap_YapStripModule(G, &mod);
|
||||
if (IsVarTerm(G)) {
|
||||
Yap_Error(INSTANTIATION_ERROR, G, NULL);
|
||||
return false;
|
||||
Yap_ThrowError(INSTANTIATION_ERROR, G, NULL);
|
||||
}
|
||||
if (!IsVarTerm(mod) && !IsAtomTerm(mod)) {
|
||||
Yap_Error(TYPE_ERROR_ATOM, G, NULL);
|
||||
@ -1275,13 +1285,34 @@ static Int is_predicate_indicator(USES_REGS1) {
|
||||
if (IsApplTerm(G)) {
|
||||
Functor f = FunctorOfTerm(G);
|
||||
if (IsExtensionFunctor(f)) {
|
||||
Yap_Error(TYPE_ERROR_PREDICATE_INDICATOR, G, NULL);
|
||||
Yap_ThrowError(TYPE_ERROR_PREDICATE_INDICATOR, G, NULL);
|
||||
}
|
||||
if (f == FunctorSlash || f == FunctorDoubleSlash) {
|
||||
return true;
|
||||
Term name = ArgOfTerm(1,G), arity = ArgOfTerm(2,G);
|
||||
if (IsVarTerm(name)) {
|
||||
Yap_ThrowError(INSTANTIATION_ERROR, name, NULL);
|
||||
} else if (!IsAtomTerm(name)) {
|
||||
Yap_ThrowError(TYPE_ERROR_ATOM, name, NULL);
|
||||
}
|
||||
if (IsVarTerm(arity)) {
|
||||
Yap_ThrowError(INSTANTIATION_ERROR, arity, NULL);
|
||||
} else if (!IsIntegerTerm(arity)) {
|
||||
Yap_ThrowError(TYPE_ERROR_INTEGER, arity, NULL);
|
||||
} else {
|
||||
Int ar = IntegerOfTerm(arity);
|
||||
if (ar < 0) {
|
||||
Yap_ThrowError(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, arity, NULL);
|
||||
}
|
||||
if ( f == FunctorDoubleSlash) {
|
||||
arity = MkIntegerTerm(ar+2);
|
||||
}
|
||||
return Yap_unify(mod, ARG2) &&
|
||||
Yap_unify(name, ARG3) &&
|
||||
Yap_unify(arity, ARG4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Yap_Error(TYPE_ERROR_PREDICATE_INDICATOR, G, NULL);
|
||||
Yap_ThrowError(TYPE_ERROR_PREDICATE_INDICATOR, G, NULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1296,9 +1327,8 @@ void Yap_InitErrorPreds(void) {
|
||||
Yap_InitCPred("$query_exception", 3, query_exception, 0);
|
||||
Yap_InitCPred("$drop_exception", 1, drop_exception, 0);
|
||||
Yap_InitCPred("$close_error", 0, close_error, HiddenPredFlag);
|
||||
Yap_InitCPred("is_boolean", 2, is_boolean, TestPredFlag);
|
||||
Yap_InitCPred("is_callable", 2, is_callable, TestPredFlag);
|
||||
Yap_InitCPred("is_atom", 2, is_atom, TestPredFlag);
|
||||
Yap_InitCPred("is_predicate_indicator", 2, is_predicate_indicator,
|
||||
TestPredFlag);
|
||||
Yap_InitCPred("is_boolean", 1, is_boolean, TestPredFlag);
|
||||
Yap_InitCPred("is_callable", 1, is_callable, TestPredFlag);
|
||||
Yap_InitCPred("is_atom", 1, is_atom, TestPredFlag);
|
||||
Yap_InitCPred("get_predicate_indicator", 4, get_predicate_indicator, 0);
|
||||
}
|
||||
|
5
C/exec.c
5
C/exec.c
@ -2174,7 +2174,7 @@ void Yap_InitYaamRegs(int myworker_id, bool full_reset) {
|
||||
#endif
|
||||
STATIC_PREDICATES_MARKED = FALSE;
|
||||
if (full_reset) {
|
||||
HR = H0 + 1;
|
||||
HB = HR = H0 + 1;
|
||||
h0var = MkVarTerm();
|
||||
REMOTE_GcGeneration(myworker_id) = Yap_NewTimedVar(h0var);
|
||||
REMOTE_GcCurrentPhase(myworker_id) = 0L;
|
||||
@ -2185,7 +2185,8 @@ void Yap_InitYaamRegs(int myworker_id, bool full_reset) {
|
||||
h0var = MkVarTerm();
|
||||
REMOTE_AttsMutableList(myworker_id) = Yap_NewTimedVar(h0var);
|
||||
#endif
|
||||
Yap_AllocateDefaultArena(128 * 1024, 2, myworker_id);
|
||||
size_t defsz = 128*1024;
|
||||
Yap_AllocateDefaultArena(defsz, myworker_id);
|
||||
} else {
|
||||
HR = Yap_ArenaLimit(REMOTE_GlobalArena(myworker_id));
|
||||
}
|
||||
|
30
C/globals.c
30
C/globals.c
@ -145,13 +145,13 @@ threads that are created <em>after</em> the registration.
|
||||
|
||||
#define Global_MkIntegerTerm(I) MkIntegerTerm(I)
|
||||
|
||||
static UInt big2arena_sz(CELL *arena_base) {
|
||||
static size_t big2arena_sz(CELL *arena_base) {
|
||||
return (((MP_INT *)(arena_base + 2))->_mp_alloc * sizeof(mp_limb_t) +
|
||||
sizeof(MP_INT) + sizeof(Functor) + 2 * sizeof(CELL)) /
|
||||
sizeof(CELL);
|
||||
}
|
||||
|
||||
static UInt arena2big_sz(UInt sz) {
|
||||
static size_t arena2big_sz(size_t sz) {
|
||||
return sz -
|
||||
(sizeof(MP_INT) + sizeof(Functor) + 2 * sizeof(CELL)) / sizeof(CELL);
|
||||
}
|
||||
@ -159,7 +159,7 @@ static UInt arena2big_sz(UInt sz) {
|
||||
/* pointer to top of an arena */
|
||||
static inline CELL *ArenaLimit(Term arena) {
|
||||
CELL *arena_base = RepAppl(arena);
|
||||
UInt sz = big2arena_sz(arena_base);
|
||||
size_t sz = big2arena_sz(arena_base);
|
||||
return arena_base + sz;
|
||||
}
|
||||
|
||||
@ -171,9 +171,9 @@ CELL *Yap_ArenaLimit(Term arena) {
|
||||
/* pointer to top of an arena */
|
||||
static inline CELL *ArenaPt(Term arena) { return (CELL *)RepAppl(arena); }
|
||||
|
||||
static inline UInt ArenaSz(Term arena) { return big2arena_sz(RepAppl(arena)); }
|
||||
static inline size_t ArenaSz(Term arena) { return big2arena_sz(RepAppl(arena)); }
|
||||
|
||||
static Term CreateNewArena(CELL *ptr, UInt size) {
|
||||
static Term CreateNewArena(CELL *ptr, size_t size) {
|
||||
Term t = AbsAppl(ptr);
|
||||
MP_INT *dst;
|
||||
|
||||
@ -186,9 +186,9 @@ static Term CreateNewArena(CELL *ptr, UInt size) {
|
||||
return t;
|
||||
}
|
||||
|
||||
static Term NewArena(UInt size, int wid, UInt arity, CELL *where) {
|
||||
static Term NewArena(size_t size, int wid, UInt arity, CELL *where) {
|
||||
Term t;
|
||||
UInt new_size;
|
||||
size_t new_size;
|
||||
WORKER_REGS(wid)
|
||||
|
||||
if (where == NULL || where == HR) {
|
||||
@ -228,11 +228,11 @@ static Int p_default_arena_size(USES_REGS1) {
|
||||
return Yap_unify(ARG1, MkIntegerTerm(ArenaSz(LOCAL_GlobalArena)));
|
||||
}
|
||||
|
||||
void Yap_AllocateDefaultArena(Int gsize, Int attsize, int wid) {
|
||||
void Yap_AllocateDefaultArena(size_t gsize, int wid) {
|
||||
REMOTE_GlobalArena(wid) = NewArena(gsize, wid, 2, NULL);
|
||||
}
|
||||
|
||||
static void adjust_cps(UInt size USES_REGS) {
|
||||
static void adjust_cps(size_t size USES_REGS) {
|
||||
/* adjust possible back pointers in choice-point stack */
|
||||
choiceptr b_ptr = B;
|
||||
while (b_ptr->cp_h == HR) {
|
||||
@ -290,14 +290,14 @@ static int GrowArena(Term arena, CELL *pt, size_t old_size, size_t size,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CELL *Yap_GetFromArena(Term *arenap, UInt cells, UInt arity) {
|
||||
CELL *Yap_GetFromArena(Term *arenap, size_t cells, UInt arity) {
|
||||
CACHE_REGS
|
||||
restart : {
|
||||
Term arena = *arenap;
|
||||
CELL *max = ArenaLimit(arena);
|
||||
CELL *base = ArenaPt(arena);
|
||||
CELL *newH;
|
||||
UInt old_sz = ArenaSz(arena), new_size;
|
||||
size_t old_sz = ArenaSz(arena), new_size;
|
||||
|
||||
if (IN_BETWEEN(base, HR, max)) {
|
||||
base = HR;
|
||||
@ -319,8 +319,8 @@ restart : {
|
||||
}
|
||||
|
||||
static void CloseArena(CELL *oldH, CELL *oldHB, CELL *oldASP, Term *oldArenaP,
|
||||
UInt old_size USES_REGS) {
|
||||
UInt new_size;
|
||||
size_t old_size USES_REGS) {
|
||||
size_t new_size;
|
||||
|
||||
if (HR == oldH)
|
||||
return;
|
||||
@ -357,7 +357,7 @@ static inline void clean_dirty_tr(tr_fr_ptr TR0 USES_REGS) {
|
||||
SP = S0+used; SF = S0+sz; }
|
||||
|
||||
static int copy_complex_term(register CELL *pt0, register CELL *pt0_end,
|
||||
int share, int copy_att_vars, CELL *ptf,
|
||||
bool share, bool copy_att_vars, CELL *ptf,
|
||||
CELL *HLow USES_REGS) {
|
||||
|
||||
int lvl = push_text_stack();
|
||||
@ -480,7 +480,7 @@ loop:
|
||||
break;
|
||||
default: {
|
||||
/* big int */
|
||||
UInt sz = (sizeof(MP_INT) + 3 * CellSize +
|
||||
size_t sz = (sizeof(MP_INT) + 3 * CellSize +
|
||||
((MP_INT *)(ap2 + 2))->_mp_alloc * sizeof(mp_limb_t)) /
|
||||
CellSize,
|
||||
i;
|
||||
|
10
C/init.c
10
C/init.c
@ -1321,8 +1321,8 @@ const char *Yap_version(void) {
|
||||
}
|
||||
|
||||
void Yap_InitWorkspace(struct yap_boot_params *yapi,
|
||||
UInt Heap, UInt Stack, UInt Trail, UInt Atts,
|
||||
UInt max_table_size, int n_workers, int sch_loop,
|
||||
UInt Heap, size_t Stack, size_t Trail, size_t Atts,
|
||||
size_t max_table_size, int n_workers, int sch_loop,
|
||||
int delay_load)
|
||||
{
|
||||
CACHE_REGS
|
||||
@ -1364,11 +1364,7 @@ void Yap_InitWorkspace(struct yap_boot_params *yapi,
|
||||
Stack = MinStackSpace;
|
||||
Stack = AdjustPageSize(Stack * K);
|
||||
Stack /= (K);
|
||||
if (!Atts)
|
||||
Atts = 2048 * sizeof(CELL);
|
||||
else
|
||||
Atts = AdjustPageSize(Atts * K);
|
||||
Atts /= (K);
|
||||
Atts = 0;
|
||||
#if defined(THREADS) || defined(YAPOR)
|
||||
worker_id = 0;
|
||||
#endif /* YAPOR || THREADS */
|
||||
|
@ -45,9 +45,6 @@ Int p_load_foreign(USES_REGS1) {
|
||||
StringList new;
|
||||
bool returncode = FALSE;
|
||||
yhandle_t CurSlot = Yap_StartSlots();
|
||||
#if __ANDROID__
|
||||
return true;
|
||||
#endif
|
||||
|
||||
// Yap_DebugPlWrite(ARG1); printf("%s\n", " \n");
|
||||
// Yap_DebugPlWrite(ARG2); printf("%s\n", " \n");
|
||||
@ -246,7 +243,28 @@ static Int p_open_shared_objects(USES_REGS1) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static Int check_embedded(USES_REGS1)
|
||||
{
|
||||
const char *s = Yap_TextTermToText(Deref(ARG1));
|
||||
if (!s)
|
||||
return false;
|
||||
#if EMBEDDED_MYDDAS
|
||||
if (!strcmp("init_myddas",s)) {
|
||||
init_myddas();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#if EMBEDDED_SQLITE3
|
||||
if (!strcmp("init_sqlite3",s)) {
|
||||
init_sqlite3();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
void Yap_InitLoadForeign(void) {
|
||||
Yap_InitCPred("$check_embedded", 1, check_embedded, SafePredFlag);
|
||||
Yap_InitCPred("$load_foreign_files", 3, p_load_foreign,
|
||||
SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("$open_shared_objects", 0, p_open_shared_objects, SafePredFlag);
|
||||
|
@ -6,7 +6,7 @@
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||
* *
|
||||
*************************************************************** f***********
|
||||
**************************************************************************
|
||||
* *
|
||||
File: modules.c *
|
||||
* Last rev: *
|
||||
@ -24,7 +24,7 @@ static char SccsId[] = "%W% %G%";
|
||||
#include "YapHeap.h"
|
||||
#include "Yatom.h"
|
||||
|
||||
static Int current_module(USES_REGS1);
|
||||
static Int currgent_module(USES_REGS1);
|
||||
static Int current_module1(USES_REGS1);
|
||||
static ModEntry *LookupModule(Term a);
|
||||
static ModEntry *LookupSystemModule(Term a);
|
||||
@ -197,6 +197,7 @@ Term Yap_Module(Term tmod) {
|
||||
|
||||
ModEntry *Yap_GetModuleEntry(Term mod) {
|
||||
ModEntry *me;
|
||||
|
||||
if (!(me = LookupModule(mod)))
|
||||
return NULL;
|
||||
return me;
|
||||
|
2
C/qlyr.c
2
C/qlyr.c
@ -1110,7 +1110,7 @@ YAP_file_type_t Yap_Restore(const char *s) {
|
||||
return -1;
|
||||
GLOBAL_RestoreFile = s;
|
||||
if (do_header(stream) == NIL)
|
||||
return YAP_BOOT_PL;
|
||||
return YAP_PL;
|
||||
read_module(stream);
|
||||
setBooleanGlobalPrologFlag(SAVED_PROGRAM_FLAG, true);
|
||||
fclose(stream);
|
||||
|
@ -1618,9 +1618,6 @@ void Yap_InitCPreds(void) {
|
||||
while (*p)
|
||||
(*(*p++))();
|
||||
}
|
||||
#if USE_MYDDAS
|
||||
init_myddas();
|
||||
#endif
|
||||
#if CAMACHO
|
||||
{
|
||||
extern void InitForeignPreds(void);
|
||||
|
1757
C/utilpreds.c
1757
C/utilpreds.c
File diff suppressed because it is too large
Load Diff
1221
C/yap-args.c
1221
C/yap-args.c
File diff suppressed because it is too large
Load Diff
291
CMakeLists.txt
291
CMakeLists.txt
@ -65,6 +65,9 @@ if (POLICY CMP0003)
|
||||
endif ()
|
||||
if (POLICY CMP0068)
|
||||
cmake_policy(SET CMP0068 NEW)
|
||||
endif()
|
||||
if (POLICY CMP0075)
|
||||
cmake_policy(SET CMP0075 NEW)
|
||||
endif ()
|
||||
|
||||
## options: compilation flags
|
||||
@ -83,8 +86,9 @@ endif ()
|
||||
|
||||
## options: libraries
|
||||
option(WITH_THREADED_CODE "threaded code" ON)
|
||||
if (NOT ANDROID)
|
||||
option(WITH_MPI "Interface to OpenMPI/MPICH" ON)
|
||||
option(WITH_READLINE "use readline or libedit" ON)
|
||||
endif()
|
||||
option(WITH_JIT "just in Time Clause Compilation" OFF)
|
||||
|
||||
if (APPLE)
|
||||
@ -121,7 +125,7 @@ if (APPLE)
|
||||
GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
|
||||
|
||||
# "/opt/local/bin" doesn't have libs, so we get the parent directory
|
||||
GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
|
||||
GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PssREFIX} DIRECTORY)
|
||||
|
||||
# "/opt/local" is where MacPorts lives, add `/lib` suffix and link
|
||||
LINK_DIRECTORIES(${LINK DIRECTORIES} ${MACPORTS_PREFIX}/lib)
|
||||
@ -131,19 +135,35 @@ if (APPLE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option (WITH_PACKAGES "packages and liaries that add value to YAP" ON)
|
||||
OPTION(WITH_MYDDAS " Enable MYDDAS DBMS interface" ON)
|
||||
|
||||
OPTION(WITH_MYDDAS " Enable MYDDAS driver" ${WITH_PACKAGES})
|
||||
OPTION(WITH_SQLITE3 " Enable MYDDAS SQLITE3 driver" ${WITH_MYDDAS})
|
||||
OPTION(WITH_MYSQL " Enable MYDDAS MYSQL driver" ${WITH_MYDDAS})
|
||||
if (ANDROID)
|
||||
option (WITH_PACKAGES "packages and libraries that add value to YAP" OFF)
|
||||
OPTION(WITH_SWIG " Enable SWIG interfaces to foreign languages" ON)
|
||||
OPTION(WITH_SQLITE3 " Enable MYDDAS SQLITE3 driver" ON)
|
||||
else()
|
||||
option (WITH_PACKAGES "packages and libraries that add value to YAP" ON)
|
||||
OPTION(WITH_SWIG " Enable SWIG interfaces to foreign languages" ${WITH_PACKAGES})
|
||||
OPTION(WITH_SQLITE3 " Enable MYDDAS SQLITE3 driver" ${WITH_PACKAGES})
|
||||
endif()
|
||||
OPTION(WITH_MYSQL " Enable MYDDAS MYSQL driver" ${WITH_MYDDAS}})
|
||||
OPTION(WITH_ODBC " Enable MYDDAS ODBC driver" ${WITH_MYDDAS})
|
||||
OPTION(WITH_POSTGRES " Enable MYDDAS POSTGRES driver" ${WITH_MYDDAS})
|
||||
OPTION(WITH_SQLITE3 " Enable MYDDAS SQLITE3 driver" ${WITH_MYDDAS})
|
||||
OPTION(WITH_SWIG " Enable SWIG interfaces to foreign languages" ${WITH_PACKAGES})
|
||||
|
||||
|
||||
|
||||
IF (WITH_SWIG)
|
||||
find_host_package(SWIG)
|
||||
# macro_log_feature (SWIG_FOUND "Swig"
|
||||
# "Use SWIG Interface Generator "
|
||||
# "http://www.swig.org" ON)
|
||||
|
||||
ENDIF (WITH_SWIG)
|
||||
|
||||
OPTION(WITH_RAPTOR " Enable the RAPTOR RDF library" ${WITH_PACKAGES})
|
||||
OPTION(WITH_XML2 " Enable the RAPTOR XML2 library" ${WITH_PACKAGES})
|
||||
OPTION(WITH_XML " Enable the Prolog XML library" ${WITH_PACKAGES})
|
||||
OPTION(WITH_CLPBN" Enable the CLPBN and PFL probabilistic languages" ${WITH_PACKAGES})
|
||||
OPTION(WITH_CLPBN " Enable the CLPBN and PFL probabilistic languages" ${WITH_PACKAGES})
|
||||
OPTION(WITH_HORUS " Enable the HORUS inference libraray for CLPBN and PFL" ${WITH_CLPBN})
|
||||
option(WITH_PROBLOG "include Problog-I." ${WITH_PACKAGES})
|
||||
OPTION(WITH_CPLINT " Enable the cplint probabilistic language" ${WITH_PACKAGES})
|
||||
@ -152,7 +172,7 @@ option(WITH_LBFGS "interface with lbfgs" ${WITH_PACKAGES})
|
||||
option(WITH_PRISM "use PRISM system in YAP" ${WITH_PACKAGES})
|
||||
option(WITH_PYTHON "Allow Python->YAP and YAP->Python" ${WITH_PACKAGES})
|
||||
option(WITH_R "Use R Interface" ${WITH_PACKAGES})
|
||||
option(WITH_JAVA "Try to use Java (currently Java 6,7,8)" ${WITH_PACKAGES})
|
||||
option(WITH_JAVA "Try to use Java (currently Java )" ${WITH_PACKAGES})
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
||||
@ -165,21 +185,16 @@ if (POLICY CMP0042)
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
endif ()
|
||||
|
||||
function(add_to_group list output)
|
||||
set(tmp ${${output}})
|
||||
foreach (path ${${list}})
|
||||
get_source_file_property(path ${path} LOCATION)
|
||||
list(APPEND tmp ${path})
|
||||
endforeach ()
|
||||
set(${output} ${tmp} CACHE INTERNAL "prolog library files")
|
||||
endfunction(add_to_group list output)
|
||||
if (ANDROID)
|
||||
function(add_to_dir list output)
|
||||
endfunction(add_to_dir list output)
|
||||
|
||||
function(add_to_libgroup el list)
|
||||
# add_custom_command( TARGET ${el} POST_BUILD
|
||||
# COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${el}> ${CMAKE_BINARY_DIR}/packages/python/swig/yap4py
|
||||
# DEPENDS ${el} )
|
||||
list(APPEND ${list} ${${el}})
|
||||
set(${list} ${${list}} CACHE INTERNAL "prolog dll files")
|
||||
#list(APPEND ${list} ${${el}})
|
||||
#set(${list} ${${list}} CACHE INTERNAL "prolog dll files")
|
||||
endfunction(add_to_libgroup el list)
|
||||
|
||||
|
||||
@ -191,6 +206,11 @@ function(add_to_corelibgroup el list)
|
||||
set(${list} ${${list}} CACHE INTERNAL "prolog dll files")
|
||||
endfunction(add_to_corelibgroup el list)
|
||||
|
||||
else()
|
||||
function(add_to_dir list output)
|
||||
endfunction(add_to_dir list output)
|
||||
|
||||
endif()
|
||||
|
||||
if (ANDROID_OLD)
|
||||
macro(MY_add_custom_target)
|
||||
@ -210,10 +230,6 @@ else ()
|
||||
add_library(${arg1} OBJECT ${ARGN})
|
||||
endmacro()
|
||||
endif ()
|
||||
macro(add_lib arg1)
|
||||
add_library(${arg1} SHARED ${ARGN})
|
||||
add_to_libgroup(${arg1} YAP_DLLS)
|
||||
endmacro()
|
||||
macro(add_corelib arg1)
|
||||
add_library(${arg1} SHARED ${ARGN})
|
||||
add_to_corelibgroup(${arg1} YAP_DLLS)
|
||||
@ -294,21 +310,21 @@ disallow_intree_builds()
|
||||
|
||||
# set(CMAKE_BUILD_TYPE Debug)
|
||||
|
||||
if ($ENV{CONDA_BUILD}x STREQUAL "1x" )
|
||||
if ($ENV{CONDA_BUILD}x STREQUAL "1x" )
|
||||
set(CMAKE_LIBRARY_ARCHITECTURE $ENV{PREFIX})
|
||||
set(CMAKE_PREFIX_PATH $ENV{PREFIX})
|
||||
set( R_COMMAND "$ENV{R}")
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS CONDA_BUILD=1)
|
||||
list (APPEND CMAKE_REQUIRED_INCLUDES
|
||||
${PREFIX}/include
|
||||
${SYS_PREFIX}/include
|
||||
)
|
||||
set(YAP_IS_MOVABLE 1)
|
||||
|
||||
endif()
|
||||
|
||||
ADD_CUSTOM_TARGET(run_install COMMAND ${CMAKE_MAKE_PROGRAM} install)
|
||||
|
||||
list (APPEND CMAKE_REQUIRED_INCLUDES
|
||||
${PREFIX}/include
|
||||
${SYS_PREFIX}/include
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -327,8 +343,11 @@ set(YAP_PLDIR ${CMAKE_INSTALL_FULL_DATADIR}/Yap)
|
||||
|
||||
set(YAP_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/Yap)
|
||||
set(YAP_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}/Yap)
|
||||
if (ANDROID)
|
||||
set(YAP_INSTALL_DATADIR ${CMAKE_SOURCE_DIR}/../yaplib/src/generated/assets/Yap)
|
||||
else()
|
||||
set(YAP_INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR}/Yap)
|
||||
|
||||
endif()
|
||||
#
|
||||
#
|
||||
# include( Sources )
|
||||
@ -350,30 +369,43 @@ find_package(GMP)
|
||||
|
||||
list(APPEND YAP_SYSTEM_OPTIONS big_numbers)
|
||||
|
||||
|
||||
|
||||
if (GMP_INCLUDE_DIRS)
|
||||
#config.h needs this (TODO: change in code latter)
|
||||
include_directories(${GMP_INCLUDE_DIRS})
|
||||
endif ()
|
||||
|
||||
|
||||
if (WITH_READLINE)
|
||||
# - Find the readline library
|
||||
# This module defines
|
||||
# READLINE_INCLUDE_DIR, path to readline/readline.h, etc.
|
||||
# READLINE_LIBRARIES, the libraries required to use READLINE.
|
||||
# READLINE_FOUND, If false, do not try to use READLINE.
|
||||
# also defined, but not for general use are
|
||||
# READLINE_readline_LIBRARY, where to find the READLINE library.
|
||||
# READLINE_ncurses_LIBRARY, where to find the ncurses library [might not be defined]
|
||||
|
||||
include(FindReadline)
|
||||
|
||||
List(APPEND YAP_SYSTEM_OPTIONS readline)
|
||||
option (WITH_READLINE "use Readline" ON)
|
||||
# include subdirectories configuration
|
||||
## after we have all functionality in
|
||||
#
|
||||
# ADD_SUBDIRECTORY(console/terminal)
|
||||
|
||||
if (READLINE_FOUND)
|
||||
include_directories(${READLINE_INCLUDE_DIR})
|
||||
List(APPEND YAP_SYSTEM_OPTIONS readline)
|
||||
# required for configure
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${READLINE_LIBRARIES})
|
||||
list(APPEND CMAKE_REQUIRED_INCLUDES ${READLINE_INCLUDE_DIR})
|
||||
include_directories( ${READLINE_INCLUDE_DIR}
|
||||
${READLINE_INCLUDE_DIR}/readline
|
||||
)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
include_directories(H
|
||||
H/generated
|
||||
include os OPTYap utf8proc JIT/HPP)
|
||||
include_directories(BEFORE ${CMAKE_BINARY_DIR})
|
||||
|
||||
add_subdirectory( H )
|
||||
|
||||
#MPI STUFF
|
||||
# library/mpi/mpi.c library/mpi/mpe.c
|
||||
@ -426,7 +458,6 @@ set(DEF_STACKSPACE 0)
|
||||
set(DEF_HEAPSPACE 0)
|
||||
set(DEF_TRAILSPACE 0)
|
||||
|
||||
# option (RATIONAL_TREES "support infinite rational trees" ON)
|
||||
# dd_definitions (-D)
|
||||
|
||||
## don't touch these opts
|
||||
@ -473,7 +504,7 @@ endif ()
|
||||
## (but later on when installing)
|
||||
#SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||
#
|
||||
## SET(CMAKE_INSTALL_FULL_RPATH ${CMAKE_TOP_BINARY_DIR})
|
||||
## SET(CMAKE_INSTALL_FULL_RPATH ${CMAKE_BINARY_DIR})
|
||||
#
|
||||
## add the automatically determined parts of the RPATH
|
||||
## which point to directories outside the build tree to the install RPATH
|
||||
@ -498,6 +529,9 @@ ELSE()
|
||||
LIST(APPEND CMAKE_INSTALL_RPATH @loader_path/../../../lib)
|
||||
ENDIF()
|
||||
|
||||
set(YAP_STARTUP startup.yss)
|
||||
set(YAP_SOURCEBOOT boot.yap )
|
||||
|
||||
# Model Specific
|
||||
if (HAVE_GCC)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -Wall)
|
||||
@ -520,6 +554,7 @@ endif (HAVE_GCC)
|
||||
#
|
||||
#option (YAP_SWI_IO ON)
|
||||
|
||||
#TODO:
|
||||
#TODO:
|
||||
if (WITH_CALL_TRACER)
|
||||
list(APPEND YAP_SYSTEM_OPTIONS "call_tracer " ${YAP_SYSTEM_OPTIONS})
|
||||
@ -528,41 +563,9 @@ endif (WITH_CALL_TRACER)
|
||||
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS UTF8PROC=1)
|
||||
|
||||
include_directories(utf8proc packages/myddas packages/myddas/sqlite3/src )
|
||||
|
||||
set_property(SOURCE ${LIBYAP_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1)
|
||||
|
||||
|
||||
IF (WITH_SWIG)
|
||||
find_host_package(SWIG)
|
||||
# macro_log_feature (SWIG_FOUND "Swig"
|
||||
# "Use SWIG Interface Generator "
|
||||
# "http://www.swig.org" ON)
|
||||
ENDIF (WITH_SWIG)
|
||||
|
||||
IF (WITH_MYDDAS)
|
||||
if (ANDROID)
|
||||
include_directories (packages/swig/android)
|
||||
else()
|
||||
|
||||
add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1)
|
||||
|
||||
if (MYSQL_FOUND)
|
||||
add_definitions(= -DMYDDAS_MYSQL=1)
|
||||
endif ()
|
||||
|
||||
if (ODBC_FOUND)
|
||||
add_definitions(= -DMYDDAS_ODBC=1)
|
||||
endif ()
|
||||
|
||||
if (MYSQL_POSTGRES)
|
||||
add_definitions(= -DMYDDAS_POSTGRES=1)
|
||||
endif ()
|
||||
endif(ANDROID)
|
||||
endif(WITH_MYDDAS)
|
||||
|
||||
|
||||
|
||||
IF (WITH_PYTHON)
|
||||
include(python )
|
||||
ENDIF (WITH_PYTHON)
|
||||
@ -574,6 +577,55 @@ IF (WITH_R)
|
||||
ENDIF (WITH_R)
|
||||
|
||||
|
||||
include(Sources)
|
||||
|
||||
|
||||
ADD_SUBDIRECTORY(OPTYap)
|
||||
ADD_SUBDIRECTORY(os)
|
||||
ADD_SUBDIRECTORY(library/dialect/swi/fli)
|
||||
ADD_SUBDIRECTORY(CXX)
|
||||
|
||||
ADD_SUBDIRECTORY(pl)
|
||||
|
||||
ADD_SUBDIRECTORY(library)
|
||||
|
||||
ADD_SUBDIRECTORY(swi/library)
|
||||
|
||||
add_subDIRECTORY(utf8proc )
|
||||
|
||||
|
||||
|
||||
if(ANDROID)
|
||||
|
||||
set(CXX_SWIG_OUTDIR ${CMAKE_BINARY_DIR}/packages/swig/android)
|
||||
add_subdirectory(packages/swig/android)
|
||||
add_definitions(-DMYDDAS=1 -DEMBEDDED_MYDDAS=1 -DMYDDAS_SQLITE3=1 -DEMBEDDED_SQLITE3=1)
|
||||
link_directories(${CMAKE_SOURCE_DIR}/../sqlite-android/jni/${CMAKE_ANDROID_ARCH_ABI})
|
||||
|
||||
else()
|
||||
add_definitions(-DMYDDAS=1 -DEMBEDDED_MYDDAS=1 -DMYDDAS_SQLITE3=1 )
|
||||
|
||||
endif()
|
||||
if (MYSQL_FOUND)
|
||||
add_definitions( -DMYDDAS_MYSQL=1)
|
||||
endif ()
|
||||
|
||||
if (ODBC_FOUND)
|
||||
add_definitions( -DMYDDAS_ODBC=1)
|
||||
endif ()
|
||||
|
||||
if (POSTGRES_FOUND)
|
||||
add_definitions( -DMYDDAS_POSTGRES=1)
|
||||
endif()
|
||||
#utf-8 is not aPconn option
|
||||
# we use the nice UTF-8 package
|
||||
#available at the Julia project
|
||||
|
||||
|
||||
add_subDIRECTORY( packages/myddas )
|
||||
add_subDIRECTORY( packages/clpqr )
|
||||
|
||||
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:libOPTYap>)
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:libYAPOs>)
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:utf8proc>)
|
||||
@ -583,51 +635,43 @@ if (WIN32 OR ANDROID)
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:YAP++>)
|
||||
if (WIN32 AND WITH_PYTHON)
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:Py4YAP>)
|
||||
list (APPEND WINDLLS ${PYTHON_LIBRARIES})
|
||||
endif ()
|
||||
if (ANDROID)
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:YAPsqlite3>)
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:YAPJava>)
|
||||
List(APPEND YLIBS $<TARGET_OBJECTS:DROID>)
|
||||
set(ANDROID_LIBRARIES sqliteX android log)
|
||||
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
include(Sources)
|
||||
|
||||
|
||||
add_corelib( # Sets the name of the library.
|
||||
add_library( # Sets the name of the library.
|
||||
libYap
|
||||
|
||||
# Sets the library as a shared library.
|
||||
SHARED
|
||||
|
||||
${ENGINE_SOURCES}
|
||||
${C_INTERFACE_SOURCES}
|
||||
//${STATIC_SOURCES}
|
||||
${STATIC_SOURCES}
|
||||
# cmake object libraries
|
||||
${YLIBS}
|
||||
)
|
||||
|
||||
if (GMP_FOUND)
|
||||
target_link_libraries(libYap ${GMP_LIBRARIES})
|
||||
endif (GMP_FOUND)
|
||||
target_link_libraries(libYap
|
||||
m
|
||||
${GMP_LIBRARIES}
|
||||
${READLINE_LIBRARIES}
|
||||
${ANDROID_LIBRARIES}
|
||||
${WINDLLS}
|
||||
${PYTHON_LIBRARIES}
|
||||
)
|
||||
|
||||
if (READLINE_FOUND)
|
||||
target_link_libraries(libYap ${READLINE_LIBRARIES})
|
||||
# required for configure
|
||||
|
||||
endif ()
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(libYap ${WINDLLS})
|
||||
if (WITH_PYTHON AND PYTHON_INCLUDE_DIRS AND PYTHON_LIBRARIES)
|
||||
target_link_libraries(libYap ${PYTHON_LIBRARIES})
|
||||
endif ()
|
||||
endif (WIN32)
|
||||
|
||||
target_link_libraries(libYap m)
|
||||
set_target_properties(libYap
|
||||
PROPERTIES OUTPUT_NAME Yap
|
||||
)
|
||||
|
||||
|
||||
set(YAP_STARTUP startup.yss)
|
||||
set(YAP_BOOTFILE boot.yap )
|
||||
## define system
|
||||
|
||||
# Optional libraries that affect compilation
|
||||
@ -646,13 +690,8 @@ string(SUBSTRING ${CMAKE_SHARED_LIBRARY_SUFFIX} 1 -1 SO_EXT)
|
||||
set_property(DIRECTORY PROPERTY CXX_STANDARD 11)
|
||||
|
||||
|
||||
include_directories(H
|
||||
H/generated
|
||||
include os OPTYap utf8proc JIT/HPP)
|
||||
include_directories(BEFORE ${CMAKE_BINARY_DIR} ${CMAKE_TOP_BINARY_DIR})
|
||||
|
||||
if (ANDROID)
|
||||
include_directories(CXX ${CMAKE_SOURCE_DIR}/../generated/src/jni)
|
||||
include_directories(CXX ${CMAKE_SOURCE_DIR}/../yaplib/generated/src/jni)
|
||||
endif ()
|
||||
include(Threads)
|
||||
#
|
||||
@ -672,30 +711,6 @@ MY_set_target_properties(libYap
|
||||
)
|
||||
|
||||
|
||||
#utf-8 is not aPconn option
|
||||
# we use the nice UTF-8 package
|
||||
#available at the Julia project
|
||||
|
||||
ADD_SUBDIRECTORY(OPTYap)
|
||||
ADD_SUBDIRECTORY(os)
|
||||
ADD_SUBDIRECTORY(packages/myddas)
|
||||
ADD_SUBDIRECTORY(utf8proc)
|
||||
ADD_SUBDIRECTORY(library/dialect/swi/fli)
|
||||
ADD_SUBDIRECTORY(CXX)
|
||||
|
||||
|
||||
add_subDIRECTORY(H)
|
||||
|
||||
#bootstrap and saved state
|
||||
add_subDIRECTORY(pl)
|
||||
|
||||
ADD_SUBDIRECTORY(library)
|
||||
|
||||
ADD_SUBDIRECTORY(swi/library "swiLibrary")
|
||||
|
||||
set_target_properties(libYap
|
||||
PROPERTIES OUTPUT_NAME Yap
|
||||
)
|
||||
|
||||
# file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/packages/python/swig/yap4py)
|
||||
|
||||
@ -717,20 +732,6 @@ if (WITH_PYTHON AND PYTHONLIBS_FOUND AND SWIG_FOUND)
|
||||
endif ()
|
||||
|
||||
|
||||
IF ( ANDROID)
|
||||
set(CMAKE_SWIG_OUTDIR ${YAP_APP_DIR}/src/generated/java/pt/up/yap/lib )
|
||||
set(CMAKE_SWIG_OUTPUT ${YAP_APP_DIR}/src/generated/jni )
|
||||
set( SWIG_MODULE_NAME pt.up.yap.lib )
|
||||
|
||||
add_subDIRECTORY(packages/swig )
|
||||
|
||||
|
||||
|
||||
|
||||
target_link_libraries(libYap ${CMAKE_SOURCE_DIR}/../sqlite-android/jni/${ANDROID_ABI}/libsqliteX.so android log )
|
||||
|
||||
ENDIF ()
|
||||
|
||||
|
||||
message(STATUS "Building YAP packages version ${YAP_VERSION}")
|
||||
|
||||
@ -897,7 +898,7 @@ endif()
|
||||
|
||||
#todo: use cmake target builds
|
||||
# option (USE_MAXPERFORMANCE
|
||||
# "try using the best flags for specific architecture" OFF)
|
||||
# "try using the best flags for specific architecture" ON)
|
||||
|
||||
# option (USE_MAXMEMORY
|
||||
# "try using the best flags for using the memory to the most" ON)
|
||||
@ -905,11 +906,11 @@ endif()
|
||||
|
||||
#TODO: use cmake target builds
|
||||
# option (USE_DEBUGYAP
|
||||
# "enable C-debugging for YAP" OFF)
|
||||
# "enable C-debugging for YAP" ON)
|
||||
|
||||
#TODO: use cmake arch/compiler
|
||||
# option (USE_CYGWIN
|
||||
# "use cygwin library in WIN32" OFF)
|
||||
# "use cygwin library in WIN32" ON)
|
||||
|
||||
#TODO:
|
||||
|
||||
@ -987,8 +988,6 @@ endif(WITH_MPI)
|
||||
|
||||
install(FILES ${INCLUDE_HEADERS} ${CONFIGURATION_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Yap )
|
||||
|
||||
|
||||
|
||||
macro_display_feature_log()
|
||||
if (POLICY CMP0058)
|
||||
cmake_policy(SET CMP0058 NEW)
|
||||
|
@ -14,7 +14,7 @@ if ( WIN32 OR ANDROID)
|
||||
|
||||
set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "_YAP_NOT_INSTALLED_=1;HAVE_CONFIG_H=1;_GNU_SOURCE;YAP_KERNEL=1" )
|
||||
else()
|
||||
add_lib(YAP++ ${CXX_SOURCES} )
|
||||
add_library(YAP++ ${CXX_SOURCES} )
|
||||
if (WITH_PYTHON)
|
||||
target_link_libraries(YAP++ Py4YAP )
|
||||
endif()
|
||||
|
@ -599,11 +599,12 @@ bool YAPEngine::mgoal(Term t, Term tmod, bool release) {
|
||||
q.CurSlot = Yap_StartSlots();
|
||||
q.p = P;
|
||||
q.cp = CP;
|
||||
Term omod = CurrentModule;
|
||||
PredEntry *ap = nullptr;
|
||||
if (IsStringTerm(tmod))
|
||||
tmod = MkAtomTerm(Yap_LookupAtom(StringOfTerm(tmod)));
|
||||
YAPPredicate *p = new YAPPredicate(t, tmod, ts, "C++");
|
||||
if (p == nullptr || (ap = p->ap) == nullptr ||
|
||||
ap = Yap_get_pred(t, tmod, "C++");
|
||||
if (ap == nullptr ||
|
||||
ap->OpcodeOfPred == UNDEF_OPCODE) {
|
||||
ap = rewriteUndefEngineQuery(ap, t, tmod);
|
||||
}
|
||||
@ -627,6 +628,7 @@ bool YAPEngine::mgoal(Term t, Term tmod, bool release) {
|
||||
// std::cerr << "mgoal " << YAPTerm(tmod).text() << ":" << YAPTerm(t).text() << "\n";
|
||||
|
||||
YAP_LeaveGoal(result && !release, &q);
|
||||
CurrentModule = LOCAL_SourceModule = omod;
|
||||
// PyEval_RestoreThread(_save);
|
||||
RECOVER_MACHINE_REGS();
|
||||
return result;
|
||||
@ -801,6 +803,7 @@ PredEntry *YAPQuery::rewriteUndefQuery() {
|
||||
PredEntry *YAPEngine::rewriteUndefEngineQuery(PredEntry *a, Term &tgoal,
|
||||
Term mod) {
|
||||
tgoal = Yap_MkApplTerm(FunctorCall, 1, &tgoal);
|
||||
LOCAL_ActiveError->errorNo = YAP_NO_ERROR;
|
||||
return PredCall;
|
||||
|
||||
// return YAPApplTerm(FunctorUndefinedQuery, ts);
|
||||
@ -919,6 +922,7 @@ void YAPEngine::doInit(YAP_file_type_t BootMode, YAPEngineArgs *engineArgs) {
|
||||
// initq.cut();
|
||||
// }
|
||||
CurrentModule = TermUser;
|
||||
LOCAL_SourceModule = TermUser;
|
||||
}
|
||||
|
||||
YAPEngine::YAPEngine(int argc, char *argv[],
|
||||
|
19
CXX/yapq.hh
19
CXX/yapq.hh
@ -94,7 +94,7 @@ public:
|
||||
/// should be a callable
|
||||
/// goal.
|
||||
inline YAPQuery(const char *s) : YAPPredicate(s, goal, names, (nts = &ARG1)) {
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "got game %ld",
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "got game %d",
|
||||
LOCAL_CurSlot);
|
||||
|
||||
openQuery();
|
||||
@ -175,11 +175,11 @@ struct X_API YAPEngineArgs : YAP_init_args {
|
||||
|
||||
public:
|
||||
YAPEngineArgs() {
|
||||
memset(this,0,sizeof(YAPEngineArgs));
|
||||
// const std::string *s = new std::string("startup.yss");
|
||||
Embedded = true;
|
||||
install = false;
|
||||
|
||||
Yap_InitDefaults(this, nullptr, 0, nullptr);
|
||||
Yap_InitDefaults(&this->start, nullptr, 0, nullptr);
|
||||
#if YAP_PYTHON
|
||||
Embedded = true;
|
||||
python_in_python = Py_IsInitialized();
|
||||
@ -231,12 +231,12 @@ public:
|
||||
|
||||
inline const char *getOUTPUT_STARTUP() { return OUTPUT_STARTUP; };
|
||||
|
||||
inline void setBOOTFILE(const char *fl) {
|
||||
BOOTFILE = (const char *)malloc(strlen(fl) + 1);
|
||||
strcpy((char *)BOOTFILE, fl);
|
||||
inline void setSOURCEBOOT(const char *fl) {
|
||||
SOURCEBOOT = (const char *)malloc(strlen(fl) + 1);
|
||||
strcpy((char *)SOURCEBOOT, fl);
|
||||
};
|
||||
|
||||
inline const char *getBOOTFILE() { return BOOTFILE; };
|
||||
inline const char *getSOURCEBOOT() { return SOURCEBOOT; };
|
||||
|
||||
inline void setPrologBOOTSTRAP(const char *fl) {
|
||||
BOOTSTRAP = (const char *)malloc(strlen(fl) + 1);
|
||||
@ -298,7 +298,7 @@ public:
|
||||
__android_log_print(
|
||||
ANDROID_LOG_INFO, "YAPDroid", "start engine ");
|
||||
#ifdef __ANDROID__
|
||||
doInit(YAP_BOOT_PL, cargs);
|
||||
doInit(YAP_PL, cargs);
|
||||
|
||||
#else
|
||||
doInit(YAP_QLY, cargs);
|
||||
@ -352,7 +352,8 @@ public:
|
||||
bool mgoal(Term t, Term tmod, bool release = false);
|
||||
/// current directory for the engine
|
||||
|
||||
bool goal(Term t, bool release = false) {
|
||||
bool goal(YAPTerm t, bool release = false) { return goal(t.term(), release); }
|
||||
bool goal(Term t, bool release = false) {
|
||||
return mgoal(t, Yap_CurrentModule(), release);
|
||||
}
|
||||
/// reset Prolog state
|
||||
|
@ -12,10 +12,10 @@ string(REGEX REPLACE "^LOCAL[^(]*[(][ \t]*([^,]+)[ \t]*,[ \t]*([^),]+).*" "#de
|
||||
list( APPEND tmp2 ${i2} "\n")
|
||||
endforeach()
|
||||
endif()
|
||||
file( WRITE ${CMAKE_TOP_BINARY_DIR}/dlocals.h ${tmp2})
|
||||
file( WRITE ${CMAKE_BINARY_DIR}/dlocals.h ${tmp2})
|
||||
|
||||
add_custom_command( OUTPUT ${CMAKE_TOP_BINARY_DIR}/dlocals.h
|
||||
COMMAND ${CMAKE_COMMAND} -E COPY ${CMAKE_TOP_BINARY_DIR}/deflocals.h ${CMAKE_TOP_BINARY_DIR}/dlocals.h
|
||||
add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/dlocals.h
|
||||
COMMAND ${CMAKE_COMMAND} -E COPY ${CMAKE_BINARY_DIR}/deflocals.h ${CMAKE_BINARY_DIR}/dlocals.h
|
||||
DEPENDS locals.h )
|
||||
|
||||
|
||||
|
2
H/Yap.h
2
H/Yap.h
@ -175,7 +175,7 @@ typedef void *(*fptr_t)(void);
|
||||
|
||||
extern const char *Yap_BINDIR, *Yap_ROOTDIR, *Yap_SHAREDIR, *Yap_LIBDIR, *Yap_DLLDIR,
|
||||
*Yap_PLDIR, *Yap_COMMONSDIR, *Yap_STARTUP,*Yap_INPUT_STARTUP,*Yap_OUTPUT_STARTUP,
|
||||
*Yap_BOOTFILE, *Yap_INCLUDEDIR;
|
||||
*Yap_SOURCEBOOT, *Yap_INCLUDEDIR;
|
||||
|
||||
|
||||
/* Basic exports */
|
||||
|
@ -354,23 +354,12 @@ vxu `on` consider `$` a lower case character.
|
||||
*/
|
||||
YAP_FLAG(LANGUAGE_FLAG, "language", true, isatom, "yap", NULL),
|
||||
|
||||
/**< if defined, first location where YAP expects to find the YAP Prolog
|
||||
library. Takes precedence over library_directory */
|
||||
YAP_FLAG(PROLOG_LIBRARY_DIRECTORY_FLAG, "prolog_library_directory", true,
|
||||
isatom, "", NULL),
|
||||
|
||||
/**< if defined, first location where YAP expects to find the YAP Prolog
|
||||
shared libraries (DLLS). Takes precedence over executable_directory/2. */
|
||||
/**< `max_arity is iso `
|
||||
YAP_FLAG(MAX_ARITY_FLAG, "max_arity", false, isatom, "unbounded", NULL),
|
||||
|
||||
Read-only flag telling the maximum arity of a functor. Takes the value
|
||||
`unbounded` for the current version of YAP.
|
||||
*/
|
||||
YAP_FLAG(PROLOG_FOREIGN_DIRECTORY_FLAG, "prolog_foreign_directory", true,
|
||||
isatom, "", NULL),
|
||||
|
||||
|
||||
YAP_FLAG(MAX_ARITY_FLAG, "max_arity", false, isatom, "unbounded", NULL),
|
||||
|
||||
YAP_FLAG(MAX_TAGGED_INTEGER_FLAG, "max_tagged_integer", false, at2n,
|
||||
"INT_MAX", NULL),
|
||||
@ -378,7 +367,14 @@ vxu `on` consider `$` a lower case character.
|
||||
YAP_FLAG(MAX_WORKERS_FLAG, "max_workers", false, at2n, "MAX_WORKERS", NULL),
|
||||
YAP_FLAG(MIN_TAGGED_INTEGER_FLAG, "min_tagged_integer", false, at2n,
|
||||
"INT_MIN", NULL),
|
||||
YAP_FLAG(N_OF_INTEGER_KEYS_IN_DB_FLAG, "n_of_integer_keys_in_db", false, ro,
|
||||
|
||||
|
||||
YAP_FLAG(MODULE_INDEPENDENT_OPERATORS_FLAG, "module_independent_operators",
|
||||
true, booleanFlag, "false", NULL),
|
||||
|
||||
|
||||
|
||||
YAP_FLAG(N_OF_INTEGER_KEYS_IN_DB_FLAG, "n_of_integer_keys_in_db", false, ro,
|
||||
"256", NULL),
|
||||
YAP_FLAG(OCCURS_CHECK_FLAG, "occurs_check", true, booleanFlag, "false",
|
||||
NULL),
|
||||
@ -407,8 +403,16 @@ vxu `on` consider `$` a lower case character.
|
||||
"true", NULL),
|
||||
|
||||
|
||||
YAP_FLAG(MODULE_INDEPENDENT_OPERATORS_FLAG, "module_independent_operators",
|
||||
true, booleanFlag, "false", NULL),
|
||||
/**< if defined, first location where YAP expects to find the YAP Prolog
|
||||
library. Takes precedence over library_directory */
|
||||
YAP_FLAG(PROLOG_LIBRARY_DIRECTORY_FLAG, "prolog_library_directory", true,
|
||||
isatom, "", NULL),
|
||||
|
||||
/**< if defined, first location where YAP expects to find the YAP Prolog
|
||||
shared libraries (DLLS). Takes precedence over executable_directory/2. */
|
||||
YAP_FLAG(PROLOG_FOREIGN_DIRECTORY_FLAG, "prolog_foreign_directory", true,
|
||||
isatom, "", NULL),
|
||||
|
||||
|
||||
YAP_FLAG(OPTIMISE_FLAG, "optimise", true, booleanFlag, "false", NULL),
|
||||
YAP_FLAG(OS_ARGV_FLAG, "os_argv", false, os_argv, "@boot", NULL),
|
||||
@ -566,7 +570,6 @@ and if it is bound to `off` disable them. The default for YAP is
|
||||
*/
|
||||
YAP_FLAG(TABLING_MODE_FLAG, "tabling_mode", true, isatom, "[]", NULL),
|
||||
|
||||
YAP_FLAG(THREADS_FLAG, "threads", false, ro, "MAX_THREADS", NULL),
|
||||
YAP_FLAG(TIMEZONE_FLAG, "timezone", false, ro, "18000", NULL),
|
||||
/**< `toplevel_hook `
|
||||
|
||||
@ -631,35 +634,7 @@ and if it is bound to `off` disable them. The default for YAP is
|
||||
YAP_FLAG(VARIABLE_NAMES_MAY_END_WITH_QUOTES_FLAG,
|
||||
"variable_names_may_end_with_quotes", true, booleanFlag, "false",
|
||||
NULL),
|
||||
/**<
|
||||
|
||||
If `normal` allow printing of informational and banner messages,
|
||||
such as the ones that are printed when consulting. If `silent`
|
||||
disable printing these messages. It is `normal` by default except if
|
||||
YAP is booted with the `-q` or `-L` flag.
|
||||
|
||||
*/
|
||||
YAP_FLAG(VERBOSE_FLAG, "verbose", true, isatom, "normal", NULL),
|
||||
|
||||
/**<
|
||||
|
||||
If `true` allow printing of informational messages when
|
||||
searching for file names. If `false` disable printing these messages. It
|
||||
is `false` by default except if YAP is booted with the `-L`
|
||||
flag.
|
||||
*/
|
||||
YAP_FLAG(VERBOSE_FILE_SEARCH_FLAG, "verbose_file_search", true, booleanFlag,
|
||||
"false", NULL),
|
||||
|
||||
/**<
|
||||
|
||||
If `true` allow printing of informational messages when
|
||||
consulting files. If `false` disable printing these messages. It
|
||||
is `true` by default except if YAP is booted with the `-L`
|
||||
flag.
|
||||
*/
|
||||
YAP_FLAG(VERBOSE_LOAD_FLAG, "verbose_load", true, booleanFlag, "true", NULL),
|
||||
|
||||
/**<
|
||||
Read-only flag that returns a compound term with the
|
||||
current version of YAP. The term will have the name `yap` and arity 4, the
|
||||
|
@ -101,37 +101,68 @@ Just fail
|
||||
*/
|
||||
YAP_FLAG(TYPEIN_MODULE_FLAG, "typein_module", true, isatom, "user",
|
||||
typein),
|
||||
/**<
|
||||
|
||||
If the second argument is bound to a stream, set user_error to
|
||||
this stream. If the second argument is unbound, unify the argument with
|
||||
the current user_error stream.
|
||||
By default, the user_error stream is set to a stream
|
||||
corresponding to the Unix `stderr` stream.
|
||||
The next example shows how to use this flag:
|
||||
|
||||
~~~{.prolog}
|
||||
?- open( '/dev/null', append, Error,
|
||||
[alias(mauri_tripa)] ).
|
||||
|
||||
Error = '$stream'(3) ? ;
|
||||
/**<
|
||||
|
||||
no
|
||||
?- set_prolog_flag(user_error, mauri_tripa).
|
||||
If `normal` allow printing of informational and banner messages,
|
||||
such as the ones that are printed when consulting. If `silent`
|
||||
disable printing these messages. It is `normal` by default except if
|
||||
YAP is booted with the `-q` or `-L` flag.
|
||||
|
||||
close(mauri_tripa).
|
||||
*/
|
||||
YAP_FLAG(VERBOSE_FLAG, "verbose", true, isatom, "normal", NULL),
|
||||
|
||||
yes
|
||||
?-
|
||||
~~~
|
||||
We execute three commands. First, we open a stream in write mode and
|
||||
give it an alias, in this case `mauri_tripa`. Next, we set
|
||||
user_error to the stream via the alias. Note that after we did so
|
||||
prompts from the system were redirected to the stream
|
||||
`mauri_tripa`. Last, we close the stream. At this point, YAP
|
||||
automatically redirects the user_error alias to the original
|
||||
`stderr`.
|
||||
*/
|
||||
/**<
|
||||
|
||||
If `true` allow printing of informational messages when
|
||||
searching for file names. If `false` disable printing these messages. It
|
||||
is `false` by default except if YAP is booted with the `-L`
|
||||
flag.
|
||||
*/
|
||||
YAP_FLAG(VERBOSE_FILE_SEARCH_FLAG, "verbose_file_search", true, booleanFlag,
|
||||
"false", NULL),
|
||||
|
||||
/**<
|
||||
|
||||
If `true` allow printing of informational messages when
|
||||
consulting files. If `false` disable printing these messages. It
|
||||
is `true` by default except if YAP is booted with the `-L`
|
||||
flag.
|
||||
*/
|
||||
YAP_FLAG(VERBOSE_LOAD_FLAG, "verbose_load", true, booleanFlag, "true", NULL),
|
||||
/**<
|
||||
|
||||
If the second argument is bound to a stream, set user_error to
|
||||
this stream. If the second argument is unbound, unify the argument with
|
||||
the current user_error stream.
|
||||
By default, the user_error stream is set to a stream
|
||||
corresponding to the Unix `stderr` stream.
|
||||
The next example shows how to use this flag:
|
||||
|
||||
~~~{.prolog}
|
||||
?- open( '/dev/null', append, Error,
|
||||
[alias(mauri_tripa)] ).
|
||||
|
||||
Error = '$stream'(3) ? ;
|
||||
|
||||
no
|
||||
?- set_prolog_flag(user_error, mauri_tripa).
|
||||
|
||||
close(mauri_tripa).
|
||||
|
||||
yes
|
||||
?-
|
||||
~~~
|
||||
We execute three commands. First, we open a stream in write mode and
|
||||
give it an alias, in this case `mauri_tripa`. Next, we set
|
||||
user_error to the stream via the alias. Note that after we did so
|
||||
prompts from the system were redirected to the stream
|
||||
`mauri_tripa`. Last, we close the stream. At this point, YAP
|
||||
automatically redirects the user_error alias to the original
|
||||
`stderr`.
|
||||
*/
|
||||
YAP_FLAG(USER_ERROR_FLAG, "user_error", true, stream, "user_error",
|
||||
set_error_stream),
|
||||
YAP_FLAG(USER_INPUT_FLAG, "user_input", true, stream, "user_input",
|
||||
|
14
H/Yapproto.h
14
H/Yapproto.h
@ -75,12 +75,12 @@ extern void Yap_FreeCodeSpace(void *);
|
||||
extern void *Yap_AllocAtomSpace(size_t);
|
||||
extern void *Yap_AllocCodeSpace(size_t);
|
||||
extern void *Yap_ReallocCodeSpace(void *, size_t);
|
||||
extern ADDR Yap_AllocFromForeignArea(Int);
|
||||
extern ADDR Yap_AllocFromForeignArea(size_t);
|
||||
extern int Yap_ExtendWorkSpace(Int);
|
||||
extern void Yap_FreeAtomSpace(void *);
|
||||
extern int Yap_FreeWorkSpace(void);
|
||||
extern void Yap_InitMemory(UInt, UInt, UInt);
|
||||
extern void Yap_InitExStacks(int, int, int);
|
||||
extern void Yap_InitMemory(size_t, size_t, size_t);
|
||||
extern void Yap_InitExStacks(int, size_t, size_t);
|
||||
|
||||
/* amasm.c */
|
||||
extern OPCODE Yap_opcode(op_numbers);
|
||||
@ -239,20 +239,20 @@ extern void Yap_inform_profiler_of_clause__(void *, void *, struct pred_entry *,
|
||||
extern void Yap_tell_gprof(yamop *);
|
||||
|
||||
/* globals.c */
|
||||
extern Term Yap_NewArena(UInt, CELL *);
|
||||
extern CELL *Yap_GetFromArena(Term *, UInt, UInt);
|
||||
extern Term Yap_NewArena(size_t, CELL *);
|
||||
extern CELL *Yap_GetFromArena(Term *, size_t, UInt);
|
||||
extern void Yap_InitGlobals(void);
|
||||
extern Term Yap_SaveTerm(Term);
|
||||
extern Term Yap_SetGlobalVal(Atom, Term);
|
||||
extern Term Yap_GetGlobal(Atom);
|
||||
extern Int Yap_DeleteGlobal(Atom);
|
||||
extern void Yap_AllocateDefaultArena(Int, Int, int);
|
||||
extern void Yap_AllocateDefaultArena(size_t gsize, int wid);
|
||||
extern CELL *Yap_ArenaLimit(Term arena);
|
||||
|
||||
/* grow.c */
|
||||
extern Int Yap_total_stack_shift_time(void);
|
||||
extern void Yap_InitGrowPreds(void);
|
||||
extern UInt Yap_InsertInGlobal(CELL *, UInt);
|
||||
extern size_t Yap_InsertInGlobal(CELL *, size_t);
|
||||
extern int Yap_growheap(bool, size_t, void *);
|
||||
extern int Yap_growstack(size_t);
|
||||
extern int Yap_growtrail(size_t, bool);
|
||||
|
@ -17,7 +17,16 @@ if (ANDROID)
|
||||
set(GMP_INCLUDE_DIRS ${GMP_ROOT} CACHE PATH "include search path")
|
||||
set(GMP_LIBRARIES ${GMP_ROOT}/libgmp.so CACHE FILEPATH "include search path")
|
||||
set(GMP_LIBRARIES_DIR ${GMP_ROOT} CACHE PATH "include search path")
|
||||
else()
|
||||
else()
|
||||
message("Bad call: ${GMP_ROOT} does not exist")
|
||||
endif()
|
||||
set( GMP_ROOT ${CMAKE_SOURCE_DIR}/../../gmp/${ANDROID_ABI} )
|
||||
if (EXISTS ${GMP_ROOT} )
|
||||
message("Looking good for ${GMP_ROOT}")
|
||||
set(GMP_INCLUDE_DIRS ${GMP_ROOT} CACHE PATH "include search path")
|
||||
set(GMP_LIBRARIES ${GMP_ROOT}/libgmp.so CACHE FILEPATH "include search path")
|
||||
set(GMP_LIBRARIES_DIR ${GMP_ROOT} CACHE PATH "include search path")
|
||||
else()
|
||||
message("Bad call: ${GMP_ROOT} does not exist")
|
||||
endif()
|
||||
find_path(GMP_INCLUDE_DIRS
|
||||
|
@ -5,17 +5,6 @@
|
||||
|
||||
set (ABSMI_SOURCES
|
||||
C/absmi.c
|
||||
C/absmi_insts.h
|
||||
C/fli_absmi_insts.h
|
||||
C/or_absmi_insts.h
|
||||
C/control_absmi_insts.h
|
||||
C/index_absmi_insts.h
|
||||
C/prim_absmi_insts.h
|
||||
C/cp_absmi_insts.h
|
||||
C/lu_absmi_insts.h
|
||||
C/unify_absmi_insts.h
|
||||
C/fail_absmi_insts.h
|
||||
C/meta_absmi_insts.h
|
||||
)
|
||||
|
||||
set (ENGINE_SOURCES
|
||||
|
@ -2035,13 +2035,13 @@ significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
|
||||
|
||||
/* run-time boot */
|
||||
#ifndef YAP_BOOTFILE
|
||||
#define YAP_BOOTFILE "${YAP_PLDIR}/pl/boot.yap"
|
||||
#ifndef YAP_SOURCEBOOT
|
||||
#define YAP_SOURCEBOOT "${CMAKE_SOURCE_DIR}/pl/boot.yap"
|
||||
#endif
|
||||
|
||||
/* init-time boot */
|
||||
#ifndef YAP_BOOTSTRAP
|
||||
#define YAP_BOOTSTRAP "${CMAKE_SOURCE_DIR}/pl/boot.yap"
|
||||
#define YAP_BOOTSTRAP "${YAP_PLDIR}/pl/boot.yap"
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -96,7 +96,7 @@ typedef enum {
|
||||
YAP_SAVED_STATE = 0x0004,
|
||||
YAP_OBJ = 0x0008,
|
||||
YAP_PL = 0x0010,
|
||||
YAP_BOOT_PL = 0x0030,
|
||||
YAP_SOURCE_PL = 0x0030,
|
||||
YAP_QLY = 0x0040,
|
||||
YAP_EXE = 0x0080,
|
||||
YAP_FOUND_BOOT_ERROR = 0x0100,
|
||||
|
@ -53,7 +53,7 @@ extern void Yap_ThrowError__(const char *file, const char *function, int lineno,
|
||||
;
|
||||
|
||||
#define Yap_NilError(id, ...) \
|
||||
Yap_Error__(false, __FILE__, __FUNCTION__, __LINE__, id, TermNil, __VA_ARGS__)
|
||||
Yap_Error__(false, __FILE__, __FUNCTION__, __LINE__, id, TermNil, __VA_ARGS__)
|
||||
|
||||
#define Yap_InitError(id, ...) \
|
||||
Yap_InitError__(__FILE__, __FUNCTION__, __LINE__, id, TermNil, __VA_ARGS__)
|
||||
|
@ -20,6 +20,8 @@ X_API YAP_file_type_t Yap_InitDefaults(void *init_args, char saved_state[],
|
||||
int Argc, char *Argv[]);
|
||||
|
||||
typedef struct yap_boot_params {
|
||||
//> struct marker
|
||||
void *start;
|
||||
//> boot type as suggested by the user
|
||||
YAP_file_type_t boot_file_type;
|
||||
//> how files are organised: NULL is GNU/Linux way
|
||||
@ -40,9 +42,11 @@ typedef struct yap_boot_params {
|
||||
const char *PLDIR;
|
||||
//> if NON-NULL, Prolog library, sets Yap_COMMONSDIR
|
||||
const char *COMMONSDIR;
|
||||
//> if NON-NULL, name for a Prolog file to use when booting at run-time
|
||||
const char *BOOTFILE;
|
||||
//> if NON-NULL, name for a Prolog file to use when booting at compile-time
|
||||
//> if NON-NULL, name for a Prolog file to use when booting at run-time
|
||||
const char *BOOTDIR;
|
||||
//> if NON-NULL, name for a Prolog directory that we shall use to start booting
|
||||
const char *SOURCEBOOT;
|
||||
//> if NON-NULL, name for a Prolog file to use when booting at compile-time
|
||||
const char *BOOTSTRAP;
|
||||
//> if NON-NULL, path where we can find the saved state
|
||||
const char *INPUT_STARTUP;
|
||||
|
@ -1,11 +1,9 @@
|
||||
set (LIBRARY_PL
|
||||
INDEX.pl
|
||||
apply.yap
|
||||
apply_macros.yap
|
||||
arg.yap
|
||||
assoc.yap
|
||||
atts.yap
|
||||
autoloader.yap
|
||||
avl.yap
|
||||
bhash.yap
|
||||
charsio.yap
|
||||
@ -63,23 +61,19 @@ set (LIBRARY_PL
|
||||
)
|
||||
|
||||
|
||||
MY_add_subdirectory(dialect)
|
||||
MY_add_subdirectory(clp)
|
||||
add_subdirectory(dialect)
|
||||
# add_subdirectory(clp)
|
||||
MY_add_subdirectory(matlab)
|
||||
MY_add_subdirectory(matrix)
|
||||
MY_add_subdirectory(random)
|
||||
MY_add_subdirectory(regex)
|
||||
MY_add_subdirectory(rltree)
|
||||
MY_add_subdirectory(system)
|
||||
MY_add_subdirectory(tries)
|
||||
add_subdirectory(matrix)
|
||||
add_subdirectory(random)
|
||||
add_subdirectory(regex)
|
||||
add_subdirectory(rltree)
|
||||
add_subdirectory(system)
|
||||
add_subdirectory(tries)
|
||||
MY_add_subdirectory(ytest)
|
||||
|
||||
add_to_group( LIBRARY_PL pl_library)
|
||||
add_to_dir(LIBRARY_PL ${YAP_INSTALL_DATADIR})
|
||||
|
||||
install(FILES ${LIBRARY_PL} DESTINATION ${YAP_INSTALL_DATADIR})
|
||||
|
||||
if (ANDROID)
|
||||
file( INSTALL ${LIBRARY_PL} DESTINATION ${YAP_INSTALL_DATADIR} )
|
||||
endif()
|
||||
|
||||
include_directories("dialect/swi")
|
||||
|
@ -1,19 +0,0 @@
|
||||
%:- start_low_level_trace.
|
||||
|
||||
:- module(user).
|
||||
:- yap_flag(verbose,normal).
|
||||
|
||||
query( String ) :-
|
||||
yap_flag(typein_module, Mod),
|
||||
atomic_to_term( String, Goal, VarNames ),
|
||||
query_to_answer( Mod:Goal, VarNames, Status, Bindings),
|
||||
output( Bindings, Status) .
|
||||
|
||||
output( Bindings, Status) :-
|
||||
(Status == answer -> true ;
|
||||
Status == exit ->true
|
||||
),
|
||||
write_query_answer( Bindings ),
|
||||
nl(user_error).
|
||||
|
||||
%:- [sqlitest].
|
@ -7,7 +7,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
:- module(apply_stub,[]).
|
||||
|
||||
|
||||
|
@ -120,10 +120,7 @@ find_predicate(G,ExportingModI) :-
|
||||
var(G),
|
||||
index(Name,Arity,ExportingModI,File),
|
||||
functor(G, Name, Arity),
|
||||
ensure_file_loaded(File).
|
||||
ensure_loaded(File).
|
||||
|
||||
:- ensure_loaded('INDEX').
|
||||
|
||||
ensure_file_loaded(File) :-
|
||||
loaded(File), !.
|
||||
ensure_file_loaded(File) :-
|
||||
load_files(autoloader:File,[silent(true),if(not_loaded)]),
|
||||
assert(loaded(File)).
|
||||
|
@ -2216,7 +2216,7 @@ X_API int PL_initialise(int myargc, char **myargv) {
|
||||
init_args.INPUT_STARTUP = NULL;
|
||||
#endif
|
||||
init_args.LIBDIR = NULL;
|
||||
init_args.BOOTFILE = NULL;
|
||||
init_args.SOURCEBOOT = NULL;
|
||||
init_args.HaltAfterBoot = true;
|
||||
init_args.FastBoot = FALSE;
|
||||
init_args.MaxTableSpaceSize = 0;
|
||||
|
@ -67,7 +67,7 @@ set (MPI_YAP_SOURCES
|
||||
# program, EXECUTABLE is the MPI program, and ARGS are the arguments to
|
||||
# pass to the MPI program.
|
||||
#
|
||||
add_lib(yap_mpi ${MPI_YAP_SOURCES})
|
||||
add_library(yap_mpi ${MPI_YAP_SOURCES})
|
||||
|
||||
target_link_libraries(yap_mpi libYap ${MPI_C_LIBRARIES})
|
||||
|
||||
|
1454
library/maplist.yap
1454
library/maplist.yap
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,4 @@
|
||||
|
||||
/**
|
||||
* @file maputils.yap
|
||||
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
|
||||
@ -27,6 +28,14 @@
|
||||
*/
|
||||
:- use_module(library(lists), [append/3]).
|
||||
|
||||
%% goal_expansion_allowed is semidet.
|
||||
%
|
||||
% `True` if we can use
|
||||
% goal-expansion.
|
||||
goal_expansion_allowed :-
|
||||
once( prolog_load_context(_, _) ), % make sure we are compiling.
|
||||
\+ current_prolog_flag(xref, true).
|
||||
|
||||
:- dynamic number_of_expansions/1.
|
||||
|
||||
number_of_expansions(0).
|
||||
@ -95,14 +104,6 @@ transformation_id(Id) :-
|
||||
assert(number_of_expansions(Id1)).
|
||||
transformation_id(0).
|
||||
|
||||
%% goal_expansion_allowed is semidet.
|
||||
%
|
||||
% `True` if we can use
|
||||
% goal-expansion.
|
||||
goal_expansion_allowed :-
|
||||
once( prolog_load_context(_, _) ), % make sure we are compiling.
|
||||
\+ current_prolog_flag(xref, true).
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
add_lib(matrix matrix.c)
|
||||
add_library(matrix matrix.c)
|
||||
|
||||
target_link_libraries(matrix libYap)
|
||||
|
||||
|
@ -1,13 +1,10 @@
|
||||
|
||||
set( LIBRANDOM_SOURCES yap_random.c)
|
||||
add_lib(yap_random ${LIBRANDOM_SOURCES})
|
||||
if (ANDROID)
|
||||
else()
|
||||
add_library(yap_random ${LIBRANDOM_SOURCES})
|
||||
|
||||
target_link_libraries(yap_random libYap)
|
||||
|
||||
set_target_properties (yap_random PROPERTIES PREFIX "")
|
||||
endif()
|
||||
|
||||
MY_install(TARGETS yap_random
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
|
@ -17,13 +17,13 @@ set ( REGEX_SOURCES
|
||||
|
||||
|
||||
|
||||
add_lib(regexp regexp.c ${REGEX_SOURCES})
|
||||
add_library(regexp regexp.c ${REGEX_SOURCES})
|
||||
|
||||
target_link_libraries(regexp libYap)
|
||||
|
||||
set_target_properties (regexp PROPERTIES PREFIX "")
|
||||
TARGET_INCLUDE_DIRECTORIES (regexp PUBLIC BEFORE
|
||||
${CMAKE_TOP_SOURCE_DIR}/include;${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR} )
|
||||
${CMAKE_SOURCE_DIR}/include;${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR} )
|
||||
|
||||
install(TARGETS regexp
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
|
@ -4,7 +4,7 @@ set ( RLTREE_SOURCES
|
||||
range_list.h
|
||||
)
|
||||
|
||||
add_lib(yap_rl yap_rl.c ${RLTREE_SOURCES})
|
||||
add_library(yap_rl yap_rl.c ${RLTREE_SOURCES})
|
||||
|
||||
target_link_libraries(yap_rl libYap)
|
||||
|
||||
|
@ -2,7 +2,7 @@ set( LIBSYSTEM_SOURCES sys.c crypto/md5.c )
|
||||
set( LIBSYSTEM_HEADERS crypto/md5.h)
|
||||
|
||||
|
||||
add_lib(sys ${LIBSYSTEM_SOURCES})
|
||||
add_library(sys ${LIBSYSTEM_SOURCES})
|
||||
if (ANDROID)
|
||||
set (TARGET libYap)
|
||||
else()
|
||||
|
@ -237,8 +237,10 @@ static YAP_Bool list_directory(void) {
|
||||
#else
|
||||
#if __ANDROID__
|
||||
{
|
||||
extern AAssetManager *Yap_assetManager(void);
|
||||
|
||||
const char *dirName = buf + strlen("/assets/");
|
||||
AAssetManager *mgr = GLOBAL_VFS->priv[0].mgr;
|
||||
AAssetManager *mgr = Yap_assetManager();
|
||||
AAssetDir *de;
|
||||
const char *dp;
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
/* Define to 1 if you have the <openssl/ripemd.h> header file. */
|
||||
#ifndef HAVE_APR_1_APR_MD5_H
|
||||
#define HAVE_APR_1_APR_MD5_H 1
|
||||
/* #undef HAVE_APR_1_APR_MD5_H */
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@ set ( TRIES_SOURCES
|
||||
tries.c
|
||||
)
|
||||
|
||||
add_lib(tries ${TRIES_SOURCES})
|
||||
add_library(tries ${TRIES_SOURCES})
|
||||
|
||||
target_link_libraries(tries libYap)
|
||||
|
||||
@ -27,7 +27,7 @@ set ( ITRIES_SOURCES
|
||||
if (ANDROID OR WIN32)
|
||||
add_component ( otries ${TRIES_SOURCES} )
|
||||
endif()
|
||||
add_lib(itries ${ITRIES_SOURCES})
|
||||
add_library(itries ${ITRIES_SOURCES})
|
||||
|
||||
target_link_libraries(itries libYap)
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
set (YAPOS_HEADERS
|
||||
getw.h
|
||||
|
||||
iopreds.h
|
||||
yapio.h
|
||||
YapEncoding.h
|
||||
@ -62,12 +63,7 @@ set (POSITION_INDEPENDENT_CODE TRUE)
|
||||
yio.yap
|
||||
)
|
||||
|
||||
add_to_group( YAPOS_PL_SOURCES pl_os_library)
|
||||
add_to_dir(YAPOS PL_SOURCES ${YAP_INSTALL_DATADIR}/os)
|
||||
|
||||
|
||||
if (ANDROID)
|
||||
file(INSTALL ${YAPOS_PL_SOURCES} DESTINATION ${YAP_INSTALL_DATADIR}/os)
|
||||
else()
|
||||
install (FILES ${YAPOS_PL_SOURCES}
|
||||
install (FILES ${YAPOS_PL_SOURCES}
|
||||
DESTINATION ${YAP_INSTALL_DATADIR}/os )
|
||||
endif()
|
||||
|
@ -77,7 +77,7 @@ open_asset(VFS_t *me, const char *fname, const char *io_mode, int sno) {
|
||||
// AAssetDir *dp = AAssetManager_openDir( Yap_assetManager(), dirname(dir) );
|
||||
// strcpy(dir, fname);
|
||||
// char *d = basename(dir);
|
||||
am = AAssetManager_open(Yap_assetManager(), fname, io_mode);
|
||||
am = AAssetManager_open(Yap_assetManager(), fname, AASSET_MODE_UNKNOWN);
|
||||
//if (am==NULL)
|
||||
// __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "failed open %s <%s>", fname, strerror(errno) );
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "open %s <%s>", fname, io_mode);
|
||||
|
19
os/sysbits.c
19
os/sysbits.c
@ -799,6 +799,7 @@ static const param_t expand_filename_defs[] = {EXPAND_FILENAME_DEFS()};
|
||||
static Term do_expand_file_name(Term t1, Term opts USES_REGS) {
|
||||
xarg *args;
|
||||
expand_filename_enum_choices_t i;
|
||||
|
||||
bool use_system_expansion = true;
|
||||
const char *tmpe = NULL;
|
||||
const char *spec;
|
||||
@ -1046,10 +1047,10 @@ static bool initSysPath(Term tlib, Term tcommons, bool dir_done,
|
||||
bool commons_done) {
|
||||
CACHE_REGS
|
||||
|
||||
if (!Yap_unify(tlib, MkAtomTerm(Yap_LookupAtom(Yap_PLDIR))))
|
||||
if (!Yap_PLDIR || !Yap_unify(tlib, MkAtomTerm(Yap_LookupAtom(Yap_PLDIR))))
|
||||
return false;
|
||||
|
||||
return Yap_unify(tcommons, MkAtomTerm(Yap_LookupAtom(Yap_COMMONSDIR)));
|
||||
return Yap_COMMONSDIR && Yap_unify(tcommons, MkAtomTerm(Yap_LookupAtom(Yap_COMMONSDIR)));
|
||||
}
|
||||
|
||||
static Int libraries_directories(USES_REGS1) {
|
||||
@ -1057,21 +1058,7 @@ static Int libraries_directories(USES_REGS1) {
|
||||
}
|
||||
|
||||
static Int system_library(USES_REGS1) {
|
||||
#if __ANDROID__
|
||||
static Term dir = 0;
|
||||
Term t;
|
||||
if (IsVarTerm(t = Deref(ARG1))) {
|
||||
if (dir == 0)
|
||||
return false;
|
||||
return Yap_unify(dir, ARG1);
|
||||
}
|
||||
if (!IsAtomTerm(t))
|
||||
return false;
|
||||
dir = t;
|
||||
return true;
|
||||
#else
|
||||
return initSysPath(ARG1, MkVarTerm(), false, true);
|
||||
#endif
|
||||
}
|
||||
|
||||
static Int commons_library(USES_REGS1) {
|
||||
|
@ -45,14 +45,14 @@ if (CMAKE_MAJOR_VERSION GREATER 2)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
ADD_LIB(horus ${HORUS_SOURCES} HorusYap.cpp )
|
||||
add_library(horus ${HORUS_SOURCES} HorusYap.cpp )
|
||||
|
||||
if(DEFINED YAP_MAJOR_VERSION)
|
||||
TARGET_LINK_LIBRARIES(horus
|
||||
libYap
|
||||
)
|
||||
else()
|
||||
ADD_LIB(horus ${HORUS_SOURCES} )
|
||||
add_library(horus ${HORUS_SOURCES} )
|
||||
endif()
|
||||
|
||||
#set_property(TARGET horus PROPERTY CXX_STANDARD 11)
|
||||
|
@ -33,7 +33,7 @@ if (GECODE_FOUND)
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
add_lib(gecode_yap ${GECODE_SOURCES})
|
||||
add_library(gecode_yap ${GECODE_SOURCES})
|
||||
|
||||
target_link_libraries(gecode_yap libYap ${GECODE_LIBRARIES})
|
||||
|
||||
|
@ -19,7 +19,10 @@ set (CLPQRPRIV clpqr/class.pl clpqr/dump.pl
|
||||
clpqr/project.pl clpqr/redund.pl)
|
||||
set (LIBPL clpr.pl clpq.pl ${CLPRPRIV} ${CLPQPRIV} ${CLPQRPRIV} )
|
||||
|
||||
install ( FILES ${YAP_INSTALL_DATADIR} DESTINATION ${YAP_INSTALL_DATADIR} )
|
||||
install ( FILES ${CLPQPRIV} DESTINATION ${YAP_INSTALL_DATADIR}/clpq )
|
||||
install ( FILES ${CLPRPRIV} DESTINATION ${YAP_INSTALL_DATADIR}/clpr )
|
||||
install ( FILES ${CLPQRPRIV} DESTINATION ${YAP_INSTALL_DATADIR}/clpqr )
|
||||
install ( FILES clpr.pl clpq.pl DESTINATION ${YAP_INSTALL_DATADIR} )
|
||||
|
||||
# $(PL) -q -f $(srcdir)/clpr_test.pl -g test,halt -t 'halt(1)'
|
||||
|
||||
|
@ -128,7 +128,7 @@ minimise variable _V_
|
||||
dump/3%, projecting_assert/1
|
||||
]).
|
||||
|
||||
:- expects_dialect(swi).
|
||||
%:- expects_dialect(swi).
|
||||
|
||||
%
|
||||
% Don't report export of private predicates from clpr
|
||||
|
@ -132,7 +132,7 @@ IF (CUDD_FOUND)
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../bdd
|
||||
)
|
||||
|
||||
add_lib(bddem
|
||||
add_library(bddem
|
||||
${BDDEM_SOURCES}
|
||||
)
|
||||
|
||||
@ -154,7 +154,7 @@ IF (CUDD_FOUND)
|
||||
)
|
||||
|
||||
|
||||
add_lib(cplint
|
||||
add_library(cplint
|
||||
${CPLINT_SOURCES}
|
||||
)
|
||||
|
||||
|
@ -77,7 +77,7 @@ cuda.c
|
||||
cuda.yap
|
||||
)
|
||||
|
||||
cuda_add_lib(libcuda ${CUDA_SOURCES})
|
||||
cuda_add_library(libcuda ${CUDA_SOURCES})
|
||||
|
||||
target_link_libraries(libcuda libYap
|
||||
${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY} # ${CUDA_nppc_LIBRARY}
|
||||
|
@ -32,7 +32,7 @@ if (GECODE_FOUND)
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
add_lib(gecode_yap ${GECODE_SOURCES})
|
||||
add_library(gecode_yap ${GECODE_SOURCES})
|
||||
|
||||
target_link_libraries(gecode_yap libYap ${GECODE_LIBRARIES})
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# set(CMAKE_MACOSX_RPATH 1)
|
||||
|
||||
add_lib(jplYap jpl.h jpl.c hacks.h)
|
||||
add_library(jplYap jpl.c)
|
||||
|
||||
include_directories (${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2} ${JAVA_AWT_PATH} )
|
||||
|
||||
|
@ -13,7 +13,9 @@ set(MYDDAS_SOURCES
|
||||
myddas_top_level.c
|
||||
)
|
||||
|
||||
include_directories(. sqlite3)
|
||||
set_property(DIRECTORY
|
||||
APPEND PROPERTY
|
||||
INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/sqlite3)
|
||||
|
||||
|
||||
set(MYDDAS_HEADERS
|
||||
@ -21,27 +23,19 @@ set(MYDDAS_HEADERS
|
||||
myddas_statistics.h
|
||||
myddas_statistics_structs.h
|
||||
myddas_structs.h
|
||||
myddas_top_level.c
|
||||
myddas_types.h)
|
||||
|
||||
set(MYDDAS_UTIL_SOURCES
|
||||
myddas_util.c
|
||||
myddas_initialization.c)
|
||||
|
||||
set (MYDDAS_FLAGS -DUSE_MYDDAS=1)
|
||||
set_property(GLOBAL
|
||||
APPEND PROPERTY
|
||||
COMPILE_DEFINITIONS
|
||||
-DUSE_MYDDAS=1)
|
||||
|
||||
include_directories(. sqlite3)
|
||||
add_subdirectory(sqlite3)
|
||||
|
||||
if (NOT ANDROID)
|
||||
add_subdirectory(mysql)
|
||||
add_subdirectory(odbc)
|
||||
add_subdirectory(postgres)
|
||||
endif()
|
||||
|
||||
set(CXX_SWIG_OUTDIR ${CMAKE_BINARY_DIR}/packages/swig/android)
|
||||
|
||||
add_component(myddas
|
||||
${MYDDAS_SOURCES}
|
||||
|
@ -1,3 +1,5 @@
|
||||
|
||||
|
||||
#ifndef __MYDDAS_H__
|
||||
#define __MYDDAS_H__
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sqlite3.h>
|
||||
#include "Yap.h"
|
||||
#include "myddas.h"
|
||||
#ifdef MYDDAS_STATS
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#ifdef USE_MYDDAS
|
||||
#ifdef MYDDAS
|
||||
|
||||
#include "myddas.h"
|
||||
|
||||
@ -689,9 +689,9 @@ void init_myddas(void) {
|
||||
{
|
||||
return;
|
||||
}
|
||||
#if USE_MYDDAS
|
||||
Term cm=CurrentModule;
|
||||
CurrentModule = USER_MODULE;
|
||||
#if MYDDAS
|
||||
Yap_InitMYDDAS_SharedPreds();
|
||||
Yap_InitBackMYDDAS_SharedPreds();
|
||||
#define stringify(X) _stringify(X)
|
||||
#define _stringify(X) #X
|
||||
Yap_REGS.MYDDAS_GLOBAL_POINTER = NULL;
|
||||
@ -699,26 +699,15 @@ void init_myddas(void) {
|
||||
MkAtomTerm(Yap_LookupAtom(stringify(MYDDAS_VERSION))));
|
||||
Yap_HaltRegisterHook((HaltHookFunc)Yap_MYDDAS_delete_all_myddas_structs,
|
||||
NULL);
|
||||
Yap_InitMYDDAS_SharedPreds();
|
||||
Yap_InitBackMYDDAS_SharedPreds();
|
||||
#undef stringify
|
||||
#undef _stringify
|
||||
Yap_MYDDAS_delete_all_myddas_structs();
|
||||
#if defined MYDDAS_ODBC
|
||||
Yap_InitBackMYDDAS_ODBCPreds();
|
||||
Yap_InitMYDDAS_ODBCPreds();
|
||||
#endif
|
||||
#if defined MYDDAS_TOP_LEVEL && \
|
||||
defined MYDDAS_MYSQL // && defined HAVE_LIBREADLINE
|
||||
Yap_InitMYDDAS_TopLevelPreds();
|
||||
#endif
|
||||
c_db_initialize_myddas(PASS_REGS1);
|
||||
#ifdef __ANDROID__
|
||||
init_sqlite3();
|
||||
#endif
|
||||
#endif
|
||||
myddas_initialised = true;
|
||||
CurrentModule = cm;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -24,7 +24,7 @@ if (WITH_MYSQL)
|
||||
if (WIN32)
|
||||
add_library(YAPmysql OBJECT ${MYSQL_SOURCES})
|
||||
else()
|
||||
add_lib(YAPmysql ${MYSQL_SOURCES})
|
||||
add_library(YAPmysql ${MYSQL_SOURCES})
|
||||
target_link_libraries(YAPmysql ${MYSQL_LIBRARIES} libYap)
|
||||
install(TARGETS YAPmysql
|
||||
RUNTIME DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
@ -32,7 +32,7 @@ if (WITH_MYSQL)
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
)
|
||||
endif()
|
||||
include_directories(${MYSQL_INCLUDE_DIR} ..)
|
||||
include_directories(${MYSQL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
set_target_properties(YAPmysql PROPERTIES
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
PREFIX ""
|
||||
|
@ -14,21 +14,17 @@ if (WITH_ODBC)
|
||||
# ODBC_INCLUDE_DIRECTORIES, where to find sql.h
|
||||
# ODBC_LIBRARIES, the libraries to link against to use ODBC
|
||||
# ODBC_FOUND. If false, you cannot build anything that requires Odbc.
|
||||
add_lib(YAPodbc ${YAPODBC_SOURCES})
|
||||
add_library(YAPodbc ${YAPODBC_SOURCES})
|
||||
target_link_libraries(YAPodbc libYap ${ODBC_LIBRARIES})
|
||||
include_directories (${ODBC_INCLUDE_DIRECTORIES} ..)
|
||||
|
||||
set_property(DIRECTORY
|
||||
APPEND PROPERTY
|
||||
INCLUDE_DIRECTORIES ${ODBC_INCLUDE_DIRECTORIES} ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR} )
|
||||
|
||||
set_target_properties (YAPodbc PROPERTIES
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
PREFIX ""
|
||||
)
|
||||
|
||||
list (APPEND MYDDAS_FLAGS -DMYDDAS_ODBC=1)
|
||||
set (MYDDAS_FLAGS ${MYDDAS_FLAGS} ON PARENT_SCOPE)
|
||||
set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS
|
||||
-DMYDDAS_ODBC=1)
|
||||
|
||||
|
||||
install(TARGETS YAPodbc
|
||||
LIBRARY DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
#if defined MYDDAS_ODBC
|
||||
#if MYDDAS_ODBC
|
||||
|
||||
#if !defined(ODBCVER)
|
||||
typedef void *SQLHDBC;
|
||||
|
@ -23,6 +23,7 @@ foreach (filename ${MYDDAS_YPP})
|
||||
get_filename_component(base ${filename} NAME_WE)
|
||||
set(base_abs ${MYDDAS_PL_OUTDIR}/${base})
|
||||
set(outfile ${base_abs}.yap)
|
||||
list(APPEND MYDDAS_YAP_FILES ${outfile})
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} ${MYDDAS_FLAGS} -x c -E -P -w ${CMAKE_CURRENT_SOURCE_DIR}/${filename} -o ${outfile}
|
||||
)
|
||||
@ -30,6 +31,7 @@ foreach (filename ${MYDDAS_YPP})
|
||||
endforeach ()
|
||||
foreach (dbms ${MYDDAS_DBMS} )
|
||||
set(outfile ${MYDDAS_PL_OUTDIR}/myddas_${dbms}.yap)
|
||||
list(APPEND MYDDAS_YAP_FILES ${outfile})
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} -D${dbms} -x c -E -P -w ${CMAKE_CURRENT_SOURCE_DIR}/myddas_driver.ypp -o ${outfile}
|
||||
)
|
||||
@ -37,8 +39,6 @@ foreach (dbms ${MYDDAS_DBMS} )
|
||||
set_source_files_properties(outfile PROPERTIES GENERATED TRUE)
|
||||
|
||||
endforeach()
|
||||
list(APPEND MYDDAS_YAP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/sqlitest.yap ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/chinook.db)
|
||||
|
||||
set( MYDDAS_YAP ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/sqlitest.yap ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/chinook.db)
|
||||
add_to_group(MYDDAS_YAP pl_library )
|
||||
file(INSTALL ${MYDDAS_YAP}
|
||||
DESTINATION ${MYDDAS_PL_OUTDIR} )
|
||||
install(FILES ${MYDDAS_YAP_FILES} DESTINATION ${YAP_INSTALL_DATADIR})
|
||||
|
@ -15,11 +15,6 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
%%:- load_foreign_files([myddas], [], init_myddas).
|
||||
|
||||
/* Initialize MYDDAS GLOBAL STRUCTURES */
|
||||
:- c_db_initialize_myddas.
|
||||
|
||||
#ifdef DEBUG
|
||||
:- yap_flag(single_var_warnings,on).
|
||||
:- yap_flag(write_strings,on).
|
||||
@ -114,6 +109,12 @@
|
||||
% myddas_mysql.ypp
|
||||
]).
|
||||
|
||||
|
||||
:- load_foreign_files([myddas], [], init_myddas).
|
||||
|
||||
/* Initialize MYDDAS GLOBAL STRUCTURES */
|
||||
:- c_db_initialize_myddas.
|
||||
|
||||
#ifdef MYDDAS_TOP_LEVEL
|
||||
:- use_module(myddas_top_level,[
|
||||
db_top_level/4,
|
||||
|
@ -76,9 +76,7 @@
|
||||
'$make_a_list'/2,
|
||||
'$write_or_not'/1
|
||||
]).
|
||||
#ifndef __ANDROID__
|
||||
:- load_foreign_files( [NAME()], [], INIT()).
|
||||
#endif
|
||||
|
||||
%--------------------------------------------------------
|
||||
% Public Predicates
|
||||
|
@ -16,9 +16,12 @@ if (WITH_POSTGRES)
|
||||
# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL
|
||||
# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries
|
||||
# PostgreSQL_LIBRARIES - The PostgreSQL libraries.
|
||||
add_lib(YAPpostgres ${YAPPOSTGRES_SOURCES})
|
||||
add_library(YAPpostgres ${YAPPOSTGRES_SOURCES})
|
||||
target_link_libraries(YAPpostgres libYap ${PostgreSQL_LIBRARIES})
|
||||
include_directories (${PostgreSQL_INCLUDE_DIRS} ..)
|
||||
set_property(DIRECTORY
|
||||
APPEND PROPERTY
|
||||
INCLUDE_DIRECTORIES ${PostgreSQL_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/.. )
|
||||
|
||||
set_target_properties (YAPpostgres PROPERTIES
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
PREFIX ""
|
||||
|
@ -1,7 +1,6 @@
|
||||
if (WITH_SQLITE3)
|
||||
|
||||
message( " * Sqlite3 Data-Base (http://www.sqlite3.org), distributed with MYDDAS" )
|
||||
|
||||
if (WITH_SQLITE3)
|
||||
set (SQLITE_TEST
|
||||
sqlitest.yap)
|
||||
|
||||
@ -9,21 +8,23 @@ if (WITH_SQLITE3)
|
||||
|
||||
set( YAPSQLITE3_SOURCES
|
||||
myddas_sqlite3.c
|
||||
src/sqlite3.h
|
||||
src/sqlite3ext.h
|
||||
)
|
||||
|
||||
message( " * Sqlite3 Data-Base (http://www.sqlite3.org), distributed with MYDDAS" )
|
||||
|
||||
add_to_dir(SQLITE_DB ${YAP_INSTALL_DATADIR})
|
||||
add_to_dir( SQLITE_TEST ${YAP_INSTALL_DATADIR})
|
||||
|
||||
|
||||
#sqlite3 is now in the system
|
||||
|
||||
set (SQLITE3_FOUND ON CACHE PRIVATE "")
|
||||
|
||||
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
set_property(DIRECTORY
|
||||
APPEND PROPERTY
|
||||
INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/src )
|
||||
|
||||
if (ANDROID)
|
||||
add_definitions(-DSQLITE_FCNTL_MMAP_SIZE=0 )
|
||||
|
||||
endif()
|
||||
|
||||
add_definitions(-DSQLITE_ENABLE_COLUMN_METADATA=1 )
|
||||
|
||||
@ -36,16 +37,18 @@ if (WITH_SQLITE3)
|
||||
|
||||
SET_PROPERTY(DIRECTORY PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 )
|
||||
|
||||
message("ql ${EMBEDDED_SQLITE3}")
|
||||
message( " * Sqlite3 Data-Base (http://www.sqlite3.org), distributed with MYDDAS" )
|
||||
if ( ANDROID )
|
||||
add_definitions(-DSQLITE_FCNTL_MMAP_SIZE=0 )
|
||||
|
||||
if (ANDROID )
|
||||
add_library( YAPsqlite3 OBJECT
|
||||
add_library( YAPsqlite3 OBJECT
|
||||
${YAPSQLITE3_SOURCES} )
|
||||
|
||||
else()
|
||||
|
||||
|
||||
list(APPEND YAPSQLITE3_SOURCES src/sqlite3.c)
|
||||
|
||||
|
||||
add_library( YAPsqlite3 SHARED
|
||||
${YAPSQLITE3_SOURCES})
|
||||
|
||||
@ -67,11 +70,11 @@ if (WITH_SQLITE3)
|
||||
endif()
|
||||
|
||||
install(FILES ${SQLITE_DB}
|
||||
DESTINATION ${YAP_PLDIR}/data
|
||||
DESTINATION ${YAP_INSTALL_DATADIR}/data
|
||||
)
|
||||
|
||||
install(FILES ${SQLITE_TEST}
|
||||
DESTINATION ${YAP_PLDIR}/test
|
||||
DESTINATION ${YAP_INSTALL_DATADIR}/test
|
||||
)
|
||||
|
||||
endif()
|
||||
|
@ -673,7 +673,6 @@ static void Yap_InitBackMYDDAS_SQLITE3Preds(void) {
|
||||
|
||||
X_API void init_sqlite3(void) {
|
||||
Term cm = CurrentModule;
|
||||
CurrentModule = MkAtomTerm(Yap_LookupAtom("user"));
|
||||
|
||||
Yap_InitMYDDAS_SQLITE3Preds();
|
||||
|
||||
|
@ -9,7 +9,7 @@ include_directories( BEFORE ${PYTHON_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/os ${CMAKE_SOURCE_DIR}/H ${CMAKE_SOURCE_DIR}/OPTYap )
|
||||
|
||||
#talk to python.pl
|
||||
add_lib(YAPPython pyload.c ${PYTHON_HEADERS} )
|
||||
add_library(YAPPython pyload.c ${PYTHON_HEADERS} )
|
||||
|
||||
|
||||
if (WIN32)
|
||||
@ -48,8 +48,6 @@ set (PYTHON_PL python.pl)
|
||||
|
||||
install(FILES python.pl DESTINATION ${YAP_INSTALL_DATADIR} )
|
||||
|
||||
add_to_group( PYTHON_PL pl_library )
|
||||
|
||||
set_target_properties (YAPPython PROPERTIES PREFIX "")
|
||||
|
||||
install(TARGETS YAPPython
|
||||
|
@ -79,9 +79,7 @@ endif()
|
||||
|
||||
|
||||
install(FILES ${YAP4PY_PL} DESTINATION ${YAP_INSTALL_DATADIR} )
|
||||
|
||||
add_to_group( YAP4PY_PL pl_library )
|
||||
|
||||
|
||||
if (WITH_DOCS AND DOXYGEN_FOUND)
|
||||
|
||||
set(CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
|
||||
|
@ -1,16 +1,14 @@
|
||||
The YAP Prolog System {#main}
|
||||
===========
|
||||
|
||||
<center>
|
||||

|
||||
</center>
|
||||
|
||||
NOTE: this version of YAP is still experimental, documentation may be out of date.
|
||||
|
||||
Introduction
|
||||
++++++++++
|
||||
## Introduction
|
||||
|
||||
This document provides User information on version 6.3.4 of
|
||||
YAP (*Yet Another Prolog*). The YAP Prolog System is a
|
||||
YAP (<em>Yet Another Prolog</em>). The YAP Prolog System is a
|
||||
high-performance Prolog compiler developed at Universidade do
|
||||
Porto. YAP supports stream Input/Output, sockets, modules,
|
||||
exceptions, Prolog debugger, C-interface, dynamic code, internal
|
||||
@ -18,6 +16,7 @@ Porto. YAP supports stream Input/Output, sockets, modules,
|
||||
|
||||
We explicitly allow both commercial and non-commercial use of YAP.
|
||||
|
||||
|
||||
YAP is based on the David H. D. Warren's WAM (Warren Abstract Machine),
|
||||
with several optimizations for better performance. YAP follows the
|
||||
Edinburgh tradition, and was originally designed to be largely
|
||||
@ -48,33 +47,47 @@ different licenses.
|
||||
|
||||
If you have a question about this software, desire to add code, found a
|
||||
bug, want to request a feature, or wonder how to get further assistance,
|
||||
please send e-mail to `yap-users AT lists.sourceforge.net. To
|
||||
subscribe to the mailing list, visit the [YAP Mailing list page](https://lists.sourceforge.net/lists/listinfo/yap-users).
|
||||
please send e-mail to <yap-users AT lists.sourceforge.net>. To
|
||||
subscribe to the mailing list, visit the page
|
||||
<https://lists.sourceforge.net/lists/listinfo/yap-users>.
|
||||
|
||||
On-line documentation is available for [YAP](http://www.dcc.fp.pt/~vsc/yap/)
|
||||
|
||||
|
||||
|
||||
The packages are, in alphabetical order:
|
||||
|
||||
+ The CHR package developed by Tom Schrijvers, Christian Holzbaur, and Jan Wielemaker.
|
||||
+ The CHR package developed by Tom Schrijvers,
|
||||
Christian Holzbaur, and Jan Wielemaker.
|
||||
|
||||
+ The CLP(BN) package and Horus toolkit developed by Tiago Gomes, and Vítor Santos Costa.
|
||||
|
||||
+ The CLP(R) package developed by Leslie De Koninck, Bart Demoen, Tom Schrijvers, and Jan Wielemaker, based on the CLP(Q,R) implementation by Christian Holzbaur.
|
||||
+ The CLP(R) package developed by Leslie De Koninck, Bart Demoen, Tom
|
||||
Schrijvers, and Jan Wielemaker, based on the CLP(Q,R) implementation
|
||||
by Christian Holzbaur.
|
||||
|
||||
+ The CPLint package developed by Fabrizio Riguzzi's research laboratory at the [University of Ferrara](http://www.ing.unife.it/Docenti/FabrizioRiguzzi/).
|
||||
+ The CPLint package developed by Fabrizio Riguzzi's research
|
||||
laboratory at the [University of Ferrara](http://www.ing.unife.it/Docenti/FabrizioRiguzzi/)
|
||||
|
||||
+ The CUDA interface package developed by Carlos Martínez, Jorge Buenabad, Inês Dutra and Vítor Santos Costa.
|
||||
+ The CUDA interface package developed by Carlos Martínez, Jorge
|
||||
Buenabad, Inês Dutra and Vítor Santos Costa.
|
||||
|
||||
+ The [GECODE](http://www.gecode.org) interface package developed by Denys Duchier and Vítor Santos Costa.
|
||||
|
||||
+ The [JPL](http://www.swi-prolog.org/packages/jpl/) (Java-Prolog Library) package developed by .
|
||||
|
||||
+ The minisat SAT solver interface developed by Michael Codish, Vitaly Lagoon, and Peter J. Stuckey.
|
||||
The minisat SAT solver interface developed by Michael Codish,
|
||||
Vitaly Lagoon, and Peter J. Stuckey.
|
||||
|
||||
+ The MYDDAS relational data-base interface developed at the Universidade do Porto by Tiago Soares, Michel Ferreira, and Ricardo Rocha.
|
||||
+ The MYDDAS relational data-base interface developed at the
|
||||
Universidade do Porto by Tiago Soares, Michel Ferreira, and Ricardo Rocha.
|
||||
|
||||
+ The [PRISM](http://rjida.meijo-u.ac.jp/prism/) logic-based programming system for statistical modeling developed at the Sato Research Laboratory, TITECH, Japan.
|
||||
+ The [PRISM](http://rjida.meijo-u.ac.jp/prism/) logic-based
|
||||
programming system for statistical modeling developed at the Sato
|
||||
Research Laboratory, TITECH, Japan.
|
||||
|
||||
+ The ProbLog 1 system developed by the [ProbLog](https://dtai.cs.kuleuven.be/problog) team in the DTAI group of KULeuven.
|
||||
+ The ProbLog 1 system developed by the [ProbLog](https://dtai.cs.kuleuven.be/problog) team in the
|
||||
DTAI group of KULeuven.
|
||||
|
||||
+ The [R](http://stoics.org.uk/~nicos/sware/packs/real/) interface package developed by Nicos Angelopoulos, Vítor Santos Costa, João Azevedo, Jan Wielemaker, and Rui Camacho.
|
||||
+ The [R](http://stoics.org.uk/~nicos/sware/packs/real/) interface package developed by Nicos Angelopoulos,
|
||||
Vítor Santos Costa, João Azevedo, Jan Wielemaker, and Rui Camacho.
|
||||
|
@ -65,11 +65,11 @@ if platform.system() == 'Windows':
|
||||
win_libs = ['wsock32','ws2_32']
|
||||
my_extra_link_args = ['-Wl,-export-all-symbols']
|
||||
elif platform.system() == 'Darwin':
|
||||
my_extra_link_args = ['-L','..','-Wl,-rpath,'+abspath(join(sysconfig.get_path('platlib'),'yap4py')),'-Wl,-rpath,/usr/local/lib','-Wl,-rpath,../yap4py']
|
||||
my_extra_link_args = ['-L','..','-Wl,-rpath,'+abspath(join(sysconfig.get_path('platlib'),'yap4py')),'-Wl,-rpath,/lib','-Wl,-rpath,../yap4py']
|
||||
win_libs = []
|
||||
local_libs = ['Py4YAP']
|
||||
elif platform.system() == 'Linux':
|
||||
my_extra_link_args = ['-L','..','-Wl,-rpath,'+abspath(join(sysconfig.get_path('platlib'),'yap4py')),'-Wl,-rpath,/usr/local/lib','-Wl,-rpath,'+join('/usr/local/lib','..'),'-Wl,-rpath,../yap4py']
|
||||
my_extra_link_args = ['-L','..','-Wl,-rpath,'+abspath(join(sysconfig.get_path('platlib'),'yap4py')),'-Wl,-rpath,/lib','-Wl,-rpath,'+join('/lib','..'),'-Wl,-rpath,../yap4py']
|
||||
win_libs = []
|
||||
local_libs = ['Py4YAP']
|
||||
|
||||
@ -91,10 +91,10 @@ extensions = [Extension('_yap', native_sources,
|
||||
('PYTHONSWIG', '1'),
|
||||
('_GNU_SOURCE', '1')],
|
||||
runtime_library_dirs=[
|
||||
abspath(join(sysconfig.get_path('platlib'),'yap4py')), abspath(sysconfig.get_path('platlib')),'/usr/local/lib'],
|
||||
abspath(join(sysconfig.get_path('platlib'),'yap4py')), abspath(sysconfig.get_path('platlib')),'/lib'],
|
||||
swig_opts=['-modern', '-c++', '-py3',
|
||||
'-DX_API', '-Iyap4py/include' ],
|
||||
library_dirs=[".",'../../..','/usr/local/lib'],
|
||||
library_dirs=[".",'../../..','/lib'],
|
||||
extra_link_args=my_extra_link_args,
|
||||
libraries=['Yap','gmp']+win_libs+local_libs,
|
||||
include_dirs=['/home/vsc/github/yap-6.3/H',
|
||||
|
@ -98,7 +98,7 @@ def live():
|
||||
args = yap.YAPEngineArgs()
|
||||
args.setYapShareDir(os.path.join(yap_lib_path,"prolog"))
|
||||
args.setYapLibDir(yap_lib_path)
|
||||
#args.setYapPrologBootFile(os.path.join(yap_lib_path."startup.yss"))
|
||||
#args.setYapPrologSOURCEBOOT(os.path.join(yap_lib_path."startup.yss"))
|
||||
engine = yap.YAPEngine(args)
|
||||
engine.goal( use_module(library('yapi') ) )
|
||||
loop = True
|
||||
|
@ -39,7 +39,7 @@ if (WIN32)
|
||||
set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${LIBXML2_LIBRARIES} )
|
||||
|
||||
else (WIN32)
|
||||
ADD_LIB(libxml2 ${LIBXML2_SOURCES} )
|
||||
add_library(libxml2 ${LIBXML2_SOURCES} )
|
||||
|
||||
if(DEFINED YAP_MAJOR_VERSION)
|
||||
TARGET_LINK_LIBRARIES(libxml2
|
||||
@ -88,7 +88,7 @@ IF (RAPTOR_FOUND)
|
||||
raptor_yap.c
|
||||
)
|
||||
|
||||
ADD_LIB(raptor ${RAPTOR_SOURCES} )
|
||||
add_library(raptor ${RAPTOR_SOURCES} )
|
||||
|
||||
if(DEFINED YAP_MAJOR_VERSION)
|
||||
TARGET_LINK_LIBRARIES(raptor
|
||||
|
@ -16,7 +16,7 @@ set_package_properties(R PROPERTIES
|
||||
DESCRIPTION "The R Project for Statistical Computing."
|
||||
|
||||
URL "https://www.r-project.org/")
|
||||
add_lib(real ${REAL_SOURCES})
|
||||
add_library(real ${REAL_SOURCES})
|
||||
target_link_libraries (real ${LIBR_LIBRARIES} libYap)
|
||||
include_directories (
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
|
@ -24,7 +24,7 @@ pl-minisat.C
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
ADD_LIB(minisat2 ${MINISAT2_SOURCES} ${MINISAT2_HEADERS} )
|
||||
add_library(minisat2 ${MINISAT2_SOURCES} ${MINISAT2_HEADERS} )
|
||||
|
||||
set_target_properties (minisat2 PROPERTIES OUTPUT_NAME pl-minisat)
|
||||
set_target_properties (minisat2 PROPERTIES PREFIX "")
|
||||
|
@ -10,8 +10,6 @@
|
||||
|
||||
set (SOURCES yap.i)
|
||||
|
||||
INCLUDE(${SWIG_USE_FILE})
|
||||
|
||||
if (ANDROID)
|
||||
add_subdirectory(android)
|
||||
else(ANDROID)
|
||||
|
@ -1,68 +1,42 @@
|
||||
|
||||
# This is a CMake file for SWIG and Android
|
||||
|
||||
set(JAVA_SWIG_OUTDIR ${CMAKE_SOURCE_DIR}/../yaplib/src/generated/java/pt/up/yap/lib)
|
||||
set(SWIG_CXX_DIR ${CMAKE_BINARY_DIR}/src/generated/jni)
|
||||
FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/src/generated/java/pt/up/yap/lib)
|
||||
FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/src/generated/assets/Yap/pl)
|
||||
FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/src/generated/assets/so)
|
||||
FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/src/generated/jni)
|
||||
set(YAP_ASSETS ${CMAKE_SOURCE_DIR}/../yaplib/src/generated/assets/Yap)
|
||||
set(GENERATED_SOURCE_DIR ${CMAKE_SOURCE_DIR}/../yaplib/src/generated)
|
||||
|
||||
set(JAVA_SWIG_OUTDIR ${GENERATED_SOURCE_DIR}/java/pt/up/yap/lib)
|
||||
|
||||
set(SWIG_SOURCES ${CMAKE_SOURCE_DIR}/packages/swig/yap.i)
|
||||
SET_SOURCE_FILES_PROPERTIES(${SWIG_SOURCES} PROPERTIES CPLUSPLUS ON)
|
||||
|
||||
FILE( MAKE_DIRECTORY ${GENERATED_SOURCE_DIR}/assets/Yap/pl)
|
||||
FILE( MAKE_DIRECTORY ${GENERATED_SOURCE_DIR}/assets/os)
|
||||
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/CXX
|
||||
)
|
||||
set(GMP_ROOT ${CMAKE_SOURCE_DIR}/../gmp/${ANDROID_ABI})
|
||||
set(GMP_INCLUDE_DIRS ${GMP_ROOT})
|
||||
set(GMP_LIBRARIES ${GMP_ROOT}/libgmp.so)
|
||||
|
||||
|
||||
file(INSTALL ${pl_library} DESTINATION ${YAP_ASSETS})
|
||||
file(INSTALL ${CMAKE_CURRENT_SOURCE_DIR}/android.yap DESTINATION ${YAP_ASSETS})
|
||||
|
||||
file(INSTALL ${pl_boot_library} DESTINATION ${YAP_ASSETS}/pl)
|
||||
file(INSTALL ${pl_os_library} DESTINATION ${YAP_ASSETS}/os)
|
||||
|
||||
|
||||
execute_process(COMMAND swig -c++ -java -package pt.up.yap.lib -O -outdir ${JAVA_SWIG_OUTDIR} -addextern -I${CMAKE_SOURCE_DIR}/CXX -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/H -I${CMAKE_SOURCE_DIR}/os -I${CMAKE_SOURCE_DIR}/OPTYap -I${CMAKE_BINARY_DIR} -I${GMP_INCLUDE_DIRS} -DX_API -o ${SWIG_CXX_DIR}/yapi_swig.cxx ${SWIG_SOURCES}
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/H
|
||||
${CMAKE_SOURCE_DIR}/os
|
||||
${CMAKE_SOURCE_DIR}/OPTYap
|
||||
)
|
||||
|
||||
execute_process(COMMAND ${SWIG_EXECUTABLE} -c++ -java -package pt.up.yap.lib -O -outdir ${JAVA_SWIG_OUTDIR} -addextern -I${CMAKE_CURRENT_SOURCE_DIR} -o ${SWIG_CXX_DIR}/streamer_swig.cxx streamer.i
|
||||
)
|
||||
add_custom_command( OUTPUT yapi_swig.cxx yapi_swig.hh
|
||||
COMMAND swig -c++ -java -package pt.up.yap.lib -O -outdir ${JAVA_SWIG_OUTDIR}
|
||||
-addextern -I${CMAKE_SOURCE_DIR}/CXX -I${CMAKE_SOURCE_DIR}/include
|
||||
-I${CMAKE_SOURCE_DIR}/H -I${CMAKE_SOURCE_DIR}/os -I${CMAKE_SOURCE_DIR}/OPTYap
|
||||
-I${CMAKE_BINARY_DIR}
|
||||
-I${GMP_INCLUDE_DIRS} -DX_API -o yapi_swig.cxx ${SWIG_SOURCES}
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/CXX/yapi.hh ${SWIG_SOURCES}
|
||||
)
|
||||
|
||||
add_custom_command( OUTPUT streamer_swig.cxx streamer_swig.hh
|
||||
COMMAND swig -c++ -java -package pt.up.yap.lib -O -outdir ${JAVA_SWIG_OUTDIR} -addextern -I${CMAKE_CURRENT_SOURCE_DIR} -o streamer_swig.cxx streamer.i
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/CXX/yapi.hh ${CMAKE_CURRENT_SOURCE_DIR}/streamer.i
|
||||
)
|
||||
|
||||
add_library(YAPJava OBJECT
|
||||
${CMAKE_BINARY_DIR}/src/generated/jni/streamer_swig.cxx
|
||||
${CMAKE_BINARY_DIR}/src/generated/jni/yapi_swig.cxx
|
||||
streamer.cpp
|
||||
)
|
||||
|
||||
set_target_properties(YAPJava PROPERTIES LINKER_LANGUAGE CXX)
|
||||
|
||||
# GMP_FOUND - true if GMP/MPIR was found
|
||||
# GMP_INCLUDE_DIRS - include search path
|
||||
# GMP_LIBRARIES - libraries to link with
|
||||
#config.h needs this (TODO: change in code latter)
|
||||
include_directories(.;${GMP_INCLUDE_DIRS};${CMAKE_SOURCE_DIR}/include;${CMAKE_SOURCE_DIR}/H;${CMAKE_SOURCE_DIR}/H/generated;${CMAKE_SOURCE_DIR}/os;${CMAKE_SOURCE_DIR}/OPTYap;${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
|
||||
if (FALSE)
|
||||
|
||||
set(SWIG_ADD_MODULE YAPJava SHARED CPLUSPLUS ${SWIG_SOURCES})
|
||||
# Define swig module with given name and specified language
|
||||
|
||||
|
||||
set(SWIG_LINK_LIBRARIES YAPJava YAP++ libYAP)
|
||||
#- Link libraries to swig module
|
||||
|
||||
|
||||
add_library(YAPJavaTop SHARED
|
||||
main.cpp main.h
|
||||
)
|
||||
|
||||
target_link_libraries(YAPJavaTop ${SWIG_MODULE_${YAPJava}_REAL_NAME} YAP++ libYap android)
|
||||
|
||||
endif ()
|
||||
add_library(DROID OBJECT
|
||||
yapi_swig.cxx streamer_swig.cxx streamer.cpp
|
||||
)
|
||||
|
@ -58,15 +58,39 @@ and_close(int sno) {
|
||||
|
||||
static int
|
||||
and_put(int sno, int ch) {
|
||||
buff0 += ch;
|
||||
streamerInstance->display(buff0);
|
||||
buff0.clear();
|
||||
buff0 += ch;
|
||||
if (ch == '\n') {
|
||||
streamerInstance->display(buff0);
|
||||
buff0.clear();
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
and_wput(int sno, int ch) {
|
||||
unsigned char b0[8];
|
||||
|
||||
size_t extra = put_utf8(b0, ch);
|
||||
if (extra < 0)
|
||||
PlIOError(DOMAIN_ERROR_ENCODING, MkIntegerTerm(ch), "ch %C found at putw", ch);
|
||||
else if(extra==0)
|
||||
return false;
|
||||
for (int i=0; i < extra; i++) {
|
||||
buff0 += b0[i];
|
||||
}
|
||||
if (ch == '\n') {
|
||||
streamerInstance->display(buff0);
|
||||
buff0.clear();
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
static int
|
||||
and_get(int sno) {
|
||||
PlIOError(PERMISSION_ERROR_OUTPUT_STREAM, MkIntTerm(sno), "streamer is just for writing");
|
||||
return EOF;
|
||||
}
|
||||
|
||||
@ -86,14 +110,16 @@ extern "C" {
|
||||
void Java_pt_up_yap_streamerJNI_swig_1module_1init(void) {
|
||||
andstream = new VFS_t();
|
||||
|
||||
andstream->name = "/android/user_error";
|
||||
andstream->name = "/android/user";
|
||||
andstream->vflags = VFS_CAN_WRITE | VFS_HAS_PREFIX;
|
||||
andstream->prefix = "/android";
|
||||
andstream->suffix = NULL;
|
||||
andstream->open = and_open;
|
||||
andstream->close = and_close;
|
||||
andstream->get_char = and_get;
|
||||
andstream->get_wchar = and_get;
|
||||
andstream->put_char = and_put;
|
||||
andstream->put_wchar = and_wput;
|
||||
andstream->flush = and_flush;
|
||||
andstream->seek = and_seek;
|
||||
andstream->next = GLOBAL_VFS;
|
||||
|
@ -139,17 +139,8 @@ class YAPEngine;
|
||||
|
||||
#else
|
||||
|
||||
%typemap(in) arity_t { (jlong)($input); }
|
||||
|
||||
|
||||
|
||||
%typemap(in) jlong %{
|
||||
$1 = (jlong)$input;
|
||||
%}
|
||||
|
||||
%typemap(out) arity_t { *(jlong *)&$result = $1; }
|
||||
|
||||
// Language independent exception handler
|
||||
// Language independent exception handler
|
||||
// simplified version
|
||||
%include <exception.i>
|
||||
#endif
|
||||
|
@ -11,7 +11,7 @@ SET ( SOURCES
|
||||
b+tree_udi.c
|
||||
)
|
||||
|
||||
ADD_LIB(udi_b+tree ${SOURCES})
|
||||
add_library(udi_b+tree ${SOURCES})
|
||||
|
||||
INSTALL(TARGETS udi_b+tree DESTINATION ${YAP_PL_LIBRARY_DIR})
|
||||
INSTALL(FILES b+tree.yap DESTINATION ${YAP_PL_LIBRARY_DIR})
|
||||
|
@ -11,7 +11,7 @@ SET ( SOURCES
|
||||
rtree_udi.c
|
||||
)
|
||||
|
||||
ADD_LIB(udi_rtree ${SOURCES})
|
||||
add_library(udi_rtree ${SOURCES})
|
||||
|
||||
INSTALL(TARGETS udi_rtree DESTINATION ${YAP_PL_LIBRARY_DIR})
|
||||
INSTALL(FILES rtree.yap DESTINATION ${YAP_PL_LIBRARY_DIR})
|
||||
|
@ -10,7 +10,7 @@ SET ( SOURCES
|
||||
uthash_udi.c
|
||||
)
|
||||
|
||||
ADD_LIB(udi_uthash ${SOURCES})
|
||||
add_library(udi_uthash ${SOURCES})
|
||||
|
||||
INSTALL(TARGETS udi_uthash DESTINATION ${YAP_PL_LIBRARY_DIR})
|
||||
INSTALL(FILES uthash.yap DESTINATION ${YAP_PL_LIBRARY_DIR})
|
||||
|
@ -1,12 +1,14 @@
|
||||
set(PL_BOOT_SOURCES
|
||||
absf.yap
|
||||
absf.yap
|
||||
android.yap
|
||||
arith.yap
|
||||
arithpreds.yap
|
||||
arrays.yap
|
||||
atoms.yap
|
||||
attributes.yap
|
||||
boot.yap
|
||||
bootlists.yap
|
||||
boot2.yap
|
||||
bootlists.yap
|
||||
bootutils.yap
|
||||
builtins.yap
|
||||
callcount.yap
|
||||
@ -62,35 +64,34 @@ set(PL_BOOT_SOURCES
|
||||
ypp.yap
|
||||
)
|
||||
|
||||
add_to_group(PL_BOOT_SOURCES pl_boot_library)
|
||||
add_to_dir(PL_BOOT_SOURCES ${YAP_INSTALL_DATADIR}/pl)
|
||||
|
||||
if (ANDROID)
|
||||
add_custom_target(STARTUP
|
||||
DEPENDS ${PL_BOOT_SOURCES}
|
||||
)
|
||||
file (INSTALL ${PL_BOOT_SOURCES} DESTINATION ${YAP_INSTALL_DATADIR}/pl)
|
||||
elseif(CMAKE_CROSSCOMPILING)
|
||||
add_custom_target(STARTUP ALL SOURCES
|
||||
DEPENDS ${PL_BOOT_SOURCES}
|
||||
)
|
||||
else ()
|
||||
add_custom_target(STARTUP ALL
|
||||
DEPENDS ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
||||
DEPENDS ${CMAKE_BINARY_DIR}/${YAP_STARTUP}
|
||||
)
|
||||
add_custom_command(OUTPUT ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
||||
COMMAND yap-bin -B
|
||||
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${YAP_STARTUP}
|
||||
COMMAND yap-bin -B ${CMAKE_SOURCE_DIR}/pl/boot.yap
|
||||
VERBATIM
|
||||
DEPENDS ${PL_BOOT_SOURCES} yap-bin
|
||||
)
|
||||
|
||||
# install(CODE "execute_process(COMMAND ./yap -B
|
||||
# WORKING_DIRECTORY ${CMAKE_TOP_BINARY_DIR})"
|
||||
# WORKING_DIRECTORY ${CMAKE_BINARY_DIR})"
|
||||
# DEPENDS Py4YAP ${PL_BOOT_SOURCES} yap-bin )
|
||||
|
||||
|
||||
install(FILES ${CMAKE_TOP_BINARY_DIR}/${YAP_STARTUP}
|
||||
DESTINATION ${YAP_INSTALL_LIBDIR}
|
||||
)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/${YAP_STARTUP}
|
||||
DESTINATION ${YAP_INSTALL_LIBDIR})
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*************************************************************************
|
||||
qqqqq/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
|
22
pl/android.yap
Normal file
22
pl/android.yap
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
%:- start_low_level_trace.
|
||||
|
||||
%:- module(android,
|
||||
% [text_to_query/2]).
|
||||
|
||||
:- initialization(yap_flag(verbose,_,normal)).
|
||||
|
||||
:- meta_predicate( text_to_query( :, - ) ).
|
||||
|
||||
text_to_query( MString, Status ) :-
|
||||
strip_module( MString, Mod, String ),
|
||||
atomic_to_term( String, Goal, VarNames ),
|
||||
(
|
||||
is_list(Goal) -> G = ensure_loaded( Goal ) ; G = Goal ),
|
||||
catch(query_to_answer( Mod:G, VarNames, Status, Bindings),
|
||||
H,error_handler(H,error)
|
||||
),
|
||||
write_query_answer( Bindings ),
|
||||
nl(user_error).
|
||||
|
||||
%:- [sqlitest].
|
38
pl/arith.yap
38
pl/arith.yap
@ -1,3 +1,4 @@
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
@ -118,19 +119,21 @@ do_not_compile_expressions :- set_value('$c_arith',[]).
|
||||
|
||||
'$c_built_in'(IN, M, H, OUT) :-
|
||||
get_value('$c_arith',true), !,
|
||||
do_c_built_in(IN, M, H, OUT).
|
||||
'$yap_strip_module'(M:IN, M1, G1),
|
||||
do_c_built_in(G1, M1, H, OUT).
|
||||
'$c_built_in'(IN, _, _H, IN).
|
||||
|
||||
|
||||
do_c_built_in(G, M, H, OUT) :- var(G), !,
|
||||
do_c_built_metacall(G, M, H, OUT).
|
||||
do_c_built_in(Mod:G, _, H, OUT) :-
|
||||
'$yap_strip_module'(Mod:G, M1, G1),
|
||||
var(G1), !,
|
||||
do_c_built_metacall(G1, M1, H, OUT).
|
||||
do_c_built_in(G1, M1, H, OUT) :-
|
||||
var(G1), !,
|
||||
do_c_built_metacall(G1, M1, H, OUT).
|
||||
do_c_built_in(G1, M1, H, OUT) :-
|
||||
var(M1), !,
|
||||
do_c_built_metacall(G1, M1, H, OUT).
|
||||
do_c_built_in('$do_error'( Error, Goal), M, Head,
|
||||
throw(error(Error,M:(Head :- Goal)))
|
||||
) :- !.
|
||||
throw(error(Error,M:(Head :- Goal)))
|
||||
) :-
|
||||
!.
|
||||
do_c_built_in(system_error( Error, Goal), M, Head, ErrorG) :-
|
||||
!,
|
||||
do_c_built_in('$do_error'( Error, Goal), M, Head, ErrorG).
|
||||
@ -144,10 +147,10 @@ do_c_built_in(X is Y, _, _, P) :-
|
||||
nonvar(Y), % Don't rewrite variables
|
||||
!,
|
||||
(
|
||||
number(Y) ->
|
||||
P = ( X = Y); % This case reduces to an unification
|
||||
expand_expr(Y, P0, X0),
|
||||
'$drop_is'(X0, X, P0, P)
|
||||
number(Y) ->
|
||||
P = ( X = Y); % This case reduces to an unification
|
||||
expand_expr(Y, P0, X0),
|
||||
'$drop_is'(X0, X, P0, P)
|
||||
).
|
||||
do_c_built_in(phrase(NT,Xs), Mod, H, NTXsNil) :-
|
||||
!,
|
||||
@ -155,7 +158,6 @@ do_c_built_in(phrase(NT,Xs), Mod, H, NTXsNil) :-
|
||||
do_c_built_in(phrase(NT,Xs0,Xs), Mod, _, NewGoal) :-
|
||||
!,
|
||||
'$c_built_in_phrase'(NT, Xs0, Xs, Mod, NewGoal ).
|
||||
|
||||
do_c_built_in(Comp0, _, _, R) :- % now, do it for comparisons
|
||||
'$compop'(Comp0, Op, E, F),
|
||||
!,
|
||||
@ -239,8 +241,10 @@ expand_expr(T, E, V) :-
|
||||
% after having expanded into Q
|
||||
% and giving as result P (the last argument)
|
||||
expand_expr(Op, X, O, Q, Q) :-
|
||||
number(X),
|
||||
catch(is( O, Op, X),_,fail), !. % do not do error handling at compile time
|
||||
number(X),
|
||||
!,
|
||||
catch(is( O, Op, X),Error,bad_expr(Error,[Op, X])), !.
|
||||
% do not do error handling at compile time
|
||||
expand_expr(Op, X, O, Q, P) :-
|
||||
'$unary_op_as_integer'(Op,IOp),
|
||||
'$do_and'(Q, is( O, IOp, X), P).
|
||||
@ -254,7 +258,7 @@ expand_expr(Op, X, O, Q, P) :-
|
||||
% the elementar arithmetic operations [+,-,*,//]
|
||||
expand_expr(Op, X, Y, O, Q, Q) :-
|
||||
number(X), number(Y),
|
||||
catch(is( O, Op, X, Y),_,fail), !.
|
||||
catch(is( O, Op, X, Y),Error,bad_expr(Error,[Op, X, Y ])), !.
|
||||
expand_expr(+, X, Y, O, Q, P) :- !,
|
||||
'$preprocess_args_for_commutative'(X, Y, X1, Y1, E),
|
||||
'$do_and'(E, '$plus'(X1,Y1,O), F),
|
||||
|
195
pl/boot.yap
195
pl/boot.yap
@ -53,7 +53,6 @@ private(_).
|
||||
true/0], ['$$compile'/4,
|
||||
'$call'/4,
|
||||
'$catch'/3,
|
||||
'$check_callable'/2,
|
||||
'$check_head_and_body'/4,
|
||||
'$check_if_reconsulted'/2,
|
||||
'$clear_reconsulting'/0,
|
||||
@ -111,21 +110,28 @@ private(_).
|
||||
% be careful here not to generate an undefined exception..
|
||||
|
||||
print_message(L,E) :-
|
||||
%stop_low_level_trace,
|
||||
'$number_of_clauses'(print_message(L,E), prolog_complete, 1),
|
||||
!,
|
||||
(L = informational
|
||||
->
|
||||
true
|
||||
;
|
||||
format( user_error, '~w in bootstrap: got ~w~n',[L,E])
|
||||
system_error(_,Info),
|
||||
'$error_descriptor'(Info, Desc),
|
||||
query_exception(prologPredFile, Desc, File),
|
||||
query_exception(prologPredLine, Desc, FilePos),
|
||||
format(user_error,'~a:~d: error:', [File,FilePos]),
|
||||
'$print_exception'(Info),
|
||||
format( user_error, '~w from bootstrap: got ~w~n',[L,E])
|
||||
).
|
||||
|
||||
'$undefp0'([M|G], _Action) :-
|
||||
stream_property( loop_stream, [file_name(F), line_number(L)]),
|
||||
format(user_error,'~a:~d error undefined:',[F,L]),
|
||||
format(user_error,'~a:~d: error: undefined ~w~n:',[F,L,M:G]),
|
||||
fail
|
||||
;
|
||||
format(user_error,' call to ~w~n',[M:G]),
|
||||
format(user_error,' call to undefined procedure ~w~n',[M:G]),
|
||||
fail.
|
||||
|
||||
:- '$undefp_handler'('$undefp0'(_,_),prolog).
|
||||
@ -145,8 +151,12 @@ print_message(L,E) :-
|
||||
'$compile'(G, assertz, G, prolog, _R),
|
||||
'$system_meta_predicates'(L).
|
||||
|
||||
:- '$mk_dynamic'( prolog_file_type(_Ext, _NType), user).
|
||||
:- '$new_multifile'( prolog_file_type(_Ext, _NType), user).
|
||||
|
||||
:- '$mk_dynamic'( '$meta_predicate'(_N,_M,_A,_P), prolog).
|
||||
:- '$new_multifile'( '$meta_predicate'(_N,_M,_A,_P), prolog).
|
||||
|
||||
:- '$new_multifile'('$full_clause_optimisation'(_H, _M, _B0, _BF), prolog).
|
||||
:- '$new_multifile'('$exec_directive'(_,_,_,_,_), prolog).
|
||||
|
||||
@ -305,181 +315,8 @@ initialize_prolog :-
|
||||
'yapor.yap',
|
||||
'qly.yap',
|
||||
'spy.yap',
|
||||
'udi.yap'].
|
||||
|
||||
%:- start_low_level_trace.
|
||||
|
||||
:- meta_predicate(log_event(+,:)).
|
||||
|
||||
:- dynamic prolog:'$user_defined_flag'/4.
|
||||
|
||||
:- multifile prolog:debug_action_hook/1.
|
||||
|
||||
:- multifile prolog:'$system_predicate'/2.
|
||||
|
||||
:- '$opdec'(1150,fx,(mode),prolog).
|
||||
|
||||
:- dynamic 'extensions_to_present_answer'/1.
|
||||
|
||||
:- ['arrays.yap'].
|
||||
|
||||
:- multifile user:portray_message/2.
|
||||
|
||||
:- dynamic user:portray_message/2.
|
||||
|
||||
/** @pred prolog:goal_expansion( :G,+ M,- NG)
|
||||
@pred user:goalexpansion(+ G,+ M,- NG)
|
||||
|
||||
The goal_expansion/3 hook is an user-defined
|
||||
procedure that is called after term expansion when compiling or
|
||||
asserting goals for each sub-goal in a clause. The first argument is
|
||||
bound to the goal and the second to the module under which the goal
|
||||
_G_ will execute. If goal_expansion/3 succeeds the new
|
||||
sub-goal _NG_ will replace _G_ and will be processed in the same
|
||||
way. If goal_expansion/3 fails the system will use the default
|
||||
expandion mechanism.
|
||||
|
||||
This hook is called:
|
||||
- at compilation time;
|
||||
- when running a query in the top-level
|
||||
|
||||
Older versions of YAP would call this procedure at every meta-call.
|
||||
|
||||
|
||||
*/
|
||||
:- multifile user:goal_expansion/3.
|
||||
|
||||
:- dynamic user:goal_expansion/3.
|
||||
|
||||
:- multifile user:goal_expansion/2.
|
||||
|
||||
:- dynamic user:goal_expansion/2.
|
||||
|
||||
:- multifile system:goal_expansion/2.
|
||||
|
||||
:- dynamic system:goal_expansion/2.
|
||||
|
||||
:- multifile goal_expansion/2.
|
||||
|
||||
:- dynamic goal_expansion/2.
|
||||
|
||||
:- use_module('messages.yap').
|
||||
|
||||
:- ['undefined.yap'].
|
||||
|
||||
:- use_module('hacks.yap').
|
||||
|
||||
|
||||
:- use_module('attributes.yap').
|
||||
:- use_module('corout.yap').
|
||||
:- use_module('dialect.yap').
|
||||
:- use_module('dbload.yap').
|
||||
:- use_module('ypp.yap').
|
||||
:- use_module('../os/chartypes.yap').
|
||||
:- ensure_loaded('../os/edio.yap').
|
||||
|
||||
yap_hacks:cut_by(CP) :- '$$cut_by'(CP).
|
||||
|
||||
:- '$change_type_of_char'(36,7). % Make $ a symbol character
|
||||
|
||||
:- set_prolog_flag(generate_debug_info,true).
|
||||
|
||||
%
|
||||
% cleanup ensure loaded and recover some data-base space.
|
||||
%
|
||||
%:- ( recorded('$lf_loaded',_,R), erase(R), fail ; true ).
|
||||
%:- ( recorded('$module',_,R), erase(R), fail ; true ).
|
||||
|
||||
:- set_value('$user_module',user), '$protect'.
|
||||
|
||||
:- style_check([+discontiguous,+multiple,+single_var]).
|
||||
|
||||
%
|
||||
% moved this to init_gc in sgc.c to separate the alpha
|
||||
%
|
||||
% :- yap_flag(gc,on).
|
||||
%
|
||||
% :- yap_flag(gc_trace,verbose`
|
||||
|
||||
:- multifile
|
||||
prolog:comment_hook/3.
|
||||
|
||||
:- source.
|
||||
|
||||
:- module(user).
|
||||
|
||||
|
||||
/** @pred term_expansion( _T_,- _X_)
|
||||
user:term_expansion( _T_,- _X_)
|
||||
|
||||
|
||||
This user-defined predicate is called by `expand_term/3` to
|
||||
preprocess all terms read when consulting a file. If it succeeds:
|
||||
|
||||
+
|
||||
If _X_ is of the form `:- G` or `?- G`, it is processed as
|
||||
a directive.
|
||||
+
|
||||
If _X_ is of the form `$source_location`( _File_, _Line_): _Clause_` it is processed as if from `File` and line `Line`.
|
||||
|
||||
+
|
||||
If _X_ is a list, all terms of the list are asserted or processed
|
||||
as directives.
|
||||
+ The term _X_ is asserted instead of _T_.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
:- multifile term_expansion/2.
|
||||
|
||||
:- dynamic term_expansion/2.
|
||||
|
||||
:- multifile system:term_expansion/2.
|
||||
|
||||
:- dynamic system:term_expansion/2.
|
||||
|
||||
:- multifile system:swi_predicate_table/4.
|
||||
|
||||
/** @pred user:message_hook(+ _Term_, + _Kind_, + _Lines_)
|
||||
|
||||
|
||||
Hook predicate that may be define in the module `user` to intercept
|
||||
messages from print_message/2. _Term_ and _Kind_ are the
|
||||
same as passed to print_message/2. _Lines_ is a list of
|
||||
format statements as described with print_message_lines/3.
|
||||
|
||||
This predicate should be defined dynamic and multifile to allow other
|
||||
modules defining clauses for it too.
|
||||
|
||||
|
||||
*/
|
||||
:- multifile user:message_hook/3.
|
||||
|
||||
:- dynamic user:message_hook/3.
|
||||
|
||||
/** @pred exception(+ _Exception_, + _Context_, - _Action_)
|
||||
|
||||
|
||||
Dynamic predicate, normally not defined. Called by the Prolog system on run-time exceptions that can be repaired `just-in-time`. The values for _Exception_ are described below. See also catch/3 and throw/1.
|
||||
If this hook preodicate succeeds it must instantiate the _Action_ argument to the atom `fail` to make the operation fail silently, `retry` to tell Prolog to retry the operation or `error` to make the system generate an exception. The action `retry` only makes sense if this hook modified the environment such that the operation can now succeed without error.
|
||||
|
||||
+ `undefined_predicate`
|
||||
_Context_ is instantiated to a predicate-indicator ( _Module:Name/Arity_). If the predicate fails Prolog will generate an existence_error exception. The hook is intended to implement alternatives to the SWI built-in autoloader, such as autoloading code from a database. Do not use this hook to suppress existence errors on predicates. See also `unknown`.
|
||||
+ `undefined_global_variable`
|
||||
_Context_ is instantiated to the name of the missing global variable. The hook must call nb_setval/2 or b_setval/2 before returning with the action retry.
|
||||
|
||||
*/
|
||||
|
||||
:- multifile user:exception/3.
|
||||
|
||||
:- dynamic user:exception/3.
|
||||
|
||||
:- ensure_loaded('../pl/pathconf.yap').
|
||||
|
||||
:- current_prolog_flag(android,true), ensure_loaded('../android.yap').
|
||||
|
||||
:- set_prolog_flag(unknown,error).
|
||||
|
||||
'udi.yap',
|
||||
'boot2.yap'].
|
||||
|
||||
%% @}
|
||||
|
||||
|
209
pl/boot2.yap
Normal file
209
pl/boot2.yap
Normal file
@ -0,0 +1,209 @@
|
||||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
* *
|
||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||
* *
|
||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2014 *
|
||||
* *
|
||||
**************************************************************************
|
||||
* *
|
||||
* File: boot.yap *
|
||||
* Last rev: 8/2/88 *
|
||||
* mods: *
|
||||
* commen ts: boot file for Prolog *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
@file boot2.yap
|
||||
@brief YAP bootstrap, now in full Prolog.
|
||||
|
||||
|
||||
@addtogroup TopLevel Top-Level and Boot Predicates
|
||||
|
||||
@ingroup builtins
|
||||
@{
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
:- meta_predicate(log_event(+,:)).
|
||||
|
||||
:- dynamic prolog:'$user_defined_flag'/4.
|
||||
|
||||
:- multifile prolog:debug_action_hook/1.
|
||||
|
||||
:- multifile prolog:'$system_predicate'/2.
|
||||
|
||||
:- '$opdec'(1150,fx,(mode),prolog).
|
||||
|
||||
:- dynamic 'extensions_to_present_answer'/1.
|
||||
|
||||
:- ['arrays.yap'].
|
||||
|
||||
:- multifile user:portray_message/2.
|
||||
|
||||
:- dynamic user:portray_message/2.
|
||||
|
||||
/** @pred prolog:goal_expansion( :G,+ M,- NG)
|
||||
@pred user:goalexpansion(+ G,+ M,- NG)
|
||||
|
||||
The goal_expansion/3 hook is an user-defined
|
||||
procedure that is called after term expansion when compiling or
|
||||
asserting goals for each sub-goal in a clause. The first argument is
|
||||
bound to the goal and the second to the module under which the goal
|
||||
_G_ will execute. If goal_expansion/3 succeeds the new
|
||||
sub-goal _NG_ will replace _G_ and will be processed in the same
|
||||
way. If goal_expansion/3 fails the system will use the default
|
||||
expandion mechanism.
|
||||
|
||||
This hook is called:
|
||||
- at compilation time;
|
||||
- when running a query in the top-level
|
||||
|
||||
Older versions of YAP would call this procedure at every meta-call.
|
||||
|
||||
|
||||
*/
|
||||
:- multifile user:goal_expansion/3.
|
||||
|
||||
:- dynamic user:goal_expansion/3.
|
||||
|
||||
:- multifile user:goal_expansion/2.
|
||||
|
||||
:- dynamic user:goal_expansion/2.
|
||||
|
||||
:- multifile system:goal_expansion/2.
|
||||
|
||||
:- dynamic system:goal_expansion/2.
|
||||
|
||||
:- multifile goal_expansion/2.
|
||||
|
||||
:- dynamic goal_expansion/2.
|
||||
|
||||
:- use_module('messages.yap').
|
||||
|
||||
:- ['undefined.yap'].
|
||||
|
||||
:- use_module('hacks.yap').
|
||||
|
||||
:- use_module('pathconf.yap').
|
||||
|
||||
|
||||
|
||||
:- use_module('attributes.yap').
|
||||
:- use_module('corout.yap').
|
||||
:- use_module('dialect.yap').
|
||||
:- use_module('dbload.yap').
|
||||
:- use_module('ypp.yap').
|
||||
:- use_module('../os/chartypes.yap').
|
||||
:- use_module('../os/edio.yap').
|
||||
|
||||
|
||||
yap_hacks:cut_by(CP) :- '$$cut_by'(CP).
|
||||
|
||||
:- '$change_type_of_char'(36,7). % Make $ a symbol character
|
||||
|
||||
:- set_prolog_flag(generate_debug_info,true).
|
||||
|
||||
%
|
||||
% cleanup ensure loaded and recover some data-base space.
|
||||
%
|
||||
%:- ( recorded('$lf_loaded',_,R), erase(R), fail ; true ).
|
||||
%:- ( recorded('$module',_,R), erase(R), fail ; true ).
|
||||
|
||||
:- set_value('$user_module',user), '$protect'.
|
||||
|
||||
:- style_check([+discontiguous,+multiple,+single_var]).
|
||||
|
||||
%
|
||||
% moved this to init_gc in sgc.c to separate the alpha
|
||||
%
|
||||
% :- yap_flag(gc,on).
|
||||
%
|
||||
% :- yap_flag(gc_trace,verbose`
|
||||
|
||||
:- multifile
|
||||
prolog:comment_hook/3.
|
||||
|
||||
:- source.
|
||||
|
||||
:- module(user).
|
||||
|
||||
:- current_prolog_flag(android,true)->use_module(user:'android.yap') ; true.
|
||||
|
||||
|
||||
/** @pred term_expansion( _T_,- _X_)
|
||||
user:term_expansion( _T_,- _X_)
|
||||
|
||||
|
||||
This user-defined predicate is called by `expand_term/3` to
|
||||
preprocess all terms read when consulting a file. If it succeeds:
|
||||
|
||||
+
|
||||
If _X_ is of the form `:- G` or `?- G`, it is processed as
|
||||
a directive.
|
||||
+
|
||||
If _X_ is of the form `$source_location`( _File_, _Line_): _Clause_` it is processed as if from `File` and line `Line`.
|
||||
|
||||
+
|
||||
If _X_ is a list, all terms of the list are asserted or processed
|
||||
as directives.
|
||||
+ The term _X_ is asserted instead of _T_.
|
||||
|
||||
*/
|
||||
:- multifile term_expansion/2.
|
||||
|
||||
:- dynamic term_expansion/2.
|
||||
|
||||
:- multifile system:term_expansion/2.
|
||||
|
||||
:- dynamic system:term_expansion/2.
|
||||
|
||||
:- multifile system:swi_predicate_table/4.
|
||||
|
||||
/** @pred user:message_hook(+ _Term_, + _Kind_, + _Lines_)
|
||||
|
||||
|
||||
Hook predicate that may be define in the module `user` to intercept
|
||||
messages from print_message/2. _Term_ and _Kind_ are the
|
||||
same as passed to print_message/2. _Lines_ is a list of
|
||||
format statements as described with print_message_lines/3.
|
||||
|
||||
This predicate should be defined dynamic and multifile to allow other
|
||||
modules defining clauses for it too.
|
||||
|
||||
|
||||
*/
|
||||
:- multifile user:message_hook/3.
|
||||
|
||||
:- dynamic user:message_hook/3.
|
||||
|
||||
/** @pred exception(+ _Exception_, + _Context_, - _Action_)
|
||||
|
||||
|
||||
Dynamic predicate, normally not defined. Called by the Prolog system on run-time exceptions that can be repaired `just-in-time`. The values for _Exception_ are described below. See also catch/3 and throw/1.
|
||||
If this hook preodicate succeeds it must instantiate the _Action_ argument to the atom `fail` to make the operation fail silently, `retry` to tell Prolog to retry the operation or `error` to make the system generate an exception. The action `retry` only makes sense if this hook modified the environment such that the operation can now succeed without error.
|
||||
|
||||
+ `undefined_predicate`
|
||||
_Context_ is instantiated to a predicate-indicator ( _Module:Name/Arity_). If the predicate fails Prolog will generate an existence_error exception. The hook is intended to implement alternatives to the SWI built-in autoloader, such as autoloading code from a database. Do not use this hook to suppress existence errors on predicates. See also `unknown`.
|
||||
+ `undefined_global_variable`
|
||||
_Context_ is instantiated to the name of the missing global variable. The hook must call nb_setval/2 or b_setval/2 before returning with the action retry.
|
||||
|
||||
*/
|
||||
|
||||
:- module(user).
|
||||
|
||||
|
||||
:- multifile user:exception/3.
|
||||
|
||||
:- dynamic user:exception/3.
|
||||
|
||||
|
||||
:- set_prolog_flag(unknown,error).
|
||||
|
||||
%% @}
|
||||
|
@ -265,7 +265,7 @@ load_files(Files0,Opts) :-
|
||||
'$lf_option'(sandboxed, 24, false).
|
||||
'$lf_option'(scope_settings, 25, false).
|
||||
'$lf_option'(modified, 26, _).
|
||||
'$lf_option'('$context_module', 27, _).
|
||||
'$lf_option'(source_module, 27, _).
|
||||
'$lf_option'('$parent_topts', 28, _).
|
||||
'$lf_option'(must_be_module, 29, false).
|
||||
'$lf_option'('$source_pos', 30, _).
|
||||
@ -317,12 +317,12 @@ load_files(Files0,Opts) :-
|
||||
'__NB_getval__'('$lf_status', OldTOpts, fail),
|
||||
nonvar(OldTOpts), functor( OldTOpts, opt, LastOpt ),
|
||||
'$lf_opt'(autoload, OldTOpts, OldAutoload),
|
||||
'$lf_opt'('$context_module', OldTOpts, OldContextModule)
|
||||
'$lf_opt'(source_module, OldTOpts, OldContextModule)
|
||||
;
|
||||
current_prolog_flag(autoload, OldAutoload),
|
||||
functor( OldTOpts, opt, LastOpt ),
|
||||
'$lf_opt'(autoload, OldTOpts, OldAutoload),
|
||||
'$lf_opt'('$context_module', OldTOpts, OldContextModule)
|
||||
'$lf_opt'(source_module, OldTOpts, OldContextModule)
|
||||
),
|
||||
functor( TOpts, opt, LastOpt ),
|
||||
( source_location(ParentF, Line) -> true ; ParentF = user_input, Line = -1 ),
|
||||
@ -448,7 +448,7 @@ load_files(Files0,Opts) :-
|
||||
( Val == false -> true ;
|
||||
Val == true -> true ;
|
||||
'$do_error'(domain_error(unimplemented_option,register(Val)),Call) ).
|
||||
'$process_lf_opt'('$context_module', Mod, Call) :-
|
||||
'$process_lf_opt'(source_module, Mod, Call) :-
|
||||
( atom(Mod) -> true ; '$do_error'(type_error(atom,Mod),Call) ).
|
||||
|
||||
|
||||
@ -724,7 +724,7 @@ db_files(Fs) :-
|
||||
set_stream( Stream, [alias(loop_stream), encoding(Encoding)] ),
|
||||
'__NB_getval__'('$loop_streams',Sts0, Sts0=[]),
|
||||
nb_setval('$loop_streams',[Stream|Sts0]),
|
||||
'$lf_opt'('$context_module', TOpts, ContextModule),
|
||||
'$lf_opt'(source_module, TOpts, ContextModule),
|
||||
'$lf_opt'(reexport, TOpts, Reexport),
|
||||
'$lf_opt'(qcompile, TOpts, QCompiling),
|
||||
'__NB_getval__'('$qcompile', ContextQCompiling, ContextQCompiling = never),
|
||||
@ -1359,7 +1359,7 @@ account the following observations:
|
||||
'$reexport'( TOpts, File, Reexport, Imports, OldF ) :-
|
||||
( Reexport == false -> true ;
|
||||
( '$lf_opt'('$parent_topts', TOpts, OldTOpts),
|
||||
'$lf_opt'('$context_module', OldTOpts, OldContextModule)
|
||||
'$lf_opt'(source_module, OldTOpts, OldContextModule)
|
||||
->
|
||||
true
|
||||
;
|
||||
|
@ -389,23 +389,13 @@ version(T) :-
|
||||
fail.
|
||||
'$set_toplevel_hook'(_).
|
||||
|
||||
query_to_answer(G, V, Status, Vs, Bindings ) :-
|
||||
gated_call( true, (G,'$delayed_goals'(G, V, Vs, LGs, _DCP)), Status, '$answer'( Status, LGs, Vs, Bindings ) ).
|
||||
|
||||
'$answer'( exit, LGs, Vs, Bindings ) :-
|
||||
!,
|
||||
'$sort'(Vs, NVs),
|
||||
'$prep_answer_var_by_var'(NVs, Bindings , LGs).
|
||||
'$answer'( answer, LGs, Vs, Bindings) :-
|
||||
!,
|
||||
'$sort'(Vs, NVs),
|
||||
'$prep_answer_var_by_var'(NVs, Bindings , LGs).
|
||||
'$answer'(!, _, _,_).
|
||||
'$answer'(fail,_,_,_).
|
||||
'$answer'(exception(E),_,_,_) :-
|
||||
'$LoopError'(E,error).
|
||||
'$answer'(external_exception(_),_,_,_).
|
||||
|
||||
query_to_answer(G, V, Status, LGs) :-
|
||||
gated_call(true,
|
||||
G,
|
||||
Status,
|
||||
true),
|
||||
'$delayed_goals'(G, V, NV, LVGs, _DCP),
|
||||
lists:append(NV, LVGs, LGs).
|
||||
|
||||
%% @}
|
||||
|
||||
|
@ -477,7 +477,7 @@ be lost.
|
||||
'$trace_goal'(G, M, GoalNumber, H) :-
|
||||
'$undefined'(G, M),
|
||||
!,
|
||||
'$get_undefined_pred'(G, M, Goal, NM),
|
||||
'$get_undefined_pred'(M:G, NM:Goal),
|
||||
( ( M == NM ; NM == prolog), G == Goal
|
||||
->
|
||||
yap_flag( unknown, Action ),
|
||||
|
35
pl/error.yap
35
pl/error.yap
@ -10,8 +10,10 @@
|
||||
[ must_be_of_type/2, % +Type, +Term
|
||||
must_be_of_type/3, % +Type, +Term, +Comment
|
||||
must_be/2, % +Type, +Term
|
||||
must_be_callable/1, % +Type, +Term
|
||||
must_be/3, % +Type, +Term, +Comment
|
||||
type_error/2, % +Type, +Term
|
||||
must_be_called/1,
|
||||
% must_be_in_domain/2, % +Domain, +Term
|
||||
% must_be_in_domain/3, % +Domain, +Term, +Comment
|
||||
domain_error/3, % +Domain, +Values, +Term
|
||||
@ -21,7 +23,9 @@
|
||||
must_bind_to_type/2, % +Type, ?Term
|
||||
instantiation_error/1, % +Term
|
||||
representation_error/1, % +Reason
|
||||
is_of_type/2 % +Type, +Term
|
||||
is_of_type/2, % +Type, +Term
|
||||
is_callable/1,
|
||||
is_callable/2
|
||||
]), []) .
|
||||
|
||||
/**
|
||||
@ -104,13 +108,13 @@ must_be(Type, X, Comment) :-
|
||||
|
||||
must_be_of_type(callable, X) :-
|
||||
!,
|
||||
is_callable(X, _).
|
||||
is_callable(X).
|
||||
must_be_of_type(atom, X) :-
|
||||
!,
|
||||
is_atom(X, _).
|
||||
is_atom(X).
|
||||
must_be_of_type(module, X) :-
|
||||
!,
|
||||
is_atom(X, _).
|
||||
is_atom(X).
|
||||
must_be_of_type(predicate_indicator, X) :-
|
||||
!,
|
||||
is_predicate_indicator(X, _).
|
||||
@ -120,19 +124,12 @@ must_be_of_type(Type, X) :-
|
||||
; is_not(Type, X)
|
||||
).
|
||||
|
||||
inline(must_be_of_type( atom, X ), is_atom(X, _) ).
|
||||
inline(must_be_of_type( module, X ), is_module(X, _) ).
|
||||
inline(must_be_of_type( callable, X ), is_callable(X, _) ).
|
||||
inline(must_be_of_type( callable, X ), is_callable(X, _) ).
|
||||
inline(must_be_atom( X ), is_callable(X, _) ).
|
||||
inline(must_be_module( X ), is_atom(X, _) ).
|
||||
|
||||
must_be_of_type(predicate_indicator, X, Comment) :-
|
||||
!,
|
||||
is_predicate_indicator(X, Comment).
|
||||
must_be_of_type(callable, X, Comment) :-
|
||||
must_be_of_type(callable, X, _Comment) :-
|
||||
!,
|
||||
is_callable(X, Comment).
|
||||
is_callable(X).
|
||||
must_be_of_type(Type, X, _Comment) :-
|
||||
( has_type(Type, X)
|
||||
-> true
|
||||
@ -335,4 +332,16 @@ must_be_instantiated(X) :-
|
||||
must_be_instantiated(X, Comment) :-
|
||||
( var(X) -> instantiation_error(X, Comment) ; true).
|
||||
|
||||
must_be_callable(X) :-
|
||||
is_callable(X).
|
||||
|
||||
|
||||
inline(must_be_of_type( atom, X ), is_atom(X) ).
|
||||
inline(must_be_of_type( module, X ), is_atom(X) ).
|
||||
inline(must_be_of_type( callable, X ), is_callable(X) ).
|
||||
inline(must_be_atom( X ), is_atom(X) ).
|
||||
inline(must_be_module( X ), is_atom(X) ).
|
||||
inline(must_be_callable( X ), is_callable(X) ).
|
||||
inline(is_callable( X,_ ), is_callable(X) ).
|
||||
|
||||
%% @}
|
||||
|
212
pl/imports.yap
212
pl/imports.yap
@ -17,121 +17,127 @@
|
||||
*/
|
||||
:- '$mk_dynamic'('$parent_module'(_,_),prolog).
|
||||
|
||||
mimp :-
|
||||
recorded('$import',I,_), %'$import'(ExportingMod,ImportingMod,G0,G,_,_),_),
|
||||
writeln(I),
|
||||
%(ImportingMod:G :- ExportingMod:G0)),
|
||||
fail.
|
||||
|
||||
'$get_undefined_predicates'(G, ImportingMod, G0, ExportingMod) :-
|
||||
recorded('$import','$import'(ExportingModI,ImportingMod,G0I,G,_,_),_),
|
||||
'$continue_imported'(ExportingMod, ExportingModI, G0, G0I).
|
||||
% SWI builtin
|
||||
'$get_undefined_predicates'(G, _ImportingMod, G, user) :-
|
||||
nonvar(G),
|
||||
'$pred_exists'(G, user).
|
||||
% autoload
|
||||
'$get_undefined_predicates'(G, ImportingMod, G0, ExportingMod) :-
|
||||
prolog_flag(autoload, true),
|
||||
prolog_flag(unknown, OldUnk, fail),
|
||||
(
|
||||
'$autoload'(G, ImportingMod, ExportingModI, swi)
|
||||
->
|
||||
prolog_flag(unknown, _, OldUnk)
|
||||
;
|
||||
prolog_flag(unknown, _, OldUnk),
|
||||
fail
|
||||
),
|
||||
'$continue_imported'(ExportingMod, ExportingModI, G0, G).
|
||||
|
||||
%:- start_low_level_trace.
|
||||
% parent module mechanism
|
||||
'$get_undefined_predicates'(G, ImportingMod, G0, ExportingMod) :-
|
||||
'$parent_module'(ImportingMod,ExportingModI),
|
||||
'$continue_imported'(ExportingMod, ExportingModI, G0, G).
|
||||
'$get_undefined_predicates'(G, _ImportingMod, G0, ExportingMod) :-
|
||||
yap_flag(default_parent_module,ExportingModI),
|
||||
'$continue_imported'(ExportingMod, ExportingModI, G0, G).
|
||||
'$get_undefined_predicates'(ImportingMod:G,ExportingMod:G0) :-
|
||||
recorded('$import','$import'(ExportingMod,ImportingMod,G,G0,_,_),_)
|
||||
->
|
||||
true
|
||||
;
|
||||
%% this should have been caught before
|
||||
'$is_system_predicate'(G, prolog)
|
||||
->
|
||||
true
|
||||
;
|
||||
% autoload
|
||||
current_prolog_flag(autoload, true)
|
||||
->
|
||||
'$autoload'(G, ImportingMod, ExportingMod, swi)
|
||||
;
|
||||
'$parent_module'(ImportingMod, NewImportingMod)
|
||||
->
|
||||
'$get_undefined_predicates'(NewImportingMod:G, ExportingMod:G0).
|
||||
|
||||
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :-
|
||||
'$get_undefined_predicates'(G, ImportingMod, G0, ExportingMod),
|
||||
!.
|
||||
|
||||
|
||||
% be careful here not to generate an undefined exception.
|
||||
'$imported_predicate'(G, _ImportingMod, G, prolog) :-
|
||||
nonvar(G), '$is_system_predicate'(G, prolog), !.
|
||||
'$imported_predicate'(G, ImportingMod, G0, ExportingMod) :-
|
||||
( var(G) -> true ;
|
||||
var(ImportingMod) -> true ;
|
||||
'$undefined'(G, ImportingMod)
|
||||
),
|
||||
'$get_undefined_predicates'(G, ImportingMod, G0, ExportingMod),
|
||||
ExportingMod \= ImportingMod.
|
||||
|
||||
|
||||
% be careful here not to generate an undefined exception.
|
||||
'$generate_imported_predicate'(G, ImportingMod, G0, ExportingMod) :-
|
||||
(
|
||||
recorded('$import','$import'(ExportingModI,ImportingMod,G0I,G,_,_),_)
|
||||
;
|
||||
'$parent_module'(ImportingMod,ExportingModI),
|
||||
\+ recorded('$import','$import'(ExportingModI,ImportingMod,G0I,G,_,_),_)
|
||||
),
|
||||
ImportingMod \= ExportingModI,
|
||||
(
|
||||
'$undefined'(G, ExportingModI)
|
||||
->
|
||||
'$generate_imported_predicate'(G, ExportingModI, G0, ExportingMod)
|
||||
;
|
||||
G=G0,
|
||||
ExportingModI=ExportingMod
|
||||
).
|
||||
|
||||
/**
|
||||
*
|
||||
* @pred '$continue_imported'(+ModIn, +ModOut, +PredIn ,+PredOut)
|
||||
/**
|
||||
*
|
||||
* @pred '$continue_imported'(+Modn, +ModOut, +Predn ,+PredOut)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
'$continue_imported'(Mod,Mod,Pred,Pred) :-
|
||||
'$pred_exists'(Pred, Mod),
|
||||
!.
|
||||
'$continue_imported'(FM,Mod,FPred,Pred) :-
|
||||
recorded('$import','$import'(IM,Mod,IPred,Pred,_,_),_),
|
||||
'$continue_imported'(FM, IM, FPred, IPred), !.
|
||||
'$continue_imported'(FM,Mod,FPred,Pred) :-
|
||||
prolog:'$parent_module'(Mod,IM),
|
||||
'$continue_imported'(FM, IM, FPred, Pred).
|
||||
'$continue_imported'(Mod:Pred,Mod,Pred) :-
|
||||
'$pred_exists'(Pred, Mod),
|
||||
!.
|
||||
'$continue_imported'(FM:FPred,Mod:Pred) :-
|
||||
'$get_undefined_predicates'(FM:FPred, ModI:PredI),
|
||||
'$continue_imported'(ModI:PredI,Mod:Pred).
|
||||
|
||||
%
|
||||
'$get_undefined_pred'(ImportingMod:G, ExportingMod:G0) :-
|
||||
must_be_callable( ImportingMod:G ),
|
||||
'$get_undefined_predicates'(ImportingMod:G, ExportingMod:G0).
|
||||
|
||||
% be careful here not to generate an undefined exception.
|
||||
'$imported_predicate'(ImportingMod:G, ExportingMod:G0) :-
|
||||
var(G) ->
|
||||
'$current_predicate'(_,G,ImportingMod,_),
|
||||
'$imported_predicate'(ImportingMod:G, ExportingMod:G0)
|
||||
;
|
||||
var(ImportingMod) ->
|
||||
current_module(ImportingMod),
|
||||
'$imported_predicate'(ImportingMod:G, ExportingMod:G0)
|
||||
;
|
||||
'$undefined'(G, ImportingMod),
|
||||
'$get_undefined_predicates'(ImportingMod:G, ExportingMod:G0),
|
||||
ExportingMod \= ImportingMod.
|
||||
|
||||
|
||||
% check if current module redefines an imported predicate.
|
||||
% and remove import.
|
||||
%
|
||||
'$not_imported'(H, Mod) :-
|
||||
recorded('$import','$import'(NM,Mod,NH,H,_,_),R),
|
||||
NM \= Mod,
|
||||
functor(NH,N,Ar),
|
||||
print_message(warning,redefine_imported(Mod,NM,N/Ar)),
|
||||
erase(R),
|
||||
fail.
|
||||
'$not_imported'(_, _).
|
||||
|
||||
|
||||
'$autoload'(G, _ImportingMod, ExportingMod, Dialect) :-
|
||||
functor(G, Name, Arity),
|
||||
'$pred_exists'(index(Name,Arity,ExportingMod,_),Dialect),
|
||||
call(Dialect:index(Name,Arity,ExportingMod,_)),
|
||||
!.
|
||||
'$autoload'(G, ImportingMod, ExportingMod, _Dialect) :-
|
||||
functor(G, N, K),
|
||||
functor(G0, N, K),
|
||||
'$autoloader_find_predicate'(G0,ExportingMod),
|
||||
ExportingMod \= ImportingMod,
|
||||
(recordzifnot('$import','$import'(ExportingMod,ImportingMod,G0,G0, N ,K),_) -> true ; true ).
|
||||
|
||||
|
||||
'$autoloader_find_predicate'(G,ExportingModI) :-
|
||||
'__NB_getval__'('$autoloader_set', true, false), !,
|
||||
autoloader:find_predicate(G,ExportingModI).
|
||||
'$autoloader_find_predicate'(G,ExportingModI) :-
|
||||
yap_flag(autoload, true, false),
|
||||
yap_flag( unknown, Unknown, fail),
|
||||
yap_flag(debug, Debug, false), !,
|
||||
load_files([library(autoloader),
|
||||
autoloader:library('INDEX'),
|
||||
swi:library('dialect/swi/INDEX')],
|
||||
[autoload(true),if(not_loaded)]),
|
||||
nb_setval('$autoloader_set', true),
|
||||
yap_flag(autoload, _, true),
|
||||
yap_flag( unknown, _, Unknown),
|
||||
yap_flag( debug, _, Debug),
|
||||
autoloader:find_predicate(G,ExportingModI).
|
||||
'$verify_import'(_M:G, prolog:G) :-
|
||||
'$is_system_predicate'(G, prolog).
|
||||
'$verify_import'(M:G, NM:NG) :-
|
||||
'$get_undefined_predicates'(M:G, M, NM:NG),
|
||||
!.
|
||||
'$verify_import'(MG, MG).
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
'$autoload'(G, _mportingMod, ExportingMod, Dialect) :-
|
||||
functor(G, Name, Arity),
|
||||
'$pred_exists'(index(Name,Arity,ExportingMod,_),Dialect),
|
||||
call(Dialect:index(Name,Arity,ExportingMod,_)),
|
||||
!.
|
||||
'$autoload'(G, ImportingMod, ExportingMod, _Dialect) :-
|
||||
functor(G, N, K),
|
||||
functor(G0, N, K),
|
||||
'$autoloader_find_predicate'(G0,ExportingMod),
|
||||
ExportingMod \= ImportingMod,
|
||||
(recordzifnot('$import','$import'(ExportingMod,ImportingMod,G0,G0, N ,K),_),
|
||||
\+ '$system_predicate'(G0,prolog)
|
||||
->
|
||||
'$compile'((G:-ExportingMod:G0), reconsult ,(ImportingMod:G:-ExportingMod:G0), ImportingMod, _)
|
||||
;
|
||||
true
|
||||
).
|
||||
|
||||
|
||||
'$autoloader_find_predicate'(G,ExportingMod) :-
|
||||
'__NB_getval__'('$autoloader_set', true, false), !,
|
||||
autoloader:find_predicate(G,ExportingMod).
|
||||
'$autoloader_find_predicate'(G,ExportingMod) :-
|
||||
yap_flag(autoload, true, false),
|
||||
yap_flag( unknown, Unknown, fail),
|
||||
yap_flag(debug, Debug, false), !,
|
||||
load_files([library(autoloader)],[silent(true)]),
|
||||
nb_setval('$autoloader_set', true),
|
||||
yap_flag(autoload, _, true),
|
||||
yap_flag( unknown, _, Unknown),
|
||||
yap_flag( debug, _, Debug),
|
||||
autoloader:find_predicate(G,ExportingMod).
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
271
pl/listing.yap
271
pl/listing.yap
@ -1,3 +1,4 @@
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* YAP Prolog *
|
||||
@ -97,30 +98,43 @@ listing(MV) :-
|
||||
listing(Stream, MV).
|
||||
|
||||
listing(Stream, MV) :-
|
||||
strip_module( MV, M, I),
|
||||
'$mlisting'(Stream, I, M).
|
||||
listing(_Stream, []) :- !.
|
||||
listing(Stream, [MV|MVs]) :- !,
|
||||
listing(Stream, MV),
|
||||
listing(Stream, MVs).
|
||||
'$yap_strip_module'( MV, M, I),
|
||||
listing_(Stream, I, M),
|
||||
!.
|
||||
|
||||
listing_(Stream, V, M) :-
|
||||
var(V),
|
||||
!,
|
||||
'$mlisting'(Stream, V, M).
|
||||
listing_(_Stream, [], _) :-
|
||||
!.
|
||||
listing_(Stream, [MV|MVs], M) :-
|
||||
!,
|
||||
'$mlisting'(Stream, MV, M),
|
||||
listing_(Stream, MVs, M).
|
||||
listing_(Stream, MV, M) :-
|
||||
'$mlisting'(Stream, MV, M).
|
||||
|
||||
'$mlisting'(Stream, MV, M) :-
|
||||
( var(MV) ->
|
||||
MV = NA,
|
||||
'$do_listing'(Stream, M, NA)
|
||||
;
|
||||
atom(MV) ->
|
||||
MV/_ = NA,
|
||||
'$do_listing'(Stream, M, NA)
|
||||
;
|
||||
MV = N//Ar -> ( integer(Ar) -> Ar2 is Ar+2, NA is N/Ar2 ; '$do_listing'(Stream, NA/Ar2, M), Ar2 >= 2, Ar is Ar2-2 )
|
||||
;
|
||||
MV = N/Ar, ( atom(N) -> true ; var(N) ), ( integer(Ar) -> true ; var(Ar) ) ->
|
||||
'$do_listing'(Stream, M, MV)
|
||||
;
|
||||
MV = M1:PP -> '$mlisting'(Stream, PP, M1)
|
||||
;
|
||||
'$do_error'(type_error(predicate_indicator,MV),listing(Stream, MV) )
|
||||
MV = NA,
|
||||
'$do_listing'(Stream, M, NA)
|
||||
;
|
||||
atom(MV) ->
|
||||
MV/_ = NA,
|
||||
'$do_listing'(Stream, M, NA)
|
||||
;
|
||||
MV = N//Ar ->
|
||||
( integer(Ar) -> Ar2 is Ar+2, NA is N/Ar2 ;
|
||||
'$do_listing'(Stream, NA/Ar2, M), Ar2 >= 2, Ar is Ar2-2 )
|
||||
;
|
||||
MV = N/Ar,
|
||||
( atom(N) -> true ; var(N) ),
|
||||
( integer(Ar) -> true ; var(Ar) ) -> '$do_listing'(Stream, M, MV)
|
||||
;
|
||||
MV = M1:PP -> '$mlisting'(Stream, PP, M1)
|
||||
;
|
||||
'$do_error'(type_error(predicate_indicator,MV),listing(Stream, MV) )
|
||||
).
|
||||
|
||||
'$do_listing'(Stream, M, Name/Arity) :-
|
||||
@ -130,33 +144,33 @@ listing(Stream, [MV|MVs]) :- !,
|
||||
\+ '$undefined'(Pred, M),
|
||||
'$listing'(Name,Arity,M,Stream),
|
||||
fail
|
||||
;
|
||||
true
|
||||
).
|
||||
;
|
||||
true
|
||||
).
|
||||
|
||||
%
|
||||
% at this point we are ground and we know who we want to list.
|
||||
%
|
||||
'$listing'(Name, Arity, M, Stream) :-
|
||||
% skip by default predicates starting with $
|
||||
functor(Pred,Name,Arity),
|
||||
'$list_clauses'(Stream,M,Pred).
|
||||
% skip by default predicates starting with $
|
||||
functor(Pred,Name,Arity),
|
||||
'$list_clauses'(Stream,M,Pred).
|
||||
'$listing'(_,_,_,_).
|
||||
|
||||
'$funcspec'(Name/Arity,Name,Arity) :- !, atom(Name).
|
||||
'$funcspec'(Name,Name,0) :- atom(Name), !.
|
||||
'$funcspec'(Name,_,_) :-
|
||||
'$do_error'(domain_error(predicate_spec,Name),listing(Name)).
|
||||
'$do_error'(domain_error(predicate_spec,Name),listing(Name)).
|
||||
|
||||
'$list_clauses'(Stream, M, Pred) :-
|
||||
'$predicate_flags'(Pred,M,Flags,Flags),
|
||||
(Flags /\ 0x48602000 =\= 0
|
||||
->
|
||||
nl(Stream),
|
||||
fail
|
||||
;
|
||||
!
|
||||
).
|
||||
'$predicate_flags'(Pred,M,Flags,Flags),
|
||||
(Flags /\ 0x48602000 =\= 0
|
||||
->
|
||||
nl(Stream),
|
||||
fail
|
||||
;
|
||||
!
|
||||
).
|
||||
'$list_clauses'(Stream, M, Pred) :-
|
||||
( '$is_dynamic'(Pred, M) -> true ; '$is_log_updatable'(Pred, M) ),
|
||||
functor( Pred, N, Ar ),
|
||||
@ -164,11 +178,11 @@ listing(Stream, [MV|MVs]) :- !,
|
||||
(
|
||||
M == Mod
|
||||
->
|
||||
format( Stream, ':- dynamic ~q/~d.~n', [N,Ar])
|
||||
format( Stream, ':- dynamic ~q/~d.~n', [N,Ar])
|
||||
;
|
||||
format( Stream, ':- dynamic ~q:~q/~d.~n', [M,N,Ar])
|
||||
),
|
||||
fail.
|
||||
format( Stream, ':- dynamic ~q:~q/~d.~n', [M,N,Ar])
|
||||
),
|
||||
fail.
|
||||
'$list_clauses'(Stream, M, Pred) :-
|
||||
'$is_thread_local'(Pred, M),
|
||||
functor( Pred, N, Ar ),
|
||||
@ -176,11 +190,11 @@ listing(Stream, [MV|MVs]) :- !,
|
||||
(
|
||||
M == Mod
|
||||
->
|
||||
format( Stream, ':- thread_local ~q/~d.~n', [N,Ar])
|
||||
format( Stream, ':- thread_local ~q/~d.~n', [N,Ar])
|
||||
;
|
||||
format( Stream, ':- thread_local ~q:~q/~d.~n', [M,N,Ar])
|
||||
),
|
||||
fail.
|
||||
format( Stream, ':- thread_local ~q:~q/~d.~n', [M,N,Ar])
|
||||
),
|
||||
fail.
|
||||
'$list_clauses'(Stream, M, Pred) :-
|
||||
'$is_multifile'(Pred, M),
|
||||
functor( Pred, N, Ar ),
|
||||
@ -188,36 +202,36 @@ listing(Stream, [MV|MVs]) :- !,
|
||||
(
|
||||
M == Mod
|
||||
->
|
||||
format( Stream, ':- multifile ~q/~d.~n', [N,Ar])
|
||||
format( Stream, ':- multifile ~q/~d.~n', [N,Ar])
|
||||
;
|
||||
format( Stream, ':- multifile ~q:~q/~d.~n', [M,N,Ar])
|
||||
),
|
||||
fail.
|
||||
format( Stream, ':- multifile ~q:~q/~d.~n', [M,N,Ar])
|
||||
),
|
||||
fail.
|
||||
'$list_clauses'(Stream, M, Pred) :-
|
||||
'$is_metapredicate'(Pred, M),
|
||||
'$is_metapredicate'(Pred, M),
|
||||
functor( Pred, Name, Arity ),
|
||||
prolog:'$meta_predicate'(Name,M,Arity,PredDef),
|
||||
'$current_module'(Mod),
|
||||
(
|
||||
M == Mod
|
||||
->
|
||||
format( Stream, ':- ~q.~n', [PredDef])
|
||||
format( Stream, ':- ~q.~n', [PredDef])
|
||||
;
|
||||
format( Stream, ':- ~q:~q.~n', [M,PredDef])
|
||||
),
|
||||
fail.
|
||||
format( Stream, ':- ~q:~q.~n', [M,PredDef])
|
||||
),
|
||||
fail.
|
||||
'$list_clauses'(Stream, _M, _Pred) :-
|
||||
nl( Stream ),
|
||||
fail.
|
||||
nl( Stream ),
|
||||
fail.
|
||||
'$list_clauses'(Stream, M, Pred) :-
|
||||
'$predicate_flags'(Pred,M,Flags,Flags),
|
||||
% has to be dynamic, source, or log update.
|
||||
Flags /\ 0x08402000 =\= 0,
|
||||
'$clause'(Pred, M, Body, _),
|
||||
'$current_module'(Mod),
|
||||
( M \= Mod -> H = M:Pred ; H = Pred ),
|
||||
portray_clause(Stream,(H:-Body)),
|
||||
fail.
|
||||
% has to be dynamic, source, or log update.
|
||||
Flags /\ 0x08402000 =\= 0,
|
||||
clause(M:Pred, Body, _),
|
||||
'$current_module'(Mod),
|
||||
( M \= Mod -> H = M:Pred ; H = Pred ),
|
||||
portray_clause(Stream,(H:-Body)),
|
||||
fail.
|
||||
|
||||
/** @pred portray_clause(+ _S_,+ _C_)
|
||||
|
||||
@ -225,9 +239,9 @@ Write clause _C_ on stream _S_ as if written by listing/0.
|
||||
*/
|
||||
portray_clause(Stream, Clause) :-
|
||||
copy_term_nat(Clause, CopiedClause),
|
||||
'$beautify_vs'(CopiedClause),
|
||||
'$portray_clause'(Stream, CopiedClause),
|
||||
fail.
|
||||
'$beautify_vs'(CopiedClause),
|
||||
'$portray_clause'(Stream, CopiedClause),
|
||||
fail.
|
||||
portray_clause(_, _).
|
||||
|
||||
/** @pred portray_clause(+ _C_)
|
||||
@ -236,79 +250,80 @@ Write clause _C_ as if written by listing/0.
|
||||
|
||||
*/
|
||||
portray_clause(Clause) :-
|
||||
current_output(Stream),
|
||||
portray_clause(Stream, Clause).
|
||||
current_output(Stream),
|
||||
portray_clause(Stream, Clause).
|
||||
|
||||
'$portray_clause'(Stream, (Pred :- true)) :- !,
|
||||
format(Stream, '~q.~n', [Pred]).
|
||||
format(Stream, '~q.~n', [Pred]).
|
||||
'$portray_clause'(Stream, (Pred:-Body)) :- !,
|
||||
format(Stream, '~q :-', [Pred]),
|
||||
'$write_body'(Body, 3, ',', Stream),
|
||||
format(Stream, '.~n', []).
|
||||
format(Stream, '~q :-', [Pred]),
|
||||
'$write_body'(Body, 3, ',', Stream),
|
||||
format(Stream, '.~n', []).
|
||||
'$portray_clause'(Stream, Pred) :-
|
||||
format(Stream, '~q.~n', [Pred]).
|
||||
format(Stream, '~q.~n', [Pred]).
|
||||
|
||||
'$write_body'(X,I,T,Stream) :- var(X), !,
|
||||
'$beforelit'(T,I,Stream),
|
||||
writeq(Stream, '_').
|
||||
'$write_body'((P,Q), I, T, Stream) :-
|
||||
!,
|
||||
'$write_body'(P,I,T, Stream),
|
||||
put(Stream, 0',), %
|
||||
'$write_body'(Q,I,',',Stream).
|
||||
'$write_body'((P->Q;S),I,_, Stream) :-
|
||||
!,
|
||||
format(Stream, '~n~*c(',[I,0' ]),
|
||||
I1 is I+2,
|
||||
'$write_body'(P,I1,'(',Stream),
|
||||
format(Stream, '~n~*c->',[I,0' ]),
|
||||
'$write_disj'((Q;S),I,I1,'->',Stream),
|
||||
format(Stream, '~n~*c)',[I,0' ]).
|
||||
'$write_body'((P->Q|S),I,_,Stream) :-
|
||||
!,
|
||||
format(Stream, '~n~*c(',[I,0' ]),
|
||||
I1 is I+2,
|
||||
'$write_body'(P,I,'(',Stream),
|
||||
format(Stream, '~n~*c->',[I,0' ]),
|
||||
'$write_disj'((Q|S),I,I1,'->',Stream),
|
||||
format(Stream, '~n~*c)',[I,0' ]).
|
||||
'$write_body'((P->Q),I,_,Stream) :-
|
||||
!,
|
||||
format(Stream, '~n~*c(',[I,0' ]),
|
||||
I1 is I+2,
|
||||
'$write_body'(P,I1,'(',Stream),
|
||||
format(Stream, '~n~*c->',[I,0' ]),
|
||||
'$write_body'(Q,I1,'->',Stream),
|
||||
format(Stream, '~n~*c)',[I,0' ]).
|
||||
'$write_body'((P;Q),I,_,Stream) :-
|
||||
!,
|
||||
format(Stream, '~n~*c(',[I,0' ]),
|
||||
I1 is I+2,
|
||||
'$write_disj'((P;Q),I,I1,'->',Stream),
|
||||
format(Stream, '~n~*c)',[I,0' ]).
|
||||
'$write_body'((P|Q),I,_,Stream) :-
|
||||
!,
|
||||
format(Stream, '~n~*c(',[I,0' ]),
|
||||
I1 is I+2,
|
||||
'$write_disj'((P|Q),I,I1,'->',Stream),
|
||||
format(Stream, '~n~*c)',[I,0' ]).
|
||||
'$write_body'(X,I,T,Stream) :-
|
||||
'$beforelit'(T,I,Stream),
|
||||
writeq(Stream,X).
|
||||
var(X), !,
|
||||
'$beforelit'(T,I,Stream),
|
||||
writeq(Stream, '_').
|
||||
'$write_body'((P,Q), I, T, Stream) :-
|
||||
!,
|
||||
'$write_body'(P,I,T, Stream),
|
||||
put(Stream, 0',), %
|
||||
'$write_body'(Q,I,',',Stream).
|
||||
'$write_body'((P->Q;S),I,_, Stream) :-
|
||||
!,
|
||||
format(Stream, '~n~*c(',[I,0' ]),
|
||||
I1 is I+2,
|
||||
'$write_body'(P,I1,'(',Stream),
|
||||
format(Stream, '~n~*c->',[I,0' ]),
|
||||
'$write_disj'((Q;S),I,I1,'->',Stream),
|
||||
format(Stream, '~n~*c)',[I,0' ]).
|
||||
'$write_body'((P->Q|S),I,_,Stream) :-
|
||||
!,
|
||||
format(Stream, '~n~*c(',[I,0' ]),
|
||||
I1 is I+2,
|
||||
'$write_body'(P,I,'(',Stream),
|
||||
format(Stream, '~n~*c->',[I,0' ]),
|
||||
'$write_disj'((Q|S),I,I1,'->',Stream),
|
||||
format(Stream, '~n~*c)',[I,0' ]).
|
||||
'$write_body'((P->Q),I,_,Stream) :-
|
||||
!,
|
||||
format(Stream, '~n~*c(',[I,0' ]),
|
||||
I1 is I+2,
|
||||
'$write_body'(P,I1,'(',Stream),
|
||||
format(Stream, '~n~*c->',[I,0' ]),
|
||||
'$write_body'(Q,I1,'->',Stream),
|
||||
format(Stream, '~n~*c)',[I,0' ]).
|
||||
'$write_body'((P;Q),I,_,Stream) :-
|
||||
!,
|
||||
format(Stream, '~n~*c(',[I,0' ]),
|
||||
I1 is I+2,
|
||||
'$write_disj'((P;Q),I,I1,'->',Stream),
|
||||
format(Stream, '~n~*c)',[I,0' ]).
|
||||
'$write_body'((P|Q),I,_,Stream) :-
|
||||
!,
|
||||
format(Stream, '~n~*c(',[I,0' ]),
|
||||
I1 is I+2,
|
||||
'$write_disj'((P|Q),I,I1,'->',Stream),
|
||||
format(Stream, '~n~*c)',[I,0' ]).
|
||||
'$write_body'(X,I,T,Stream) :-
|
||||
'$beforelit'(T,I,Stream),
|
||||
writeq(Stream,X).
|
||||
|
||||
|
||||
|
||||
|
||||
'$write_disj'((Q;S),I0,I,C,Stream) :- !,
|
||||
'$write_body'(Q,I,C,Stream),
|
||||
format(Stream, '~n~*c;',[I0,0' ]),
|
||||
'$write_disj'(S,I0,I,';',Stream).
|
||||
'$write_body'(Q,I,C,Stream),
|
||||
format(Stream, '~n~*c;',[I0,0' ]),
|
||||
'$write_disj'(S,I0,I,';',Stream).
|
||||
'$write_disj'((Q|S),I0,I,C,Stream) :- !,
|
||||
'$write_body'(Q,I,C,Stream),
|
||||
format(Stream, '~n~*c|',[I0,0' ]),
|
||||
'$write_disj'(S,I0,I,'|',Stream).
|
||||
'$write_body'(Q,I,C,Stream),
|
||||
format(Stream, '~n~*c|',[I0,0' ]),
|
||||
'$write_disj'(S,I0,I,'|',Stream).
|
||||
'$write_disj'(S,_,I,C,Stream) :-
|
||||
'$write_body'(S,I,C,Stream).
|
||||
'$write_body'(S,I,C,Stream).
|
||||
|
||||
'$beforelit'('(',_,Stream) :-
|
||||
!,
|
||||
@ -324,11 +339,11 @@ portray_clause(Clause) :-
|
||||
|
||||
'$v_transform'([]).
|
||||
'$v_transform'(['$VAR'(-1)|L]) :-
|
||||
'$v_transform'(L).
|
||||
'$v_transform'(L).
|
||||
|
||||
'$vv_transform'([],_) :- !.
|
||||
'$vv_transform'(['$VAR'(M)|L],M) :-
|
||||
N is M+1,
|
||||
'$vv_transform'(L,N).
|
||||
N is M+1,
|
||||
'$vv_transform'(L,N).
|
||||
|
||||
%% @}
|
||||
|
@ -62,6 +62,9 @@ YAP supports the SWI-Prolog interface to loading foreign code, the shlib package
|
||||
*/
|
||||
|
||||
|
||||
load_foreign_files(_Objs,_Libs,Entry) :-
|
||||
'$check_embedded'(Entry),
|
||||
!.
|
||||
load_foreign_files(Objs,Libs,Entry) :-
|
||||
source_module(M),
|
||||
%G = load_foreign_files(Objs,Libs,Entry),
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user