Merge branch 'master' of ssh://yap.git.sourceforge.net/gitroot/yap/yap-6.3

This commit is contained in:
Tiago Gomes 2012-11-09 16:29:24 +00:00
commit c53220aa61
105 changed files with 2916 additions and 6792 deletions

6
.gitmodules vendored
View File

@ -37,3 +37,9 @@
[submodule "packages/real"]
path = packages/real
url = git://www.swi-prolog.org/home/pl/git/packages/real.git
[submodule "packages/archive"]
path = packages/archive
url = git://yap.git.sourceforge.net/gitroot/yap/archive
[submodule "packages/odbc"]
path = packages/odbc
url = git://yap.git.sourceforge.net/gitroot/yap/odbc

View File

@ -856,7 +856,10 @@ Yap_absmi(int inp)
BOp(Ystop, l);
SET_ASP(YREG, E_CB*sizeof(CELL));
/* make sure ASP is initialised */
Yap_StartSlots( PASS_REGS1 );
saveregs();
#if PUSH_REGS
restore_absmi_regs(old_regs);
#endif
@ -2164,7 +2167,7 @@ Yap_absmi(int inp)
} else {
DynamicClause *cl = ClauseFlagsToDynamicClause(pt1);
int erase;
LOCK(cl->ClLock);
DEC_CLREF_COUNT(cl);
erase = (cl->ClFlags & ErasedMask) && !(cl->ClRefCount);
@ -2945,45 +2948,8 @@ Yap_absmi(int inp)
if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL) {
PredEntry *ap = PREG->u.pp.p;
if (ap->PredFlags & HiddenPredFlag) {
CACHE_Y_AS_ENV(YREG);
CACHE_A1();
check_depth(DEPTH, ap);
PREG = ap->CodeOfPred;
/* for profiler */
save_pc();
ALWAYS_LOOKAHEAD(ap->OpcodeOfPred);
/* do deallocate */
CPREG = (yamop *) ENV_YREG[E_CP];
ENV_YREG = ENV = (CELL *) ENV_YREG[E_E];
#ifdef FROZEN_STACKS
{
choiceptr top_b = PROTECT_FROZEN_B(B);
#ifdef YAPOR_SBA
if (ENV_YREG > (CELL *) top_b || ENV_YREG < H) ENV_YREG = (CELL *) top_b;
#else
if (ENV_YREG > (CELL *) top_b) ENV_YREG = (CELL *) top_b;
#endif
else ENV_YREG = (CELL *)((CELL)ENV_YREG + ENV_Size(CPREG));
}
#else
if (ENV_YREG > (CELL *)B) {
ENV_YREG = (CELL *)B;
} else {
ENV_YREG = (CELL *) ((CELL) ENV_YREG + ENV_Size(CPREG));
}
#endif /* FROZEN_STACKS */
WRITEBACK_Y_AS_ENV();
/* setup GB */
ENV_YREG[E_CB] = (CELL) B;
ALWAYS_GONext();
ALWAYS_END_PREFETCH();
ENDCACHE_Y_AS_ENV();
} else {
SREG = (CELL *) ap;
goto creepde;
}
SREG = (CELL *) ap;
goto creepde;
}
/* set SREG for next instructions */
SREG = (CELL *) PREG->u.p.p;
@ -6915,7 +6881,7 @@ Yap_absmi(int inp)
BOp(call_cpred, Osbpp);
check_trail(TR);
if (!(PREG->u.Osbpp.p->PredFlags & (SafePredFlag|HiddenPredFlag))) {
if (!(PREG->u.Osbpp.p->PredFlags & (SafePredFlag))) {
CACHE_Y_AS_ENV(YREG);
check_stack(NoStackCall, H);
ENDCACHE_Y_AS_ENV();

View File

@ -210,6 +210,7 @@ LookupAtom(char *atom)
return na;
}
static Atom
LookupWideAtom(wchar_t *atom)
{ /* lookup atom in atom table */
@ -248,12 +249,16 @@ LookupWideAtom(wchar_t *atom)
#endif
/* add new atom to start of chain */
sz = wcslen(atom);
ae = (AtomEntry *) Yap_AllocAtomSpace(sizeof(AtomEntry) + sizeof(wchar_t)*(sz + 1)+sizeof(WideAtomEntry));
ae = (AtomEntry *) Yap_AllocAtomSpace((size_t)(((AtomEntry *)NULL)+1) + sizeof(wchar_t)*(sz + 1));
if (ae == NULL) {
WRITE_UNLOCK(WideHashChain[hash].AERWLock);
return NIL;
}
wae = (WideAtomEntry *)(ae->StrOfAE+sizeof(wchar_t)*(sz + 1));
wae = (WideAtomEntry *) Yap_AllocAtomSpace(sizeof(WideAtomEntry));
if (wae == NULL) {
WRITE_UNLOCK(WideHashChain[hash].AERWLock);
return NIL;
}
na = AbsAtom(ae);
ae->PropsOfAE = AbsWideAtomProp(wae);
wae->NextOfPE = NIL;
@ -1196,6 +1201,7 @@ Yap_NStringToList(char *s, size_t len)
return t;
}
Term
Yap_WideStringToList(wchar_t *s)
{
@ -1205,6 +1211,8 @@ Yap_WideStringToList(wchar_t *s)
t = MkAtomTerm(AtomNil);
while (cp > s) {
if (ASP < H+1024)
return (CELL)0;
t = MkPairTerm(MkIntegerTerm(*--cp), t);
}
return t;
@ -1219,6 +1227,8 @@ Yap_NWideStringToList(wchar_t *s, size_t len)
t = MkAtomTerm(AtomNil);
while (cp > s) {
if (ASP < H+1024)
return (CELL)0;
t = MkPairTerm(MkIntegerTerm(*--cp), t);
}
return t;
@ -1323,6 +1333,8 @@ Yap_WideStringToListOfAtoms(wchar_t *s)
t = MkAtomTerm(AtomNil);
while (cp > s) {
so[0] = *--cp;
if (ASP < H+1024)
return (CELL)0;
t = MkPairTerm(MkAtomTerm(LookupWideAtom(so)), t);
}
return t;
@ -1339,6 +1351,8 @@ Yap_NWideStringToListOfAtoms(wchar_t *s, size_t len)
so[1] = '\0';
t = MkAtomTerm(AtomNil);
while (cp > s) {
if (ASP < H+1024)
return (CELL)0;
so[0] = *--cp;
t = MkPairTerm(MkAtomTerm(LookupWideAtom(so)), t);
}

View File

@ -557,7 +557,7 @@ p_agc_threshold(USES_REGS1)
void
Yap_init_agc(void)
{
Yap_InitCPred("$atom_gc", 0, p_atom_gc, HiddenPredFlag);
Yap_InitCPred("$inform_agc", 3, p_inform_agc, HiddenPredFlag);
Yap_InitCPred("$agc_threshold", 1, p_agc_threshold, HiddenPredFlag|SafePredFlag);
Yap_InitCPred("$atom_gc", 0, p_atom_gc, 0);
Yap_InitCPred("$inform_agc", 3, p_inform_agc, 0);
Yap_InitCPred("$agc_threshold", 1, p_agc_threshold, SafePredFlag);
}

View File

@ -2445,9 +2445,9 @@ p_static_array_location( USES_REGS1 )
void
Yap_InitArrayPreds( void )
{
Yap_InitCPred("$create_array", 2, p_create_array, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$array_references", 3, p_array_references, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$array_arg", 3, p_array_arg, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$create_array", 2, p_create_array, SyncPredFlag);
Yap_InitCPred("$array_references", 3, p_array_references, SafePredFlag);
Yap_InitCPred("$array_arg", 3, p_array_arg, SafePredFlag);
Yap_InitCPred("static_array", 3, p_create_static_array, SafePredFlag|SyncPredFlag);
Yap_InitCPred("resize_static_array", 3, p_resize_static_array, SafePredFlag|SyncPredFlag);
Yap_InitCPred("mmapped_array", 4, p_create_mmapped_array, SafePredFlag|SyncPredFlag);
@ -2457,10 +2457,10 @@ Yap_InitArrayPreds( void )
Yap_InitCPred("array_element", 3, p_access_array, 0);
Yap_InitCPred("reset_static_array", 1, p_clear_static_array, SafePredFlag);
Yap_InitCPred("close_static_array", 1, p_close_static_array, SafePredFlag);
Yap_InitCPred("$sync_mmapped_arrays", 0, p_sync_mmapped_arrays, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$compile_array_refs", 0, p_compile_array_refs, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$array_refs_compiled", 0, p_array_refs_compiled, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$static_array_properties", 3, p_static_array_properties, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$sync_mmapped_arrays", 0, p_sync_mmapped_arrays, SafePredFlag);
Yap_InitCPred("$compile_array_refs", 0, p_compile_array_refs, SafePredFlag);
Yap_InitCPred("$array_refs_compiled", 0, p_array_refs_compiled, SafePredFlag);
Yap_InitCPred("$static_array_properties", 3, p_static_array_properties, SafePredFlag);
Yap_InitCPred("static_array_to_term", 2, p_static_array_to_term, 0L);
Yap_InitCPred("static_array_location", 2, p_static_array_location, 0L);
}

View File

@ -1075,7 +1075,7 @@ void Yap_InitAttVarPreds(void)
Yap_InitCPred("all_attvars", 1, p_all_attvars, 0);
CurrentModule = OldCurrentModule;
Yap_InitCPred("attvar", 1, p_is_attvar, SafePredFlag|TestPredFlag);
Yap_InitCPred("$att_bound", 1, p_attvar_bound, SafePredFlag|TestPredFlag|HiddenPredFlag);
Yap_InitCPred("$att_bound", 1, p_attvar_bound, SafePredFlag|TestPredFlag);
}

2
C/bb.c
View File

@ -375,6 +375,6 @@ Yap_InitBBPreds(void)
Yap_InitCPred("bb_get", 2, p_bb_get, 0);
Yap_InitCPred("bb_delete", 2, p_bb_delete, 0);
Yap_InitCPred("bb_update", 3, p_bb_update, 0);
Yap_InitCPred("$resize_bb_int_keys", 1, p_resize_bb_int_keys, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$resize_bb_int_keys", 1, p_resize_bb_int_keys, SafePredFlag|SyncPredFlag);
}

View File

@ -556,8 +556,8 @@ Yap_BlobStringOfTermAndLength(Term t, size_t *sp)
void
Yap_InitBigNums(void)
{
Yap_InitCPred("$has_bignums", 0, p_has_bignums, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$bignum", 1, p_is_bignum, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$has_bignums", 0, p_has_bignums, SafePredFlag);
Yap_InitCPred("$bignum", 1, p_is_bignum, SafePredFlag);
Yap_InitCPred("rational", 3, p_rational, 0);
Yap_InitCPred("rational", 1, p_is_rational, SafePredFlag);
}

View File

@ -2566,8 +2566,8 @@ YAP_RestartGoal(void)
LOCAL_PrologMode = UserCCallMode;
if (out == FALSE) {
/* cleanup */
Yap_CloseSlots( PASS_REGS1 );
Yap_trust_last();
Yap_CloseSlots( PASS_REGS1 );
LOCAL_AllowRestart = FALSE;
}
} else {

327
C/cdmgr.c
View File

@ -1656,7 +1656,7 @@ add_first_static(PredEntry *p, yamop *cp, int spy_flag)
yamop *pt = cp;
if (is_logupd(p)) {
if (p == PredGoalExpansion) {
if (p == PredGoalExpansion || p->FunctorOfPred == FunctorGoalExpansion2) {
PRED_GOAL_EXPANSION_ON = TRUE;
Yap_InitComma();
}
@ -1711,7 +1711,7 @@ add_first_dynamic(PredEntry *p, yamop *cp, int spy_flag)
{
yamop *ncp = ((DynamicClause *)NULL)->ClCode;
DynamicClause *cl;
if (p == PredGoalExpansion) {
if (p == PredGoalExpansion || p->FunctorOfPred == FunctorGoalExpansion2) {
PRED_GOAL_EXPANSION_ON = TRUE;
Yap_InitComma();
}
@ -2093,6 +2093,7 @@ mark_preds_with_this_func(Functor f, Prop p0)
for (i = 0; i < PredHashTableSize; i++) {
PredEntry *p = PredHash[i];
/* search the whole pred table, kind of inneficient */
while (p) {
Prop nextp = p->NextOfPE;
if (p->FunctorOfPred == f)
@ -2102,6 +2103,109 @@ mark_preds_with_this_func(Functor f, Prop p0)
}
}
static void
mark_preds_with_this_atom(Prop p)
{
while (p) {
Prop nextp = p->NextOfPE;
if (p->KindOfPE == PEProp)
RepPredProp(p)->PredFlags |= GoalExPredFlag;
p = nextp;
}
}
static void
goal_expansion_support(PredEntry *p, Term tf)
{
if (p == PredGoalExpansion) {
Term tg = ArgOfTerm(1, tf);
Term tm = ArgOfTerm(2, tf);
if (IsVarTerm(tg) || IsVarTerm(tm)) {
if (!IsVarTerm(tg)) {
/* this is the complicated case, first I need to inform
predicates for this functor */
PRED_GOAL_EXPANSION_FUNC = TRUE;
if (IsAtomTerm(tg)) {
AtomEntry *ae = RepAtom(AtomOfTerm(tg));
Prop p0 = ae->PropsOfAE;
int found = FALSE;
while (p0) {
PredEntry *pe = RepPredProp(p0);
if (pe->KindOfPE == PEProp) {
pe->PredFlags |= GoalExPredFlag;
found = TRUE;
}
p0 = pe->NextOfPE;
}
if (!found) {
PredEntry *npe = RepPredProp(PredPropByAtom(AtomOfTerm(tg),IDB_MODULE));
npe->PredFlags |= GoalExPredFlag;
}
} else if (IsApplTerm(tg)) {
FunctorEntry *fe = (FunctorEntry *)FunctorOfTerm(tg);
Prop p0;
p0 = fe->PropsOfFE;
if (p0) {
mark_preds_with_this_func(FunctorOfTerm(tg), p0);
} else {
Term mod = CurrentModule;
PredEntry *npe;
if (CurrentModule == PROLOG_MODULE)
mod = IDB_MODULE;
npe = RepPredProp(PredPropByFunc(fe,mod));
npe->PredFlags |= GoalExPredFlag;
}
}
} else {
PRED_GOAL_EXPANSION_ALL = TRUE;
}
} else {
if (IsAtomTerm(tm)) {
if (IsAtomTerm(tg)) {
PredEntry *p = RepPredProp(PredPropByAtom(AtomOfTerm(tg), tm));
p->PredFlags |= GoalExPredFlag;
} else if (IsApplTerm(tg)) {
PredEntry *p = RepPredProp(PredPropByFunc(FunctorOfTerm(tg), tm));
p->PredFlags |= GoalExPredFlag;
}
}
}
} else if (p->FunctorOfPred == FunctorGoalExpansion2) {
Term tg = ArgOfTerm(1, tf);
if (IsVarTerm(tg)) {
PRED_GOAL_EXPANSION_ALL = TRUE;
} else if (IsApplTerm(tg)) {
FunctorEntry *fe = (FunctorEntry *)FunctorOfTerm(tg);
Prop p0;
PredEntry *npe;
p0 = fe->PropsOfFE;
if (p0 && (p->ModuleOfPred == PROLOG_MODULE || p->ModuleOfPred == SYSTEM_MODULE || p->ModuleOfPred == USER_MODULE)) {
mark_preds_with_this_func(fe, p0);
PRED_GOAL_EXPANSION_FUNC = TRUE;
}
npe = RepPredProp(PredPropByFunc(fe,p->ModuleOfPred));
npe->PredFlags |= GoalExPredFlag;
} else if (IsAtomTerm(tg)) {
Atom at = AtomOfTerm(tg);
Prop p0;
PredEntry *npe;
p0 = RepAtom(at)->PropsOfAE;
if (p0 && (p->ModuleOfPred == PROLOG_MODULE || p->ModuleOfPred == SYSTEM_MODULE || p->ModuleOfPred == USER_MODULE)) {
mark_preds_with_this_atom(p0);
PRED_GOAL_EXPANSION_FUNC = TRUE;
}
npe = RepPredProp(PredPropByAtom(at,p->ModuleOfPred));
npe->PredFlags |= GoalExPredFlag;
}
}
}
static int
addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
/*
@ -2158,63 +2262,7 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
}
if (pflags & (SpiedPredFlag|CountPredFlag|ProfiledPredFlag))
spy_flag = TRUE;
if (p == PredGoalExpansion) {
Term tg = ArgOfTerm(1, tf);
Term tm = ArgOfTerm(2, tf);
if (IsVarTerm(tg) || IsVarTerm(tm)) {
if (!IsVarTerm(tg)) {
/* this is the complicated case, first I need to inform
predicates for this functor */
PRED_GOAL_EXPANSION_FUNC = TRUE;
if (IsAtomTerm(tg)) {
AtomEntry *ae = RepAtom(AtomOfTerm(tg));
Prop p0 = ae->PropsOfAE;
int found = FALSE;
while (p0) {
PredEntry *pe = RepPredProp(p0);
if (pe->KindOfPE == PEProp) {
pe->PredFlags |= GoalExPredFlag;
found = TRUE;
}
p0 = pe->NextOfPE;
}
if (!found) {
PredEntry *npe = RepPredProp(PredPropByAtom(AtomOfTerm(tg),IDB_MODULE));
npe->PredFlags |= GoalExPredFlag;
}
} else if (IsApplTerm(tg)) {
FunctorEntry *fe = (FunctorEntry *)FunctorOfTerm(tg);
Prop p0;
p0 = fe->PropsOfFE;
if (p0) {
mark_preds_with_this_func(FunctorOfTerm(tg), p0);
} else {
Term mod = CurrentModule;
PredEntry *npe;
if (CurrentModule == PROLOG_MODULE)
mod = IDB_MODULE;
npe = RepPredProp(PredPropByFunc(fe,mod));
npe->PredFlags |= GoalExPredFlag;
}
}
} else {
PRED_GOAL_EXPANSION_ALL = TRUE;
}
} else {
if (IsAtomTerm(tm)) {
if (IsAtomTerm(tg)) {
PredEntry *p = RepPredProp(PredPropByAtom(AtomOfTerm(tg), tm));
p->PredFlags |= GoalExPredFlag;
} else if (IsApplTerm(tg)) {
PredEntry *p = RepPredProp(PredPropByFunc(FunctorOfTerm(tg), tm));
p->PredFlags |= GoalExPredFlag;
}
}
}
}
goal_expansion_support(p, tf);
if (mode == consult)
not_was_reconsulted(p, t, TRUE);
/* always check if we have a valid error first */
@ -4335,6 +4383,42 @@ p_all_system_pred( USES_REGS1 )
pe->OpcodeOfPred == Yap_opcode(_try_userc));
}
void
Yap_HidePred(PredEntry *pe)
{
Prop p0 = AbsPredProp(pe);
if (pe->ArityOfPE == 0) {
Atom a = (Atom)pe->FunctorOfPred;
p0 = RepAtom(a)->PropsOfAE;
if (p0 == AbsPredProp(pe)) {
RepAtom(a)->PropsOfAE = pe->NextOfPE;
} else {
while (p0->NextOfPE != AbsPredProp(pe))
p0 = p0->NextOfPE;
if (p0 == NIL)
return;
p0->NextOfPE = pe->NextOfPE;
}
} else {
Functor funt = pe->FunctorOfPred;
p0 = funt->PropsOfFE;
if (p0 == AbsPredProp(pe)) {
funt->PropsOfFE = pe->NextOfPE;
} else {
while (p0->NextOfPE != AbsPredProp(pe))
p0 = p0->NextOfPE;
if (p0 == NIL)
return;
p0->NextOfPE = pe->NextOfPE;
}
}
pe->NextOfPE = HIDDEN_PREDICATES;
HIDDEN_PREDICATES = AbsPredProp(pe);
pe->PredFlags |= HiddenPredFlag;
}
static Int /* $system_predicate(P) */
p_hide_predicate( USES_REGS1 )
{
@ -4347,7 +4431,9 @@ p_hide_predicate( USES_REGS1 )
if (IsVarTerm(t1))
return (FALSE);
if (IsAtomTerm(t1)) {
pe = RepPredProp(Yap_GetPredPropByAtom(AtomOfTerm(t1), mod));
Atom a = AtomOfTerm(t1);
pe = RepPredProp(Yap_GetPredPropByAtom(a, mod));
} else if (IsApplTerm(t1)) {
Functor funt = FunctorOfTerm(t1);
if (IsExtensionFunctor(funt)) {
@ -4368,15 +4454,16 @@ p_hide_predicate( USES_REGS1 )
}
pe = RepPredProp(Yap_GetPredPropByFunc(funt, mod));
} else if (IsPairTerm(t1)) {
return (TRUE);
return TRUE;
} else
return (FALSE);
return FALSE;
if (EndOfPAEntr(pe))
return FALSE;
pe->PredFlags |= HiddenPredFlag;
return(TRUE);
Yap_HidePred(pe);
return TRUE;
}
static Int /* $hidden_predicate(P) */
p_hidden_predicate( USES_REGS1 )
{
@ -5888,65 +5975,65 @@ Yap_InitCdMgr(void)
CACHE_REGS
Term cm = CurrentModule;
Yap_InitCPred("$compile_mode", 2, p_compile_mode, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$start_consult", 3, p_startconsult, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$show_consult_level", 1, p_showconslultlev, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$end_consult", 0, p_endconsult, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$set_spy", 2, p_setspy, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$rm_spy", 2, p_rmspy, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$compile_mode", 2, p_compile_mode, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$start_consult", 3, p_startconsult, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$show_consult_level", 1, p_showconslultlev, SafePredFlag);
Yap_InitCPred("$end_consult", 0, p_endconsult, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$set_spy", 2, p_setspy, SyncPredFlag);
Yap_InitCPred("$rm_spy", 2, p_rmspy, SafePredFlag|SyncPredFlag);
/* gc() may happen during compilation, hence these predicates are
now unsafe */
Yap_InitCPred("$compile", 4, p_compile, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$compile_dynamic", 5, p_compile_dynamic, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$purge_clauses", 2, p_purge_clauses, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$in_use", 2, p_in_use, TestPredFlag | SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$is_dynamic", 2, p_is_dynamic, TestPredFlag | SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$is_metapredicate", 2, p_is_metapredicate, TestPredFlag | SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$is_expand_goal_or_meta_predicate", 2, p_is_expandgoalormetapredicate, TestPredFlag | SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$is_log_updatable", 2, p_is_log_updatable, TestPredFlag | SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$is_source", 2, p_is_source, TestPredFlag | SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$owner_file", 3, p_owner_file, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$mk_d", 2, p_mk_d, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$pred_exists", 2, p_pred_exists, TestPredFlag | SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$number_of_clauses", 3, p_number_of_clauses, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$undefined", 2, p_undefined, SafePredFlag|TestPredFlag|HiddenPredFlag);
Yap_InitCPred("$optimizer_on", 0, p_optimizer_on, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$clean_up_dead_clauses", 0, p_clean_up_dead_clauses, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$optimizer_off", 0, p_optimizer_off, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$kill_dynamic", 2, p_kill_dynamic, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$new_multifile", 3, p_new_multifile, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$is_multifile", 2, p_is_multifile, TestPredFlag | SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$is_profiled", 1, p_is_profiled, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$profile_info", 3, p_profile_info, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$profile_reset", 2, p_profile_reset, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$is_call_counted", 1, p_is_call_counted, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$call_count_info", 3, p_call_count_info, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$call_count_set", 6, p_call_count_set, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$call_count_reset", 0, p_call_count_reset, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$toggle_static_predicates_in_use", 0, p_toggle_static_predicates_in_use, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$set_pred_module", 2, p_set_pred_module, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$parent_pred", 3, p_parent_pred, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$system_predicate", 2, p_system_pred, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$all_system_predicate", 3, p_all_system_pred, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$hide_predicate", 2, p_hide_predicate, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$hidden_predicate", 2, p_hidden_predicate, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$pred_for_code", 5, p_pred_for_code, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$current_stack", 1, p_current_stack, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$log_update_clause", 4, p_log_update_clause, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$continue_log_update_clause", 5, p_continue_log_update_clause, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$log_update_clause_erase", 4, p_log_update_clause_erase, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$continue_log_update_clause_erase", 5, p_continue_log_update_clause_erase, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$static_clause", 4, p_static_clause, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$continue_static_clause", 5, p_continue_static_clause, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$static_pred_statistics", 5, p_static_pred_statistics, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$p_nth_clause", 4, p_nth_clause, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$program_continuation", 3, p_program_continuation, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$compile", 4, p_compile, SyncPredFlag);
Yap_InitCPred("$compile_dynamic", 5, p_compile_dynamic, SyncPredFlag);
Yap_InitCPred("$purge_clauses", 2, p_purge_clauses, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$in_use", 2, p_in_use, TestPredFlag | SafePredFlag|SyncPredFlag);
Yap_InitCPred("$is_dynamic", 2, p_is_dynamic, TestPredFlag | SafePredFlag);
Yap_InitCPred("$is_metapredicate", 2, p_is_metapredicate, TestPredFlag | SafePredFlag);
Yap_InitCPred("$is_expand_goal_or_meta_predicate", 2, p_is_expandgoalormetapredicate, TestPredFlag | SafePredFlag);
Yap_InitCPred("$is_log_updatable", 2, p_is_log_updatable, TestPredFlag | SafePredFlag);
Yap_InitCPred("$is_source", 2, p_is_source, TestPredFlag | SafePredFlag);
Yap_InitCPred("$owner_file", 3, p_owner_file, SafePredFlag);
Yap_InitCPred("$mk_d", 2, p_mk_d, SafePredFlag);
Yap_InitCPred("$pred_exists", 2, p_pred_exists, TestPredFlag | SafePredFlag);
Yap_InitCPred("$number_of_clauses", 3, p_number_of_clauses, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$undefined", 2, p_undefined, SafePredFlag|TestPredFlag);
Yap_InitCPred("$optimizer_on", 0, p_optimizer_on, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$clean_up_dead_clauses", 0, p_clean_up_dead_clauses, SyncPredFlag);
Yap_InitCPred("$optimizer_off", 0, p_optimizer_off, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$kill_dynamic", 2, p_kill_dynamic, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$new_multifile", 3, p_new_multifile, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$is_multifile", 2, p_is_multifile, TestPredFlag | SafePredFlag);
Yap_InitCPred("$is_profiled", 1, p_is_profiled, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$profile_info", 3, p_profile_info, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$profile_reset", 2, p_profile_reset, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$is_call_counted", 1, p_is_call_counted, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$call_count_info", 3, p_call_count_info, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$call_count_set", 6, p_call_count_set, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$call_count_reset", 0, p_call_count_reset, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$toggle_static_predicates_in_use", 0, p_toggle_static_predicates_in_use, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$set_pred_module", 2, p_set_pred_module, SafePredFlag);
Yap_InitCPred("$parent_pred", 3, p_parent_pred, SafePredFlag);
Yap_InitCPred("$system_predicate", 2, p_system_pred, SafePredFlag);
Yap_InitCPred("$all_system_predicate", 3, p_all_system_pred, SafePredFlag);
Yap_InitCPred("$hide_predicate", 2, p_hide_predicate, SafePredFlag);
Yap_InitCPred("$hidden_predicate", 2, p_hidden_predicate, SafePredFlag);
Yap_InitCPred("$pred_for_code", 5, p_pred_for_code, SyncPredFlag);
Yap_InitCPred("$current_stack", 1, p_current_stack, SyncPredFlag);
Yap_InitCPred("$log_update_clause", 4, p_log_update_clause, SyncPredFlag);
Yap_InitCPred("$continue_log_update_clause", 5, p_continue_log_update_clause, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$log_update_clause_erase", 4, p_log_update_clause_erase, SyncPredFlag);
Yap_InitCPred("$continue_log_update_clause_erase", 5, p_continue_log_update_clause_erase, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$static_clause", 4, p_static_clause, SyncPredFlag);
Yap_InitCPred("$continue_static_clause", 5, p_continue_static_clause, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$static_pred_statistics", 5, p_static_pred_statistics, SyncPredFlag);
Yap_InitCPred("$p_nth_clause", 4, p_nth_clause, SyncPredFlag);
Yap_InitCPred("$program_continuation", 3, p_program_continuation, SafePredFlag|SyncPredFlag);
CurrentModule = HACKS_MODULE;
Yap_InitCPred("current_choicepoints", 1, p_all_choicepoints, HiddenPredFlag);
Yap_InitCPred("current_continuations", 1, p_all_envs, HiddenPredFlag);
Yap_InitCPred("choicepoint", 7, p_choicepoint_info, HiddenPredFlag);
Yap_InitCPred("continuation", 4, p_env_info, HiddenPredFlag);
Yap_InitCPred("cp_to_predicate", 5, p_cpc_info, HiddenPredFlag);
Yap_InitCPred("current_choicepoints", 1, p_all_choicepoints, 0);
Yap_InitCPred("current_continuations", 1, p_all_envs, 0);
Yap_InitCPred("choicepoint", 7, p_choicepoint_info, 0);
Yap_InitCPred("continuation", 4, p_env_info,0);
Yap_InitCPred("cp_to_predicate", 5, p_cpc_info, 0);
CurrentModule = cm;
CurrentModule = DBLOAD_MODULE;
Yap_InitCPred("dbload_get_space", 4, p_dbload_get_space, 0L);

View File

@ -57,6 +57,8 @@ cmp_atoms(Atom a1, Atom a2)
while (*s1 == *s2) {
if (!*s1) return 0;
s1++;
s2++;
}
return *s1-*s2;
}
@ -67,6 +69,8 @@ cmp_atoms(Atom a1, Atom a2)
while (*s1 == *s2) {
if (!*s1) return 0;
s1++;
s2++;
}
return *s1-*s2;
} else {
@ -728,7 +732,7 @@ Yap_InitCmpPreds(void)
Yap_InitCmpPred("=<", 2, a_le, SafePredFlag | BinaryPredFlag);
Yap_InitCmpPred("<", 2, a_lt, SafePredFlag | BinaryPredFlag);
Yap_InitCmpPred(">=", 2, a_ge, SafePredFlag | BinaryPredFlag);
Yap_InitCPred("$a_compare", 3, p_acomp, TestPredFlag | SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$a_compare", 3, p_acomp, TestPredFlag | SafePredFlag);
Yap_InitCmpPred("\\==", 2, a_noteq, BinaryPredFlag | SafePredFlag);
Yap_InitCmpPred("@<", 2, a_gen_lt, BinaryPredFlag | SafePredFlag);
Yap_InitCmpPred("@=<", 2, a_gen_le, BinaryPredFlag | SafePredFlag);

View File

@ -563,12 +563,12 @@ Yap_InitCoroutPreds( void )
WakeUpCode = pred;
#endif
Yap_InitAttVarPreds();
Yap_InitCPred("$yap_has_rational_trees", 0, p_yap_has_rational_trees, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$yap_has_coroutining", 0, p_yap_has_coroutining, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$can_unify", 3, p_can_unify, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$non_ground", 2, p_non_ground, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$coroutining", 0, p_coroutining, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$awoken_goals", 1, p_awoken_goals, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$yap_has_rational_trees", 0, p_yap_has_rational_trees, SafePredFlag);
Yap_InitCPred("$yap_has_coroutining", 0, p_yap_has_coroutining, SafePredFlag);
Yap_InitCPred("$can_unify", 3, p_can_unify, SafePredFlag);
Yap_InitCPred("$non_ground", 2, p_non_ground, SafePredFlag);
Yap_InitCPred("$coroutining", 0, p_coroutining, SafePredFlag);
Yap_InitCPred("$awoken_goals", 1, p_awoken_goals, SafePredFlag);
}

View File

@ -5522,56 +5522,56 @@ Yap_InitDBPreds(void)
Yap_InitCPred("recorded", 3, p_recorded, SyncPredFlag);
Yap_InitCPred("recorda", 3, p_rcda, SyncPredFlag);
Yap_InitCPred("recordz", 3, p_rcdz, SyncPredFlag);
Yap_InitCPred("$still_variant", 2, p_still_variant, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$still_variant", 2, p_still_variant, SyncPredFlag);
Yap_InitCPred("recorda_at", 3, p_rcda_at, SyncPredFlag);
Yap_InitCPred("recordz_at", 3, p_rcdz_at, SyncPredFlag);
Yap_InitCPred("$recordap", 3, p_rcdap, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$recordzp", 3, p_rcdzp, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$recordap", 4, p_drcdap, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$recordzp", 4, p_drcdzp, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$recordap", 3, p_rcdap, SyncPredFlag);
Yap_InitCPred("$recordzp", 3, p_rcdzp, SyncPredFlag);
Yap_InitCPred("$recordap", 4, p_drcdap, SyncPredFlag);
Yap_InitCPred("$recordzp", 4, p_drcdzp, SyncPredFlag);
Yap_InitCPred("erase", 1, p_erase, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$erase_clause", 2, p_erase_clause, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$erase_clause", 2, p_erase_clause, SafePredFlag|SyncPredFlag);
Yap_InitCPred("increase_reference_count", 1, p_increase_reference_counter, SafePredFlag|SyncPredFlag);
Yap_InitCPred("decrease_reference_count", 1, p_decrease_reference_counter, SafePredFlag|SyncPredFlag);
Yap_InitCPred("current_reference_count", 2, p_current_reference_counter, SafePredFlag|SyncPredFlag);
Yap_InitCPred("erased", 1, p_erased, TestPredFlag | SafePredFlag|SyncPredFlag);
Yap_InitCPred("instance", 2, p_instance, SyncPredFlag);
Yap_InitCPred("$instance_module", 2, p_instance_module, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$instance_module", 2, p_instance_module, SyncPredFlag);
Yap_InitCPred("eraseall", 1, p_eraseall, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$record_stat_source", 4, p_rcdstatp, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$some_recordedp", 1, p_somercdedp, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$first_instance", 3, p_first_instance, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$init_db_queue", 1, p_init_queue, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$db_key", 2, p_db_key, HiddenPredFlag);
Yap_InitCPred("$db_enqueue", 2, p_enqueue, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$db_enqueue_unlocked", 2, p_enqueue_unlocked, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$db_dequeue", 2, p_dequeue, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$db_dequeue_unlocked", 2, p_dequeue_unlocked, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$db_peek_queue", 2, p_peek_queue, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$db_clean_queues", 1, p_clean_queues, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$switch_log_upd", 1, p_slu, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$log_upd", 1, p_lu, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$hold_index", 3, p_hold_index, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$fetch_reference_from_index", 3, p_fetch_reference_from_index, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$resize_int_keys", 1, p_resize_int_keys, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$record_stat_source", 4, p_rcdstatp, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$some_recordedp", 1, p_somercdedp, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$first_instance", 3, p_first_instance, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$init_db_queue", 1, p_init_queue, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$db_key", 2, p_db_key, 0L);
Yap_InitCPred("$db_enqueue", 2, p_enqueue, SyncPredFlag);
Yap_InitCPred("$db_enqueue_unlocked", 2, p_enqueue_unlocked, SyncPredFlag);
Yap_InitCPred("$db_dequeue", 2, p_dequeue, SyncPredFlag);
Yap_InitCPred("$db_dequeue_unlocked", 2, p_dequeue_unlocked, SyncPredFlag);
Yap_InitCPred("$db_peek_queue", 2, p_peek_queue, SyncPredFlag);
Yap_InitCPred("$db_clean_queues", 1, p_clean_queues, SyncPredFlag);
Yap_InitCPred("$switch_log_upd", 1, p_slu, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$log_upd", 1, p_lu, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$hold_index", 3, p_hold_index, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$fetch_reference_from_index", 3, p_fetch_reference_from_index, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$resize_int_keys", 1, p_resize_int_keys, SafePredFlag|SyncPredFlag);
Yap_InitCPred("key_statistics", 4, p_key_statistics, SyncPredFlag);
Yap_InitCPred("$lu_statistics", 5, p_lu_statistics, SyncPredFlag);
Yap_InitCPred("total_erased", 4, p_total_erased, SyncPredFlag);
Yap_InitCPred("key_erased_statistics", 5, p_key_erased_statistics, SyncPredFlag);
Yap_InitCPred("heap_space_info", 3, p_heap_space_info, SyncPredFlag);
Yap_InitCPred("$nth_instance", 3, p_nth_instance, SyncPredFlag);
Yap_InitCPred("$nth_instancep", 3, p_nth_instancep, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$jump_to_next_dynamic_clause", 0, p_jump_to_next_dynamic_clause, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$install_thread_local", 2, p_install_thread_local, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$nth_instancep", 3, p_nth_instancep, SyncPredFlag);
Yap_InitCPred("$jump_to_next_dynamic_clause", 0, p_jump_to_next_dynamic_clause, SyncPredFlag);
Yap_InitCPred("$install_thread_local", 2, p_install_thread_local, SafePredFlag);
}
void
Yap_InitBackDB(void)
{
Yap_InitCPredBack("$recorded_with_key", 3, 3, in_rded_with_key, co_rded, SyncPredFlag|HiddenPredFlag);
Yap_InitCPredBack("$recorded_with_key", 3, 3, in_rded_with_key, co_rded, SyncPredFlag);
RETRY_C_RECORDED_K_CODE = NEXTOP(PredRecordedWithKey->cs.p_code.FirstClause,OtapFs);
Yap_InitCPredBack("$recordedp", 3, 3, in_rdedp, co_rdedp, SyncPredFlag|HiddenPredFlag);
Yap_InitCPredBack("$recordedp", 3, 3, in_rdedp, co_rdedp, SyncPredFlag);
RETRY_C_RECORDEDP_CODE = NEXTOP(RepPredProp(PredPropByFunc(Yap_MkFunctor(AtomRecordedP, 3),0))->cs.p_code.FirstClause,OtapFs);
Yap_InitCPredBack("$current_immediate_key", 2, 4, init_current_key, cont_current_key,
SyncPredFlag|HiddenPredFlag);
SyncPredFlag);
}

View File

@ -72,8 +72,8 @@ static Int p_set_depth_limit_for_next_call( USES_REGS1 )
void Yap_InitItDeepenPreds(void)
{
Yap_InitCPred("get_depth_limit", 1, p_get_depth_limit, SafePredFlag);
Yap_InitCPred("$set_depth_limit", 1, p_set_depth_limit, HiddenPredFlag);
Yap_InitCPred("$set_depth_limit_for_next_call", 1, p_set_depth_limit_for_next_call, HiddenPredFlag);
Yap_InitCPred("$set_depth_limit", 1, p_set_depth_limit, 0);
Yap_InitCPred("$set_depth_limit_for_next_call", 1, p_set_depth_limit_for_next_call, 0);
}
#endif

View File

@ -236,7 +236,7 @@ do_execute(Term t, Term mod USES_REGS)
if (a == AtomTrue || a == AtomOtherwise || a == AtomCut)
return(TRUE);
else if (a == AtomFail || a == AtomFalse)
else if (a == AtomFail || (a == AtomFalse && !RepPredProp(PredPropByAtom(a, mod))->ModuleOfPred) )
return(FALSE);
/* call may not define new system predicates!! */
pe = RepPredProp(PredPropByAtom(a, mod));
@ -1789,56 +1789,56 @@ Yap_InitExecFs(void)
CACHE_REGS
Term cm = CurrentModule;
Yap_InitComma();
Yap_InitCPred("$execute", 1, p_execute, HiddenPredFlag);
Yap_InitCPred("$execute", 2, p_execute2, HiddenPredFlag);
Yap_InitCPred("$execute", 3, p_execute3, HiddenPredFlag);
Yap_InitCPred("$execute", 4, p_execute4, HiddenPredFlag);
Yap_InitCPred("$execute", 5, p_execute5, HiddenPredFlag);
Yap_InitCPred("$execute", 6, p_execute6, HiddenPredFlag);
Yap_InitCPred("$execute", 7, p_execute7, HiddenPredFlag);
Yap_InitCPred("$execute", 8, p_execute8, HiddenPredFlag);
Yap_InitCPred("$execute", 9, p_execute9, HiddenPredFlag);
Yap_InitCPred("$execute", 10, p_execute10, HiddenPredFlag);
Yap_InitCPred("$execute", 11, p_execute11, HiddenPredFlag);
Yap_InitCPred("$execute", 12, p_execute12, HiddenPredFlag);
Yap_InitCPred("$execute_in_mod", 2, p_execute_in_mod, HiddenPredFlag);
Yap_InitCPred("$execute_wo_mod", 2, p_execute_in_mod, HiddenPredFlag);
Yap_InitCPred("call_with_args", 1, p_execute_0, HiddenPredFlag);
Yap_InitCPred("call_with_args", 2, p_execute_1, HiddenPredFlag);
Yap_InitCPred("call_with_args", 3, p_execute_2, HiddenPredFlag);
Yap_InitCPred("call_with_args", 4, p_execute_3, HiddenPredFlag);
Yap_InitCPred("call_with_args", 5, p_execute_4, HiddenPredFlag);
Yap_InitCPred("call_with_args", 6, p_execute_5, HiddenPredFlag);
Yap_InitCPred("call_with_args", 7, p_execute_6, HiddenPredFlag);
Yap_InitCPred("call_with_args", 8, p_execute_7, HiddenPredFlag);
Yap_InitCPred("call_with_args", 9, p_execute_8, HiddenPredFlag);
Yap_InitCPred("call_with_args", 10, p_execute_9, HiddenPredFlag);
Yap_InitCPred("call_with_args", 11, p_execute_10, HiddenPredFlag);
Yap_InitCPred("$debug_on", 1, p_debug_on, HiddenPredFlag);
Yap_InitCPred("$execute", 1, p_execute, 0);
Yap_InitCPred("$execute", 2, p_execute2, 0);
Yap_InitCPred("$execute", 3, p_execute3, 0);
Yap_InitCPred("$execute", 4, p_execute4, 0);
Yap_InitCPred("$execute", 5, p_execute5, 0);
Yap_InitCPred("$execute", 6, p_execute6, 0);
Yap_InitCPred("$execute", 7, p_execute7, 0);
Yap_InitCPred("$execute", 8, p_execute8, 0);
Yap_InitCPred("$execute", 9, p_execute9, 0);
Yap_InitCPred("$execute", 10, p_execute10, 0);
Yap_InitCPred("$execute", 11, p_execute11, 0);
Yap_InitCPred("$execute", 12, p_execute12, 0);
Yap_InitCPred("$execute_in_mod", 2, p_execute_in_mod, 0);
Yap_InitCPred("$execute_wo_mod", 2, p_execute_in_mod, 0);
Yap_InitCPred("call_with_args", 1, p_execute_0, 0);
Yap_InitCPred("call_with_args", 2, p_execute_1, 0);
Yap_InitCPred("call_with_args", 3, p_execute_2, 0);
Yap_InitCPred("call_with_args", 4, p_execute_3, 0);
Yap_InitCPred("call_with_args", 5, p_execute_4, 0);
Yap_InitCPred("call_with_args", 6, p_execute_5, 0);
Yap_InitCPred("call_with_args", 7, p_execute_6, 0);
Yap_InitCPred("call_with_args", 8, p_execute_7, 0);
Yap_InitCPred("call_with_args", 9, p_execute_8, 0);
Yap_InitCPred("call_with_args", 10, p_execute_9, 0);
Yap_InitCPred("call_with_args", 11, p_execute_10, 0);
Yap_InitCPred("$debug_on", 1, p_debug_on, 0);
#ifdef DEPTH_LIMIT
Yap_InitCPred("$execute_under_depth_limit", 2, p_execute_depth_limit, HiddenPredFlag);
Yap_InitCPred("$execute_under_depth_limit", 2, p_execute_depth_limit, 0);
#endif
Yap_InitCPred("$execute0", 2, p_execute0, HiddenPredFlag);
Yap_InitCPred("$execute_nonstop", 2, p_execute_nonstop, HiddenPredFlag);
Yap_InitCPred("$execute_clause", 4, p_execute_clause, HiddenPredFlag);
Yap_InitCPred("$execute0", 2, p_execute0, 0);
Yap_InitCPred("$execute_nonstop", 2, p_execute_nonstop, 0);
Yap_InitCPred("$execute_clause", 4, p_execute_clause, 0);
CurrentModule = HACKS_MODULE;
Yap_InitCPred("current_choice_point", 1, p_save_cp, HiddenPredFlag);
Yap_InitCPred("current_choicepoint", 1, p_save_cp, HiddenPredFlag);
Yap_InitCPred("env_choice_point", 1, p_save_env_b, HiddenPredFlag);
Yap_InitCPred("trail_suspension_marker", 1, p_trail_suspension_marker, HiddenPredFlag);
Yap_InitCPred("current_choice_point", 1, p_save_cp, 0);
Yap_InitCPred("current_choicepoint", 1, p_save_cp, 0);
Yap_InitCPred("env_choice_point", 1, p_save_env_b, 0);
Yap_InitCPred("trail_suspension_marker", 1, p_trail_suspension_marker, 0);
Yap_InitCPred("cut_at", 1, p_clean_ifcp, SafePredFlag);
CurrentModule = cm;
Yap_InitCPred("$pred_goal_expansion_on", 0, p_pred_goal_expansion_on, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$restore_regs", 1, p_restore_regs, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$restore_regs", 2, p_restore_regs2, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$clean_ifcp", 1, p_clean_ifcp, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$pred_goal_expansion_on", 0, p_pred_goal_expansion_on, SafePredFlag);
Yap_InitCPred("$restore_regs", 1, p_restore_regs, SafePredFlag);
Yap_InitCPred("$restore_regs", 2, p_restore_regs2, SafePredFlag);
Yap_InitCPred("$clean_ifcp", 1, p_clean_ifcp, SafePredFlag);
Yap_InitCPred("qpack_clean_up_to_disjunction", 0, p_cut_up_to_next_disjunction, SafePredFlag);
Yap_InitCPred("$jump_env_and_store_ball", 1, p_jump_env, HiddenPredFlag);
Yap_InitCPred("$creep_allowed", 0, p_creep_allowed, HiddenPredFlag);
Yap_InitCPred("$generate_pred_info", 4, p_generate_pred_info, HiddenPredFlag);
Yap_InitCPred("$uncaught_throw", 0, p_uncaught_throw, HiddenPredFlag);
Yap_InitCPred("$reset_exception", 1, p_reset_exception, HiddenPredFlag);
Yap_InitCPred("$get_exception", 1, p_get_exception, HiddenPredFlag);
Yap_InitCPred("$jump_env_and_store_ball", 1, p_jump_env, 0);
Yap_InitCPred("$creep_allowed", 0, p_creep_allowed, 0);
Yap_InitCPred("$generate_pred_info", 4, p_generate_pred_info, 0);
Yap_InitCPred("$uncaught_throw", 0, p_uncaught_throw, 0);
Yap_InitCPred("$reset_exception", 1, p_reset_exception, 0);
Yap_InitCPred("$get_exception", 1, p_get_exception, 0);
}

View File

@ -1980,11 +1980,11 @@ Yap_total_stack_shift_time(void)
void
Yap_InitGrowPreds(void)
{
Yap_InitCPred("$grow_heap", 1, p_growheap, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$grow_stack", 1, p_growstack, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$inform_trail_overflows", 2, p_inform_trail_overflows, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$inform_heap_overflows", 2, p_inform_heap_overflows, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$inform_stack_overflows", 2, p_inform_stack_overflows, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$grow_heap", 1, p_growheap, SafePredFlag);
Yap_InitCPred("$grow_stack", 1, p_growstack, SafePredFlag);
Yap_InitCPred("$inform_trail_overflows", 2, p_inform_trail_overflows, SafePredFlag);
Yap_InitCPred("$inform_heap_overflows", 2, p_inform_heap_overflows, SafePredFlag);
Yap_InitCPred("$inform_stack_overflows", 2, p_inform_stack_overflows, SafePredFlag);
Yap_init_gc();
Yap_init_agc();
}

View File

@ -4201,8 +4201,8 @@ p_gc( USES_REGS1 )
void
Yap_init_gc(void)
{
Yap_InitCPred("$gc", 0, p_gc, HiddenPredFlag);
Yap_InitCPred("$inform_gc", 3, p_inform_gc, HiddenPredFlag);
Yap_InitCPred("$gc", 0, p_gc, 0);
Yap_InitCPred("$inform_gc", 3, p_inform_gc, 0);
}
void

View File

@ -6007,6 +6007,9 @@ Yap_RemoveClauseFromIndex(PredEntry *ap, yamop *beg) {
ap->OpcodeOfPred = Yap_opcode(_op_fail);
} else if (ap->PredFlags & IndexedPredFlag) {
remove_from_index(ap, sp, &cl, beg, last, &cint);
} else if (ap->cs.p_code.NOfClauses == 1) {
ap->cs.p_code.TrueCodeOfPred = ap->cs.p_code.FirstClause;
ap->CodeOfPred = (yamop *)(&(ap->OpcodeOfPred));
}
}
@ -6300,9 +6303,9 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
newpc = ipc->u.OtILl.d;
}
#if MULTIPLE_STACKS
DEC_CLREF_COUNT(cl);
B->cp_tr--;
TR--;
DEC_CLREF_COUNT(cl);
/* actually get rid of the code */
if (cl->ClRefCount == 0 && cl->ClFlags & (ErasedMask|DirtyMask)) {
/* I am the last one using this clause, hence I don't need a lock
@ -6311,22 +6314,19 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
*/
LogUpdClause *lcl = ipc->u.OtILl.d;
if (newpc) {
/* I am the last one using this clause, hence I don't need a lock
to dispose of it
*/
/* make sure the clause isn't destroyed */
/* always add an extra reference */
INC_CLREF_COUNT(lcl);
TRAIL_CLREF(lcl);
if (lcl->ClRefCount == 1) {
/* make sure the clause isn't destroyed */
/* always add an extra reference */
INC_CLREF_COUNT(lcl);
TRAIL_CLREF(lcl);
B->cp_tr = TR;
}
}
if (cl->ClFlags & ErasedMask) {
Yap_ErLogUpdIndex(cl);
} else {
Yap_CleanUpIndex(cl);
}
if (newpc) {
DEC_CLREF_COUNT(lcl);
}
}
#else
if (TrailTerm(B->cp_tr-1) == CLREF_TO_TRENTRY(cl) &&

View File

@ -271,13 +271,11 @@ syntax_error (TokEntry * tokptr, IOSTREAM *st, Term *outp)
CELL *Hi = H;
/* make sure to globalise variable */
Yap_unify(*outp, MkVarTerm());
start = tokptr->TokPos;
clean_vars(LOCAL_VarTable);
clean_vars(LOCAL_AnonVarTable);
while (1) {
Term ts[2];
if (H > ASP-1024) {
tf[3] = TermNil;
err = 0;
@ -357,6 +355,8 @@ syntax_error (TokEntry * tokptr, IOSTREAM *st, Term *outp)
}
tokptr = tokptr->TokNext;
}
/* now we can throw away tokens, so we can unify and possibly overwrite TR */
Yap_unify(*outp, MkVarTerm());
if (IsVarTerm(*outp) && (VarOfTerm(*outp) > H || VarOfTerm(*outp) < H0)) {
tf[0] = Yap_MkNewApplTerm(Yap_MkFunctor(AtomRead,1),1);
} else {
@ -1114,24 +1114,24 @@ Yap_InitIOPreds(void)
if (!Stream)
Stream = (StreamDesc *)Yap_AllocCodeSpace(sizeof(StreamDesc)*MaxStreams);
/* here the Input/Output predicates */
Yap_InitCPred ("$set_read_error_handler", 1, p_set_read_error_handler, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$get_read_error_handler", 1, p_get_read_error_handler, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$read", 7, p_read, SyncPredFlag|HiddenPredFlag|UserCPredFlag);
Yap_InitCPred ("$read", 8, p_read2, SyncPredFlag|HiddenPredFlag|UserCPredFlag);
Yap_InitCPred ("$set_read_error_handler", 1, p_set_read_error_handler, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("$get_read_error_handler", 1, p_get_read_error_handler, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("$read", 7, p_read, SyncPredFlag|UserCPredFlag);
Yap_InitCPred ("$read", 8, p_read2, SyncPredFlag|UserCPredFlag);
#if DEBUG
Yap_InitCPred ("write_string", 2, p_write_string, SyncPredFlag|UserCPredFlag);
#endif
Yap_InitCPred ("$start_line", 1, p_startline, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$change_type_of_char", 2, p_change_type_of_char, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$type_of_char", 2, p_type_of_char, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$start_line", 1, p_startline, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("$change_type_of_char", 2, p_change_type_of_char, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("$type_of_char", 2, p_type_of_char, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("char_conversion", 2, p_char_conversion, SyncPredFlag);
Yap_InitCPred ("$current_char_conversion", 2, p_current_char_conversion, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$all_char_conversions", 1, p_all_char_conversions, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$force_char_conversion", 0, p_force_char_conversion, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$disable_char_conversion", 0, p_disable_char_conversion, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$current_char_conversion", 2, p_current_char_conversion, SyncPredFlag);
Yap_InitCPred ("$all_char_conversions", 1, p_all_char_conversions, SyncPredFlag);
Yap_InitCPred ("$force_char_conversion", 0, p_force_char_conversion, SyncPredFlag);
Yap_InitCPred ("$disable_char_conversion", 0, p_disable_char_conversion, SyncPredFlag);
#if HAVE_SELECT
// Yap_InitCPred ("stream_select", 3, p_stream_select, SafePredFlag|SyncPredFlag);
#endif
Yap_InitCPred ("$float_format", 1, p_float_format, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$float_format", 1, p_float_format, SafePredFlag|SyncPredFlag);
}

View File

@ -229,12 +229,12 @@ Yap_InitLoadForeign( void )
Yap_FindExecutable("yap");
else
Yap_FindExecutable(GLOBAL_argv[0]);
Yap_InitCPred("$load_foreign_files", 3, p_load_foreign, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$open_shared_objects", 0, p_open_shared_objects, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$open_shared_object", 3, p_open_shared_object, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$load_foreign_files", 3, p_load_foreign, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$open_shared_objects", 0, p_open_shared_objects, SafePredFlag);
Yap_InitCPred("$open_shared_object", 3, p_open_shared_object, SyncPredFlag);
Yap_InitCPred("close_shared_object", 1, p_close_shared_object, SyncPredFlag|SafePredFlag);
Yap_InitCPred("call_shared_object_function", 2, p_call_shared_object_function, SyncPredFlag);
Yap_InitCPred("$obj_suffix", 1, p_obj_suffix, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$obj_suffix", 1, p_obj_suffix, SafePredFlag);
}
void

View File

@ -301,13 +301,13 @@ Yap_StripModule(Term t, Term *modp)
void
Yap_InitModulesC(void)
{
Yap_InitCPred("$current_module", 2, p_current_module, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$current_module", 1, p_current_module1, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$change_module", 1, p_change_module, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("strip_module", 3, p_strip_module, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$current_module", 2, p_current_module, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$current_module", 1, p_current_module1, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$change_module", 1, p_change_module, SafePredFlag|SyncPredFlag);
Yap_InitCPred("strip_module", 3, p_strip_module, SafePredFlag|SyncPredFlag);
Yap_InitCPred("context_module", 1, p_context_module, 0);
Yap_InitCPredBack("$all_current_modules", 1, 1, init_current_module, cont_current_module,
SafePredFlag|SyncPredFlag|HiddenPredFlag);
SafePredFlag|SyncPredFlag);
}
@ -327,5 +327,6 @@ Yap_InitModules(void)
LookupModule(ARG_MODULE);
LookupModule(GLOBALS_MODULE);
LookupModule(DBLOAD_MODULE);
LookupModule(RANGE_MODULE);
CurrentModule = PROLOG_MODULE;
}

View File

@ -177,9 +177,14 @@ VarNames(VarEntry *p,Term l USES_REGS)
{
if (p != NULL) {
if (strcmp(p->VarRep, "_") != 0) {
Term o = MkPairTerm(MkPairTerm(Yap_StringToList(p->VarRep), p->VarAdr),
VarNames(p->VarRight,
VarNames(p->VarLeft,l PASS_REGS) PASS_REGS));
Term t[2];
Term o;
t[0] = MkAtomTerm(Yap_LookupAtom(p->VarRep));
t[1] = p->VarAdr;
o = Yap_MkApplTerm(FunctorEq, 2, t);
o = MkPairTerm(o, VarNames(p->VarRight,
VarNames(p->VarLeft,l PASS_REGS) PASS_REGS));
if (H > ASP-4096) {
save_machine_regs();
siglongjmp(LOCAL_IOBotch,1);
@ -555,6 +560,10 @@ ParseTerm(int prio, JMPBUFF *FailBuff USES_REGS)
t = MkAtomTerm(Yap_LookupWideAtom(p));
else
t = Yap_WideStringToList(p);
if (t == 0L) {
LOCAL_ErrorMessage = "Stack Overflow";
FAIL;
}
NextToken;
}
break;

View File

@ -845,7 +845,7 @@ Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int
Int l;
Yap_StartSlots( PASS_REGS1 );
l = Yap_InitSlot(t);
l = Yap_InitSlot(t PASS_REGS );
{ IOENC encodings[3];
IOENC *enc;

View File

@ -934,6 +934,9 @@ read_pred(IOSTREAM *stream, Term mod) {
if (flags & MultiFileFlag && ap->ModuleOfPred == PROLOG_MODULE)
ap->ModuleOfPred = TermProlog;
read_clauses(stream, ap, nclauses, flags);
if (flags & HiddenPredFlag) {
Yap_HidePred(ap);
}
}
static void
@ -1054,8 +1057,8 @@ Yap_Restore(char *s, char *lib_dir)
void Yap_InitQLYR(void)
{
Yap_InitCPred("$qload_module_preds", 1, p_read_module_preds, SyncPredFlag|HiddenPredFlag|UserCPredFlag);
Yap_InitCPred("$qload_program", 1, p_read_program, SyncPredFlag|HiddenPredFlag|UserCPredFlag);
Yap_InitCPred("$qload_module_preds", 1, p_read_module_preds, SyncPredFlag|UserCPredFlag);
Yap_InitCPred("$qload_program", 1, p_read_program, SyncPredFlag|UserCPredFlag);
if (FALSE) {
restore_codes();
}

View File

@ -898,8 +898,8 @@ p_save_program( USES_REGS1 )
void Yap_InitQLY(void)
{
Yap_InitCPred("$qsave_module_preds", 2, p_save_module_preds, SyncPredFlag|HiddenPredFlag|UserCPredFlag);
Yap_InitCPred("$qsave_program", 1, p_save_program, SyncPredFlag|HiddenPredFlag|UserCPredFlag);
Yap_InitCPred("$qsave_module_preds", 2, p_save_module_preds, SyncPredFlag|UserCPredFlag);
Yap_InitCPred("$qsave_program", 1, p_save_program, SyncPredFlag|UserCPredFlag);
if (FALSE) {
restore_codes();
}

129
C/range.c Normal file
View File

@ -0,0 +1,129 @@
/*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V. Santos Costa and Universidade do Porto 1985-- *
* *
**************************************************************************
* *
* File: range.c *
* comments: Arithmetic interval computation *
* *
* *
* *
*************************************************************************/
#ifdef SCCS
static char SccsId[] = "%W% %G%";
#endif
#include "Yap.h"
#include "Yatom.h"
#include "YapHeap.h"
#include "eval.h"
static Int
p_in_range( USES_REGS1 ) {
Term t;
double i,j;
double d1;
double d2;
double d3;
t = Deref(ARG1);
if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t);
t = Deref(ARG4);
if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t);
d1 = i-j;
t = Deref(ARG2);
if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t);
t = Deref(ARG5);
if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t);
d2 = i-j;
t = Deref(ARG3);
if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t);
t = Deref(ARG6);
if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t);
d3 = i-j;
t = Deref(ARG7);
if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t);
t = Deref(ARG8);
if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t);
return fabs(sqrt(d1*d1 + d2*d2 + d3*d3)-i) <= j;
}
static Int
p_in_range2( USES_REGS1 ) {
CELL *p1, *p2;
Term t;
double i,j;
double d1;
double d2;
double d3;
UInt arity;
p1 = RepAppl(Deref(ARG1));
arity = ArityOfFunctor((Functor)*p1);
p1 += arity-2;
p2 = RepAppl(Deref(ARG2))+(arity-2);;
t = Deref(p1[0]);
if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t);
t = Deref(p2[0]);
if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t);
d1 = i-j;
t = Deref(p1[1]);
if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t);
t = Deref(p2[1]);
if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t);
d2 = i-j;
t = Deref(p1[2]);
if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t);
t = Deref(p2[2]);
if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t);
d3 = i-j;
t = Deref(ARG3);
if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t);
t = Deref(ARG4);
if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t);
return fabs(sqrt(d1*d1 + d2*d2 + d3*d3)-i) <= j;
}
static Int
p_euc_dist( USES_REGS1 ) {
Term t1 = Deref(ARG1);
Term t2 = Deref(ARG2);
double d1 = (double)(IntegerOfTerm(ArgOfTerm(1,t1))-IntegerOfTerm(ArgOfTerm(1,t2)));
double d2 = (double)(IntegerOfTerm(ArgOfTerm(2,t1))-IntegerOfTerm(ArgOfTerm(2,t2)));
double d3 = (double)(IntegerOfTerm(ArgOfTerm(3,t1))-IntegerOfTerm(ArgOfTerm(3,t2)));
Int result = (Int)sqrt(d1*d1+d2*d2+d3*d3);
return(Yap_unify(ARG3,MkIntegerTerm(result)));
}
#if DEBUG
volatile int loop_counter = 0;
static Int
p_loop( USES_REGS1 ) {
while (loop_counter == 0);
return(TRUE);
}
#endif
void
Yap_InitRange(void)
{
CACHE_REGS
Term cm = CurrentModule;
CurrentModule = RANGE_MODULE;
Yap_InitCPred("euclidean_distance", 3, p_euc_dist, SafePredFlag);
#ifdef DEBUG
Yap_InitCPred("loop", 0, p_loop, SafePredFlag);
#endif
Yap_InitCPred("in_range", 8, p_in_range, TestPredFlag|SafePredFlag);
Yap_InitCPred("in_range", 4, p_in_range2, TestPredFlag|SafePredFlag);
CurrentModule = cm;
}

View File

@ -1843,7 +1843,7 @@ p_restore( USES_REGS1 )
void
Yap_InitSavePreds(void)
{
Yap_InitCPred("$save", 2, p_save2, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$save_program", 1, p_save_program, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$restore", 1, p_restore, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$save", 2, p_save2, SyncPredFlag);
Yap_InitCPred("$save_program", 1, p_save_program, SyncPredFlag);
Yap_InitCPred("$restore", 1, p_restore, SyncPredFlag);
}

View File

@ -836,14 +836,14 @@ ch_to_wide(char *base, char *charp)
}
#define add_ch_to_buff(ch) \
if (wcharp) { *wcharp++ = (ch); charp = (char *)wcharp; } \
if (wcharp) { *wcharp++ = (ch); if (wcharp >= (wchar_t *)AuxSp-1024) goto huge_var_error; charp = (char *)wcharp; } \
else { \
if (ch > MAX_ISO_LATIN1 && !wcharp) { \
/* does not fit in ISO-LATIN */ \
wcharp = ch_to_wide(TokImage, charp); \
if (!wcharp) goto huge_var_error; \
*wcharp++ = (ch); charp = (char *)wcharp; \
} else *charp++ = ch; \
} else { if (charp >= (char *)AuxSp-1024) goto huge_var_error; *charp++ = ch; } \
}
TokEntry *

View File

@ -415,7 +415,7 @@ p_ksort( USES_REGS1 )
void
Yap_InitSortPreds(void)
{
Yap_InitCPred("$sort", 2, p_sort, HiddenPredFlag);
Yap_InitCPred("$msort", 2, p_msort, HiddenPredFlag);
Yap_InitCPred("$keysort", 2, p_ksort, HiddenPredFlag);
Yap_InitCPred("$sort", 2, p_sort, 0);
Yap_InitCPred("$msort", 2, p_msort, 0);
Yap_InitCPred("$keysort", 2, p_ksort, 0);
}

View File

@ -932,6 +932,8 @@ p_name( USES_REGS1 )
Atom at = AtomOfTerm(AtomNameT);
if (IsWideAtom(at)) {
NewT = Yap_WideStringToList((wchar_t *)(RepAtom(at)->StrOfAE));
if (NewT == 0L)
goto expand_global;
return Yap_unify(NewT, ARG2);
} else
String = RepAtom(at)->StrOfAE;
@ -1052,6 +1054,15 @@ p_name( USES_REGS1 )
}
/* error handling */
expand_global:
if (!Yap_gc(2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return(FALSE);
}
AtomNameT = Deref(ARG1);
t = Deref(ARG2);
goto restart_aux;
expand_auxsp:
String = Yap_ExpandPreAllocCodeSpace(0,NULL, TRUE);
if (String + 1024 > (char *)AuxSp) {
@ -1190,6 +1201,8 @@ p_string_to_list( USES_REGS1 )
if (Yap_IsWideStringTerm(t)) {
StringT = Yap_WideStringToList(Yap_BlobWideStringOfTerm(t));
if (StringT == 0L)
goto expand_global;
} else if (Yap_IsStringTerm(t)) {
StringT = Yap_StringToList(Yap_BlobStringOfTerm(t));
} else if (IsAtomTerm(t)) {
@ -1198,6 +1211,8 @@ p_string_to_list( USES_REGS1 )
StringT = Yap_WideStringToList(RepAtom(at)->WStrOfAE);
else
StringT = Yap_StringToList(RepAtom(at)->StrOfAE);
if (StringT == 0L)
goto expand_global;
} else if (IsIntTerm(t)) {
char *String = Yap_PreAllocCodeSpace();
if (String + 1024 > (char *)AuxSp)
@ -1309,6 +1324,15 @@ p_string_to_list( USES_REGS1 )
return(FALSE);
/* error handling */
expand_global:
if (!Yap_gc(2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return(FALSE);
}
NameT = Deref(ARG1);
t = Deref(ARG2);
goto restart_aux;
expand_auxsp:
String = Yap_ExpandPreAllocCodeSpace(0,NULL, TRUE);
if (String + 1024 > (char *)AuxSp) {
@ -1344,6 +1368,8 @@ p_atom_chars( USES_REGS1 )
} else {
NewT = Yap_WideStringToListOfAtoms((wchar_t *)RepAtom(AtomOfTerm(t1))->StrOfAE);
}
if (NewT == 0L)
goto expand_global;
} else {
if (yap_flags[YAP_TO_CHARS_FLAG] == QUINTUS_TO_CHARS) {
NewT = Yap_StringToList(RepAtom(at)->StrOfAE);
@ -1514,6 +1540,14 @@ p_atom_chars( USES_REGS1 )
return Yap_unify_constant(ARG1, MkAtomTerm(at));
}
/* error handling */
expand_global:
if (!Yap_gc(2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return(FALSE);
}
t1 = Deref(ARG1);
goto restart_aux;
expand_auxsp:
String = Yap_ExpandPreAllocCodeSpace(0,NULL, TRUE);
if (String + 1024 > (char *)AuxSp) {
@ -1919,6 +1953,8 @@ p_atom_codes( USES_REGS1 )
} else {
NewT = Yap_StringToList(Yap_BlobStringOfTerm(t1));
}
if (NewT == 0L)
goto expand_global;
} else if (!IsAtomTerm(t1)) {
Yap_Error(TYPE_ERROR_ATOM, t1, "atom_codes/2");
return(FALSE);
@ -1929,6 +1965,8 @@ p_atom_codes( USES_REGS1 )
} else {
NewT = Yap_StringToList(RepAtom(at)->StrOfAE);
}
if (NewT == 0L)
goto expand_global;
}
return (Yap_unify(NewT, ARG2));
} else {
@ -2001,7 +2039,15 @@ p_atom_codes( USES_REGS1 )
}
}
/* error handling */
expand_auxsp:
expand_global:
if (!Yap_gc(2, ENV, gc_P(P,CP))) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, LOCAL_ErrorMessage);
return(FALSE);
}
t1 = Deref(ARG1);
goto restart_pred;
expand_auxsp:
if (String + 1024 > (char *)AuxSp) {
String = Yap_ExpandPreAllocCodeSpace(0,NULL, TRUE);
@ -3205,6 +3251,8 @@ cont_current_predicate( USES_REGS1 )
Arity = ArityOfFunctor(f);
}
}
if (pp->PredFlags & HiddenPredFlag)
return FALSE;
return
Yap_unify(ARG2,name) &&
Yap_unify(ARG3, MkIntegerTerm((Int)Arity));
@ -3265,6 +3313,8 @@ cont_current_predicate_for_atom( USES_REGS1 )
} else if (pp->KindOfPE == PEProp) {
PredEntry *pe = RepPredProp(pf);
PELOCK(31,pe);
if (pe->PredFlags & HiddenPredFlag)
return FALSE;
if (pe->ModuleOfPred == mod ||
pe->ModuleOfPred == 0) {
/* we found the predicate */
@ -4263,77 +4313,6 @@ p_loop( USES_REGS1 ) {
}
#endif
#if QSAR
static Int
p_in_range( USES_REGS1 ) {
Term t;
double i,j;
double d1;
double d2;
double d3;
t = Deref(ARG1);
if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t);
t = Deref(ARG4);
if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t);
d1 = i-j;
t = Deref(ARG2);
if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t);
t = Deref(ARG5);
if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t);
d2 = i-j;
t = Deref(ARG3);
if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t);
t = Deref(ARG6);
if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t);
d3 = i-j;
t = Deref(ARG7);
if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t);
t = Deref(ARG8);
if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t);
return fabs(sqrt(d1*d1 + d2*d2 + d3*d3)-i) <= j;
}
static Int
p_in_range2( USES_REGS1 ) {
CELL *p1, *p2;
Term t;
double i,j;
double d1;
double d2;
double d3;
UInt arity;
p1 = RepAppl(Deref(ARG1));
arity = ArityOfFunctor((Functor)*p1);
p1 += arity-2;
p2 = RepAppl(Deref(ARG2))+(arity-2);;
t = Deref(p1[0]);
if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t);
t = Deref(p2[0]);
if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t);
d1 = i-j;
t = Deref(p1[1]);
if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t);
t = Deref(p2[1]);
if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t);
d2 = i-j;
t = Deref(p1[2]);
if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t);
t = Deref(p2[2]);
if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t);
d3 = i-j;
t = Deref(ARG3);
if (IsFloatTerm(t)) i = FloatOfTerm(t); else i = IntegerOfTerm(t);
t = Deref(ARG4);
if (IsFloatTerm(t)) j = FloatOfTerm(t); else j = IntegerOfTerm(t);
return fabs(sqrt(d1*d1 + d2*d2 + d3*d3)-i) <= j;
}
#endif
static Int
p_max_tagged_integer( USES_REGS1 ) {
@ -4349,19 +4328,19 @@ void
Yap_InitBackCPreds(void)
{
Yap_InitCPredBack("$current_atom", 1, 2, init_current_atom, cont_current_atom,
SafePredFlag|SyncPredFlag|HiddenPredFlag);
SafePredFlag|SyncPredFlag);
Yap_InitCPredBack("$current_wide_atom", 1, 2, init_current_wide_atom,
cont_current_wide_atom,
SafePredFlag|SyncPredFlag|HiddenPredFlag);
SafePredFlag|SyncPredFlag);
Yap_InitCPredBack("$current_predicate", 3, 1, init_current_predicate, cont_current_predicate,
SafePredFlag|SyncPredFlag|HiddenPredFlag);
SafePredFlag|SyncPredFlag);
Yap_InitCPredBack("$current_predicate_for_atom", 3, 1, init_current_predicate_for_atom, cont_current_predicate_for_atom,
SafePredFlag|SyncPredFlag|HiddenPredFlag);
SafePredFlag|SyncPredFlag);
Yap_InitCPredBack("$current_op", 5, 1, init_current_op, cont_current_op,
SafePredFlag|SyncPredFlag);
Yap_InitCPredBack("$current_atom_op", 5, 1, init_current_atom_op, cont_current_atom_op,
SafePredFlag|SyncPredFlag);
Yap_InitCPredBack("$sub_atom_fetch", 5, 5, init_sub_atom_fetch, cont_sub_atom_fetch, HiddenPredFlag);
Yap_InitCPredBack("$sub_atom_fetch", 5, 5, init_sub_atom_fetch, cont_sub_atom_fetch, 0);
#ifdef BEAM
Yap_InitCPredBack("eam", 1, 0, start_eam, cont_eam,
SafePredFlag);
@ -4406,9 +4385,9 @@ Yap_InitCPreds(void)
/* numerical comparison */
Yap_InitCPred("set_value", 2, p_setval, SafePredFlag|SyncPredFlag);
Yap_InitCPred("get_value", 2, p_value, TestPredFlag|SafePredFlag|SyncPredFlag);
Yap_InitCPred("$values", 3, p_values, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$values", 3, p_values, SafePredFlag|SyncPredFlag);
/* general purpose */
Yap_InitCPred("$opdec", 4, p_opdec, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$opdec", 4, p_opdec, SafePredFlag|SyncPredFlag);
Yap_InitCPred("name", 2, p_name, 0);
Yap_InitCPred("string_to_atom", 2, p_string_to_atom, 0);
Yap_InitCPred("string_to_list", 2, p_string_to_list, 0);
@ -4416,8 +4395,8 @@ Yap_InitCPreds(void)
Yap_InitCPred("atom_chars", 2, p_atom_chars, 0);
Yap_InitCPred("atom_codes", 2, p_atom_codes, 0);
Yap_InitCPred("atom_length", 2, p_atom_length, SafePredFlag);
Yap_InitCPred("$atom_split", 4, p_atom_split, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$sub_atom_extract", 5, p_sub_atom_extract, HiddenPredFlag);
Yap_InitCPred("$atom_split", 4, p_atom_split, SafePredFlag);
Yap_InitCPred("$sub_atom_extract", 5, p_sub_atom_extract, 0);
Yap_InitCPred("number_chars", 2, p_number_chars, 0);
Yap_InitCPred("number_atom", 2, p_number_atom, 0);
Yap_InitCPred("number_codes", 2, p_number_codes, 0);
@ -4425,28 +4404,28 @@ Yap_InitCPreds(void)
Yap_InitCPred("atom_concat", 2, p_atom_concat, 0);
Yap_InitCPred("atomic_concat", 2, p_atomic_concat, 0);
Yap_InitCPred("=..", 2, p_univ, 0);
Yap_InitCPred("$statistics_trail_max", 1, p_statistics_trail_max, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$statistics_heap_max", 1, p_statistics_heap_max, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$statistics_global_max", 1, p_statistics_global_max, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$statistics_local_max", 1, p_statistics_local_max, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$statistics_heap_info", 2, p_statistics_heap_info, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$statistics_stacks_info", 3, p_statistics_stacks_info, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$statistics_trail_info", 2, p_statistics_trail_info, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$statistics_atom_info", 2, p_statistics_atom_info, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$statistics_db_size", 4, p_statistics_db_size, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$statistics_lu_db_size", 5, p_statistics_lu_db_size, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$argv", 1, p_argv, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$executable", 1, p_executable, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$runtime", 2, p_runtime, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$cputime", 2, p_cputime, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$systime", 2, p_systime, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$walltime", 2, p_walltime, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$access_yap_flags", 2, p_access_yap_flags, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$set_yap_flags", 2, p_set_yap_flags, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$p_system_mode", 1, p_system_mode, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$statistics_trail_max", 1, p_statistics_trail_max, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$statistics_heap_max", 1, p_statistics_heap_max, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$statistics_global_max", 1, p_statistics_global_max, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$statistics_local_max", 1, p_statistics_local_max, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$statistics_heap_info", 2, p_statistics_heap_info, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$statistics_stacks_info", 3, p_statistics_stacks_info, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$statistics_trail_info", 2, p_statistics_trail_info, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$statistics_atom_info", 2, p_statistics_atom_info, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$statistics_db_size", 4, p_statistics_db_size, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$statistics_lu_db_size", 5, p_statistics_lu_db_size, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$argv", 1, p_argv, SafePredFlag);
Yap_InitCPred("$executable", 1, p_executable, SafePredFlag);
Yap_InitCPred("$runtime", 2, p_runtime, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$cputime", 2, p_cputime, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$systime", 2, p_systime, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$walltime", 2, p_walltime, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$access_yap_flags", 2, p_access_yap_flags, SafePredFlag);
Yap_InitCPred("$set_yap_flags", 2, p_set_yap_flags, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$p_system_mode", 1, p_system_mode, SafePredFlag|SyncPredFlag);
Yap_InitCPred("abort", 0, p_abort, SyncPredFlag);
Yap_InitCPred("$max_tagged_integer", 1, p_max_tagged_integer, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$min_tagged_integer", 1, p_min_tagged_integer, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$max_tagged_integer", 1, p_max_tagged_integer, SafePredFlag);
Yap_InitCPred("$min_tagged_integer", 1, p_min_tagged_integer, SafePredFlag);
#ifdef BEAM
Yap_InitCPred("@", 0, eager_split, SafePredFlag);
Yap_InitCPred(":", 0, force_wait, SafePredFlag);
@ -4456,33 +4435,33 @@ Yap_InitCPreds(void)
Yap_InitCPred("eamtime", 0, show_time, SafePredFlag);
Yap_InitCPred("eam", 0, use_eam, SafePredFlag);
#endif
Yap_InitCPred("$halt", 1, p_halt, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$lock_system", 0, p_lock_system, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$unlock_system", 0, p_unlock_system, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$enter_undefp", 0, p_enterundefp, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$exit_undefp", 0, p_exitundefp, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$halt", 1, p_halt, SyncPredFlag);
Yap_InitCPred("$lock_system", 0, p_lock_system, SafePredFlag);
Yap_InitCPred("$unlock_system", 0, p_unlock_system, SafePredFlag);
Yap_InitCPred("$enter_undefp", 0, p_enterundefp, SafePredFlag);
Yap_InitCPred("$exit_undefp", 0, p_exitundefp, SafePredFlag);
/* basic predicates for the prolog machine tracer */
/* they are defined in analyst.c */
/* Basic predicates for the debugger */
Yap_InitCPred("$creep", 0, p_creep, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$signal_creep", 0, p_signal_creep, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$disable_creep", 0, p_disable_creep, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$disable_docreep", 0, p_disable_docreep, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$do_not_creep", 0, p_stop_creep, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$creep", 0, p_creep, SafePredFlag);
Yap_InitCPred("$signal_creep", 0, p_signal_creep, SafePredFlag);
Yap_InitCPred("$disable_creep", 0, p_disable_creep, SafePredFlag);
Yap_InitCPred("$disable_docreep", 0, p_disable_docreep, SafePredFlag);
Yap_InitCPred("$do_not_creep", 0, p_stop_creep, SafePredFlag|SyncPredFlag);
#ifdef DEBUG
Yap_InitCPred("$debug", 1, p_debug, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$debug", 1, p_debug, SafePredFlag|SyncPredFlag);
#endif
/* Accessing and changing the flags for a predicate */
Yap_InitCPred("$flags", 4, p_flags, SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$flags", 4, p_flags, SyncPredFlag);
/* hiding and unhiding some predicates */
Yap_InitCPred("hide", 1, p_hide, SafePredFlag|SyncPredFlag);
Yap_InitCPred("unhide", 1, p_unhide, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$hidden", 1, p_hidden, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$has_yap_or", 0, p_has_yap_or, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$has_eam", 0, p_has_eam, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$hidden", 1, p_hidden, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$has_yap_or", 0, p_has_yap_or, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$has_eam", 0, p_has_eam, SafePredFlag|SyncPredFlag);
#ifndef YAPOR
Yap_InitCPred("parallel_mode", 1, p_parallel_mode, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$c_yapor_workers", 1, p_yapor_workers, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$c_yapor_workers", 1, p_yapor_workers, SafePredFlag|SyncPredFlag);
#endif /* YAPOR */
#ifdef INES
Yap_InitCPred("euc_dist", 3, p_euc_dist, SafePredFlag);
@ -4510,6 +4489,7 @@ Yap_InitCPreds(void)
Yap_InitLoadForeign();
Yap_InitModulesC();
Yap_InitSavePreds();
Yap_InitRange();
Yap_InitSysPreds();
Yap_InitUnify();
Yap_InitQLY();

View File

@ -3226,18 +3226,18 @@ Yap_InitSysPreds(void)
InitLastWtime();
Yap_InitCPred ("srandom", 1, p_srandom, SafePredFlag);
Yap_InitCPred ("sh", 0, p_sh, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("$shell", 1, p_shell, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$shell", 1, p_shell, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("system", 1, p_system, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("rename", 2, p_mv, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("$yap_home", 1, p_yap_home, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$dir_separator", 1, p_dir_sp, SafePredFlag|HiddenPredFlag);
Yap_InitCPred ("$alarm", 4, p_alarm, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$getenv", 2, p_getenv, SafePredFlag|HiddenPredFlag);
Yap_InitCPred ("$putenv", 2, p_putenv, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$set_fpu_exceptions", 0, p_set_fpu_exceptions, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$first_signal", 1, p_first_signal, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$host_type", 1, p_host_type, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$continue_signals", 0, p_continue_signals, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("$yap_home", 1, p_yap_home, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("$dir_separator", 1, p_dir_sp, SafePredFlag);
Yap_InitCPred ("$alarm", 4, p_alarm, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("$getenv", 2, p_getenv, SafePredFlag);
Yap_InitCPred ("$putenv", 2, p_putenv, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("$set_fpu_exceptions", 0, p_set_fpu_exceptions, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("$first_signal", 1, p_first_signal, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("$host_type", 1, p_host_type, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("$continue_signals", 0, p_continue_signals, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("$env_separator", 1, p_env_separator, SafePredFlag);
Yap_InitCPred ("$unix", 0, p_unix, SafePredFlag);
Yap_InitCPred ("$win32", 0, p_win32, SafePredFlag);
@ -3247,7 +3247,7 @@ Yap_InitSysPreds(void)
Yap_InitCPred ("win_registry_get_value", 3, p_win_registry_get_value,0);
#endif
CurrentModule = HACKS_MODULE;
Yap_InitCPred ("virtual_alarm", 4, p_virtual_alarm, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred ("virtual_alarm", 4, p_virtual_alarm, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("enable_interrupts", 0, p_enable_interrupts, SafePredFlag);
Yap_InitCPred ("disable_interrupts", 0, p_disable_interrupts, SafePredFlag);
CurrentModule = OPERATING_SYSTEM_MODULE;

View File

@ -62,15 +62,15 @@ allocate_new_tid(void)
if (new_worker_id >= MAX_THREADS) {
new_worker_id = -1;
} else if (!Yap_local[new_worker_id]) {
DEBUG_TLOCK_ACCESS(new_worker_id, 0);
if (!Yap_InitThread(new_worker_id)) {
return -1;
}
pthread_mutex_lock(&(REMOTE_ThreadHandle(new_worker_id).tlock));
DEBUG_TLOCK_ACCESS(new_worker_id, 0);
REMOTE_ThreadHandle(new_worker_id).in_use = TRUE;
} else if (new_worker_id < MAX_THREADS) {
DEBUG_TLOCK_ACCESS(new_worker_id, 0);
pthread_mutex_lock(&(REMOTE_ThreadHandle(new_worker_id).tlock));
DEBUG_TLOCK_ACCESS(new_worker_id, 0);
REMOTE_ThreadHandle(new_worker_id).in_use = TRUE;
} else {
new_worker_id = -1;
@ -406,8 +406,8 @@ p_thread_zombie_self( USES_REGS1 )
/* make sure the lock is available */
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
return Yap_unify(MkIntegerTerm(-1), ARG1);
DEBUG_TLOCK_ACCESS(4, worker_id);
pthread_mutex_lock(&(LOCAL_ThreadHandle.tlock));
DEBUG_TLOCK_ACCESS(4, worker_id);
if (LOCAL_ActiveSignals &= YAP_ITI_SIGNAL) {
DEBUG_TLOCK_ACCESS(5, worker_id);
pthread_mutex_unlock(&(LOCAL_ThreadHandle.tlock));
@ -498,9 +498,9 @@ Yap_thread_attach_engine(int wid)
pthread_mutex_lock(&(REMOTE_ThreadHandle(wid).tlock));
*/
if (REMOTE_ThreadHandle(wid).ref_count ) {
DEBUG_TLOCK_ACCESS(8, wid);
REMOTE_ThreadHandle(wid).ref_count++;
REMOTE_ThreadHandle(wid).pthread_handle = pthread_self();
DEBUG_TLOCK_ACCESS(8, wid);
pthread_mutex_unlock(&(REMOTE_ThreadHandle(wid).tlock));
return TRUE;
}
@ -516,8 +516,8 @@ Yap_thread_attach_engine(int wid)
Int
Yap_thread_detach_engine(int wid)
{
DEBUG_TLOCK_ACCESS(10, wid);
pthread_mutex_lock(&(REMOTE_ThreadHandle(wid).tlock));
DEBUG_TLOCK_ACCESS(10, wid);
//REMOTE_ThreadHandle(wid).pthread_handle = 0;
REMOTE_ThreadHandle(wid).ref_count--;
pthread_setspecific(Yap_yaamregs_key, NULL);
@ -529,8 +529,8 @@ Yap_thread_detach_engine(int wid)
Int
Yap_thread_destroy_engine(int wid)
{
DEBUG_TLOCK_ACCESS(10, wid);
pthread_mutex_lock(&(REMOTE_ThreadHandle(wid).tlock));
DEBUG_TLOCK_ACCESS(10, wid);
if (REMOTE_ThreadHandle(wid).ref_count == 0) {
kill_thread_engine(wid, TRUE);
return TRUE;
@ -949,41 +949,41 @@ p_thread_unlock( USES_REGS1 )
void Yap_InitThreadPreds(void)
{
Yap_InitCPred("$no_threads", 0, p_no_threads, HiddenPredFlag);
Yap_InitCPred("$max_workers", 1, p_max_workers, HiddenPredFlag);
Yap_InitCPred("$max_threads", 1, p_max_threads, HiddenPredFlag);
Yap_InitCPred("$thread_new_tid", 1, p_thread_new_tid, HiddenPredFlag);
Yap_InitCPred("$create_thread", 7, p_create_thread, HiddenPredFlag);
Yap_InitCPred("$thread_self", 1, p_thread_self, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$thread_status_lock", 1, p_thread_status_lock, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$thread_status_unlock", 1, p_thread_status_unlock, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$thread_zombie_self", 1, p_thread_zombie_self, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$thread_join", 1, p_thread_join, HiddenPredFlag);
Yap_InitCPred("$thread_destroy", 1, p_thread_destroy, HiddenPredFlag);
Yap_InitCPred("$no_threads", 0, p_no_threads, 0);
Yap_InitCPred("$max_workers", 1, p_max_workers, 0);
Yap_InitCPred("$max_threads", 1, p_max_threads, 0);
Yap_InitCPred("$thread_new_tid", 1, p_thread_new_tid, 0);
Yap_InitCPred("$create_thread", 7, p_create_thread, 0);
Yap_InitCPred("$thread_self", 1, p_thread_self, SafePredFlag);
Yap_InitCPred("$thread_status_lock", 1, p_thread_status_lock, SafePredFlag);
Yap_InitCPred("$thread_status_unlock", 1, p_thread_status_unlock, SafePredFlag);
Yap_InitCPred("$thread_zombie_self", 1, p_thread_zombie_self, SafePredFlag);
Yap_InitCPred("$thread_join", 1, p_thread_join, 0);
Yap_InitCPred("$thread_destroy", 1, p_thread_destroy, 0);
Yap_InitCPred("thread_yield", 0, p_thread_yield, 0);
Yap_InitCPred("$detach_thread", 1, p_thread_detach, HiddenPredFlag);
Yap_InitCPred("$thread_detached", 1, p_thread_detached, HiddenPredFlag);
Yap_InitCPred("$thread_detached", 2, p_thread_detached2, HiddenPredFlag);
Yap_InitCPred("$thread_exit", 0, p_thread_exit, HiddenPredFlag);
Yap_InitCPred("$detach_thread", 1, p_thread_detach, 0);
Yap_InitCPred("$thread_detached", 1, p_thread_detached, 0);
Yap_InitCPred("$thread_detached", 2, p_thread_detached2, 0);
Yap_InitCPred("$thread_exit", 0, p_thread_exit, 0);
Yap_InitCPred("thread_setconcurrency", 2, p_thread_set_concurrency, 0);
Yap_InitCPred("$valid_thread", 1, p_valid_thread, HiddenPredFlag);
Yap_InitCPred("$new_mutex", 1, p_new_mutex, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$destroy_mutex", 1, p_destroy_mutex, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$lock_mutex", 1, p_lock_mutex, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$trylock_mutex", 1, p_trylock_mutex, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$unlock_mutex", 1, p_unlock_mutex, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$mutex_info", 3, p_mutex_info, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$cond_create", 1, p_cond_create, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$cond_destroy", 1, p_cond_destroy, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$cond_signal", 1, p_cond_signal, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$cond_broadcast", 1, p_cond_broadcast, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$cond_wait", 2, p_cond_wait, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$thread_stacks", 4, p_thread_stacks, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$signal_thread", 1, p_thread_signal, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$nof_threads", 1, p_nof_threads, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$nof_threads_created", 1, p_nof_threads_created, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$thread_sleep", 4, p_thread_sleep, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$thread_runtime", 1, p_thread_runtime, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$valid_thread", 1, p_valid_thread, 0);
Yap_InitCPred("$new_mutex", 1, p_new_mutex, SafePredFlag);
Yap_InitCPred("$destroy_mutex", 1, p_destroy_mutex, SafePredFlag);
Yap_InitCPred("$lock_mutex", 1, p_lock_mutex, SafePredFlag);
Yap_InitCPred("$trylock_mutex", 1, p_trylock_mutex, SafePredFlag);
Yap_InitCPred("$unlock_mutex", 1, p_unlock_mutex, SafePredFlag);
Yap_InitCPred("$mutex_info", 3, p_mutex_info, SafePredFlag);
Yap_InitCPred("$cond_create", 1, p_cond_create, SafePredFlag);
Yap_InitCPred("$cond_destroy", 1, p_cond_destroy, SafePredFlag);
Yap_InitCPred("$cond_signal", 1, p_cond_signal, SafePredFlag);
Yap_InitCPred("$cond_broadcast", 1, p_cond_broadcast, SafePredFlag);
Yap_InitCPred("$cond_wait", 2, p_cond_wait, SafePredFlag);
Yap_InitCPred("$thread_stacks", 4, p_thread_stacks, SafePredFlag);
Yap_InitCPred("$signal_thread", 1, p_thread_signal, SafePredFlag);
Yap_InitCPred("$nof_threads", 1, p_nof_threads, SafePredFlag);
Yap_InitCPred("$nof_threads_created", 1, p_nof_threads_created, SafePredFlag);
Yap_InitCPred("$thread_sleep", 4, p_thread_sleep, SafePredFlag);
Yap_InitCPred("$thread_runtime", 1, p_thread_runtime, SafePredFlag);
Yap_InitCPred("$thread_self_lock", 1, p_thread_self_lock, SafePredFlag);
Yap_InitCPred("$thread_run_at_exit", 2, p_thread_atexit, SafePredFlag);
Yap_InitCPred("$thread_unlock", 1, p_thread_unlock, SafePredFlag);
@ -1047,14 +1047,14 @@ p_max_workers(void)
void Yap_InitThreadPreds(void)
{
Yap_InitCPred("$max_workers", 1, p_max_workers, HiddenPredFlag);
Yap_InitCPred("$thread_self", 1, p_thread_self, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$no_threads", 0, p_no_threads, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$max_threads", 1, p_max_threads, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$nof_threads", 1, p_nof_threads, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$nof_threads_created", 1, p_nof_threads_created, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$thread_stacks", 4, p_thread_stacks, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$thread_runtime", 1, p_thread_runtime, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$max_workers", 1, p_max_workers, 0);
Yap_InitCPred("$thread_self", 1, p_thread_self, SafePredFlag);
Yap_InitCPred("$no_threads", 0, p_no_threads, SafePredFlag);
Yap_InitCPred("$max_threads", 1, p_max_threads, SafePredFlag);
Yap_InitCPred("$nof_threads", 1, p_nof_threads, SafePredFlag);
Yap_InitCPred("$nof_threads_created", 1, p_nof_threads_created, SafePredFlag);
Yap_InitCPred("$thread_stacks", 4, p_thread_stacks, SafePredFlag);
Yap_InitCPred("$thread_runtime", 1, p_thread_runtime, SafePredFlag);
Yap_InitCPred("$thread_unlock", 1, p_thread_unlock, SafePredFlag);
}

View File

@ -5195,8 +5195,8 @@ void Yap_InitUtilCPreds(void)
Yap_InitCPred("duplicate_term", 2, p_duplicate_term, 0);
Yap_InitCPred("copy_term_nat", 2, p_copy_term_no_delays, 0);
Yap_InitCPred("ground", 1, p_ground, SafePredFlag);
Yap_InitCPred("$variables_in_term", 3, p_variables_in_term, HiddenPredFlag);
Yap_InitCPred("$non_singletons_in_term", 3, p_non_singletons_in_term, HiddenPredFlag);
Yap_InitCPred("$variables_in_term", 3, p_variables_in_term, 0);
Yap_InitCPred("$non_singletons_in_term", 3, p_non_singletons_in_term, 0);
Yap_InitCPred("term_variables", 2, p_term_variables, 0);
Yap_InitCPred("term_variables", 3, p_term_variables3, 0);
Yap_InitCPred("term_attvars", 2, p_term_attvars, 0);
@ -5224,7 +5224,7 @@ void Yap_InitUtilCPreds(void)
Yap_InitCPred("import_term", 2, p_import_term, 0);
CurrentModule = cm;
#ifdef DEBUG
Yap_InitCPred("$force_trail_expansion", 1, p_force_trail_expansion, SafePredFlag|HiddenPredFlag);
Yap_InitCPred("$force_trail_expansion", 1, p_force_trail_expansion, SafePredFlag);
Yap_InitCPred("dum", 1, camacho_dum, SafePredFlag);
#endif
}

View File

@ -137,6 +137,7 @@ void STD_PROTO(Yap_BuildMegaClause,(struct pred_entry *));
void STD_PROTO(Yap_EraseMegaClause,(yamop *,struct pred_entry *));
void STD_PROTO(Yap_ResetConsultStack,(void));
void STD_PROTO(Yap_AssertzClause,(struct pred_entry *, yamop *));
void Yap_HidePred(struct pred_entry *pe);
/* cmppreds.c */
@ -319,6 +320,9 @@ void STD_PROTO(Yap_InitQLY,(void));
int STD_PROTO(Yap_Restore,(char *, char *));
void STD_PROTO(Yap_InitQLYR,(void));
/* range.c */
void Yap_InitRange(void);
/* save.c */
int STD_PROTO(Yap_SavedInfo,(char *,char *,CELL *,CELL *,CELL *));
int STD_PROTO(Yap_SavedStateRestore,(char *, char *));

View File

@ -99,6 +99,9 @@
#define GLOBALS_MODULE Yap_heap_regs->globals_module
#define SWI_MODULE Yap_heap_regs->swi_module
#define DBLOAD_MODULE Yap_heap_regs->dbload_module
#define RANGE_MODULE Yap_heap_regs->range_module
#define HIDDEN_PREDICATES Yap_heap_regs->hidden_predicates

View File

@ -99,6 +99,9 @@
Term globals_module;
Term swi_module;
Term dbload_module;
Term range_module;
Prop hidden_predicates;

View File

@ -225,6 +225,7 @@
AtomQuiet = Yap_LookupAtom("quiet");
AtomRadix = Yap_LookupAtom("radix");
AtomRandom = Yap_LookupAtom("random");
AtomRange = Yap_LookupAtom("range");
AtomRead = Yap_LookupAtom("read");
AtomReadutil = Yap_LookupAtom("readutil");
AtomRecordedP = Yap_FullLookupAtom("$recordep");
@ -383,6 +384,7 @@
FunctorGPrimitive = Yap_MkFunctor(AtomPrimitive,1);
FunctorGVar = Yap_MkFunctor(AtomGVar,1);
FunctorGeneratePredInfo = Yap_MkFunctor(AtomGeneratePredInfo,4);
FunctorGoalExpansion2 = Yap_MkFunctor(AtomGoalExpansion,2);
FunctorGoalExpansion = Yap_MkFunctor(AtomGoalExpansion,3);
FunctorHandleThrow = Yap_MkFunctor(AtomHandleThrow,3);
FunctorId = Yap_MkFunctor(AtomId,1);

View File

@ -99,6 +99,9 @@
GLOBALS_MODULE = MkAtomTerm(AtomNb);
SWI_MODULE = MkAtomTerm(AtomSwi);
DBLOAD_MODULE = MkAtomTerm(AtomDBLoad);
RANGE_MODULE = MkAtomTerm(AtomRange);
HIDDEN_PREDICATES = NULL;

View File

@ -200,6 +200,18 @@ typedef uintptr_t PL_atomic_t; /* same a word */
#define TRAIL_OVERFLOW (-3)
#define ARGUMENT_OVERFLOW (-4)
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Foreign language interface definitions. Note that these macros MUST be
consistent with the definitions in pl-itf.h, which is included with
users foreign language code.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#define NOTRACE PL_FA_NOTRACE
#define META PL_FA_TRANSPARENT
#define NDET PL_FA_NONDETERMINISTIC
#define VA PL_FA_VARARGS
#define CREF PL_FA_CREF
#define ISO PL_FA_ISO
/********************************
* THREADS *

View File

@ -225,6 +225,7 @@
AtomQuiet = AtomAdjust(AtomQuiet);
AtomRadix = AtomAdjust(AtomRadix);
AtomRandom = AtomAdjust(AtomRandom);
AtomRange = AtomAdjust(AtomRange);
AtomRead = AtomAdjust(AtomRead);
AtomReadutil = AtomAdjust(AtomReadutil);
AtomRecordedP = AtomAdjust(AtomRecordedP);
@ -383,6 +384,7 @@
FunctorGPrimitive = FuncAdjust(FunctorGPrimitive);
FunctorGVar = FuncAdjust(FunctorGVar);
FunctorGeneratePredInfo = FuncAdjust(FunctorGeneratePredInfo);
FunctorGoalExpansion2 = FuncAdjust(FunctorGoalExpansion2);
FunctorGoalExpansion = FuncAdjust(FunctorGoalExpansion);
FunctorHandleThrow = FuncAdjust(FunctorHandleThrow);
FunctorId = FuncAdjust(FunctorId);

View File

@ -253,6 +253,7 @@ static char SccsId[] = "@(#)rheap.c 1.3 3/15/90";
#define RestoreSWIBlobTypes() RestoreSWIBlobTypes__( PASS_REGS1 )
#define RestoreInvisibleAtoms() RestoreInvisibleAtoms__( PASS_REGS1 )
#define RestorePredHash() RestorePredHash__( PASS_REGS1 )
#define RestoreHiddenPredicates() RestoreHiddenPredicates__( PASS_REGS1 )
#define RestoreDBTermsList() RestoreDBTermsList__( PASS_REGS1 )
#define RestoreExpandList() RestoreExpandList__( PASS_REGS1 )
#define RestoreIntKeys() RestoreIntKeys__( PASS_REGS1 )
@ -726,6 +727,14 @@ RestoreSWIBlobs__( USES_REGS1 )
RestoreAtomList(SWI_Blobs PASS_REGS);
}
static void
RestoreHiddenPredicates__( USES_REGS1 )
{
HIDDEN_PREDICATES = PropAdjust(HIDDEN_PREDICATES);
RestoreEntries(HIDDEN_PREDICATES, TRUE PASS_REGS);
}
static void
RestorePredHash__( USES_REGS1 )
{

View File

@ -99,6 +99,9 @@
GLOBALS_MODULE = AtomTermAdjust(GLOBALS_MODULE);
SWI_MODULE = AtomTermAdjust(SWI_MODULE);
DBLOAD_MODULE = AtomTermAdjust(DBLOAD_MODULE);
RANGE_MODULE = AtomTermAdjust(RANGE_MODULE);
RestoreHiddenPredicates();

View File

@ -448,6 +448,8 @@
#define AtomRadix Yap_heap_regs->AtomRadix_
Atom AtomRandom_;
#define AtomRandom Yap_heap_regs->AtomRandom_
Atom AtomRange_;
#define AtomRange Yap_heap_regs->AtomRange_
Atom AtomRead_;
#define AtomRead Yap_heap_regs->AtomRead_
Atom AtomReadutil_;
@ -764,6 +766,8 @@
#define FunctorGVar Yap_heap_regs->FunctorGVar_
Functor FunctorGeneratePredInfo_;
#define FunctorGeneratePredInfo Yap_heap_regs->FunctorGeneratePredInfo_
Functor FunctorGoalExpansion2_;
#define FunctorGoalExpansion2 Yap_heap_regs->FunctorGoalExpansion2_
Functor FunctorGoalExpansion_;
#define FunctorGoalExpansion Yap_heap_regs->FunctorGoalExpansion_
Functor FunctorHandleThrow_;

View File

@ -40,7 +40,7 @@ STATIC_PROTO(Int c_db_tl_readline,(void));
void Yap_InitMYDDAS_TopLevelPreds(void)
{
/* c_db_readline: +Prompt x -Line */
Yap_InitCPred("c_db_tl_readline", 2, c_db_tl_readline, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("c_db_tl_readline", 2, c_db_tl_readline, SafePredFlag|SyncPredFlag);
}

View File

@ -256,6 +256,7 @@ C_SOURCES= \
$(srcdir)/C/parser.c \
$(srcdir)/C/qlyr.c \
$(srcdir)/C/qlyw.c \
$(srcdir)/C/range.c \
$(srcdir)/C/save.c $(srcdir)/C/scanner.c \
$(srcdir)/C/sort.c $(srcdir)/C/stdpreds.c $(srcdir)/C/sysbits.c \
$(srcdir)/C/threads.c \
@ -366,7 +367,8 @@ ENGINE_OBJECTS = \
myddas_mysql.o myddas_odbc.o myddas_shared.o myddas_initialization.o \
myddas_util.o myddas_statistics.o myddas_top_level.o \
myddas_wkb2prolog.o modules.o other.o \
parser.o qlyr.o qlyw.o save.o scanner.o sort.o stdpreds.o \
parser.o qlyr.o qlyw.o range.o \
save.o scanner.o sort.o stdpreds.o \
sysbits.o threads.o tracer.o \
udi.o rtree.o rtree_udi.o\
unify.o userpreds.o utilpreds.o \
@ -715,6 +717,7 @@ all: startup.yss
@ENABLE_CLPBN_BP@ (cd packages/CLPBN/horus; $(MAKE))
@ENABLE_MINISAT@ (cd packages/swi-minisat2/C; $(MAKE))
@ENABLE_LIBARCHIVE@ @INSTALL_DLLS@ (cd packages/archive; $(MAKE))
@ENABLE_ODBC@ @INSTALL_DLLS@ (cd packages/odbc; $(MAKE))
@ENABLE_ZLIB@ @INSTALL_DLLS@ (cd packages/zlib; $(MAKE))
@ENABLE_CPLINT@ (cd packages/cplint/approx/simplecuddLPADs; $(MAKE))
@ENABLE_CPLINT@ (cd packages/cplint; $(MAKE))
@ -724,6 +727,7 @@ all: startup.yss
@ENABLE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE))
@ENABLE_CUDD@ (cd packages/ProbLog/simplecudd_lfi; $(MAKE))
@ENABLE_JPL@ @INSTALL_DLLS@ (cd packages/jpl; $(MAKE))
@ENABLE_PYTHON@ @INSTALL_DLLS@ (cd packages/python; $(MAKE))
startup.yss: yap@EXEC_SUFFIX@ $(PL_SOURCES)
-rm -f startup.yss
@ -787,12 +791,14 @@ install_unix: startup.yss libYap.a
@ENABLE_SGML@ @INSTALL_DLLS@ (cd packages/sgml; $(MAKE) install)
@ENABLE_ZLIB@ @INSTALL_DLLS@ (cd packages/zlib; $(MAKE) @ZLIB_INSTALL@)
@ENABLE_LIBARCHIVE@ @INSTALL_DLLS@ (cd packages/archive; $(MAKE) install)
@ENABLE_ODBC@ @INSTALL_DLLS@ (cd packages/odbc; $(MAKE) install)
@ENABLE_CLPBN_BP@ @INSTALL_DLLS@ (cd packages/CLPBN/horus; $(MAKE) install)
@ENABLE_MINISAT@ (cd packages/swi-minisat2/C; $(MAKE) install)
@INSTALL_MATLAB@ (cd library/matlab; $(MAKE) install)
@ENABLE_REAL@ (cd packages/real; $(MAKE) install)
@ENABLE_JPL@ @INSTALL_DLLS@ (cd packages/jpl; $(MAKE) install)
#@ENABLE_JPL@ @INSTALL_DLLS@ (cd packages/pyswip; $(MAKE) install)
@ENABLE_PYTHON@ @INSTALL_DLLS@ (cd packages/python; $(MAKE) install)
#@ENABLE_JPL@ @INSTALL_DLLS@ (cd packages/python; $(MAKE) install)
mkdir -p $(DESTDIR)$(INCLUDEDIR)
mkdir -p $(DESTDIR)$(INCLUDEDIR)/src
$(INSTALL) $(HEADERS) $(DESTDIR)$(INCLUDEDIR)/src
@ -857,6 +863,7 @@ install_win32: startup.yss @ENABLE_WINCONSOLE@ yap-win@EXEC_SUFFIX@
(cd packages/CLPBN ; $(MAKE) install)
@ENABLE_CLPBN_BP@ (cd packages/CLPBN/horus; $(MAKE) install)
@ENABLE_JPL@ (cd packages/jpl ; $(MAKE) install)
@ENABLE_PYTHON@ (cd packages/python ; $(MAKE) install)
@ENABLE_MINISAT@ (cd packages/swi-minisat2/C; $(MAKE) install)
@ENABLE_CPLINT@ (cd packages/cplint; $(MAKE) install)
@ENABLE_PRISM@ (cd packages/prism/src/c; $(MAKE) install)
@ -928,9 +935,12 @@ clean: clean_docs
@ENABLE_CPLINT@ (cd packages/cplint/approx/simplecuddLPADs; $(MAKE) clean)
@ENABLE_CPLINT@ (cd packages/cplint; $(MAKE) clean)
@ENABLE_BDDLIB@ (cd packages/bdd; $(MAKE) clean)
@ENABLE_LIBARCHIVE@ (cd packages/archive; $(MAKE) clean)
@ENABLE_ODBC@ (cd packages/odbc; $(MAKE) clean)
@ENABLE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE) clean)
@ENABLE_CUDD@ (cd packages/ProbLog/simplecudd_lfi; $(MAKE) clean)
@ENABLE_JPL@ @INSTALL_DLLS@ (cd packages/jpl; $(MAKE) clean)
@ENABLE_PYTHON@ @INSTALL_DLLS@ (cd packages/python; $(MAKE) clean)

View File

@ -204,31 +204,31 @@ void Yap_init_optyap_preds(void) {
Yap_InitCPred("wake_choice_point", 1, p_wake_choice_point, SafePredFlag|SyncPredFlag);
Yap_InitCPred("abolish_frozen_choice_points", 1, p_abolish_frozen_choice_points_until, SafePredFlag|SyncPredFlag);
Yap_InitCPred("abolish_frozen_choice_points", 0, p_abolish_frozen_choice_points_all, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$c_table", 3, p_table, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$c_tabling_mode", 3, p_tabling_mode, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$c_abolish_table", 2, p_abolish_table, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$c_table", 3, p_table, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$c_tabling_mode", 3, p_tabling_mode, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$c_abolish_table", 2, p_abolish_table, SafePredFlag|SyncPredFlag);
Yap_InitCPred("abolish_all_tables", 0, p_abolish_all_tables, SafePredFlag|SyncPredFlag);
Yap_InitCPred("show_tabled_predicates", 1, p_show_tabled_predicates, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$c_show_table", 3, p_show_table, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$c_show_table", 3, p_show_table, SafePredFlag|SyncPredFlag);
Yap_InitCPred("show_all_tables", 1, p_show_all_tables, SafePredFlag|SyncPredFlag);
Yap_InitCPred("show_global_trie", 1, p_show_global_trie, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$c_table_statistics", 3, p_show_statistics_table, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$c_table_statistics", 3, p_show_statistics_table, SafePredFlag|SyncPredFlag);
Yap_InitCPred("tabling_statistics", 1, p_show_statistics_tabling, SafePredFlag|SyncPredFlag);
Yap_InitCPred("global_trie_statistics", 1, p_show_statistics_global_trie, SafePredFlag|SyncPredFlag);
#endif /* TABLING */
#ifdef YAPOR
Yap_InitCPred("parallel_mode", 1, p_parallel_mode, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$c_yapor_start", 0, p_yapor_start, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$c_yapor_workers", 1, p_yapor_workers, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$c_worker", 0, p_worker, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$c_parallel_new_answer", 1, p_parallel_new_answer, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$c_parallel_get_answers", 1, p_parallel_get_answers, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$c_yapor_start", 0, p_yapor_start, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$c_yapor_workers", 1, p_yapor_workers, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$c_worker", 0, p_worker, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$c_parallel_new_answer", 1, p_parallel_new_answer, SafePredFlag|SyncPredFlag);
Yap_InitCPred("$c_parallel_get_answers", 1, p_parallel_get_answers, SafePredFlag|SyncPredFlag);
Yap_InitCPred("or_statistics", 1, p_show_statistics_or, SafePredFlag|SyncPredFlag);
#endif /* YAPOR */
#if defined(YAPOR) && defined(TABLING)
Yap_InitCPred("opt_statistics", 1, p_show_statistics_opt, SafePredFlag|SyncPredFlag);
#endif /* YAPOR && TABLING */
Yap_InitCPred("$c_get_optyap_statistics", 3, p_get_optyap_statistics, SafePredFlag|SyncPredFlag|HiddenPredFlag);
Yap_InitCPred("$c_get_optyap_statistics", 3, p_get_optyap_statistics, SafePredFlag|SyncPredFlag);
}

View File

@ -1,112 +0,0 @@
/*************************************************************************
* *
* YAP Prolog %W% %G%
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: Atoms.h.m4 *
* Last rev: 19/2/88 *
* mods: *
* comments: atom properties header file for YAP *
* *
*************************************************************************/
#undef EXTERN
#ifndef ADTDEFS_C
#define EXTERN static
#else
#define EXTERN
#endif
/********* operations for atoms ****************************************/
/* Atoms are assumed to be uniquely represented by an OFFSET and to have
associated with them a struct of type AtomEntry
The two functions
RepAtom : Atom -> *AtomEntry
AbsAtom : *AtomEntry -> Atom
are used to encapsulate the implementation of atoms
*/
typedef struct AtomEntryStruct *Atom;
typedef struct PropEntryStruct *Prop;
/* I can only define the structure after I define the actual atoms */
/* atom structure */
typedef struct AtomEntryStruct {
Atom NextOfAE; /* used to build hash chains */
Prop PropsOfAE; /* property list for this atom */
#if defined(YAPOR) || defined(THREADS)
rwlock_t ARWLock;
#endif
char StrOfAE[MIN_ARRAY]; /* representation of atom as a string */
}
AtomEntry;
/* Props and Atoms are stored in chains, ending with a NIL */
#if USE_OFFSETS
# define EndOfPAEntr(P) ( Addr(P) == AtomBase)
#else
# define EndOfPAEntr(P) ( Addr(P) == NIL )
#endif
#define AtomName(at) RepAtom(at)->StrOfAE
/* ********************** Properties **********************************/
#if USE_OFFSETS
#define USE_OFFSETS_IN_PROPS 1
#else
#define USE_OFFSETS_IN_PROPS 0
#endif
typedef SFLAGS PropFlags;
/* basic property entry structure */
typedef struct PropEntryStruct {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
} PropEntry;
/* ************************* Functors **********************************/
/* Functor data type
abstype Functor = atom # int
with MkFunctor(a,n) = ...
and NameOfFunctor(f) = ...
and ArityOfFunctor(f) = ... */
#define MaxArity 255
#define FunctorProperty ((PropFlags)(0xbb00))
/* functor property */
typedef struct FunctorEntryStruct {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
unsigned int ArityOfFE; /* arity of functor */
Atom NameOfFE; /* back pointer to owner atom */
Prop PropsOfFE; /* pointer to list of properties for this functor */
#if defined(YAPOR) || defined(THREADS)
rwlock_t FRWLock;
#endif
} FunctorEntry;
typedef FunctorEntry *Functor;

View File

@ -1,177 +0,0 @@
/*************************************************************************
* *
* YAP Prolog %W% %G% *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: Tags_24bits.h.m4 *
* Last rev: December 90 *
* mods: *
* comments: Tag Scheme for machines with 24 bits adresses (m68000) *
* version: $Id: Tags_24bits.h,v 1.9 2002-06-01 04:29:01 vsc Exp $ *
*************************************************************************/
/* Version for 24 bit addresses (68000)
Each term is represented internally as an unsigned 32 bit integer as
follows:
tag value
ints 1m1000 numeric value
floats 1m1001 floating point value
pairs 1mr10. ptr to pair
aplied functor 1mr01. ptr to functor followed by args
ref 0mr000 address of cell
undefined 0mr000 pointing to itself
*/
#define AllTagBits 0xfc000000L
#define TagBits 0xbc000000L
#define MaskAdr 0x03ffffffL
#define AdrHiBit 0x02000000L
#define NumberTag 0xa0000000L
#define FloatTag 0xa4000000L
#define AtomTag 0x84000000L
#define PairTag 0x90000000L
#define ApplTag 0x88000000L
#define RefTag 0x80000000L
#define MaskBits 6
#define PairBit 0x10000000L
#define ApplBit 0x08000000L
#define CompBits 0x18000000L
#define NumberMask 0xb8000000L
#define MAX_ABS_INT /* 0xfe00000LL */ ((((UInt)(1<<7))-1) << SHIFT_HIGH_TAG)
#define NonTagPart(X) (Signed(X) & MaskAdr)
#define TAGGEDA(TAG,V) (TAG | Unsigned(V))
#define TAGGED(TAG,V) (TAG | NonTagPart(Unsigned(V)))
#define NONTAGGED(TAG,V) NonTagPart(Unsigned(V))
#define BitOn(Bit,V) (Bit & Unsigned(V))
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
/* bits that should not be used by anyone but us */
#define YAP_PROTECTED_MASK 0x00000000L
inline EXTERN int IsVarTerm(Term);
inline EXTERN int IsVarTerm(Term t)
{
return (int) (Signed(t) >= 0);
}
inline EXTERN int IsNonVarTerm(Term);
inline EXTERN int IsNonVarTerm(Term t)
{
return (int) (Signed(t) < 0);
}
inline EXTERN Term * RepPair(Term);
inline EXTERN Term * RepPair(Term t)
{
return (Term *) (NonTagPart(t));
}
inline EXTERN Term AbsPair(Term *);
inline EXTERN Term AbsPair(Term * p)
{
return (Term) (TAGGEDA(PairTag, (p)));
}
inline EXTERN Int IsPairTerm(Term);
inline EXTERN Int IsPairTerm(Term t)
{
return (Int) (BitOn(PairBit, (t)));
}
inline EXTERN Term * RepAppl(Term);
inline EXTERN Term * RepAppl(Term t)
{
return (Term *) (NonTagPart(t));
}
inline EXTERN Term AbsAppl(Term *);
inline EXTERN Term AbsAppl(Term * p)
{
return (Term) (TAGGEDA(ApplTag, (p)));
}
inline EXTERN Int IsApplTerm(Term);
inline EXTERN Int IsApplTerm(Term t)
{
return (Int) (BitOn(ApplBit, (t)));
}
inline EXTERN Int IsAtomOrIntTerm(Term);
inline EXTERN Int IsAtomOrIntTerm(Term t)
{
return (Int) (!(Unsigned(t) & CompBits));
}
inline EXTERN Term AdjustPtr(Term t, Term off);
inline EXTERN Term AdjustPtr(Term t, Term off)
{
return (Term) ((t)+off);
}
inline EXTERN Term AdjustIDBPtr(Term t, Term off);
inline EXTERN Term AdjustIDBPtr(Term t, Term off)
{
return (Term) ((t)+off);
}
static inline Int
IntOfTerm(Term t)
{
Int n;
n = (Unsigned(t) & MaskPrim) >> 2;
if (Unsigned(t) & AdrHiBit)
n |= 0xfc000000;
return (n);
}

View File

@ -1,194 +0,0 @@
/*************************************************************************
* *
* YAP Prolog %W% %G% *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: Tags_32LowTag.h.m4 *
* Last rev: December 90 *
* mods: *
* comments: Original Tag Scheme for machines with 32 bits adresses *
* version: $Id: Tags_32LowTag.h,v 1.9 2002-06-01 04:29:01 vsc Exp $ *
*************************************************************************/
#define TAG_LOW_BITS_32 1
/* Version for 32 bit addresses machines,
Each term is represented internally as an unsigned 32 bit integer as
follows:
tag value
ints m.....110 numeric value
atoms m.....010 offset of atom entry
pairs mr.....11 ptr to pair
aplied functor mr.....01 ptr to functor followed by args
ref mr.....00 address of cell
undefined mr.....00 address of cell pointing to itself
functors are represented as ptrs to the functor entry in the atom
property list
*/
#define SHIFT_LOW_TAG 2
#define SHIFT_HIGH_TAG 2
#define MKTAG(HI,LO) ((((UInt) (HI))<<SHIFT_HIGH_TAG)|(LO))
#define TagBits /* 0x00000007L */ MKTAG(0x1,3)
#define LowTagBits /* 0x00000003L */ MKTAG(0x0,3)
#define LowBit /* 0x00000001L */ MKTAG(0x0,1)
#define HighTagBits /* 0x0000000cL */ MKTAG(0x1,0)
#define NumberTag /* 0x0000000dL */ MKTAG(0x1,2)
#define AtomTag /* 0x00000006L */ MKTAG(0x0,2)
/*
subtract the total for tag bits, plus 1 bit for GC, plus another
for sign
*/
#define MAX_ABS_INT ((Int)0x04000000L)
/*
UNIQUE_TAG_FOR_PAIR gives the representation for pair an
unique tag
This allows optimisation of switch_list
*/
#define UNIQUE_TAG_FOR_PAIRS 1
#define PairBits /* 0x00000003L */ MKTAG(0x0,3)
#define ApplBit /* 0x00000001L */ MKTAG(0x0,1)
#define PrimiBits /* 0x00000002L */ MKTAG(0x0,2)
#define NumberBits /* 0x0000000aL */ MKTAG(0x2,2)
#define NumberMask /* 0x0000000bL */ MKTAG(0x2,3)
#define NonTagPart(V) ((Unsigned(V)>>1) & ~LowTagBits)
#define TAGGED(TAG,V) (((Unsigned(V)<<(SHIFT_HIGH_TAG+SHIFT_LOW_TAG+1))>>1)|(TAG))
#define NONTAGGED(TAG,V) ((Unsigned(V)<<(SHIFT_HIGH_TAG+SHIFT_LOW_TAG+1))>>1)
#define TAGGEDA(TAG,V) ((Unsigned(V) << 1)|(TAG))
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
/* bits that should not be used by anyone but us */
#define YAP_PROTECTED_MASK 0xc0000000L
inline EXTERN int IsVarTerm(Term);
inline EXTERN int IsVarTerm(Term t)
{
return (int) (!((t) & LowTagBits));
}
inline EXTERN int IsNonVarTerm(Term);
inline EXTERN int IsNonVarTerm(Term t)
{
return (int) (((t) & LowTagBits));
}
inline EXTERN Term * RepPair(Term);
inline EXTERN Term * RepPair(Term t)
{
return (Term *) ((t)-PairBits);
}
inline EXTERN Term AbsPair(Term *);
inline EXTERN Term AbsPair(Term * p)
{
return (Term) (Unsigned(p)+PairBits);
}
inline EXTERN Int IsPairTerm(Term);
inline EXTERN Int IsPairTerm(Term t)
{
return (Int) ((((t) & LowTagBits) == PairBits));
}
inline EXTERN Term * RepAppl(Term);
inline EXTERN Term * RepAppl(Term t)
{
return (Term *) (((t)-ApplBit));
}
inline EXTERN Term AbsAppl(Term *);
inline EXTERN Term AbsAppl(Term * p)
{
return (Term) (Unsigned(p)+ApplBit);
}
inline EXTERN Int IsApplTerm(Term);
inline EXTERN Int IsApplTerm(Term t)
{
return (Int) ((((t) & LowTagBits) == ApplBit));
}
inline EXTERN Int IsAtomOrIntTerm(Term);
inline EXTERN Int IsAtomOrIntTerm(Term t)
{
return (Int) ((((t) & LowTagBits) == 2));
}
inline EXTERN Term AdjustPtr(Term t, Term off);
inline EXTERN Term AdjustPtr(Term t, Term off)
{
return (Term) ((t)+off);
}
inline EXTERN Term AdjustIDBPtr(Term t, Term off);
inline EXTERN Term AdjustIDBPtr(Term t, Term off)
{
return (Term) ((t)+off);
}
inline EXTERN Int IntOfTerm(Term);
inline EXTERN Int IntOfTerm(Term t)
{
return (Int) (((Int)(t << 1))>>(SHIFT_LOW_TAG+SHIFT_HIGH_TAG+1));
}

View File

@ -1,290 +0,0 @@
/*************************************************************************
* *
* YAP Prolog %W% %G% *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: Tags_32Ops.h.m4 *
* Last rev: December 90 *
* mods: *
* comments: Original Tag Scheme for machines with 32 bits adresses *
* version: $Id: Tags_32Ops.h,v 1.9 2002-06-01 04:29:01 vsc Exp $ *
*************************************************************************/
/*
Version for 32 bit addresses machines,
Each term is represented internally as an unsigned 32 bit integer as
follows:
tag value
ints 1m1....01 numeric value
atoms 1m0....01 offset of atom entry
pairs 1mr....11 ptr to pair
aplied functor 1mr....00 ptr to functor followed by args
undefined 0mr....00 address of cell pointing to itself
functors are represented as ptrs to the functor entry in the atom
property list
This version speeds up access to lists and to compound
terms by using the XOR and NOT operations to build their tags. This
saves operations on RISC machines.
As a further optimisation, only pairs or compound terms have
the second lowest bit set. This allows one to recognise lists or
compound terms with a single operation.
The main problem is that the default value of the M and R bits for GC
are now 1 in compound terms and structures.
*/
#define TAGS_FAST_OPS 1
#define SHIFT_HIGH_TAG 29
#define MKTAG(HI,LO) ((((UInt) (HI))<<SHIFT_HIGH_TAG)|(LO))
#define TagBits /* 0xb0000003L */ MKTAG(0x5,3)
#define LowTagBits /* 0x00000003L */ MKTAG(0x0,3)
#define LowBit /* 0x00000001L */ MKTAG(0x0,1)
#define HighTagBits /* 0xf0000000L */ MKTAG(0x7,0)
#define AdrHiBit /* 0x08000000L */ (((UInt)1) << (SHIFT_HIGH_TAG-1))
#define MaskAdr /* 0x1ffffffcL */ ((((UInt)1) << (SHIFT_HIGH_TAG))-4)
#define MaskPrim /* 0x0ffffffcL */ ((((UInt)1) << (SHIFT_HIGH_TAG))-4)
#define NumberTag /* 0xb0000001L */ MKTAG(0x5,2)
#define AtomTag /* 0x90000001L */ MKTAG(0x4,2)
#define MAX_ABS_INT /* 0xfe00000LL */ ((Int)0x04000000L)
/* bits that should not be used by anyone but us */
#define YAP_PROTECTED_MASK 0xe0000000L
#define MaskBits 4
/*
UNIQUE_TAG_FOR_PAIR gives the representation for pair an
unique tag
This allows optimisation of switch_list
*/
#if defined(i386) || defined(sparc) || defined(_POWER) || defined(__sparc)
#define UNIQUE_TAG_FOR_PAIRS 1
#endif
#if UNIQUE_TAG_FOR_PAIRS
#define PairBit /* 0x00000001L */ 1
#define ApplBit /* 0x00000000L */ 0
#else
#define PairBit /* 0x00000000L */ 0
#define ApplBit /* 0x00000001L */ 1
#endif
#define NonTagPart(X) (Signed(X) & MaskPrim)
#define TAGGEDA(TAG,V) (TAG | Unsigned(V))
#define TAGGED(TAG,V) (TAG | NonTagPart(Unsigned(V)<<2))
#define NONTAGGED(TAG,V) NonTagPart(Unsigned(V)<<2)
#define BitOn(Bit,V) (Bit & Unsigned(V))
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
/* never forget to surround arguments to a macro by brackets */
inline EXTERN int IsVarTerm(Term);
inline EXTERN int IsVarTerm(Term t)
{
return (int) (Signed(t) >= 0);
}
inline EXTERN int IsNonVarTerm(Term);
inline EXTERN int IsNonVarTerm(Term t)
{
return (int) (Signed(t) < 0);
}
#if UNIQUE_TAG_FOR_PAIRS
inline EXTERN Term * RepPair(Term);
inline EXTERN Term * RepPair(Term t)
{
return (Term *) ((~(t)));
}
inline EXTERN Term AbsPair(Term *);
inline EXTERN Term AbsPair(Term * p)
{
return (Term) ((~Unsigned(p)));
}
inline EXTERN Int IsPairTerm(Term);
inline EXTERN Int IsPairTerm(Term t)
{
return (Int) (((t) & PairBit));
}
inline EXTERN Term * RepAppl(Term);
inline EXTERN Term * RepAppl(Term t)
{
return (Term *) ((-Signed(t)));
}
inline EXTERN Term AbsAppl(Term *);
inline EXTERN Term AbsAppl(Term * p)
{
return (Term) ((-Signed(p)));
}
inline EXTERN Int IsApplTerm(Term);
inline EXTERN Int IsApplTerm(Term t)
{
return (Int) ((!((t) & LowTagBits)));
}
#else
inline EXTERN Term * RepPair(Term);
inline EXTERN Term * RepPair(Term t)
{
return (Term *) ((-Signed(t)));
}
inline EXTERN Term AbsPair(Term *);
inline EXTERN Term AbsPair(Term * p)
{
return (Term) (((CELL)(-Signed(p))));
}
inline EXTERN Int IsPairTerm(Term);
inline EXTERN Int IsPairTerm(Term t)
{
return (Int) ((!((t) & LowTagBits)));
}
inline EXTERN Term * RepAppl(Term);
inline EXTERN Term * RepAppl(Term t)
{
return (Term *) ((~(t)));
}
inline EXTERN Term AbsAppl(Term *);
inline EXTERN Term AbsAppl(Term * p)
{
return (Term) ((~Unsigned(p)));
}
inline EXTERN Int IsApplTerm(Term);
inline EXTERN Int IsApplTerm(Term t)
{
return (Int) (((t) & ApplBit));
}
#endif
inline EXTERN Int IsAtomOrIntTerm(Term);
inline EXTERN Int IsAtomOrIntTerm(Term t)
{
return (Int) (((Unsigned(t) & LowTagBits) == 0x2));
}
inline EXTERN Int IntOfTerm(Term);
inline EXTERN Int IntOfTerm(Term t)
{
return (Int) ((Int)(Unsigned(t) << 3) >> 5);
}
#if UNIQUE_TAG_FOR_PAIRS
inline EXTERN Term AdjustPtr(Term t, Term off);
inline EXTERN Term AdjustPtr(Term t, Term off)
{
return (Term) (((IsVarTerm(t) || IsAtomOrIntTerm(t)) ? (t)+(off) : (IsPairTerm(t) ? (CELL)AbsPair((CELL *)((CELL)RepPair(t)+(off))) : (t)-(off))));
}
inline EXTERN Term AdjustIDBPtr(Term t, Term off);
inline EXTERN Term AdjustIDBPtr(Term t, Term off)
{
return (Term) (IsVarTerm(t) ? (t)+(off) : (t)-(off));
}
#else
inline EXTERN Term AdjustPtr(Term t, Term off);
inline EXTERN Term AdjustPtr(Term t, Term off)
{
return (Term) (((IsVarTerm(t) || IsAtomOrIntTerm(t)) ? (t)+(off) : (IsApplTerm(t) ? (CELL)AbsAppl((CELL *)((CELL)RepAppl(t)+(off))) : (t)-(off))));
}
inline EXTERN Term AdjustIDBPtr(Term t, Term off);
inline EXTERN Term AdjustIDBPtr(Term t, Term off)
{
return (Term) (IsVarTerm(t) ? (t)+(off) : (IsApplTerm(t) ? (CELL)AbsAppl((CELL *)((CELL)RepAppl(t)+(off))) : (t)-(off)));
}
#endif

View File

@ -1,182 +0,0 @@
/*************************************************************************
* *
* YAP Prolog %W% %G% *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: Tags_32bits.h.m4 *
* Last rev: December 90 *
* mods: *
* comments: Original Tag Scheme for machines with 32 bits adresses *
* version: $Id: Tags_32bits.h,v 1.9 2002-06-01 04:29:01 vsc Exp $ *
*************************************************************************/
/* Original version for 32 bit addresses machines,
Each term is represented internally as an unsigned 32 bit integer as
follows:
tag value
ints 1m1....00 numeric value
atoms 1m0....00 offset of atom entry
pairs 1mr....01 ptr to pair
aplied functor 1mr....10 ptr to functor followed by args
ref 0mr....00 address of cell
undefined 0mr....00 address of cell pointing to itself
functors are represented as ptrs to the functor entry in the atom
property list
*/
#define SHIFT_HIGH_TAG 29
#define MKTAG(HI,LO) ((((UInt) (HI))<<SHIFT_HIGH_TAG)|(LO))
#define TagBits /* 0xe0000003L */ MKTAG(0x7,3)
#define LowTagBits /* 0x00000003L */ MKTAG(0x0,3)
#define HighTagBits /* 0xe0000000L */ MKTAG(0x7,0)
#define AdrHiBit /* 0x10000000L */ (((UInt)1) << (SHIFT_HIGH_TAG-1))
#define MaskAdr /* 0x1ffffffcL */ ((((UInt)1) << SHIFT_HIGH_TAG)-4)
#define MaskPrim /* 0x0ffffffcL */ ((((UInt)1) << (SHIFT_HIGH_TAG))-4)
#define NumberTag /* 0xa0000000L */ MKTAG(0x5,0)
#define AtomTag /* 0x80000000L */ MKTAG(0x4,0)
#define PairTag /* 0x80000001L */ MKTAG(0x4,1)
#define ApplTag /* 0x80000002L */ MKTAG(0x4,2)
#define MAX_ABS_INT /* 0x04000000L */ (1 << (SHIFT_HIGH_TAG-3))
/* bits that should not be used by anyone but us */
#define YAP_PROTECTED_MASK 0xe0000000L
#define MaskBits 4
#define PairBit /* 0x00000001L */ 1
#define ApplBit /* 0x00000002L */ 2
#define NonTagPart(X) (Signed(X) & MaskPrim)
#define TAGGEDA(TAG,V) (TAG | Unsigned(V))
#define TAGGED(TAG,V) (TAG | NonTagPart(Unsigned(V)<<2))
#define NONTAGGED(TAG,V) NonTagPart(Unsigned(V)<<2)
#define BitOn(Bit,V) (Bit & Unsigned(V))
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
inline EXTERN int IsVarTerm(Term);
inline EXTERN int IsVarTerm(Term t)
{
return (int) (Signed(t) >= 0);
}
inline EXTERN int IsNonVarTerm(Term);
inline EXTERN int IsNonVarTerm(Term t)
{
return (int) (Signed(t) < 0);
}
inline EXTERN Term * RepPair(Term);
inline EXTERN Term * RepPair(Term t)
{
return (Term *) (NonTagPart(t));
}
inline EXTERN Term AbsPair(Term *);
inline EXTERN Term AbsPair(Term * p)
{
return (Term) (TAGGEDA(PairTag, (p)));
}
inline EXTERN Int IsPairTerm(Term);
inline EXTERN Int IsPairTerm(Term t)
{
return (Int) (BitOn(PairBit, (t)));
}
inline EXTERN Term * RepAppl(Term);
inline EXTERN Term * RepAppl(Term t)
{
return (Term *) (NonTagPart(t));
}
inline EXTERN Term AbsAppl(Term *);
inline EXTERN Term AbsAppl(Term * p)
{
return (Term) (TAGGEDA(ApplTag, (p)));
}
inline EXTERN Int IsApplTerm(Term);
inline EXTERN Int IsApplTerm(Term t)
{
return (Int) (BitOn(ApplBit, (t)));
}
inline EXTERN int IsAtomOrIntTerm(Term);
inline EXTERN int IsAtomOrIntTerm(Term t)
{
return (int) (((Unsigned(t) & LowTagBits) == 0));
}
inline EXTERN Term AdjustPtr(Term t, Term off);
inline EXTERN Term AdjustPtr(Term t, Term off)
{
return (Term) ((t)+off);
}
inline EXTERN Term AdjustIDBPtr(Term t, Term off);
inline EXTERN Term AdjustIDBPtr(Term t, Term off)
{
return (Term) ((t)+off);
}
inline EXTERN Int IntOfTerm(Term);
inline EXTERN Int IntOfTerm(Term t)
{
return (Int) (((Int)(t << 3))>>(3+2));
}

View File

@ -1,183 +0,0 @@
/*************************************************************************
* *
* YAP Prolog %W% %G% *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: Tags_32Ops.h.m4 *
* Last rev: December 90 *
* mods: *
* comments: Original Tag Scheme for machines with 32 bits adresses *
* version: $Id: Tags_64bits.h,v 1.9 2002-06-01 04:29:01 vsc Exp $ *
*************************************************************************/
#define TAG_64BITS 1
/* Version for 64 bit addresses machines,
Each term is represented internally as an unsigned 64 bit integer as
follows:
tag value
ints 0m1....001 numeric value
atoms 0m0....001 offset of atom entry
pairs 0mr....011 ptr to pair
aplied functor 0mr....101 ptr to functor followed by args
undefined 0mr....000 address of cell pointing to itself
functors are represented as ptrs to the functor entry in the atom
property list
We rely on the fact that addresses are always multiple of 8.
*/
#define SHIFT_HIGH_TAG 61
#define MKTAG(HI,LO) ((((UInt) (HI))<<SHIFT_HIGH_TAG)|(LO))
#define TagBits /* 0x30000007L */ MKTAG(0x1,7)
#define LowTagBits /* 0x00000007L */ MKTAG(0x0,7)
#define HighTagBits /* 0x70000000L */ MKTAG(0x1,0)
#define AdrHiBit /* 0x08000000L */ (((UInt)1) << (SHIFT_HIGH_TAG-1))
#define MaskPrim /* 0x0ffffff8L */ ((((UInt)1) << (SHIFT_HIGH_TAG))-8)
#define NumberTag /* 0x30000001L */ MKTAG(0x1,1)
#define AtomTag /* 0x10000001L */ MKTAG(0x0,1)
#define MAX_ABS_INT /* 0xfe00000LL */ (((Int)1) << (63-(2+4)))
/* bits that should not be used by anyone but us */
#define YAP_PROTECTED_MASK 0xe000000000000000L
#define UNIQUE_TAG_FOR_PAIRS 1
#define PrimiBit /* 0x00000001L */ 1
#define PairBits /* 0x00000003L */ 3
#define ApplBits /* 0x00000005L */ 5
#define PrimiBits /* 0x70000004L */ MKTAG(0x7,7)
#define NumberMask /* 0x20000007L */ MKTAG(0x2,7)
#define NonTagPart(X) (Signed(X) & MaskPrim)
#define TAGGEDA(TAG,V) (TAG | Unsigned(V))
#define TAGGED(TAG,V) (TAG | NonTagPart(Unsigned(V)<<3)) /* SQRT(8) */
#define NONTAGGED(TAG,V) NonTagPart(Unsigned(V)<<3) /* SQRT(8) */
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
inline EXTERN int IsVarTerm(Term);
inline EXTERN int IsVarTerm(Term t)
{
return (int) ((!((t) & 0x1)));
}
inline EXTERN int IsNonVarTerm(Term);
inline EXTERN int IsNonVarTerm(Term t)
{
return (int) (((t) & 0x1));
}
inline EXTERN Term * RepPair(Term);
inline EXTERN Term * RepPair(Term t)
{
return (Term *) (((t)-PairBits));
}
inline EXTERN Term AbsPair(Term *);
inline EXTERN Term AbsPair(Term * p)
{
return (Term) (((CELL)(p)+PairBits));
}
inline EXTERN Int IsPairTerm(Term);
inline EXTERN Int IsPairTerm(Term t)
{
return (Int) (((t) & 0x2));
}
inline EXTERN Term * RepAppl(Term);
inline EXTERN Term * RepAppl(Term t)
{
return (Term *) (((t)-ApplBits));
}
inline EXTERN Term AbsAppl(Term *);
inline EXTERN Term AbsAppl(Term * p)
{
return (Term) (((CELL)(p)+ApplBits));
}
inline EXTERN Int IsApplTerm(Term);
inline EXTERN Int IsApplTerm(Term t)
{
return (Int) ((((t) & 0x4)));
}
inline EXTERN Int IsAtomOrIntTerm(Term);
inline EXTERN Int IsAtomOrIntTerm(Term t)
{
return (Int) ((((t) & LowTagBits) == 0x1));
}
inline EXTERN Term AdjustPtr(Term t, Term off);
inline EXTERN Term AdjustPtr(Term t, Term off)
{
return (Term) (((t)+off));
}
inline EXTERN Term AdjustIDBPtr(Term t, Term off);
inline EXTERN Term AdjustIDBPtr(Term t, Term off)
{
return (Term) ((t)+off);
}
inline EXTERN Int IntOfTerm(Term);
inline EXTERN Int IntOfTerm(Term t)
{
return (Int) ((Int)(Unsigned(t) << 3) >> 6);
}

View File

@ -1,436 +0,0 @@
/*************************************************************************
* *
* YAP Prolog %W% %G% *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: TermExt.h *
* mods: *
* comments: Extensions to standard terms for YAP *
* version: $Id: TermExt.h,v 1.9 2002-06-01 04:29:01 vsc Exp $ *
*************************************************************************/
#if USE_OFFSETS
#define AtomFoundVar ((Atom)(&(((special_functors *)(NULL))->AtFoundVar)))
#define AtomNil ((Atom)(&(((special_functors *)(NULL))->AtNil)))
#define AtomDot ((Atom)(&(((special_functors *)(NULL))->AtDot)))
#else
#define AtomFoundVar AbsAtom(&(SF_STORE->AtFoundVar))
#define AtomNil AbsAtom(&(SF_STORE->AtNil))
#define AtomDot AbsAtom(&(SF_STORE->AtDot))
#endif
#define TermFoundVar MkAtomTerm(AtomFoundVar)
#define TermNil MkAtomTerm(AtomNil)
#define TermDot MkAtomTerm(AtomDot)
#ifdef IN_SECOND_QUADRANT
typedef enum {
db_ref_e = sizeof(Functor *)|RBIT,
long_int_e = 2*sizeof(Functor *)|RBIT,
#ifdef USE_GMP
big_int_e = 3*sizeof(Functor *)|RBIT,
double_e = 4*sizeof(Functor *)|RBIT
#else
double_e = 3*sizeof(Functor *)|RBIT
#endif
} blob_type;
#else
typedef enum {
db_ref_e = sizeof(Functor *),
long_int_e = 2*sizeof(Functor *),
#ifdef USE_GMP
big_int_e = 3*sizeof(Functor *),
double_e = 4*sizeof(Functor *)
#else
double_e = 3*sizeof(Functor *)
#endif
} blob_type;
#endif
#define FunctorDBRef ((Functor)(db_ref_e))
#define FunctorLongInt ((Functor)(long_int_e))
#ifdef USE_GMP
#define FunctorBigInt ((Functor)(big_int_e))
#endif
#define FunctorDouble ((Functor)(double_e))
#define EndSpecials (double_e)
inline EXTERN blob_type BlobOfFunctor(Functor f);
inline EXTERN blob_type BlobOfFunctor(Functor f)
{
return (blob_type) ((CELL)f);
}
#define SF_STORE ((special_functors *)HEAP_INIT_BASE)
#ifdef COROUTINING
typedef struct {
/* what to do when someone tries to bind our term to someone else
in some predefined context */
void (*bind_op)(Term *, Term);
/* what to do if someone wants to copy our constraint */
int (*copy_term_op)(CELL *, CELL ***, CELL *);
/* copy the constraint into a term and back */
Term (*to_term_op)(CELL *);
int (*term_to_op)(Term, Term);
/* op called to do marking in GC */
void (*mark_op)(CELL *);
} ext_op;
/* known delays */
typedef enum {
empty_ext = 0*sizeof(ext_op), /* default op, this should never be called */
susp_ext = 1*sizeof(ext_op), /* support for delayable goals */
attvars_ext = 2*sizeof(ext_op), /* support for attributed variables */
/* add your own extensions here */
/* keep this one */
} exts;
/* array with the ops for your favourite extensions */
extern ext_op attas[attvars_ext+1];
#endif
/* make sure that these data structures are the first thing to be allocated
in the heap when we start the system */
typedef struct special_functors_struct
{
AtomEntry AtFoundVar;
char AtFoundVarChars[8];
AtomEntry AtNil;
char AtNilChars[8];
AtomEntry AtDot;
char AtDotChars[8];
}
special_functors;
#if SIZEOF_DOUBLE == SIZEOF_LONG_INT
inline EXTERN Term MkFloatTerm(Float);
inline EXTERN Term MkFloatTerm(Float dbl)
{
return (Term) ((H[0] = (CELL)FunctorDouble, *(Float *)(H+1) = dbl, H[2]=((2*sizeof(CELL)+EndSpecials)|MBIT),H+=3,AbsAppl(H-3)));
}
inline EXTERN Float FloatOfTerm(Term t);
inline EXTERN Float FloatOfTerm(Term t)
{
return (Float) (*(Float *)(RepAppl(t)+1));
}
#define InitUnalignedFloat()
#else
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
#ifdef i386X
#define DOUBLE_ALIGNED(ADDR) TRUE
#else
/* first, need to address the alignment problem */
#define DOUBLE_ALIGNED(ADDR) ((CELL)(ADDR) & 0x4)
#endif
inline EXTERN Float STD_PROTO(CpFloatUnaligned,(CELL *));
inline EXTERN void STD_PROTO(AlignGlobalForDouble,(void));
inline EXTERN Float
CpFloatUnaligned(CELL *ptr)
{
union { Float f; CELL d[2]; } u;
u.d[0] = ptr[1];
u.d[1] = ptr[2];
return(u.f);
}
inline EXTERN Term MkFloatTerm(Float);
inline EXTERN Term MkFloatTerm(Float dbl)
{
return (Term) ((AlignGlobalForDouble(), H[0] = (CELL)FunctorDouble, *(Float *)(H+1) = dbl, H[3]=((3*sizeof(CELL)+EndSpecials)|MBIT), H+=4, AbsAppl(H-4)));
}
inline EXTERN Float FloatOfTerm(Term t);
inline EXTERN Float FloatOfTerm(Term t)
{
return (Float) ((DOUBLE_ALIGNED(RepAppl(t)) ? *(Float *)(RepAppl(t)+1) : CpFloatUnaligned(RepAppl(t))));
}
/* no alignment problems for 64 bit machines */
#else
/* OOPS, YAP only understands Floats that are as large as cells or that
take two cells!!! */
#endif
#endif
inline EXTERN int IsFloatTerm(Term);
inline EXTERN int IsFloatTerm(Term t)
{
return (int) (IsApplTerm(t) && FunctorOfTerm(t) == FunctorDouble);
}
/* extern Functor FunctorLongInt; */
inline EXTERN Term MkLongIntTerm(Int);
inline EXTERN Term MkLongIntTerm(Int i)
{
return (Term) ((H[0] = (CELL)FunctorLongInt,H[1] = (CELL)(i),H[2]=((2*sizeof(CELL)+EndSpecials)|MBIT),H+=3,AbsAppl(H-3)));
}
inline EXTERN Int LongIntOfTerm(Term t);
inline EXTERN Int LongIntOfTerm(Term t)
{
return (Int) (RepAppl(t)[1]);
}
inline EXTERN int IsLongIntTerm(Term);
inline EXTERN int IsLongIntTerm(Term t)
{
return (int) (IsApplTerm(t) && FunctorOfTerm(t) == FunctorLongInt);
}
#ifdef USE_GMP
#include <stdio.h>
#include <gmp.h>
MP_INT *STD_PROTO(PreAllocBigNum,(void));
MP_INT *STD_PROTO(InitBigNum,(Int));
Term STD_PROTO(MkBigIntTerm, (MP_INT *));
MP_INT *STD_PROTO(BigIntOfTerm, (Term));
void STD_PROTO(CleanBigNum,(void));
inline EXTERN int IsBigIntTerm(Term);
inline EXTERN int IsBigIntTerm(Term t)
{
return (int) (IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt);
}
inline EXTERN int IsLargeIntTerm(Term);
inline EXTERN int IsLargeIntTerm(Term t)
{
return (int) (IsApplTerm(t) && ((FunctorOfTerm(t) <= FunctorBigInt) && (FunctorOfTerm(t) >= FunctorLongInt)));
}
#else
inline EXTERN int IsBigIntTerm(Term);
inline EXTERN int IsBigIntTerm(Term t)
{
return (int) (FALSE);
}
inline EXTERN int IsLargeIntTerm(Term);
inline EXTERN int IsLargeIntTerm(Term t)
{
return (int) (IsApplTerm(t) && FunctorOfTerm(t) == FunctorLongInt);
}
#endif
/* extern Functor FunctorLongInt; */
inline EXTERN int IsLargeNumTerm(Term);
inline EXTERN int IsLargeNumTerm(Term t)
{
return (int) (IsApplTerm(t) && ((FunctorOfTerm(t) <= FunctorDouble) && (FunctorOfTerm(t) >= FunctorLongInt)));
}
inline EXTERN int IsNumTerm(Term);
inline EXTERN int IsNumTerm(Term t)
{
return (int) ((IsIntTerm(t) || IsLargeNumTerm(t)));
}
inline EXTERN Int IsAtomicTerm(Term);
inline EXTERN Int IsAtomicTerm(Term t)
{
return (Int) (IsAtomOrIntTerm(t) || IsLargeNumTerm(t));
}
inline EXTERN Int IsExtensionFunctor(Functor);
inline EXTERN Int IsExtensionFunctor(Functor f)
{
return (Int) (f <= FunctorDouble);
}
inline EXTERN Int IsBlobFunctor(Functor);
inline EXTERN Int IsBlobFunctor(Functor f)
{
return (Int) ((f <= FunctorDouble && f >= FunctorDBRef));
}
inline EXTERN Int IsPrimitiveTerm(Term);
inline EXTERN Int IsPrimitiveTerm(Term t)
{
return (Int) ((IsAtomOrIntTerm(t) || (IsApplTerm(t) && IsBlobFunctor(FunctorOfTerm(t)))));
}
#ifdef TERM_EXTENSIONS
inline EXTERN Int IsAttachFunc(Functor);
inline EXTERN Int IsAttachFunc(Functor f)
{
return (Int) (FALSE);
}
inline EXTERN Int IsAttachedTerm(Term);
inline EXTERN Int IsAttachedTerm(Term t)
{
return (Int) ((IsVarTerm(t) && VarOfTerm(t) < H0) );
}
inline EXTERN exts ExtFromCell(CELL *);
inline EXTERN exts ExtFromCell(CELL * pt)
{
return (exts) (pt[1]);
}
#else
inline EXTERN Int IsAttachFunc(Functor);
inline EXTERN Int IsAttachFunc(Functor f)
{
return (Int) (FALSE);
}
inline EXTERN Int IsAttachedTerm(Term);
inline EXTERN Int IsAttachedTerm(Term t)
{
return (Int) (FALSE);
}
#endif
EXTERN int STD_PROTO(unify_extension,(Functor, CELL, CELL *, CELL));
inline EXTERN int
unify_extension(Functor f, CELL d0, CELL *pt0, CELL d1)
{
switch(BlobOfFunctor(f)) {
case db_ref_e:
return (d0 == d1);
case long_int_e:
return(pt0[1] == RepAppl(d1)[1]);
#ifdef USE_GMP
case big_int_e:
return (mpz_cmp(BigIntOfTerm(d0),BigIntOfTerm(d1)) == 0);
#endif /* USE_GMP */
case double_e:
{
CELL *pt1 = RepAppl(d1);
return (pt0[1] == pt1[1]
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
&& pt0[2] == pt1[2]
#endif
);
}
}
return(FALSE);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,235 +0,0 @@
/* config.h. Generated automatically by configure. */
/* are we using gcc */
/* #define HAVE_GCC 1 */
/* should we use gcc threaded code (i.e. goto *adrs) */
/* #define USE_THREADED_CODE 1*/
/* Should we use lib readline ? */
/* #undef HAVE_LIBREADLINE */
/* Should we use gmp ? */
/* #define HAVE_LIBGMP 1 */
/* does the compiler support inline ? */
/* #undef inline */
/* Do we have Ansi headers ? */
#define STDC_HEADERS 1
/* Host Name ? */
#define HOST_ALIAS ""
/* #undef HAVE_SYS_WAIT_H */
#define NO_UNION_WAIT 1
/* #undef HAVE_ARPA_INET_H */
#define HAVE_CTYPE_H 1
#define HAVE_DIRECT_H 1
#define HAVE_DIRENT_H 1
#define HAVE_ERRNO_H 1
#define HAVE_FCNTL_H 1
/* #undef HAVE_FENV_H */
/* #undef HAVE_FPU_CONTROL_H */
/* #undef HAVE_GMP_H */
/* #undef HAVE_IEEEFP_H */
#define HAVE_IO_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MEMORY_H 1
/* #undef HAVE_NETDB_H */
/* #undef HAVE_NETINET_IN_H */
/* #undef HAVE_READLINE_READLINE_H */
/* #undef HAVE_REGEX_H */
/* #undef HAVE_SIGINFO_H */
#define HAVE_SIGNAL_H 1
#define HAVE_STDARG_H 1
#define HAVE_STRING_H 1
/* #undef HAVE_STROPTS_H */
/* #undef HAVE_SYS_CONF_H */
#define HAVE_SYS_FILE_H 1
/* #undef HAVE_SYS_MMAN_H */
/* #undef HAVE_SYS_PARAM_H */
/* #undef HAVE_SYS_RESOURCE_H */
/* #undef HAVE_SYS_SELECT_H */
/* #undef HAVE_SYS_SHM_H */
/* #undef HAVE_SYS_SOCKET_H */
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TIME_H 1
/* #undef HAVE_SYS_TIMES_H */
#define HAVE_SYS_TYPES_H 1
/* #undef HAVE_SYS_UCONTEXT_H */
/* #undef HAVE_SYS_UN_H */
#define HAVE_TIME_H 1
#define HAVE_UNISTD_H 1
#define HAVE_WINSOCK_H 1
#define HAVE_WINSOCK2_H 1
/* Do we have restartable syscalls */
/* #undef HAVE_RESTARTABLE_SYSCALLS */
/* is 'tms' defined in <sys/time.h> ? */
/* #undef TM_IN_SYS_TIME */
/* define type of prt returned by malloc: char or void */
#define MALLOC_T void *
/* Define byte order */
/* #undef WORDS_BIGENDIAN */
/* Define sizes of some basic types */
#define SIZEOF_INT_P 4
#define SIZEOF_INT 4
#define SIZEOF_SHORT_INT 2
#define SIZEOF_LONG_INT 4
#define SIZEOF_LONG_LONG_INT 8
#define SIZEOF_FLOAT 4
#define SIZEOF_DOUBLE 8
/* Define representation of floats */
/* only one of the following shoud be set */
/* to add a new representation you must edit FloatOfTerm and MkFloatTerm
in adtdefs.c
*/
#define FFIEEE 1
/* #undef FFVAX */ /* manual */
/* Define the standard type of a float argument to a function */
#define FAFloat double /* manual */
/* Set the minimum and default heap, trail and stack size */
#define MinTrailSpace ( 32*SIZEOF_INT_P)
#define MinStackSpace (200*SIZEOF_INT_P)
#define MinHeapSpace (200*SIZEOF_INT_P)
#define UsrTrailSpace (0)
#define UsrStackSpace (0)
#define UsrHeapSpace (0)
#if (UsrTrailSpace > MinTrailSpace)
#define DefTrailSpace UsrTrailSpace
#else
#define DefTrailSpace MinTrailSpace
#endif
#if (UsrStackSpace > MinStackSpace)
#define DefStackSpace UsrStackSpace
#else
#define DefStackSpace MinStackSpace
#endif
#if (UsrHeapSpace > MinHeapSpace)
#define DefHeapSpace UsrHeapSpace
#else
#define DefHeapSpace MinHeapSpace
#endif
/* Define return type for signal */
#define RETSIGTYPE void
/* #undef HAVE_ACOSH */
/* #undef HAVE_ALARM */
/* #undef HAVE_ASINH */
/* #undef HAVE_ATANH */
#define HAVE_CHDIR 1
#define HAVE_DUP2 1
/* #undef HAVE_FETESTEXCEPT */
/* #undef HAVE_FINITE */
#define HAVE_GETCWD 1
#define HAVE_GETENV 1
/* #undef HAVE_GETHOSTBYNAME */
/* #undef HAVE_GETHOSTID */
/* #undef HAVE_GETHOSTNAME */
/* #undef HAVE_GETHRTIME */
/* #undef HAVE_GETPWNAM */
/* #undef HAVE_GETRUSAGE */
/* #undef HAVE_GETTIMEOFDAY */
/* #undef HAVE_GETWD */
#define HAVE_ISATTY 1
/* #undef HAVE_ISNAN */
/* #undef HAVE_KILL */
#define HAVE_LABS 1
/* #undef HAVE_LINK */
#define HAVE_LOCALTIME 1
/* #undef HAVE_LSTAT */
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
/* #undef HAVE_MKSTEMP */
#define HAVE_MKTEMP 1
/* #undef HAVE_MMAP */
#define HAVE_OPENDIR 1
#define HAVE_POPEN 1
#define HAVE_PUTENV 1
#define HAVE_RAND 1
/* #undef HAVE_RANDOM */
#define HAVE_RENAME 1
/* #undef HAVE_RINT */
/* #undef HAVE_RL_SET_PROMPT */
/* #undef HAVE_SBRK */
/* #undef HAVE_SELECT */
#define HAVE_SETBUF 1
/* #undef HAVE_SETLINEBUF */
/* #undef HAVE_SHMAT */
/* #undef HAVE_SIGACTION */
/* #undef HAVE_SIGGETMASK */
/* #undef HAVE_SIGINTERRUPT */
#define HAVE_SIGNAL 1
/* #undef HAVE_SIGPROCMASK */
#define HAVE_SIGSETJMP 0
#define HAVE_SLEEP 1
/* #undef HAVE_SNPRINTF */
/* #undef HAVE_SOCKET */
#define HAVE_STAT 1
#define HAVE_STRCHR 1
#define HAVE_STRERROR 1
#define HAVE_STRNCAT 1
#define HAVE_STRNCPY 1
#define HAVE_STRTOD 1
#define HAVE_SYSTEM 1
#define HAVE_TIME 1
/* #undef HAVE_TIMES */
#define HAVE_TMPNAM 1
/* #undef HAVE_USLEEP */
/* #undef HAVE_VSNPRINTF */
/* #undef HAVE_WAITPID */
#define HAVE_MPZ_XOR 0
#define HAVE_SIGSEGV 1
#define HAVE_ENVIRON 1
#define SELECT_TYPE_ARG1
#define SELECT_TYPE_ARG234
#define SELECT_TYPE_ARG5
#define TYPE_SELECT_
#define MYTYPE(X) MYTYPE1#X
/* define how to pass the address of a function */
#define FunAdr(Fn) Fn
#define ALIGN_LONGS 1
#define LOW_ABSMI 0
#define MSHIFTOFFS 1
#define USE_MMAP (HAVE_MMAP)
#define USE_SHM (HAVE_SHMAT & !HAVE_MMAP)
#define USE_SBRK (HAVE_SBRK & !HAVE_MMAP & !HAVE_SHMAT)
/* for OSes that do not allow user access to the first
quadrant of the memory space */
/* #undef FORCE_SECOND_QUADRANT */
#if (HAVE_SOCKET || defined(__MINGW32__)) && !defined(SIMICS)
#define USE_SOCKET 1
#endif
#if HAVE_GMP_H && HAVE_LIBGMP
#define USE_GMP 1
#endif
/* Is fflush(NULL) clobbering input streams? */
#define BROKEN_FFLUSH_NULL 1

View File

@ -1,128 +0,0 @@
/*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: corout_utils.h *
* Last rev: *
* mods: *
* comments: Co-routining from within YAP *
* *
*************************************************************************/
STATIC_PROTO (Term SDeref, (Term));
STATIC_PROTO (Term SDerefa, (CELL *));
STATIC_PROTO (sus_tag * deref_susp_chain, (sus_tag *));
static inline Term
SDeref (Term a)
{
while (IsVarTerm (a))
{
Term *b = (Term *) a;
a = *b;
#if YAPOR_SBA
if (a == (0))
return (CELL) b;
#else
if (a == ((Term) b))
return a;
#endif
}
return (a);
}
static inline Term
SDerefa (CELL * b)
{
Term a = *b;
while (IsVarTerm (a))
{
#if YAPOR_SBA
if (a == (0))
return (CELL) b;
#else
if (a == ((Term) b))
return a;
#endif
b = (Term *) a;
a = *b;
}
return (a);
}
static inline CELL *
SADerefa (CELL * b)
{
Term a = *b;
while (IsVarTerm (a))
{
#if YAPOR_SBA
if (a == (0))
return b;
#else
if (a == ((Term) b))
return b;
#endif
b = (Term *) a;
a = *b;
}
return (b);
}
inline EXTERN Term SArgOfTerm (int i, Term t);
inline EXTERN Term
SArgOfTerm (int i, Term t)
{
return (Term) (SDerefa (RepAppl (t) + (i)));
}
inline EXTERN Term SHeadOfTerm (Term);
inline EXTERN Term
SHeadOfTerm (Term t)
{
return (Term) (SDerefa (RepPair (t)));
}
inline EXTERN Term STailOfTerm (Term);
inline EXTERN Term
STailOfTerm (Term t)
{
return (Term) (SDerefa (RepPair (t) + 1));
}
static inline sus_tag *
deref_susp_chain (sus_tag * susp)
{
/* we may have bound several suspension chains together. Follow the
reference chain
*/
while (IsVarTerm (susp->ActiveSus)
&& susp->ActiveSus != (CELL) & susp->ActiveSus)
susp =
(sus_tag *) (susp->ActiveSus - (Int) (&(((sus_tag *) (0))->ActiveSus)));
return (susp);
}

View File

@ -1,543 +0,0 @@
/*************************************************************************
* *
* YAP Prolog %W% %G%
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: sshift.h *
* Last rev: 19/2/88 *
* mods: *
* comments: stack shifter functionality for YAP *
* *
*************************************************************************/
/* The difference between the old stack pointers and the new ones */
extern Int LOCAL_HDiff,
LOCAL_GDiff,
LOCAL_LDiff,
LOCAL_TrDiff,
LOCAL_XDiff,
LOCAL_DelayDiff;
/* The old stack pointers */
extern CELL *LOCAL_OldASP, *LOCAL_OldLCL0;
extern tr_fr_ptr LOCAL_OldTR;
extern CELL *LOCAL_OldGlobalBase, *LOCAL_OldH, *LOCAL_OldH0;
extern ADDR LOCAL_OldTrailBase, LOCAL_OldTrailTop;
extern ADDR LOCAL_OldHeapBase, LOCAL_OldHeapTop;
#define CharP(ptr) ((char *) (ptr))
inline EXTERN int IsHeapP(CELL *);
inline EXTERN int IsHeapP(CELL * ptr)
{
return (int) ((ptr >= (CELL *)HeapBase && ptr <= (CELL *)HeapTop) );
}
/* Adjusting cells and pointers to cells */
inline EXTERN CELL * PtoGloAdjust(CELL *);
inline EXTERN CELL * PtoGloAdjust(CELL * ptr)
{
return (CELL *) (((CELL *)(CharP(ptr) + LOCAL_GDiff)) );
}
inline EXTERN CELL * PtoDelayAdjust(CELL *);
inline EXTERN CELL * PtoDelayAdjust(CELL * ptr)
{
return (CELL *) (((CELL *)(CharP(ptr) + LOCAL_DelayDiff)) );
}
inline EXTERN tr_fr_ptr PtoTRAdjust(tr_fr_ptr);
inline EXTERN tr_fr_ptr PtoTRAdjust(tr_fr_ptr ptr)
{
return (tr_fr_ptr) (((tr_fr_ptr)(CharP(ptr) + LOCAL_TrDiff)) );
}
inline EXTERN CELL * CellPtoTRAdjust(CELL *);
inline EXTERN CELL * CellPtoTRAdjust(CELL * ptr)
{
return (CELL *) (((CELL *)(CharP(ptr) + LOCAL_TrDiff)) );
}
inline EXTERN CELL * PtoLocAdjust(CELL *);
inline EXTERN CELL * PtoLocAdjust(CELL * ptr)
{
return (CELL *) (((CELL *)(CharP(ptr) + LOCAL_LDiff)) );
}
inline EXTERN choiceptr ChoicePtrAdjust(choiceptr);
inline EXTERN choiceptr ChoicePtrAdjust(choiceptr ptr)
{
return (choiceptr) (((choiceptr)(CharP(ptr) + LOCAL_LDiff)) );
}
#ifdef TABLING
inline EXTERN choiceptr ConsumerChoicePtrAdjust(choiceptr);
inline EXTERN choiceptr ConsumerChoicePtrAdjust(choiceptr ptr)
{
return (choiceptr) (((choiceptr)(CharP(ptr) + LOCAL_LDiff)) );
}
inline EXTERN choiceptr GeneratorChoicePtrAdjust(choiceptr);
inline EXTERN choiceptr GeneratorChoicePtrAdjust(choiceptr ptr)
{
return (choiceptr) (((choiceptr)(CharP(ptr) + LOCAL_LDiff)) );
}
#endif /* TABLING */
inline EXTERN CELL GlobalAdjust(CELL);
inline EXTERN CELL GlobalAdjust(CELL val)
{
return (CELL) ((val+LOCAL_GDiff) );
}
inline EXTERN CELL DelayAdjust(CELL);
inline EXTERN CELL DelayAdjust(CELL val)
{
return (CELL) ((val+LOCAL_DelayDiff) );
}
inline EXTERN ADDR GlobalAddrAdjust(ADDR);
inline EXTERN ADDR GlobalAddrAdjust(ADDR ptr)
{
return (ADDR) ((ptr+LOCAL_GDiff) );
}
inline EXTERN ADDR DelayAddrAdjust(ADDR);
inline EXTERN ADDR DelayAddrAdjust(ADDR ptr)
{
return (ADDR) ((ptr+LOCAL_DelayDiff) );
}
inline EXTERN CELL LocalAdjust(CELL);
inline EXTERN CELL LocalAdjust(CELL val)
{
return (CELL) ((val+LOCAL_LDiff) );
}
inline EXTERN ADDR LocalAddrAdjust(ADDR);
inline EXTERN ADDR LocalAddrAdjust(ADDR ptr)
{
return (ADDR) ((ptr+LOCAL_LDiff) );
}
inline EXTERN CELL TrailAdjust(CELL);
inline EXTERN CELL TrailAdjust(CELL val)
{
return (CELL) ((val+LOCAL_TrDiff) );
}
inline EXTERN ADDR TrailAddrAdjust(ADDR);
inline EXTERN ADDR TrailAddrAdjust(ADDR ptr)
{
return (ADDR) ((ptr+LOCAL_TrDiff) );
}
/* heap data structures */
inline EXTERN Functor FuncAdjust(Functor);
inline EXTERN Functor FuncAdjust(Functor f)
{
return (Functor) ((Functor)(CharP(f)+LOCAL_HDiff) );
}
inline EXTERN CELL * CellPtoHeapAdjust(CELL *);
inline EXTERN CELL * CellPtoHeapAdjust(CELL * ptr)
{
return (CELL *) (((CELL *)(CharP(ptr) + LOCAL_HDiff)) );
}
#if USE_OFFSETS
inline EXTERN Atom AtomAdjust(Atom);
inline EXTERN Atom AtomAdjust(Atom at)
{
return (Atom) ((at) );
}
inline EXTERN Prop PropAdjust(Prop);
inline EXTERN Prop PropAdjust(Prop p)
{
return (Prop) ((p) );
}
#else
inline EXTERN Atom AtomAdjust(Atom);
inline EXTERN Atom AtomAdjust(Atom at)
{
return (Atom) ((at == NULL ? (at) : (Atom)(CharP(at)+LOCAL_HDiff) ));
}
inline EXTERN Prop PropAdjust(Prop);
inline EXTERN Prop PropAdjust(Prop p)
{
return (Prop) ((p == NULL ? (p) : (Prop)(CharP(p)+LOCAL_HDiff)) );
}
#endif
inline EXTERN Term AtomTermAdjust(Term);
inline EXTERN Term AtomTermAdjust(Term at)
{
return (Term) ((at) );
}
#if TAGS_FAST_OPS
inline EXTERN Term BlobTermAdjust(Term);
inline EXTERN Term BlobTermAdjust(Term t)
{
return (Term) ((t-LOCAL_HDiff) );
}
#else
inline EXTERN Term BlobTermAdjust(Term);
inline EXTERN Term BlobTermAdjust(Term t)
{
return (Term) ((t+LOCAL_HDiff) );
}
#endif
inline EXTERN AtomEntry * AtomEntryAdjust(AtomEntry *);
inline EXTERN AtomEntry * AtomEntryAdjust(AtomEntry * at)
{
return (AtomEntry *) ((AtomEntry *)(CharP(at)+LOCAL_HDiff) );
}
inline EXTERN union CONSULT_OBJ * ConsultObjAdjust(union CONSULT_OBJ *);
inline EXTERN union CONSULT_OBJ * ConsultObjAdjust(union CONSULT_OBJ * co)
{
return (union CONSULT_OBJ *) ((union CONSULT_OBJ *)(CharP(co)+LOCAL_HDiff) );
}
inline EXTERN DBRef DBRefAdjust(DBRef);
inline EXTERN DBRef DBRefAdjust(DBRef dbr)
{
return (DBRef) ((DBRef)(CharP(dbr)+LOCAL_HDiff) );
}
inline EXTERN Term CodeAdjust(Term);
inline EXTERN Term CodeAdjust(Term dbr)
{
return (Term) (((Term)(dbr)+LOCAL_HDiff) );
}
inline EXTERN ADDR AddrAdjust(ADDR);
inline EXTERN ADDR AddrAdjust(ADDR addr)
{
return (ADDR) ((ADDR)(CharP(addr)+LOCAL_HDiff) );
}
inline EXTERN CODEADDR CodeAddrAdjust(CODEADDR);
inline EXTERN CODEADDR CodeAddrAdjust(CODEADDR addr)
{
return (CODEADDR) ((CODEADDR)(CharP(addr)+LOCAL_HDiff) );
}
inline EXTERN BlockHeader * BlockAdjust(BlockHeader *);
inline EXTERN BlockHeader * BlockAdjust(BlockHeader * addr)
{
return (BlockHeader *) ((BlockHeader *)(CharP(addr)+LOCAL_HDiff) );
}
inline EXTERN yamop * PtoOpAdjust(yamop *);
inline EXTERN yamop * PtoOpAdjust(yamop * ptr)
{
return (yamop *) (((yamop *)(CharP(ptr) + LOCAL_HDiff)) );
}
inline EXTERN CELL * PtoHeapCellAdjust(CELL *);
inline EXTERN CELL * PtoHeapCellAdjust(CELL * ptr)
{
return (CELL *) (((CELL *)(CharP(ptr) + LOCAL_HDiff)) );
}
inline EXTERN PredEntry * PtoPredAdjust(PredEntry *);
inline EXTERN PredEntry * PtoPredAdjust(PredEntry * ptr)
{
return (PredEntry *) (((PredEntry *)(CharP(ptr) + LOCAL_HDiff)) );
}
inline EXTERN ArrayEntry * PtoArrayEAdjust(ArrayEntry *);
inline EXTERN ArrayEntry * PtoArrayEAdjust(ArrayEntry * ptr)
{
return (ArrayEntry *) (((ArrayEntry *)(CharP(ptr) + LOCAL_HDiff)) );
}
#if PRECOMPUTE_REGADDRESS
inline EXTERN AREG XAdjust(AREG);
inline EXTERN AREG XAdjust(AREG reg)
{
return (AREG) ((AREG)((reg)+LOCAL_XDiff) );
}
#else
inline EXTERN AREG XAdjust(AREG);
inline EXTERN AREG XAdjust(AREG reg)
{
return (AREG) ((reg) );
}
#endif
inline EXTERN YREG YAdjust(YREG);
inline EXTERN YREG YAdjust(YREG reg)
{
return (YREG) ((reg) );
}
inline EXTERN int IsOldLocal(CELL);
inline EXTERN int IsOldLocal(CELL reg)
{
return (int) (IN_BETWEEN(LOCAL_OldASP, reg, LOCAL_OldLCL0));
}
/* require because the trail might contain dangling pointers */
inline EXTERN int IsOldLocalInTR(CELL);
inline EXTERN int IsOldLocalInTR(CELL reg)
{
return (int) (IN_BETWEEN(LOCAL_OldH, reg, LOCAL_OldLCL0) );
}
inline EXTERN int IsOldLocalInTRPtr(CELL *);
inline EXTERN int IsOldLocalInTRPtr(CELL * ptr)
{
return (int) (IN_BETWEEN(LOCAL_OldH, ptr, LOCAL_OldLCL0) );
}
inline EXTERN int IsOldH(CELL);
inline EXTERN int IsOldH(CELL reg)
{
return (int) (( CharP(reg) == CharP(LOCAL_OldH) ) );
}
inline EXTERN int IsOldGlobal(CELL);
inline EXTERN int IsOldGlobal(CELL reg)
{
return (int) (IN_BETWEEN(LOCAL_OldH0, reg, LOCAL_OldH) );
}
inline EXTERN int IsOldGlobalPtr(CELL *);
inline EXTERN int IsOldGlobalPtr(CELL * ptr)
{
return (int) (IN_BETWEEN( LOCAL_OldH0, ptr, LOCAL_OldH) );
}
inline EXTERN int IsOldDelay(CELL);
inline EXTERN int IsOldDelay(CELL reg)
{
return (int) (IN_BETWEEN(LOCAL_OldGlobalBase, reg, LOCAL_OldH0) );
}
inline EXTERN int IsOldDelayPtr(CELL *);
inline EXTERN int IsOldDelayPtr(CELL * ptr)
{
return (int) (IN_BETWEEN( LOCAL_OldGlobalBase, ptr, LOCAL_OldH0) );
}
inline EXTERN int IsOldTrail(CELL);
inline EXTERN int IsOldTrail(CELL reg)
{
return (int) (IN_BETWEEN(LOCAL_OldTrailBase, reg, LOCAL_OldTR) );
}
inline EXTERN int IsOldTrailPtr(CELL *);
inline EXTERN int IsOldTrailPtr(CELL * ptr)
{
return (int) (IN_BETWEEN(LOCAL_OldTrailBase, ptr, LOCAL_OldTR) );
}
inline EXTERN int IsOldCode(CELL);
inline EXTERN int IsOldCode(CELL reg)
{
return (int) (IN_BETWEEN(LOCAL_OldHeapBase, reg, LOCAL_OldHeapTop) );
}
inline EXTERN int IsOldCodeCellPtr(CELL *);
inline EXTERN int IsOldCodeCellPtr(CELL * ptr)
{
return (int) (IN_BETWEEN(LOCAL_OldHeapBase, ptr, LOCAL_OldHeapTop) );
}
inline EXTERN int IsGlobal(CELL);
inline EXTERN int IsGlobal(CELL reg)
{
return (int) (IN_BETWEEN(GlobalBase, reg, H) );
}
void STD_PROTO(AdjustStacksAndTrail, (void));
void STD_PROTO(AdjustRegs, (int));

View File

@ -1,153 +0,0 @@
# Microsoft Developer Studio Generated NMAKE File, Based on wyap.dsp
!IF "$(CFG)" == ""
CFG=wyap - Win32 Debug
!MESSAGE No configuration specified. Defaulting to wyap - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "wyap - Win32 Release" && "$(CFG)" != "wyap - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "wyap.mak" CFG="wyap - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "wyap - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "wyap - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "wyap - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\wyap.exe"
CLEAN :
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\yap.obj"
-@erase "$(OUTDIR)\wyap.exe"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "..\include" /I "..\VC\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\wyap.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\wyap.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib ..\yapdll\Release\yapdll.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\wyap.pdb" /machine:I386 /out:"$(OUTDIR)\wyap.exe"
LINK32_OBJS= \
"$(INTDIR)\yap.obj"
"$(OUTDIR)\wyap.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "wyap - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\wyap.exe"
CLEAN :
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(INTDIR)\yap.obj"
-@erase "$(OUTDIR)\wyap.exe"
-@erase "$(OUTDIR)\wyap.ilk"
-@erase "$(OUTDIR)\wyap.pdb"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\wyap.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\wyap.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"$(OUTDIR)\wyap.pdb" /debug /machine:I386 /out:"$(OUTDIR)\wyap.exe" /pdbtype:sept
LINK32_OBJS= \
"$(INTDIR)\yap.obj"
"$(OUTDIR)\wyap.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("wyap.dep")
!INCLUDE "wyap.dep"
!ELSE
!MESSAGE Warning: cannot find "wyap.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "wyap - Win32 Release" || "$(CFG)" == "wyap - Win32 Debug"
SOURCE="\Yap\Yap-4.3.17\console\yap.c"
"$(INTDIR)\yap.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF

View File

@ -1,780 +0,0 @@
# Microsoft Developer Studio Generated NMAKE File, Based on yapdll.dsp
!IF "$(CFG)" == ""
CFG=yapdll - Win32 Debug
!MESSAGE No configuration specified. Defaulting to yapdll - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "yapdll - Win32 Release" && "$(CFG)" != "yapdll - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "yapdll.mak" CFG="yapdll - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "yapdll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "yapdll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "yapdll - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\yapdll.dll"
CLEAN :
-@erase "$(INTDIR)\absmi.obj"
-@erase "$(INTDIR)\adtdefs.obj"
-@erase "$(INTDIR)\alloc.obj"
-@erase "$(INTDIR)\amasm.obj"
-@erase "$(INTDIR)\analyst.obj"
-@erase "$(INTDIR)\arith0.obj"
-@erase "$(INTDIR)\arith1.obj"
-@erase "$(INTDIR)\arith2.obj"
-@erase "$(INTDIR)\arrays.obj"
-@erase "$(INTDIR)\attvar.obj"
-@erase "$(INTDIR)\bb.obj"
-@erase "$(INTDIR)\bignum.obj"
-@erase "$(INTDIR)\c_interface.obj"
-@erase "$(INTDIR)\cdmgr.obj"
-@erase "$(INTDIR)\cmppreds.obj"
-@erase "$(INTDIR)\compiler.obj"
-@erase "$(INTDIR)\computils.obj"
-@erase "$(INTDIR)\corout.obj"
-@erase "$(INTDIR)\dbase.obj"
-@erase "$(INTDIR)\depth_bound.obj"
-@erase "$(INTDIR)\errors.obj"
-@erase "$(INTDIR)\eval.obj"
-@erase "$(INTDIR)\exec.obj"
-@erase "$(INTDIR)\grow.obj"
-@erase "$(INTDIR)\heapgc.obj"
-@erase "$(INTDIR)\index.obj"
-@erase "$(INTDIR)\init.obj"
-@erase "$(INTDIR)\iopreds.obj"
-@erase "$(INTDIR)\load_aix.obj"
-@erase "$(INTDIR)\load_aout.obj"
-@erase "$(INTDIR)\load_coff.obj"
-@erase "$(INTDIR)\load_dl.obj"
-@erase "$(INTDIR)\load_dld.obj"
-@erase "$(INTDIR)\load_dll.obj"
-@erase "$(INTDIR)\load_foreign.obj"
-@erase "$(INTDIR)\load_none.obj"
-@erase "$(INTDIR)\load_shl.obj"
-@erase "$(INTDIR)\mavar.obj"
-@erase "$(INTDIR)\modules.obj"
-@erase "$(INTDIR)\opt.init.obj"
-@erase "$(INTDIR)\or.memory.obj"
-@erase "$(INTDIR)\opt.preds.obj"
-@erase "$(INTDIR)\or.cowengine.obj"
-@erase "$(INTDIR)\or.cut.obj"
-@erase "$(INTDIR)\or.engine.obj"
-@erase "$(INTDIR)\or.sbaengine.obj"
-@erase "$(INTDIR)\or.scheduler.obj"
-@erase "$(INTDIR)\other.obj"
-@erase "$(INTDIR)\parser.obj"
-@erase "$(INTDIR)\save.obj"
-@erase "$(INTDIR)\scanner.obj"
-@erase "$(INTDIR)\sort.obj"
-@erase "$(INTDIR)\stdpreds.obj"
-@erase "$(INTDIR)\sysbits.obj"
-@erase "$(INTDIR)\tab.completion.obj"
-@erase "$(INTDIR)\tab.tries.obj"
-@erase "$(INTDIR)\tracer.obj"
-@erase "$(INTDIR)\unify.obj"
-@erase "$(INTDIR)\userpreds.obj"
-@erase "$(INTDIR)\utilpreds.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\write.obj"
-@erase "$(INTDIR)\ypsocks.obj"
-@erase "$(INTDIR)\ypstdio.obj"
-@erase "$(OUTDIR)\yapdll.dll"
-@erase "$(OUTDIR)\yapdll.exp"
-@erase "$(OUTDIR)\yapdll.lib"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "..\include" /I "..\H" /I "..\OPTYap" /I "..\VC\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "YAPDLL_EXPORTS" /Fp"$(INTDIR)\yapdll.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\yapdll.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\yapdll.pdb" /machine:I386 /out:"$(OUTDIR)\yapdll.dll" /implib:"$(OUTDIR)\yapdll.lib"
LINK32_OBJS= \
"$(INTDIR)\absmi.obj" \
"$(INTDIR)\adtdefs.obj" \
"$(INTDIR)\alloc.obj" \
"$(INTDIR)\amasm.obj" \
"$(INTDIR)\analyst.obj" \
"$(INTDIR)\arith0.obj" \
"$(INTDIR)\arith1.obj" \
"$(INTDIR)\arith2.obj" \
"$(INTDIR)\arrays.obj" \
"$(INTDIR)\attvar.obj" \
"$(INTDIR)\bb.obj" \
"$(INTDIR)\bignum.obj" \
"$(INTDIR)\c_interface.obj" \
"$(INTDIR)\cdmgr.obj" \
"$(INTDIR)\cmppreds.obj" \
"$(INTDIR)\compiler.obj" \
"$(INTDIR)\computils.obj" \
"$(INTDIR)\corout.obj" \
"$(INTDIR)\dbase.obj" \
"$(INTDIR)\depth_bound.obj" \
"$(INTDIR)\errors.obj" \
"$(INTDIR)\eval.obj" \
"$(INTDIR)\exec.obj" \
"$(INTDIR)\grow.obj" \
"$(INTDIR)\heapgc.obj" \
"$(INTDIR)\index.obj" \
"$(INTDIR)\init.obj" \
"$(INTDIR)\iopreds.obj" \
"$(INTDIR)\load_aix.obj" \
"$(INTDIR)\load_aout.obj" \
"$(INTDIR)\load_coff.obj" \
"$(INTDIR)\load_dl.obj" \
"$(INTDIR)\load_dld.obj" \
"$(INTDIR)\load_dll.obj" \
"$(INTDIR)\load_foreign.obj" \
"$(INTDIR)\load_none.obj" \
"$(INTDIR)\load_shl.obj" \
"$(INTDIR)\mavar.obj" \
"$(INTDIR)\modules.obj" \
"$(INTDIR)\opt.init.obj" \
"$(INTDIR)\or.memory.obj" \
"$(INTDIR)\opt.preds.obj" \
"$(INTDIR)\or.cowengine.obj" \
"$(INTDIR)\or.cut.obj" \
"$(INTDIR)\or.engine.obj" \
"$(INTDIR)\or.sbaengine.obj" \
"$(INTDIR)\or.scheduler.obj" \
"$(INTDIR)\other.obj" \
"$(INTDIR)\parser.obj" \
"$(INTDIR)\save.obj" \
"$(INTDIR)\scanner.obj" \
"$(INTDIR)\sort.obj" \
"$(INTDIR)\stdpreds.obj" \
"$(INTDIR)\sysbits.obj" \
"$(INTDIR)\tab.completion.obj" \
"$(INTDIR)\tab.tries.obj" \
"$(INTDIR)\tracer.obj" \
"$(INTDIR)\unify.obj" \
"$(INTDIR)\userpreds.obj" \
"$(INTDIR)\utilpreds.obj" \
"$(INTDIR)\write.obj" \
"$(INTDIR)\ypsocks.obj" \
"$(INTDIR)\ypstdio.obj"
"$(OUTDIR)\yapdll.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "yapdll - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\yapdll.dll"
CLEAN :
-@erase "$(INTDIR)\absmi.obj"
-@erase "$(INTDIR)\adtdefs.obj"
-@erase "$(INTDIR)\alloc.obj"
-@erase "$(INTDIR)\amasm.obj"
-@erase "$(INTDIR)\analyst.obj"
-@erase "$(INTDIR)\arith0.obj"
-@erase "$(INTDIR)\arith1.obj"
-@erase "$(INTDIR)\arith2.obj"
-@erase "$(INTDIR)\arrays.obj"
-@erase "$(INTDIR)\attvar.obj"
-@erase "$(INTDIR)\bb.obj"
-@erase "$(INTDIR)\bignum.obj"
-@erase "$(INTDIR)\c_interface.obj"
-@erase "$(INTDIR)\cdmgr.obj"
-@erase "$(INTDIR)\cmppreds.obj"
-@erase "$(INTDIR)\compiler.obj"
-@erase "$(INTDIR)\computils.obj"
-@erase "$(INTDIR)\corout.obj"
-@erase "$(INTDIR)\dbase.obj"
-@erase "$(INTDIR)\depth_bound.obj"
-@erase "$(INTDIR)\errors.obj"
-@erase "$(INTDIR)\eval.obj"
-@erase "$(INTDIR)\exec.obj"
-@erase "$(INTDIR)\grow.obj"
-@erase "$(INTDIR)\heapgc.obj"
-@erase "$(INTDIR)\index.obj"
-@erase "$(INTDIR)\init.obj"
-@erase "$(INTDIR)\iopreds.obj"
-@erase "$(INTDIR)\load_aix.obj"
-@erase "$(INTDIR)\load_aout.obj"
-@erase "$(INTDIR)\load_coff.obj"
-@erase "$(INTDIR)\load_dl.obj"
-@erase "$(INTDIR)\load_dld.obj"
-@erase "$(INTDIR)\load_dll.obj"
-@erase "$(INTDIR)\load_foreign.obj"
-@erase "$(INTDIR)\load_none.obj"
-@erase "$(INTDIR)\load_shl.obj"
-@erase "$(INTDIR)\mavar.obj"
-@erase "$(INTDIR)\modules.obj"
-@erase "$(INTDIR)\opt.init.obj"
-@erase "$(INTDIR)\or.memory.obj"
-@erase "$(INTDIR)\opt.preds.obj"
-@erase "$(INTDIR)\or.cowengine.obj"
-@erase "$(INTDIR)\or.cut.obj"
-@erase "$(INTDIR)\or.engine.obj"
-@erase "$(INTDIR)\or.sbaengine.obj"
-@erase "$(INTDIR)\or.scheduler.obj"
-@erase "$(INTDIR)\other.obj"
-@erase "$(INTDIR)\parser.obj"
-@erase "$(INTDIR)\save.obj"
-@erase "$(INTDIR)\scanner.obj"
-@erase "$(INTDIR)\sort.obj"
-@erase "$(INTDIR)\stdpreds.obj"
-@erase "$(INTDIR)\sysbits.obj"
-@erase "$(INTDIR)\tab.completion.obj"
-@erase "$(INTDIR)\tab.tries.obj"
-@erase "$(INTDIR)\tracer.obj"
-@erase "$(INTDIR)\unify.obj"
-@erase "$(INTDIR)\userpreds.obj"
-@erase "$(INTDIR)\utilpreds.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(INTDIR)\write.obj"
-@erase "$(INTDIR)\ypsocks.obj"
-@erase "$(INTDIR)\ypstdio.obj"
-@erase "$(OUTDIR)\yapdll.dll"
-@erase "$(OUTDIR)\yapdll.exp"
-@erase "$(OUTDIR)\yapdll.ilk"
-@erase "$(OUTDIR)\yapdll.lib"
-@erase "$(OUTDIR)\yapdll.pdb"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "YAPDLL_EXPORTS" /U "..\include" /U "..\H" /U "..\OPTYap" /U "..\VC\include" /Fp"$(INTDIR)\yapdll.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\yapdll.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\yapdll.pdb" /debug /machine:I386 /out:"$(OUTDIR)\yapdll.dll" /implib:"$(OUTDIR)\yapdll.lib" /pdbtype:sept
LINK32_OBJS= \
"$(INTDIR)\absmi.obj" \
"$(INTDIR)\adtdefs.obj" \
"$(INTDIR)\alloc.obj" \
"$(INTDIR)\amasm.obj" \
"$(INTDIR)\analyst.obj" \
"$(INTDIR)\arith0.obj" \
"$(INTDIR)\arith1.obj" \
"$(INTDIR)\arith2.obj" \
"$(INTDIR)\arrays.obj" \
"$(INTDIR)\attvar.obj" \
"$(INTDIR)\bb.obj" \
"$(INTDIR)\bignum.obj" \
"$(INTDIR)\c_interface.obj" \
"$(INTDIR)\cdmgr.obj" \
"$(INTDIR)\cmppreds.obj" \
"$(INTDIR)\compiler.obj" \
"$(INTDIR)\computils.obj" \
"$(INTDIR)\corout.obj" \
"$(INTDIR)\dbase.obj" \
"$(INTDIR)\depth_bound.obj" \
"$(INTDIR)\errors.obj" \
"$(INTDIR)\eval.obj" \
"$(INTDIR)\exec.obj" \
"$(INTDIR)\grow.obj" \
"$(INTDIR)\heapgc.obj" \
"$(INTDIR)\index.obj" \
"$(INTDIR)\init.obj" \
"$(INTDIR)\iopreds.obj" \
"$(INTDIR)\load_aix.obj" \
"$(INTDIR)\load_aout.obj" \
"$(INTDIR)\load_coff.obj" \
"$(INTDIR)\load_dl.obj" \
"$(INTDIR)\load_dld.obj" \
"$(INTDIR)\load_dll.obj" \
"$(INTDIR)\load_foreign.obj" \
"$(INTDIR)\load_none.obj" \
"$(INTDIR)\load_shl.obj" \
"$(INTDIR)\mavar.obj" \
"$(INTDIR)\modules.obj" \
"$(INTDIR)\opt.init.obj" \
"$(INTDIR)\or.memory.obj" \
"$(INTDIR)\opt.preds.obj" \
"$(INTDIR)\or.cowengine.obj" \
"$(INTDIR)\or.cut.obj" \
"$(INTDIR)\or.engine.obj" \
"$(INTDIR)\or.sbaengine.obj" \
"$(INTDIR)\or.scheduler.obj" \
"$(INTDIR)\other.obj" \
"$(INTDIR)\parser.obj" \
"$(INTDIR)\save.obj" \
"$(INTDIR)\scanner.obj" \
"$(INTDIR)\sort.obj" \
"$(INTDIR)\stdpreds.obj" \
"$(INTDIR)\sysbits.obj" \
"$(INTDIR)\tab.completion.obj" \
"$(INTDIR)\tab.tries.obj" \
"$(INTDIR)\tracer.obj" \
"$(INTDIR)\unify.obj" \
"$(INTDIR)\userpreds.obj" \
"$(INTDIR)\utilpreds.obj" \
"$(INTDIR)\write.obj" \
"$(INTDIR)\ypsocks.obj" \
"$(INTDIR)\ypstdio.obj"
"$(OUTDIR)\yapdll.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("yapdll.dep")
!INCLUDE "yapdll.dep"
!ELSE
!MESSAGE Warning: cannot find "yapdll.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "yapdll - Win32 Release" || "$(CFG)" == "yapdll - Win32 Debug"
SOURCE="\Yap\Yap-4.3.17\C\absmi.c"
"$(INTDIR)\absmi.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\adtdefs.c"
"$(INTDIR)\adtdefs.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\alloc.c"
"$(INTDIR)\alloc.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\amasm.c"
"$(INTDIR)\amasm.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\analyst.c"
"$(INTDIR)\analyst.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\arith0.c"
"$(INTDIR)\arith0.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\arith1.c"
"$(INTDIR)\arith1.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\arith2.c"
"$(INTDIR)\arith2.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\arrays.c"
"$(INTDIR)\arrays.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\attvar.c"
"$(INTDIR)\attvar.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\bb.c"
"$(INTDIR)\bb.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\bignum.c"
"$(INTDIR)\bignum.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\c_interface.c"
"$(INTDIR)\c_interface.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\cdmgr.c"
"$(INTDIR)\cdmgr.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\cmppreds.c"
"$(INTDIR)\cmppreds.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\compiler.c"
"$(INTDIR)\compiler.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\computils.c"
"$(INTDIR)\computils.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\corout.c"
"$(INTDIR)\corout.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\dbase.c"
"$(INTDIR)\dbase.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\depth_bound.c"
"$(INTDIR)\depth_bound.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\errors.c"
"$(INTDIR)\errors.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\eval.c"
"$(INTDIR)\eval.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\exec.c"
"$(INTDIR)\exec.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\grow.c"
"$(INTDIR)\grow.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\heapgc.c"
"$(INTDIR)\heapgc.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\index.c"
"$(INTDIR)\index.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\init.c"
"$(INTDIR)\init.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\iopreds.c"
"$(INTDIR)\iopreds.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_aix.c"
"$(INTDIR)\load_aix.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_aout.c"
"$(INTDIR)\load_aout.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_coff.c"
"$(INTDIR)\load_coff.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_dl.c"
"$(INTDIR)\load_dl.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_dld.c"
"$(INTDIR)\load_dld.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_dll.c"
"$(INTDIR)\load_dll.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_foreign.c"
"$(INTDIR)\load_foreign.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_none.c"
"$(INTDIR)\load_none.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_shl.c"
"$(INTDIR)\load_shl.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\mavar.c"
"$(INTDIR)\mavar.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\modules.c"
"$(INTDIR)\modules.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\opt.init.c"
"$(INTDIR)\opt.init.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\or.memory.c"
"$(INTDIR)\or.memory.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\opt.preds.c"
"$(INTDIR)\opt.preds.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\or.cowengine.c"
"$(INTDIR)\or.cowengine.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\or.cut.c"
"$(INTDIR)\or.cut.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\or.engine.c"
"$(INTDIR)\or.engine.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\or.sbaengine.c"
"$(INTDIR)\or.sbaengine.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\or.scheduler.c"
"$(INTDIR)\or.scheduler.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\other.c"
"$(INTDIR)\other.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\parser.c"
"$(INTDIR)\parser.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\save.c"
"$(INTDIR)\save.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\scanner.c"
"$(INTDIR)\scanner.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\sort.c"
"$(INTDIR)\sort.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\stdpreds.c"
"$(INTDIR)\stdpreds.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\sysbits.c"
"$(INTDIR)\sysbits.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\tab.completion.c"
"$(INTDIR)\tab.completion.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\tab.tries.c"
"$(INTDIR)\tab.tries.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\tracer.c"
"$(INTDIR)\tracer.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\unify.c"
"$(INTDIR)\unify.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\userpreds.c"
"$(INTDIR)\userpreds.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\utilpreds.c"
"$(INTDIR)\utilpreds.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\write.c"
"$(INTDIR)\write.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\ypsocks.c"
"$(INTDIR)\ypsocks.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\ypstdio.c"
"$(INTDIR)\ypstdio.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF

View File

@ -340,6 +340,29 @@
#define HAVE_MPE 0
#endif
/* libarchive */
#undef HAVE_ARCHIVE_READ_SUPPORT_COMPRESSION_BZIP2
#undef HAVE_ARCHIVE_READ_SUPPORT_COMPRESSION_COMPRESS
#undef HAVE_ARCHIVE_READ_SUPPORT_COMPRESSION_GZIP
#undef HAVE_ARCHIVE_READ_SUPPORT_COMPRESSION_LZMA
#undef HAVE_ARCHIVE_READ_SUPPORT_COMPRESSION_NONE
#undef HAVE_ARCHIVE_READ_SUPPORT_COMPRESSION_XZ
#undef HAVE_ARCHIVE_READ_SUPPORT_FORMAT_AR
#undef HAVE_ARCHIVE_READ_SUPPORT_FORMAT_CPIO
#undef HAVE_ARCHIVE_READ_SUPPORT_FORMAT_EMPTY
#undef HAVE_ARCHIVE_READ_SUPPORT_FORMAT_ISO9660
#undef HAVE_ARCHIVE_READ_SUPPORT_FORMAT_MTREE
#undef HAVE_ARCHIVE_READ_SUPPORT_FORMAT_RAW
#undef HAVE_ARCHIVE_READ_SUPPORT_FORMAT_TAR
#undef HAVE_ARCHIVE_READ_SUPPORT_FORMAT_ZIP
/* SQL and ODBC support */
#undef HAVE_SQL_H
#undef HAVE_GMTIME
#undef HAVE_TIMEGM
#undef HAVE_SQLLEN
#undef HAVE_SQLULEN
/* should we avoid realloc() in mpi.c? */
#define MPI_AVOID_REALLOC 0

488
configure vendored
View File

@ -1,11 +1,9 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68.
# Generated by GNU Autoconf 2.69.
#
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
# Foundation, Inc.
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
#
#
# This configure script is free software; the Free Software Foundation
@ -134,6 +132,31 @@ export LANGUAGE
# CDPATH.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
# Use a proper internal environment variable to ensure we don't fall
# into an infinite loop, continuously re-executing ourselves.
if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
_as_can_reexec=no; export _as_can_reexec;
# We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
# Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
case $- in # ((((
*v*x* | *x*v* ) as_opts=-vx ;;
*v* ) as_opts=-v ;;
*x* ) as_opts=-x ;;
* ) as_opts= ;;
esac
exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
# Admittedly, this is quite paranoid, since all the known shells bail
# out after a failed `exec'.
$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
as_fn_exit 255
fi
# We don't want this to propagate to other subprocesses.
{ _as_can_reexec=; unset _as_can_reexec;}
if test "x$CONFIG_SHELL" = x; then
as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
emulate sh
@ -167,7 +190,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
else
exitcode=1; echo positional parameters were not saved.
fi
test x\$exitcode = x0 || exit 1"
test x\$exitcode = x0 || exit 1
test -x / || exit 1"
as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
@ -212,21 +236,25 @@ IFS=$as_save_IFS
if test "x$CONFIG_SHELL" != x; then :
# We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
# Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
export CONFIG_SHELL
case $- in # ((((
*v*x* | *x*v* ) as_opts=-vx ;;
*v* ) as_opts=-v ;;
*x* ) as_opts=-x ;;
* ) as_opts= ;;
esac
exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
export CONFIG_SHELL
# We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
# Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
case $- in # ((((
*v*x* | *x*v* ) as_opts=-vx ;;
*v* ) as_opts=-v ;;
*x* ) as_opts=-x ;;
* ) as_opts= ;;
esac
exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
# Admittedly, this is quite paranoid, since all the known shells bail
# out after a failed `exec'.
$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
exit 255
fi
if test x$as_have_required = xno; then :
@ -328,6 +356,14 @@ $as_echo X"$as_dir" |
} # as_fn_mkdir_p
# as_fn_executable_p FILE
# -----------------------
# Test if FILE is an executable regular file.
as_fn_executable_p ()
{
test -f "$1" && test -x "$1"
} # as_fn_executable_p
# as_fn_append VAR VALUE
# ----------------------
# Append the text in VALUE to the end of the definition contained in VAR. Take
@ -449,6 +485,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
chmod +x "$as_me.lineno" ||
{ $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
# If we had to re-execute with $CONFIG_SHELL, we're ensured to have
# already done that, so ensure we don't try to do so again and fall
# in an infinite loop. This has already happened in practice.
_as_can_reexec=no; export _as_can_reexec
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
# original and so on. Autoconf is especially sensitive to this).
@ -483,16 +523,16 @@ if (echo >conf$$.file) 2>/dev/null; then
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -p'.
# In both cases, we have to default to `cp -pR'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -p'
as_ln_s='cp -pR'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
as_ln_s='cp -pR'
fi
else
as_ln_s='cp -p'
as_ln_s='cp -pR'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
@ -504,28 +544,8 @@ else
as_mkdir_p=false
fi
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in #(
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
as_test_x='test -x'
as_executable_p=as_fn_executable_p
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@ -601,6 +621,12 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS
LIBOBJS
ENABLE_ODBC
ODBC_PLTARGETS
ODBC_TARGETS
ODBC_LIBS
ODBC_LDFLAGS
ODBC_CFLAGS
ENABLE_LIBARCHIVE
ARCHIVE_PLTARGETS
ARCHIVE_TARGETS
@ -623,6 +649,10 @@ IN_SWI
IN_YAP
PROLOG_SYSTEM
M4GENABSMI
PYTHON_LIBS
PYTHON_INCLUDES
ENABLE_PYTHON
PYTHON_TARGET
INSTALL_PRISM
MATLAB_INCLUDE
INSTALL_MATLAB
@ -702,6 +732,7 @@ CPLINT_CFLAGS
CPLINT_LIBS
ENABLE_PRISM
ENABLE_GECODE
PYTHON
REXE
INSTALL_INFO
MPI_CC
@ -817,6 +848,7 @@ enable_cplint
enable_clpbn_bp
with_gmp
with_R
with_python
with_minisat
with_cudd
enable_myddas
@ -1303,8 +1335,6 @@ target=$target_alias
if test "x$host_alias" != x; then
if test "x$build_alias" = x; then
cross_compiling=maybe
$as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used" >&2
elif test "x$build_alias" != "x$host_alias"; then
cross_compiling=yes
fi
@ -1500,6 +1530,7 @@ Optional Packages:
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-gmp=DIR use GNU Multiple Precision in DIR
--with-R=DIR interface to R language
--with-python=DIR interface to R language
--enable-minisat use minisat interface
--with-cudd=DIR use CUDD package in DIR
--with-java=JAVA_HOME use Java instalation in JAVA_HOME
@ -1594,9 +1625,9 @@ test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
configure
generated by GNU Autoconf 2.68
generated by GNU Autoconf 2.69
Copyright (C) 2010 Free Software Foundation, Inc.
Copyright (C) 2012 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
_ACEOF
@ -1907,7 +1938,7 @@ $as_echo "$ac_try_echo"; } >&5
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
test -x conftest$ac_exeext
}; then :
ac_retval=0
else
@ -2010,7 +2041,8 @@ int
main ()
{
static int test_array [1 - 2 * !(($2) >= 0)];
test_array [0] = 0
test_array [0] = 0;
return test_array [0];
;
return 0;
@ -2026,7 +2058,8 @@ int
main ()
{
static int test_array [1 - 2 * !(($2) <= $ac_mid)];
test_array [0] = 0
test_array [0] = 0;
return test_array [0];
;
return 0;
@ -2052,7 +2085,8 @@ int
main ()
{
static int test_array [1 - 2 * !(($2) < 0)];
test_array [0] = 0
test_array [0] = 0;
return test_array [0];
;
return 0;
@ -2068,7 +2102,8 @@ int
main ()
{
static int test_array [1 - 2 * !(($2) >= $ac_mid)];
test_array [0] = 0
test_array [0] = 0;
return test_array [0];
;
return 0;
@ -2102,7 +2137,8 @@ int
main ()
{
static int test_array [1 - 2 * !(($2) <= $ac_mid)];
test_array [0] = 0
test_array [0] = 0;
return test_array [0];
;
return 0;
@ -2286,7 +2322,7 @@ This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by $as_me, which was
generated by GNU Autoconf 2.68. Invocation command line was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@ -2662,7 +2698,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="${ac_tool_prefix}gcc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -2702,7 +2738,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="gcc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -2755,7 +2791,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="${ac_tool_prefix}cc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -2796,7 +2832,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
ac_prog_rejected=yes
continue
@ -2854,7 +2890,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -2898,7 +2934,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -3344,8 +3380,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
struct stat;
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
@ -3458,7 +3493,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -3502,7 +3537,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CXX="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -3705,7 +3740,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_AWK="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -4055,7 +4090,7 @@ do
for ac_prog in grep ggrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
{ test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
as_fn_executable_p "$ac_path_GREP" || continue
# Check for GNU ac_path_GREP and select it if it is found.
# Check for GNU $ac_path_GREP
case `"$ac_path_GREP" --version 2>&1` in
@ -4121,7 +4156,7 @@ do
for ac_prog in egrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
{ test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
as_fn_executable_p "$ac_path_EGREP" || continue
# Check for GNU ac_path_EGREP and select it if it is found.
# Check for GNU $ac_path_EGREP
case `"$ac_path_EGREP" --version 2>&1` in
@ -4660,13 +4695,27 @@ if test "${with_R+set}" = set; then :
elif test "$withval" = no; then
yap_cv_R=no
else
yap_cv_R=$with_R
yap_cv_R=$withval
fi
else
yap_cv_R=no
fi
# Check whether --with-python was given.
if test "${with_python+set}" = set; then :
withval=$with_python; if test "$withval" = yes; then
yap_cv_python=yes
elif test "$withval" = no; then
yap_cv_python=no
else
yap_cv_python=$withval
fi
else
yap_cv_python=no
fi
# Check whether --with-minisat was given.
if test "${with_minisat+set}" = set; then :
@ -4701,6 +4750,8 @@ if test "${enable_myddas+set}" = set; then :
yap_cv_myddas=$enable_myddas
LDFLAGS="$LDFLAGS -L${yap_cv_myddas}/lib "
CPPFLAGS="$CPPFLAGS -I${yap_cv_myddas}/include "
ODBC_LDFLAGS="-L${yap_cv_myddas}/lib "
ODBC_CFLAGS="-I${yap_cv_myddas}/include "
fi
else
yap_cv_myddas=/usr
@ -5225,7 +5276,7 @@ case $as_dir/ in #((
# by default.
for ac_prog in ginstall scoinst install; do
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
if test $ac_prog = install &&
grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
@ -5298,7 +5349,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -5338,7 +5389,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_RANLIB="ranlib"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -5390,7 +5441,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_INDENT="${ac_tool_prefix}indent"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -5430,7 +5481,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_INDENT="indent"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -5482,7 +5533,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_AR="${ac_tool_prefix}ar"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -5522,7 +5573,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_AR="ar"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -5574,7 +5625,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_MPI_CC="${ac_tool_prefix}mpicc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -5614,7 +5665,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_MPI_CC="mpicc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -5668,7 +5719,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_INSTALL_INFO="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -5709,7 +5760,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_SHELL="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -6699,7 +6750,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_REXE="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -6794,6 +6845,70 @@ else
ENABLE_REAL="@# "
fi
if test "$yap_cv_python" = "no"; then
PYTHON_TARGET="dummy"
ENABLE_PYTHON="@# "
elif test -e "$srcdir"/packages/python/Makefile.in ; then
PYTHON_TARGET="pitf"
ENABLE_PYTHON=""
if test "$yap_cv_python" = "yes"
then
for ac_prog in python
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_PYTHON+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$PYTHON"; then
ac_cv_prog_PYTHON="$PYTHON" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_PYTHON="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
PYTHON=$ac_cv_prog_PYTHON
if test -n "$PYTHON"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5
$as_echo "$PYTHON" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$PYTHON" && break
done
test -n "$PYTHON" || PYTHON=""none""
else
PYTHON="$yap_cv_python"
fi
PYTHONHOME=`$PYTHON -c'import sys; print sys.prefix'`
PYTHONVERSION=`"$PYTHON" -c "import sys; print sys.version[:3]"`
PYTHON_LIBS="-L $PYTHONHOME/lib -lpython$PYTHONVERSION"
LIBS="$LIBS $PYTHON_LIBS"
PYTHON_INCLUDES="-I $PYTHONHOME/include/python$PYTHONVERSION"
else
PYTHON_TARGET="dummy"
ENABLE_PYTHON="@# "
fi
if test "$yap_cv_myddas" != "no"
then
@ -6925,6 +7040,73 @@ else
yap_cv_odbc="no"
fi
if test "$yap_cv_odbc" = yes
then
ODBC_LIBS="$ODBC_LIBS -lodbc"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing SQLAllocHandle" >&5
$as_echo_n "checking for library containing SQLAllocHandle... " >&6; }
if ${ac_cv_search_SQLAllocHandle+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char SQLAllocHandle ();
int
main ()
{
return SQLAllocHandle ();
;
return 0;
}
_ACEOF
for ac_lib in '' iodbc; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_search_SQLAllocHandle=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
if ${ac_cv_search_SQLAllocHandle+:} false; then :
break
fi
done
if ${ac_cv_search_SQLAllocHandle+:} false; then :
else
ac_cv_search_SQLAllocHandle=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_SQLAllocHandle" >&5
$as_echo "$ac_cv_search_SQLAllocHandle" >&6; }
ac_res=$ac_cv_search_SQLAllocHandle
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
yap_cv_odbc="yes"
else
yap_cv_odbc="no"
fi
if test "$yap_cv_odbc" = yes
then
ODBC_LIBS="$ODBC_LIBS -liodbc"
fi
fi
if test "$yap_cv_odbc" = yes
then
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_ODBC"
@ -7411,6 +7593,12 @@ else
ENABLE_LIBARCHIVE="@# "
fi
if test -e "$srcdir"/packages/odbc/Makefile.in; then
ENABLE_ODBC=""
else
ENABLE_ODBC="@# "
fi
if test "$use_chr" = no; then
ENABLE_CHR="@# "
elif test -e "$srcdir"/packages/chr/Makefile.in; then
@ -9528,6 +9716,10 @@ CMDEXT=sh
@ -10823,6 +11015,63 @@ fi
fi
if test "$yap_cv_odbc" = yes; then
ODBC_TARGETS="odbc4pl.$SO"
ODBC_PLTARGETS=odbc.pl
for ac_header in sql.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "sql.h" "ac_cv_header_sql_h" "$ac_includes_default"
if test "x$ac_cv_header_sql_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SQL_H 1
_ACEOF
fi
done
for ac_func in localtime mktime gmtime timegm
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
ac_fn_c_check_type "$LINENO" "SQLLEN" "ac_cv_type_SQLLEN" "#include <sql.h>
"
if test "x$ac_cv_type_SQLLEN" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SQLLEN 1
_ACEOF
fi
ac_fn_c_check_type "$LINENO" "SQLULEN" "ac_cv_type_SQLULEN" "#include <sql.h>
"
if test "x$ac_cv_type_SQLULEN" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SQLULEN 1
_ACEOF
fi
else
ODBC_TARGETS=nolib
ODBC_PLTARGETS=odbc.pl
fi
if test "$ENABLE_LIBARCHIVE" = ""
then
OLD_LIBS=$LIBS
@ -10886,6 +11135,7 @@ fi
fi
LIBS="$LIBS -larchive"
for ac_func in archive_read_support_compression_bzip2 \
archive_read_support_compression_compress \
archive_read_support_compression_gzip \
@ -10950,10 +11200,19 @@ fi
LIBS="$OLD_LIBS"
fi
mkdir -p library/lammpi
mkdir -p library/matrix
mkdir -p library/matlab
@ -11091,7 +11350,12 @@ ac_config_files="$ac_config_files packages/http/Makefile"
fi
if test "$ENABLE_JPL" = ""; then
ac_config_files="$ac_config_files packages/jpl/Makefile packages/jpl/jpl_paths.yap packages/jpl/src/java/Makefile packages/pyswip/Makefile"
ac_config_files="$ac_config_files packages/jpl/Makefile packages/jpl/jpl_paths.yap packages/jpl/src/java/Makefile"
fi
if test "$ENABLE_PYTHON" = ""; then
ac_config_files="$ac_config_files packages/python/Makefile"
fi
@ -11137,6 +11401,11 @@ ac_config_files="$ac_config_files packages/archive/Makefile"
fi
if test "$ENABLE_ODBC" = ""; then
ac_config_files="$ac_config_files packages/odbc/Makefile"
fi
if test "$ENABLE_CUDD" = ""; then
ac_config_files="$ac_config_files packages/bdd/Makefile"
@ -11583,16 +11852,16 @@ if (echo >conf$$.file) 2>/dev/null; then
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -p'.
# In both cases, we have to default to `cp -pR'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -p'
as_ln_s='cp -pR'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
as_ln_s='cp -pR'
fi
else
as_ln_s='cp -p'
as_ln_s='cp -pR'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
@ -11652,28 +11921,16 @@ else
as_mkdir_p=false
fi
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in #(
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
# as_fn_executable_p FILE
# -----------------------
# Test if FILE is an executable regular file.
as_fn_executable_p ()
{
test -f "$1" && test -x "$1"
} # as_fn_executable_p
as_test_x='test -x'
as_executable_p=as_fn_executable_p
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@ -11695,7 +11952,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# values after options handling.
ac_log="
This file was extended by $as_me, which was
generated by GNU Autoconf 2.68. Invocation command line was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
@ -11757,10 +12014,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
config.status
configured by $0, generated by GNU Autoconf 2.68,
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
Copyright (C) 2010 Free Software Foundation, Inc.
Copyright (C) 2012 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
@ -11850,7 +12107,7 @@ fi
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
if \$ac_cs_recheck; then
set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
shift
\$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
CONFIG_SHELL='$SHELL'
@ -11915,7 +12172,7 @@ do
"packages/jpl/Makefile") CONFIG_FILES="$CONFIG_FILES packages/jpl/Makefile" ;;
"packages/jpl/jpl_paths.yap") CONFIG_FILES="$CONFIG_FILES packages/jpl/jpl_paths.yap" ;;
"packages/jpl/src/java/Makefile") CONFIG_FILES="$CONFIG_FILES packages/jpl/src/java/Makefile" ;;
"packages/pyswip/Makefile") CONFIG_FILES="$CONFIG_FILES packages/pyswip/Makefile" ;;
"packages/python/Makefile") CONFIG_FILES="$CONFIG_FILES packages/python/Makefile" ;;
"packages/pldoc/Makefile") CONFIG_FILES="$CONFIG_FILES packages/pldoc/Makefile" ;;
"packages/pldoc/server/man_server.pl") CONFIG_FILES="$CONFIG_FILES packages/pldoc/server/man_server.pl" ;;
"packages/plunit/Makefile") CONFIG_FILES="$CONFIG_FILES packages/plunit/Makefile" ;;
@ -11925,6 +12182,7 @@ do
"packages/sgml/Makefile") CONFIG_FILES="$CONFIG_FILES packages/sgml/Makefile" ;;
"packages/zlib/Makefile") CONFIG_FILES="$CONFIG_FILES packages/zlib/Makefile" ;;
"packages/archive/Makefile") CONFIG_FILES="$CONFIG_FILES packages/archive/Makefile" ;;
"packages/odbc/Makefile") CONFIG_FILES="$CONFIG_FILES packages/odbc/Makefile" ;;
"packages/bdd/Makefile") CONFIG_FILES="$CONFIG_FILES packages/bdd/Makefile" ;;
"packages/ProbLog/simplecudd/Makefile") CONFIG_FILES="$CONFIG_FILES packages/ProbLog/simplecudd/Makefile" ;;
"packages/ProbLog/simplecudd_lfi/Makefile") CONFIG_FILES="$CONFIG_FILES packages/ProbLog/simplecudd_lfi/Makefile" ;;

View File

@ -241,9 +241,19 @@ AC_ARG_WITH(R,
elif test "$withval" = no; then
yap_cv_R=no
else
yap_cv_R=$with_R
yap_cv_R=$withval
fi,
[yap_cv_R=no])
AC_ARG_WITH(python,
[ --with-python[=DIR] interface to R language],
if test "$withval" = yes; then
yap_cv_python=yes
elif test "$withval" = no; then
yap_cv_python=no
else
yap_cv_python=$withval
fi,
[yap_cv_python=no])
dnl best test we could do.
AC_ARG_WITH(minisat,
@ -272,6 +282,8 @@ AC_ARG_ENABLE(myddas,
yap_cv_myddas=$enable_myddas
LDFLAGS="$LDFLAGS -L${yap_cv_myddas}/lib "
CPPFLAGS="$CPPFLAGS -I${yap_cv_myddas}/include "
ODBC_LDFLAGS="-L${yap_cv_myddas}/lib "
ODBC_CFLAGS="-I${yap_cv_myddas}/include "
fi,
[yap_cv_myddas=/usr])
@ -834,6 +846,28 @@ else
ENABLE_REAL="@# "
fi
if test "$yap_cv_python" = "no"; then
PYTHON_TARGET="dummy"
ENABLE_PYTHON="@# "
elif test -e "$srcdir"/packages/python/Makefile.in ; then
PYTHON_TARGET="pitf"
ENABLE_PYTHON=""
if test "$yap_cv_python" = "yes"
then
AC_CHECK_PROGS(PYTHON, python, "none")
else
PYTHON="$yap_cv_python"
fi
PYTHONHOME=`$PYTHON -c'import sys; print sys.prefix'`
PYTHONVERSION=`"$PYTHON" -c "import sys; print sys.version[[:3]]"`
PYTHON_LIBS="-L $PYTHONHOME/lib -lpython$PYTHONVERSION"
LIBS="$LIBS $PYTHON_LIBS"
PYTHON_INCLUDES="-I $PYTHONHOME/include/python$PYTHONVERSION"
else
PYTHON_TARGET="dummy"
ENABLE_PYTHON="@# "
fi
dnl if test "$yap_cv_cudd" != "no"
dnl then
dnl AC_CHECK_LIB(cudd,Cudd_Init)
@ -857,6 +891,16 @@ then
;;
esac
AC_SEARCH_LIBS(SQLAllocHandle, [odbc], [yap_cv_odbc="yes"], [yap_cv_odbc="no"])
if test "$yap_cv_odbc" = yes
then
ODBC_LIBS="$ODBC_LIBS -lodbc"
else
AC_SEARCH_LIBS(SQLAllocHandle, [iodbc], [yap_cv_odbc="yes"], [yap_cv_odbc="no"])
if test "$yap_cv_odbc" = yes
then
ODBC_LIBS="$ODBC_LIBS -liodbc"
fi
fi
if test "$yap_cv_odbc" = yes
then
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_ODBC"
@ -976,6 +1020,12 @@ else
ENABLE_LIBARCHIVE="@# "
fi
if test -e "$srcdir"/packages/odbc/Makefile.in; then
ENABLE_ODBC=""
else
ENABLE_ODBC="@# "
fi
if test "$use_chr" = no; then
ENABLE_CHR="@# "
elif test -e "$srcdir"/packages/chr/Makefile.in; then
@ -1822,6 +1872,10 @@ AC_SUBST(REAL_LIBS)
AC_SUBST(INSTALL_MATLAB)
AC_SUBST(MATLAB_INCLUDE)
AC_SUBST(INSTALL_PRISM)
AC_SUBST(PYTHON_TARGET)
AC_SUBST(ENABLE_PYTHON)
AC_SUBST(PYTHON_INCLUDES)
AC_SUBST(PYTHON_LIBS)
dnl check for threaded code
AC_MSG_CHECKING(for gcc threaded code)
@ -2305,14 +2359,29 @@ else
EOF
fi
AC_SUBST(ZLIBS)
AC_SUBST(ZLIB_TARGETS)
AC_SUBST(ZLIB_PLTARGETS)
AC_SUBST(ZLIB_INSTALL)
fi
dnl zlib
dnl archive
if test "$yap_cv_odbc" = yes; then
ODBC_TARGETS="odbc4pl.$SO"
ODBC_PLTARGETS=odbc.pl
AC_CHECK_HEADERS(sql.h)
AC_CHECK_FUNCS(localtime mktime gmtime timegm)
AC_CHECK_TYPES([SQLLEN, SQLULEN],,,
[#include <sql.h>
])
else
ODBC_TARGETS=nolib
ODBC_PLTARGETS=odbc.pl
fi
if test "$ENABLE_LIBARCHIVE" = ""
then
OLD_LIBS=$LIBS
@ -2331,6 +2400,7 @@ if test "$ARCHIVEH" = yes; then
ARCHIVELIB=no)
fi
LIBS="$LIBS -larchive"
AC_CHECK_FUNCS(archive_read_support_compression_bzip2 \
archive_read_support_compression_compress \
archive_read_support_compression_gzip \
@ -2373,10 +2443,19 @@ AC_SUBST(ARCHIVE_LIBS)
AC_SUBST(ARCHIVE_TARGETS)
AC_SUBST(ARCHIVE_PLTARGETS)
LIBS="$OLD_LIBS"
fi
AC_SUBST(ENABLE_LIBARCHIVE)
AC_SUBST(ODBC_CFLAGS)
AC_SUBST(ODBC_LDFLAGS)
AC_SUBST(ODBC_LIBS)
AC_SUBST(ODBC_TARGETS)
AC_SUBST(ODBC_PLTARGETS)
AC_SUBST(ENABLE_ODBC)
mkdir -p library/lammpi
mkdir -p library/matrix
mkdir -p library/matlab
@ -2483,7 +2562,11 @@ AC_CONFIG_FILES([packages/http/Makefile])
fi
if test "$ENABLE_JPL" = ""; then
AC_CONFIG_FILES([packages/jpl/Makefile packages/jpl/jpl_paths.yap packages/jpl/src/java/Makefile packages/pyswip/Makefile ])
AC_CONFIG_FILES([packages/jpl/Makefile packages/jpl/jpl_paths.yap packages/jpl/src/java/Makefile ])
fi
if test "$ENABLE_PYTHON" = ""; then
AC_CONFIG_FILES([ packages/python/Makefile ])
fi
if test "$ENABLE_PLDOC" = ""; then
@ -2519,6 +2602,10 @@ if test "$ENABLE_LIBARCHIVE" = ""; then
AC_CONFIG_FILES([packages/archive/Makefile])
fi
if test "$ENABLE_ODBC" = ""; then
AC_CONFIG_FILES([packages/odbc/Makefile])
fi
if test "$ENABLE_CUDD" = ""; then
AC_CONFIG_FILES([packages/bdd/Makefile])

View File

@ -2358,7 +2358,8 @@ Add predicates to the public list of the context module. This implies
the predicate will be imported into another module if this module is
imported with @code{use_module/[1,2]}. Note that predicates are normally
exported using the directive @code{module/2}. @code{export/1} is meant
to handle export from dynamically created modules.
to handle export from dynamically created modules. The directive argument
may also be a list of predicates.
@item export_list(?@var{Mod},?@var{ListOfPredicateIndicator})
@findex export_list/2

View File

@ -259,18 +259,6 @@ typedef void *PL_engine_t;
#define PL_ACTION_GUIAPP 10 /* Win32: set when this is a gui */
#define PL_ACTION_ATTACH_CONSOLE 11 /* MT: Attach a console */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Foreign language interface definitions. Note that these macros MUST be
consistent with the definitions in pl-itf.h, which is included with
users foreign language code.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#define NOTRACE PL_FA_NOTRACE
#define META PL_FA_TRANSPARENT
#define NDET PL_FA_NONDETERMINISTIC
#define VA PL_FA_VARARGS
#define CREF PL_FA_CREF
#define ISO PL_FA_ISO
typedef enum
{ FRG_FIRST_CALL = 0, /* Initial call */

View File

@ -35,7 +35,6 @@ PROGRAMS= \
$(srcdir)/avl.yap \
$(srcdir)/bhash.yap \
$(srcdir)/charsio.yap \
$(srcdir)/cleanup.yap \
$(srcdir)/clp/clpfd.pl \
$(srcdir)/coinduction.yap \
$(srcdir)/dbqueues.yap \
@ -56,6 +55,7 @@ PROGRAMS= \
$(srcdir)/prandom.yap \
$(srcdir)/queues.yap \
$(srcdir)/random.yap \
$(srcdir)/range.yap \
$(srcdir)/r_session.yap \
$(srcdir)/rbtrees.yap \
$(srcdir)/regexp.yap \

View File

@ -150,7 +150,10 @@ PL_agc_hook(PL_agc_hook_t entry)
YAP: char* AtomName(Atom) */
X_API char* PL_atom_chars(atom_t a) /* SAM check type */
{
return RepAtom(SWIAtomToAtom(a))->StrOfAE;
Atom at = SWIAtomToAtom(a);
if (IsWideAtom(at))
return NULL;
return RepAtom(at)->StrOfAE;
}
/* SWI: char* PL_atom_chars(atom_t atom)
@ -281,7 +284,7 @@ X_API int PL_get_atom_chars(term_t ts, char **a) /* SAM check type */
{
CACHE_REGS
Term t = Yap_GetFromSlot(ts PASS_REGS);
if (!IsAtomTerm(t))
if (!IsAtomTerm(t) || IsWideAtom(AtomOfTerm(t)))
return 0;
*a = RepAtom(AtomOfTerm(t))->StrOfAE;
return 1;
@ -394,9 +397,9 @@ X_API int PL_get_integer(term_t ts, int *i)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
if (!YAP_IsIntTerm(t) )
if (IsVarTerm(t) || !IsIntegerTerm(t) )
return 0;
*i = YAP_IntOfTerm(t);
*i = (int)IntegerOfTerm(t);
return 1;
}
@ -843,6 +846,11 @@ X_API int PL_cons_functor_v(term_t d, functor_t f, term_t a0)
X_API int PL_cons_list(term_t d, term_t h, term_t t)
{
CACHE_REGS
if (Unsigned(H) > Unsigned(ASP)-CreepFlag) {
if (!do_gc(0)) {
return FALSE;
}
}
Yap_PutInSlot(d,MkPairTerm(Yap_GetFromSlot(h PASS_REGS),Yap_GetFromSlot(t PASS_REGS)) PASS_REGS);
return TRUE;
}
@ -1070,7 +1078,7 @@ X_API int PL_warning(const char *msg, ...) {
X_API int PL_unify(term_t t1, term_t t2)
{
CACHE_REGS
return YAP_Unify(Yap_GetFromSlot(t1 PASS_REGS),Yap_GetFromSlot(t2 PASS_REGS));
return Yap_unify(Yap_GetFromSlot(t1 PASS_REGS),Yap_GetFromSlot(t2 PASS_REGS));
}
/* SWI: int PL_unify_atom(term_t ?t, atom *at)
@ -1247,7 +1255,7 @@ X_API int PL_unify_arg(int index, term_t tt, term_t arg)
return FALSE;
to = ArgOfTerm(index, t);
}
return Yap_unify(Yap_GetFromSlot(t PASS_REGS),to);
return Yap_unify(Yap_GetFromSlot(arg PASS_REGS),to);
}
/* SWI: int PL_unify_list(term_t ?t, term_t +h, term_t -t)
@ -1799,7 +1807,7 @@ X_API int PL_is_list(term_t ts)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
return Yap_IsListTerm(t);
return !IsVarTerm(t) && (t == TermNil || IsPairTerm(t));
}
X_API int
@ -2316,7 +2324,7 @@ X_API int PL_next_solution(qid_t qi)
if (setjmp(LOCAL_execution->env))
return 0;
if (qi->state == 0) {
result = YAP_RunGoal(qi->g);
result = YAP_RunGoal(qi->g);
} else {
LOCAL_AllowRestart = qi->open;
result = YAP_RestartGoal();

View File

@ -0,0 +1,29 @@
:- use_module(library(lam_mpi)).
:- initialization(main).
main :-
mpi_init,
writeln(ok1),
mpi_comm_size(N),
writeln(ok2:N),
mpi_comm_rank(Rank),
do_comm(Rank),
mpi_finalize.
do_comm(Rank) :-
between(1,10,I),
NI is I*10,
gen_list(NI,List),
mpi_bcast2(0, List),
mpi_barrier,
format('Rank=~d Msg=~w~n',[Rank,List]),
fail.
do_comm(_).
gen_list(0,[]) :- !.
gen_list(I,[I|List]) :-
I1 is I-1,
gen_list(I1,List).

25
library/range.yap Normal file
View File

@ -0,0 +1,25 @@
/*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: terms.yap *
* Last rev: 5/12/99 *
* mods: *
* comments: Term manipulation operations *
* *
*************************************************************************/
:- module(range, [
euclidean_distance/3,
in_range/4,
in_range/8
]).

View File

@ -230,6 +230,7 @@ A Queue N "queue"
A Quiet N "quiet"
A Radix N "radix"
A Random N "random"
A Range N "range"
A Read N "read"
A Readutil N "readutil"
A RecordedP F "$recordep"
@ -388,6 +389,7 @@ F GNumber Number 1
F GPrimitive Primitive 1
F GVar GVar 1
F GeneratePredInfo GeneratePredInfo 4
F GoalExpansion2 GoalExpansion 2
F GoalExpansion GoalExpansion 3
F HandleThrow HandleThrow 3
F Id Id 1

View File

@ -101,6 +101,10 @@ Term arg_module ARG_MODULE MkAT AtomArg
Term globals_module GLOBALS_MODULE MkAT AtomNb
Term swi_module SWI_MODULE MkAT AtomSwi
Term dbload_module DBLOAD_MODULE MkAT AtomDBLoad
Term range_module RANGE_MODULE MkAT AtomRange
// hidden predicates
Prop hidden_predicates HIDDEN_PREDICATES =NULL RestoreHiddenPredicates()
//
// Module list

View File

@ -471,7 +471,7 @@ init_tout(PL_chars_t *t, size_t len)
{ t->text.t = t->buf;
t->storage = PL_CHARS_LOCAL;
} else
{ t->text.t = PL_malloc(len);
{ t->text.t = PL_malloc(len+1);
t->storage = PL_CHARS_MALLOC;
}
succeed;
@ -480,7 +480,7 @@ init_tout(PL_chars_t *t, size_t len)
{ t->text.w = (pl_wchar_t*)t->buf;
t->storage = PL_CHARS_LOCAL;
} else
{ t->text.w = PL_malloc(len*sizeof(pl_wchar_t));
{ t->text.w = PL_malloc((len+1)*sizeof(pl_wchar_t));
t->storage = PL_CHARS_MALLOC;
}
succeed;

@ -1 +1 @@
Subproject commit a48f0a8a78d48ccb9c51de63d198ac57e6893ba0
Subproject commit 87ea72e5db5844be1bccfac0efb56abdab1d7f84

1
packages/archive Submodule

@ -0,0 +1 @@
Subproject commit 4445c093d08d0693899d8f3a3ac1b0842370d868

@ -1 +1 @@
Subproject commit 36cf4832100adb7b1fd4bd7f15e8e967dbba6855
Subproject commit 75108ca1f119a6fbae3907ce7666e07dc2dcf286

1
packages/odbc Submodule

@ -0,0 +1 @@
Subproject commit 761bb9831f7221207949176de729711d0018e511

View File

@ -1,340 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (c) 2007-2012 Yüce Tekol
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Preamble
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,58 +1,58 @@
PySWIP INSTALL
==============
PySWIP requires SWI-Prolog as a shared library since it uses ctypes to access SWI-Prolog/C functions. The shared library is present in Win32 installer, but missing by default from the builds made directly from the source.
PySWIP requires SWI-Prolog as a shared library since it uses ctypes to access SWI-Prolog/C functions. The shared library is present in the Win32 installer, but missing by default from the builds made directly from the source.
Installing on Linux
-------------------
These instructions are tested on a Linux system, but should also work for POSIX systems. Also, you may want to install development packages for readline and libgmp (not required for basics).
These instructions are tested on a Linux system, but should also work for POSIX systems. Also, you may want to install development packages for readline, libncurses, and libgmp.
You need to do the following to install a shared library enabled version of SWI-Prolog. We use version 5.6.34 of SWI-Prolog but any other recent version should work fine. Please make the necessary modifications for your environment.
You need to do the following to install a shared library enabled version of SWI-Prolog. We use version 6.0.2 of SWI-Prolog. Please make the necessary modifications for your environment.
1) Get the source from: http://www.swi-prolog.org/download.html::
1) Get the source from http://www.swi-prolog.org/download/stable:
$ wget http://gollem.science.uva.nl/cgi-bin/nph-download/SWI-Prolog/pl-5.6.34.tar.gz
$ wget http://www.swi-prolog.org/download/stable/src/pl-6.0.2.tar.gz
2) Extract the archive and cd into it::
2) Extract the archive and cd into it:
$ tar xzvf pl-5.6.34.tar.gz
$ cd pl-5.6.34
$ tar xzvf pl-6.0.2.tar.gz
$ cd pl-6.0.2.tar.gz
3) Configure the source with shared library enabled::
3) Configure the source with shared library enabled:
$ ./configure --prefix=/usr --enable-shared
$ ./configure --enable-shared
*** If using a 64-bit system, you may have to compile with the -ggdb flag in order to get PySWIP to work with SWI-Prolog without segfaults (But not necessarily. YMMV.):
$ CFLAGS=-ggdb ./configure --enable-shared
4) Compile the source::
4) Compile the source:
$ make
5) Install the source::
5) Install the source:
$ sudo make install
6) clp library is useful for constraint handling problems, so let's install that too::
6) *** This is perhaps no longer relevant, as it appears clp is installed by default with SWI-Prolog
clp library is useful for constraint handling problems, so let's install that too:
$ cd cd packages/clpqr
$ ./configure --prefix=/usr --enable-shared
$ ./configure --enable-shared
$ make && make install
7) Create a soft link to ``libpol.so``::
7) If you are not using Python 2.5 or later, you should install ctypes, or get a new version of Python (apt-get is fine if you're using Ubuntu).
$ sudo ln -s /usr/lib/pl-5.6.34/lib/i686-linux/libpl.so.5.6.34 /usr/lib/libpl.so
8) Unpack PySwIP package and install it with, ``python setup.py install``.
8) Next, get and install ctypes from: http://starship.python.net/crew/theller/ctypes . Note that you don't need to install it if you are using Python 2.5.
9) Unpack PySwIP package and install it with, ``python setup.py install``.
10) After you install it, you can test it with the following at your Python shell::
9) After you install it, you can test it with the following at your Python shell::
>>> from pyswip import Prolog
>>> prolog = Prolog()
>>> prolog.assertz("father(michael,john)")
If you get an error, such as "libpl (shared) not found." or "FATAL ERROR: Resource not found" be sure you have installed SWI-Prolog as a share library. Check your default library directory (usually ``/usr/lib``) for ``libpl.so``.
If you get an error, such as "libpl (shared) not found." or "FATAL ERROR: Resource not found" be sure you have installed SWI-Prolog as a shared library. Check your default library directory (usually ``/usr/lib``) for ``libswipl.so``.
Installing on Win32

