android
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
#endif /* INDENT_CODE */
|
#endif /* INDENT_CODE */
|
||||||
|
|
||||||
BOp(call_cpred, Osbpp);
|
BOp(call_cpred, Osbpp);
|
||||||
#if __ANDROID__
|
#if __ANDROID__ && STRONG_DEBUG
|
||||||
char *s; Atom name;
|
char *s; Atom name;
|
||||||
if (PREG->y_u.Osbpp.p->ArityOfPE) {
|
if (PREG->y_u.Osbpp.p->ArityOfPE) {
|
||||||
Functor f = PREG->y_u.Osbpp.p->FunctorOfPred;
|
Functor f = PREG->y_u.Osbpp.p->FunctorOfPred;
|
||||||
|
9
C/init.c
9
C/init.c
@@ -1125,12 +1125,21 @@ InitAtoms(void)
|
|||||||
HashChain[i].Entry = NIL;
|
HashChain[i].Entry = NIL;
|
||||||
}
|
}
|
||||||
NOfAtoms = 0;
|
NOfAtoms = 0;
|
||||||
|
#if OLD_STYLE_INITIAL_ATOMS
|
||||||
Yap_LookupAtomWithAddress("**",(AtomEntry *)&(SF_STORE->AtFoundVar));
|
Yap_LookupAtomWithAddress("**",(AtomEntry *)&(SF_STORE->AtFoundVar));
|
||||||
Yap_ReleaseAtom(AtomFoundVar);
|
Yap_ReleaseAtom(AtomFoundVar);
|
||||||
Yap_LookupAtomWithAddress("?",(AtomEntry *)&(SF_STORE->AtFreeTerm));
|
Yap_LookupAtomWithAddress("?",(AtomEntry *)&(SF_STORE->AtFreeTerm));
|
||||||
Yap_ReleaseAtom(AtomFreeTerm);
|
Yap_ReleaseAtom(AtomFreeTerm);
|
||||||
Yap_LookupAtomWithAddress("[]",(AtomEntry *)&(SF_STORE->AtNil));
|
Yap_LookupAtomWithAddress("[]",(AtomEntry *)&(SF_STORE->AtNil));
|
||||||
Yap_LookupAtomWithAddress(".",(AtomEntry *)&(SF_STORE->AtDot));
|
Yap_LookupAtomWithAddress(".",(AtomEntry *)&(SF_STORE->AtDot));
|
||||||
|
#else
|
||||||
|
SF_STORE->AtFoundVar = Yap_LookupAtom("**");
|
||||||
|
Yap_ReleaseAtom(AtomFoundVar);
|
||||||
|
SF_STORE->AtFreeTerm = Yap_LookupAtom("?");
|
||||||
|
Yap_ReleaseAtom(AtomFreeTerm);
|
||||||
|
SF_STORE->AtNil = Yap_LookupAtom("[]");
|
||||||
|
SF_STORE->AtDot = Yap_LookupAtom(".");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -931,11 +931,16 @@ Yap_HandleToString(term_t l, size_t sz, size_t *length, int *encoding, int flags
|
|||||||
|
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
|
|
||||||
size_t size = 4096, total = size;
|
size_t size = 4096, total = size;
|
||||||
IOSTREAM *fd;
|
IOSTREAM *fd;
|
||||||
|
|
||||||
total = size;
|
total = size;
|
||||||
buf = malloc(total);
|
buf = malloc(total);
|
||||||
|
#ifdef DEBUG
|
||||||
|
{CACHE_REGS
|
||||||
|
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "text %p \n", buf);}
|
||||||
|
#endif
|
||||||
while ( (fd = Sopenmem(&buf, &size, "w")) == NULL ||
|
while ( (fd = Sopenmem(&buf, &size, "w")) == NULL ||
|
||||||
(( fd->encoding = ENC_UTF8) && FALSE) ||
|
(( fd->encoding = ENC_UTF8) && FALSE) ||
|
||||||
(PL_write_term(fd, l, 1200, flags) == 0) ||
|
(PL_write_term(fd, l, 1200, flags) == 0) ||
|
||||||
@@ -944,7 +949,7 @@ Yap_HandleToString(term_t l, size_t sz, size_t *length, int *encoding, int flags
|
|||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{CACHE_REGS
|
{CACHE_REGS
|
||||||
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "text %p, %x buf=%s\n", fd, LOCAL_SlotBase[28], buf);}
|
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "fd %p, %x buf=%s\n", fd, LOCAL_SlotBase[28], buf);}
|
||||||
#endif
|
#endif
|
||||||
Sclose(fd);
|
Sclose(fd);
|
||||||
if (!fd)
|
if (!fd)
|
||||||
|
@@ -2721,7 +2721,7 @@ p_yap_paths( USES_REGS1 ) {
|
|||||||
out2 = MkAtomTerm(Yap_LookupAtom(destdir));
|
out2 = MkAtomTerm(Yap_LookupAtom(destdir));
|
||||||
} else {
|
} else {
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
out2 = MkAtomTerm(Yap_LookupAtom("/assets/share"));
|
out2 = MkAtomTerm(Yap_LookupAtom("/assets/share/Yap"));
|
||||||
#else
|
#else
|
||||||
out2 = MkAtomTerm(Yap_LookupAtom(YAP_SHAREDIR));
|
out2 = MkAtomTerm(Yap_LookupAtom(YAP_SHAREDIR));
|
||||||
#endif
|
#endif
|
||||||
|
19
CXX/yapi.cpp
19
CXX/yapi.cpp
@@ -288,18 +288,10 @@ const char *YAPTerm::text() {
|
|||||||
int enc;
|
int enc;
|
||||||
|
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
#ifdef DEBUG
|
|
||||||
{CACHE_REGS
|
|
||||||
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "text %d, %x \n", t, LOCAL_SlotBase[t]);}
|
|
||||||
#endif
|
|
||||||
if (!(os = Yap_HandleToString(t, sze, &length, &enc, 0))) {
|
if (!(os = Yap_HandleToString(t, sze, &length, &enc, 0))) {
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
return (char *)NULL;
|
return (char *)NULL;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
|
||||||
{CACHE_REGS
|
|
||||||
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "text %d, %x %p\n", t, LOCAL_SlotBase[t], os);}
|
|
||||||
#endif
|
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
@@ -315,16 +307,11 @@ char *YAPQuery::text() {
|
|||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
return (char *)NULL;
|
return (char *)NULL;
|
||||||
}
|
}
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "II ") ; }
|
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "II %s", os) ; }
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YAPListTerm::nil() {
|
|
||||||
CACHE_REGS
|
|
||||||
return gt() == TermNil;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
YAPIntegerTerm::YAPIntegerTerm(intptr_t i) { CACHE_REGS Term tn = MkIntegerTerm( i ); mk( tn ); }
|
YAPIntegerTerm::YAPIntegerTerm(intptr_t i) { CACHE_REGS Term tn = MkIntegerTerm( i ); mk( tn ); }
|
||||||
|
|
||||||
@@ -348,11 +335,11 @@ YAPTerm::YAPTerm(intptr_t i) { CACHE_REGS Term tn = MkIntegerTerm( i ); mk( tn )
|
|||||||
YAPTerm YAPListTerm::car()
|
YAPTerm YAPListTerm::car()
|
||||||
{
|
{
|
||||||
Term to = gt();
|
Term to = gt();
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "to=%d", to) ; }
|
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "to=%p", to) ; }
|
||||||
if (IsPairTerm(to))
|
if (IsPairTerm(to))
|
||||||
return YAPTerm(HeadOfTerm(to));
|
return YAPTerm(HeadOfTerm(to));
|
||||||
else
|
else
|
||||||
return MkIntTerm(-1);
|
throw YAPError::YAP_DOMAIN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPVarTerm::YAPVarTerm() { CACHE_REGS mk( MkVarTerm( ) ); }
|
YAPVarTerm::YAPVarTerm() { CACHE_REGS mk( MkVarTerm( ) ); }
|
||||||
|
34
CXX/yapt.hh
34
CXX/yapt.hh
@@ -121,10 +121,20 @@ public:
|
|||||||
YAPAtomTerm(wchar_t *s) ;
|
YAPAtomTerm(wchar_t *s) ;
|
||||||
// Constructor: receives a sequence of n wchar_ts, whatever they may be;
|
// Constructor: receives a sequence of n wchar_ts, whatever they may be;
|
||||||
YAPAtomTerm(wchar_t *s, size_t len);
|
YAPAtomTerm(wchar_t *s, size_t len);
|
||||||
|
virtual bool isVar() { return false; } /// type check for unbound
|
||||||
|
virtual bool isAtom() { return true; } /// type check for atom
|
||||||
|
virtual bool isInteger() { return false; } /// type check for integer
|
||||||
|
virtual bool isFloat() { return false; } /// type check for floating-point
|
||||||
|
virtual bool isString() { return false; } /// type check for a string " ... "
|
||||||
|
virtual bool isCompound() { return false; } /// is a primitive term
|
||||||
|
virtual bool isAppl() { return false; } /// is a structured term
|
||||||
|
virtual bool isPair() { return false; } /// is a pair term
|
||||||
|
virtual bool isGround() { return true; } /// term is ground
|
||||||
|
virtual bool isList() { return gt() == TermNil; } /// [] is a list
|
||||||
// Getter: outputs the atom;
|
// Getter: outputs the atom;
|
||||||
YAPAtom getAtom() { return YAPAtom(AtomOfTerm( gt() )); }
|
YAPAtom getAtom() { return YAPAtom(AtomOfTerm( gt() )); }
|
||||||
// Getter: outputs the name as a sequence of ISO-LATIN1 codes;
|
// Getter: outputs the name as a sequence of ISO-LATIN1 codes;
|
||||||
const char *getName() { return AtomOfTerm( gt() )->StrOfAE; }
|
const char *text() { return AtomOfTerm( gt() )->StrOfAE; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -139,6 +149,16 @@ public:
|
|||||||
YAPApplTerm(YAPFunctor f);
|
YAPApplTerm(YAPFunctor f);
|
||||||
YAPFunctor getFunctor();
|
YAPFunctor getFunctor();
|
||||||
YAPTerm getArg(int i);
|
YAPTerm getArg(int i);
|
||||||
|
virtual bool isVar() { return false; } /// type check for unbound
|
||||||
|
virtual bool isAtom() { return false; } /// type check for atom
|
||||||
|
virtual bool isInteger() { return false; } /// type check for integer
|
||||||
|
virtual bool isFloat() { return false; } /// type check for floating-point
|
||||||
|
virtual bool isString() { return false; } /// type check for a string " ... "
|
||||||
|
virtual bool isCompound() { return true; } /// is a primitive term
|
||||||
|
virtual bool isAppl() { return true; } /// is a structured term
|
||||||
|
virtual bool isPair() { return false; } /// is a pair term
|
||||||
|
virtual bool isGround() { return true; } /// term is ground
|
||||||
|
virtual bool isList() { return false; } /// [] is a list
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,14 +178,14 @@ public:
|
|||||||
* @brief Integer Term
|
* @brief Integer Term
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class YAPIntegerTerm: private YAPTerm {
|
class YAPIntegerTerm: YAPTerm {
|
||||||
public:
|
public:
|
||||||
YAPIntegerTerm(intptr_t i);
|
YAPIntegerTerm(intptr_t i);
|
||||||
intptr_t getInteger() { return IntegerOfTerm( gt() ); }
|
intptr_t getInteger() { return IntegerOfTerm( gt() ); }
|
||||||
bool isTagged() { return IsIntTerm( gt() ); }
|
bool isTagged() { return IsIntTerm( gt() ); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class YAPListTerm: private YAPTerm {
|
class YAPListTerm: public YAPTerm {
|
||||||
public:
|
public:
|
||||||
/// Create a list term out of a standard term. Check if a valid operation.
|
/// Create a list term out of a standard term. Check if a valid operation.
|
||||||
///
|
///
|
||||||
@@ -204,7 +224,13 @@ public:
|
|||||||
/// Check if the list is empty.
|
/// Check if the list is empty.
|
||||||
///
|
///
|
||||||
/// @param[in] the list
|
/// @param[in] the list
|
||||||
bool nil();
|
inline bool nil() {
|
||||||
|
CACHE_REGS
|
||||||
|
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "II %x %x", gt(), TermNil) ; }
|
||||||
|
return gt() == TermNil;
|
||||||
|
}
|
||||||
|
|
||||||
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
17
H/TermExt.h
17
H/TermExt.h
@@ -32,16 +32,21 @@ language. Next, we discuss support to the most important ones.
|
|||||||
#define SF_STORE ((special_functors *)HEAP_INIT_BASE)
|
#define SF_STORE ((special_functors *)HEAP_INIT_BASE)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_OFFSETS
|
#if defined(USE_OFFSETS)
|
||||||
#define AtomFoundVar ((Atom)(&(((special_functors *)(NULL))->AtFoundVar)))
|
#define AtomFoundVar ((Atom)(&(((special_functors *)(NULL))->AtFoundVar)))
|
||||||
#define AtomFreeTerm ((Atom)(&(((special_functors *)(NULL))->AtFreeTerm)))
|
#define AtomFreeTerm ((Atom)(&(((special_functors *)(NULL))->AtFreeTerm)))
|
||||||
#define AtomNil ((Atom)(&(((special_functors *)(NULL))->AtNil)))
|
#define AtomNil ((Atom)(&(((special_functors *)(NULL))->AtNil)))
|
||||||
#define AtomDot ((Atom)(&(((special_functors *)(NULL))->AtDot)))
|
#define AtomDot ((Atom)(&(((special_functors *)(NULL))->AtDot)))
|
||||||
#else
|
#elif OLD_STYLE_INITIAL_ATOMS
|
||||||
#define AtomFoundVar AbsAtom((AtomEntry *)&(SF_STORE->AtFoundVar))
|
#define AtomFoundVar AbsAtom((AtomEntry *)&(SF_STORE->AtFoundVar))
|
||||||
#define AtomFreeTerm AbsAtom((AtomEntry *)&(SF_STORE->AtFreeTerm))
|
#define AtomFreeTerm AbsAtom((AtomEntry *)&(SF_STORE->AtFreeTerm))
|
||||||
#define AtomNil AbsAtom((AtomEntry *)&(SF_STORE->AtNil))
|
#define AtomNil AbsAtom((AtomEntry *)&(SF_STORE->AtNil))
|
||||||
#define AtomDot AbsAtom((AtomEntry *)&(SF_STORE->AtDot))
|
#define AtomDot AbsAtom((AtomEntry *)&(SF_STORE->AtDot))
|
||||||
|
#else
|
||||||
|
#define AtomFoundVar AbsAtom(SF_STORE->AtFoundVar)
|
||||||
|
#define AtomFreeTerm AbsAtom(SF_STORE->AtFreeTerm)
|
||||||
|
#define AtomNil AbsAtom(SF_STORE->AtNil)
|
||||||
|
#define AtomDot AbsAtom(SF_STORE->AtDot)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TermFoundVar MkAtomTerm(AtomFoundVar)
|
#define TermFoundVar MkAtomTerm(AtomFoundVar)
|
||||||
@@ -164,10 +169,18 @@ exts;
|
|||||||
in the heap when we start the system */
|
in the heap when we start the system */
|
||||||
typedef struct special_functors_struct
|
typedef struct special_functors_struct
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if 0
|
||||||
struct ExtraAtomEntryStruct AtFoundVar;
|
struct ExtraAtomEntryStruct AtFoundVar;
|
||||||
struct ExtraAtomEntryStruct AtFreeTerm;
|
struct ExtraAtomEntryStruct AtFreeTerm;
|
||||||
struct ExtraAtomEntryStruct AtNil;
|
struct ExtraAtomEntryStruct AtNil;
|
||||||
struct ExtraAtomEntryStruct AtDot;
|
struct ExtraAtomEntryStruct AtDot;
|
||||||
|
#else
|
||||||
|
struct AtomEntryStruct *AtFoundVar;
|
||||||
|
struct AtomEntryStruct *AtFreeTerm;
|
||||||
|
struct AtomEntryStruct *AtNil;
|
||||||
|
struct AtomEntryStruct *AtDot;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
special_functors;
|
special_functors;
|
||||||
#endif /* YAP_H */
|
#endif /* YAP_H */
|
||||||
|
@@ -625,9 +625,12 @@ libYap.a: $(LIB_OBJECTS) yapi.o
|
|||||||
adb shell mkdir -p /data/yap
|
adb shell mkdir -p /data/yap
|
||||||
adb shell mkdir -p /data/yap/pl
|
adb shell mkdir -p /data/yap/pl
|
||||||
adb shell mkdir -p /data/yap/swi/library
|
adb shell mkdir -p /data/yap/swi/library
|
||||||
adb shell mkdir -p /data/yap/packages
|
|
||||||
adb shell mkdir -p /data/yap/packages/chr
|
adb shell mkdir -p /data/yap/packages/chr
|
||||||
adb shell mkdir -p /data/yap/packages/clib
|
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 yap /data/yap/
|
||||||
adb push @DYNYAPLIB@ /data/yap/
|
adb push @DYNYAPLIB@ /data/yap/
|
||||||
for p in $(EXTRAYAPLIBS); do \
|
for p in $(EXTRAYAPLIBS); do \
|
||||||
@@ -639,6 +642,9 @@ libYap.a: $(LIB_OBJECTS) yapi.o
|
|||||||
adb push $(srcdir)/swi/library /data/yap/swi/library
|
adb push $(srcdir)/swi/library /data/yap/swi/library
|
||||||
adb push $(srcdir)/pl /data/yap/pl/
|
adb push $(srcdir)/pl /data/yap/pl/
|
||||||
adb push $(srcdir)/library /data/yap/library/
|
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/
|
||||||
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 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 pull /data/yap/startup.yss
|
||||||
#adb shell rm -rf /data/yap
|
#adb shell rm -rf /data/yap
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
copy_line/2,
|
copy_line/2,
|
||||||
filter/3,
|
filter/3,
|
||||||
file_filter/3,
|
file_filter/3,
|
||||||
|
file_select/2,
|
||||||
file_filter_with_initialization/5,
|
file_filter_with_initialization/5,
|
||||||
process/2
|
process/2
|
||||||
]).
|
]).
|
||||||
@@ -297,15 +298,22 @@ process(StreamInp, Command) :-
|
|||||||
fail
|
fail
|
||||||
).
|
).
|
||||||
|
|
||||||
|
/**
|
||||||
/** @pred file_filter(+ _FileIn_, + _FileOut_, + _Goal_) is meta
|
* @pred file_filter(+ _FileIn_, + _FileOut_, + _Goal_) is meta
|
||||||
|
*
|
||||||
|
* @param _FileIn_ File to process
|
||||||
|
* @param _FileOut_ Output file, often user_error
|
||||||
|
* @param _Goal_ to be metacalled, receives FileIn and FileOut as
|
||||||
|
* extra arguments
|
||||||
|
*
|
||||||
|
* @return succeeds
|
||||||
|
|
||||||
For every line _LineIn_ in file _FileIn_, execute
|
For every line _LineIn_ in file _FileIn_, execute
|
||||||
`call(Goal,LineIn,LineOut)`, and output _LineOut_ to file
|
`call(Goal,LineIn,LineOut)`, and output _LineOut_ to file
|
||||||
_FileOut_.
|
_FileOut_.
|
||||||
|
|
||||||
The input stream is accessible through the alias `filter_input`, and the output
|
The input stream is accessible through the alias `filter_input`, and
|
||||||
stream is accessible through `filter_output`.
|
the output stream is accessible through `filter_output`.
|
||||||
*/
|
*/
|
||||||
file_filter(Inp, Out, Command) :-
|
file_filter(Inp, Out, Command) :-
|
||||||
open(Inp, read, StreamInp, [alias(filter_input)]),
|
open(Inp, read, StreamInp, [alias(filter_input)]),
|
||||||
@@ -327,6 +335,37 @@ file_filter_with_initialization(Inp, Out, Command, FormatString, Parameters) :-
|
|||||||
filter(StreamInp, StreamOut, Command),
|
filter(StreamInp, StreamOut, Command),
|
||||||
close(StreamInp),
|
close(StreamInp),
|
||||||
close(StreamOut).
|
close(StreamOut).
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @pred file_select(+ _FileIn_, + _Goal_) is meta
|
||||||
|
*
|
||||||
|
* @param _FileIn_ File to process
|
||||||
|
* @param _Goal_ to be metacalled, receives FileIn as
|
||||||
|
* extra arguments
|
||||||
|
*
|
||||||
|
* @return bindings to arguments of _Goal_.
|
||||||
|
|
||||||
|
For every line _LineIn_ in file _FileIn_, execute
|
||||||
|
`call(`Goal,LineIn)`.
|
||||||
|
|
||||||
|
The input stream is accessible through the alias `filter_input`, and
|
||||||
|
the output stream is accessible through `filter_output`.
|
||||||
|
*/
|
||||||
|
file_select(Inp, Command) :-
|
||||||
|
open(Inp, read, StreamInp, [alias(filter_input)]),
|
||||||
|
repeat,
|
||||||
|
read_line_to_codes(StreamInp, Line),
|
||||||
|
(
|
||||||
|
Line == end_of_file
|
||||||
|
->
|
||||||
|
close(StreamInp),
|
||||||
|
!,
|
||||||
|
fail
|
||||||
|
;
|
||||||
|
call(Command, Line)
|
||||||
|
).
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@}
|
@}
|
||||||
*/
|
*/
|
||||||
|
@@ -1676,7 +1676,7 @@ ChDir(const char *path)
|
|||||||
size_t sz = strlen(ospath)+1;
|
size_t sz = strlen(ospath)+1;
|
||||||
AAssetDir_close(dir);
|
AAssetDir_close(dir);
|
||||||
LOCAL_InAssetDir = (char *)malloc(sz);
|
LOCAL_InAssetDir = (char *)malloc(sz);
|
||||||
strncpy(LOCAL_InAssetDir, ospath, sz-1);
|
strncpy(LOCAL_InAssetDir, ospath, sz);
|
||||||
succeed;
|
succeed;
|
||||||
} else {
|
} else {
|
||||||
fail;
|
fail;
|
||||||
|
Submodule packages/raptor updated: 36f99e3c3c...b36fdac228
@@ -59,54 +59,67 @@ public class JavaYap extends Activity
|
|||||||
EditText text;
|
EditText text;
|
||||||
String str;
|
String str;
|
||||||
String buf;
|
String buf;
|
||||||
|
YAPQuery q;
|
||||||
|
Boolean running = false;
|
||||||
|
int i=1;
|
||||||
|
YAPListTerm vs0;
|
||||||
|
|
||||||
void runQuery(String str)
|
void runQuery(String str, Boolean more)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
YAPQuery q = eng.query( str );
|
// check if at initial query
|
||||||
|
if (!running) {
|
||||||
|
q = eng.query( str );
|
||||||
|
// get the uninstantiated query variables.
|
||||||
|
vs0 = q.namedVars();
|
||||||
|
running = true;
|
||||||
|
}
|
||||||
|
// start computing
|
||||||
|
Boolean compute = true;
|
||||||
|
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
Log.i(TAG, "onQueryButtonClick called");
|
Log.i(TAG, "onQueryButtonClick called");
|
||||||
}
|
}
|
||||||
YAPListTerm vs0 = q.namedVars();
|
|
||||||
Boolean rc;
|
Boolean rc = true;
|
||||||
|
|
||||||
// text.setText("");
|
// text.setText("");
|
||||||
if (vs0.nil()) {
|
if (vs0.nil()) {
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
Log.i(TAG, "q0=\n");
|
Log.i(TAG, "q0=\n");
|
||||||
}
|
}
|
||||||
if (q.next()) {
|
if (compute && q.next()) {
|
||||||
outputText.append( "yes\n" );
|
outputText.append( "yes\n" );
|
||||||
|
running = compute = more;
|
||||||
} else {
|
} else {
|
||||||
outputText.append( "no\n" );
|
outputText.append( "no\n" );
|
||||||
|
running = false;
|
||||||
|
compute = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int i=1;
|
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
//Log.i(TAG, "q1= "+vs0.text()+"\n");
|
Log.i(TAG, "q1= "+vs0.text()+"\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
while (rc = q.next()) {
|
while (compute && (rc = q.next()) ) {
|
||||||
YAPListTerm vs = vs0;
|
YAPListTerm vs = vs0;
|
||||||
while(!vs.nil()){
|
while(!vs.nil()){
|
||||||
YAPTerm eq = vs.car();
|
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
Log.i(TAG, "q= "+vs0+"\n");
|
Log.i(TAG, "q= "+vs0.text()+"\n");
|
||||||
}
|
}
|
||||||
|
YAPTerm eq = vs.car();
|
||||||
//outputText.append(Integer.toString(i) + ": " + eq.text() );
|
//outputText.append(Integer.toString(i) + ": " + eq.text() );
|
||||||
outputText.append(Integer.toString(i++));
|
outputText.append(Integer.toString(i++));
|
||||||
Log.i(TAG, "q= "+ eq.getArg(1)+"\n");
|
|
||||||
Log.i(TAG, "q= "+ eq.getArg(2)+"\n");
|
|
||||||
Log.i(TAG, "q= "+ eq.getArg(1).text()+"\n");
|
|
||||||
Log.i(TAG, "q= "+ eq.getArg(2).text()+"\n");
|
|
||||||
outputText.append(":\t" + eq.getArg(1).text() + " = " + eq.getArg(2).text() +"\n" );
|
outputText.append(":\t" + eq.getArg(1).text() + " = " + eq.getArg(2).text() +"\n" );
|
||||||
vs = vs.cdr();
|
vs = vs.cdr();
|
||||||
}
|
}
|
||||||
|
compute = more;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( !rc) {
|
||||||
q.close();
|
q.close();
|
||||||
|
running = compute = false;
|
||||||
|
}
|
||||||
} catch(Exception e){
|
} catch(Exception e){
|
||||||
outputText.append("Exception thrown :" + e);
|
outputText.append("Exception thrown :" + e);
|
||||||
return;
|
return;
|
||||||
@@ -174,7 +187,7 @@ outputText.append(":\t" + eq.getArg(1).text() + " = " + eq.getArg(2).text() +"\n
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onQueryButtonClick(View view)
|
public void onFirstButtonClick(View view)
|
||||||
{
|
{
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
Log.i(TAG, "onQueryButtonClick called");
|
Log.i(TAG, "onQueryButtonClick called");
|
||||||
@@ -184,33 +197,32 @@ outputText.append(":\t" + eq.getArg(1).text() + " = " + eq.getArg(2).text() +"\n
|
|||||||
public void run() {
|
public void run() {
|
||||||
scroller.fullScroll(ScrollView.FOCUS_DOWN);
|
scroller.fullScroll(ScrollView.FOCUS_DOWN);
|
||||||
str = text.getText().toString();
|
str = text.getText().toString();
|
||||||
outputText.append("?- " + str);
|
//outputText.append("?- " + str+"\n\n");
|
||||||
Log.i(TAG, "onQueryButtonClick "+str + "\n");
|
Log.i(TAG, "onQueryAnyButtonClick "+str + "\n");
|
||||||
runQuery(str);
|
runQuery(str, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onQuerySelectionButtonClick(View view)
|
public void onAllButtonClick(View view)
|
||||||
{
|
{
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
Log.i(TAG, "onQuerySelectionButtonClick called");
|
Log.i(TAG, "onQueryButtonClick called");
|
||||||
}
|
}
|
||||||
// Ensure scroll to end of text
|
// Ensure scroll to end of text
|
||||||
scroller.post(new Runnable() {
|
scroller.post(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
scroller.fullScroll(ScrollView.FOCUS_DOWN);
|
scroller.fullScroll(ScrollView.FOCUS_DOWN);
|
||||||
int startSelection = text.getSelectionStart();
|
str = text.getText().toString();
|
||||||
int endSelection = text.getSelectionEnd();
|
outputText.append("?- " + str+"\n\n");
|
||||||
str = text.getText().toString().substring( startSelection, endSelection );
|
Log.i(TAG, "onAllButtonClick "+str + "\n");
|
||||||
Log.i(TAG, "onQuerySelectionButtonClick "+str);
|
runQuery(str, true);
|
||||||
outputText.append("?- " + str + "\n");
|
|
||||||
runQuery(str);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** static constructor */
|
/** static constructor */
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("android");
|
System.loadLibrary("android");
|
||||||
|
@@ -9,12 +9,16 @@
|
|||||||
android:lines="6" />
|
android:lines="6" />
|
||||||
<LinearLayout android:orientation="vertical"
|
<LinearLayout android:orientation="vertical"
|
||||||
android:layout_width="wrap_content" android:layout_height="fill_parent">
|
android:layout_width="wrap_content" android:layout_height="fill_parent">
|
||||||
<Button android:id="@+id/QueryButton" android:layout_width="fill_parent"
|
<Button android:id="@+id/FirstButton"
|
||||||
android:layout_height="wrap_content" android:text="Query..."
|
android:layout_width="fill_parent"
|
||||||
android:onClick="onQueryButtonClick" />
|
android:layout_height="wrap_content"
|
||||||
<Button android:id="@+id/QuerySelectionButton"
|
android:text="First..."
|
||||||
android:layout_width="fill_parent" android:layout_height="wrap_content"
|
android:onClick="onFirstButtonClick" />
|
||||||
android:text="Select" android:onClick="onQuerySelectionButtonClick" />
|
<Button android:id="@+id/AllButton"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="All..."
|
||||||
|
android:onClick="onAllButtonClick" />
|
||||||
<Button android:id="@+id/ClearButton" android:layout_width="fill_parent"
|
<Button android:id="@+id/ClearButton" android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content" android:text="Reset"
|
android:layout_height="wrap_content" android:text="Reset"
|
||||||
android:onClick="onClearButtonClick" />
|
android:onClick="onClearButtonClick" />
|
||||||
@@ -27,5 +31,3 @@
|
|||||||
<!-- Set MaxLegth EditText -->
|
<!-- Set MaxLegth EditText -->
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
@@ -124,9 +124,8 @@ absolute_file_name(File,Opts,TrueFileName) :-
|
|||||||
/**
|
/**
|
||||||
@pred absolute_file_name(+Name:atom,+Path:atom) is nondet
|
@pred absolute_file_name(+Name:atom,+Path:atom) is nondet
|
||||||
|
|
||||||
11 Converts the given file specification into an absolute path, using default options. See absolute_file_name/3 for details on the options.
|
Converts the given file specification into an absolute path, using default options. See absolute_file_name/3 for details on the options.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
absolute_file_name(V,Out) :- var(V), !, % absolute_file_name needs commenting.
|
absolute_file_name(V,Out) :- var(V), !, % absolute_file_name needs commenting.
|
||||||
'$do_error'(instantiation_error, absolute_file_name(V, Out)).
|
'$do_error'(instantiation_error, absolute_file_name(V, Out)).
|
||||||
absolute_file_name(user,user) :- !.
|
absolute_file_name(user,user) :- !.
|
||||||
@@ -499,7 +498,7 @@ remove_from_path(New) :- '$check_path'(New,Path),
|
|||||||
`library( _File_ )` are searched by the predicates consult/1,
|
`library( _File_ )` are searched by the predicates consult/1,
|
||||||
reconsult/1, use_module/1, ensure_loaded/1, and load_files/2.
|
reconsult/1, use_module/1, ensure_loaded/1, and load_files/2.
|
||||||
|
|
||||||
This directory is initialized s a rule that calls the system predicate
|
This directory is initialized by a rule that calls the system predicate
|
||||||
system_library/1.
|
system_library/1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -661,3 +660,5 @@ user:file_search_path(path, C) :-
|
|||||||
),
|
),
|
||||||
lists:member(C, B)
|
lists:member(C, B)
|
||||||
).
|
).
|
||||||
|
|
||||||
|
%%@}
|
Reference in New Issue
Block a user