android debugging plus clean-ups

This commit is contained in:
Vítor Santos Costa 2015-04-13 13:28:17 +01:00
parent d1a230eb56
commit ef586e264e
77 changed files with 2346 additions and 4054 deletions

View File

@ -3,7 +3,7 @@
* Yap Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* \z *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************

View File

@ -6518,7 +6518,7 @@ p_nth_instance( USES_REGS1 )
}
CurSlot = Yap_StartSlots( );
/* I have pe and n */
sl4 = Yap_InitSlot( ARG4 PASS_REGS );
sl4 = Yap_InitSlot( ARG4 );
/* in case we have to index or to expand code */
for (i = 1; i <= pe->ArityOfPE; i++) {
XREGS[i] = MkVarTerm();
@ -6527,7 +6527,7 @@ p_nth_instance( USES_REGS1 )
IPred(pe, 0, CP);
}
cl0 = Yap_NthClause(pe, Count);
ARG4 = Yap_GetFromSlot( sl4 PASS_REGS );
ARG4 = Yap_GetFromSlot( sl4 );
LOCAL_CurSlot = CurSlot;
if (cl0 == NULL) {
UNLOCK(pe->PELock);
@ -6761,4 +6761,3 @@ Yap_InitCdMgr(void)
Yap_InitCPred("$predicate_live_cps", 4, p_predicate_lu_cps, 0L);
#endif
}

View File