View File

@ -1,45 +0,0 @@
#
# default base directory for YAP installation
#
#
ROOTDIR = @prefix@
#
# where the binary should be
#
BINDIR = $(ROOTDIR)/bin
#
# where YAP should look for binary libraries
#
LIBDIR=@libdir@
YAPLIBDIR=@libdir@/Yap
#
# where YAP should look for architecture-independent Prolog libraries
#
SHAREDIR=$(ROOTDIR)/share
#
#
# You shouldn't need to change what follows.
#
INSTALL=@INSTALL@
INSTALL_DATA=@INSTALL_DATA@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
srcdir=@srcdir@
YAP_EXTRAS=@YAP_EXTRAS@
install:
(cd $(srcdir); python setup.py install)
clean:
test:
(cd $(srcdir)/examples; python create_term.py)
(cd $(srcdir)/examples; python knowledgebase.py)
(cd $(srcdir)/examples; python knowledgebase.py)
(cd $(srcdir)/examples; python register_foreign.py)
(cd $(srcdir)/examples; python register_foreign_simple.py)
(cd $(srcdir)/examples/coins; python coins.py)
(cd $(srcdir)/examples/draughts; python puzzle1.py)
(cd $(srcdir)/examples/hanoi; python hanoi.py)
(cd $(srcdir)/examples/sendmoremoney; python money.py)
(cd $(srcdir)/examples/sudoku; python sudoku.py)
(cd $(srcdir)/examples/sudoku; python sudoku_daily.py)

View File

@ -5,7 +5,7 @@ PySWIP README
0.2.2
:Author:
Yuce Tekol. <http://www.geocities.com/yucetekol>
Yuce Tekol. <yucetekol@gmail.com>
:Project Website:
http://code.google.com/p/pyswip
@ -14,7 +14,7 @@ PySWIP README
Introduction
------------
PySWIP is a GPL'd Python - SWI-Prolog bridge enabling to query SWI-Prolog in your Python programs. It features an (incomplete) SWI-Prolog foreign language interface, a utility class that makes it easy querying with Prolog and also a Pythonic interface.
PySWIP is a Python - SWI-Prolog bridge enabling to query SWI-Prolog in your Python programs. It features an (incomplete) SWI-Prolog foreign language interface, a utility class that makes it easy querying with Prolog and also a Pythonic interface.
Since PySWIP uses SWI-Prolog as a shared library and ctypes to access it, it doesn't require compilation to be installed.

View File

@ -1,7 +1,7 @@
% Coins -- 2007 by Yuce Tekol <yucetekol@gmail.com>
:- use_module(library('clpfd')).
:- use_module(library(clpfd)).
coins(S, Count, Total) :-
% A=1, B=5, C=10, D=50, E=100

View File

@ -5,7 +5,7 @@ from pyswip.prolog import Prolog
def main():
prolog = Prolog()
a1 = PL_new_term_refs(2)
a2 = a1 + 1
t = PL_new_term_ref()
@ -13,6 +13,7 @@ def main():
animal2 = PL_new_functor(PL_new_atom("animal"), 2)
assertz = PL_new_functor(PL_new_atom("assertz"), 1)
PL_put_atom_chars(a1, "gnu")
PL_put_integer(a2, 50)
#PL_cons_functor(t, animal2, a1, a2)