@ -20,7 +20,7 @@
}
s = name->StrOfAE;
__android_log_print(ANDROID_LOG_INFO, "YAP", " %s ", s);
LOG( " %s ", s);
#endif
check_trail(TR);
if (!(PREG->y_u.Osbpp.p->PredFlags & (SafePredFlag|NoTracePredFlag|HiddenPredFlag))) {

View File

@ -574,7 +574,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
rd->varnames = 0;
rd->singles = 0;
return Yap_unify_constant( Yap_GetFromSlot( t0 PASS_REGS), MkAtomTerm (AtomEof));
return Yap_unify_constant( Yap_GetFromSlot( t0), MkAtomTerm (AtomEof));
}
}
repeat_cycle:
@ -620,7 +620,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
rd->has_exception = TRUE;
rd->exception = Yap_InitSlot(terror PASS_REGS);
rd->exception = Yap_InitSlot(terror);
CurrentModule = OCurrentModule;
return FALSE;
}
@ -630,9 +630,9 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
break;
}
}
if (!Yap_unify(t, Yap_GetFromSlot( t0 PASS_REGS)))
if (!Yap_unify(t, Yap_GetFromSlot( t0)))
return FALSE;
if (store_comments && !Yap_unify(LOCAL_Comments, Yap_GetFromSlot( rd->comments PASS_REGS)))
if (store_comments && !Yap_unify(LOCAL_Comments, Yap_GetFromSlot( rd->comments )))
return FALSE;
if (rd->varnames) {
Term v;
@ -656,7 +656,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
}
}
LOCAL_VarNames = v;
if (!Yap_unify(v, Yap_GetFromSlot( rd->varnames PASS_REGS ))) {
if (!Yap_unify(v, Yap_GetFromSlot( rd->varnames ))) {
CurrentModule = OCurrentModule;
return FALSE;
}
@ -683,7 +683,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
TR = old_TR;
}
}
if (!Yap_unify(v, Yap_GetFromSlot( rd->variables PASS_REGS ) )) {
if (!Yap_unify(v, Yap_GetFromSlot( rd->variables ) )) {
CurrentModule = OCurrentModule;
return FALSE;
}
@ -711,11 +711,11 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
}
if (rd->singles == 1) {
if (IsPairTerm(v))
rd->singles = Yap_InitSlot( v PASS_REGS);
rd->singles = Yap_InitSlot( v );
else
rd->singles = FALSE;
} else if (rd->singles) {
if (!Yap_unify( v, Yap_GetFromSlot( rd->singles PASS_REGS ))) {
if (!Yap_unify( v, Yap_GetFromSlot( rd->singles ))) {
CurrentModule = OCurrentModule;
return FALSE;
}

View File

@ -848,7 +848,7 @@ case Var_tok:
tn = Yap_MkNewApplTerm(SWIFunctorToFunctor(FUNCTOR_quasi_quotation4), 4);
tnp = RepAppl(tn) + 1;
tnp[0] = MkAtomTerm(at);
if (!get_quasi_quotation(Yap_InitSlot(ArgOfTerm(2, tn) PASS_REGS),
if (!get_quasi_quotation(Yap_InitSlot(ArgOfTerm(2, tn)),
&qq->text,
qq->text + strlen((const char *)qq->text), rd))
FAIL;
@ -857,7 +857,7 @@ case Var_tok:
intptr_t qqend = qq->end.charno;
// set_range_position(positions, -1, qqend PASS_LD);
if (!PL_unify_term(Yap_InitSlot(ArgOfTerm(2, t) PASS_REGS), PL_FUNCTOR,
if (!PL_unify_term(Yap_InitSlot(ArgOfTerm(2, t) ), PL_FUNCTOR,
FUNCTOR_minus2, PL_INTPTR,
qq->mid.charno + 2, /* end of | token */
PL_INTPTR, qqend - 2)) /* end minus "|}" */
@ -865,12 +865,12 @@ case Var_tok:
}
tnp[2] =
Yap_GetFromSlot(rd->varnames PASS_REGS); /* Arg 3: the var dictionary */
Yap_GetFromSlot(rd->varnames); /* Arg 3: the var dictionary */
/* Arg 4: the result */
t = ArgOfTerm(4, tn);
if (!(to = PL_new_term_ref()) ||
!PL_unify_list(rd->qq_tail, to, rd->qq_tail) ||
!PL_unify(to, Yap_InitSlot(tn PASS_REGS)))
!PL_unify(to, Yap_InitSlot(tn )))
FAIL;
}
NextToken;

View File

@ -208,7 +208,7 @@ int
valueExpression(term_t t, Number r ARG_LD)
{
REGS_FROM_LD
YAP_Term t0 = Yap_Eval(Yap_GetFromSlot(t PASS_REGS) PASS_REGS);
YAP_Term t0 = Yap_Eval(Yap_GetFromSlot(t ) PASS_REGS);
if (YAP_IsIntTerm(t0)) {
r->type = V_INTEGER;
r->value.i = YAP_IntOfTerm(t0);
@ -313,7 +313,7 @@ _PL_unify_atomic(term_t t, PL_atomic_t a)
{
GET_LD
if (IsApplTerm(a) || IsAtomTerm(a))
return Yap_unify(Yap_GetFromSlot(t PASS_REGS), a);
return Yap_unify(Yap_GetFromSlot(t ), a);
return PL_unify_atom(t, a);
}
@ -321,7 +321,7 @@ int
_PL_unify_string(term_t t, word w)
{
CACHE_REGS
return Yap_unify(Yap_GetFromSlot(t PASS_REGS), w);
return Yap_unify(Yap_GetFromSlot(t ), w);
}
Atom lookupAtom(const char *s, size_t len)
@ -863,7 +863,7 @@ Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int
yhandle_t CurSlot = Yap_StartSlots();
Yap_StartSlots( );
l = Yap_InitSlot(t PASS_REGS );
l = Yap_InitSlot(t );
{ IOENC encodings[3];
IOENC *enc;
@ -935,22 +935,15 @@ Yap_HandleToString(term_t l, size_t sz, size_t *length, int *encoding, int flags
size_t size = 4096, total = size;
IOSTREAM *fd;
total = size;
total = size+1;
buf = malloc(total);
#ifdef DEBUG
{CACHE_REGS
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "text %p \n", buf);}
#endif
buf[0]='\0';
while ( (fd = Sopenmem(&buf, &size, "w")) == NULL ||
(( fd->encoding = ENC_UTF8) && FALSE) ||
(PL_write_term(fd, l, 1200, flags) == 0) ||
Sputcode(EOS, fd) < 0 ||
Sflush(fd) < 0 ) /* failure */
{
#ifdef DEBUG
{CACHE_REGS
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "fd %p, %x buf=%s\n", fd, LOCAL_SlotBase[28], buf);}
#endif
Sclose(fd);
if (!fd)
return NULL;
@ -960,10 +953,6 @@ Yap_HandleToString(term_t l, size_t sz, size_t *length, int *encoding, int flags
return NULL;
Sclose(fd);
}
#ifdef DEBUG
{CACHE_REGS
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "text done %s", buf);}
#endif
Sclose(fd);
/* success */
return buf;
@ -1082,7 +1071,7 @@ PL_dispatch(int fd, int wait)
X_API int _PL_get_arg__LD(int index, term_t ts, term_t a ARG_LD)
{
REGS_FROM_LD
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
if ( !YAP_IsApplTerm(t) ) {
if (YAP_IsPairTerm(t)) {
if (index == 1){
@ -1104,7 +1093,7 @@ X_API int _PL_get_arg__LD(int index, term_t ts, term_t a ARG_LD)
int PL_get_atom__LD(term_t ts, atom_t *a ARG_LD)
{
REGS_FROM_LD
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
if ( !IsAtomTerm(t))
return 0;
*a = YAP_SWIAtomFromAtom(AtomOfTerm(t));
@ -1121,42 +1110,42 @@ X_API int PL_put_atom__LD(term_t t, atom_t a ARG_LD)
int PL_put_term__LD(term_t d, term_t s ARG_LD)
{
REGS_FROM_LD
Yap_PutInSlot(d,Yap_GetFromSlot(s PASS_REGS) PASS_REGS);
Yap_PutInSlot(d,Yap_GetFromSlot(s) PASS_REGS);
return 1;
}
term_t PL_new_term_ref__LD(ARG1_LD)
{
REGS_FROM_LD
term_t to = Yap_NewSlots(1 PASS_REGS);
term_t to = Yap_NewSlots(1);
return to;
}
int PL_is_atom__LD(term_t ts ARG_LD)
{
REGS_FROM_LD
Term t = Yap_GetFromSlot(ts PASS_REGS);
Term t = Yap_GetFromSlot(ts);
return !IsVarTerm(t) && IsAtomTerm(t);
}
int PL_is_variable__LD(term_t ts ARG_LD)
{
REGS_FROM_LD
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
return IsVarTerm(t);
}
X_API int PL_unify__LD(term_t t1, term_t t2 ARG_LD)
{
REGS_FROM_LD
return Yap_unify(Yap_GetFromSlot(t1 PASS_REGS),Yap_GetFromSlot(t2 PASS_REGS));
return Yap_unify(Yap_GetFromSlot(t1),Yap_GetFromSlot(t2));
}
int PL_unify_atom__LD(term_t t, atom_t at ARG_LD)
{
REGS_FROM_LD
YAP_Term cterm = MkAtomTerm(YAP_AtomFromSWIAtom(at));
return YAP_Unify(Yap_GetFromSlot(t PASS_REGS),cterm);
return YAP_Unify(Yap_GetFromSlot(t),cterm);
}
/* SWI: int PL_unify_integer(term_t ?t, long n)
@ -1165,7 +1154,7 @@ int PL_unify_integer__LD(term_t t, intptr_t i ARG_LD)
{
REGS_FROM_LD
Term iterm = MkIntegerTerm(i);
return Yap_unify(Yap_GetFromSlot(t PASS_REGS),iterm);
return Yap_unify(Yap_GetFromSlot(t),iterm);
}
/* SWI: int PL_unify_integer(term_t ?t, long n)
@ -1175,7 +1164,7 @@ X_API int PL_unify_int64__LD(term_t t, int64_t n ARG_LD)
REGS_FROM_LD
#if SIZEOF_INT_P==8
Term iterm = MkIntegerTerm(n);
return Yap_unify(Yap_GetFromSlot(t PASS_REGS),iterm);
return Yap_unify(Yap_GetFromSlot(t),iterm);
#elif USE_GMP
YAP_Term iterm;
char s[64];
@ -1190,7 +1179,7 @@ X_API int PL_unify_int64__LD(term_t t, int64_t n ARG_LD)
#endif
mpz_init_set_str (&rop, s, 10);
iterm = YAP_MkBigNumTerm((void *)&rop);
return YAP_Unify(Yap_GetFromSlot(t PASS_REGS),iterm);
return YAP_Unify(Yap_GetFromSlot(t),iterm);
#else
if ((long)n == n)
return PL_unify_integer(t, n);

View File

@ -77,7 +77,8 @@ Yap_AlwaysAllocCodeSpace(UInt size)
static void
QLYR_ERROR(qlfr_err_t my_err)
{
Yap_Error(SAVED_STATE_ERROR,TermNil,"error %s in saved state %s",GLOBAL_RestoreFile, qlyr_error[my_err]);
// __android_log_print(ANDROID_LOG_INFO, "YAP ", "error %s in saved state %s",GLOBAL_RestoreFile, qlyr_error[my_err]);
Yap_Error(SAVED_STATE_ERROR,TermNil,"error %s in saved state %s",GLOBAL_RestoreFile, qlyr_error[my_err]);
Yap_exit(1);
}
@ -95,6 +96,7 @@ LookupAtom(Atom oat)
}
a = a->next;
}
// __android_log_print(ANDROID_LOG_INFO, "YAP ", "error %p in saved state ", oat);
QLYR_ERROR(UNKNOWN_ATOM);
return NIL;
}
@ -900,9 +902,9 @@ ReadHash(IOSTREAM *stream)
}
static void
read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, UInt flags) {
read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, pred_flags_t flags) {
CACHE_REGS
if (pp->PredFlags & LogUpdatePredFlag) {
if (flags & LogUpdatePredFlag) {
/* first, clean up whatever was there */
if (pp->cs.p_code.NOfClauses) {
LogUpdClause *cl;
@ -934,7 +936,7 @@ read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, UInt flags) {
RestoreLUClause(cl, pp PASS_REGS);
Yap_AssertzClause(pp, cl->ClCode);
}
} else if (pp->PredFlags & MegaClausePredFlag) {
} else if (flags & MegaClausePredFlag) {
CACHE_REGS
char *base = (void *)read_UInt(stream);
UInt mask = read_UInt(stream);
@ -964,7 +966,7 @@ read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, UInt flags) {
/* This must be set for restoremegaclause */
pp->cs.p_code.NOfClauses = nclauses;
RestoreMegaClause(cl PASS_REGS);
} else if (pp->PredFlags & DynamicPredFlag) {
} else if (flags & DynamicPredFlag) {
UInt i;
for (i = 0; i < nclauses; i++) {
@ -983,7 +985,7 @@ read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, UInt flags) {
UInt i;
if (pp->PredFlags & SYSTEM_PRED_FLAGS) {
if (flags & SYSTEM_PRED_FLAGS) {
if (nclauses) {
QLYR_ERROR(INCONSISTENT_CPRED);
}
@ -1005,8 +1007,8 @@ read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, UInt flags) {
static void
read_pred(IOSTREAM *stream, Term mod) {
UInt flags;
UInt nclauses, fl1;
pred_flags_t flags, fl1;
UInt nclauses;
PredEntry *ap;
ap = LookupPredEntry((PredEntry *)read_UInt(stream));
@ -1015,17 +1017,24 @@ read_pred(IOSTREAM *stream, Term mod) {
if (ap->PredFlags & IndexedPredFlag) {
Yap_RemoveIndexation(ap);
}
/* if (ap->ArityOfPE && ap->ModuleOfPred != IDB_MODULE) */
#if 0
if (ap->ArityOfPE && ap->ModuleOfPred != IDB_MODULE)
__android_log_print(ANDROID_LOG_INFO, "YAP ", " %s/%ld %lx\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE, ap->ArityOfPE, flags);
/* printf(" %s/%ld %lx\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE, ap->ArityOfPE, flags); */
/* else if (ap->ModuleOfPred != IDB_MODULE) */
else if (ap->ModuleOfPred != IDB_MODULE)
__android_log_print(ANDROID_LOG_INFO, "YAP "," %s/%ld %lx\n", ((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE, flags);
/* printf(" %s/%ld %lx\n", ((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE, flags); */
fl1 = flags & ((UInt)STATIC_PRED_FLAGS|(UInt)EXTRA_PRED_FLAGS);
else
__android_log_print(ANDROID_LOG_INFO, "YAP "," number\n");
#endif
fl1 = flags & ((pred_flags_t)STATIC_PRED_FLAGS|(UInt)EXTRA_PRED_FLAGS);
ap->PredFlags &= ~((UInt)STATIC_PRED_FLAGS|(UInt)EXTRA_PRED_FLAGS);
ap->PredFlags |= fl1;
if (flags & NumberDBPredFlag) {
ap->src.IndxId = read_UInt(stream);
} else {
ap->src.OwnerFile = (Atom)read_UInt(stream);
if (ap->src.OwnerFile) {
ap->src.OwnerFile = AtomAdjust(ap->src.OwnerFile);
}
@ -1035,7 +1044,9 @@ read_pred(IOSTREAM *stream, Term mod) {
if (flags & MultiFileFlag && ap->ModuleOfPred == PROLOG_MODULE) {
ap->ModuleOfPred = TermProlog;
}
read_clauses(stream, ap, nclauses, flags);
if (nclauses)
read_clauses(stream, ap, nclauses, flags);
if (flags & HiddenPredFlag) {
Yap_HidePred(ap);
}
@ -1146,6 +1157,7 @@ Yap_Restore(char *s, char *lib_dir)
read_module(stream);
Sclose( stream );
GLOBAL_RestoreFile = NULL;
CurrentModule = USER_MODULE;
return DO_ONLY_CODE;
}
@ -1160,4 +1172,3 @@ void Yap_InitQLYR(void)
restore_codes();
}
}

View File

@ -249,19 +249,6 @@ open_file(char *my_file, int flag)
char flags[6];
int i=0;
#if __ANDROID__
if (strstr(my_file, "/assets/") == my_file) {
if (flag == O_RDONLY) {
my_file += strlen("/assets/");
AAsset* asset = AAssetManager_open(GLOBAL_assetManager, my_file, AASSET_MODE_UNKNOWN);
if (!asset)
return NULL;
AAsset_close( asset );
return NULL; // usually the file will be compressed, so there is no point in actually trying to open it.
}
return NULL;
}
#endif
if (flag & O_RDONLY) {
flags[i++] = 'r';
}

130
C/stdpreds.c Normal file → Executable file
View File

@ -877,61 +877,69 @@ static Int
return TRUE;
}
static PropEntry *
fetchPredFromListOfProps (PropEntry *p)
{
while (p) {
if (p->KindOfPE == PEProp) {
// found our baby..
return p;
} else if (p->KindOfPE == FunctorProperty) {
// go to list of properties in functor..
PropEntry *q;
FunctorEntry *f = RepFunctorProp(p);
if ((q = fetchPredFromListOfProps( f->PropsOfFE ))) {
return q;
}
}
p = p->NextOfPE;
}
return NIL;
}
static PropEntry *
nextPredForAtom (PropEntry *p)
{
PredEntry *pe;
if (p == NIL)
return NIL;
pe = RepPredProp(p);
if (pe->ArityOfPE == 0) {
// if atom prop, search atom list
return fetchPredFromListOfProps(p->NextOfPE);
} else {
FunctorEntry *f = pe->FunctorOfPred;
// first search remainder of functor list
if ((p = fetchPredFromListOfProps(p->NextOfPE))) {
return p;
}
// if that fails, follow the functor
return fetchPredFromListOfProps( f->NextOfPE );
}
}
static Int cont_current_predicate(USES_REGS1) {
PredEntry *pp = NULL;
PropEntry *n;
UInt Arity;
Term name;
Term t1 = Deref(ARG1), t2 = Deref(ARG2), t3;
bool is_det = false, rc;
bool rc;
Functor f;
if (IsNonVarTerm(t1)) {
// current_pred(A, M, P)
PropEntry *p = AddressOfTerm(EXTRA_CBACK_ARG(4, 1));
PropEntry *q = AddressOfTerm(EXTRA_CBACK_ARG(4, 2));
// restart inner loop
for (; q; q = q->NextOfPE) {
if (q->KindOfPE == PEProp) {
pp = RepPredProp(q);
q = q->NextOfPE;
if (q == NIL)
p = p->NextOfPE;
if (!p)
is_det = true;
// we are done with this loop.
break;
}
}
if (!pp && p) {
// try using outer loop
for (; p; p = p->NextOfPE) {
if (p->KindOfPE == PEProp) {
q = NULL;
pp = RepPredProp(p);
p = p->NextOfPE;
if (!p)
is_det = true;
break;
} else if (p->KindOfPE == FunctorProperty) {
// looping on p/n
for (q = RepFunctorProp(p)->PropsOfFE; q; q = q->NextOfPE) {
if (q->KindOfPE == PEProp) {
pp = RepPredProp(q);
q = q->NextOfPE;
if (!q && !p->NextOfPE)
is_det = true;
break;
}
}
break;
}
}
}
if (pp == NULL) // nothing more
cut_fail();
if (!is_det) {
EXTRA_CBACK_ARG(4, 1) = MkAddressTerm(p);
EXTRA_CBACK_ARG(4, 2) = MkAddressTerm(q);
pp = RepPredProp(p);
n = nextPredForAtom (p);
if (n == NIL) {
YAP_cut_up();
} else {
EXTRA_CBACK_ARG(4, 1) = MkAddressTerm(n);
B->cp_h = HR;
}
} else if (IsNonVarTerm(t2)) {
// operating within the same module.
@ -945,8 +953,8 @@ static Int cont_current_predicate(USES_REGS1) {
if (npp) {
EXTRA_CBACK_ARG(4, 1) = MkAddressTerm(npp);
B->cp_h = HR;
} else {
is_det = true;
} else {
YAP_cut_up();
}
} else {
pp = AddressOfTerm(EXTRA_CBACK_ARG(4, 1));
@ -964,10 +972,12 @@ static Int cont_current_predicate(USES_REGS1) {
} // we found a new answer
if (!pp)
cut_fail();
else
else {
EXTRA_CBACK_ARG(4, 1) = MkAddressTerm(pp->NextPredOfModule);
B->cp_h = HR;
B->cp_h = HR;
}
}
if (pp->ModuleOfPred != IDB_MODULE) {
f = pp->FunctorOfPred;
Arity = pp->ArityOfPE;
@ -996,15 +1006,11 @@ static Int cont_current_predicate(USES_REGS1) {
t3 = name;
}
rc = (!(pp->PredFlags & HiddenPredFlag)) &&
Yap_unify(ARG2, ModToTerm(pp->ModuleOfPred)) && Yap_unify(ARG1, name) &&
Yap_unify(ARG3, t3) && Yap_unify(ARG4, MkIntegerTerm(pp->PredFlags));
if (is_det) {
if (rc)
cut_succeed();
else
cut_fail();
}
return rc;
Yap_unify(ARG2, ModToTerm(pp->ModuleOfPred)) &&
Yap_unify(ARG1, name) &&
Yap_unify(ARG3, t3) &&
Yap_unify(ARG4, MkIntegerTerm(pp->PredFlags));
return rc;
}
static Int init_current_predicate(USES_REGS1) {
@ -1015,6 +1021,9 @@ static Int init_current_predicate(USES_REGS1) {
PredEntry *pp = NULL;
ModEntry *m = NULL;
t1 = Yap_StripModule(t1, &t2);
t3 = Yap_StripModule(t3, &t2);
// check term
if (!IsVarTerm(t3)) {
t3 = Yap_StripModule(t3, &t2);
@ -1076,15 +1085,10 @@ static Int init_current_predicate(USES_REGS1) {
Yap_Error(TYPE_ERROR_ATOM, t1, "current_predicate/2");
cut_fail();
} else {
PropEntry *p = RepAtom(AtomOfTerm(t1))->PropsOfAE, *q = NIL;
while (p && p->KindOfPE == FunctorProperty &&
(q = RepFunctorProp(p)->PropsOfFE) == NIL) {
p = p->NextOfPE;
}
PropEntry *p = fetchPredFromListOfProps(RepAtom(AtomOfTerm(t1))->PropsOfAE);
if (!p)
cut_fail();
EXTRA_CBACK_ARG(4, 1) = MkAddressTerm(p);
EXTRA_CBACK_ARG(4, 2) = MkAddressTerm(q);
B->cp_h = HR;
}
}

View File

@ -107,6 +107,7 @@ static char SccsId[] = "%W% %G%";
#include <readline/readline.h>
#endif
/// File Error Handler
static void
Yap_FileError(yap_error_number type, Term where, const char *format,...)
{
@ -123,6 +124,7 @@ Yap_FileError(yap_error_number type, Term where, const char *format,...)
}
static void InitTime(int);
static void InitWTime(void);
static Int p_sh( USES_REGS1 );
@ -141,24 +143,6 @@ static int chdir(char *);
/* #define signal skel_signal */
#endif /* MACYAP */
#if DEBUG
void
LOG(const char *fmt, ...);
void
LOG(const char *fmt, ...)
{
FILE * fd;
va_list ap;
fd = fopen("c:\\cygwin\\Log.txt", "a");
va_start(ap, fmt);
vfprintf(fd, fmt, ap);
va_end(ap);
fclose( fd );
}
#endif
void exit(int);
@ -180,12 +164,118 @@ Yap_WinError(char *yap_error)
#define is_valid_env_char(C) ( ((C) >= 'a' && (C) <= 'z') || ((C) >= 'A' && \
(C) <= 'Z') || (C) == '_' )
#if __ANDROID__
AAssetManager * Yap_assetManager;
void *
Yap_openAssetFile( const char *path ) {
AAssetDir *d;
LOG("openA %s %p", path, path);
const char * p = path+8;
AAsset* asset = AAssetManager_open(Yap_assetManager, p, AASSET_MODE_UNKNOWN);
return asset;
}
bool
Yap_isAsset( const char *path )
{
return path[0] == '/'&&
path[1] == 'a'&&
path[2] == 's'&&
path[3] == 's'&&
path[4] == 'e'&&
path[5] == 't'&&
path[6] == 's'&&
(path[7] == '/' || path[7] == '\0');
}
bool
Yap_AccessAsset( const char *name, int mode )
{
AAssetManager* mgr = Yap_assetManager;
const char *bufp=name+7;
if (bufp[0] == '/')
bufp++;
if ((mode & W_OK) == W_OK) {
return false;
}
// check if file is a directory.
AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp);
if (assetDir) {
AAssetDir_close(assetDir);
return true;
}
return false;
}
bool
Yap_AssetIsFile( const char *name )
{
AAssetManager* mgr = Yap_assetManager;
const char *bufp=name+7;
if (bufp[0] == '/')
bufp++;
// check if file is a directory.
AAsset *asset = AAssetManager_open(mgr, bufp, AASSET_MODE_UNKNOWN);
if (!asset)
return false;
AAsset_close(asset);
return true;
}
bool
Yap_AssetIsDir( const char *name )
{
AAssetManager* mgr = Yap_assetManager;
const char *bufp=name+7;
if (bufp[0] == '/')
bufp++;
// check if file is a directory.
AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp);
if (!assetDir) {
return false;
}
AAssetDir_close(assetDir);
AAsset *asset = AAssetManager_open(mgr, bufp, AASSET_MODE_UNKNOWN);
if (!asset)
return true;
AAsset_close(asset);
return false;
}
int64_t
Yap_AssetSize( const char *name )
{
AAssetManager* mgr = Yap_assetManager;
const char *bufp=name+7;
if (bufp[0] == '/')
bufp++;
AAsset *asset = AAssetManager_open(mgr, bufp, AASSET_MODE_UNKNOWN);
if (!asset)
return -1;
off64_t len = AAsset_getLength64(asset);
AAsset_close(asset);
return len;
}
#endif
/// is_directory: verifies whether an expanded file name
/// points at a readable directory
static bool
is_directory(const char *FileName)
{
#ifdef __ANDROID__
if (Yap_isAsset(FileName)) {
return Yap_AssetIsDir(FileName);
}
#endif
#ifdef __WINDOWS__
DWORD dwAtts = GetFileAttributes( FileName );
if (dwAtts == INVALID_FILE_ATTRIBUTES)
@ -211,7 +301,12 @@ is_directory(const char *FileName)
static bool
has_access(const char *FileName, int mode)
{
#if HAS_ACCESS
#ifdef __ANDROID__
if (Yap_isAsset(FileName)) {
return Yap_AccessAsset(FileName, mode);
}
#endif
#if HAVE_ACCESS
if (access( FileName, mode ) == 0)
return true;
if (errno == EINVAL) {
@ -269,12 +364,112 @@ IsAbsolutePath(const char *p)
#endif
}
#define isValidEnvChar(C) ( ((C) >= 'a' && (C) <= 'z') || ((C) >= 'A' && \
(C) <= 'Z') || (C) == '_' )
// this is necessary because
// support for ~expansion at the beginning
// systems like Android do not do this.
static char *
yapExpandVars (const char *source, char *result)
{
const char *src = source;
char *res = result;
if (strlen(source) >= YAP_FILENAME_MAX) {
Yap_Error(OPERATING_SYSTEM_ERROR, TermNil, "%s in true_file-name is larger than the buffer size (%d bytes)", source, strlen(source));
}
/* step 1: eating home information */
if (source[0] == '~') {
if (dir_separator(source[1]) || source[1] == '\0')
{
char *s;
src++;
#if defined(_WIN32)
s = getenv("HOMEDRIVE");
if (s != NULL)
strncpy (result, getenv ("HOMEDRIVE"), YAP_FILENAME_MAX);
s = getenv("HOMEPATH");
if (s != NULL)
strncpy (result, s, YAP_FILENAME_MAX);
#else
s = getenv ("HOME");
if (s != NULL)
strncpy (result, s, YAP_FILENAME_MAX);
#endif
} else {
#if HAVE_GETPWNAM
struct passwd *user_passwd;
src++;
while (!dir_separator((*res = *src)) && *res != '\0')
res++, src++;
res[0] = '\0';
if ((user_passwd = getpwnam (result)) == NULL) {
Yap_FileError(OPERATING_SYSTEM_ERROR, MkAtomTerm(Yap_LookupAtom(source)),"User %s does not exist in %s", result, source);
return NULL;
}
strncpy (result, user_passwd->pw_dir, YAP_FILENAME_MAX);
#else
Yap_FileError(OPERATING_SYSTEM_ERROR, MkAtomTerm(Yap_LookupAtom(source)),"User %s cannot be found in %s, missing getpwnam", result, source);
return NULL;
#endif
}
strncat (result, src, YAP_FILENAME_MAX);
return result;
}
#if !HAVE_WORDEXP
// do VARIABLE expansion
else if (source[0] == '$') {
/* follow SICStus expansion rules */
int ch;
char *s;
src = source+1;
if (src[0] == '{') {
src++;
while ((*res++ = (ch = *src++)) && isValidEnvChar (ch) && ch != '}') {
res++;
}
if (ch == '}') {
// {...}
// done
}
} else {
while ((*res++ = (ch = *src++)) && isValidEnvChar (ch) && ch != '}') {
res++;
}
src--;
}
res[0] = '\0';
if ((s = (char *) getenv (result))) {
strncpy (result, s, YAP_FILENAME_MAX);
} else {
result[0] = '\0';
}
strncat (result, src, YAP_FILENAME_MAX);
}
#endif
else {
strncpy (result, source, YAP_FILENAME_MAX);
}
return result;
}
char *
expandVars(const char *pattern, char *expanded, int maxlen)
{
char tmp[YAP_FILENAME_MAX+1];
if ((pattern = yapExpandVars(pattern, tmp)) == NULL) {
return NULL;
}
#if __WIN32 || __MINGW32__
DWORD retval=0;
// notice that the file does not need to exist1
if (ini == NULL) {
ini = malloc(strlen(w)+1);
}
retval = ExpandEnvironmentStrings(pattern,
expanded,
maxlen);
@ -286,7 +481,7 @@ expandVars(const char *pattern, char *expanded, int maxlen)
}
return expanded;
#elif HAVE_WORDEXP
wordexp_t result;
wordexp_t result;
/* Expand the string for the program to run. */
switch (wordexp (pattern, &result, 0))
@ -297,6 +492,9 @@ wordexp_t result;
return NULL;
} else {
char *w = result.we_wordv[0];
if (expanded == NULL) {
expanded = malloc(strlen(w)+1);
}
strncpy( expanded, w, maxlen );
wordfree (&result);
return expanded;
@ -309,8 +507,15 @@ wordexp_t result;
default: /* Some other error. */
return NULL;
}
#else
// just use basic
if (expanded == NULL) {
expanded = malloc(strlen(pattern)+1);
}
strcpy(expanded, pattern);
#endif
return NULL;
return expanded;
}
#if _WIN32 || defined(__MINGW32__)
@ -378,15 +583,17 @@ PrologPath(const char *p, char *buf, size_t len)
char *
OsPath(const char *p, char *buf)
{ strcpy(buf, p);
{
if()z
trcpy(buf, p);
return buf;
}
#else
char *
OsPath(const char *X, char *Y) {
if (X!=Y && Y) strcpy(Y,X);
return Y;
//if (X!=Y && Y) strcpy(Y,X);
return (char *)X ;
}
#endif /* O_XOS */
@ -400,6 +607,29 @@ bool ChDir(const char *path) {
bool rc = false;
char *qpath = AbsoluteFile(path, NULL);
#ifdef __ANDROID__
if (GLOBAL_AssetsWD) {
free( GLOBAL_AssetsWD );
GLOBAL_AssetsWD = NULL;
}
if (Yap_isAsset(qpath) ) {
AAssetManager* mgr = Yap_assetManager;
const char *ptr = qpath+8;
AAssetDir* d;
if (ptr[0] == '/')
ptr++;
d = AAssetManager_openDir(mgr, ptr);
if (d) {
GLOBAL_AssetsWD = malloc( strlen(qpath) + 1 );
strcpy( GLOBAL_AssetsWD, qpath );
AAssetDir_close( d );
return true;
}
return false;
} else {
GLOBAL_AssetsWD = NULL;
}
#endif
#if _WIN32 || defined(__MINGW32__)
GET_LD
if ((rc = (SetCurrentDirectory(qpath) != 0)) == 0)
@ -476,7 +706,7 @@ static char *myrealpath( const char *path, char *out)
strcat(rc, s0);
free(s0);
}
return rc;
return rc;
}
#else
return NULL;
@ -488,16 +718,14 @@ char *
{
GET_LD
char *rc;
char *qpath0;
#if _WIN32 || defined(__MINGW32__)
char *o = malloc(YAP_FILENAME_MAX+1);
if (!o)
return NULL;
#if HAVE_WORDEXP
char o[YAP_FILENAME_MAX+1];
#elif _WIN32 || defined(__MINGW32__)
char u[YAP_FILENAME_MAX+1];
// first pass, remove Unix style stuff
if (unix2win(spec, o, YAP_FILENAME_MAX) == NULL)
if (unix2win(spec, u, YAP_FILENAME_MAX) == NULL)
return NULL;
spec = (const char *)o;
spec = (const char *)u;
#endif
if (tmp == NULL) {
tmp = malloc(YAP_FILENAME_MAX+1);
@ -507,24 +735,13 @@ char *
}
if ( truePrologFlag(PLFLAG_FILEVARS) )
{
qpath0 = malloc(YAP_FILENAME_MAX+1);
#if HAVE_WORDEXP
qpath0=expandVars(spec,qpath0,YAP_FILENAME_MAX);
spec=expandVars(spec,o,YAP_FILENAME_MAX);
#endif
#if _WIN32 || defined(__MINGW32__)
free((char *)spec);
#endif
spec = qpath0;
}
#if HAVE_REALPATH
rc = myrealpath(spec, tmp);
#endif
if (spec == qpath0
#if _WIN32 || defined(__MINGW32__)
|| true
#endif
)
free((char *)spec);
return rc;
}
@ -882,7 +1099,7 @@ void Yap_systime_interval(Int *now,Int *interval)
The problem is that mingw32 does not seem to have acces to div */
#ifndef do_div
#define do_div(n,base) ({ \
unsigned long __upper, __low, __high, __mod; \
unsigned long __upper, __low, __high, __mod; \
asm("":"=a" (__low), "=d" (__high):"A" (n)); \
__upper = __high; \
if (__high) { \
@ -2103,10 +2320,10 @@ Yap_volume_header(char *file)
char * PL_cwd(char *cwd, size_t cwdlen)
{
return Yap_getcwd( cwd, cwdlen );
return (char *)Yap_getcwd( (const char *)cwd, cwdlen );
}
char * Yap_getcwd(const char *cwd, size_t cwdlen)
const char * Yap_getcwd(const char *cwd, size_t cwdlen)
{
#if _WIN32 || defined(__MINGW32__)
if (GetCurrentDirectory(cwdlen, (char *)cwd) == 0)
@ -2116,7 +2333,13 @@ Yap_volume_header(char *file)
}
return (char *)cwd;
#else
return getcwd(cwd, cwdlen);
#if __ANDROID__
if (GLOBAL_AssetsWD) {
return strncpy( (char *)cwd, (const char *)GLOBAL_AssetsWD, cwdlen);
}
#endif
return getcwd((char *)cwd, cwdlen);
#endif
}
@ -2127,7 +2350,8 @@ Yap_volume_header(char *file)
char *work;
char ares1[YAP_FILENAME_MAX+1];
work = expandVars( source, ares1, YAP_FILENAME_MAX);
work = expandVars( source, ares1, YAP_FILENAME_MAX);
// expand names first
if (root && !IsAbsolutePath( source ) ) {
char ares2[YAP_FILENAME_MAX+1];
@ -2163,8 +2387,7 @@ TrueFileName (char *isource, char *root, char *result, int in_lib, int expand_ro
#if HAVE_GETENV
{
char *yap_env = getenv("YAPLIBDIR");
if (yap_env &&
exists((work = expandWithPrefix( source, yap_env, result ))))
if (yap_env && exists((work = expandWithPrefix( source, yap_env, result ))))
return true; // done
}
#endif
@ -2287,14 +2510,14 @@ p_sh ( USES_REGS1 )
/** shell(+Command:text, -Status:integer) is det.
Run an external command and wait for its completion.
Run an external command and wait for its completion.
*/
static Int
p_shell ( USES_REGS1 )
{ /* '$shell'(+SystCommand) */
#if _MSC_VER || defined(__MINGW32__)
char *cmd;
term_t A1 = Yap_InitSlot(ARG1 PASS_REGS);
term_t A1 = Yap_InitSlot(ARG1);
if ( PL_get_chars(A1, &cmd, CVT_ALL|REP_FN|CVT_EXCEPTION) )
{ int rval = System(cmd);
@ -2373,7 +2596,7 @@ p_system ( USES_REGS1 )
{ /* '$system'(+SystCommand) */
#if _MSC_VER || defined(__MINGW32__)
char *cmd;
term_t A1 = Yap_InitSlot(ARG1 PASS_REGS);
term_t A1 = Yap_InitSlot(ARG1);
if ( PL_get_chars(A1, &cmd, CVT_ALL|REP_FN|CVT_EXCEPTION) )
{ STARTUPINFO si;
PROCESS_INFORMATION pi;
@ -2935,11 +3158,7 @@ p_yap_paths( USES_REGS1 ) {
strncat(destdir, "/" YAP_SHAREDIR, YAP_FILENAME_MAX );
out2 = MkAtomTerm(Yap_LookupAtom(destdir));
} else {
#if __ANDROID__
out2 = MkAtomTerm(Yap_LookupAtom("/assets/share/Yap"));
#else
out2 = MkAtomTerm(Yap_LookupAtom(YAP_SHAREDIR));
#endif
}
if (env_destdir) {
strncat(destdir, env_destdir, YAP_FILENAME_MAX );
@ -2973,9 +3192,7 @@ p_log_event( USES_REGS1 ) {
#endif
if (IsWideAtom(at) || IsBlob(at))
return FALSE;
#if __ANDROID__
__android_log_print(ANDROID_LOG_INFO, "YAP", " %s ",RepAtom(at)->StrOfAE);
#endif
LOG( " %s ",RepAtom(at)->StrOfAE);
return TRUE;
}

View File

@ -537,7 +537,7 @@ read_Text( void *buf, seq_tv_t *inp, encoding_t *enc, int *minimal, size_t *leng
CurSlot = Yap_StartSlots();
fd = Sopenmem(&s, &sz, "w");
fd->encoding = ENC_UTF8;
if ( ! PL_write_term(fd, Yap_InitSlot(inp->val.t PASS_REGS), 1200, 0) ||
if ( ! PL_write_term(fd, Yap_InitSlot(inp->val.t), 1200, 0) ||
Sputcode(EOS, fd) < 0 ||
Sflush(fd) < 0 ) {
AUX_ERROR( inp->val.t, LOCAL_MAX_SIZE, s, char);
@ -1463,4 +1463,3 @@ Yap_Splice_Text( int n, size_t cuts[], seq_tv_t *inp, encoding_t encv[], seq_tv
}
return (void *)outv;;
}

View File

@ -144,6 +144,20 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
Int arity;
/* extern int gc_calls; */
vsc_count++;
#if __ANDROID__
PredEntry *ap = pred;
if (pred && port == enter_pred) {
UInt flags = ap->PredFlags;
if (ap->ArityOfPE && ap->ModuleOfPred != IDB_MODULE)
__android_log_print(ANDROID_LOG_INFO, "YAP ", " %s/%ld %lx\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE, ap->ArityOfPE, flags);
/* printf(" %s/%ld %lx\n", NameOfFunctor(ap->FunctorOfPred)->StrOfAE, ap->ArityOfPE, flags); */
else if (ap->ModuleOfPred != IDB_MODULE)
__android_log_print(ANDROID_LOG_INFO, "YAP "," %s/%ld %lx\n", ((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE, flags);
/* printf(" %s/%ld %lx\n", ((Atom)(ap->FunctorOfPred))->StrOfAE, ap->ArityOfPE, flags); */
__android_log_print(ANDROID_LOG_INFO, "YAP "," %x ", ap->src.OwnerFile);
}
return;
#endif
// if (!worker_id) return;
LOCK(Yap_heap_regs->low_level_trace_lock);

View File

@ -694,8 +694,8 @@ static Term from_pointer(CELL *ptr0, struct rewind_term *rwt,
if (wglb->Keep_terms) {
struct rewind_term *x = rwt->parent;
rwt->u_sd.s.old = Yap_InitSlot(t PASS_REGS);
rwt->u_sd.s.ptr = Yap_InitSlot((CELL)ptr0 PASS_REGS);
rwt->u_sd.s.old = Yap_InitSlot(t);
rwt->u_sd.s.ptr = Yap_InitSlot((CELL)ptr0);
if (!IsAtomicTerm(t) && !IsVarTerm(t)) {
while (x) {
@ -785,7 +785,7 @@ static Term check_infinite_loop(Term t, struct rewind_term *x,
CACHE_REGS
if (wglb->Keep_terms) {
while (x) {
if (Yap_GetFromSlot(x->u_sd.s.old PASS_REGS) == t)
if (Yap_GetFromSlot(x->u_sd.s.old) == t)
return TermFoundVar;
x = x->parent;
}

View File

@ -167,11 +167,7 @@ int
YAP_parse_yap_arguments(int argc, char *argv[], YAP_init_args *iap)
{
char *p;
#ifdef USE_SYSTEM_MALLOC
int BootMode = YAP_FULL_BOOT_FROM_PROLOG;
#else
int BootMode = YAP_BOOT_FROM_SAVED_CODE;
#endif
unsigned long int *ssize;
iap->SavedState = NULL;
@ -554,5 +550,6 @@ YAP_parse_yap_arguments(int argc, char *argv[], YAP_init_args *iap)
}
GD->cmdline.appl_argc = argc;
GD->cmdline.appl_argv = argv;
//___androidlog_print(ANDROID_LOG_INFO, "YAP ", "boot mode %d", BootMode);
return BootMode;
}

View File

@ -118,14 +118,34 @@ protected:
PredEntry *ap;
/// auxiliary routine to find a predicate in the current module.
PredEntry *getPred( Term t, Term* &outp ) ;
PredEntry *getPred( Term &t, Term* &outp ) ;
/// String constructor for predicates
///
/// It also communicates the array of arguments t[]
/// and the array of variables
/// back to yapquery
YAPPredicate(const char *s, Term* &out, Term& vnames ) throw (int);
YAPPredicate(const char *s, Term &out, yhandle_t &vnames ) {
CACHE_REGS
BACKUP_MACHINE_REGS();
Term *outp;
char ns[strlen(s)+1];
memcpy(ns, s, strlen(s)+1);
LOG("iPP=%d %d %d", strlen(s), s[0], s[1]);
LOG("iPP=%s", s);
vnames = Yap_NewSlots(1);
out = Yap_StringToTerm(ns, strlen(s)+1, vnames ) ;
LOG("iP2=%s", s);
//extern char *s0;
//fprintf(stderr,"ap=%p arity=%d text=%s", ap, ap->ArityOfPE, s);
// Yap_DebugPlWrite(out);
// delete [] ns;
if (out == 0L)
throw YAPError::YAP_SYNTAX_ERROR;
ap = getPred( out, outp);
RECOVER_MACHINE_REGS();
}
/// Term constructor for predicates
///
@ -185,30 +205,6 @@ public:
YAPPredicate(YAPAtom at, arity_t arity);
/// String constructor for predicates.
///
/// String is a Prolog term, we extract the main functor after considering the module qualifiers.
inline YAPPredicate(const char *s) throw (int) {
Term t, tp;
t = YAP_ReadBuffer(s,&tp);
if (t == 0L)
throw YAPError::YAP_SYNTAX_ERROR;
CELL * v;
ap = getPred( t, v);
}
/// String constructor for predicates, also keeps arguments in tp[]
///
/// String is a Prolog term, we extract the main functor after considering the module qualifiers.
inline YAPPredicate(const char *s, Term* outp) throw (int) {
Term t, tp;
t = YAP_ReadBuffer(s,&tp);
if (t == 0L)
throw YAPError::YAP_SYNTAX_ERROR;
ap = getPred( t, outp );
}
/// module of a predicate
///
/// notice that modules are currently treated as atoms, this should change.
@ -315,4 +311,3 @@ public:
}
};

View File

@ -136,23 +136,23 @@ YAPStringTerm::YAPStringTerm(wchar_t *s, size_t len) : YAPTerm() { // build stri
YAPApplTerm::YAPApplTerm(YAPFunctor f, YAPTerm ts[]) : YAPTerm() {
BACKUP_MACHINE_REGS();
BACKUP_H();
UInt arity = ArityOfFunctor(f.f);
mk ( Yap_MkApplTerm( f.f, arity, (Term *)ts) );
RECOVER_MACHINE_REGS();
RECOVER_H();
}
YAPApplTerm::YAPApplTerm(YAPFunctor f) : YAPTerm() {
BACKUP_MACHINE_REGS();
BACKUP_H();
UInt arity = ArityOfFunctor(f.f);
mk ( Yap_MkNewApplTerm( f.f, arity) );
RECOVER_MACHINE_REGS();
RECOVER_H();
}
YAPTerm YAPApplTerm::getArg(int arg) {
BACKUP_MACHINE_REGS();
BACKUP_H();
YAPTerm to = YAPTerm( ArgOfTerm(arg, gt() ) );
RECOVER_MACHINE_REGS();
RECOVER_H();
return to;
}
@ -162,20 +162,20 @@ YAPFunctor YAPApplTerm::getFunctor() {
YAPPairTerm::YAPPairTerm(YAPTerm th, YAPTerm tl) : YAPTerm() {
CACHE_REGS
BACKUP_MACHINE_REGS();
BACKUP_H();
mk ( MkPairTerm( th.term(), tl.term() ) );
RECOVER_MACHINE_REGS();
RECOVER_H();
}
YAPPairTerm::YAPPairTerm() : YAPTerm() {
BACKUP_MACHINE_REGS();
BACKUP_H();
t = Yap_MkNewPairTerm( );
RECOVER_MACHINE_REGS();
RECOVER_H();
}
void YAPTerm::mk(Term t0) { CACHE_REGS t = Yap_InitSlot( t0 PASS_REGS); }
void YAPTerm::mk(Term t0) { CACHE_REGS t = Yap_InitSlot( t0 ); }
Term YAPTerm::gt() { CACHE_REGS return Yap_GetFromSlot( t PASS_REGS); }
Term YAPTerm::gt() { CACHE_REGS return Yap_GetFromSlot( t ); }
YAP_tag_t YAPTerm::tag() {
Term tt = gt( );
@ -193,7 +193,7 @@ YAP_tag_t YAPTerm::tag() {
return YAP_TAG_PAIR;
if (IsAtomOrIntTerm(tt)) {
if (IsAtomTerm(tt))
return YAP_TAG_ATOM;
return YAP_TAG_ATOM;
return YAP_TAG_INT;
} else {
Functor f = FunctorOfTerm(tt);
@ -296,20 +296,9 @@ const char *YAPTerm::text() {
return os;
}
char *YAPQuery::text() {
size_t sze = 4096, length;
char *os;
int enc;
const char *YAPQuery::text() {
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I t=(%d) %lx", *q_g) ; }
BACKUP_MACHINE_REGS();
if (!(os = Yap_HandleToString(*q_g, sze, &length, &enc, 0))) {
RECOVER_MACHINE_REGS();
return (char *)NULL;
}
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "II %s", os) ; }
RECOVER_MACHINE_REGS();
return os;
return goal.text();
}
@ -335,7 +324,7 @@ YAPTerm::YAPTerm(intptr_t i) { CACHE_REGS Term tn = MkIntegerTerm( i ); mk( tn )
YAPTerm YAPListTerm::car()
{
Term to = gt();
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "to=%p", to) ; }
{ LOG( "to=%lx", to) ; }
if (IsPairTerm(to))
return YAPTerm(HeadOfTerm(to));
else
@ -395,51 +384,80 @@ char *YAPAtom::getName(void) {
}
}
void YAPQuery::initOpenQ() {
CACHE_REGS
oq = LOCAL_execution;
LOCAL_execution = this;
q_open=1;
q_state=0;
q_flags = PL_Q_PASS_EXCEPTION;
q_p = P;
q_cp = CP;
}
void
YAPQuery::initQuery( Term *ts )
YAPQuery::initQuery( Term t )
{
CACHE_REGS
BACKUP_MACHINE_REGS();
size_t arity = ap->ArityOfPE;
LOG("iQ=%d", arity);
goal = YAPTerm( t );
if (arity) {
q_g = Yap_NewSlots( arity );
for (size_t i=0; i < arity; i++) {
Yap_PutInSlot(q_g+i, ArgOfTerm(i+1, t) PASS_REGS);
}
} else {
q_g = 0;
}
initOpenQ();
RECOVER_MACHINE_REGS();
}
void
YAPQuery::initQuery( YAPTerm ts[], arity_t arity )
{
CACHE_REGS
this->oq = (YAPQuery *)LOCAL_execution;
LOCAL_execution = (struct open_query_struct *)this;
this->q_open=1;
this->q_state=0;
this->q_flags = PL_Q_PASS_EXCEPTION;
this->q_g = ts;
this->q_p = P;
this->q_cp = CP;
}
void
YAPQuery::initQuery( YAPTerm t[], arity_t arity )
{
Term *ts = new Term[arity];
for (arity_t i = 0; i < arity; i++)
ts[i] = t[i].term();
return initQuery( ts );
BACKUP_MACHINE_REGS();
if (arity) {
q_g = Yap_NewSlots( arity );
for (size_t i=0; i < arity; i++) {
Yap_PutInSlot(q_g+i, ts[i].term() PASS_REGS);
}
Term t = Yap_MkApplTerm(ap->FunctorOfPred, ap->ArityOfPE, Yap_AddressFromSlot(q_g));
goal = YAPTerm( t );
} else {
q_g = 0;
goal = YAPTerm( MkAtomTerm((Atom)ap->FunctorOfPred) );
}
initOpenQ();
RECOVER_MACHINE_REGS();
}
YAPQuery::YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm t[]): YAPPredicate(f, mod)
YAPQuery::YAPQuery(YAPFunctor f, YAPTerm mod, YAPTerm ts[]): YAPPredicate(f, mod)
{
/* ignore flags for now */
initQuery( t , f.arity());
initQuery( ts , f.arity());
}
YAPQuery::YAPQuery(YAPFunctor f, YAPTerm t[]): YAPPredicate(f)
YAPQuery::YAPQuery(YAPFunctor f, YAPTerm ts[]): YAPPredicate(f)
{
/* ignore flags for now */
initQuery( t , f.arity());
initQuery( ts , f.arity());
}
YAPQuery::YAPQuery(YAPPredicate p, YAPTerm t[]): YAPPredicate(p.ap)
YAPQuery::YAPQuery(YAPPredicate p, YAPTerm ts[]): YAPPredicate(p.ap)
{
initQuery( t , p.ap->ArityOfPE);
initQuery( ts , p.ap->ArityOfPE);
}
YAPListTerm YAPQuery::namedVars() {
CACHE_REGS
Term o = Yap_GetFromSlot( this->vnames.t PASS_REGS );
Term o = Yap_GetFromSlot( vnames );
return YAPListTerm( o );
}
@ -448,24 +466,23 @@ bool YAPQuery::next()
CACHE_REGS
int result;
BACKUP_MACHINE_REGS();
if (q_open != 1) return false;
if (setjmp(((YAPQuery *)LOCAL_execution)->q_env))
if (setjmp(q_env))
return false;
// don't forget, on success these guys must create slots
if (q_state == 0) {
// extern void toggle_low_level_trace(void);
//toggle_low_level_trace();
result = (bool)YAP_EnterGoal((YAP_PredEntryPtr)ap, q_g, &q_h);
// don't forget, on success these guys must create slots
if (this->q_state == 0) {
result = (bool)YAP_EnterGoal((YAP_PredEntryPtr)ap, q_g, &q_h);
} else {
LOCAL_AllowRestart = this->q_open;
LOCAL_AllowRestart = q_open;
result = (bool)YAP_RetryGoal(&q_h);
}
this->q_state = 1;
q_state = 1;
if (!result) {
YAP_LeaveGoal(FALSE, &q_h);
this->q_open = 0;
q_open = 0;
}
RECOVER_MACHINE_REGS();
return result;
}
@ -473,26 +490,31 @@ void YAPQuery::cut()
{
CACHE_REGS
if (this->q_open != 1 || this->q_state == 0) return;
YAP_LeaveGoal(FALSE, &this->q_h);
this->q_open = 0;
LOCAL_execution = (struct open_query_struct *)this->oq;
BACKUP_MACHINE_REGS();
if (q_open != 1 || q_state == 0) return;
YAP_LeaveGoal(FALSE, &q_h);
q_open = 0;
LOCAL_execution = this;
RECOVER_MACHINE_REGS();
}
void YAPQuery::close()
{
CACHE_REGS
if (EX && !(this->q_flags & (PL_Q_CATCH_EXCEPTION))) {
RECOVER_MACHINE_REGS();
if (EX && !(q_flags & (PL_Q_CATCH_EXCEPTION))) {
EX = (struct DB_TERM *)NULL;
}
/* need to implement backtracking here */
if (this->q_open != 1 || this->q_state == 0) {
if (q_open != 1 || q_state == 0) {
RECOVER_MACHINE_REGS();
return;
}
YAP_LeaveGoal(FALSE, &this->q_h);
this->q_open = 0;
LOCAL_execution = (struct open_query_struct *)this->oq;
YAP_LeaveGoal(FALSE, &q_h);
q_open = 0;
LOCAL_execution = this;
RECOVER_MACHINE_REGS();
}
static YAPEngine *curren;
@ -502,7 +524,16 @@ static YAPEngine *curren;
#include <jni.h>
#include <string.h>
extern AAssetManager *assetManager;
JNIEnv *Yap_jenv;
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
JNIEnv* env;
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
return -1;
}
Yap_jenv = env;
return JNI_VERSION_1_6;
}
extern char *Yap_AndroidBufp;
static size_t Yap_AndroidMax, Yap_AndroidSz;
@ -530,6 +561,19 @@ displayWithJava(int c)
}
}
extern "C" void Java_pt_up_fc_dcc_yap_JavaYap_load(JNIEnv *env0, jobject obj, jobject mgr);
extern "C" void Java_pt_up_fc_dcc_yap_JavaYap_load
(JNIEnv *env0, jobject obj, jobject asset_manager)
{
AAssetManager *mgr = AAssetManager_fromJava(Yap_jenv, asset_manager);
if (mgr == NULL) {
LOG( "we're doomed, mgr = 0; bip bip bip");
} else {
Yap_assetManager = mgr;
}
}
#endif
@ -548,8 +592,6 @@ YAPEngine::YAPEngine( char *savedState,
YAPCallback *cb): _callback(0)
{ // a single engine can be active
#if __ANDROID__
if (GLOBAL_assetManager == (AAssetManager *)NULL)
return;
Yap_DisplayWithJava = displayWithJava;
Yap_AndroidBufp = (char *)malloc(Yap_AndroidMax = 4096);
Yap_AndroidBufp[0] = '\0';
@ -573,22 +615,6 @@ YAPEngine::YAPEngine( char *savedState,
YAP_Init( &init_args );
}
YAPQuery *YAPEngine::query( char *s ) {
YAPQuery *n = new YAPQuery( s );
return n;
}
YAPPredicate::YAPPredicate(const char *s, Term* &outp, Term &vnames) throw (int) {
CACHE_REGS
yhandle_t sl = Yap_NewSlots(1 PASS_REGS);
Term t = Yap_StringToTerm(s, strlen(s)+1, sl );
if (t == 0L)
throw YAPError::YAP_SYNTAX_ERROR;
vnames = Yap_GetFromSlot( sl PASS_REGS );
ap = getPred( t, outp );
}
YAPPredicate::YAPPredicate(YAPAtom at) {
CACHE_REGS
@ -606,35 +632,32 @@ YAPPredicate::YAPPredicate(YAPAtom at, arity_t arity) {
}
/// auxiliary routine to find a predicate in the current module.
PredEntry *YAPPredicate::getPred( Term t, Term* &outp ) {
PredEntry *YAPPredicate::getPred( Term &t, Term* &outp ) {
CACHE_REGS
Term m = CurrentModule ;
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "H= %p, outp=%p", HR, outp) ; }
t = Yap_StripModule(t, &m);
t = Yap_StripModule(t, &m);
if (IsVarTerm(t) || IsNumTerm(t)) {
ap = (PredEntry *)NULL;
outp = (Term *)NULL;
return ap;
}
if (IsAtomTerm(t)) {
ap = RepPredProp(PredPropByAtom(AtomOfTerm(t), m));
if (outp) outp = (Term *)NULL;
outp = (Term *)NULL;
return ap;
} else if (IsPairTerm(t)) {
ap = RepPredProp(PredPropByFunc(FunctorCsult, PROLOG_MODULE));
outp = HR;
HR[0] = RepPair(t)[0];
HR[1] = m;
HR+=2;
} else {
Functor f = FunctorOfTerm(t);
if (IsExtensionFunctor(f)) {
Term ts[1];
ts[0] = t;
t = Yap_MkApplTerm(FunctorCsult, 1, ts);
}
Functor f = FunctorOfTerm(t);
if (IsExtensionFunctor(f)) {
ap = (PredEntry *)NULL;
outp = (Term *)NULL;
} else {
} else {
ap = RepPredProp(PredPropByFunc(f, m));
outp = RepAppl(t)+1;
}
}
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "done H= %p, outp=%p", HR, outp) ; }
return ap;
}
@ -711,15 +734,20 @@ YAPPrologPredicate::YAPPrologPredicate(YAPAtom name,
void *YAPPrologPredicate::assertClause( YAPTerm clause, bool last, YAPTerm source) {
CACHE_REGS
RECOVER_MACHINE_REGS();
Term tt = clause.gt();
Term sourcet = source.gt();
yamop *codeaddr = Yap_cclause(tt, PP->ArityOfPE, CurrentModule, sourcet); /* vsc: give the number of arguments
to cclause in case there is overflow */
Term ntt = clause.gt();
if (LOCAL_ErrorMessage)
return 0;
if (LOCAL_ErrorMessage) {
RECOVER_MACHINE_REGS();
return 0;
}
Term *tref = &ntt;
if (Yap_addclause(ntt, codeaddr, (last ? 0 : 2), CurrentModule, tref))
if (Yap_addclause(ntt, codeaddr, (last ? 0 : 2), CurrentModule, tref)) {
RECOVER_MACHINE_REGS();
}
return tref;
return 0;
}

View File

@ -68,7 +68,6 @@ extern "C" {
#include <windows.h>
#endif
// taken from yap_structs.h
#include "iopreds.h"

View File

@ -5,25 +5,22 @@
Queries and engines
*/
static const char *s0;
/**
* @brief Queries
*
* interface to a YAP Query;
* uses an SWI-like status info internally.
*/
class YAPQuery: public YAPPredicate {
int q_open;
int q_state;
Term *q_g;
yamop *q_p, *q_cp;
jmp_buf q_env;
int q_flags;
Term vs;
YAP_dogoalinfo q_h;
YAPQuery *oq;
YAPTerm vnames;
void initQuery( Term ts[] );
void initQuery( YAPTerm t[], arity_t arity );
class YAPQuery: public YAPPredicate, open_query_struct {
yhandle_t vnames;
YAPTerm goal;
Term t;
void initOpenQ();
void initQuery( Term t );
void initQuery( YAPTerm ts[], arity_t arity );
public:
/// main constructor, uses a predicate and an array of terms
///
@ -43,12 +40,11 @@ public:
/// string constructor without varnames
///
/// It is given a string, calls the parser and obtains a Prolog term that should be a callable
/// goal. It does not ask for a list of variables.
inline YAPQuery(const char *s): YAPPredicate(s, q_g, vs)
/// goal.
inline YAPQuery(const char *s): YAPPredicate(s, t, vnames)
{
vnames = YAPTerm( vs );
initQuery( q_g );
}
initQuery( t );
};
/// set flags for query execution, currently only for exception handling
void setFlag(int flag) {q_flags |= flag; }
@ -62,7 +58,7 @@ public:
/// same call for every solution
bool next();
/// represent the top-goal
char *text();
const char *text();
/// remove alternatives in the current search space, and finish the current query
void cut();
/// finish the current query: undo all bindings.
@ -77,8 +73,8 @@ public:
/// class that actually implements the callback.
class YAPCallback {
public:
virtual ~YAPCallback() { printf("~YAPCallback\n"); }
virtual void run() { __android_log_print(ANDROID_LOG_INFO, __FUNCTION__, "callback"); }
virtual ~YAPCallback() { }
virtual void run() { LOG("callback"); }
virtual void run(char *s) { }
};
@ -119,7 +115,10 @@ public:
/// execute the callback with a text argument.
YAPError hasError( ) { return yerror; }
/// build a query on the engine
YAPQuery *query( char *s );
YAPQuery *query( const char *s ) {
s0=s;
return new YAPQuery( s );
};
/// current module for the engine
YAPModule currentModule( ) { return YAPModule( ) ; }
};

View File

@ -18,7 +18,7 @@ protected:
void mk(Term t0); /// internal method to convert from term to handle
Term gt(); /// get handle and obtain term
public:
~YAPTerm() {};
virtual ~YAPTerm() {};
YAPTerm(Term tn) { mk( tn ); } /// private method to convert from Term (internal YAP representation) to YAPTerm
// do nothing constructor
YAPTerm() { mk(TermNil); }
@ -32,7 +32,7 @@ public:
YAP_tag_t tag();
/// copy the term ( term copy )
YAPTerm deepCopy();
inline Term term() { return gt(); } /// private method to convert from YAPTerm to Term (internal YAP representation)
inline Term term() { return gt(); } /// from YAPTerm to Term (internal YAP representation)
//const YAPTerm *vars();
/// this term is == to t1
bool exactlyEqual(YAPTerm t1);
@ -67,7 +67,7 @@ public:
tf = YAPTerm((Term)0);
}
RECOVER_MACHINE_REGS();
//{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "after getArg H= %p, i=%d", HR, tf.gt()) ; }
REGS_LOG( "after getArg H= %p, i=%d", HR, tf.gt()) ;
return tf;
}
@ -78,7 +78,7 @@ public:
/**
* @brief Variable Term
*/
class YAPVarTerm: private YAPTerm {
class YAPVarTerm: public YAPTerm {
YAPVarTerm(Term t) { if (IsVarTerm(t)) mk( t ); }
public:
/// constructor
@ -103,7 +103,7 @@ public:
* @brief Atom Term
* Term Representation of an Atom
*/
class YAPAtomTerm: YAPTerm {
class YAPAtomTerm: public YAPTerm {
friend class YAPModule;
// Constructor: receives a C-atom;
YAPAtomTerm(Atom a) { mk( MkAtomTerm(a) ); }
@ -140,7 +140,7 @@ public:
/**
* @brief Compound Term
*/
class YAPApplTerm: YAPTerm {
class YAPApplTerm: public YAPTerm {
friend class YAPTerm;
YAPApplTerm(Term t0) { mk(t0); }
public:
@ -164,7 +164,7 @@ public:
/**
* @brief List Constructor Term
*/
class YAPPairTerm: YAPTerm {
class YAPPairTerm: public YAPTerm {
friend class YAPTerm;
YAPPairTerm(Term t0) { if (IsPairTerm(t0)) mk( t0 ); else mk(0); }
public:
@ -174,15 +174,24 @@ public:
YAPTerm getTail() { return YAPTerm(TailOfTerm( gt() )); }
};
/**
* @brief Number Term
*/
class YAPNumberTerm: public YAPTerm {
public:
YAPNumberTerm() {};
bool isTagged() { return IsIntTerm( gt() ); }
};
/**
* @brief Integer Term
*/
class YAPIntegerTerm: YAPTerm {
class YAPIntegerTerm: public YAPNumberTerm {
public:
YAPIntegerTerm(intptr_t i);
intptr_t getInteger() { return IntegerOfTerm( gt() ); }
bool isTagged() { return IsIntTerm( gt() ); }
};
class YAPListTerm: public YAPTerm {
@ -218,15 +227,15 @@ public:
return YAPListTerm(TailOfTerm( to ));
else if ( to == TermNil)
return YAPListTerm( );
/* error */;
/* error */
throw YAPError::YAP_TYPE_ERROR;
}
/// Check if the list is empty.
///
/// @param[in] the list
inline bool nil() {
CACHE_REGS
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "II %x %x", gt(), TermNil) ; }
{ LOG( "II %x %x", gt(), TermNil) ; }
return gt() == TermNil;
}
@ -236,7 +245,7 @@ public:
/**
* @brief String Term
*/
class YAPStringTerm: private YAPTerm {
class YAPStringTerm: public YAPTerm {
public:
/// your standard constructor
YAPStringTerm(char *s) ;

View File

@ -126,7 +126,7 @@ typedef struct PropEntryStruct
typedef CELL arity_t;
#define FunctorProperty ((PropFlags)(0xbb00))
#define FunctorProperty ((PropFlags)(0xbb00))
/* functor property */
typedef struct FunctorEntryStruct

49
H/Yap.h
View File

@ -1,4 +1,4 @@
/*************************************************************************
/*************************************************************************
* *
* YAP Prolog %W% %G% *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
@ -505,16 +505,19 @@ extern int Yap_output_msg;
#if __ANDROID__
#include <jni.h>
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#include <android/log.h>
#else
static inline char * __android_log_print(int i,const char *loc,const char *msg,...) {
return NULL;
}
#define ANDROID_LOG_INFO 0
#define ANDROID_LOG_ERROR 0
#define ANDROID_LOG_DEBUG 0
extern AAssetManager * Yap_assetManager;
extern void *Yap_openAssetFile( const char *path ) ;
extern bool Yap_isAsset( const char *path );
extern bool Yap_AccessAsset( const char *name , int mode);
extern bool Yap_AssetIsFile( const char *name );
extern bool Yap_AssetIsDir( const char *name );
extern int64_t Yap_AssetSize( const char *name );
#endif
@ -858,4 +861,34 @@ Global variables for JIT
#endif
#endif
#if DEBUGX
inline static void
LOG0(const char *f, int l, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
#if __ANDROID__
__android_log_print(ANDROID_LOG_INFO, "YAP ", fmt, ap);
#else __WINDOWS__
FILE * fd;
fd = fopen("c:\\cygwin\\Log.txt", "a");
vfprintf(fd, fmt, ap);
fclose(fd);
#endif
vfprintf(stderr, fmt, ap);
va_end(ap);
}
#else
#define LOG0( ... )
#endif
#ifndef __ANDROID__
#define __android_log_print( ... )
#endif
#define LOG( ... ) LOG0( __FILE__, __LINE__, __VA_ARGS__ )
#define REGS_LOG( ... ) CACHE_REGS LOG0( __FILE__, __LINE__, __VA_ARGS__ )
#endif /* YAP_H */

View File

@ -87,9 +87,10 @@ Yap_CurrentSlot( USES_REGS1 ) {
return LOCAL_CurSlot;
}
#define Yap_GetFromSlot(slot) Yap_GetFromSlot__(slot PASS_REGS)
/// @brief read from a slot.
static inline Term
Yap_GetFromSlot(yhandle_t slot USES_REGS)
Yap_GetFromSlot__(yhandle_t slot USES_REGS)
{
return(Deref(LOCAL_SlotBase[slot]));
}
@ -142,9 +143,11 @@ ensure_slots(int N USES_REGS)
}
}
#define Yap_InitSlot( t ) Yap_InitSlot__( t PASS_REGS )
/// @brief create a new slot with term t
static inline Int
Yap_InitSlot(Term t USES_REGS)
static inline yhandle_t
Yap_InitSlot__(Term t USES_REGS)
{
yhandle_t old_slots = LOCAL_CurSlot;
@ -154,9 +157,11 @@ Yap_InitSlot(Term t USES_REGS)
return old_slots;
}
#define Yap_NewSlots( n ) Yap_NewSlots__( n PASS_REGS )
/// @brief allocate n empty new slots
static inline yhandle_t
Yap_NewSlots(int n USES_REGS)
Yap_NewSlots__(int n USES_REGS)
{
yhandle_t old_slots = LOCAL_CurSlot;
int i;

View File

@ -371,7 +371,13 @@ int Yap_signal_index(const char *);
#ifdef MAC
void Yap_SetTextFile(char *);
#endif
char *Yap_getcwd(const char *, size_t);
#if __ANDROIDD__
extern AAssetManager * Yap_assetManager;
extern void *Yap_openAssetFile( const char *path ) ;
extern bool Yap_isAsset( const char *path );
#endif
const char *Yap_getcwd(const char *, size_t);
void Yap_cputime_interval(Int *,Int *);
void Yap_systime_interval(Int *,Int *);
void Yap_walltime_interval(Int *,Int *);
@ -465,5 +471,3 @@ gc_P(yamop *p, yamop *cp)
{
return (p->opc == Yap_opcode(_execute_cpred) ? cp : p);
}

View File

@ -754,7 +754,7 @@ typedef enum {
will not be aligned on RISC machines */
profile_data StatisticsForPred; /* enable profiling for predicate */
struct pred_entry *NextPredOfModule; /* next pred for same module */
} PredEntry;
} PredEntry;
#define PEProp ((PropFlags)(0x0000))
#if USE_OFFSETS_IN_PROPS
@ -1898,4 +1898,3 @@ AddPropToAtom(AtomEntry *ae, PropEntry *p)
#endif

View File

@ -1089,8 +1089,6 @@ extern void **Yap_ABSMI_OPCODES;
#endif
#if DEPTH_LIMIT
/*
Make this into an even number so that the system will know

View File

@ -1,4 +1,4 @@
/*************************************************************************
/*************************************************************************
* *
* YAP Prolog *
* *
@ -25,4 +25,3 @@ typedef struct array_access_struct {
Term indx; /* index in array, for now
keep it as an integer! */
} array_access;

View File

@ -301,6 +301,7 @@ LogUpdClause *Yap_FollowIndexingCode(PredEntry *,yamop *, Term *, yamop *,yamop
yamop *Yap_ExoLookup(PredEntry *ap USES_REGS);
CELL Yap_NextExo(choiceptr cpt, struct index_t *it);
#
#if USE_THREADED_CODE
#define OP_HASH_SIZE 2048

View File

@ -38,6 +38,7 @@
#if __ANDROID__
#define GLOBAL_assetManager Yap_global->assetManager_
#define GLOBAL_AssetsWD Yap_global->AssetsWD_
#endif
#if THREADS

View File

@ -38,6 +38,7 @@ typedef struct global_data {
#if __ANDROID__
struct AAssetManager* assetManager_;
char* AssetsWD_;
#endif
#if THREADS

View File

@ -37,7 +37,8 @@ static void InitGlobal(void) {
GLOBAL_AGCHook = NULL;
#if __ANDROID__
GLOBAL_assetManager = GLOBAL_assetManager;
GLOBAL_assetManager = NULL;
GLOBAL_AssetsWD = NULL;
#endif
#if THREADS

View File

@ -33,14 +33,14 @@ CLOSE_SEQ_STRING(Word p, Word p0, term_t tail, term_t term, term_t l) {
p--;
if (tail) {
RESET_VARIABLE(p);
if (Yap_unify(Yap_GetFromSlot(l PASS_REGS), Yap_GetFromSlot(term PASS_REGS))) {
if (Yap_unify(Yap_GetFromSlot(l), Yap_GetFromSlot(term))) {
Yap_PutInSlot(tail, (CELL)(p) PASS_REGS);
return TRUE;
}
return FALSE;
} else {
p[0] = TermNil;
return Yap_unify(Yap_GetFromSlot(l PASS_REGS), Yap_GetFromSlot(term PASS_REGS));
return Yap_unify(Yap_GetFromSlot(l), Yap_GetFromSlot(term ));
}
}

View File

@ -188,6 +188,7 @@ typedef struct {
int optimise; /* -O: optimised compilation */
} cmdline;
#if 0
struct
{ //char * CWDdir;
//size_t CWDlen;
@ -196,6 +197,7 @@ typedef struct {
char * module; /* argv[0] module passed */
#endif
} paths;
#endif
struct
{ ExtensionCell _ext_head; /* head of registered extensions */
@ -411,4 +413,3 @@ typedef struct PL_local_data {
extern PL_local_data_t lds;
#endif

View File

@ -242,7 +242,7 @@ users foreign language code.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#define NOTRACE PL_FA_NOTRACE
#define META PL_FA_TRANSPARENT
#define METAP PL_FA_TRANSPARENT
#define NDET PL_FA_NONDETERMINISTIC
#define VA PL_FA_VARARGS
#define CREF PL_FA_CREF

View File

@ -75,7 +75,7 @@ COMMON(word) pl_writeq(term_t term);
static inline int
get_procedure(term_t descr, predicate_t *proc, term_t he, int f) {
CACHE_REGS
Term t = Yap_GetFromSlot(descr PASS_REGS);
Term t = Yap_GetFromSlot(descr );
if (IsVarTerm(t)) return FALSE;
if (IsAtomTerm(t))
@ -143,7 +143,7 @@ atomName(Atom atom)
Procedure resolveProcedure(functor_t f, Module module);
#define charEscapeWriteOption(A) FALSE // VSC: to implement
#define wordToTermRef(A) Yap_InitSlot(*(A) PASS_REGS)
#define wordToTermRef(A) Yap_InitSlot(*(A))
#define isTaggedInt(A) IsIntegerTerm(A)
#define valInt(A) IntegerOfTerm(A)

View File

@ -38,6 +38,7 @@ static void RestoreGlobal(void) {
#if __ANDROID__
#endif
#if THREADS

View File

@ -18,19 +18,21 @@ YAPLIBDIR=@libdir@/Yap
#
# where YAP should look for architecture-independent Prolog libraries
#
SHAREDIR=$(ROOTDIR)/share
DATAROOTDIR=@datarootdir@
#
SHAREDIR=$(DATAROOTDIR)
#
# where the includes should be stored
#
INCLUDEDIR=$(ROOTDIR)/include/Yap
INCLUDEDIR=@includedir@/Yap
#
# where to store info files
#
INFODIR=$(SHAREDIR)/info
INFODIR=$(DATAROOTDIR)/info
#
# where to store documentation files
#
DOCSDIR=$(SHAREDIR)/doc/Yap
DOCSDIR=$(SHAREDIR)/doc/yap
#
# Add this flag to YAP_EXTRAS if you need the extension:
@ -413,8 +415,8 @@ JIT_OBJECTS = \
@JITDEBUGPREDS@ \
@JITSTATISTICPREDS@
MYDDAS_OBJECTS = \
@INCLUDE_MYDDAS@ myddas_initialization.o \
MYDDAS_ALL_OBJECTS = \
myddas_initialization.o \
myddas_mysql.o \
myddas_odbc.o \
myddas_postgres.o \
@ -424,6 +426,8 @@ MYDDAS_OBJECTS = \
myddas_util.o \
myddas_wkb2prolog.o
MYDDAS_OBJECTS = @OBJECTS_MYDDAS@
LIBTAI_OBJECTS = \
tai_add.o tai_now.o tai_pack.o \
tai_sub.o tai_unpack.o taia_add.o taia_approx.o \
@ -465,7 +469,15 @@ PLCONS_OBJECTS = \
pl-ntmain.o \
yapres.o
all: startup.yss @WINDOWS@ yap-win@EXEC_SUFFIX@
all: "$(STARTUP_ANDROID)android-setup startup.yss windowsi
xandroid-setup:
( cd packages/swig && make android/jni/Android.mk )
android-setup:
windowsi:
@WINDOWS@ yap-win@EXEC_SUFFIX@
Makefile: Makefile.in
@ -507,7 +519,7 @@ save.o: C/save.c
%.o: BEAM/%.c config.h
$(CC) -c $(CFLAGS) $< -o $@
yapi.o: CXX/yapi.cpp CXX/yapi.hh config.h
yapi.o: CXX/yapi.cpp CXX/yapi.hh CXX/yapq.hh CXX/yapt.hh CXX/yapdb.hh CXX/yapie.hh CXX/yapa.hh config.h
$(CXX) -c $(CXXFLAGS) $< -o $@
sys.o: library/system/sys.c config.h
@ -640,34 +652,27 @@ libYap.a: $(LIB_OBJECTS) yapi.o
done
@STARTUP_ANDROID@startup.yss: yap@EXEC_SUFFIX@ @DYNYAPLIB@ $(PL_SOURCES) $(SWI_LIB_SOURCES)
adb shell rm -rf /data/yap
adb shell mkdir -p /data/yap
adb shell mkdir -p /data/yap/pl
adb shell mkdir -p /data/yap/swi/library
adb shell mkdir -p /data/yap/packages/chr
adb shell mkdir -p /data/yap/packages/clib
adb shell mkdir -p /data/yap/packages/myddas
adb shell mkdir -p /data/yap/assets/myddas
adb shell mkdir -p /data/yap/assets/lib
adb shell mkdir -p /data/yap/assets/share
adb push yap /data/yap/
adb push @DYNYAPLIB@ /data/yap/
\rm -rf data/yap
mkdir -p data/yap/packages
mkdir -p data/yap/swi
cp -a yap data/yap
cp -a @DYNYAPLIB@ data/yap
for p in $(EXTRAYAPLIBS); do \
adb shell $(LN_S) /data/yap/@DYNYAPLIB@ /data/yap/$$p; \
(cd data/yap && $(LN_S) @DYNYAPLIB@ $$p ); \
done
adb push $(GMPDIR)/lib/libgmp.so /data/yap
adb push $(SQLITE3DIR)/lib/libsqliteX.so /data/yap
#adb push packages/clib/*.so /data/yap
#adb push library/system/*.so /data/yap
adb push $(srcdir)/swi/library /data/yap/swi/library
adb push $(srcdir)/pl /data/yap/pl/
adb push $(srcdir)/library /data/yap/library/
adb push $(srcdir)/packages/myddas /data/yap/packages/myddas/
adb push $(srcdir)/packages/chr /data/yap/packages/chr/
adb push $(srcdir)/packages/clib /data/yap/packages/clib/
cp -a ../../gmp-android/lib/libgmp.so data/yap
cp -a ../../sqlite3-android/lib/libsqliteX.so data/yap
cp -a $(srcdir)/pl data/yap
cp -a $(srcdir)/library data/yap
cp -a $(srcdir)/swi/library data/yap/swi
cp -a $(srcdir)/packages/clib data/yap/packages
cp -a $(srcdir)/packages/chr data/yap/packages
cp -a $(srcdir)/packages/myddas data/yap/packages
\rm -rf data/yap/packages/*/.git
adb push data/yap /data/yap >/dev/null 2>&1
adb shell "echo \"bootstrap('/data/yap/pl/init.yap'). module(user). qsave_program('/data/yap/startup.yss').\" | LD_LIBRARY_PATH=/data/yap /data/yap/yap@EXEC_SUFFIX@ -b /data/yap/pl/boot.yap"
adb pull /data/yap/startup.yss
#adb shell rm -rf /data/yap
install: @INSTALL_COMMAND@ install_startup install_common

View File

@ -1,8 +1,5 @@
/* config.h.in. Generated from configure.in by autoheader. */
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
/* longs should be in addresses that are multiple of four. */
#undef ALIGN_LONGS
@ -331,9 +328,6 @@
/* Define to 1 if you have the <gmp.h> header file. */
#undef HAVE_GMP_H
/* Define to 1 if you have the `gmtime' function. */
#undef HAVE_GMTIME
/* Define of h_errno is provided */
#undef HAVE_H_ERRNO
@ -475,9 +469,6 @@
/* Define to 1 if you have the `localtime' function. */
#undef HAVE_LOCALTIME
/* Define to 1 if the system has the type `long long'. */
#undef HAVE_LONG_LONG
/* Define to 1 if you have the `lstat' function. */
#undef HAVE_LSTAT
@ -743,12 +734,6 @@
/* Define to 1 if you have the <sqlite3.h> header file. */
#undef HAVE_SQLITE3_H
/* Define to 1 if the system has the type `SQLLEN'. */
#undef HAVE_SQLLEN
/* Define to 1 if the system has the type `SQLULEN'. */
#undef HAVE_SQLULEN
/* Define to 1 if you have the <sql.h> header file. */
#undef HAVE_SQL_H
@ -884,9 +869,6 @@
/* Define to 1 if you have the `time' function. */
#undef HAVE_TIME
/* Define to 1 if you have the `timegm' function. */
#undef HAVE_TIMEGM
/* Define to 1 if you have the `times' function. */
#undef HAVE_TIMES
@ -1067,9 +1049,6 @@
/* The size of `short int', as computed by sizeof. */
#undef SIZEOF_SHORT_INT
/* The size of `SQLWCHAR', as computed by sizeof. */
#undef SIZEOF_SQLWCHAR
/* The size of `void*', as computed by sizeof. */
#undef SIZEOF_VOIDP
@ -1130,18 +1109,6 @@
/* Define to name of the UUID header file. */
#undef UUID_H
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
# undef WORDS_BIGENDIAN
# endif
#endif
/* architecture */
#undef YAP_ARCH
@ -1157,13 +1124,13 @@
/* numerical version */
#undef YAP_NUMERIC_VERSION
/* where to look for Prolog sources */
/* where YAP lives */
#undef YAP_PL_SRCDIR
/* where YAP lives */
#undef YAP_ROOTDIR
/* where to look for the Prolog library */
/* where YAP lives */
#undef YAP_SHAREDIR
/* saved state file */

774
configure vendored
View File

@ -690,16 +690,12 @@ CPLINT_LIBS
CUDD_CPPFLAGS
CUDD_LIBS
PKG_BDDLIB
ODBC_LIBS
ODBC_LDFLAGS
ODBC_CFLAGS
ODBC_PLTARGETS
ODBC_TARGETS
ARCHIVE_LDFLAGS
ARCHIVE_CPPFLAGS
ARCHIVE_LIBS
ARCHIVE_PLTARGETS
ARCHIVE_TARGETS
CLIB_CPPFLAGS
CLIB_LIBUUID
CLIB_CRYPTOBJ
CLIB_CRYPTLIBS
@ -725,7 +721,7 @@ JITFLAGS
LLVM_CONFIG
MYDDAS_LIBS
MYDDAS_CPPFLAGS
INCLUDE_MYDDAS
OBJECTS_MYDDAS
PKG_MYDDAS
EXTRA_LIBS_FOR_SWIDLLS
CLIB_PTHREADS
@ -1613,7 +1609,6 @@ Optional Packages:
--without-time Exclude alarm library
--with-libarchive=DIR libarchive package
--with-odbc=<dir> Location of ODBC include/lib
--with-cudd=DIR use CUDD package in DIR
--with-cplint=DIR with the cplint library using the CUDD library in DIR/lib
--with-zlib=DIR zlib compression library
@ -7259,13 +7254,6 @@ else
PKG_LIBARCHIVE=""
fi
if test -e "$srcdir"/packages/odbc/Makefile.in
then
PKG_ODBC="packages/odbc"
else
PKG_ODBC=""
fi
if test "$use_chr" = no
then
PKG_CHR=""
@ -11219,11 +11207,11 @@ else
ENABLE_MYDDAS=""
fi
INCLUDE_MYDDAS="#"
OBJECTS_MYDDAS="#"
if test x"$ENABLE_MYDDAS" = x -a x"$STARTUP_ANDROID" = x
then
#in Android we have to actually include myddas in the binary
INCLUDE_MYDDAS=""
OBJECTS_MYDDAS="$(ALL_MYDDAS_OBJECTS)"
fi
@ -12215,6 +12203,7 @@ fi
CLIB_TARGETS="socket.$SO cgi.$SO memfile.$SO files.$SO mime.$SO crypt.$SO time.$SO"
case "$PLARCH" in
@ -12394,7 +12383,69 @@ fi
fi
dl to be installed in various places.
# brew in OSX
if test -d /usr/local/opt/ossp-uuid; then
CPPFLAGS="$CPPFLAGS -I /usr/local/opt/ossp-uuid/include"
UUID_LIB_PATH="-L /usr/local/opt/ossp-uuid/lib"
fi
# /opt
if test -d /opt/include/ossp; then
CPPFLAGS="$CPPFLAGS -I /opt/include"
UUID_LIB_PATH="-L /opt/lib"
fi
# /usr/local
if test -d /opt/include/ossp; then
CPPFLAGS="$CPPFLAGS -I /opt/include"
UUID_LIB_PATH="-L /opt/lib"
fi
if test x"$UUID_H" = "x"; then
ac_fn_c_check_header_compile "$LINENO" "ossp/uuid.h" "ac_cv_header_ossp_uuid_h" "/*first*/
"
if test "x$ac_cv_header_ossp_uuid_h" = xyes; then :
UUID_H=ossp/uuid.h
has_uuid=true
fi
fi
if test x"$UUID_H" = "x" -a ! -d /usr/include/uuid; then
ac_fn_c_check_header_compile "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "/*first*/
"
if test "x$ac_cv_header_uuid_uuid_h" = xyes; then :
UUID_H=uuid/uuid.h
has_uuid=true
fi
fi
if test x"$UUID_H" = "x"; then
ac_fn_c_check_header_compile "$LINENO" "uuid.h" "ac_cv_header_uuid_h" "/*first*/
"
if test "x$ac_cv_header_uuid_h" = xyes; then :
UUID_H=uuid.h
has_uuid=true
fi
fi
if test x"$UUID_H" = "x"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find uuid.h -- dropping uuid.pl" >&5
$as_echo "$as_me: WARNING: Cannot find uuid.h -- dropping uuid.pl" >&2;}
else
cat >>confdefs.h <<_ACEOF
#define UUID_H <$UUID_H>
_ACEOF
has_uuid=true
fi
if test x"$has_uuid" != "x"; then
ac_fn_c_check_func "$LINENO" "uuid_create" "ac_cv_func_uuid_create"
if test "x$ac_cv_func_uuid_create" = xyes; then :
has_uuid=true
@ -12438,7 +12489,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_create" >&5
$as_echo "$ac_cv_lib_uuid_uuid_create" >&6; }
if test "x$ac_cv_lib_uuid_uuid_create" = xyes; then :
CLIB_LIBUUID=-luuid
CLIB_LIBUUID="$UUID_LIB_PATH -luuid"
has_uuid=true
fi
@ -12452,45 +12503,6 @@ $as_echo "$as_me: WARNING: Cannot find libossp-uuid or libuuid -- dropping uuid
fi
if test x"$has_uuid" != "x"; then
if test x"$UUID_H" = "x"; then
ac_fn_c_check_header_compile "$LINENO" "ossp/uuid.h" "ac_cv_header_ossp_uuid_h" "/*first*/
"
if test "x$ac_cv_header_ossp_uuid_h" = xyes; then :
UUID_H=ossp/uuid.h
fi
fi
if test x"$UUID_H" = "x" -a ! -d /usr/include/uuid; then
ac_fn_c_check_header_compile "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "/*first*/
"
if test "x$ac_cv_header_uuid_uuid_h" = xyes; then :
UUID_H=uuid/uuid.h
fi
fi
if test x"$UUID_H" = "x"; then
ac_fn_c_check_header_compile "$LINENO" "uuid.h" "ac_cv_header_uuid_h" "/*first*/
"
if test "x$ac_cv_header_uuid_h" = xyes; then :
UUID_H=uuid.h
fi
fi
if test x"$UUID_H" = "x"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find uuid.h -- dropping uuid.pl" >&5
$as_echo "$as_me: WARNING: Cannot find uuid.h -- dropping uuid.pl" >&2;}
else
cat >>confdefs.h <<_ACEOF
#define UUID_H <$UUID_H>
_ACEOF
CLIB_TARGETS="$CLIB_TARGETS uuid.$SO"
fi
fi
@ -12835,6 +12847,7 @@ if echo "$CLIB_PLTARGETS" | grep socket.pl 2>&1 >/dev/null; then
CLIB_PLTARGETS="$CLIB_PLTARGETS streampool.pl"
fi
CLIB_CPPFLAGS="$CPPFLAGS"
@ -13024,608 +13037,6 @@ fi
fi
if test "$PKG_ODBC" != ""; then
# Check whether --with-odbc was given.
if test "${with_odbc+set}" = set; then :
withval=$with_odbc; case $withval in
no|yes) echo 'Specify dir for ODBC please';
exit 1 ;;
*) ODBC_DIR=${withval}
esac
fi
if test ! -z "$ODBC_DIR"; then
ODBC_CFLAGS="-I${ODBC_DIR}/include"
ODBC_LDFLAGS="-L${ODBC_DIR}/lib"
CFLAGS="-I${ODBC_DIR}/include ${CFLAGS}"
CPPFLAGS="-I${ODBC_DIR}/include ${CPPFLAGS}"
CIFLAGS="-I${ODBC_DIR}/include ${CIFLAGS}"
LDFLAGS="-L${ODBC_DIR}/lib ${LDFLAGS}"
fi
havelib=no
case "$PLARCH" in
*-win32|*-win64)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lodbc32" >&5
$as_echo_n "checking for main in -lodbc32... " >&6; }
if ${ac_cv_lib_odbc32_main+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lodbc32 $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_odbc32_main=yes
else
ac_cv_lib_odbc32_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_odbc32_main" >&5
$as_echo "$ac_cv_lib_odbc32_main" >&6; }
if test "x$ac_cv_lib_odbc32_main" = xyes; then :
ODBC_LIBS="-lodbc32 $LIBS"
havelib=yes
fi
;;
*)
if test $havelib = no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SQLAllocEnv in -lodbc" >&5
$as_echo_n "checking for SQLAllocEnv in -lodbc... " >&6; }
if ${ac_cv_lib_odbc_SQLAllocEnv+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lodbc $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 SQLAllocEnv ();
int
main ()
{
return SQLAllocEnv ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_odbc_SQLAllocEnv=yes
else
ac_cv_lib_odbc_SQLAllocEnv=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_odbc_SQLAllocEnv" >&5
$as_echo "$ac_cv_lib_odbc_SQLAllocEnv" >&6; }
if test "x$ac_cv_lib_odbc_SQLAllocEnv" = xyes; then :
ODBC_LIBS="-lodbc $LIBS"
havelib=yes
fi
if test $havelib = no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SQLAllocEnv in -liodbc" >&5
$as_echo_n "checking for SQLAllocEnv in -liodbc... " >&6; }
if ${ac_cv_lib_iodbc_SQLAllocEnv+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-liodbc $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 SQLAllocEnv ();
int
main ()
{
return SQLAllocEnv ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_iodbc_SQLAllocEnv=yes
else
ac_cv_lib_iodbc_SQLAllocEnv=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iodbc_SQLAllocEnv" >&5
$as_echo "$ac_cv_lib_iodbc_SQLAllocEnv" >&6; }
if test "x$ac_cv_lib_iodbc_SQLAllocEnv" = xyes; then :
ODBC_LIBS="-liodbc $LIBS"
havelib=yes
fi
fi
fi
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
$as_echo_n "checking whether byte ordering is bigendian... " >&6; }
if ${ac_cv_c_bigendian+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_cv_c_bigendian=unknown
# See if we're dealing with a universal compiler.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifndef __APPLE_CC__
not a universal capable compiler
#endif
typedef int dummy;
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
# Check for potential -arch flags. It is not universal unless
# there are at least two -arch flags with different values.
ac_arch=
ac_prev=
for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do
if test -n "$ac_prev"; then
case $ac_word in
i?86 | x86_64 | ppc | ppc64)
if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then
ac_arch=$ac_word
else
ac_cv_c_bigendian=universal
break
fi
;;
esac
ac_prev=
elif test "x$ac_word" = "x-arch"; then
ac_prev=arch
fi
done
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test $ac_cv_c_bigendian = unknown; then
# See if sys/param.h defines the BYTE_ORDER macro.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
#include <sys/param.h>
int
main ()
{
#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \
&& defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \
&& LITTLE_ENDIAN)
bogus endian macros
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
# It does; now see whether it defined to BIG_ENDIAN or not.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
#include <sys/param.h>
int
main ()
{
#if BYTE_ORDER != BIG_ENDIAN
not big endian
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_c_bigendian=yes
else
ac_cv_c_bigendian=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
if test $ac_cv_c_bigendian = unknown; then
# See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris).
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <limits.h>
int
main ()
{
#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
bogus endian macros
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
# It does; now see whether it defined to _BIG_ENDIAN or not.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <limits.h>
int
main ()
{
#ifndef _BIG_ENDIAN
not big endian
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_c_bigendian=yes
else
ac_cv_c_bigendian=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
if test $ac_cv_c_bigendian = unknown; then
# Compile a test program.
if test "$cross_compiling" = yes; then :
# Try to guess by grepping values from an object file.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
short int ascii_mm[] =
{ 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
short int ascii_ii[] =
{ 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
int use_ascii (int i) {
return ascii_mm[i] + ascii_ii[i];
}
short int ebcdic_ii[] =
{ 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
short int ebcdic_mm[] =
{ 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
int use_ebcdic (int i) {
return ebcdic_mm[i] + ebcdic_ii[i];
}
extern int foo;
int
main ()
{
return use_ascii (foo) == use_ebcdic (foo);
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then
ac_cv_c_bigendian=yes
fi
if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
if test "$ac_cv_c_bigendian" = unknown; then
ac_cv_c_bigendian=no
else
# finding both strings is unlikely to happen, but who knows?
ac_cv_c_bigendian=unknown
fi
fi
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$ac_includes_default
int
main ()
{
/* Are we little or big endian? From Harbison&Steele. */
union
{
long int l;
char c[sizeof (long int)];
} u;
u.l = 1;
return u.c[sizeof (long int) - 1] == 1;
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
ac_cv_c_bigendian=no
else
ac_cv_c_bigendian=yes
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5
$as_echo "$ac_cv_c_bigendian" >&6; }
case $ac_cv_c_bigendian in #(
yes)
$as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h
;; #(
no)
;; #(
universal)
$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
;; #(
*)
as_fn_error $? "unknown endianness
presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
esac
for ac_header in malloc.h time.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in sql.h
do :
ac_fn_c_check_header_compile "$LINENO" "sql.h" "ac_cv_header_sql_h" "
#ifdef __WINDOWS__
#include <windef.h>
#endif
"
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" "long long" "ac_cv_type_long_long" "$ac_includes_default"
if test "x$ac_cv_type_long_long" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LONG_LONG 1
_ACEOF
fi
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5
$as_echo_n "checking size of long... " >&6; }
if ${ac_cv_sizeof_long+:} false; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then :
else
if test "$ac_cv_type_long" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (long)
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_long=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5
$as_echo "$ac_cv_sizeof_long" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_LONG $ac_cv_sizeof_long
_ACEOF
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of SQLWCHAR" >&5
$as_echo_n "checking size of SQLWCHAR... " >&6; }
if ${ac_cv_sizeof_SQLWCHAR+:} false; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (SQLWCHAR))" "ac_cv_sizeof_SQLWCHAR" "
#ifdef __WINDOWS__
#include <windef.h>
#endif
#include <sql.h>
"; then :
else
if test "$ac_cv_type_SQLWCHAR" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (SQLWCHAR)
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_SQLWCHAR=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_SQLWCHAR" >&5
$as_echo "$ac_cv_sizeof_SQLWCHAR" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_SQLWCHAR $ac_cv_sizeof_SQLWCHAR
_ACEOF
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of wchar_t" >&5
$as_echo_n "checking size of wchar_t... " >&6; }
if ${ac_cv_sizeof_wchar_t+:} false; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (wchar_t))" "ac_cv_sizeof_wchar_t" "$ac_includes_default"; then :
else
if test "$ac_cv_type_wchar_t" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (wchar_t)
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_wchar_t=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_wchar_t" >&5
$as_echo "$ac_cv_sizeof_wchar_t" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_WCHAR_T $ac_cv_sizeof_wchar_t
_ACEOF
ac_fn_c_check_type "$LINENO" "SQLLEN" "ac_cv_type_SQLLEN" "
#ifdef __WINDOWS__
#include <windef.h>
#endif
#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" "
#ifdef __WINDOWS__
#include <windef.h>
#endif
#include <sql.h>
"
if test "x$ac_cv_type_SQLULEN" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SQLULEN 1
_ACEOF
fi
if test "$havelib" = yes &&
test "$ac_cv_header_sql_h" = yes; then
ODBC_TARGETS="odbc4pl.$SO"
else
echo "ERROR: Cannot find odbc library or the header sql.h"
echo "WARNING: ODBC interface will not be built"
ODBC_TARGETS=""
fi
ODBC_PLTARGETS=`echo $ODBC_TARGETS | sed "s/4pl\.$SO/.pl/g"`
if test "$ODBC_TARGETS" = "nolib"
then
PKG_ODBC=""
fi
else
ODBC_TARGETS=nolib
ODBC_PLTARGETS=odbc.pl
fi
# Check whether --with-cudd was given.
@ -14731,7 +14142,7 @@ else
JAVA_TEST=Test.java
CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST
/* #line 14734 "configure" */
/* #line 14145 "configure" */
public class Test {
}
EOF
@ -14907,7 +14318,7 @@ EOF
if uudecode$EXEEXT Test.uue; then
ac_cv_prog_uudecode_base64=yes
else
echo "configure: 14910: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
echo "configure: 14321: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
echo "configure: failed file was:" >&5
cat Test.uue >&5
ac_cv_prog_uudecode_base64=no
@ -15038,7 +14449,7 @@ else
JAVA_TEST=Test.java
CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST
/* #line 15041 "configure" */
/* #line 14452 "configure" */
public class Test {
}
EOF
@ -15073,7 +14484,7 @@ JAVA_TEST=Test.java
CLASS_TEST=Test.class
TEST=Test
cat << \EOF > $JAVA_TEST
/* [#]line 15076 "configure" */
/* [#]line 14487 "configure" */
public class Test {
public static void main (String args[]) {
System.exit (0);
@ -16054,7 +15465,6 @@ LTLIBOBJS=$ac_ltlibobjs
: "${CONFIG_STATUS=./config.status}"
ac_write_fail=0
ac_clean_files_save=$ac_clean_files
@ -17741,10 +17151,11 @@ fi
if test "$PKG_SWIG" != ""; then
mkdir -p packages/swig/android
mkdir -p packages/swig/android/usr
mkdir -p packages/swig/python
mkdir -p packages/swig/R
mkdir -p packages/swig/java
mkdir -p packages/swig/fli
mkdir -p packages/swig/jni
@ -18208,6 +17619,10 @@ yap_timestamp=`date`
yap_nversion=`expr $YAP_MAJOR_VERSION \* 10000 + $YAP_MINOR_VERSION \* 100 + $YAP_POINT_VERSION`
yap_startup=startup.yss
BINDIR=$bindir
DATAROOTDIR="$prefix"/share
BINDIR="$bindir"
cat >>confdefs.h <<_ACEOF
#define YAP_STARTUP "$yap_startup"
@ -18255,7 +17670,7 @@ _ACEOF
cat >>confdefs.h <<_ACEOF
#define YAP_BINDIR "$prefix/bin"
#define YAP_BINDIR "$BINDIR"
_ACEOF
@ -18265,7 +17680,7 @@ _ACEOF
cat >>confdefs.h <<_ACEOF
#define YAP_LIBDIR "$prefix/lib/Yap"
#define YAP_LIBDIR "$LIBDIR/Yap"
_ACEOF
@ -18274,18 +17689,18 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
cat >>confdefs.h <<_ACEOF
#define YAP_PL_SRCDIR "$prefix/share/Yap/pl"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define YAP_ROOTDIR "$prefix"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define YAP_SHAREDIR "$prefix/share"
#define YAP_SHAREDIR "$DATAROOTDIR"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define YAP_PL_SRCDIR "$DATAROOTDIR/Yap/pl"
_ACEOF
@ -18347,7 +17762,6 @@ mkdir -p packages/prism/src/c/up
mkdir -p packages/prism/src/prolog
mkdir -p packages/ProbLog
mkdir -p packages/ProbLog/simplecudd
mkdir -p packages/prosqlite
mkdir -p packages/R
mkdir -p packages/RDF
mkdir -p packages/real
@ -18468,12 +17882,6 @@ ac_config_files="$ac_config_files packages/archive/Makefile"
fi
if test "$PKG_ODBC" != ""; then
ac_config_files="$ac_config_files packages/odbc/Makefile"
fi
if test "$PKG_MINISAT" != ""; then
ac_config_files="$ac_config_files packages/swi-minisat2/Makefile"
@ -18507,11 +17915,6 @@ ac_config_files="$ac_config_files packages/prism/src/prolog/Makefile"
fi
if test "$PKG_PROSQLITE" != ""; then
ac_config_files="$ac_config_files packages/prosqlite/Makefile"
fi
if test "$PKG_WINCONSOLE" != ""; then
ac_config_files="$ac_config_files swi/console/Makefile"
@ -18630,7 +18033,6 @@ LTLIBOBJS=$ac_ltlibobjs
: "${CONFIG_STATUS=./config.status}"
ac_write_fail=0
ac_clean_files_save=$ac_clean_files
@ -19262,7 +18664,6 @@ 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/swi-minisat2/Makefile") CONFIG_FILES="$CONFIG_FILES packages/swi-minisat2/Makefile" ;;
"packages/swi-minisat2/C/Makefile") CONFIG_FILES="$CONFIG_FILES packages/swi-minisat2/C/Makefile" ;;
"packages/real/Makefile") CONFIG_FILES="$CONFIG_FILES packages/real/Makefile" ;;
@ -19272,7 +18673,6 @@ do
"packages/CLPBN/horus/Makefile") CONFIG_FILES="$CONFIG_FILES packages/CLPBN/horus/Makefile" ;;
"packages/prism/src/c/Makefile") CONFIG_FILES="$CONFIG_FILES packages/prism/src/c/Makefile" ;;
"packages/prism/src/prolog/Makefile") CONFIG_FILES="$CONFIG_FILES packages/prism/src/prolog/Makefile" ;;
"packages/prosqlite/Makefile") CONFIG_FILES="$CONFIG_FILES packages/prosqlite/Makefile" ;;
"swi/console/Makefile") CONFIG_FILES="$CONFIG_FILES swi/console/Makefile" ;;
"packages/yap-lbfgs/Makefile") CONFIG_FILES="$CONFIG_FILES packages/yap-lbfgs/Makefile" ;;

View File

@ -793,13 +793,6 @@ else
PKG_LIBARCHIVE=""
fi
if test -e "$srcdir"/packages/odbc/Makefile.in
then
PKG_ODBC="packages/odbc"
else
PKG_ODBC=""
fi
if test "$use_chr" = no
then
PKG_CHR=""
@ -2038,21 +2031,6 @@ fi
fi
if test "$PKG_ODBC" != ""; then
m4_include([packages/odbc/configure.in])
if test "$ODBC_TARGETS" = "nolib"
then
PKG_ODBC=""
fi
else
ODBC_TARGETS=nolib
ODBC_PLTARGETS=odbc.pl
fi
m4_include([packages/bdd/configure.in])
m4_include([packages/cplint/configure.in])
@ -2131,6 +2109,10 @@ yap_timestamp=`date`
yap_nversion=`expr $YAP_MAJOR_VERSION \* 10000 + $YAP_MINOR_VERSION \* 100 + $YAP_POINT_VERSION`
yap_startup=startup.yss
BINDIR=$bindir
DATAROOTDIR="$prefix"/share
BINDIR="$bindir"
AC_DEFINE_UNQUOTED(YAP_STARTUP, [ "$yap_startup" ], [saved state file])
AC_DEFINE_UNQUOTED( C_CC, [ "$CC" ], [c-compiler used])
AC_DEFINE_UNQUOTED( C_CFLAGS, ["$CFLAGS $YAP_EXTRAS $ -D_YAP_NOT_INSTALLED_=1 $CPPFLAGS -I. -I$srcdir/H -I$srcdir/include -I$srcdir/os -I$srcdir/OPTYap -I$srcdir/BEAM" ], [compilation flags])
@ -2140,13 +2122,13 @@ AC_DEFINE_UNQUOTED( C_LIBPLSO, [ "$LIBS $EXTRA_LIBS_FOR_DLLS" ], [libs for linki
AC_DEFINE_UNQUOTED( SO_EXT, [ "$SO" ], [relocable objects])
AC_DEFINE_UNQUOTED( SO_PATH, [ "$SOPATH" ], [library search variable])
AC_DEFINE_UNQUOTED( YAP_ARCH, [ "$ARCH" ], [architecture])
AC_DEFINE_UNQUOTED( YAP_BINDIR, [ "$prefix/bin" ], [where the yap executable lives])
AC_DEFINE_UNQUOTED( YAP_BINDIR, [ "$BINDIR" ], [where the yap executable lives])
AC_DEFINE_UNQUOTED( YAP_FULL_VERSION, [ "YAP $YAP_VERSION ($ARCH): $yap_timestamp" ], [YAP version string])
AC_DEFINE_UNQUOTED( YAP_LIBDIR, [ "$prefix/lib/Yap" ], [where to look for shared libraries])
AC_DEFINE_UNQUOTED( YAP_LIBDIR, [ "$LIBDIR/Yap" ], [where to look for shared libraries])
AC_DEFINE_UNQUOTED( YAP_NUMERIC_VERSION, [ $yap_nversion ], [numerical version])
AC_DEFINE_UNQUOTED( YAP_PL_SRCDIR, [ "$prefix/share/Yap/pl" ], [where to look for Prolog sources])
AC_DEFINE_UNQUOTED( YAP_ROOTDIR, [ "$prefix" ], [where YAP lives])
AC_DEFINE_UNQUOTED( YAP_SHAREDIR, [ "$prefix/share" ], [where to look for the Prolog library])
AC_DEFINE_UNQUOTED( YAP_SHAREDIR, [ "$DATAROOTDIR" ], [where YAP lives])
AC_DEFINE_UNQUOTED( YAP_PL_SRCDIR, [ "$DATAROOTDIR/Yap/pl" ], [where YAP lives])
AC_DEFINE_UNQUOTED( YAP_TIMESTAMP, [ "$yap_timestamp" ], [date of compilation])
AC_DEFINE_UNQUOTED( YAP_VERSION, [ "$YAP_VERSION" ], [yap version])
AC_DEFINE_UNQUOTED( YAP_YAPLIB, [ "$YAPLIB" ], [name of YAP library])
@ -2194,7 +2176,6 @@ mkdir -p packages/prism/src/c/up
mkdir -p packages/prism/src/prolog
mkdir -p packages/ProbLog
mkdir -p packages/ProbLog/simplecudd
mkdir -p packages/prosqlite
mkdir -p packages/R
mkdir -p packages/RDF
mkdir -p packages/real
@ -2281,11 +2262,6 @@ if test "$PKG_LIBARCHIVE" != ""; then
AC_CONFIG_FILES([packages/archive/Makefile])
fi
if test "$PKG_ODBC" != ""; then
AC_CONFIG_FILES([packages/odbc/Makefile])
fi
if test "$PKG_MINISAT" != ""; then
AC_CONFIG_FILES([packages/swi-minisat2/Makefile])
AC_CONFIG_FILES([packages/swi-minisat2/C/Makefile])
@ -2310,10 +2286,6 @@ AC_CONFIG_FILES([packages/prism/src/c/Makefile])
AC_CONFIG_FILES([packages/prism/src/prolog/Makefile])
fi
if test "$PKG_PROSQLITE" != ""; then
AC_CONFIG_FILES([packages/prosqlite/Makefile])
fi
if test "$PKG_WINCONSOLE" != ""; then
AC_CONFIG_FILES([swi/console/Makefile])
fi

View File

@ -19,6 +19,7 @@
#define _YAPDEFS_H 1
#include <stdlib.h>
#include <setjmp.h>
#ifdef YAP_H
@ -285,13 +286,27 @@ Int Yap_InitDefaults( YAP_init_args *init_args, char saved_state[] );
/* this should be opaque to the user */
typedef struct {
unsigned long b; //> choice-point at entry
YAP_Int CurSlot; //> variables at entry
YAP_Int EndSlot; //> variables at successful execution
YAP_handle_t CurSlot; //> variables at entry
YAP_handle_t EndSlot; //> variables at successful execution
struct yami *p; //> Program Counter at entry
struct yami *cp; //> Continuation PC at entry
} YAP_dogoalinfo;
// query manipulation support
typedef struct open_query_struct {
int q_open;
int q_state;
YAP_handle_t q_g;
struct pred_entry *q_pe;
struct yami *q_p, *q_cp;
jmp_buf q_env;
int q_flags;
YAP_dogoalinfo q_h;
struct open_query_struct *oq;
} YAP_openQuery;
typedef void (*YAP_halt_hook)(int exit_code, void *closure);
typedef YAP_Int YAP_opaque_tag_t;

View File

@ -1848,7 +1848,7 @@ extern X_API YAP_PredEntryPtr YAP_FunctorToPredInModule(YAP_Functor, YAP_Module)
extern X_API YAP_PredEntryPtr YAP_AtomToPredInModule(YAP_Atom, YAP_Module);
/* int YAP_EnterGoal(void) */
extern X_API YAP_Bool YAP_EnterGoal(YAP_PredEntryPtr, YAP_Term *, YAP_dogoalinfo *);
extern X_API YAP_Bool YAP_EnterGoal(YAP_PredEntryPtr, YAP_handle_t, YAP_dogoalinfo *);
/* int YAP_RetryGoal(void) */
extern X_API YAP_Bool YAP_RetryGoal(YAP_dogoalinfo *);

View File

@ -47,7 +47,7 @@ PL_EXPORT(int)
PL_is_blob(term_t t, PL_blob_t **type)
{
CACHE_REGS
Term yt = Yap_GetFromSlot(t PASS_REGS);
Term yt = Yap_GetFromSlot(t);
Atom a;
BlobPropEntry *b;
@ -144,7 +144,7 @@ PL_unify_blob(term_t t, void *blob, size_t len, PL_blob_t *type)
if (type->acquire) {
type->acquire(AtomToSWIAtom(AbsAtom(ae)));
}
return Yap_unify(Yap_GetFromSlot(t PASS_REGS), MkAtomTerm(AbsAtom(ae)));
return Yap_unify(Yap_GetFromSlot(t), MkAtomTerm(AbsAtom(ae)));
}
PL_EXPORT(int)
@ -175,7 +175,7 @@ PL_get_blob(term_t t, void **blob, size_t *len, PL_blob_t **type)
Term tt;
AtomEntry *ae;
tt = Yap_GetFromSlot(t PASS_REGS);
tt = Yap_GetFromSlot(t);
if (IsVarTerm(tt))
return FALSE;
if (!IsAtomTerm(tt))

View File

@ -192,7 +192,7 @@ X_API char* PL_atom_nchars(atom_t a, size_t *len) /* SAM check type */
X_API term_t PL_copy_term_ref(term_t from)
{
CACHE_REGS
return Yap_InitSlot(Yap_GetFromSlot(from PASS_REGS) PASS_REGS);
return Yap_InitSlot(Yap_GetFromSlot(from));
}
/** @brief create a new term reference
@ -202,7 +202,7 @@ X_API term_t PL_new_term_ref(void)
{
CACHE_REGS
term_t to = Yap_NewSlots(1 PASS_REGS);
term_t to = Yap_NewSlots(1);
return to;
}
@ -213,7 +213,7 @@ X_API term_t PL_new_term_ref(void)
X_API term_t PL_new_term_refs(int n)
{
CACHE_REGS
term_t to = Yap_NewSlots(n PASS_REGS);
term_t to = Yap_NewSlots(n);
return to;
}
@ -223,7 +223,7 @@ X_API term_t PL_new_term_refs(int n)
X_API void PL_reset_term_refs(term_t after)
{
CACHE_REGS
term_t new = Yap_NewSlots(1 PASS_REGS);
term_t new = Yap_NewSlots(1);
Yap_RecoverSlots(after-new, new PASS_REGS);
}
@ -247,7 +247,7 @@ X_API void PL_reset_term_refs(term_t after)
X_API int PL_get_name_arity(term_t ts, atom_t *name, int *arity)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
if (IsAtomTerm(t)) {
*name = AtomToSWIAtom(AtomOfTerm(t));
*arity = 0;
@ -277,7 +277,7 @@ X_API int PL_get_name_arity(term_t ts, atom_t *name, int *arity)
X_API int PL_get_arg(int index, term_t ts, term_t a)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts );
if (IsVarTerm( t ))
return 0;
if ( !IsApplTerm(t) ) {
@ -308,7 +308,7 @@ X_API int PL_get_arg(int index, term_t ts, term_t a)
X_API int PL_get_compound_name_arity(term_t ts, atom_t *ap, int *ip)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
if ( !YAP_IsApplTerm(t) ) {
if (YAP_IsPairTerm(t)) {
if (ip)
@ -337,7 +337,7 @@ X_API int PL_get_compound_name_arity(term_t ts, atom_t *ap, int *ip)
X_API int PL_get_atom(term_t ts, atom_t *a)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
if ( !IsAtomTerm(t))
return 0;
*a = AtomToSWIAtom(AtomOfTerm(t));
@ -352,7 +352,7 @@ X_API int PL_get_atom(term_t ts, atom_t *a)
X_API int PL_get_integer(term_t ts, int *i)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts );
if (IsVarTerm(t) || !IsIntegerTerm(t) )
return 0;
*i = (int)IntegerOfTerm(t);
@ -365,7 +365,7 @@ X_API int PL_get_integer(term_t ts, int *i)
X_API int PL_get_long(term_t ts, long *i)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
if (!YAP_IsIntTerm(t) ) {
if (YAP_IsFloatTerm(t)) {
double dbl = YAP_FloatOfTerm(t);
@ -385,7 +385,7 @@ X_API int PL_get_long(term_t ts, long *i)
X_API int PL_get_bool(term_t ts, int *i)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
Atom at;
if (!IsAtomTerm(t) )
@ -408,7 +408,7 @@ X_API int PL_get_bool(term_t ts, int *i)
X_API int PL_get_int64(term_t ts, int64_t *i)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
if (!YAP_IsIntTerm(t) ) {
if (YAP_IsFloatTerm(t)) {
double dbl = YAP_FloatOfTerm(t);
@ -458,7 +458,7 @@ X_API int PL_get_int64(term_t ts, int64_t *i)
X_API int PL_get_intptr(term_t ts, intptr_t *a)
{
CACHE_REGS
Term t = Yap_GetFromSlot(ts PASS_REGS);
Term t = Yap_GetFromSlot(ts);
if ( !IsIntegerTerm(t) )
return 0;
*a = (intptr_t)(IntegerOfTerm(t));
@ -471,7 +471,7 @@ X_API int PL_get_intptr(term_t ts, intptr_t *a)
X_API int PL_get_uintptr(term_t ts, uintptr_t *a)
{
CACHE_REGS
Term t = Yap_GetFromSlot(ts PASS_REGS);
Term t = Yap_GetFromSlot(ts);
if ( !IsIntegerTerm(t) )
return 0;
*a = (uintptr_t)(IntegerOfTerm(t));
@ -484,7 +484,7 @@ X_API int PL_get_uintptr(term_t ts, uintptr_t *a)
X_API int _PL_get_arg(int index, term_t ts, term_t a)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
if ( !YAP_IsApplTerm(t) ) {
if (YAP_IsPairTerm(t)) {
if (index == 1){
@ -508,7 +508,7 @@ X_API int _PL_get_arg(int index, term_t ts, term_t a)
X_API int PL_get_atom_chars(term_t ts, char **a) /* SAM check type */
{
CACHE_REGS
Term t = Yap_GetFromSlot(ts PASS_REGS);
Term t = Yap_GetFromSlot(ts);
if (!IsAtomTerm(t) || IsWideAtom(AtomOfTerm(t)))
return 0;
*a = RepAtom(AtomOfTerm(t))->StrOfAE;
@ -521,7 +521,7 @@ X_API int PL_get_atom_chars(term_t ts, char **a) /* SAM check type */
X_API int PL_get_atom_nchars(term_t ts, size_t *len, char **s) /* SAM check type */
{
CACHE_REGS
Term t = Yap_GetFromSlot(ts PASS_REGS);
Term t = Yap_GetFromSlot(ts);
if (!IsAtomTerm(t))
return 0;
*s = RepAtom(AtomOfTerm(t))->StrOfAE;
@ -564,7 +564,7 @@ X_API int PL_get_atom_nchars(term_t ts, size_t *len, char **s) /* SAM check typ
X_API int PL_get_functor(term_t ts, functor_t *f)
{
CACHE_REGS
Term t = Yap_GetFromSlot(ts PASS_REGS);
Term t = Yap_GetFromSlot(ts);
if ( IsAtomTerm(t)) {
*f = t;
} else {
@ -579,7 +579,7 @@ X_API int PL_get_functor(term_t ts, functor_t *f)
X_API int PL_get_float(term_t ts, double *f) /* SAM type check*/
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
if ( IsFloatTerm(t)) {
*f = FloatOfTerm(t);
} else if ( IsIntegerTerm(t)) {
@ -600,7 +600,7 @@ X_API int PL_get_float(term_t ts, double *f) /* SAM type check*/
X_API int PL_get_string_chars(term_t t, char **s, size_t *len)
{
CACHE_REGS
Term tt = Yap_GetFromSlot(t PASS_REGS);
Term tt = Yap_GetFromSlot(t);
if (!IsStringTerm(tt)) {
return 0;
}
@ -616,7 +616,7 @@ X_API int PL_get_string_chars(term_t t, char **s, size_t *len)
X_API int PL_get_list(term_t ts, term_t h, term_t tl)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts );
if (IsVarTerm(t) || !IsPairTerm(t) ) {
return 0;
}
@ -632,7 +632,7 @@ X_API int PL_get_list(term_t ts, term_t h, term_t tl)
X_API int PL_get_head(term_t ts, term_t h)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
if (!YAP_IsPairTerm(t) ) {
return 0;
}
@ -667,7 +667,7 @@ X_API int PL_unify_bool(term_t t, int a)
{
CACHE_REGS
Term iterm = (a ? MkAtomTerm(AtomTrue) : MkAtomTerm(AtomFalse) );
return Yap_unify(Yap_GetFromSlot(t PASS_REGS),iterm);
return Yap_unify(Yap_GetFromSlot(t ),iterm);
}
@ -680,7 +680,7 @@ X_API int PL_unify_bool(term_t t, int a)
X_API int PL_get_mpz(term_t t, mpz_t mpz)
{
CACHE_REGS
Term t0 = Yap_GetFromSlot(t PASS_REGS);
Term t0 = Yap_GetFromSlot(t);
return Yap_term_to_existing_big(t0, mpz);
}
@ -689,13 +689,13 @@ X_API int PL_unify_mpz(term_t t, mpz_t mpz)
{
CACHE_REGS
Term iterm = Yap_MkBigIntTerm(mpz);
return Yap_unify(Yap_GetFromSlot(t PASS_REGS),iterm);
return Yap_unify(Yap_GetFromSlot(t),iterm);
}
X_API int PL_get_mpq(term_t t, mpq_t mpz)
{
CACHE_REGS
Term t0 = Yap_GetFromSlot(t PASS_REGS);
Term t0 = Yap_GetFromSlot(t);
return Yap_term_to_existing_rat(t0, mpz);
}
@ -704,7 +704,7 @@ X_API int PL_unify_mpq(term_t t, mpq_t mpq)
{
CACHE_REGS
Term iterm = Yap_MkBigRatTerm(mpq);
return Yap_unify(Yap_GetFromSlot(t PASS_REGS),iterm);
return Yap_unify(Yap_GetFromSlot(t),iterm);
}
#endif
@ -713,7 +713,7 @@ X_API int PL_unify_mpq(term_t t, mpq_t mpq)
X_API int PL_get_module(term_t ts, module_t *m)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
if (!IsAtomTerm(t) )
return FALSE;
*m = Yap_GetModuleEntry(t);
@ -737,7 +737,7 @@ X_API module_t PL_new_module(atom_t swiat)
X_API int PL_get_nil(term_t ts)
{
CACHE_REGS
Term t = Yap_GetFromSlot(ts PASS_REGS);
Term t = Yap_GetFromSlot(ts );
return ( t == TermNil );
}
@ -747,7 +747,7 @@ X_API int PL_get_nil(term_t ts)
X_API int PL_get_pointer(term_t ts, void **i)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
if (IsVarTerm(t) || !IsIntegerTerm(t) )
return 0;
*i = (void *)IntegerOfTerm(t);
@ -757,7 +757,7 @@ X_API int PL_get_pointer(term_t ts, void **i)
X_API int PL_get_tail(term_t ts, term_t tl)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts );
if (!YAP_IsPairTerm(t) ) {
return 0;
}
@ -889,7 +889,7 @@ X_API int PL_cons_functor(term_t d, functor_t f,...)
}
va_start (ap, f);
for (i = 0; i < arity; i++) {
Yap_unify(tmp[i],Yap_GetFromSlot(va_arg(ap, term_t) PASS_REGS));
Yap_unify(tmp[i],Yap_GetFromSlot(va_arg(ap, term_t)));
}
va_end (ap);
Yap_PutInSlot(d,t PASS_REGS);
@ -921,7 +921,7 @@ X_API int PL_cons_functor_v(term_t d, functor_t f, term_t a0)
tmp = RepAppl(t)+1;
}
for (i = 0; i < arity; i++) {
Yap_unify(tmp[i] , Yap_GetFromSlot(a0 PASS_REGS) );
Yap_unify(tmp[i] , Yap_GetFromSlot(a0 ) );
a0++;
}
Yap_PutInSlot(d,t PASS_REGS);
@ -937,7 +937,7 @@ X_API int PL_cons_list(term_t d, term_t h, term_t t)
return FALSE;
}
}
Yap_PutInSlot(d,MkPairTerm(Yap_GetFromSlot(h PASS_REGS),Yap_GetFromSlot(t PASS_REGS)) PASS_REGS);
Yap_PutInSlot(d,MkPairTerm(Yap_GetFromSlot(h),Yap_GetFromSlot(t)) PASS_REGS);
return TRUE;
}
@ -1103,7 +1103,7 @@ X_API int PL_put_string_nchars(term_t t, size_t len, const char *chars)
X_API int PL_put_term(term_t d, term_t s)
{
CACHE_REGS
Yap_PutInSlot(d,Yap_GetFromSlot(s PASS_REGS) PASS_REGS);
Yap_PutInSlot(d,Yap_GetFromSlot(s ) PASS_REGS);
return TRUE;
}
@ -1123,14 +1123,14 @@ X_API int PL_put_variable(term_t t)
X_API int PL_raise_exception(term_t exception)
{
CACHE_REGS
EX = Yap_StoreTermInDB(Yap_GetFromSlot(exception PASS_REGS),0);
EX = Yap_StoreTermInDB(Yap_GetFromSlot(exception),0);
return 0;
}
X_API int PL_throw(term_t exception)
{
CACHE_REGS
YAP_Throw(Yap_GetFromSlot(exception PASS_REGS));
YAP_Throw(Yap_GetFromSlot(exception));
if (LOCAL_execution)
longjmp(LOCAL_execution->q_env, 0);
return 0;
@ -1158,7 +1158,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 ),Yap_GetFromSlot(t2 ));
}
/* SWI: int PL_unify_atom(term_t ?t, atom *at)
@ -1167,7 +1167,7 @@ X_API int PL_unify_atom(term_t t, atom_t at)
{
CACHE_REGS
YAP_Term cterm = MkAtomTerm(SWIAtomToAtom(at));
return YAP_Unify(Yap_GetFromSlot(t PASS_REGS),cterm);
return YAP_Unify(Yap_GetFromSlot(t),cterm);
}
/* SWI: int PL_unify_atom_chars(term_t ?t, const char *chars)
@ -1181,7 +1181,7 @@ X_API int PL_unify_atom_chars(term_t t, const char *s)
return FALSE;
}
Yap_AtomIncreaseHold(at);
return Yap_unify(Yap_GetFromSlot(t PASS_REGS), MkAtomTerm(at));
return Yap_unify(Yap_GetFromSlot(t), MkAtomTerm(at));
}
/* SWI: int PL_unify_atom_chars(term_t ?t, const char *chars)
@ -1195,7 +1195,7 @@ X_API int PL_unify_atom_nchars(term_t t, size_t len, const char *s)
return FALSE;
}
Yap_AtomIncreaseHold(at);
return Yap_unify(Yap_GetFromSlot(t PASS_REGS), MkAtomTerm(at));
return Yap_unify(Yap_GetFromSlot(t), MkAtomTerm(at));
}
/* SWI: int PL_unify_float(term_t ?t, double f)
@ -1204,7 +1204,7 @@ X_API int PL_unify_float(term_t t, double f)
{
CACHE_REGS
Term fterm = MkFloatTerm(f);
return Yap_unify(Yap_GetFromSlot(t PASS_REGS),fterm);
return Yap_unify(Yap_GetFromSlot(t),fterm);
}
/* SWI: int PL_unify_integer(term_t ?t, long n)
@ -1213,21 +1213,21 @@ X_API int PL_unify_integer(term_t t, long n)
{
CACHE_REGS
Term iterm = MkIntegerTerm(n);
return Yap_unify(Yap_GetFromSlot(t PASS_REGS),iterm);
return Yap_unify(Yap_GetFromSlot(t),iterm);
}
X_API int PL_unify_intptr(term_t t, intptr_t n)
{
CACHE_REGS
Term iterm = MkIntegerTerm(n);
return Yap_unify(Yap_GetFromSlot(t PASS_REGS),iterm);
return Yap_unify(Yap_GetFromSlot(t),iterm);
}
X_API int PL_unify_uintptr(term_t t, uintptr_t n)
{
CACHE_REGS
Term iterm = MkIntegerTerm(n);
return Yap_unify(Yap_GetFromSlot(t PASS_REGS),iterm);
return Yap_unify(Yap_GetFromSlot(t),iterm);
}
/* SWI: int PL_unify_integer(term_t ?t, long n)
@ -1235,7 +1235,7 @@ X_API int PL_unify_uintptr(term_t t, uintptr_t n)
X_API int PL_unify_functor(term_t t, functor_t f)
{
CACHE_REGS
Term tt = Yap_GetFromSlot(t PASS_REGS);
Term tt = Yap_GetFromSlot(t);
Functor ff = SWIFunctorToFunctor(f);
if (IsVarTerm(tt)) {
if (Unsigned(HR)+ArityOfFunctor(ff) > Unsigned(ASP)-CreepFlag) {
@ -1259,7 +1259,7 @@ X_API int PL_unify_int64(term_t t, int64_t n)
CACHE_REGS
#if SIZEOF_INT_P==8
Term iterm = MkIntegerTerm(n);
return Yap_unify(Yap_GetFromSlot(t PASS_REGS),iterm);
return Yap_unify(Yap_GetFromSlot(t),iterm);
#elif USE_GMP
YAP_Term iterm;
char s[64];
@ -1274,7 +1274,7 @@ X_API int PL_unify_int64(term_t t, int64_t n)
#endif
mpz_init_set_str (&rop, s, 10);
iterm = YAP_MkBigNumTerm((void *)&rop);
return YAP_Unify(Yap_GetFromSlot(t PASS_REGS),iterm);
return YAP_Unify(Yap_GetFromSlot(t ),iterm);
#else
if ((long)n == n)
return PL_unify_integer(t, n);
@ -1302,7 +1302,7 @@ X_API int PL_unify_list(term_t tt, term_t h, term_t tail)
return FALSE;
}
}
t = Deref(Yap_GetFromSlot(tt PASS_REGS));
t = Deref(Yap_GetFromSlot(tt));
if (IsVarTerm(t)) {
Term pairterm = Yap_MkNewPairTerm();
Yap_unify(t, pairterm);
@ -1321,7 +1321,7 @@ X_API int PL_unify_list(term_t tt, term_t h, term_t tail)
X_API int PL_unify_arg(int index, term_t tt, term_t arg)
{
CACHE_REGS
Term t = Deref(Yap_GetFromSlot(tt PASS_REGS)), to;
Term t = Deref(Yap_GetFromSlot(tt )), to;
if (index < 0)
return FALSE;
if (IsVarTerm(t) || IsAtomOrIntTerm(t)) {
@ -1341,7 +1341,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(arg PASS_REGS),to);
return Yap_unify(Yap_GetFromSlot(arg),to);
}
/* SWI: int PL_unify_list(term_t ?t, term_t +h, term_t -t)
@ -1354,7 +1354,7 @@ X_API int PL_unify_list_chars(term_t t, const char *chars)
if (LOCAL_Error_TYPE && !Yap_SWIHandleError( "PL_unify_list_chars" ))
return FALSE;
}
return Yap_unify(Yap_GetFromSlot(t PASS_REGS), chterm);
return Yap_unify(Yap_GetFromSlot(t), chterm);
}
/* SWI: int PL_unify_list(term_t ?t, term_t +h, term_t -t)
@ -1367,7 +1367,7 @@ X_API int PL_unify_list_ncodes(term_t t, size_t len, const char *chars)
if (LOCAL_Error_TYPE && !Yap_SWIHandleError( "PL_unify_list_ncodes" ))
return FALSE;
}
return Yap_unify(Yap_GetFromSlot(t PASS_REGS), chterm);
return Yap_unify(Yap_GetFromSlot(t), chterm);
}
X_API int
@ -1379,7 +1379,7 @@ PL_unify_list_codes(term_t t, const char *chars)
if (LOCAL_Error_TYPE && !Yap_SWIHandleError( "PL_unify_list_codes" ))
return FALSE;
}
return Yap_unify(Yap_GetFromSlot(t PASS_REGS), chterm);
return Yap_unify(Yap_GetFromSlot(t), chterm);
}
/* SWI: int PL_unify_nil(term_t ?l)
@ -1387,7 +1387,7 @@ PL_unify_list_codes(term_t t, const char *chars)
X_API int PL_unify_nil(term_t t)
{
CACHE_REGS
return Yap_unify(Yap_GetFromSlot(t PASS_REGS), TermNil);
return Yap_unify(Yap_GetFromSlot(t), TermNil);
}
/* SWI: int PL_unify_pointer(term_t ?t, void *ptr)
@ -1397,7 +1397,7 @@ X_API int PL_unify_pointer(term_t t, void *ptr)
{
CACHE_REGS
YAP_Term ptrterm = YAP_MkIntTerm((YAP_Int)ptr);
return YAP_Unify(Yap_GetFromSlot(t PASS_REGS), ptrterm);
return YAP_Unify(Yap_GetFromSlot(t ), ptrterm);
}
/* SWI: int PL_unify_list(term_t ?t, term_t +h, term_t -t)
@ -1410,7 +1410,7 @@ X_API int PL_unify_string_chars(term_t t, const char *chars)
if (LOCAL_Error_TYPE && !Yap_SWIHandleError( "PL_unify_list_ncodes" ))
return FALSE;
}
return Yap_unify(Yap_GetFromSlot(t PASS_REGS), chterm);
return Yap_unify(Yap_GetFromSlot(t), chterm);
}
X_API int PL_unify_string_nchars(term_t t, size_t len, const char *chars)
@ -1421,7 +1421,7 @@ X_API int PL_unify_string_nchars(term_t t, size_t len, const char *chars)
if (LOCAL_Error_TYPE && !Yap_SWIHandleError( "PL_unify_list_ncodes" ))
return FALSE;
}
return Yap_unify(Yap_GetFromSlot(t PASS_REGS), chterm);
return Yap_unify(Yap_GetFromSlot(t), chterm);
}
/* SWI: int PL_unify_wchars(term_t ?t, int type, size_t len,, const pl_wchar_t *s)
@ -1440,24 +1440,24 @@ X_API int PL_unify_wchars(term_t t, int type, size_t len, const pl_wchar_t *char
if (at) {
Yap_AtomIncreaseHold(at);
chterm = MkAtomTerm(at);
return Yap_unify(Yap_GetFromSlot(t PASS_REGS), chterm);
return Yap_unify(Yap_GetFromSlot(t), chterm);
}
}
break;
case PL_UTF8_STRING:
case PL_STRING:
if ((chterm = Yap_NWCharsToString(chars, len PASS_REGS)) != 0) {
return YAP_Unify(Yap_GetFromSlot(t PASS_REGS), chterm);
return YAP_Unify(Yap_GetFromSlot(t ), chterm);
}
break;
case PL_CODE_LIST:
if ((chterm = Yap_NWCharsToListOfCodes(chars, len PASS_REGS)) != 0) {
return YAP_Unify(Yap_GetFromSlot(t PASS_REGS), chterm);
return YAP_Unify(Yap_GetFromSlot(t), chterm);
}
break;
case PL_CHAR_LIST:
if ((chterm = Yap_NWCharsToListOfAtoms(chars, len PASS_REGS)) != 0) {
return YAP_Unify(Yap_GetFromSlot(t PASS_REGS), chterm);
return YAP_Unify(Yap_GetFromSlot(t), chterm);
}
break;
default:
@ -1609,7 +1609,7 @@ int PL_unify_termv(term_t l, va_list ap)
break;
case PL_TERM:
{
Term t = Yap_GetFromSlot(va_arg(ap, size_t) PASS_REGS);
Term t = Yap_GetFromSlot(va_arg(ap, size_t));
if (IsVarTerm(t) && VarOfTerm(t) >= ASP && VarOfTerm(t) < LCL0) {
Yap_unify(*pt++, t);
}
@ -1754,7 +1754,7 @@ int PL_unify_termv(term_t l, va_list ap)
nels = stack[depth-1].nels;
}
}
res = Yap_unify(Yap_GetFromSlot(l PASS_REGS),a[0]);
res = Yap_unify(Yap_GetFromSlot(l),a[0]);
RECOVER_MACHINE_REGS();
return res;
}
@ -1791,7 +1791,7 @@ X_API int PL_term_type(term_t t)
{
CACHE_REGS
/* YAP_ does not support strings as different objects */
YAP_Term v = Yap_GetFromSlot(t PASS_REGS);
YAP_Term v = Yap_GetFromSlot(t );
if (IsVarTerm(v)) {
return PL_VARIABLE;
} else if (IsAtomTerm(v)) {
@ -1810,25 +1810,25 @@ X_API int PL_term_type(term_t t)
X_API int PL_is_atom(term_t t)
{
CACHE_REGS
return IsAtomTerm(Yap_GetFromSlot(t PASS_REGS));
return IsAtomTerm(Yap_GetFromSlot(t));
}
X_API int PL_is_ground(term_t t)
{
CACHE_REGS
return Yap_IsGroundTerm(Yap_GetFromSlot(t PASS_REGS));
return Yap_IsGroundTerm(Yap_GetFromSlot(t));
}
X_API int PL_is_acyclic(term_t t)
{
CACHE_REGS
return Yap_IsAcyclicTerm(Yap_GetFromSlot(t PASS_REGS));
return Yap_IsAcyclicTerm(Yap_GetFromSlot(t));
}
X_API int PL_is_callable(term_t t)
{
CACHE_REGS
YAP_Term t1 = Yap_GetFromSlot(t PASS_REGS);
YAP_Term t1 = Yap_GetFromSlot(t);
if (IsVarTerm(t1))
return FALSE;
if (IsAtomTerm(t1) || IsPairTerm(t1))
@ -1841,21 +1841,21 @@ X_API int PL_is_callable(term_t t)
X_API int PL_is_atomic(term_t ts)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
return !IsVarTerm(t) || !IsApplTerm(t) || !IsPairTerm(t);
}
X_API int PL_is_compound(term_t ts)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
return (IsApplTerm(t) || IsPairTerm(t));
}
X_API int PL_is_functor(term_t ts, functor_t f)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
Functor ff = SWIFunctorToFunctor(f);
if (YAP_IsApplTerm(t)) {
return FunctorOfTerm(t) == (Functor)ff;
@ -1868,14 +1868,14 @@ X_API int PL_is_functor(term_t ts, functor_t f)
X_API int PL_is_float(term_t ts)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
return !IsVarTerm(t) && IsFloatTerm(t);
}
X_API int PL_is_integer(term_t ts)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts );
if (IsVarTerm(t)) return FALSE;
if (IsIntTerm(t)) return TRUE;
if (IsApplTerm(t)) {
@ -1893,14 +1893,14 @@ X_API int PL_is_integer(term_t ts)
X_API int PL_is_list(term_t ts)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts );
return !IsVarTerm(t) && (t == TermNil || IsPairTerm(t));
}
X_API int PL_is_pair(term_t ts)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
return !IsVarTerm(t) && IsPairTerm(t);
}
@ -1916,7 +1916,7 @@ PL_skip_list(term_t list, term_t tail, size_t *len)
if ( len )
*len = length;
if ( tail )
{ Term t2 = Yap_GetFromSlot(tail PASS_REGS);
{ Term t2 = Yap_GetFromSlot(tail);
Yap_unify(t2, *t);
}
@ -1935,29 +1935,29 @@ PL_skip_list(term_t list, term_t tail, size_t *len)
X_API int PL_is_number(term_t ts)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
return IsIntegerTerm(t) || IsBigIntTerm(t) || IsFloatTerm(t);
}
X_API int PL_is_string(term_t ts)
{
CACHE_REGS
Term t = Yap_GetFromSlot(ts PASS_REGS);
Term t = Yap_GetFromSlot(ts);
return IsStringTerm(t);
}
X_API int PL_is_variable(term_t ts)
{
CACHE_REGS
YAP_Term t = Yap_GetFromSlot(ts PASS_REGS);
YAP_Term t = Yap_GetFromSlot(ts);
return YAP_IsVarTerm(t);
}
X_API int PL_compare(term_t ts1, term_t ts2)
{
CACHE_REGS
YAP_Term t1 = Yap_GetFromSlot(ts1 PASS_REGS);
YAP_Term t2 = Yap_GetFromSlot(ts2 PASS_REGS);
YAP_Term t1 = Yap_GetFromSlot(ts1);
YAP_Term t2 = Yap_GetFromSlot(ts2);
return YAP_CompareTerms(t1, t2);
}
@ -1966,7 +1966,7 @@ PL_record_external
(term_t ts, size_t *sz)
{
CACHE_REGS
Term t = Yap_GetFromSlot(ts PASS_REGS);
Term t = Yap_GetFromSlot(ts);
size_t len = 512, nsz;
char *s;
@ -2015,7 +2015,7 @@ X_API record_t
PL_record(term_t ts)
{
CACHE_REGS
Term t = Yap_GetFromSlot(ts PASS_REGS);
Term t = Yap_GetFromSlot(ts);
return (record_t)YAP_Record(t);
}
@ -2102,7 +2102,7 @@ PL_exception(qid_t q)
YAP_Term t;
if (YAP_GoalHasException(&t)) {
CACHE_REGS
term_t to = Yap_NewSlots(1 PASS_REGS);
term_t to = Yap_NewSlots(1);
Yap_PutInSlot(to,t PASS_REGS);
return to;
} else {
@ -2179,7 +2179,7 @@ PL_strip_module(term_t raw, module_t *m, term_t plain)
m0 = MkAtomTerm(AtomProlog);
} else
m0 = USER_MODULE;
t = Yap_StripModule(Yap_GetFromSlot(raw PASS_REGS), &m0);
t = Yap_StripModule(Yap_GetFromSlot(raw), &m0);
if (!t)
return FALSE;
*m = Yap_GetModuleEntry(m0);
@ -2259,7 +2259,7 @@ X_API int PL_unify_predicate(term_t head, predicate_t pred, int how)
}
}
nt = Yap_MkApplTerm(FunctorModule, 2, ts);
return Yap_unify(Yap_GetFromSlot(head PASS_REGS),nt);
return Yap_unify(Yap_GetFromSlot(head),nt);
}
X_API void PL_predicate_info(predicate_t p,atom_t *name, int *arity, module_t *m)
@ -2379,9 +2379,6 @@ PL_discard_foreign_frame(fid_t f)
X_API qid_t PL_open_query(module_t ctx, int flags, predicate_t p, term_t t0)
{
CACHE_REGS
YAP_Term *t = NULL;
if (t0)
t = Yap_AddressFromSlot(t0);
/* ignore flags and module for now */
qid_t new = (qid_t)Yap_AllocCodeSpace(sizeof(struct open_query_struct));
@ -2391,7 +2388,7 @@ X_API qid_t PL_open_query(module_t ctx, int flags, predicate_t p, term_t t0)
new->q_state=0;
new->q_flags = flags;
new->q_pe = (PredEntry *)p;
new->q_g = t;
new->q_g = t0;
return new;
}
@ -2475,7 +2472,7 @@ X_API int PL_call(term_t tp, module_t m)
Term t[2], g;
t[0] = SWIModuleToModule(m);
t[1] = Yap_GetFromSlot(tp PASS_REGS);
t[1] = Yap_GetFromSlot(tp );
g = Yap_MkApplTerm(FunctorModule,2,t);
out = YAP_RunGoal(g);
@ -2554,7 +2551,7 @@ X_API void PL_load_extensions(const PL_extension *ptr)
X_API int PL_is_inf(term_t st)
{
CACHE_REGS
Term t = Deref(Yap_GetFromSlot(st PASS_REGS));
Term t = Deref(Yap_GetFromSlot(st));
if (IsVarTerm(t)) return FALSE;
if (!IsFloatTerm(t)) return FALSE;
#if HAVE_ISINF
@ -2638,7 +2635,7 @@ X_API int PL_unify_thread_id(term_t t, int i)
{
CACHE_REGS
Term iterm = MkIntegerTerm(i);
return Yap_unify(Yap_GetFromSlot(t PASS_REGS),iterm);
return Yap_unify(Yap_GetFromSlot(t),iterm);
}
@ -2821,7 +2818,7 @@ X_API int
PL_eval_expression_to_int64_ex(term_t t, int64_t *val)
{
CACHE_REGS
Term res = Yap_Eval(Yap_GetFromSlot(t PASS_REGS));
Term res = Yap_Eval(Yap_GetFromSlot(t));
if (!res) {
return FALSE;
}
@ -3126,7 +3123,7 @@ Int Yap_StreamToFileNo(Term t) {
IOSTREAM *s;
int rc;
if ( (rc=PL_get_stream_handle(Yap_InitSlot(t PASS_REGS), &s)) ) {
if ( (rc=PL_get_stream_handle(Yap_InitSlot(t), &s)) ) {
return Sfileno(s);
}
return -1;
@ -3138,7 +3135,7 @@ FILE *Yap_FileDescriptorFromStream(Term t)
IOSTREAM *s;
int rc;
if ( (rc=PL_get_stream_handle(Yap_InitSlot(t PASS_REGS), &s)) ) {
if ( (rc=PL_get_stream_handle(Yap_InitSlot(t), &s)) ) {
fprintf(stderr,"Unimplemented\n");
// return Sfileno(s);
}
@ -3183,7 +3180,7 @@ extern term_t Yap_CvtTerm(term_t ts);
term_t Yap_CvtTerm(term_t ts)
{
CACHE_REGS
Term t = Yap_GetFromSlot(ts PASS_REGS);
Term t = Yap_GetFromSlot(ts);
if (IsVarTerm(t)) return ts;
if (IsPairTerm(t)) return ts;
if (IsAtomTerm(t)) return ts;
@ -3207,7 +3204,7 @@ term_t Yap_CvtTerm(term_t ts)
ta[1] = Yap_MkBigIntTerm(mpq_denref(b));
if (ta[1] == TermNil)
return ts;
return Yap_InitSlot(Yap_MkApplTerm(FunctorRDiv, 2, ta) PASS_REGS);
return Yap_InitSlot(Yap_MkApplTerm(FunctorRDiv, 2, ta));
}
#endif
case EMPTY_ARENA:
@ -3215,14 +3212,14 @@ term_t Yap_CvtTerm(term_t ts)
case ARRAY_FLOAT:
case CLAUSE_LIST:
case EXTERNAL_BLOB:
return Yap_InitSlot(MkIntTerm(0) PASS_REGS);
return Yap_InitSlot(MkIntTerm(0));
default:
return ts;
}
} else if (f == FunctorDBRef) {
Term ta[0];
ta[0] = MkIntegerTerm((Int)DBRefOfTerm(t));
return Yap_InitSlot(Yap_MkApplTerm(FunctorDBREF, 1, ta) PASS_REGS);
return Yap_InitSlot(Yap_MkApplTerm(FunctorDBREF, 1, ta));
}
}
}
@ -3233,4 +3230,3 @@ term_t Yap_CvtTerm(term_t ts)
* @}
* @}
*/

View File

@ -37,18 +37,6 @@
void Yap_swi_install(void);
void Yap_install_blobs(void);
typedef struct open_query_struct {
int q_open;
int q_state;
YAP_Term *q_g;
PredEntry *q_pe;
yamop *q_p, *q_cp;
jmp_buf q_env;
int q_flags;
YAP_dogoalinfo q_h;
struct open_query_struct *oq;
} open_query;
#define addr_hash(V) (((CELL) (V)) >> 4 & (N_SWI_HASH-1))
static inline void

View File

@ -1099,4 +1099,3 @@ pages = {14--17}
Data Representation in the BinWAM. {\em Proc.~of Programming
Languages Implementation and Logic Programming (PLILP'94)}, LNCS
844, Madrid 1994.

View File

@ -39,7 +39,8 @@ Agc_hook AGCHook =NULL
#if __ANDROID__
// no need to perform initialization, it is done before we start the Prolog engine.
struct AAssetManager* assetManager =GLOBAL_assetManager
struct AAssetManager* assetManager =NULL
char* AssetsWD =NULL
#endif
/* multi-thread support */

View File

@ -130,50 +130,57 @@ startemulator () {
fi
}
androidize () {
cd packages/swig
mkdir -p "$ANDROID_NDK_ROOT"/build/core/lib
make install-android
cd ../..
}
cd $BUILDDROID
if test x$1 = xmake
then
./config.status
make -j install
rm -r packages/swig/android
elif test x$1 = xenv
export HOST="$ANDROID_ARCH"-linux-androideabi
export CPP="$HOST"-cpp
export DESTDIR=`pwd`/packages/swig/android
export PATH="$PATH":/usr/local/bin
if test x$1 = xenv
then
return 0
elif test x$1 = xdmake
then
make
elif test x$1 = xgo
elif test x$1 = xmake
then
echo "In make I believe"
pushd packages/swig
make clean
popd
./config.status
CFLAGS="-g" make -j install
elif test x$1 = xeclipse
then
startemulator
"$ECLIPSE" &
return 0
else
startemulator
startemulator
rm -rf "$BUILDDROID"/*
cd "$BUILDDROID"
export HOST="$ANDROID_ARCH"-linux-androideabi
export CPP="$HOST"-cpp
"$YAP_SRC"/configure \
--host="$HOST" \
--prefix=`pwd` \
--enable-low-level-tracer \
--enable-debug-yap \
--enable-dynamic-loading \
--bindir=/usr/bin \
--prefix=/assets \
--enable-dynamic-loading \
--with-swig \
--with-gmp=$GMPDIR \
--with-sqlite3=$SQLITE3DIR #\
--with-gmp="$GMPDIR" \
--with-sqlite3="$SQLITE3DIR"
#\
#--enable-chr=yes #--enable-threads
make depend
make -j install
CFLAGS="-g" make -j install
fi
cd packages/swig
mkdir -p "$ANDROID_NDK_ROOT"/build/core/lib
make android
make install-android
adb uninstall pt.up.fc.dcc.yap
adb install android/bin/JavaYap-debug.apk
androidize

View File

@ -369,9 +369,6 @@ PL_EXPORT(int) StryLock(IOSTREAM *s);
PL_EXPORT(int) Sunlock(IOSTREAM *s);
PL_EXPORT(IOSTREAM *) Snew(void *handle, int flags, IOFUNCTIONS *functions);
PL_EXPORT(IOSTREAM *) Sopen_file(const char *path, const char *how);
#ifdef ANDROID_ASSET_MANAGER_H
PL_EXPORT(IOSTREAM *) Sopen_asset(char *bufp, const char *how, AAssetManager* mgr);
#endif
PL_EXPORT(IOSTREAM *) Sfdopen(int fd, const char *type);
PL_EXPORT(int) Sfileno(IOSTREAM *s);
PL_EXPORT(IOSTREAM *) Sopen_pipe(const char *command, const char *type);

View File

@ -3533,15 +3533,6 @@ openStream(term_t file, term_t mode, term_t options)
#endif /*HAVE_POPEN*/
if ( PL_get_file_name(file, &path, 0) )
{
#if __ANDROID__
if (strstr(path,"/assets/")) {
if (!(s=Sopen_asset(path+8, "r", GLOBAL_assetManager)))
{ PL_error(NULL, 0, OsError(), ERR_FILE_OPERATION,
ATOM_open, ATOM_source_sink, file);
return NULL;
}
} else
#endif
if ( !(s = Sopen_file(path, how)) )
{ PL_error(NULL, 0, OsError(), ERR_FILE_OPERATION,
ATOM_open, ATOM_source_sink, file);
@ -5327,13 +5318,13 @@ peek(term_t stream, term_t chr, int how ARG_LD)
if ( how == PL_BYTE )
{ IOPOS pos = s->posbuf;
c = Sgetc(s);
if ( c != EOF )
Sungetc(c, s);
if ( c != EOF ){
Sungetc(c, s);
}
s->posbuf = pos;
} else
{ c = Speekcode(s);
} else {
c = Speekcode(s);
}
if ( Sferror(s) )
return streamStatus(s);
@ -5755,7 +5746,7 @@ BeginPredDefs(file)
PRED_DEF("get0", 1, get_code1, 0)
PRED_DEF("ttyflush", 0, ttyflush, 0)
PRED_DEF("prompt", 2, prompt, 0)
PRED_DEF("tab", 2, tab2, 0)
PRED_DEF("tab", 2, tab2, 0)
PRED_DEF("tab", 1, tab1, 0)
/* Quintus IO */
PRED_DEF("byte_count", 2, byte_count, 0)
@ -5883,20 +5874,20 @@ static const PL_extension foreigns[] = {
FRG("print", 1, pl_print, 0),
FRG("writeln", 1, pl_writeln, 0),
FRG("nl", 1, pl_nl1, ISO),
FRG("format", 2, pl_format, META),
FRG("format", 2, pl_format, METAP),
FRG("write", 2, pl_write2, ISO),
FRG("writeq", 2, pl_writeq2, ISO),
FRG("print", 2, pl_print2, 0),
FRG("write_canonical", 2, pl_write_canonical2, ISO),
FRG("format", 3, pl_format3, META),
FRG("format", 3, pl_format3, METAP),
FRG("sleep", 1, pl_sleep, 0),
FRG("get_time", 1, pl_get_time, 0),
// vsc
FRG("format_predicate", 2, pl_format_predicate, META),
FRG("format_predicate", 2, pl_format_predicate, METAP),
FRG("current_format_predicate", 2, pl_current_format_predicate,
META|NDET),
METAP|NDET),
FRG("$raw_read", 1, pl_raw_read, 0),
FRG("$raw_read", 2, pl_raw_read2, 0),
@ -5906,32 +5897,6 @@ static const PL_extension foreigns[] = {
LFRG((char *)NULL, 0, NULL, 0)
};
#if __ANDROID__
JNIEnv *Yap_jenv;
void Java_pt_up_fc_dcc_yap_JavaYap_load(JNIEnv *env0, jobject obj, jobject mgr);
void Java_pt_up_fc_dcc_yap_JavaYap_load
(JNIEnv *env0, jobject obj, jobject mgr0)
{
AAssetManager *mgr = AAssetManager_fromJava(env0, mgr0);
Yap_jenv = env0;
if (mgr == NULL) {
__android_log_print(ANDROID_LOG_DEBUG, "YapJava", "Need to print : we're doomed, mgr = 0; bip bip bip");
} else {
__android_log_print(ANDROID_LOG_DEBUG, "YapJava", "Need to print : we're winning, mgr = %p; yeah", mgr);
GLOBAL_assetManager = mgr;
}
}
AAssetManager *Yap_assetManager( void );
AAssetManager *Yap_assetManager( void )
{
return GLOBAL_assetManager;
}
#endif
struct PL_local_data *Yap_InitThreadIO(int wid)
{
@ -6046,4 +6011,3 @@ init_yap(void)
/**
@}
*/

View File

@ -122,25 +122,12 @@ LastModifiedFile(const char *name, double *tp)
char tmp[MAXPATHLEN];
statstruct buf;
#ifdef __ANDROID__
if (strstr(name,"/assets")) {
AAssetManager* mgr = GLOBAL_assetManager;
*tp = (double)0;
if (!strcmp(name,"/assets"))
return TRUE;
const char *bufp=name+strlen("/assets/");
// check if file is a directory.
AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp);
if (assetDir) {
const char *ptr = AAssetDir_getNextFileName(assetDir) ;
AAssetDir_close(assetDir);
if (ptr)
return TRUE;
}
AAsset *asset = AAssetManager_open(mgr, bufp, AASSET_MODE_UNKNOWN);
if (!asset)
return FALSE;
AAsset_close(asset);
return TRUE;
if (Yap_isAsset(name)) {
if ( statfunc(OsPath("/", tmp), &buf) < 0 )
return FALSE;
*tp = (double)buf.st_mtime;
return Yap_AccessAsset(name, R_OK);
}
#endif
@ -202,31 +189,19 @@ LastModifiedFile64(const char *name, int64_t *tp)
char tmp[MAXPATHLEN];
statstruct buf;
#ifdef __ANDROID__
if (strstr(name,"/assets")) {
AAssetManager* mgr = GLOBAL_assetManager;
*tp = (int64_t)0;
if (!strcmp(name,"/assets"))
return TRUE;
const char *bufp=name+strlen("/assets/");
// check if file is a directory.
AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp);
if (assetDir) {
const char *ptr = AAssetDir_getNextFileName(assetDir) ;
AAssetDir_close(assetDir);
if (ptr)
return TRUE;
}
AAsset *asset = AAssetManager_open(mgr, bufp, AASSET_MODE_UNKNOWN);
if (!asset)
return FALSE;
AAsset_close(asset);
return TRUE;
}
if (Yap_isAsset(name)) {
if ( statfunc(OsPath("/", tmp), &buf) < 0 ) {
return FALSE;
}
*tp = (int64_t)buf.st_mtime;
return Yap_AccessAsset(name, R_OK);
}
#endif
if ( statfunc(OsPath(name, tmp), &buf) < 0 )
return FALSE;
if ( statfunc(OsPath(name, tmp), &buf) < 0 ){
return FALSE;
}
*tp = (int64_t)buf.st_mtime;
return TRUE;
@ -246,26 +221,9 @@ SizeFile(const char *path)
statstruct buf;
#ifdef __ANDROID__
if (strstr(path,"/assets")) {
AAssetManager* mgr = GLOBAL_assetManager;
if (!strcmp(path,"/assets"))
return 0;
const char *bufp=path+strlen("/assets/");
// check if file is a directory.
AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp);
if (assetDir) {
const char *ptr = AAssetDir_getNextFileName(assetDir) ;
AAssetDir_close(assetDir);
if (ptr)
return 0;
}
AAsset *asset = AAssetManager_open(mgr, bufp, AASSET_MODE_UNKNOWN);
if (!asset)
return -1;
AAsset_close(asset);
return 0;
}
if (Yap_isAsset(path)) {
return Yap_AssetSize( path );
}
#endif
if ( statfunc(OsPath(path, tmp), &buf) < 0 )
return -1;
@ -288,36 +246,6 @@ ACCESS_WRITE and ACCESS_EXECUTE.
int
AccessFile(const char *path, int mode)
{ char tmp[MAXPATHLEN];
#ifdef __ANDROID__
if (strstr(path,"/assets")) {
AAssetManager* mgr = GLOBAL_assetManager;
if (!strcmp(path,"/assets"))
return !(mode & ACCESS_WRITE );
const char *bufp=path+strlen("/assets/");
// check if file is a directory.
AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp);
if (assetDir) {
const char *ptr = AAssetDir_getNextFileName(assetDir) ;
AAssetDir_close(assetDir);
if (ptr)
return !(mode & ACCESS_WRITE );
}
AAsset *asset = AAssetManager_open(mgr, bufp, AASSET_MODE_UNKNOWN);
if (!asset)
return FALSE;
AAsset_close(asset);
if ( mode == ACCESS_EXIST )
return TRUE;
else
{
if ( mode & ACCESS_WRITE ) return FALSE;
#ifdef X_OK
if ( mode & ACCESS_EXECUTE ) return FALSE;
#endif
return TRUE;
}
}
#endif
#ifdef HAVE_ACCESS
int m = 0;
@ -331,6 +259,11 @@ AccessFile(const char *path, int mode)
#endif
}
#ifdef __ANDROID__
if (Yap_isAsset(path)) {
return !(mode & ACCESS_WRITE ) && Yap_AccessAsset(path, m);
}
#endif
return access(OsPath(path, tmp), m) == 0 ? TRUE : FALSE;
#else
# error "No implementation for AccessFile()"
@ -348,25 +281,9 @@ ExistsFile(const char *path)
statstruct buf;
#ifdef __ANDROID__
if (strstr(path,"/assets")) {
AAssetManager* mgr = GLOBAL_assetManager;
if (!strcmp(path,"/assets"))
return TRUE;
const char *bufp=path+strlen("/assets/");
// check if file is a directory.
AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp);
if (assetDir) {
const char *ptr = AAssetDir_getNextFileName(assetDir) ;
AAssetDir_close(assetDir);
if (ptr)
return TRUE;
}
AAsset *asset = AAssetManager_open(mgr, bufp, AASSET_MODE_UNKNOWN);
if (!asset)
return FALSE;
AAsset_close(asset);
return TRUE;
}
if (Yap_isAsset(path)) {
return Yap_AssetIsFile(path);
}
#endif
if ( statfunc(OsPath(path, tmp), &buf) == -1 || !S_ISREG(buf.st_mode) )
{ DEBUG(2, perror(tmp));
@ -388,22 +305,9 @@ ExistsDirectory(const char *path)
statstruct buf;
#ifdef __ANDROID__
if (strstr(ospath,"/assets")) {
AAssetManager* mgr = GLOBAL_assetManager;
const char *ptr = NULL;
if (!strcmp(path,"/assets"))
return TRUE;
const char *bufp=path+strlen("/assets/");
// check if file is a directory.
AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp);
if (assetDir)
ptr = AAssetDir_getNextFileName(assetDir);
if (assetDir) {
AAssetDir_close(assetDir);
}
return ptr != NULL;
}
if (Yap_isAsset(ospath)) {
return Yap_AssetIsDir(ospath);
}
#endif
if ( statfunc(ospath, &buf) < 0 )
return FALSE;
@ -688,12 +592,10 @@ get_file_name(term_t n, char **namep, char *tmp, int flags)
if ( len+1 >= MAXPATHLEN )
return PL_error(NULL, 0, NULL, ERR_REPRESENTATION,
ATOM_max_path_length);
if ( truePrologFlag(PLFLAG_FILEVARS) )
{ if ( !(name = expandVars(name, tmp, MAXPATHLEN)) )
return FALSE;
}
if ( !(flags & PL_FILE_NOERRORS) )
{ atom_t op = 0;
@ -732,10 +634,9 @@ PL_get_file_name(term_t n, char **namep, int flags)
if ( (rc=get_file_name(n, &name, buf, flags)) )
{ if ( (flags & PL_FILE_OSPATH) )
{ if ( !(name = OsPath(name, ospath)) )
{ if ( !(name = OsPath(name, ospath)) )
return FALSE;
}
*namep = buffer_string(name, BUF_RING);
}
@ -1138,7 +1039,6 @@ PRED_IMPL("$absolute_file_name", 2, absolute_file_name, 0)
term_t name = A1;
term_t expanded = A2;
if ( PL_get_file_name(name, &n, 0) &&
(n = AbsoluteFile(n, tmp)) )
return PL_unify_chars(expanded, PL_ATOM|REP_FN, -1, n);

1193
os/pl-os.c

File diff suppressed because it is too large Load Diff

View File

@ -144,16 +144,16 @@ unifyList(term_t term, list_ctx *ctx)
CACHE_REGS
if (!CloseList(ctx->gstore, TermNil))
return FALSE;
return Yap_unify(Yap_GetFromSlot(term PASS_REGS), ctx->start);
return Yap_unify(Yap_GetFromSlot(term), ctx->start);
}
int
unifyDiffList(term_t head, term_t tail, list_ctx *ctx)
{
CACHE_REGS
if (!CloseList(ctx->gstore, Yap_GetFromSlot(tail PASS_REGS)))
if (!CloseList(ctx->gstore, Yap_GetFromSlot(tail)))
return FALSE;
return Yap_unify(Yap_GetFromSlot(head PASS_REGS), ctx->start);
return Yap_unify(Yap_GetFromSlot(head), ctx->start);
}
#else

View File

@ -1182,7 +1182,7 @@ read_clause(IOSTREAM *s, term_t term, term_t options ARG_LD)
PL_TERM, term,
PL_TERM, tpos );
}
ap = Yap_PredFromClause( Yap_GetFromSlot(term PASS_REGS) PASS_REGS);
ap = Yap_PredFromClause( Yap_GetFromSlot(term) PASS_REGS);
if (rd.styleCheck & (DISCONTIGUOUS_STYLE|MULTIPLE_CHECK) && ap != NULL ) {
if ( rd.styleCheck & (DISCONTIGUOUS_STYLE) && Yap_discontiguous( ap PASS_REGS) ) {
printMessage(ATOM_warning,
@ -1541,7 +1541,7 @@ Yap_StringToTerm(const char *s, size_t len, term_t bindings)
init_read_data(&rd, stream PASS_LD);
rd.varnames = bindings;
term_t tt = Yap_NewSlots(1 PASS_REGS);
term_t tt = Yap_NewSlots(1);
if ( !(rval = read_term(tt, &rd PASS_LD)) && rd.has_exception ) {
rval = PL_raise_exception(rd.exception);
@ -1552,7 +1552,7 @@ Sclose(stream);
LD->read_source = oldsrc;
// getchar();
return Yap_GetFromSlot( tt PASS_REGS);
return Yap_GetFromSlot( tt);
}
/** @pred atom_to_term(+ _Atom_, - _Term_, - _Bindings_)
@ -1638,4 +1638,3 @@ PRED_DEF("$qq_open", 2, qq_open, 0)
EndPredDefs
//! @}

View File

@ -44,11 +44,16 @@
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#include <android/log.h>
int Yap_isAsset( const char *path );
#define LOG(...) __android_log_print(ANDROID_LOG_DEBUG,"YAP Stream", __VA_ARGS__)
#else
#define __android_log_print(i,loc,msg,...)
#define ANDROID_LOG_INFO 0
#define ANDROID_LOG_ERROR 0
#define ANDROID_LOG_DEBUG 0
#define LOG(...)
#endif
@ -768,7 +773,8 @@ unget_byte(int c, IOSTREAM *s)
int
Sungetc(int c, IOSTREAM *s)
{ if ( s->bufp > s->unbuffer )
{
if ( s->bufp > s->unbuffer )
{ unget_byte(c, s);
return c;
@ -1153,7 +1159,6 @@ Speekcode(IOSTREAM *s)
{ int c;
char *start;
size_t safe = (size_t)-1;
if ( !s->buffer )
{ if ( (s->flags & SIO_NBUF) )
{ errno = EINVAL;
@ -1786,6 +1791,11 @@ object, which in turn calls the ->unlink which may wish to close the
associated stream.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#if __ANDROID__
static int
Sclose_asset(void *handle);
#endif
int
Sclose(IOSTREAM *s)
{ int rval = 0;
@ -1825,12 +1835,19 @@ Sclose(IOSTREAM *s)
rval = -1;
}
#if __ANDROID__
if (s->functions->close == Sclose_asset) {
#endif
while(s->locks > 0) /* remove buffer-locks */
{ int rc = Sunlock(s);
if ( rval == 0 )
rval = rc;
}
#if __ANDROID__
}
#endif
if ( rval < 0 )
reportStreamError(s);
run_close_hooks(s); /* deletes Prolog registration */
@ -2916,11 +2933,41 @@ Sopen_file(const char *path, const char *how)
#endif
#if __ANDROID__
if (strstr(path, "/assets/") == path) {
AAssetManager *Yap_assetManager( void );
char * p = (char *)path + strlen("/assets/");
return Sopen_asset( p, how-1, Yap_assetManager());
}
if (Yap_isAsset(path)) {
extern IOFUNCTIONS Sassetfunctions;
extern void *Yap_openAssetFile(const char *);
if (op != 'r')
return NULL;
for( ; *how; how++)
{ switch(*how)
{
case 'b': /* binary */
flags &= ~SIO_TEXT;
enc = ENC_OCTET;
break;
case 'r': /* no record */
flags &= ~SIO_RECORDPOS;
break;
default:
errno = EINVAL;
return NULL;
}
}
#if O_LARGEFILES && defined(O_LARGEFILE)
oflags |= O_LARGEFILE;
#endif
lfd = (intptr_t)Yap_openAssetFile( path );
if (!lfd) {
errno = EINVAL;
return NULL;
}
Sfilefunctions = Sassetfunctions;
lock = 0;
flags |= SIO_INPUT;
goto build_stream;
}
#endif
for( ; *how; how++)
@ -3037,6 +3084,9 @@ Sopen_file(const char *path, const char *how)
}
lfd = (intptr_t)fd;
#if __ANDROID__
build_stream:
#endif
s = Snew((void *)lfd, flags, &Sfilefunctions);
if ( enc != ENC_UNKNOWN )
s->encoding = enc;
@ -3332,66 +3382,6 @@ Sopen_asset(char **buffer, size_t *sizep, const char* mode)
Open an Android asset, essentially a read-only part of a ZIP archive.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
IOSTREAM *
Sopen_asset(char *bufp, const char *how, AAssetManager* mgr)
{
AAsset* asset;
int flags = SIO_FILE|SIO_TEXT|SIO_RECORDPOS|SIO_FBUF;
int op = *how++;
IOSTREAM *s;
IOENC enc = ENC_UNKNOWN;
for( ; *how; how++)
{ switch(*how)
{ case 'b': /* binary */
flags &= ~SIO_TEXT;
enc = ENC_OCTET;
break;
case 'r': /* no record */
flags &= ~SIO_RECORDPOS;
break;
case 'L': /* lock r: read, w: write */
case 'l': /* lock r: read, w: write */
// read-only, nothing changes.
break;
default:
errno = EINVAL;
return NULL;
}
}
#if O_LARGEFILES && defined(O_LARGEFILE)
oflags |= O_LARGEFILE;
#endif
switch(op)
{ case 'w':
return NULL;
case 'a':
return NULL;
case 'u':
return NULL;
case 'r':
//const char *utf8 = (*env)->GetStringUTFChars(env, bufp, NULL);
asset = AAssetManager_open(mgr, bufp, AASSET_MODE_UNKNOWN);
flags |= SIO_INPUT;
break;
default:
errno = EINVAL;
return NULL;
}
if ( !asset )
return NULL;
s = Snew((void *)asset, flags, &Sassetfunctions);
if ( enc != ENC_UNKNOWN )
s->encoding = enc;
return s;
}
#endif /* __ANDROID__ */
/*******************************

View File

@ -67,6 +67,3 @@ out:
return rc;
}
#endif

View File

@ -193,7 +193,7 @@ static int
bind_varnames(term_t varnames ARG_LD)
{
CACHE_REGS
Term t = Yap_GetFromSlot(varnames PASS_REGS);
Term t = Yap_GetFromSlot(varnames);
while(!IsVarTerm(t) && IsPairTerm(t)) {
Term tl = HeadOfTerm(t);
Functor f;
@ -221,7 +221,7 @@ char *
varName(term_t t, char *name)
{
CACHE_REGS
CELL *adr = (CELL *)Yap_GetFromSlot(t PASS_REGS);
CELL *adr = (CELL *)Yap_GetFromSlot(t);
if (IsAttVar(adr)) {
Ssprintf(name, "_D%ld", (CELL)adr - (CELL)H0);
@ -262,20 +262,10 @@ writeTopTerm(term_t t, int prec, write_options *options)
if (flags & PL_WRT_BLOB_PORTRAY)
yap_flag |= Blob_Portray_f;
old_module = CurrentModule;
char * buf[1024];
size_t length;
int encode; Term tn;
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "Yap_REGS=%p\n", Yap_REGS);
CurrentModule = Yap_GetModuleFromEntry(options->module);
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "t=%d\n", t) ;
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "LOCAl_SlotBase[t]=%ld\n", LOCAL_SlotBase[t]);
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "LOCAl_SlotBase=%ld\n", Deref(LOCAL_SlotBase[t]));
Yap_plwrite(Yap_GetFromSlot(t PASS_REGS), options->out, options->max_depth, yap_flag, prec);
Yap_plwrite(Yap_GetFromSlot(t), options->out, options->max_depth, yap_flag, prec);
CurrentModule = old_module;
return TRUE;
}

View File

@ -62,7 +62,7 @@ MYDDAS_PROLOG= \
myddas_assert_predicates.ypp \
myddas_mysql.ypp \
myddas_sqlite3.ypp \
myddas_top_level.ypp \
myddas_top_level.ypp \
myddas_errors.ypp \
myddas_postgres.ypp \
myddas_prolog2sql.ypp \
@ -85,7 +85,7 @@ all: $(SOBJS) $(MYDDAS_YAP)
$(CC) -c $(CFLAGS) $< -o $@
%.yap: $(srcdir)/pl/%.ypp
$(ECPP) $(YAP_EXTRAS) -P -w $< -o $@
$(ECPP) $(YAP_EXTRAS) -P -w $< > $@
@DO_SECOND_LD@%.@SO@: $(OBJS)
@DO_SECOND_LD@ @SHLIB_LD@ $(LDFLAGS) -o $@ $(OBJS) @EXTRA_LIBS_FOR_DLLS@ @MYDDAS_LIBS@

View File

@ -195,14 +195,14 @@ else
ENABLE_MYDDAS=""
fi
INCLUDE_MYDDAS="#"
OBJECTS_MYDDAS="#"
if test x"$ENABLE_MYDDAS" = x -a x"$STARTUP_ANDROID" = x
then
#in Android we have to actually include myddas in the binary
INCLUDE_MYDDAS=""
OBJECTS_MYDDAS="$(ALL_MYDDAS_OBJECTS)"
fi
AC_SUBST(PKG_MYDDAS)
AC_SUBST(INCLUDE_MYDDAS)
AC_SUBST(OBJECTS_MYDDAS)
AC_SUBST(MYDDAS_CPPFLAGS)
AC_SUBST(MYDDAS_LIBS)

View File

@ -26,9 +26,8 @@ LOCAL_MODULE := example
LOCAL_SHARED_LIBRARIES := yap0 yap1 sqliteX yap2
LOCAL_STATIC_LIBRARIES := @abs_top_builddir@/libYap.ar
LOCAL_SRC_FILES += @abs_top_builddir@/packages/swig/android/jni/yap_wrap.cpp
LOCAL_SRC_FILES += @srcdir@/../prosqlite/c/prosqlite.c
LOCAL_C_INCLUDES := @abs_top_builddir@ @GMPDIR@/include @srcdir@/../../H @srcdir@/../../include @srcdir@/../../os @srcdir@/../../OPTYap @srcdir@/../../BEAM @srcdir@/../../CXX sqlite
LOCAL_CFLAGS := @YAP_EXTRAS@ @DEFS@ -D_YAP_NOT_INSTALLED_=1 -DDESTDIR=\"\"
LOCAL_CPP_FEATURES := rtti
# LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
LOCAL_ALLOW_UNDEFINED_SYMBOLS := false
include $(BUILD_SHARED_LIBRARY)

View File

@ -26,11 +26,9 @@ JAVA_SQLITE="$(srcdir)/android/src/org"
SQLITE=$(JNI_SQLITE) $(JAVA_SQLITE)
PROSQLITE=$(srcdir)/../prosqlite/prolog/prosqlite.pl
PYTHON_PROGRAMS = $(srcdir)/python/demo.py
ANDROID_PROGRAMS=$(srcdir)/android/JavaYap.java $(PROSQLITE) $(SQLITE)
ANDROID_PROGRAMS=$(srcdir)/android/JavaYap.java $(SQLITE)
PROGRAMS= $(PYTHON_PROGRAMS) $(JAVA_PROGRAMS) $(ANDROID_PROGRAMS)
@ -42,7 +40,7 @@ YAP_EXPORT_SAVED_STATE="../../startup.yss"
PYTHON_PROGRAMS = $(srcdir)/python/demo.py
ANDROID_PROGRAMS=$(srcdir)/android/JavaYap.java $(PROSQLITE) $(SQLITE)
ANDROID_PROGRAMS=$(srcdir)/android/JavaYap.java $(SQLITE)
SWIG_FILES= \
$(srcdir)/yap.i
@ -89,9 +87,6 @@ JavaYap-debug.apk: android/libs/armeabi/libexample.so
android/libs/armeabi/libexample.so: android/jni/Android.mk android/jni/Application.mk android/jni/yap_wrap.cpp
( cd android/jni && NDK_DEBUG=1 ndk-build )
cp -r $(YAP_EXPORT_PLS)/* android/assets/share/Yap
cp -r $(YAP_EXPORT_DLLS)/*.so android/jni
cp -r $(YAP_EXPORT_SAVED_STATE) android/assets/lib/Yap
android/jni/Application.mk: android/jni/Android.mk
cp $(srcdir)/android/jni/Application.mk android/jni
@ -124,11 +119,13 @@ R:
yap.i: $(srcdir)/../../../../include/YapInterface.h
install:
install: all
clean:
rm -fr android/* jni/* java/* python/*
rm -fr android/libs/armeabi/libexample.so JavaYap-debug.apk android/jni/Application.mk \
android/jni/Android.mk android/jni/yap_wrap.cpp python/_yap.so jni/yap_wrap.o \
python/yap_wrap.cpp python/yap.py jni/yap_wrap.cpp java/yap.java
distclean: clean
rm -f *def Makefile

View File

@ -60,9 +60,10 @@ public class JavaYap extends Activity
String str;
String buf;
YAPQuery q;
Boolean running = false;
Boolean running = false, compute = true;
int i=1;
YAPListTerm vs0;
private AssetManager mgr;
void runQuery(String str, Boolean more)
{
@ -70,13 +71,18 @@ public class JavaYap extends Activity
{
// check if at initial query
if (!running) {
if (BuildConfig.DEBUG) {
Log.i(TAG, "query "+str);
}
q = eng.query( str );
// get the uninstantiated query variables.
vs0 = q.namedVars();
running = true;
}
// start computing
Boolean compute = true;
compute = true;
if (BuildConfig.DEBUG) {
Log.i(TAG, "onQueryButtonClick called");
@ -89,7 +95,7 @@ public class JavaYap extends Activity
if (BuildConfig.DEBUG) {
Log.i(TAG, "q0=\n");
}
if (compute && q.next()) {
if (compute && (rc = q.next())) {
outputText.append( "yes\n" );
running = compute = more;
} else {
@ -102,7 +108,7 @@ public class JavaYap extends Activity
Log.i(TAG, "q1= "+vs0.text()+"\n");
}
while (compute && (rc = q.next()) ) {
YAPListTerm vs = vs0;
YAPListTerm vs = q.namedVars();
while(!vs.nil()){
if (BuildConfig.DEBUG) {
Log.i(TAG, "q= "+vs0.text()+"\n");
@ -118,11 +124,14 @@ public class JavaYap extends Activity
}
if ( !rc) {
q.close();
running = compute = false;
compute = true;
running = false;
}
} catch(Exception e){
outputText.append("Exception thrown :" + e);
return;
q.close();
compute = true;
running = false;
}
}
@ -139,8 +148,8 @@ public class JavaYap extends Activity
s = getPackageName();
PackageInfo p = m.getPackageInfo(s, 0);
//s = p.applicationInfo.dataDir;
AssetManager mgr = getResources().getAssets();
Log.i(TAG, "mgr=" +mgr + " " + s);
mgr = getResources().getAssets();
Log.i(TAG, "mgr0=" +mgr + " " + s);
load(mgr);
} catch(NameNotFoundException e) {
Log.e(TAG, "Couldn't find package information in PackageManager", e);
@ -239,8 +248,6 @@ public class JavaYap extends Activity
private static native void load(AssetManager mgr);
private AssetManager mgr;
private static final String TAG = "JavaYap";
}
@ -256,13 +263,6 @@ class JavaCallback extends YAPCallback
Log.i(TAG, "java callback init");
}
public void run()
{
Log.i(TAG, "java callback ");
System.out.println("JavaCallback.run() ");
}
public void run(String s)
{
Log.i(TAG, "java callback ");

View File

@ -3567,7 +3567,7 @@ SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
** UTF-16 encoded strings and the other functions return UTF-8.
**
** ^These APIs are only available if the library was compiled with the
** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
** [SQLITE_ENABLE_COLUMN_METAPDATA] C-preprocessor symbol.
**
** If two or more threads call one or more of these routines against the same
** prepared statement and column at the same time then the results are
@ -5130,7 +5130,7 @@ SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
**
** ^This API is only available if the library was compiled with the
** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
** [SQLITE_ENABLE_COLUMN_METAPDATA] C-preprocessor symbol defined.
*/
SQLITE_API int sqlite3_table_column_metadata(
sqlite3 *db, /* Connection handle */
@ -8674,7 +8674,7 @@ typedef struct WhereInfo WhereInfo;
/* TODO: This definition is just included so other modules compile. It
** needs to be revisited.
*/
#define SQLITE_N_BTREE_META 10
#define SQLITE_N_BTREE_METAP 10
/*
** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
@ -9045,7 +9045,7 @@ typedef struct VdbeOpList VdbeOpList;
#define COLNAME_DATABASE 2
#define COLNAME_TABLE 3
#define COLNAME_COLUMN 4
#ifdef SQLITE_ENABLE_COLUMN_METADATA
#ifdef SQLITE_ENABLE_COLUMN_METAPDATA
# define COLNAME_N 5 /* Number of COLNAME_xxx symbols */
#else
# ifdef SQLITE_OMIT_DECLTYPE
@ -13104,8 +13104,8 @@ static const char * const azCompileOpt[] = {
#ifdef SQLITE_ENABLE_CEROD
"ENABLE_CEROD",
#endif
#ifdef SQLITE_ENABLE_COLUMN_METADATA
"ENABLE_COLUMN_METADATA",
#ifdef SQLITE_ENABLE_COLUMN_METAPDATA
"ENABLE_COLUMN_METAPDATA",
#endif
#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
"ENABLE_EXPENSIVE_ASSERT",
@ -65428,12 +65428,12 @@ SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){
#endif
/*
** Constraint: If you have ENABLE_COLUMN_METADATA then you must
** Constraint: If you have ENABLE_COLUMN_METAPDATA then you must
** not define OMIT_DECLTYPE.
*/
#if defined(SQLITE_OMIT_DECLTYPE) && defined(SQLITE_ENABLE_COLUMN_METADATA)
#if defined(SQLITE_OMIT_DECLTYPE) && defined(SQLITE_ENABLE_COLUMN_METAPDATA)
# error "Must not define both SQLITE_OMIT_DECLTYPE \
and SQLITE_ENABLE_COLUMN_METADATA"
and SQLITE_ENABLE_COLUMN_METAPDATA"
#endif
#ifndef SQLITE_OMIT_DECLTYPE
@ -65453,7 +65453,7 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){
#endif /* SQLITE_OMIT_UTF16 */
#endif /* SQLITE_OMIT_DECLTYPE */
#ifdef SQLITE_ENABLE_COLUMN_METADATA
#ifdef SQLITE_ENABLE_COLUMN_METAPDATA
/*
** Return the name of the database from which a result column derives.
** NULL is returned if the result column is an expression or constant or
@ -65501,7 +65501,7 @@ SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_COLUMN);
}
#endif /* SQLITE_OMIT_UTF16 */
#endif /* SQLITE_ENABLE_COLUMN_METADATA */
#endif /* SQLITE_ENABLE_COLUMN_METAPDATA */
/******************************* sqlite3_bind_ ***************************
@ -69285,7 +69285,7 @@ case OP_ReadCookie: { /* out2-prerelease */
assert( p->bIsReader );
iDb = pOp->p1;
iCookie = pOp->p3;
assert( pOp->p3<SQLITE_N_BTREE_META );
assert( pOp->p3<SQLITE_N_BTREE_METAP );
assert( iDb>=0 && iDb<db->nDb );
assert( db->aDb[iDb].pBt!=0 );
assert( (p->btreeMask & (((yDbMask)1)<<iDb))!=0 );
@ -69307,7 +69307,7 @@ case OP_ReadCookie: { /* out2-prerelease */
*/
case OP_SetCookie: { /* in3 */
Db *pDb;
assert( pOp->p2<SQLITE_N_BTREE_META );
assert( pOp->p2<SQLITE_N_BTREE_METAP );
assert( pOp->p1>=0 && pOp->p1<db->nDb );
assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );
assert( p->readOnly==0 );
@ -95154,7 +95154,7 @@ struct sqlite3_api_routines {
** excluded from a build of SQLite. Substitute a NULL pointer
** for any missing APIs.
*/
#ifndef SQLITE_ENABLE_COLUMN_METADATA
#ifndef SQLITE_ENABLE_COLUMN_METAPDATA
# define sqlite3_column_database_name 0
# define sqlite3_column_database_name16 0
# define sqlite3_column_table_name 0
@ -100186,9 +100186,9 @@ static void generateSortTail(
** The declaration type for any expression other than a column is NULL.
**
** This routine has either 3 or 6 parameters depending on whether or not
** the SQLITE_ENABLE_COLUMN_METADATA compile-time option is used.
** the SQLITE_ENABLE_COLUMN_METAPDATA compile-time option is used.
*/
#ifdef SQLITE_ENABLE_COLUMN_METADATA
#ifdef SQLITE_ENABLE_COLUMN_METAPDATA
# define columnType(A,B,C,D,E,F) columnTypeImpl(A,B,C,D,E,F)
static const char *columnTypeImpl(
NameContext *pNC,
@ -100201,14 +100201,14 @@ static const char *columnTypeImpl(
char const *zOrigDb = 0;
char const *zOrigTab = 0;
char const *zOrigCol = 0;
#else /* if !defined(SQLITE_ENABLE_COLUMN_METADATA) */
#else /* if !defined(SQLITE_ENABLE_COLUMN_METAPDATA) */
# define columnType(A,B,C,D,E,F) columnTypeImpl(A,B,F)
static const char *columnTypeImpl(
NameContext *pNC,
Expr *pExpr,
u8 *pEstWidth
){
#endif /* !defined(SQLITE_ENABLE_COLUMN_METADATA) */
#endif /* !defined(SQLITE_ENABLE_COLUMN_METAPDATA) */
char const *zType = 0;
int j;
u8 estWidth = 1;
@ -100281,7 +100281,7 @@ static const char *columnTypeImpl(
assert( !pS );
if( iCol<0 ) iCol = pTab->iPKey;
assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
#ifdef SQLITE_ENABLE_COLUMN_METADATA
#ifdef SQLITE_ENABLE_COLUMN_METAPDATA
if( iCol<0 ){
zType = "INTEGER";
zOrigCol = "rowid";
@ -100325,7 +100325,7 @@ static const char *columnTypeImpl(
#endif
}
#ifdef SQLITE_ENABLE_COLUMN_METADATA
#ifdef SQLITE_ENABLE_COLUMN_METAPDATA
if( pzOrigDb ){
assert( pzOrigTab && pzOrigCol );
*pzOrigDb = zOrigDb;
@ -100355,7 +100355,7 @@ static void generateColumnTypes(
for(i=0; i<pEList->nExpr; i++){
Expr *p = pEList->a[i].pExpr;
const char *zType;
#ifdef SQLITE_ENABLE_COLUMN_METADATA
#ifdef SQLITE_ENABLE_COLUMN_METAPDATA
const char *zOrigDb = 0;
const char *zOrigTab = 0;
const char *zOrigCol = 0;
@ -121509,7 +121509,7 @@ SQLITE_API void sqlite3_thread_cleanup(void){
** Return meta information about a specific column of a database table.
** See comment in sqlite3.h (sqlite.h.in) for details.
*/
#ifdef SQLITE_ENABLE_COLUMN_METADATA
#ifdef SQLITE_ENABLE_COLUMN_METAPDATA
SQLITE_API int sqlite3_table_column_metadata(
sqlite3 *db, /* Connection handle */
const char *zDbName, /* Database name or NULL */

View File

@ -7379,4 +7379,3 @@ struct sqlite3_rtree_geometry {
#endif
#endif /* ifndef _SQLITE3RTREE_H_ */

View File

@ -21,10 +21,11 @@ fi
if test "$PKG_SWIG" != ""; then
mkdir -p packages/swig/android
mkdir -p packages/swig/android/usr
mkdir -p packages/swig/python
mkdir -p packages/swig/R
mkdir -p packages/swig/java
mkdir -p packages/swig/fli
mkdir -p packages/swig/jni
AC_SUBST(SWIG)

View File

@ -3,20 +3,31 @@
import sys
import yap
#
# initialize engine
engine = yap.YAPEngine();
# engine = yap.YAPEngine(yap.YAPParams());
def go():
while True:
s = raw_input("Prolog Query: ")
q = engine.query(s)
while q.next():
vs = q.namedVars();
if vs.length() == 0:
print "yes"
else:
while vs.length() > 0:
eq = vs.car()
print eq.getArg(1).text() + " = " + eq.getArg(2).text()
vs = vs.cdr()
print "no more answers"
def query( s ):
q = engine.query(s)
while q.next():
vs = q.namedVars()
if vs.length() == 0:
print( "yes" )
return
else:
while vs.length() > 0:
eq = vs.car()
print( eq.getArg(1).text() + " = " + eq.getArg(2).text() )
vs = vs.cdr()
s = raw_input("next: ?")
if s.find(';') != 0 :
return
print( "no more answers" )
return
def live():
loop = True
while loop:
s = raw_input("?- ")
query( s )

View File

@ -50,8 +50,6 @@
extern "C" {
extern Term Yap_StringToTerm(const char *s, size_t len, term_t bindings);
#if THREADS
#define Yap_regp regcache
#endif
@ -89,4 +87,3 @@
}
}
#endif

View File

@ -16,7 +16,7 @@
*************************************************************************/
:- system_module( '$_consult', [compile/1,
consult/1,
db_files/1,-
db_files/1,
ensure_loaded/1,
exists_source/1,
exo_files/1,
@ -879,6 +879,7 @@ db_files(Fs) :-
'$do_startup_reconsult'(_).
'$skip_unix_header'(Stream) :-
writeln(Stream),
peek_code(Stream, 0'#), !, % 35 is ASCII for '#
skip(Stream, 10),
'$skip_unix_header'(Stream).

View File

@ -823,7 +823,10 @@ expand_goal(G, G).
% be careful here not to generate an undefined exception.
'$imported_pred'(G, ImportingMod, G0, ExportingMod) :-
'$enter_undefp',
'$undefined'(G, ImportingMod),
( var(G) -> true ;
var(ImportingMod) -> true ;
'$undefined'(G, ImportingMod)
),
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod),
ExportingMod \= ImportingMod, !,
'$exit_undefp'.
@ -833,8 +836,8 @@ expand_goal(G, G).
% This predicate should be bidirectional: both
% a consumer and a generator.
'$get_undefined_pred'(G, ImportingMod, call(G), ImportingMod) :-
var(G), !.
%'$get_undefined_pred'(G, ImportingMod, call(G), ImportingMod) :-
% var(G), !.
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :-
recorded('$import','$import'(ExportingModI,ImportingMod,G0I,G,_,_),_),
'$continue_imported'(ExportingMod, ExportingModI, G0, G0I).
@ -1404,10 +1407,14 @@ export_list(Module, List) :-
G0=..[_N0|Args],
G1=..[N1|Args],
( '$check_import'(M0,ContextMod,N1,K) ->
( ContextMod = user ->
( recordzifnot('$import','$import'(M0,user,G0,G1,N1,K),_) -> true ; true)
( ContextMod == prolog ->
recordzifnot('$import','$import'(M0,user,G0,G1,N1,K),_),
fail
;
( recordaifnot('$import','$import'(M0,ContextMod,G0,G1,N1,K),_) -> true ; true )
recordaifnot('$import','$import'(M0,ContextMod,G0,G1,N1,K),_),
fail
;
true
)
;
true

View File

@ -251,4 +251,3 @@ discontiguous(F) :-
'$start_line'(LN), write(user_error,LN),
write(user_error,')'),
nl(user_error).

View File

@ -15,9 +15,10 @@
* *
*************************************************************************/
/** @defgroup Database Using the Clausal Data Base
@ingroup builtins
@{
/**
* @defgroup Database Using the Clausal Data Base
* @ingroup builtins
* @{
Predicates in YAP may be dynamic or static. By default, when
consulting or reconsulting, predicates are assumed to be static:
@ -33,9 +34,6 @@ semantics will be the same as for C-Prolog. But the programmer should be
aware of the fact that asserting or retracting are still expensive operations,
and therefore he should try to avoid them whenever possible.
*/
:- system_module( '$_preds', [abolish/1,
@ -1003,7 +1001,7 @@ hide_predicate(P) :-
For the predicates obeying the specification _P_ unify _Prop_
with a property of _P_. These properties may be:
with a property of _P_. These properties may be:
+ `built_in `
true for built-in predicates,
@ -1044,20 +1042,19 @@ or built-in.
*/
predicate_property(Pred,Prop) :- var(Pred), !,
'$current_module'(Mod),
'$predicate_property2'(Pred,Prop,Mod).
predicate_property(Mod:Pred,Prop) :- !,
'$predicate_property2'(Pred,Prop,Mod).
predicate_property(Pred,Prop) :-
'$current_module'(Mod),
'$predicate_property2'(Pred,Prop,Mod).
strip_module(Pred, Mod, TruePred),
'$predicate_property2'(TruePred,Prop,Mod).
'$predicate_property2'(Pred,Prop,M) :- var(M), !,
'$all_current_modules'(M),
'$predicate_property2'(Pred,Prop,M).
'$predicate_property2'(Pred,Prop,M0) :- var(Pred), !,
(M = M0 ; M = prolog), % prolog mode is automatically incorporate in every other module
'$predicate_property2'(Pred, Prop, Mod) :-
var(Mod), !,
'$all_current_modules'(Mod),
'$predicate_property2'(Pred, Prop, Mod).
'$predicate_property2'(Pred,Prop,M0) :-
var(Pred), !,
(M = M0 ;
M = prolog ;
M = user), % prolog and user modules are automatically incorporate in every other module
'$generate_all_preds_from_mod'(Pred, SourceMod, M),
'$predicate_property'(Pred,SourceMod,M,Prop).
'$predicate_property2'(M:Pred,Prop,_) :- !,
@ -1167,22 +1164,22 @@ predicate_erased_statistics(P,NCls,Sz,ISz) :-
Defines the relation: _P_ is a currently defined predicate whose name is the atom _A_.
*/
current_predicate(A,T) :-
'$ground_module'(T, M, T0),
format('`0 ~w~n', [M:T0]),
(
'$current_predicate'(A, M, T0, Flags),
%TFlags is Flags /\ 0x00004000,
% format('1 ~w ~16r~n', [M:T0,Flags, TFlags]),
Flags /\ 0x00004000 =:= 0x0
;
'$imported_predicate'(A, M, A/_Arity, T0, Flags),
% format('2 ~w ~16r~n', [M:T0,Flags]),
Flags /\ 0x00004000 =:= 0x0
).
'$ground_module'(T, M, T0),
(
'$current_predicate'(A, M, T0, _),
%TFlags is Flags /\ 0x00004000,
% format('1 ~w ~16r~n', [M:T0,Flags, TFlags]),
\+ '$system_predicate'(T0, M)
;
'$imported_pred'(T0, M, SourceT, SourceMod),
functor(T0, A, _),
% format('2 ~w ~16r~n', [M:T0,Flags]),
\+ '$system_predicate'(SourceT, SourceMod)
).
/** @pred system_predicate( _A_, _P_)
Defines the relation: _P_ is a built-in predicate whose name
Defines the relation: _P_ is a built-in predicate whose name
is the atom _A_.
*/
@ -1211,15 +1208,17 @@ system_predicate(P) :-
_Na_ is the name of the predicate, and _Ar_ its arity.
*/
current_predicate(F0) :-
'$ground_module'(F0, M, F),
strip_module(F0, M, F),
(
'$current_predicate'(N, M, S, _),
functor( S, N, Ar),
F = N/Ar
;
'$imported_predicate'(_Name, M, F, S, _)
),
\+ system_predicate(_, S).
var(F)
->
current_predicate(M:A, S),
functor( S, A, Ar)
;
F = A/Ar,
current_predicate(M:A, S),
functor( S, A, Ar)
).
'$imported_predicate'(A, ImportingMod, A/Arity, G, Flags) :-
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod),
@ -1319,4 +1318,3 @@ clause_property(ClauseRef, predicate(PredicateIndicator)) :-
/**
@}
*/

View File

@ -327,4 +327,3 @@ all(T,G,S) :-
/**
@}
*/

View File

@ -205,4 +205,3 @@ predmerge(<, P, H1, H2, T1, T2, [H1|R]) :-
predmerge(P, T1, [H2|T2], R).
%%! @}

View File

@ -737,5 +737,3 @@ bind_actions()
}
}
}