View File

@ -4,7 +4,7 @@
solve(Board) :-
Board = [NW,N,NE,W,E,SW,S,SE],
domains(Board,0..12),
maplist(in_board(0..12), Board),
sum(Board, #=, 12),
NW + N + NE #= 5,
NE + E + SE #= 5,
@ -12,7 +12,4 @@ solve(Board) :-
SW + S + SE #= 5,
label(Board).
domains([],_).
domains([Pos|Board],D) :-
Pos in D,
domains(Board,D).
in_board(D, V) :- V in D.

View File

@ -17,9 +17,7 @@ call(assertz(parent("gina", "bob")), module=test2)
print "knowledgebase test1"
X = Variable()
print "ok"
q = Query(parent(X, "bob"), module=test1)
print "ok"
while q.nextSolution():
print X.value
q.closeQuery()

View File

@ -2,11 +2,11 @@
% SEND + MORE = MONEY
% Adapted from: http://en.wikipedia.org/wiki/Constraint_programming
:- use_module(library(clpfd)).
:- use_module(library('bounds')).
sendmore(Digits) :-
Digits = [S,E,N,D,M,O,R,Y], % Create variables
allin(Digits, 0..9), % Associate domains to variables
Digits in 0..9, % Associate domains to variables
S #\= 0, % Constraint: S must be different from 0
M #\= 0,
all_different(Digits), % all the elements must take different values
@ -15,8 +15,3 @@ sendmore(Digits) :-
#= 10000*M + 1000*O + 100*N + 10*E + Y,
label(Digits). % Start the search
allin([],_).
allin([Pos|Board],D) :-
Pos in D,
allin(Board,D).

View File

@ -8,7 +8,7 @@
sudoku(Pss) :-
flatten(Pss, Ps),
allin(Ps, 1..9),
maplist(all_in(1..9), Ps),
maplist(all_different, Pss),
Pss = [R1,R2,R3,R4,R5,R6,R7,R8,R9],
columns(R1, R2, R3, R4, R5, R6, R7, R8, R9),
@ -25,7 +25,5 @@ blocks([X1,X2,X3|R1], [X4,X5,X6|R2], [X7,X8,X9|R3]) :-
all_different([X1,X2,X3,X4,X5,X6,X7,X8,X9]),
blocks(R1, R2, R3).
allin([],_).
allin([Pos|Board],D) :-
Pos in D,
allin(Board,D).
all_in(D, Pos) :-
Pos in D.

View File

@ -18,7 +18,7 @@
# MA 02110-1301, USA.
# PySWIP version
__VERSION__ = "0.2.2b"
__VERSION__ = "0.2.2"
from pyswip.prolog import Prolog
from pyswip.easy import *

View File

@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
# pyswip -- Python SWI-Prolog bridge
# (c) 2006-2007 Yüce TEKOL
# (c) 2010-2011 Manuel ROTTER
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@ -17,35 +19,191 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
import sys
import os
import warnings
from subprocess import Popen, PIPE
from ctypes import *
from ctypes.util import find_library
try:
from ctypes import *
except ImportError:
print>>sys.stderr, "A required module: 'ctypes' not found."
sys.exit(1)
def _fixWindowsPath(dll):
"""
When the path to the DLL is not in Windows search path, Windows will not be
able to find other DLLs on the same directory, so we have to add it to the
path. This function takes care of it.
:param dll: File name of the DLL
:type dll: string
"""
if sys.platform[:3] != 'win':
return # Nothing to do here
pathToDll = os.path.dirname(dll)
currentWindowsPath = os.getenv('PATH')
try:
if sys.platform[:3] == "win":
# we're on windows
_lib = CDLL("yap.dll")
elif sys.platform[:3] == "dar":
# we're on Mac OS
_lib = CDLL("libYap.dylib")
else:
# UNIX-like
if pathToDll not in currentWindowsPath:
# We will prepend the path, to avoid conflicts between DLLs
newPath = pathToDll + ';' + currentWindowsPath
os.putenv('PATH', newPath)
def _findYap():
"""
This function makes a big effort to find the path to the SWI-Prolog shared
library. Since this is both OS dependent and installation dependent, we may
not aways succeed. If we do, we return a name/path that can be used by
CDLL(). Otherwise we raise an exception.
:return: Name or path to the library that can be used by CDLL
:rtype: String
:raises ImportError: If we cannot guess the name of the library
"""
# Now begins the guesswork
platform = sys.platform[:3]
# use YAPLIBDIR first
path=os.getenv('YAPLIBDIR')
if path is not None:
if platform == 'lin':
name = 'libYap.so'
elif platform == 'dar':
name = 'libYap.dylib'
path = os.path.join(path, name)
if os.path.exists(path):
return path
# No matter what the platform is, the first try should alway be
# find_library.
path = find_library('Yap') # or find_library('swipl') or find_library('pl')
if path is not None:
return path
if platform == 'win': # In Windows, we have the default installer path and
# the registry to look
dllName = 'yap.dll'
# First try: check the usual installation path (this is faster but
# hardcoded)
programFiles = os.getenv('ProgramFiles')
path = os.path.join(programFiles, r'pl\bin', dllName)
if os.path.exists(path):
return path
# Second try: use reg.exe to find the installation path in the registry
# (reg should be installed in all Windows XPs)
try:
_lib = CDLL("libYap.so")
except IndexError:
# let's try the cwd
_lib = CDLL("./libYap.so")
except OSError:
print>>sys.stderr, "libYap (shared) not found. Possible reasons:"
print>>sys.stderr, "1) YAP has not been installed as a shared library, use --with-java)"
print>>sys.stderr, "1) set LD_LIBRARY_PATH=/usr/local/lib or somewhere elser where libYap.so can be found"
sys.exit(1)
cmd = Popen(['reg', 'query',
r'HKEY_LOCAL_MACHINE\Software\SWI\Prolog',
'/v', 'home'], stdout=PIPE)
ret = cmd.communicate()
# Result is like:
# ! REG.EXE VERSION 3.0
#
# HKEY_LOCAL_MACHINE\Software\SWI\Prolog
# home REG_SZ C:\Program Files\pl
# (Note: spaces are \t in the output)
ret = ret[0].splitlines()
ret = [line for line in ret if len(line) > 0]
data = ret[-1].split('\t')
path = data[-1]
path = os.path.join(path, 'bin', dllName)
if os.path.exists(path):
return path
except OSError:
# reg.exe not found? Weird...
pass
# Last try: maybe it is in the current dir
if os.path.exists(dllName):
return dllName
elif platform == 'lin':
# In Linux we will try some hardcoded paths. find_library will have
# already done almost all we can
paths = ['/lib', '/usr/lib', '/usr/local/lib', '.', './lib']
name = 'libYap.so' #, 'libswipl.so', 'libpl.so']
for path in paths:
path = os.path.join(path, name)
if os.path.exists(path):
return path
spaths=os.getenv('LD_LIBRARY_DIR')
if (spaths):
paths = spaths.split(':')
for path in paths:
path = os.path.join(path, name)
if os.path.exists(path):
return path
elif platform == "dar": # Help with MacOS is welcome!!
paths = ['.', './lib']
names = ['libYap.dylib'] #, 'libswipl.dylib', 'libpl.dylib']
for name in names:
for path in paths:
path = os.path.join(path, name)
if os.path.exists(path):
return path
# Last resource: see if executable is on the path
try: # try to get library path from swipl executable.
cmd = Popen(['yap', '-dump-runtime-variables'], stdout=PIPE)
ret = cmd.communicate()
# Parse the output into a dictionary
ret = ret[0].replace(';', '').splitlines()
ret = [line.split('=', 1) for line in ret]
rtvars = dict((name, value[1:-1]) for name, value in ret)
if rtvars['PLSHARED'] == 'yes':
# determine platform specific path
if platform in ("win", "cyg"):
dllName = rtvars['PLLIB'][:-4] + '.' + rtvars['PLSOEXT']
path = os.path.join(rtvars['PLBASE'],
'bin')
else: # assume UNIX-like
dllName = 'lib' + rtvars['PLLIB'][2:] + '.' + rtvars['PLSOEXT']
path = os.path.join(rtvars['PLBASE'],
'lib',
rtvars['PLARCH'])
fullName = os.path.join(path, dllName)
if os.path.exists(fullName):
return fullName
# If it does not exist, search for a name like dllName in path
files = os.listdir(path)
for f in files:
if dllName in f:
fullName = os.path.join(path, f)
return fullName
else: # PLSHARED="no"
raise ImportError('SWI-Prolog is not installed as a shared library.')
except (OSError, KeyError): # KeyError from accessing rtvars
pass
# This is a catch all raise
raise ImportError('Could not find the SWI-Prolog library in this platform. '
'If you are sure it is installed, please open an issue.')
class c_void(Structure):
_fields_ = [('dummy', c_int)]
c_void_p = POINTER(c_void)
# Load the library
path = _findYap()
_fixWindowsPath(path)
print path
_lib = CDLL(path)
# PySWIP constants
PYSWIP_MAXSTR = 1024
@ -178,13 +336,12 @@ functor_t = c_ulong
PL_atomic_t = c_ulong
foreign_t = c_ulong
pl_wchar_t = c_wchar
atom_t_p = c_void_p
##_lib.PL_initialise(len(sys.argv), _argv)
PL_initialise = _lib.PL_initialise
##PL_initialise.argtypes = [c_int, c_c
PL_initialise.argtypes = [c_int, POINTER(c_char_p)]
PL_open_foreign_frame = _lib.PL_open_foreign_frame
PL_open_foreign_frame.restype = fid_t
@ -210,6 +367,9 @@ PL_discard_foreign_frame.argtypes = [fid_t]
PL_put_list_chars = _lib.PL_put_list_chars
PL_put_list_chars.argtypes = [term_t, c_char_p]
#PL_put_list_chars = _lib.PL_put_list_nchars
#PL_put_list_nchars.argtypes = [term_t, c_size_t, c_char_p]
#PL_EXPORT(void) PL_register_atom(atom_t a);
PL_register_atom = _lib.PL_register_atom
PL_register_atom.argtypes = [atom_t]
@ -230,27 +390,32 @@ PL_functor_arity.argtypes = [functor_t]
# /* Get C-values from Prolog terms */
#PL_EXPORT(int) PL_get_atom(term_t t, atom_t *a);
PL_get_atom = _lib.PL_get_atom
PL_get_atom.argtypes = [term_t, atom_t_p]
PL_get_atom.argtypes = [term_t, POINTER(atom_t)]
PL_get_atom_ex = _lib.PL_get_atom_ex
PL_get_atom_ex.argtypes = [term_t, POINTER(atom_t)]
#PL_EXPORT(int) PL_get_atom_chars(term_t t, char **a);
PL_get_atom_chars = _lib.PL_get_atom_chars
PL_get_atom_chars.argtypes = [term_t, POINTER(c_char_p)]
PL_get_atom_nchars = _lib.PL_get_atom_nchars
PL_get_atom_nchars.argtypes = [term_t, POINTER(c_size_t), POINTER(c_char_p)]
#PL_EXPORT(int) PL_get_bool(term_t t, int *value);
PL_get_bool = _lib.PL_get_bool
PL_get_bool.argtypes = [term_t, c_int_p]
#PL_EXPORT(int) PL_get_atom_chars(term_t t, char **a);
PL_get_atom_chars = _lib.PL_get_atom_chars # FIXME
PL_get_atom_chars.argtypes = [term_t, POINTER(c_char_p)]
PL_get_bool.argtypes = [term_t, POINTER(c_int)]
##define PL_get_string_chars(t, s, l) PL_get_string(t,s,l)
# /* PL_get_string() is depricated */
#PL_EXPORT(int) PL_get_string(term_t t, char **s, size_t *len);
PL_get_string = _lib.PL_get_string_chars
PL_get_string.argtypes = [term_t, POINTER(c_char_p), c_int_p]
PL_get_string_chars = PL_get_string
PL_get_string_chars.argtypes = [term_t, POINTER(c_char_p), c_int_p]
#PL_get_string = _lib.PL_get_string
#PL_get_string_chars = PL_get_string_chars
#PL_get_string_chars.argtypes = [term_t, POINTER(c_char_p), c_int_p]
#PL_EXPORT(int) PL_get_chars(term_t t, char **s, unsigned int flags);
PL_get_chars = _lib.PL_get_chars # FIXME:
PL_get_chars = _lib.PL_get_chars
PL_get_chars.argtypes = [term_t, POINTER(c_char_p), c_uint]
#PL_EXPORT(int) PL_get_list_chars(term_t l, char **s,
@ -264,24 +429,28 @@ PL_get_chars.argtypes = [term_t, POINTER(c_char_p), c_uint]
# unsigned int flags);
#PL_EXPORT(int) PL_get_integer(term_t t, int *i);
PL_get_integer = _lib.PL_get_integer
PL_get_integer.argtypes = [term_t, POINTER(c_int)]
PL_get_integer.argtypes = [term_t, c_int_p]
#PL_EXPORT(int) PL_get_long(term_t t, long *i);
PL_get_long = _lib.PL_get_long
PL_get_long.argtypes = [term_t, POINTER(c_long)]
PL_get_long.argtypes = [term_t, c_long_p]
#PL_EXPORT(int) PL_get_pointer(term_t t, void **ptr);
PL_get_pointer = _lib.PL_get_pointer
PL_get_pointer.argtypes = [term_t, POINTER(c_void_p)]
#PL_EXPORT(int) PL_get_float(term_t t, double *f);
PL_get_float = _lib.PL_get_float
PL_get_float.argtypes = [term_t, c_double_p]
#PL_EXPORT(int) PL_get_functor(term_t t, functor_t *f);
PL_get_functor = _lib.PL_get_functor
#PL_get_functor.argtypes = [term_t, c_ulong]
PL_get_functor.argtypes = [term_t, POINTER(functor_t)]
#PL_EXPORT(int) PL_get_name_arity(term_t t, atom_t *name, int *arity);
PL_get_name_arity = _lib.PL_get_name_arity
PL_get_name_arity.argtypes = [term_t, POINTER(atom_t), c_int_p]
PL_get_name_arity.argtypes = [term_t, POINTER(atom_t), POINTER(c_int)]
#PL_EXPORT(int) PL_get_module(term_t t, module_t *module);
#PL_EXPORT(int) PL_get_arg(int index, term_t t, term_t a);
@ -292,18 +461,24 @@ PL_get_arg.argtypes = [c_int, term_t, term_t]
#PL_EXPORT(int) PL_get_head(term_t l, term_t h);
PL_get_head = _lib.PL_get_head
PL_get_head.argtypes = [term_t, term_t]
#PL_EXPORT(int) PL_get_tail(term_t l, term_t t);
PL_get_tail = _lib.PL_get_tail
PL_get_tail.argtypes = [term_t, term_t]
#PL_EXPORT(int) PL_get_nil(term_t l);
PL_get_nil = _lib.PL_get_nil
PL_get_nil.argtypes = [term_t]
#PL_EXPORT(int) PL_get_term_value(term_t t, term_value_t *v);
#PL_EXPORT(char *) PL_quote(int chr, const char *data);
PL_put_atom_chars = _lib.PL_put_atom_chars
PL_put_atom_chars.argtypes = [term_t, c_char_p]
PL_put_atom_nchars = _lib.PL_put_atom_nchars
PL_put_atom_nchars.argtypes = [term_t, c_size_t, c_char_p]
PL_atom_chars = _lib.PL_atom_chars
PL_atom_chars.argtypes = [atom_t]
PL_atom_chars.restype = c_char_p
@ -330,9 +505,6 @@ PL_copy_term_ref.restype = term_t
PL_get_list = _lib.PL_get_list
PL_get_list.argtypes = [term_t, term_t, term_t]
PL_get_chars = _lib.PL_get_chars
PL_get_chars.argtypes = [term_t, POINTER(c_char_p), c_uint]
PL_close_query = _lib.PL_close_query
PL_close_query.argtypes = [qid_t]
@ -344,13 +516,13 @@ PL_halt = _lib.PL_halt
PL_halt.argtypes = [c_int]
PL_unify_integer = _lib.PL_unify_integer
PL_unify_integer.argtypes = [term_t,c_long]
PL_unify_integer.argtypes = [term_t,c_int]
PL_unify = _lib.PL_unify
PL_unify.argtypes = [term_t,term_t]
PL_unify_arg = _lib.PL_unify_arg
PL_unify.argtypes = [c_int,term_t,atom_t]
PL_unify_arg.argtypes = [c_int,term_t,term_t]
# Verify types
@ -410,6 +582,8 @@ PL_is_number.restype = c_int
#PL_EXPORT(void) PL_put_variable(term_t t);
PL_put_variable = _lib.PL_put_variable
PL_put_variable.argtypes = [term_t]
PL_put_variable.restype = None
#PL_EXPORT(void) PL_put_atom(term_t t, atom_t a);
#PL_EXPORT(void) PL_put_atom_chars(term_t t, const char *chars);
#PL_EXPORT(void) PL_put_string_chars(term_t t, const char *chars);
@ -420,27 +594,39 @@ PL_put_variable.argtypes = [term_t]
#PL_EXPORT(void) PL_put_list_nchars(term_t t, size_t l, const char *chars);
#PL_EXPORT(void) PL_put_list_ncodes(term_t t, size_t l, const char *chars);
#PL_EXPORT(void) PL_put_integer(term_t t, long i);
PL_put_integer = _lib.PL_put_integer
PL_put_integer.argtypes = [term_t, c_long]
PL_put_integer.restype = None
#PL_EXPORT(void) PL_put_pointer(term_t t, void *ptr);
#PL_EXPORT(void) PL_put_float(term_t t, double f);
#PL_EXPORT(void) PL_put_functor(term_t t, functor_t functor);
PL_put_functor = _lib.PL_put_functor
PL_put_functor.argtypes = [term_t, functor_t]
PL_put_functor.restype = None
#PL_EXPORT(void) PL_put_list(term_t l);
PL_put_list = _lib.PL_put_list
PL_put_list.argtypes = [term_t]
PL_put_list.restype = None
#PL_EXPORT(void) PL_put_nil(term_t l);
PL_put_nil = _lib.PL_put_nil
PL_put_nil.argtypes = [term_t]
PL_put_nil.restype = None
#PL_EXPORT(void) PL_put_term(term_t t1, term_t t2);
PL_put_term = _lib.PL_put_term
PL_put_term.argtypes = [term_t,term_t]
PL_put_term.argtypes = [term_t, term_t]
PL_put_term.restype = None
# /* construct a functor or list-cell */
#PL_EXPORT(void) PL_cons_functor(term_t h, functor_t f, ...);
#class _PL_cons_functor(object):
PL_cons_functor = _lib.PL_cons_functor # FIXME:
#PL_cons_functor = _lib.PL_cons_functor # FIXME:
#PL_cons_functor.argtypes = [term_t, functor_t,
#PL_EXPORT(void) PL_cons_functor_v(term_t h, functor_t fd, term_t a0);
PL_cons_functor_v = _lib.PL_cons_functor_v
@ -449,6 +635,7 @@ PL_cons_functor_v.restype = None
#PL_EXPORT(void) PL_cons_list(term_t l, term_t h, term_t t);
PL_cons_list = _lib.PL_cons_list
PL_cons_list.argtypes = [term_t, term_t, term_t]
#
# term_t PL_exception(qid_t qid)
@ -456,9 +643,12 @@ PL_exception = _lib.PL_exception
PL_exception.argtypes = [qid_t]
PL_exception.restype = term_t
#
#func_t = CFUNCTYPE(c_int)
PL_register_foreign = _lib.PL_register_foreign
PL_register_foreign.argtypes = [c_char_p, c_int, c_void_p, c_int]
PL_register_foreign.restype = None
#
#PL_EXPORT(atom_t) PL_new_atom(const char *s);
@ -483,12 +673,11 @@ PL_record.restype = record_t
#PL_EXPORT(void) PL_recorded(record_t record, term_t term);
PL_recorded = _lib.PL_recorded
PL_recorded.argtypes = [record_t,term_t]
PL_recorded.restype = None
#PL_EXPORT(void) PL_erase(record_t record);
PL_erase = _lib.PL_erase
PL_erase.argtypes = [record_t]
PL_erase.restype = None
#
#PL_EXPORT(char *) PL_record_external(term_t t, size_t *size);
#PL_EXPORT(int) PL_recorded_external(const char *rec, term_t term);
@ -580,16 +769,16 @@ IOSTREAM._fields_.extend([("tee",IOSTREAM),
#PL_EXPORT(IOSTREAM *) Sopen_string(IOSTREAM *s, char *buf, size_t sz, const char *m);
#Sopen_string = _lib.Sopen_string
#Sopen_string.argtypes = [POINTER(IOSTREAM), c_char_p, c_size_t, c_char_p]
#Sopen_string.restype = POINTER(IOSTREAM)
Sopen_string = _lib.Sopen_string
Sopen_string.argtypes = [POINTER(IOSTREAM), c_char_p, c_size_t, c_char_p]
Sopen_string.restype = POINTER(IOSTREAM)
#PL_EXPORT(int) Sclose(IOSTREAM *s);
#Sclose = _lib.Sclose
#Sclose.argtypes = [POINTER(IOSTREAM)]
Sclose = _lib.Sclose
Sclose.argtypes = [POINTER(IOSTREAM)]
#PL_EXPORT(int) PL_unify_stream(term_t t, IOSTREAM *s);
#PL_unify_stream = _lib.PL_unify_stream
#PL_unify_stream.argtypes = [term_t, POINTER(IOSTREAM)]
PL_unify_stream = _lib.PL_unify_stream
PL_unify_stream.argtypes = [term_t, POINTER(IOSTREAM)]

78
packages/pyswip/pyswip/easy.py Normal file → Executable file
View File

@ -40,7 +40,8 @@ class Atom(object):
else:
self.handle = handleOrChars
PL_register_atom(self.handle)
self.chars = c_char_p(PL_atom_chars(self.handle)).value
#self.chars = c_char_p(PL_atom_chars(self.handle)).value
self.chars = PL_atom_chars(self.handle)
def fromTerm(cls, term):
"""Create an atom from a Term or term handle."""
@ -48,7 +49,7 @@ class Atom(object):
term = term.handle
a = atom_t()
if PL_get_atom(term, addressof(a)):
if PL_get_atom(term, byref(a)):
return cls(a.value)
fromTerm = classmethod(fromTerm)
@ -115,7 +116,9 @@ class Variable(object):
else:
raise
t = PL_new_term_ref()
if (self.handle == None):
t = PL_new_term_ref()
self.handle = t
fun(self.handle, value)
def get_value(self):
@ -139,7 +142,6 @@ class Variable(object):
#PL_put_variable(term)
self.handle = term
class Functor(object):
__slots__ = "handle","name","arity","args","__value","a0"
func = {}
@ -256,7 +258,7 @@ def getAtomChars(t):
"""If t is an atom, return it as a string, otherwise raise InvalidTypeError.
"""
s = c_char_p()
if PL_get_atom_chars(t, addressof(s)):
if PL_get_atom_chars(t, byref(s)):
return s.value
else:
raise InvalidTypeError("atom")
@ -269,8 +271,8 @@ def getAtom(t):
def getBool(t):
"""If t is of type bool, return it, otherwise raise InvalidTypeError.
"""
b = c_long()
if PL_get_long(t, byref(b)):
b = c_int()
if PL_get_int(t, byref(b)):
return bool(b.value)
else:
raise InvalidTypeError("bool")
@ -278,9 +280,9 @@ def getBool(t):
def getLong(t):
"""If t is of type long, return it, otherwise raise InvalidTypeError.
"""
i = c_long()
if PL_get_long(t, byref(i)):
return i.value
l = c_long()
if PL_get_long(t, byref(l)):
return l.value
else:
raise InvalidTypeError("long")
@ -305,14 +307,22 @@ def getString(t):
else:
raise InvalidTypeError("string")
mappedTerms = {}
def getTerm(t):
global mappedTerms
#print 'mappedTerms', mappedTerms
#if t in mappedTerms:
# return mappedTerms[t]
p = PL_term_type(t)
if p < PL_TERM:
return _getterm_router[p](t)
res = _getterm_router[p](t)
elif PL_is_list(t):
return getList(t)
res = getList(t)
else:
return getFunctor(t)
res = getFunctor(t)
mappedTerms[t] = res
return res
def getList(x):
"""Return t as a list.
@ -339,15 +349,31 @@ _getterm_router = {
PL_TERM:getTerm
}
arities = {}
def _callbackWrapper(arity=1):
return CFUNCTYPE(*([foreign_t] + [term_t]*arity))
global arities
res = arities.get(arity)
if res is None:
res = CFUNCTYPE(*([foreign_t] + [term_t]*arity))
arities[arity] = res
return res
funwraps = {}
def _foreignWrapper(fun):
def wrapper(*args):
args = [getTerm(arg) for arg in args]
r = fun(*args)
return (r is None) and True or r
return wrapper
global funwraps
res = funwraps.get(fun)
if res is None:
def wrapper(*args):
args = [getTerm(arg) for arg in args]
r = fun(*args)
return (r is None) and True or r
res = wrapper
funwraps[fun] = res
return res
cwraps = []
def registerForeign(func, name=None, arity=None, flags=0):
"""Register a Python predicate
@ -358,14 +384,21 @@ def registerForeign(func, name=None, arity=None, flags=0):
``arity``: Arity (number of arguments) of the function. If this value is not
used, ``func.arity`` should exist.
"""
global cwraps
if arity is None:
arity = func.arity
if name is None:
name = func.func_name
return PL_register_foreign(name, arity,
cast(_callbackWrapper(arity)(_foreignWrapper(func)),c_void_p), (flags))
cwrap = _callbackWrapper(arity)
fwrap = _foreignWrapper(func)
fwrap2 = cwrap(fwrap)
cwraps.append(fwrap2)
return PL_register_foreign(name, arity, cast(fwrap2, c_void_p), flags)
# return PL_register_foreign(name, arity,
# _callbackWrapper(arity)(_foreignWrapper(func)), flags)
newTermRef = PL_new_term_ref
@ -416,7 +449,6 @@ class Query(object):
f = Functor.fromTerm(t)
p = PL_pred(f.handle, module)
Query.fid = PL_open_foreign_frame()
Query.qid = PL_open_query(module, flags, p, f.a0)
# def __del__(self):
@ -435,9 +467,7 @@ class Query(object):
def closeQuery():
if Query.qid is not None:
PL_close_query(Query.qid)
PL_discard_foreign_frame(Query.fid)
Query.qid = None
Query.fid = None
closeQuery = staticmethod(closeQuery)

View File

@ -25,10 +25,11 @@ def _initialize():
plargs[0] = "./"
plargs[1] = "-q"
plargs[2] = "-nosignals"
#plargs[2] = "\x00"
PL_initialise(3, plargs)
swipl_fid = PL_open_foreign_frame()
swipl_load = PL_new_term_ref()
PL_chars_to_term("asserta((pyrun(GoalString,BindingList):-atom_codes(A,GoalString),atom_to_term(A,Goal,BindingList),call(Goal))).", swipl_load)
PL_chars_to_term("asserta((pyrun(GoalString,BindingList):-(atom_codes(A,GoalString),atom_to_term(A,Goal,BindingList),call(Goal)))).", swipl_load)
PL_call(swipl_load, None)
PL_discard_foreign_frame(swipl_fid)
_initialize()
@ -63,7 +64,7 @@ class Prolog:
swipl_bindingList = swipl_args + 1
PL_put_list_chars(swipl_goalCharList, query)
swipl_predicate = PL_predicate("pyrun", 2, None)
self.swipl_qid = swipl_qid = PL_open_query(None, plq,
swipl_predicate, swipl_args)
@ -88,7 +89,7 @@ class Prolog:
PL_cut_query(self.swipl_qid)
PL_discard_foreign_frame(self.swipl_fid)
raise PrologError("".join(["Caused by: '", query, "'."]))
def __del__(self):
if not self.error:
PL_close_query(self.swipl_qid)

View File

@ -12,7 +12,7 @@ setup(name="pyswip",
download_url="http://code.google.com/p/pyswip/downloads/list",
author="Yuce Tekol",
author_email="yucetekol@gmail.com",
description="PySWIP enables querying SWI-Prolog and YAP in your Python programs.",
description="PySWIP enables querying SWI-Prolog in your Python programs.",
long_description="""
PySWIP 0.2.2
============

View File

@ -0,0 +1,97 @@
################################################################
# YAP/SWI-Prolog R interface package
# Author: Nicos Angelopoulos
# Copyright: Perl License
################################################################
PACKAGE=python
DOC=python
PKGCFLAGS=@PYTHON_INCLUDES@
include ../Makefile.defs
OBJS= python.o
SOLIBS= python.@SO@
LIBPL= python.pl
all: @PYTHON_TARGET@
pitf: $(SOLIBS)
dummy::
python.@SO@: $(OBJS)
$(LD) $(LDSOFLAGS) -o $@ $(OBJS) $(LIBS) @PYTHON_LIBS@ $(LIBPLSO)
install: install-@PYTHON_TARGET@
install-dummy::
install-pitf: $(SOLIBS) $(addprefix $(srcdir)/, $(LIBPL))
mkdir -p $(DESTDIR)$(SOLIBDIR)
rm -f $(DESTDIR)$(SOLIBDIR)/python.@SO@
$(INSTALL_PROGRAM) $(SOLIBS) $(SOLIBDIR)
mkdir -p $(DESTDIR)$(PLLIBDIR)
for f in $(LIBPL); do \
$(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(PLLIBDIR); \
done
$(MKINDEX)
ln-install::
$(MAKE) INSTALL_DATA="../ln-install" INSTALL_PROGRAM="../ln-install" install
rpm-install: install
html-install::
mkdir -p $(DESTDIR)$(PKGDOC)
$(INSTALL) -m 644 $(DOC).html $(DESTDIR)$(PKGDOC)
pdf-install::
mkdir -p $(DESTDIR)$(PKGDOC)
$(INSTALL) -m 644 $(DOC).pdf $(DESTDIR)$(PKGDOC)
uninstall::
(cd $(SOLIBDIR) && rm -f $(TARGETS))
(cd $(PLBASE)/library && rm -f $(LIBPL))
$(MKINDEX)
################################################################
# Documentation
################################################################
TEXEXTRA= libpython.tex
$(TEX): $(TEXEXTRA)
libpython.tex: python.pl
$(PLTOTEX) --section 'library(python)' --out=$@
################################################################
# Testing
################################################################
check::
(cd $(srcdir) && $(PL) -q -f test_python.pl -g test_python,halt -t 'halt(1)' )
(cd $(srcdir)/examples; python create_term.py)
(cd $(srcdir)/examples; python knowledgebase.py)
(cd $(srcdir)/examples; python knowledgebase.py)
(cd $(srcdir)/examples; python register_foreign.py)
(cd $(srcdir)/examples; python register_foreign_simple.py)
(cd $(srcdir)/examples/coins; python coins.py)
(cd $(srcdir)/examples/draughts; python puzzle1.py)
(cd $(srcdir)/examples/hanoi; python hanoi.py)
(cd $(srcdir)/examples/sendmoremoney; python money.py)
(cd $(srcdir)/examples/sudoku; python sudoku.py)
(cd $(srcdir)/examples/sudoku; python sudoku_daily.py)
################################################################
# Clean
################################################################
clean:
rm -f $(SOLIBS) *~ *.o *% a.out core config.log
distclean: clean
rm -f $(TARGETS) config.cache config.h config.status Makefile
rm -f $(DOC).aux $(DOC).log $(DOC).out $(DOC).toc
rm -rf html
rm -rf autom4te.cache

View File

@ -0,0 +1,22 @@
i = 5
def f(arg=i):
print arg
def multiply(a,b):
print "Will compute", a, "times", b
c = 0
for i in range(0, a):
c = c + b
return c
def square(a,b):
return [a*a,b*b]
def lsquare(a):
print a
b = []
for i in a:
b.append(i*i)
return b

View File

@ -0,0 +1,46 @@
/*
import nltk
sentence = """At eight o'clock on Thursday morning
... Arthur didn't feel very good."""
tokens = nltk.word_tokenize(sentence)
tagged = nltk.pos_tag(tokens)
tagged[0:6]
entities = nltk.chunk.ne_chunk(tagged)
entities
*/
:- use_module(library(python)).
:- use_module(library(maplist)).
main :-
main(Sentence, Tokens, Tagged),
writeln(Sentence),
writeln(tokens=Tokens),
writeln(tagged=Tagged),
fail.
main :-
Sentence = 'Debutta a New York il nuovo sistema operativo (cronaca in diretta). E c\'è il tablet Surface. Svolta radicale che strizza l\'occhio al mondo touch per l\'azienda che controlla il 92% dei pc dal nostro inviato M. Serafini',
% c = nltk.stem.snowball.ItalianStemmer("italian')
$c := nltk:stem:snowball:'ItalianStemmer'(italian),
Tokens := nltk:word_tokenize(Sentence),
writeln(tokens=Tokens),
% o = c.stem('voglio')
maplist(process, Tokens, Stems),
writeln(stems=Stems).
process(In, Out) :-
Out := $c:stem(In),
writeln(In:=Out).
process(In, In).
main(Sentence, Tokens, Tagged) :-
Sentence = '\"At eight o\'clock on Thursday morning\
... Arthur didn\'t feel very good.\"',
Tokens := nltk:word_tokenize(Sentence),
%['At', 'eight', "o'clock", 'on', 'Thursday', 'morning',
% 'Arthur', 'did', "n't", 'feel', 'very', 'good', '.']
Tagged := nltk:pos_tag(Tokens).
%>>> tagged[0:6]
%[('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'),
%('Thursday', 'NNP'), ('morning', 'NN')]

818
packages/python/python.c Normal file
View File

@ -0,0 +1,818 @@
#include <SWI-Stream.h>
#include <SWI-Prolog.h>
#ifdef HAVE_STAT
#undef HAVE_STAT
#endif
#include <Python.h>
#include <assert.h>
static atom_t ATOM_true,
ATOM_false,
ATOM_t;
static functor_t FUNCTOR_dollar1,
FUNCTOR_dir1,
FUNCTOR_iter1,
FUNCTOR_len1,
FUNCTOR_pointer1,
FUNCTOR_complex2,
FUNCTOR_plus2,
FUNCTOR_sub2,
FUNCTOR_mul2,
FUNCTOR_div2,
FUNCTOR_hat2,
FUNCTOR_colon2,
FUNCTOR_equal2;
static PyObject *py_Main;
static inline int
proper_ascii_string(const char *s)
{
unsigned int c;
while ((c = *s++)) {
if (c > 127)
return FALSE;
}
return TRUE;
}
static Py_ssize_t
get_p_int(PyObject *o, Py_ssize_t def) {
if (o == NULL)
return def;
if (PyLong_Check(o)) {
return PyLong_AsLong(o);
} else if (PyInt_Check(o)) {
return PyInt_AsLong(o);
}
return def;
}
static PyObject *
term_to_python(term_t t)
{
// Yap_DebugPlWrite(YAP_GetFromSlot(t)); fprintf(stderr, " here I am\n");
switch (PL_term_type(t)) {
case PL_VARIABLE:
return NULL;
case PL_ATOM:
{
char *s;
if (!PL_get_atom_chars(t, &s)) {
wchar_t *w;
atom_t at;
size_t len;
if (!PL_get_atom(t, &at))
return NULL;
if (!(w = PL_atom_wchars(at, &len)))
return NULL;
return PyUnicode_FromWideChar(w, wcslen(w) );
}
if (proper_ascii_string(s))
return PyString_FromStringAndSize(s, strlen(s) );
else
return PyUnicode_DecodeLatin1(s, strlen(s), NULL);
}
case PL_INTEGER:
{
int64_t j;
if (!PL_get_int64_ex(t, &j))
return NULL;
return PyInt_FromLong(j);
}
case PL_STRING:
{
char *s;
size_t len;
if (!PL_get_string_chars(t, &s, &len))
return NULL;
return PyByteArray_FromStringAndSize(s, len);
}
case PL_FLOAT:
{
double fl;
if (!PL_get_float(t, &fl))
return NULL;
return PyFloat_FromDouble( fl );
}
case PL_TERM:
if (PL_is_list(t)) {
size_t len, i;
term_t tail = PL_new_term_ref(), arg;
PyObject *out;
PL_skip_list(t, tail, &len);
if (!PL_get_nil(tail))
return NULL;
arg = tail;
out = PyList_New(len);
if (!out)
return NULL;
for (i=0; i< len; i++) {
if (!PL_get_list(t, arg, t)) {
return NULL;
}
if (PyList_SetItem(out, i, term_to_python(arg)) < 0)
return NULL;
}
return out;
} else {
functor_t fun;
if (!PL_get_functor(t, &fun))
return NULL;
if (fun == FUNCTOR_dollar1) {
char *s;
term_t targ = PL_new_term_ref();
if (! PL_get_arg(1, t, targ) )
return NULL;
if (!PL_get_atom_chars(targ, &s))
return NULL;
/* return __main__,s */
return PyObject_GetAttrString(py_Main, s);
} else if (fun == FUNCTOR_pointer1) {
void *ptr;
term_t targ = PL_new_term_ref();
if (! PL_get_arg(1, t, targ) )
return NULL;
if (!PL_get_pointer(targ, &ptr))
return NULL;
/* return __main__,s */
return (PyObject *)ptr;
} else if (fun == FUNCTOR_len1) {
term_t targ = PL_new_term_ref();
PyObject *ptr;
if (! PL_get_arg(1, t, targ) )
return NULL;
ptr = term_to_python(targ);
return PyLong_FromLong(PyObject_Length(ptr));
} else if (fun == FUNCTOR_dir1) {
term_t targ = PL_new_term_ref();
PyObject *ptr;
if (! PL_get_arg(1, t, targ) )
return NULL;
ptr = term_to_python(targ);
return PyObject_Dir(ptr);
} else if (fun == FUNCTOR_iter1) {
term_t targ = PL_new_term_ref();
PyObject *ptr;
if (! PL_get_arg(1, t, targ) )
return NULL;
ptr = term_to_python(targ);
return PyObject_GetIter(ptr);
} else if (fun == FUNCTOR_complex2) {
term_t targ = PL_new_term_ref();
PyObject *lhs, *rhs;
double d1, d2;
if (! PL_get_arg(1, t, targ) )
return NULL;
lhs = term_to_python(targ);
if (!PyNumber_Check(lhs))
return NULL;
if (PyFloat_Check(lhs)) {
d1 = PyFloat_AsDouble(lhs);
} else if (PyLong_Check(lhs)) {
d1 = PyLong_AsLong(lhs);
} else if (PyInt_Check(lhs)) {
d1 = PyInt_AsLong(lhs);
} else {
return NULL;
}
if (! PL_get_arg(2, t, targ) )
return NULL;
rhs = term_to_python(targ);
if (!PyNumber_Check(rhs))
return NULL;
if (PyFloat_Check(rhs)) {
d2 = PyFloat_AsDouble(rhs);
} else if (PyLong_Check(rhs)) {
d2 = PyLong_AsLong(rhs);
} else if (PyInt_Check(rhs)) {
d2 = PyInt_AsLong(rhs);
} else {
return NULL;
}
return PyComplex_FromDoubles(d1, d2);
} else if (fun == FUNCTOR_plus2) {
term_t targ = PL_new_term_ref();
PyObject *lhs, *rhs;
if (! PL_get_arg(1, t, targ) )
return NULL;
lhs = term_to_python(targ);
if (! PL_get_arg(2, t, targ) )
return NULL;
rhs = term_to_python(targ);
if (PySequence_Check(lhs) && PySequence_Check(rhs)) {
return PySequence_Concat(lhs, rhs);
}
if (!PyNumber_Check(lhs))
return NULL;
if (!PyNumber_Check(rhs))
return NULL;
return PyNumber_Add(lhs, rhs);
} else if (fun == FUNCTOR_sub2) {
term_t targ = PL_new_term_ref();
PyObject *lhs, *rhs;
if (! PL_get_arg(1, t, targ) )
return NULL;
lhs = term_to_python(targ);
if (!PyNumber_Check(lhs))
return NULL;
if (! PL_get_arg(2, t, targ) )
return NULL;
rhs = term_to_python(targ);
if (!PyNumber_Check(rhs))
return NULL;
return PyNumber_Subtract(lhs, rhs);
} else if (fun == FUNCTOR_mul2) {
term_t targ = PL_new_term_ref();
PyObject *lhs, *rhs;
if (! PL_get_arg(1, t, targ) )
return NULL;
lhs = term_to_python(targ);
if (! PL_get_arg(2, t, targ) )
return NULL;
rhs = term_to_python(targ);
if (PySequence_Check(lhs) && (PyInt_Check(rhs) || PyLong_Check(rhs)) ){
return PySequence_Repeat(lhs, get_p_int(rhs, 0));
}
if (!PyNumber_Check(lhs)+!PyNumber_Check(rhs))
return NULL;
return PyNumber_Multiply(lhs, rhs);
} else if (fun == FUNCTOR_div2) {
term_t targ = PL_new_term_ref();
PyObject *lhs, *rhs;
if (! PL_get_arg(1, t, targ) )
return NULL;
lhs = term_to_python(targ);
if (!PyNumber_Check(lhs))
return NULL;
if (! PL_get_arg(2, t, targ) )
return NULL;
rhs = term_to_python(targ);
if (!PyNumber_Check(rhs))
return NULL;
return PyNumber_Divide(lhs, rhs);
} else if (fun == FUNCTOR_hat2) {
term_t targ = PL_new_term_ref(), trhs = PL_new_term_ref();
PyObject *lhs, *rhs;
if (! PL_get_arg(1, t, targ))
return NULL;
lhs = term_to_python(targ);
if (! PL_get_arg(2, t, targ) || !PL_is_list(targ) || !PL_get_list(targ, trhs, targ) )
return NULL;
if (PL_is_functor(trhs, FUNCTOR_colon2) ) {
Py_ssize_t left, right;
if (!PL_get_arg(1, trhs, targ))
return NULL;
left = get_p_int(term_to_python(targ), 0);
if (!PL_get_arg(2, trhs, targ))
return NULL;
right = get_p_int(term_to_python(targ), PyObject_Size(lhs) );
if (!PySequence_Check(lhs))
return NULL;
return PySequence_GetSlice(lhs, left, right);
} else {
rhs = term_to_python(trhs);
return PyObject_GetItem(lhs, rhs);
}
} else {
atom_t name;
int len;
if (! PL_get_name_arity( t, &name, &len) ) {
return NULL;
}
if (name == ATOM_t) {
term_t targ = PL_new_term_ref();
PyObject *out;
int i;
out = PyTuple_New(len);
if (!out)
return NULL;
for (i=0; i< len; i++) {
if (!PL_get_arg(i+1, t, targ)) {
return NULL;
}
if (PyTuple_SetItem(out, i, term_to_python(targ)) < 0)
return NULL;
}
return out;
}
}
}
return NULL;
}
return NULL;
}
static int
assign_python(PyObject *root, term_t t, PyObject *e)
{
// Yap_DebugPlWrite(YAP_GetFromSlot(t)); fprintf(stderr, " here I am\n");
switch (PL_term_type(t)) {
case PL_VARIABLE:
return -1;
case PL_ATOM:
{
char *s;
if (!PL_get_atom_chars(t, &s)) {
wchar_t *w;
atom_t at;
size_t len;
PyObject *wo;
if (!PL_get_atom(t, &at))
return -1;
if (!(w = PL_atom_wchars(at, &len)))
return -1;
wo = PyUnicode_FromWideChar(w, wcslen(w) );
return PyObject_SetAttr(root, wo, e);
}
if (proper_ascii_string(s)) {
return PyObject_SetAttrString(root, s, e);
} else {
PyObject *wo= PyUnicode_DecodeLatin1(s, strlen(s), NULL);
return PyObject_SetAttr(root, wo, e);
}
}
case PL_INTEGER:
case PL_STRING:
case PL_FLOAT:
return -1;
case PL_TERM:
if (PL_is_list(t)) {
return -1;
} else {
functor_t fun;
if (!PL_get_functor(t, &fun))
return -1;
if (fun == FUNCTOR_dollar1) {
char *s;
if (! PL_get_arg(1, t, t) )
return -1;
if (!PL_get_atom_chars(t, &s)) {
wchar_t *w;
atom_t at;
size_t len;
PyObject *attr;
if (!PL_get_atom(t, &at)) {
return -1;
}
if (!(w = PL_atom_wchars(at, &len)))
return -1;
attr = PyUnicode_FromWideChar(w, wcslen(w) );
if (!attr)
return -1;
return PyObject_SetAttr(py_Main, attr, e);
}
if (proper_ascii_string(s)) {
return PyObject_SetAttrString(py_Main, s, e);
} else {
PyObject *attr= PyUnicode_DecodeLatin1(s, strlen(s), NULL);
if (!attr)
return -1;
return PyObject_SetAttr(py_Main, attr, e);
}
} else if (fun == FUNCTOR_pointer1) {
return -1;
} else if (fun == FUNCTOR_hat2) {
term_t targ = PL_new_term_ref(), trhs = PL_new_term_ref();
PyObject *lhs, *rhs;
if (! PL_get_arg(1, t, targ) )
return -1;
lhs = term_to_python(targ);
if (! PL_get_arg(2, t, targ) || !PL_is_list(targ) || !PL_get_list(targ, trhs, targ ) )
return -1;
if (PL_is_functor(trhs, FUNCTOR_colon2) ) {
Py_ssize_t left, right;
if (!PL_get_arg(1, trhs, targ))
return -1;
left = get_p_int(term_to_python(targ), 0);
if (!PL_get_arg(2, trhs, targ))
return -1;
right = get_p_int(term_to_python(targ), PyObject_Size(lhs) );
if (!PySequence_Check(lhs))
return -1;
return PySequence_SetSlice(lhs, left, right, e);
} else {
rhs = term_to_python(trhs);
return PyObject_SetItem(lhs, rhs, e);
}
}
}
return -1;
}
return -1;
}
static foreign_t
python_to_term(PyObject *pVal, term_t t)
{
if (PyLong_Check(pVal)) {
return PL_unify_int64(t, PyLong_AsLong(pVal));
} else if (PyInt_Check(pVal)) {
return PL_unify_int64(t, PyInt_AsLong(pVal));
} else if (PyBool_Check(pVal)) {
if (PyObject_IsTrue(pVal)) {
return PL_unify_atom(t, ATOM_true);
} else {
return PL_unify_atom(t, ATOM_false);
}
} else if (PyFloat_Check(pVal)) {
return PL_unify_float(t, PyFloat_AsDouble(pVal));
} else if (PyComplex_Check(pVal)) {
term_t to = PL_new_term_ref(), t1= PL_new_term_ref(), t2 = PL_new_term_ref();
if (!PL_put_float(t1, PyComplex_RealAsDouble(pVal) ) ||
!PL_put_float(t2, PyComplex_ImagAsDouble(pVal) ) ||
!PL_cons_functor(to, FUNCTOR_complex2, t1, t2) )
return FALSE;
return PL_unify(t, to);
} else if (PyUnicode_Check(pVal)) {
Py_ssize_t sz = PyUnicode_GetSize(pVal)+1;
wchar_t *ptr;
ptr = malloc(sizeof(wchar_t)*sz);
sz = PyUnicode_AsWideChar((struct PyUnicodeObject *)pVal, ptr, sz-1);
atom_t tmp_atom = PL_new_atom_wchars(sz,ptr);
free(ptr);
return PL_unify_atom(t, tmp_atom);
} else if (PyByteArray_Check(pVal)) {
atom_t tmp_atom = PL_new_atom(PyByteArray_AsString(pVal));
return PL_unify_atom(t, tmp_atom);
} else if (PyString_Check(pVal)) {
atom_t tmp_atom = PL_new_atom(PyString_AsString(pVal));
return PL_unify_atom(t, tmp_atom);
} else if (PyTuple_Check(pVal)) {
Py_ssize_t i, sz = PyTuple_Size(pVal);
functor_t f = PL_new_functor(ATOM_t, sz);
if (!PL_unify_functor(t, f))
return FALSE;
for (i = 0; i < sz; i++) {
term_t to = PL_new_term_ref();
if (!PL_unify_arg(i+1, t, to))
return FALSE;
if ( !python_to_term(PyTuple_GetItem(pVal, i), to) )
return FALSE;
}
return TRUE;
} else if (PyList_Check(pVal)) {
term_t to = PL_new_term_ref();
Py_ssize_t i, sz = PyList_GET_SIZE(pVal);
for (i = 0; i < sz; i++) {
if (!PL_unify_list(t, to, t) ||
!python_to_term(PyList_GetItem(pVal, i), to))
return FALSE;
}
return PL_unify_nil(t);
} else {
term_t to = PL_new_term_ref(), t1 = PL_new_term_ref();
PL_put_pointer(t1, (void *)pVal);
PL_cons_functor(to, FUNCTOR_pointer1, t1);
Py_INCREF(pVal);
return PL_unify(t, to);
}
}
static int
python_import(term_t mname, term_t mod)
{
char *s;
size_t len;
PyObject *pName, *pModule;
if ( !PL_get_nchars(mname, &len, &s, CVT_ALL|CVT_EXCEPTION) ) {
return FALSE;
}
pName = PyString_FromString(s);
if (pName == NULL) {
return FALSE;
}
pModule = PyImport_Import(pName);
// PyErr_Print();
Py_DECREF(pName);
if (pModule == NULL) {
return FALSE;
}
return python_to_term(pModule, mod);
}
static foreign_t
python_f(term_t tmod, term_t fname, term_t tf)
{
char *s;
size_t len;
PyObject *pF, *pModule;
/* if an atom, fetch again */
if ( PL_is_atom(tmod) ) {
PyObject *pName;
if ( !PL_get_nchars(fname, &len, &s, CVT_ALL|CVT_EXCEPTION) ) {
return FALSE;
}
pName = PyString_FromString(s);
if (pName == NULL) {
return FALSE;
}
pModule = PyImport_Import(pName);
} else if (!(pModule = term_to_python(tmod)))
return FALSE;
if ( !PL_get_nchars(fname, &len, &s, CVT_ALL|CVT_EXCEPTION) ) {
return FALSE;
}
pF = PyObject_GetAttrString(pModule, s);
if (pF == NULL || ! PyCallable_Check(pF)) {
return FALSE;
}
return python_to_term(pF, tf);
}
static foreign_t
python_o(term_t tmod, term_t fname, term_t tf)
{
char *s;
size_t len;
PyObject *pO, *pModule;
pModule = term_to_python(tmod);
if ( !PL_get_nchars(fname, &len, &s, CVT_ALL|CVT_EXCEPTION) ) {
return FALSE;
}
pO = PyObject_GetAttrString(pModule, s);
if (pO == NULL) {
return FALSE;
}
return python_to_term(pO, tf);
}
static foreign_t
python_len(term_t tobj, term_t tf)
{
Py_ssize_t len;
PyObject *o;
o = term_to_python(tobj);
if (o == NULL)
return FALSE;
len = PyObject_Length(o);
return PL_unify_int64(tf, len);
}
static foreign_t
python_dir(term_t tobj, term_t tf)
{
PyObject *dir;
PyObject *o;
o = term_to_python(tobj);
if (o == NULL)
return FALSE;
dir = PyObject_Dir(o);
return python_to_term(dir, tf);
}
static foreign_t
python_is(term_t tobj, term_t tf)
{
PyObject *o;
o = term_to_python(tobj);
if (!o)
return FALSE;
return python_to_term(o, tf);
}
static foreign_t
python_apply(term_t tin, term_t targs, term_t tf)
{
PyObject *pF, *pValue;
PyObject *pArgs;
int i, arity, j;
atom_t aname;
foreign_t out;
term_t targ = PL_new_term_ref();
pF = term_to_python(tin);
if ( pF == NULL ) {
return FALSE;
}
if (! PL_get_name_arity( targs, &aname, &arity) ) {
return FALSE;
}
if (PyFunction_Check(pF)) {
int tuple_inited = FALSE;
PyObject *pOpt = NULL;
for (j = arity ; j > 0; j--) {
term_t tsubarg = PL_new_term_ref();
PyObject *pArg;
int posx;
Py_ssize_t pos;
if (! PL_get_arg(j, targs, targ) )
return FALSE;
if (! PL_is_functor(targ, FUNCTOR_equal2) )
break;
if (! PL_get_arg(1, targ, tsubarg) || !PL_get_integer(tsubarg, &posx) )
break;
pos = posx;
if (!tuple_inited) {
if ((pOpt = PyFunction_GetDefaults(pF)) == NULL)
break;
tuple_inited = TRUE;
}
if (! PL_get_arg(2, targ, tsubarg) )
break;
pArg = term_to_python(tsubarg);
if (pArg == NULL)
return FALSE;
/* pArg reference stolen here: */
PyTuple_SetItem(pOpt, pos, pArg);
}
if (tuple_inited) {
if (PyFunction_SetDefaults(pF, pOpt) < 0) {
return FALSE;
}
arity = j;
}
}
pArgs = PyTuple_New(arity);
for (i = 0 ; i < arity; i++) {
PyObject *pArg;
if (! PL_get_arg(i+1, targs, targ) )
return FALSE;
pArg = term_to_python(targ);
if (pArg == NULL)
return FALSE;
/* pArg reference stolen here: */
PyTuple_SetItem(pArgs, i, pArg);
}
if (PyCallable_Check(pF)) {
pValue = PyObject_CallObject(pF, pArgs);
} else {
return FALSE;
}
PyErr_Print();
Py_DECREF(pArgs);
if (pValue == NULL)
return FALSE;
out = 0;
out = python_to_term(pValue, tf);
Py_DECREF(pValue);
return out;
}
static foreign_t
python_assign(term_t name, term_t exp)
{
PyObject *e = term_to_python(exp);
if (e == NULL)
return FALSE;
return assign_python(py_Main, name, e) >= 0;
}
static foreign_t
python_access(term_t obj, term_t f, term_t out)
{
PyObject *o = term_to_python(obj), *pValue, *pArgs, *pF;
atom_t name;
char *s;
int i, arity;
term_t targ = PL_new_term_ref();
if (o == NULL)
return FALSE;
if ( PL_is_atom(f) ) {
if (!PL_get_atom_chars(f, &s))
return FALSE;
if ((pValue = PyObject_GetAttrString(o, s)) == NULL)
return FALSE;
if ( PyCallable_Check(pValue) )
pValue = PyObject_CallObject(pValue, NULL);
PyErr_Print();
return python_to_term(pValue, out);
}
if (! PL_get_name_arity( f, &name, &arity) ) {
return FALSE;
}
s = PL_atom_chars(name);
if ((pF = PyObject_GetAttrString(o, s)) == NULL) {
PyErr_Print();
return FALSE;
}
pArgs = PyTuple_New(arity);
for (i = 0 ; i < arity; i++) {
PyObject *pArg;
if (! PL_get_arg(i+1, f, targ) )
return FALSE;
pArg = term_to_python(targ);
if (pArg == NULL)
return FALSE;
/* pArg reference stolen here: */
PyTuple_SetItem(pArgs, i, pArg);
}
pValue = PyObject_CallObject(pF, pArgs);
if (pValue == NULL) {
Py_DECREF(pArgs);
Py_DECREF(pF);
return FALSE;
}
Py_DECREF(pArgs);
Py_DECREF(pF);
return python_to_term(pValue, out);
}
static foreign_t
python_run_command(term_t cmd)
{
char *s;
size_t len;
if ( PL_get_nchars(cmd, &len, &s, CVT_ALL|CVT_EXCEPTION) ) {
PyRun_SimpleString(s);
return TRUE;
}
return FALSE;
}
static foreign_t
init_python(void)
{
Py_Initialize();
py_Main = PyImport_AddModule("__main__");
return TRUE;
}
static foreign_t
end_python(void)
{
Py_Finalize();
return TRUE;
}
install_t install_python(void);
install_t
install_python(void)
{ // FUNCTOR_dot2 = PL_new_functor(PL_new_atom("."), 2);
// FUNCTOR_equal2 = PL_new_functor(PL_new_atom("="), 2);
// FUNCTOR_boolop1 = PL_new_functor(PL_new_atom("@"), 1);
ATOM_true = PL_new_atom("true");
ATOM_false = PL_new_atom("false");
ATOM_t = PL_new_atom("t");
FUNCTOR_dollar1 = PL_new_functor(PL_new_atom("$"), 1);
FUNCTOR_pointer1 = PL_new_functor(PL_new_atom("__obj__"), 1);
FUNCTOR_dir1 = PL_new_functor(PL_new_atom("dir"), 1);
FUNCTOR_iter1 = PL_new_functor(PL_new_atom("iter"), 1);
FUNCTOR_len1 = PL_new_functor(PL_new_atom("len"), 1);
FUNCTOR_complex2 = PL_new_functor(PL_new_atom("complex"), 2);
FUNCTOR_plus2 = PL_new_functor(PL_new_atom("+"), 2);
FUNCTOR_sub2 = PL_new_functor(PL_new_atom("-"), 2);
FUNCTOR_mul2 = PL_new_functor(PL_new_atom("*"), 2);
FUNCTOR_div2 = PL_new_functor(PL_new_atom("/"), 2);
FUNCTOR_hat2 = PL_new_functor(PL_new_atom("^"), 2);
FUNCTOR_colon2 = PL_new_functor(PL_new_atom(":"), 2);
FUNCTOR_equal2 = PL_new_functor(PL_new_atom("="), 2);
PL_register_foreign("init_python", 0, init_python, 0);
PL_register_foreign("end_python", 0, end_python, 0);
PL_register_foreign("python_import", 2, python_import, 0);
PL_register_foreign("python_f", 3, python_f, 0);
PL_register_foreign("python_o", 3, python_o, 0);
PL_register_foreign("python_len", 2, python_len, 0);
PL_register_foreign("python_is", 2, python_is, 0);
PL_register_foreign("python_dir", 2, python_dir, 0);
PL_register_foreign("python_apply", 3, python_apply, 0);
PL_register_foreign("python_access", 3, python_access, 0);
PL_register_foreign("python_assign", 2, python_assign, 0);
PL_register_foreign("python_run_command", 1, python_run_command, 0);
}

178
packages/python/python.pl Normal file
View File

@ -0,0 +1,178 @@
%%% -*- Mode: Prolog; -*-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Author: Vitor Santos Costa
% E-mail: vsc@dcc.fc.up.pt
% Copyright (C): Universidade do Porto
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This file is part of the YAP Python Interface
% distributed according to Perl Artistic License
% check LICENSE file for distribution license
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/** <module> python
A C-based Prolog interface to python.
@author Vitor Santos Costa
@version 0:0:5, 2012/10/8
@license Perl Artistic License
*/
%%%
:- module(python, [
init_python/0,
end_python/0,
python_command/1,
python_assign/3,
python_import/1,
python/2,
op(100,fy,$),
op(950,fy,:=),
op(950,yfx,:=),
(:=)/2,
(:=)/1
]).
/************************************************************************************************************
Python interface
Data types are
Python Prolog
string atoms
numbers numbers
lists lists
tuples t(...)
generic objs __pointer__(Address)
$var refers to the attribute __main__.var
*************************************************************************************************************/
:- use_module(library(shlib)).
:- use_module(library(lists)).
:- use_module(library(apply_macros)).
:- use_module(library(charsio)).
:- dynamic python_mref_cache/2.
:= F :- python(F,_).
V := F :- var(V), !, python(F,V).
A := F :- python(F, F1), python_assign(A, F1).
python_import(Module) :-
python_do_import(Module, _).
python_do_import(Module, MRef) :-
python_mref_cache(Module, MRef), !.
python_do_import(Module, MRef) :-
python_import(Module, MRef),
assert( python_mref_cache(Module, MRef) ).
fetch_module(M:E, M1, E1, MRef) :-
atom(M),
python_import(M, MRef0),
module_extend(M, E, M1, E1, MRef0, MRef).
%
% extend the module as much as we can.
%
module_extend(M0, M:E, MF, EF, MRef0, MRef) :-
atom(M),
atom_concat([M0,'.',M], MM),
python_import(MM, MRef1), !,
module_extend(MM, E, MF, EF, MRef1, MRef).
module_extend(M, E, M, E, MRef, MRef).
% given an object, detect its len method
python_eval_term(Expression, O) :-
fetch_module(Expression, Module, Exp, MRef), !,
(
atom(Exp)
->
python_access(MRef, Exp, O)
;
functor(Exp, F, _),
python_f(MRef, F, FRef),
python_check_args(FRef, Exp, NExp),
python_apply(FRef, NExp, O)
).
python_eval_term(Obj:Field, O) :-
python_access(Obj, Field, O).
python_check_args(FRef, Exp, NExp) :-
functor(Exp, _, Arity),
arg(Arity, Exp, _=_), !,
fetch_args(FRef, Dict),
Exp =.. [F|LArgs],
match_args(LArgs, Dict, NLArgs, _),
NExp =.. [F|NLArgs].
python_check_args(FRef, Exp, NExp).
fetch_args(FRef, Args) :-
python_import('inspect', M),
python_f(M, getargspec, F),
python_apply(F, getargspec(FRef), ExtraArgs),
ExtraArgs=t(Args, _, _, _).
match_args([], _, [], ok).
match_args([A=V|LArgs], Dict, [I=V|NLArgs], OK) :-
match_args(LArgs, Dict, NLArgs, ok), !,
( nth0(I, Dict, A) -> true ; throw(type_error(argument(A=V))) ).
match_args([A|LArgs], Dict, [A|NLArgs], not_ok) :-
match_args(LArgs, Dict, NLArgs, _).
python(Obj, Out) :-
python_eval_term(Obj, Out), !.
python(Obj, OArg) :-
python_do_is(Obj, Obj1),
python_is(Obj1, OArg).
python_do_is(A+B, NA+NB) :- !,
python_do_is(A, NA),
python_do_is(B, NB).
python_do_is(A-B, NA-NB) :- !,
python_do_is(A, NA),
python_do_is(B, NB).
python_do_is(A*B, NA*NB) :- !,
python_do_is(A, NA),
python_do_is(B, NB).
python_do_is(A/B, NA/NB) :- !,
python_do_is(A, NA),
python_do_is(B, NB).
python_do_is(A, NA) :-
python_eval_term(A, NA), !.
python_do_is(A, A).
python_command(Cmd) :-
python_run_command(Cmd).
start_python :-
use_foreign_library(foreign(python)),
init_python,
python_command('import sys'),
python_command('import inspect').
add_cwd_to_python :-
unix(getcwd(Dir)),
atom_concat(['sys.path.append(\"',Dir,'\")'], Command),
python_command(Command),
python_command("sys.argv = [\"yap\"]").
% done
python_assign(Name, Exp, '$'(Name)) :-
python_assign(Name, Exp).
:- initialization(start_python, now).
:- initialization(add_cwd_to_python).

@ -1 +1 @@
Subproject commit d0118006ebb4e9afe6eb23d0cff46fec56d76a12
Subproject commit 4d3759739bd256a5a2d0c75ae4921c9147ad5d30

View File

@ -628,21 +628,22 @@ true :- true.
'$write_vars_and_goals'(NLAnsw, first, FLAnsw).
'$purge_dontcares'([],[]).
'$purge_dontcares'([[[95|_]|_]|Vs],NVs) :- !,
'$purge_dontcares'([Name=_|Vs],NVs) :-
atom_codes(Name, [C|_]), C is "_", !,
'$purge_dontcares'(Vs,NVs).
'$purge_dontcares'([V|Vs],[V|NVs]) :-
'$purge_dontcares'(Vs,NVs).
'$prep_answer_var_by_var'([], L, L).
'$prep_answer_var_by_var'([[Name|Value]|L], LF, L0) :-
'$prep_answer_var_by_var'([Name=Value|L], LF, L0) :-
'$delete_identical_answers'(L, Value, NL, Names),
'$prep_answer_var'([Name|Names], Value, LF, LI),
'$prep_answer_var_by_var'(NL, LI, L0).
% fetch all cases that have the same solution.
'$delete_identical_answers'([], _, [], []).
'$delete_identical_answers'([[Name|Value]|L], Value0, FL, [Name|Names]) :-
'$delete_identical_answers'([(Name=Value)|L], Value0, FL, [Name|Names]) :-
Value == Value0, !,
'$delete_identical_answers'(L, Value0, FL, Names).
'$delete_identical_answers'([VV|L], Value0, [VV|FL], Names) :-
@ -678,11 +679,11 @@ true :- true.
'$write_goal_output'(var([V|VL]), First, [var([V|VL])|L], next, L) :- !,
( First = first -> true ; format(user_error,',~n',[]) ),
format(user_error,'~s',[V]),
format(user_error,'~a',[V]),
'$write_output_vars'(VL).
'$write_goal_output'(nonvar([V|VL],B), First, [nonvar([V|VL],B)|L], next, L) :- !,
( First = first -> true ; format(user_error,',~n',[]) ),
format(user_error,'~s',[V]),
format(user_error,'~a',[V]),
'$write_output_vars'(VL),
format(user_error,' = ', []),
( recorded('$print_options','$toplevel'(Opts),_) ->
@ -902,7 +903,7 @@ not(G) :- \+ '$execute'(G).
'$call'(G, CP, G0, CurMod) :-
( '$is_expand_goal_or_meta_predicate'(G,CurMod) ->
(
'$notrace'(user:goal_expansion(G, CurMod, NG)) ->
'$notrace'(('$pred_exists'(goal_expansion(G,NG), CurMod), CurMod:goal_expansion(G,NG) ; system:goal_expansion(G,NG) ; user:goal_expansion(G, CurMod, NG) ; user:goal_expansion(G,NG) )) ->
'$call'(NG, CP, G0,CurMod)
;
% repeat other code.

View File

@ -614,7 +614,7 @@ debugging :-
fail.
'$action'(0'A,_,_,_,_,_) :- !, % 'b break
'$skipeol'(0'A),
'$show_choicepoint_stack',
'$stack_dump',
fail.
'$action'(0'c,_,_,_,_,on) :- !, % 'c creep
'$skipeol'(0'c),
@ -719,7 +719,7 @@ debugging :-
% do not need to debug!
'$continue_debugging'(_,G) :-
'nb_getval'('$debug_run',Zip),
(Zip == nodebug ; number(Zip) ; Zip = spy(_) ), !,
(Zip == nodebug ; number(Zip) ; Zip == spy ), !,
'$execute_dgoal'(G).
'$continue_debugging'(_,G) :-
'$execute_creep_dgoal'(G).
@ -873,44 +873,6 @@ debugging :-
'$delete_if_there'([Q|L], T, [Q|LN]) :-
'$delete_if_there'(L, T, LN).
'$show_choicepoint_stack' :-
yap_hacks:current_choicepoints(Cps),
length(Cps,Level),
'$debug_show_cps'(Cps,Level).
'$debug_show_cps'([],_).
'$debug_show_cps'([C|Cps],Level) :-
'$debug_show_cp'(C, Level),
Level1 is Level-1,
'$debug_show_cps'(Cps, Level1).
'$debug_show_cp'(C, Level) :-
yap_hacks:choicepoint(C,_,Module,Name,Arity,Goal,_),
'$continue_debug_show_cp'(Module,Name,Arity,Goal,Level).
'$continue_debug_show_cp'(prolog,'$do_live',0,(_;_),Level) :- !,
format(user_error,' [~d] \'$toplevel\'',[Level]).
'$continue_debug_show_cp'(prolog,'$do_log_upd_clause',4,'$do_log_upd_clause'(_,_,Goal,_),Level) :- !,
format(user_error,' [~d] ',[Level]),
'$debugger_write'(user_error,Goal),
nl(user_error).
'$continue_debug_show_cp'(prolog,'$do_static_clause',5,'$do_static_clause'(_,_,Goal,_,_),Level) :- !,
format(user_error,' [~d] ',[Level]),
'$debugger_write'(user_error,Goal),
nl(user_error).
'$continue_debug_show_cp'(Module,Name,Arity,_,_) :-
functor(G0, Name, Arity),
'$hidden_predicate'(G0,Module),
!.
'$continue_debug_show_cp'(Module,Name,Arity,Goal,Level) :-
var(Goal), !,
format(user_error,' [~d] ~q:~q/~d~n',[Level,Module,Name,Arity]).
'$continue_debug_show_cp'(Module,Name,Arity,(V1;V2),Level) :-
var(V1), var(V2), !,
format(user_error,' [~d] ~q:~q/~d: ;/2~n',[Level,Module,Name,Arity]).
'$continue_debug_show_cp'(_,_,_,G,Level) :-
format(user_error,' [~d] ~q~n',[Level,G]).
'$debugger_deterministic_goal'(G) :-
yap_hacks:current_choicepoints(CPs0),
% $cps(CPs0),

View File

@ -647,7 +647,7 @@ yap_flag(update_semantics,X) :-
yap_flag(toplevel_hook,G) :-
var(G), !,
( recorded('$toplevel_hooks',G,_) -> G ; G = false ).
( recorded('$toplevel_hooks',G,_) -> G ; G = fail ).
yap_flag(toplevel_hook,G) :- !,
'$set_toplevel_hook'(G).

Some files were not shown because too many files have changed in this diff Show More