Merge branch 'master' of ssh://ssh.dcc.fc.up.pt:31064/home/vsc/yap
This commit is contained in:
commit
f0a6018a00
@ -2106,45 +2106,42 @@ X_API void YAP_ClearExceptions(void) {
|
|||||||
|
|
||||||
X_API int YAP_InitConsult(int mode, const char *fname, char **full,
|
X_API int YAP_InitConsult(int mode, const char *fname, char **full,
|
||||||
int *osnop) {
|
int *osnop) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
int sno;
|
int sno;
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
const char *fl = NULL;
|
const char *fl = NULL;
|
||||||
int lvl = push_text_stack();
|
if (mode == YAP_BOOT_MODE) {
|
||||||
if (mode == YAP_BOOT_MODE) {
|
mode = YAP_CONSULT_MODE;
|
||||||
mode = YAP_CONSULT_MODE;
|
|
||||||
}
|
|
||||||
if (fname == NULL || fname[0] == '\0') {
|
|
||||||
fl = Yap_BOOTFILE;
|
|
||||||
}
|
|
||||||
if (fname) {
|
|
||||||
fl = Yap_AbsoluteFile(fname, true);
|
|
||||||
if (!fl || !fl[0]) {
|
|
||||||
pop_text_stack(lvl);
|
|
||||||
*full = NULL;
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
*full = pop_output_text_stack(lvl, fl);
|
|
||||||
}
|
}
|
||||||
} else {
|
if (fname == NULL || fname[0] == '\0') {
|
||||||
pop_text_stack(lvl);
|
fl = Yap_BOOTFILE;
|
||||||
|
}
|
||||||
|
if (!fname || !(fl = Yap_AbsoluteFile(fname, true)) || !fl[0]) {
|
||||||
|
__android_log_print(
|
||||||
|
ANDROID_LOG_INFO, "YAPDroid", "failed ABSOLUTEFN %s ", fl);
|
||||||
|
*full = NULL;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
__android_log_print(
|
||||||
|
ANDROID_LOG_INFO, "YAPDroid", "done init_ consult %s ",fl);
|
||||||
|
|
||||||
lvl = push_text_stack();
|
int lvl = push_text_stack();
|
||||||
char *d = Malloc(strlen(fl) + 1);
|
char *d = Malloc(strlen(fl) + 1);
|
||||||
strcpy(d, fl);
|
strcpy(d, fl);
|
||||||
bool consulted = (mode == YAP_CONSULT_MODE);
|
bool consulted = (mode == YAP_CONSULT_MODE);
|
||||||
Term tat = MkAtomTerm(Yap_LookupAtom(d));
|
Term tat = MkAtomTerm(Yap_LookupAtom(d));
|
||||||
sno = Yap_OpenStream(tat, "r", MkAtomTerm(Yap_LookupAtom(fname)),
|
sno = Yap_OpenStream(tat, "r", MkAtomTerm(Yap_LookupAtom(fname)),
|
||||||
LOCAL_encoding);
|
LOCAL_encoding);
|
||||||
if (sno < 0 || !Yap_ChDir(dirname((char *)d))) {
|
__android_log_print(
|
||||||
|
ANDROID_LOG_INFO, "YAPDroid", "OpenStream got %d ",sno);
|
||||||
pop_text_stack(lvl);
|
pop_text_stack(lvl);
|
||||||
|
if (sno < 0 || !Yap_ChDir(dirname((char *)d))) {
|
||||||
*full = NULL;
|
*full = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
LOCAL_PrologMode = UserMode;
|
LOCAL_PrologMode = UserMode;
|
||||||
|
*full = pop_output_text_stack__(lvl, fl);
|
||||||
Yap_init_consult(consulted, pop_output_text_stack__(lvl, fl));
|
Yap_init_consult(consulted,*full);
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||||
return sno;
|
return sno;
|
||||||
|
264
C/yap-args.c
264
C/yap-args.c
@ -153,22 +153,25 @@ const char *Yap_BINDIR, *Yap_ROOTDIR, *Yap_SHAREDIR, *Yap_LIBDIR, *Yap_DLLDIR,
|
|||||||
* recursive consulting.
|
* recursive consulting.
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
static bool consult(const char *b_file USES_REGS) {
|
static bool load_file(const char *b_file USES_REGS) {
|
||||||
Term t;
|
Term t;
|
||||||
int c_stream, osno, oactive;
|
int c_stream, osno, oactive;
|
||||||
Functor functor_query = Yap_MkFunctor(Yap_LookupAtom("?-"), 1);
|
|
||||||
|
Functor functor_query = Yap_MkFunctor(Yap_LookupAtom("?-"), 1);
|
||||||
Functor functor_command1 = Yap_MkFunctor(Yap_LookupAtom(":-"), 1);
|
Functor functor_command1 = Yap_MkFunctor(Yap_LookupAtom(":-"), 1);
|
||||||
Functor functor_compile2 = Yap_MkFunctor(Yap_LookupAtom("c_compile"), 1);
|
Functor functor_compile2 = Yap_MkFunctor(Yap_LookupAtom("c_compile"), 1);
|
||||||
|
|
||||||
/* consult in C */
|
/* consult in C */
|
||||||
int lvl = push_text_stack();
|
int lvl = push_text_stack();
|
||||||
char *full;
|
char *full;
|
||||||
/* the consult mode does not matter here, really */
|
/* the consult mode does not matter here, really */
|
||||||
if ((osno = Yap_CheckAlias(AtomLoopStream)) < 0) {
|
if ((osno = Yap_CheckAlias(AtomLoopStream)) < 0) {
|
||||||
osno = 0;
|
osno = 0;
|
||||||
}
|
}
|
||||||
c_stream = YAP_InitConsult(YAP_BOOT_MODE, b_file, &full, &oactive);
|
c_stream = YAP_InitConsult(YAP_BOOT_MODE, b_file, &full, &oactive);
|
||||||
if (c_stream < 0) {
|
__android_log_print(
|
||||||
|
ANDROID_LOG_INFO, "YAPDroid", "done init_ consult %s ",b_file);
|
||||||
|
if (c_stream < 0) {
|
||||||
fprintf(stderr, "[ FATAL ERROR: could not open file %s ]\n", b_file);
|
fprintf(stderr, "[ FATAL ERROR: could not open file %s ]\n", b_file);
|
||||||
pop_text_stack(lvl);
|
pop_text_stack(lvl);
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -177,6 +180,8 @@ static bool consult(const char *b_file USES_REGS) {
|
|||||||
pop_text_stack(lvl);
|
pop_text_stack(lvl);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
__android_log_print(
|
||||||
|
ANDROID_LOG_INFO, "YAPDroid", "do reset %s ",b_file);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
@ -197,7 +202,7 @@ static bool consult(const char *b_file USES_REGS) {
|
|||||||
FunctorOfTerm(t) == functor_command1)) {
|
FunctorOfTerm(t) == functor_command1)) {
|
||||||
t = ArgOfTerm(1, t);
|
t = ArgOfTerm(1, t);
|
||||||
if (IsApplTerm(t) && FunctorOfTerm(t) == functor_compile2) {
|
if (IsApplTerm(t) && FunctorOfTerm(t) == functor_compile2) {
|
||||||
consult(RepAtom(AtomOfTerm(ArgOfTerm(1, t)))->StrOfAE);
|
load_file(RepAtom(AtomOfTerm(ArgOfTerm(1, t)))->StrOfAE);
|
||||||
Yap_ResetException(LOCAL_ActiveError);
|
Yap_ResetException(LOCAL_ActiveError);
|
||||||
} else {
|
} else {
|
||||||
YAP_RunGoalOnce(t);
|
YAP_RunGoalOnce(t);
|
||||||
@ -206,7 +211,7 @@ static bool consult(const char *b_file USES_REGS) {
|
|||||||
YAP_CompileClause(t);
|
YAP_CompileClause(t);
|
||||||
}
|
}
|
||||||
yap_error_descriptor_t *errd;
|
yap_error_descriptor_t *errd;
|
||||||
if ((errd = Yap_GetException(LOCAL_ActiveError))) {
|
if ((errd = Yap_GetException(LOCAL_ActiveError)) && (errd->errorNo != YAP_NO_ERROR)) {
|
||||||
fprintf(stderr, "%s:%ld:0: Error %s %s Found\n", errd->errorFile,
|
fprintf(stderr, "%s:%ld:0: Error %s %s Found\n", errd->errorFile,
|
||||||
(long int)errd->errorLine, errd->classAsText, errd->errorAsText);
|
(long int)errd->errorLine, errd->classAsText, errd->errorAsText);
|
||||||
}
|
}
|
||||||
@ -221,16 +226,82 @@ static bool consult(const char *b_file USES_REGS) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char * EOLIST ="EOLINE";
|
||||||
|
|
||||||
|
|
||||||
|
static bool is_dir( const char *path, const void *info) {
|
||||||
|
|
||||||
|
if (Yap_isDirectory( path ))
|
||||||
|
return true;
|
||||||
|
char s[YAP_FILENAME_MAX + 1];
|
||||||
|
Int i = strlen(path);
|
||||||
|
strncpy(s, path, YAP_FILENAME_MAX);
|
||||||
|
while (--i) {
|
||||||
|
if (Yap_dir_separator((int)path[i]))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i == 0) {
|
||||||
|
s[0] = '.';
|
||||||
|
i = 1;
|
||||||
|
}
|
||||||
|
s[i] = '\0';
|
||||||
|
return
|
||||||
|
strcmp(info,s) == 0 ||
|
||||||
|
Yap_isDirectory( s );
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool is_file( const char *path, const void *info) {
|
||||||
|
|
||||||
|
return Yap_Exists( path );
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool is_wfile( const char *path, const void *info) {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef bool testf(const char *s, const void *info);
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
static const char *sel(bool dir, bool ok1, const char *s1, bool ok2,
|
static const char *sel(
|
||||||
const char *s2, ...) {
|
testf test, const void *info, const char *s1, ...) {
|
||||||
if (ok1 && s1)
|
const char *fmt = s1;
|
||||||
return s1;
|
va_list ap;
|
||||||
if (ok2)
|
char *buf = malloc(FILENAME_MAX + 1);
|
||||||
return s2;
|
__android_log_print(
|
||||||
return NULL;
|
ANDROID_LOG_INFO, "YAPDroid", "try %s", s1);
|
||||||
}
|
|
||||||
|
va_start(ap, s1);
|
||||||
|
while (fmt != EOLIST) {
|
||||||
|
__android_log_print( ANDROID_LOG_INFO, "YAPDroid", "loop %s", fmt);
|
||||||
|
|
||||||
|
if (fmt == NULL || fmt[0]=='\0') {
|
||||||
|
fmt = va_arg(ap, const char *);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
strncpy(buf, fmt, FILENAME_MAX); // Yap_AbsoluteFile(fmt,true), FILENAME_MAX);
|
||||||
|
__android_log_print( ANDROID_LOG_INFO, "YAPDroid", "triyimh %s", buf);
|
||||||
|
if (test(buf,info)) {
|
||||||
|
__android_log_print(
|
||||||
|
ANDROID_LOG_INFO, "YAPDroid", "got %s", buf);
|
||||||
|
buf = realloc(buf, strlen(buf) + 1);
|
||||||
|
va_end(ap);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
__android_log_print(
|
||||||
|
ANDROID_LOG_INFO, "YAPDroid", "tried %s, failed", buf);
|
||||||
|
fmt = va_arg(ap, const char *);
|
||||||
|
}
|
||||||
|
|
||||||
|
__android_log_print(
|
||||||
|
ANDROID_LOG_INFO, "YAPDroid", "failed search ");
|
||||||
|
va_end(ap);
|
||||||
|
free(buf);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *join(const char *s0, const char *s1) {
|
static const char *join(const char *s0, const char *s1) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
@ -256,103 +327,130 @@ static void Yap_set_locations(YAP_init_args *iap) {
|
|||||||
// --_not useful in Android, WIN32;
|
// --_not useful in Android, WIN32;
|
||||||
/// -- DESTDIR/ in Anaconda
|
/// -- DESTDIR/ in Anaconda
|
||||||
/// -- /usr/locall in most Unix style systems
|
/// -- /usr/locall in most Unix style systems
|
||||||
Yap_ROOTDIR = sel(true, iap->ROOTDIR != NULL, iap->ROOTDIR, true,
|
Yap_ROOTDIR = sel( is_dir, NULL,
|
||||||
|
iap->ROOTDIR,
|
||||||
|
getenv("YAPROOTDIR"),
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
NULL,
|
"/",
|
||||||
#else
|
#else
|
||||||
join(getenv("DESTDIR"), YAP_ROOTDIR),
|
join(getenv("DESTDIR"), YAP_ROOTDIR),
|
||||||
|
join(getenv("DESTDIR"), join(getenv("ḦOME"),".local")),
|
||||||
|
join(getenv("DESTDIR"), "/usr/local"),
|
||||||
|
join(getenv("DESTDIR"), "/usr"),
|
||||||
|
join(getenv("DESTDIR"), "/opt"),
|
||||||
#endif
|
#endif
|
||||||
false);
|
EOLIST
|
||||||
/// BINDIR: where the OS stores header files, namely libYap...
|
);
|
||||||
Yap_BINDIR = sel(true, iap->BINDIR != NULL, iap->BINDIR, true,
|
|
||||||
#if __ANDROID__
|
/// BINDIR: where the OS stores header files, namely libYap...
|
||||||
NULL,
|
Yap_BINDIR = sel( is_dir, Yap_ROOTDIR, iap->BINDIR,
|
||||||
#else
|
getenv("YAPBINDIR"),
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
join(getenv("DESTDIR"), YAP_BINDIR),
|
join(getenv("DESTDIR"), YAP_BINDIR),
|
||||||
#endif
|
#endif
|
||||||
false);
|
join(Yap_ROOTDIR, "/bin"),
|
||||||
|
EOLIST);
|
||||||
|
|
||||||
/// LIBDIR: where the OS stores dynamic libraries, namely libYap...
|
/// LIBDIR: where the OS stores dynamic libraries, namely libYap...
|
||||||
Yap_LIBDIR = sel(true, iap->LIBDIR != NULL, iap->LIBDIR, true,
|
Yap_LIBDIR = sel( is_dir, Yap_ROOTDIR, iap->LIBDIR,
|
||||||
#if __ANDROID__
|
#if !defined(__ANDROID__)
|
||||||
NULL,
|
|
||||||
#else
|
|
||||||
join(getenv("DESTDIR"), YAP_LIBDIR),
|
join(getenv("DESTDIR"), YAP_LIBDIR),
|
||||||
#endif
|
#endif
|
||||||
false);
|
join(Yap_ROOTDIR, "/lib"),
|
||||||
|
EOLIST);
|
||||||
|
|
||||||
/// DLLDIR: where libraries can find expicitely loaded DLLs
|
/// DLLDIR: where libraries can find expicitely loaded DLLs
|
||||||
Yap_DLLDIR = sel(true, iap->DLLDIR != NULL, iap->DLLDIR, true,
|
Yap_DLLDIR = sel(is_dir, Yap_LIBDIR, iap->DLLDIR,
|
||||||
#if __ANDROID__
|
getenv("YAPLIBDIR"),
|
||||||
NULL,
|
#if !defined(__ANDROID__)
|
||||||
#else
|
join(getenv("DESTDIR"), YAP_DLLDIR),
|
||||||
join(getenv("DESTDIR"), YAP_DLLDIR),
|
join(Yap_LIBDIR, "/yap"),
|
||||||
#endif
|
#endif
|
||||||
false);
|
EOLIST);
|
||||||
|
|
||||||
/// INCLUDEDIR: where the OS stores header files, namely libYap...
|
/// INCLUDEDIR: where the OS stores header files, namely libYap...
|
||||||
Yap_INCLUDEDIR = sel(true, iap->INCLUDEDIR != NULL, iap->INCLUDEDIR, true,
|
Yap_INCLUDEDIR = sel(is_dir, Yap_ROOTDIR, iap->INCLUDEDIR,
|
||||||
#if __ANDROID__
|
#if !defined(__ANDROID__)
|
||||||
NULL,
|
join(getenv("DESTDIR"), YAP_INCLUDEDIR),
|
||||||
#else
|
|
||||||
join(getenv("DESTDIR"), YAP_INCLUDEDIR),
|
|
||||||
#endif
|
#endif
|
||||||
false);
|
join(Yap_ROOTDIR, "/include"),
|
||||||
|
EOLIST);
|
||||||
|
|
||||||
/// SHAREDIR: where OS & ARCH independent files live
|
/// SHAREDIR: where OS & ARCH independent files live
|
||||||
Yap_SHAREDIR = sel(true, iap->SHAREDIR != NULL, iap->SHAREDIR, true,
|
Yap_SHAREDIR = sel( is_dir, Yap_ROOTDIR, iap->SHAREDIR,
|
||||||
#if __ANDROID__
|
getenv("YAPSHAREDIR"),
|
||||||
"/assets",
|
#if !defined(__ANDROID__)
|
||||||
#else
|
join(getenv("DESTDIR"), YAP_SHAREDIR),
|
||||||
join(getenv("DESTDIR"), YAP_SHAREDIR),
|
join(Yap_ROOTDIR, "/share"),
|
||||||
|
"/assets",
|
||||||
#endif
|
#endif
|
||||||
false);
|
join(Yap_ROOTDIR, "/files"),
|
||||||
|
EOLIST);
|
||||||
/// PLDIR: where we can find Prolog files
|
/// PLDIR: where we can find Prolog files
|
||||||
Yap_PLDIR = sel(true, iap->PLDIR != NULL, iap->PLDIR, true,
|
Yap_PLDIR = sel( is_dir, Yap_SHAREDIR, iap->PLDIR,
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
|
YAP_PLDIR,
|
||||||
"/assets/Yap",
|
"/assets/Yap",
|
||||||
#else
|
#else
|
||||||
join(getenv("DESTDIR"), YAP_PLDIR),
|
join(getenv("DESTDIR"), YAP_PLDIR),
|
||||||
|
join(Yap_SHAREDIR, "/Yap"),
|
||||||
#endif
|
#endif
|
||||||
false);
|
EOLIST);
|
||||||
/// ``COMMONSDIR: Prolog Commons
|
/// ``COMMONSDIR: Prolog Commons
|
||||||
Yap_COMMONSDIR = sel(true, iap->COMMONSDIR != NULL, iap->COMMONSDIR, true,
|
Yap_COMMONSDIR = sel(is_dir, Yap_SHAREDIR, iap->COMMONSDIR,
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
"/assets/PrologCommons",
|
"/assets/PrologCommons",
|
||||||
#else
|
#else
|
||||||
join(getenv("DESTDIR"), YAP_SHAREDIR "/PrologCommons"),
|
join(getenv("DESTDIR"), YAP_SHAREDIR "/PrologCommons"),
|
||||||
|
join(Yap_SHAREDIR, "PrologCommons"),
|
||||||
#endif
|
#endif
|
||||||
false);
|
EOLIST);
|
||||||
/// BOOTPLDIR: where we can find Prolog bootstrap files
|
/// BOOTPLDIR: where we can find Prolog bootstrap files
|
||||||
Yap_BOOTSTRAP = sel(true, iap->BOOTSTRAP != NULL, iap->BOOTSTRAP, true,
|
Yap_BOOTSTRAP = sel( is_file, NULL, iap->BOOTSTRAP,
|
||||||
#if __ANDROID__
|
YAP_BOOTSTRAP,
|
||||||
"/assets/Yap/pl/boot.yap",
|
EOLIST);
|
||||||
#else
|
|
||||||
join(getenv("DESTDIR"), YAP_BOOTSTRAP),
|
|
||||||
#endif
|
|
||||||
false);
|
|
||||||
/// BOOTFILE: where we can find the core Prolog boot file
|
/// BOOTFILE: where we can find the core Prolog boot file
|
||||||
Yap_BOOTFILE = sel(false, iap->BOOTFILE != NULL, iap->BOOTFILE, true,
|
|
||||||
|
const char * Yap_PLBOOTDIR = sel( is_dir, Yap_PLDIR,
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
"/assets/Yap/pl/boot.yap",
|
"/assets/Yap/pl",
|
||||||
#else
|
#else
|
||||||
join(getenv("DESTDIR"), YAP_BOOTFILE),
|
join(Yap_PLDIR, "/pl"),
|
||||||
#endif
|
#endif
|
||||||
false);
|
EOLIST);
|
||||||
|
|
||||||
|
Yap_BOOTFILE = sel( is_wfile, Yap_PLBOOTDIR, iap->BOOTFILE,
|
||||||
|
#if __ANDROID__
|
||||||
|
"/assets/Yap/pl/boot.yap",
|
||||||
|
#else
|
||||||
|
join(Yap_PLBOOTDIR, "/boot.yap"),
|
||||||
|
#endif
|
||||||
|
EOLIST);
|
||||||
/// STARTUP: where we can find the core Prolog bootstrap file
|
/// STARTUP: where we can find the core Prolog bootstrap file
|
||||||
Yap_OUTPUT_STARTUP =
|
Yap_OUTPUT_STARTUP =
|
||||||
sel(false, iap->OUTPUT_STARTUP != NULL, iap->OUTPUT_STARTUP, true,
|
sel( is_wfile, Yap_AbsoluteFile(".",false), iap->OUTPUT_STARTUP,
|
||||||
#if __ANDROID__
|
#if defined(__ANDROID__)
|
||||||
NULL,
|
EOLIST,
|
||||||
#else
|
#else
|
||||||
join(getenv("DESTDIR"), YAP_OUTPUT_STARTUP),
|
YAP_OUTPUT_STARTUP,
|
||||||
#endif
|
#endif
|
||||||
false);
|
"startup.yss",
|
||||||
|
EOLIST);
|
||||||
|
|
||||||
Yap_INPUT_STARTUP =
|
Yap_INPUT_STARTUP =
|
||||||
sel(false, iap->INPUT_STARTUP != NULL, iap->INPUT_STARTUP, true,
|
sel( is_file, Yap_DLLDIR, iap->INPUT_STARTUP,
|
||||||
|
"startup.yss",
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
NULL,
|
EOLIST,
|
||||||
#else
|
#else
|
||||||
join(getenv("DESTDIR"), YAP_INPUT_STARTUP),
|
join(getenv("DESTDIR"), YAP_INPUT_STARTUP),
|
||||||
#endif
|
#endif
|
||||||
false);
|
join(Yap_DLLDIR, "/startup.yss"),
|
||||||
if (Yap_ROOTDIR)
|
"/usr/local/lib/Yap/startup.yss",
|
||||||
|
"/usr/lib/Yap/startup.yss",
|
||||||
|
EOLIST);
|
||||||
|
|
||||||
|
if (Yap_ROOTDIR)
|
||||||
setAtomicGlobalPrologFlag(HOME_FLAG,
|
setAtomicGlobalPrologFlag(HOME_FLAG,
|
||||||
MkAtomTerm(Yap_LookupAtom(Yap_ROOTDIR)));
|
MkAtomTerm(Yap_LookupAtom(Yap_ROOTDIR)));
|
||||||
if (Yap_PLDIR)
|
if (Yap_PLDIR)
|
||||||
@ -461,17 +559,18 @@ X_API YAP_file_type_t Yap_InitDefaults(void *x, char *saved_state, int argc,
|
|||||||
LOCAL_TextBuffer = Yap_InitTextAllocator();
|
LOCAL_TextBuffer = Yap_InitTextAllocator();
|
||||||
YAP_init_args *iap = x;
|
YAP_init_args *iap = x;
|
||||||
memset(iap, 0, sizeof(YAP_init_args));
|
memset(iap, 0, sizeof(YAP_init_args));
|
||||||
|
iap->Argc = argc;
|
||||||
|
iap->Argv = argv;
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
iap->boot_file_type = YAP_BOOT_PL;
|
iap->boot_file_type = YAP_BOOT_PL;
|
||||||
iap->INPUT_STARTUP = NULL;
|
iap->INPUT_STARTUP = NULL;
|
||||||
iap->assetManager = NULL;
|
iap->assetManager = NULL;
|
||||||
|
return YAP_BOOT_PL;
|
||||||
#else
|
#else
|
||||||
iap->boot_file_type = YAP_QLY;
|
iap->boot_file_type = YAP_QLY;
|
||||||
iap->INPUT_STARTUP = saved_state;
|
iap->INPUT_STARTUP = saved_state;
|
||||||
#endif
|
|
||||||
iap->Argc = argc;
|
|
||||||
iap->Argv = argv;
|
|
||||||
return YAP_QLY;
|
return YAP_QLY;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1006,7 +1105,8 @@ X_API void YAP_Init(YAP_init_args *yap_init) {
|
|||||||
bool try_restore = yap_init->boot_file_type == YAP_QLY;
|
bool try_restore = yap_init->boot_file_type == YAP_QLY;
|
||||||
bool do_bootstrap = yap_init->boot_file_type == YAP_BOOT_PL;
|
bool do_bootstrap = yap_init->boot_file_type == YAP_BOOT_PL;
|
||||||
struct ssz_t minfo;
|
struct ssz_t minfo;
|
||||||
|
__android_log_print(
|
||||||
|
ANDROID_LOG_INFO, "YAPDroid", "start init ");
|
||||||
if (YAP_initialized)
|
if (YAP_initialized)
|
||||||
/* ignore repeated calls to YAP_Init */
|
/* ignore repeated calls to YAP_Init */
|
||||||
return;
|
return;
|
||||||
@ -1039,16 +1139,20 @@ X_API void YAP_Init(YAP_init_args *yap_init) {
|
|||||||
Yap_ExecutionMode = yap_init->ExecutionMode;
|
Yap_ExecutionMode = yap_init->ExecutionMode;
|
||||||
Yap_set_locations(yap_init);
|
Yap_set_locations(yap_init);
|
||||||
|
|
||||||
if (do_bootstrap || !try_restore ||
|
if (Yap_INPUT_STARTUP==NULL)
|
||||||
|
try_restore = false;
|
||||||
|
if (do_bootstrap || !try_restore ||
|
||||||
!Yap_SavedInfo(Yap_INPUT_STARTUP, &minfo.Trail, &minfo.Stack,
|
!Yap_SavedInfo(Yap_INPUT_STARTUP, &minfo.Trail, &minfo.Stack,
|
||||||
&minfo.Heap)) {
|
&minfo.Heap)) {
|
||||||
init_globals(yap_init);
|
init_globals(yap_init);
|
||||||
|
|
||||||
start_modules();
|
start_modules();
|
||||||
CurrentModule = PROLOG_MODULE;
|
CurrentModule = PROLOG_MODULE;
|
||||||
TermEof = MkAtomTerm(Yap_LookupAtom("end_of_file"));
|
TermEof = MkAtomTerm(Yap_LookupAtom("end_of_file"));
|
||||||
LOCAL_consult_level = -1;
|
LOCAL_consult_level = -1;
|
||||||
consult(Yap_BOOTSTRAP PASS_REGS);
|
__android_log_print(
|
||||||
|
ANDROID_LOG_INFO, "YAPDroid", "init %s ", Yap_BOOTSTRAP);
|
||||||
|
load_file(Yap_BOOTSTRAP PASS_REGS);
|
||||||
setAtomicGlobalPrologFlag(RESOURCE_DATABASE_FLAG,
|
setAtomicGlobalPrologFlag(RESOURCE_DATABASE_FLAG,
|
||||||
MkAtomTerm(Yap_LookupAtom(Yap_BOOTFILE)));
|
MkAtomTerm(Yap_LookupAtom(Yap_BOOTFILE)));
|
||||||
setBooleanGlobalPrologFlag(SAVED_PROGRAM_FLAG, false);
|
setBooleanGlobalPrologFlag(SAVED_PROGRAM_FLAG, false);
|
||||||
@ -1056,6 +1160,8 @@ X_API void YAP_Init(YAP_init_args *yap_init) {
|
|||||||
if (yap_init->QuietMode) {
|
if (yap_init->QuietMode) {
|
||||||
setVerbosity(TermSilent);
|
setVerbosity(TermSilent);
|
||||||
}
|
}
|
||||||
|
__android_log_print(
|
||||||
|
ANDROID_LOG_INFO, "YAPDroid", "restore %s ",Yap_INPUT_STARTUP );
|
||||||
Yap_Restore(Yap_INPUT_STARTUP);
|
Yap_Restore(Yap_INPUT_STARTUP);
|
||||||
init_globals(yap_init);
|
init_globals(yap_init);
|
||||||
|
|
||||||
|
@ -320,6 +320,7 @@ set(YAP_ROOTDIR ${prefix})
|
|||||||
# libdir defined above
|
# libdir defined above
|
||||||
set(YAP_DATADIR ${CMAKE_INSTALL_FULL_DATADIR})
|
set(YAP_DATADIR ${CMAKE_INSTALL_FULL_DATADIR})
|
||||||
set(YAP_INCLUDEDIR ${CMAKE_INSTALL_FULL_INCLUDEDIR}/Yap)
|
set(YAP_INCLUDEDIR ${CMAKE_INSTALL_FULL_INCLUDEDIR}/Yap)
|
||||||
|
set(YAP_BINDIR ${CMAKE_INSTALL_FULL_BINDIR})
|
||||||
set(YAP_LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR})
|
set(YAP_LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR})
|
||||||
set(YAP_DLLDIR ${CMAKE_INSTALL_FULL_LIBDIR}/Yap)
|
set(YAP_DLLDIR ${CMAKE_INSTALL_FULL_LIBDIR}/Yap)
|
||||||
set(YAP_PLDIR ${CMAKE_INSTALL_FULL_DATADIR}/Yap)
|
set(YAP_PLDIR ${CMAKE_INSTALL_FULL_DATADIR}/Yap)
|
||||||
@ -532,8 +533,16 @@ include_directories(utf8proc packages/myddas packages/myddas/sqlite3/src )
|
|||||||
set_property(SOURCE ${LIBYAP_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1)
|
set_property(SOURCE ${LIBYAP_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1)
|
||||||
|
|
||||||
|
|
||||||
|
IF (WITH_SWIG)
|
||||||
|
find_host_package(SWIG)
|
||||||
|
# macro_log_feature (SWIG_FOUND "Swig"
|
||||||
|
# "Use SWIG Interface Generator "
|
||||||
|
# "http://www.swig.org" ON)
|
||||||
|
ENDIF (WITH_SWIG)
|
||||||
|
|
||||||
IF (WITH_MYDDAS)
|
IF (WITH_MYDDAS)
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
|
include_directories (packages/swig/android)
|
||||||
else()
|
else()
|
||||||
|
|
||||||
add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1)
|
add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1)
|
||||||
@ -553,14 +562,6 @@ IF (WITH_MYDDAS)
|
|||||||
endif(WITH_MYDDAS)
|
endif(WITH_MYDDAS)
|
||||||
|
|
||||||
|
|
||||||
IF (WITH_SWIG)
|
|
||||||
find_host_package(SWIG)
|
|
||||||
# macro_log_feature (SWIG_FOUND "Swig"
|
|
||||||
# "Use SWIG Interface Generator "
|
|
||||||
# "http://www.swig.org" ON)
|
|
||||||
ENDIF (WITH_SWIG)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
IF (WITH_PYTHON)
|
IF (WITH_PYTHON)
|
||||||
include(python )
|
include(python )
|
||||||
|
@ -270,6 +270,8 @@ public:
|
|||||||
inline void setArgv(char **fl) { Argv = fl; };
|
inline void setArgv(char **fl) { Argv = fl; };
|
||||||
|
|
||||||
inline char **getArgv() { return Argv; };
|
inline char **getArgv() { return Argv; };
|
||||||
|
|
||||||
|
inline void setROOTDIR(char *fl) { ROOTDIR = fl; };
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -293,7 +295,14 @@ public:
|
|||||||
YAPEngine(YAPEngineArgs *cargs) {
|
YAPEngine(YAPEngineArgs *cargs) {
|
||||||
engine_args = cargs;
|
engine_args = cargs;
|
||||||
// doInit(cargs->boot_file_type);
|
// doInit(cargs->boot_file_type);
|
||||||
|
__android_log_print(
|
||||||
|
ANDROID_LOG_INFO, "YAPDroid", "start engine ");
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
doInit(YAP_BOOT_PL, cargs);
|
||||||
|
|
||||||
|
#else
|
||||||
doInit(YAP_QLY, cargs);
|
doInit(YAP_QLY, cargs);
|
||||||
|
#endif
|
||||||
}; /// construct a new engine, including aaccess to callbacks
|
}; /// construct a new engine, including aaccess to callbacks
|
||||||
/// construct a new engine using argc/argv list of arguments
|
/// construct a new engine using argc/argv list of arguments
|
||||||
YAPEngine(int argc, char *argv[],
|
YAPEngine(int argc, char *argv[],
|
||||||
|
@ -2030,7 +2030,7 @@ significant byte first (like Motorola and SPARC, unlike Intel). */
|
|||||||
|
|
||||||
/* name of Commons library */
|
/* name of Commons library */
|
||||||
#ifndef YAP_COMMONSDIR
|
#ifndef YAP_COMMONSDIR
|
||||||
#define YAP COMMONSDIR "${YAP_DATADIR}/PrologCommmons"
|
#define YAP_COMMONSDIR "${YAP_DATADIR}/PrologCommmons"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
19
library/android.yap
Normal file
19
library/android.yap
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
%:- start_low_level_trace.
|
||||||
|
|
||||||
|
:- module(user).
|
||||||
|
:- yap_flag(verbose,normal).
|
||||||
|
|
||||||
|
query( String ) :-
|
||||||
|
yap_flag(typein_module, Mod),
|
||||||
|
atomic_to_term( String, Goal, VarNames ),
|
||||||
|
query_to_answer( Mod:Goal, VarNames, Status, Bindings),
|
||||||
|
output( Bindings, Status) .
|
||||||
|
|
||||||
|
output( Bindings, Status) :-
|
||||||
|
(Status == answer -> true ;
|
||||||
|
Status == exit ->true
|
||||||
|
),
|
||||||
|
write_query_answer( Bindings ),
|
||||||
|
nl(user_error).
|
||||||
|
|
||||||
|
%:- [sqlitest].
|
10
os/assets.c
10
os/assets.c
@ -77,18 +77,20 @@ open_asset(VFS_t *me, const char *fname, const char *io_mode, int sno) {
|
|||||||
// AAssetDir *dp = AAssetManager_openDir( Yap_assetManager(), dirname(dir) );
|
// AAssetDir *dp = AAssetManager_openDir( Yap_assetManager(), dirname(dir) );
|
||||||
// strcpy(dir, fname);
|
// strcpy(dir, fname);
|
||||||
// char *d = basename(dir);
|
// char *d = basename(dir);
|
||||||
am = AAssetManager_open(Yap_assetManager(), fname, mode);
|
am = AAssetManager_open(Yap_assetManager(), fname, io_mode);
|
||||||
//if (am==NULL)
|
//if (am==NULL)
|
||||||
// __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "failed open %s <%s>", fname, strerror(errno) );
|
// __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "failed open %s <%s>", fname, strerror(errno) );
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "open %s <%s>", fname, io_mode);
|
||||||
// while (dp) {
|
// while (dp) {
|
||||||
// char *f = AAssetDir_getNextFileName(dp);
|
// char *f = AAssetDir_getNextFileName(dp);
|
||||||
// __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "open %s <%s>", f, d);
|
// __android_log_print(ANDROID_LOG_INFO, "YAPDroid", "open %s <%s>", fname, mode);
|
||||||
// if (f && strcasecmp(d,f) == 0) {
|
// if (f && strcasecmp(d,f) == 0) {
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
if (!am) {
|
if (!am) {
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "failed %s <%s>", fname, io_mode);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
// try not to use it as an asset
|
// try not to use it as an asset
|
||||||
@ -111,7 +113,7 @@ open_asset(VFS_t *me, const char *fname, const char *io_mode, int sno) {
|
|||||||
st->vfs = NULL;
|
st->vfs = NULL;
|
||||||
st->vfs_handle = NULL;
|
st->vfs_handle = NULL;
|
||||||
st->status = Seekable_Stream_f|Input_Stream_f;
|
st->status = Seekable_Stream_f|Input_Stream_f;
|
||||||
return st;
|
return st->file;
|
||||||
} else {
|
} else {
|
||||||
// should be done, but if not
|
// should be done, but if not
|
||||||
GLOBAL_Stream[sno].vfs_handle = am;
|
GLOBAL_Stream[sno].vfs_handle = am;
|
||||||
|
134
os/iopreds.c
134
os/iopreds.c
@ -1135,7 +1135,7 @@ bool Yap_initStream(int sno, FILE *fd, Atom name, const char *io_mode,
|
|||||||
ANDROID_LOG_INFO, "YAPDroid", "init %s %s:%s stream <%d>", io_mode,
|
ANDROID_LOG_INFO, "YAPDroid", "init %s %s:%s stream <%d>", io_mode,
|
||||||
CurrentModule == 0 ? "prolog"
|
CurrentModule == 0 ? "prolog"
|
||||||
: RepAtom(AtomOfTerm(CurrentModule))->StrOfAE,
|
: RepAtom(AtomOfTerm(CurrentModule))->StrOfAE,
|
||||||
name, sno);
|
RepAtom(name)->StrOfAE, sno);
|
||||||
if (io_mode == NULL)
|
if (io_mode == NULL)
|
||||||
Yap_Error(PERMISSION_ERROR_NEW_ALIAS_FOR_STREAM, MkIntegerTerm(sno),
|
Yap_Error(PERMISSION_ERROR_NEW_ALIAS_FOR_STREAM, MkIntegerTerm(sno),
|
||||||
"File opened with NULL Permissions");
|
"File opened with NULL Permissions");
|
||||||
@ -1242,74 +1242,80 @@ static bool fill_stream(int sno, StreamDesc *st, Term tin, const char *io_mode,
|
|||||||
|
|
||||||
st->file = NULL;
|
st->file = NULL;
|
||||||
if (fname) {
|
if (fname) {
|
||||||
if ((vfsp = vfs_owner(fname)) != NULL &&
|
if ((vfsp = vfs_owner(fname)) != NULL) {
|
||||||
vfsp->open(vfsp, fname, io_mode, sno)) {
|
if (vfsp->open(vfsp, fname, io_mode, sno)) {
|
||||||
// read, write, append
|
// read, write, append
|
||||||
user_name = st->user_name;
|
user_name = st->user_name;
|
||||||
st->vfs = vfsp;
|
st->vfs = vfsp;
|
||||||
UNLOCK(st->streamlock);
|
UNLOCK(st->streamlock);
|
||||||
} else {
|
__android_log_print(
|
||||||
st->file = fopen(fname, io_mode);
|
ANDROID_LOG_INFO, "YAPDroid", "got %d ", sno);
|
||||||
if (st->file == NULL) {
|
} else {
|
||||||
UNLOCK(st->streamlock);
|
UNLOCK(st->streamlock);
|
||||||
if (errno == ENOENT && !strchr(io_mode, 'r')) {
|
__android_log_print(
|
||||||
PlIOError(EXISTENCE_ERROR_SOURCE_SINK, tin, "%s: %s", fname,
|
ANDROID_LOG_INFO, "YAPDroid", "failed %s ",fname);
|
||||||
strerror(errno));
|
return false;
|
||||||
} else {
|
}
|
||||||
PlIOError(PERMISSION_ERROR_OPEN_SOURCE_SINK, tin, "%s: %s", fname,
|
} else {
|
||||||
strerror(errno));
|
st->file = fopen(fname, io_mode);
|
||||||
}
|
if (st->file == NULL) {
|
||||||
}
|
__android_log_print(
|
||||||
st->vfs = NULL;
|
ANDROID_LOG_INFO, "YAPDroid", "failed %s ",fname);
|
||||||
}
|
UNLOCK(st->streamlock);
|
||||||
if (!st->file && !st->vfs) {
|
if (errno == ENOENT && !strchr(io_mode, 'r')) {
|
||||||
PlIOError(EXISTENCE_ERROR_SOURCE_SINK, tin, "%s", fname);
|
PlIOError(EXISTENCE_ERROR_SOURCE_SINK, tin, "%s: %s", fname,
|
||||||
/* extract BACK info passed through the stream descriptor */
|
strerror(errno));
|
||||||
return false;
|
} else {
|
||||||
}
|
PlIOError(PERMISSION_ERROR_OPEN_SOURCE_SINK, tin, "%s: %s", fname,
|
||||||
} else if (IsApplTerm(tin)) {
|
strerror(errno));
|
||||||
Functor f = FunctorOfTerm(tin);
|
}
|
||||||
if (f == FunctorAtom || f == FunctorString || f == FunctorCodes1 ||
|
return false;
|
||||||
f == FunctorCodes || f == FunctorChars1 || f == FunctorChars) {
|
}
|
||||||
if (strchr(io_mode, 'r')) {
|
|
||||||
return Yap_OpenBufWriteStream(PASS_REGS1);
|
|
||||||
} else {
|
|
||||||
int j = push_text_stack();
|
|
||||||
const char *buf;
|
|
||||||
|
|
||||||
buf = Yap_TextTermToText(tin PASS_REGS);
|
|
||||||
if (!buf) {
|
|
||||||
pop_text_stack(j);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
buf = pop_output_text_stack(j, buf);
|
|
||||||
Atom nat = Yap_LookupAtom(Yap_StrPrefix(buf, 32));
|
|
||||||
sno = Yap_open_buf_read_stream(buf, strlen(buf) + 1, &LOCAL_encoding,
|
|
||||||
MEM_BUF_MALLOC, nat,
|
|
||||||
MkAtomTerm(NameOfFunctor(f)));
|
|
||||||
pop_text_stack(j);
|
|
||||||
return Yap_OpenBufWriteStream(PASS_REGS1);
|
|
||||||
}
|
|
||||||
} else if (!strcmp(RepAtom(NameOfFunctor(f))->StrOfAE, "popen")) {
|
|
||||||
const char *buf;
|
|
||||||
int i = push_text_stack();
|
|
||||||
buf = Yap_TextTermToText(ArgOfTerm(1, tin) PASS_REGS);
|
|
||||||
if (buf == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
} else if (IsApplTerm(tin)) {
|
||||||
|
Functor f = FunctorOfTerm(tin);
|
||||||
|
if (f == FunctorAtom || f == FunctorString || f == FunctorCodes1 ||
|
||||||
|
f == FunctorCodes || f == FunctorChars1 || f == FunctorChars) {
|
||||||
|
if (strchr(io_mode, 'r')) {
|
||||||
|
return Yap_OpenBufWriteStream(PASS_REGS1);
|
||||||
|
} else {
|
||||||
|
int j = push_text_stack();
|
||||||
|
const char *buf;
|
||||||
|
|
||||||
|
buf = Yap_TextTermToText(tin PASS_REGS);
|
||||||
|
if (!buf) {
|
||||||
|
pop_text_stack(j);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
buf = pop_output_text_stack(j, buf);
|
||||||
|
Atom nat = Yap_LookupAtom(Yap_StrPrefix(buf, 32));
|
||||||
|
sno = Yap_open_buf_read_stream(buf, strlen(buf) + 1, &LOCAL_encoding,
|
||||||
|
MEM_BUF_MALLOC, nat,
|
||||||
|
MkAtomTerm(NameOfFunctor(f)));
|
||||||
|
pop_text_stack(j);
|
||||||
|
return Yap_OpenBufWriteStream(PASS_REGS1);
|
||||||
|
}
|
||||||
|
} else if (!strcmp(RepAtom(NameOfFunctor(f))->StrOfAE, "popen")) {
|
||||||
|
const char *buf;
|
||||||
|
int i = push_text_stack();
|
||||||
|
buf = Yap_TextTermToText(ArgOfTerm(1, tin) PASS_REGS);
|
||||||
|
if (buf == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
st->file = _popen(buf, io_mode);
|
st->file = _popen(buf, io_mode);
|
||||||
#else
|
#else
|
||||||
st->file = popen(buf, io_mode);
|
st->file = popen(buf, io_mode);
|
||||||
#endif
|
#endif
|
||||||
fname = "popen";
|
fname = "popen";
|
||||||
user_name = tin;
|
user_name = tin;
|
||||||
st->status |= Popen_Stream_f;
|
st->status |= Popen_Stream_f;
|
||||||
pop_text_stack(i);
|
pop_text_stack(i);
|
||||||
} else {
|
} else {
|
||||||
Yap_ThrowError(DOMAIN_ERROR_SOURCE_SINK, tin, "open");
|
Yap_ThrowError(DOMAIN_ERROR_SOURCE_SINK, tin, "open");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!strchr(io_mode, 'b') && binary_file(fname)) {
|
if (!strchr(io_mode, 'b') && binary_file(fname)) {
|
||||||
st->status |= Binary_Stream_f;
|
st->status |= Binary_Stream_f;
|
||||||
}
|
}
|
||||||
|
@ -376,10 +376,10 @@ static Term syntax_error(TokEntry *errtok, int sno, Term cmod, Int newpos, bool
|
|||||||
TokEntry *tok = LOCAL_tokptr;
|
TokEntry *tok = LOCAL_tokptr;
|
||||||
Int start_line = tok->TokLine;
|
Int start_line = tok->TokLine;
|
||||||
Int err_line = errtok->TokLine;
|
Int err_line = errtok->TokLine;
|
||||||
Int end_line = GetCurInpLine(GLOBAL_Stream + sno);
|
Int startpos = tok->TokPos;
|
||||||
Int startpos = tok->TokPos;
|
|
||||||
Int errpos = errtok->TokPos;
|
Int errpos = errtok->TokPos;
|
||||||
Int endpos = GetCurInpPos(GLOBAL_Stream + sno);
|
Int end_line = GetCurInpLine(GLOBAL_Stream + sno);
|
||||||
|
Int endpos = GetCurInpPos(GLOBAL_Stream + sno);
|
||||||
|
|
||||||
Yap_local.ActiveError->errorNo = SYNTAX_ERROR;
|
Yap_local.ActiveError->errorNo = SYNTAX_ERROR;
|
||||||
Yap_local.ActiveError->parserFirstLine = start_line;
|
Yap_local.ActiveError->parserFirstLine = start_line;
|
||||||
|
@ -355,7 +355,7 @@ bool Yap_ChDir(const char *path) {
|
|||||||
int lvl = push_text_stack();
|
int lvl = push_text_stack();
|
||||||
|
|
||||||
const char *qpath = Yap_AbsoluteFile(path, true);
|
const char *qpath = Yap_AbsoluteFile(path, true);
|
||||||
//__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "chdir %s", path);
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "chdir %s", path);
|
||||||
VFS_t *v;
|
VFS_t *v;
|
||||||
if ((v = vfs_owner(qpath))) {
|
if ((v = vfs_owner(qpath))) {
|
||||||
rc = v->chdir(v, (qpath));
|
rc = v->chdir(v, (qpath));
|
||||||
|
@ -53,7 +53,6 @@ SET_PROPERTY(SOURCE ${MYDDAS_SOURCES}
|
|||||||
${MYDDAS_UTIL_SOURCES}
|
${MYDDAS_UTIL_SOURCES}
|
||||||
${MYDDAS_HEADERS} PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 )
|
${MYDDAS_HEADERS} PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 )
|
||||||
|
|
||||||
MY_add_dependencies(myddas plmyddas)
|
|
||||||
add_subdirectory(pl)
|
add_subdirectory(pl)
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,74 +9,36 @@ set(MYDDAS_YPP
|
|||||||
myddas_prolog2sql_optimizer.ypp)
|
myddas_prolog2sql_optimizer.ypp)
|
||||||
|
|
||||||
set(MYDDAS_DRIVERS
|
set(MYDDAS_DRIVERS
|
||||||
"myddas_driver.ypp"
|
myddas_driver.ypp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if (ANDROID)
|
|
||||||
set (MYDDAS_PREFIX ${YAP_INSTALL_DATADIR} )
|
|
||||||
else()
|
|
||||||
set (MYDDAS_PREFIX ${CMAKE_CURRENT_BINARY_DIR} )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
get_property(MYDDAS_FLAGS GLOBAL PROPERTY COMPILE_DEFINITIONS)
|
|
||||||
|
|
||||||
function(cpp_compile output filename)
|
|
||||||
get_filename_component(base ${filename} NAME_WE)
|
|
||||||
set(base_abs ${MYDDAS_PREFIX}/${base})
|
|
||||||
set(outfile ${base_abs}.yap)
|
|
||||||
set(${output} ${${output}} ${outfile} PARENT_SCOPE)
|
|
||||||
IF (MSVC)
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${outfile}
|
|
||||||
COMMAND ${CMAKE_C_COMPILER} ${MYDDAS_FLAGS} /EP /P ${outfile} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
|
|
||||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${filename}")
|
|
||||||
ELSE (MSVC)
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${outfile}
|
|
||||||
COMMAND ${CMAKE_C_COMPILER} ${MYDDAS_FLAGS} -x c -E -P -w ${CMAKE_CURRENT_SOURCE_DIR}/${filename} -o ${outfile}
|
|
||||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${filename}")
|
|
||||||
ENDIF (MSVC)
|
|
||||||
set_source_files_properties(${outfile} PROPERTIES GENERATED TRUE)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
if (ANDROID)
|
|
||||||
set (MYDDAS_PL_OUTDIR ${YAP_APP_DIR}/src/generated/assets/Yap )
|
|
||||||
else()
|
|
||||||
set (MYDDAS_PL_OUTDIR ${CMAKE_CURRENT_BINARY_DIR} )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
function(cpp_driver output dbms filename)
|
|
||||||
set(outfile ${MYDDAS_PL_OUTDIR}/myddas_${dbms}.yap)
|
|
||||||
set(${output} ${${output}} ${outfile} PARENT_SCOPE)
|
|
||||||
IF (MSVC)
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${outfile}
|
|
||||||
COMMAND ${CMAKE_C_COMPILER} -D${dbms} /EP /P ${outfile} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
|
|
||||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${filename}")
|
|
||||||
else ()
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${outfile}
|
|
||||||
COMMAND ${CMAKE_C_COMPILER} -D${dbms} -x c -E -P -w ${CMAKE_CURRENT_SOURCE_DIR}/${filename} -o ${outfile}
|
|
||||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${filename}")
|
|
||||||
ENDIF (MSVC)
|
|
||||||
set_source_files_properties(${outfile} PROPERTIES GENERATED TRUE)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
set(MYDDAS_DBMS sqlite3 postgres odbc)
|
set(MYDDAS_DBMS sqlite3 postgres odbc)
|
||||||
|
|
||||||
foreach (file ${MYDDAS_YPP})
|
if (ANDROID)
|
||||||
cpp_compile(MYDDAS_YAP ${file})
|
set (MYDDAS_PL_OUTDIR ${YAP_APP_DIR}/src/generated/assets/Yap )
|
||||||
endforeach ()
|
else()
|
||||||
foreach (driver ${MYDDAS_DBMS})
|
set (MYDDAS_PL_OUTDIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
cpp_driver(MYDDAS_YAP ${driver} myddas_driver.ypp)
|
endif()
|
||||||
endforeach ()
|
get_property(MYDDAS_FLAGS GLOBAL PROPERTY COMPILE_DEFINITIONS)
|
||||||
|
foreach (filename ${MYDDAS_YPP})
|
||||||
|
get_filename_component(base ${filename} NAME_WE)
|
||||||
|
set(base_abs ${MYDDAS_PL_OUTDIR}/${base})
|
||||||
|
set(outfile ${base_abs}.yap)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_C_COMPILER} ${MYDDAS_FLAGS} -x c -E -P -w ${CMAKE_CURRENT_SOURCE_DIR}/${filename} -o ${outfile}
|
||||||
|
)
|
||||||
|
set_source_files_properties(outfile PROPERTIES GENERATED TRUE)
|
||||||
|
endforeach ()
|
||||||
|
foreach (dbms ${MYDDAS_DBMS} )
|
||||||
|
set(outfile ${MYDDAS_PL_OUTDIR}/myddas_${dbms}.yap)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_C_COMPILER} -D${dbms} -x c -E -P -w ${CMAKE_CURRENT_SOURCE_DIR}/myddas_driver.ypp -o ${outfile}
|
||||||
|
)
|
||||||
|
|
||||||
list (APPEND MYDDAS_YAP ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/sqlitest.yap ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/chinook.db)
|
set_source_files_properties(outfile PROPERTIES GENERATED TRUE)
|
||||||
add_to_group(MYDDAS_YAP pl_library )
|
|
||||||
|
|
||||||
add_custom_target(plmyddas ALL DEPENDS ${MYDDAS_YAP} )
|
endforeach()
|
||||||
|
|
||||||
install(FILES ${MYDDAS_YAP}
|
set( MYDDAS_YAP ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/sqlitest.yap ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/chinook.db)
|
||||||
DESTINATION ${YAP_INSTALL_DATADIR}
|
add_to_group(MYDDAS_YAP pl_library )
|
||||||
)
|
file(INSTALL ${MYDDAS_YAP}
|
||||||
|
DESTINATION ${MYDDAS_PL_OUTDIR} )
|
||||||
|
@ -73,8 +73,9 @@ python_query( Caller, String ) :-
|
|||||||
query_to_answer( Goal, VarNames, Status, Bindings),
|
query_to_answer( Goal, VarNames, Status, Bindings),
|
||||||
Caller.port := Status,
|
Caller.port := Status,
|
||||||
write_query_answer( Bindings ),
|
write_query_answer( Bindings ),
|
||||||
nl(user_error),
|
nl(user_error),
|
||||||
maplist(in_dict(Caller.answer, Bindings), Bindings).
|
maplist(in_dict(Caller.answer, Bindings), Bindings).
|
||||||
|
>>>>>>> 37d5dcedc17b8c63cd9fa213454edb37816a130f
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -78,16 +78,20 @@ class Query (YAPQuery):
|
|||||||
super().__init__(g)
|
super().__init__(g)
|
||||||
self.engine = engine
|
self.engine = engine
|
||||||
self.port = "call"
|
self.port = "call"
|
||||||
self.bindings = None
|
|
||||||
self.answer = {}
|
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
def done(self):
|
||||||
|
return self.port == "fail" or self.port == "exit"
|
||||||
|
|
||||||
def __next__(self):
|
def __next__(self):
|
||||||
if self.port == "fail":
|
self.answer = {}
|
||||||
raise IndexError()
|
if self.port == "fail" or self.port == "exit":
|
||||||
return self.next()
|
raise StopIteration()
|
||||||
|
if self.next():
|
||||||
|
return self.answer
|
||||||
|
raise StopIteration()
|
||||||
|
|
||||||
def name( name, arity):
|
def name( name, arity):
|
||||||
try:
|
try:
|
||||||
@ -141,7 +145,7 @@ class YAPShell:
|
|||||||
# # vs is the list of variables
|
# # vs is the list of variables
|
||||||
# you can print it out, the left-side is the variable name,
|
# you can print it out, the left-side is the variable name,
|
||||||
# the right side wraps a handle to a variable
|
# the right side wraps a handle to a variable
|
||||||
import pdb; pdb.set_trace()
|
# import pdb; pdb.set_trace()
|
||||||
# #pdb.set_trace()
|
# #pdb.set_trace()
|
||||||
# atom match either symbols, or if no symbol exists, sttrings, In this case
|
# atom match either symbols, or if no symbol exists, sttrings, In this case
|
||||||
# variable names should match strings
|
# variable names should match strings
|
||||||
@ -151,14 +155,13 @@ class YAPShell:
|
|||||||
# return
|
# return
|
||||||
try:
|
try:
|
||||||
engine = self.engine
|
engine = self.engine
|
||||||
bindings = []
|
bindings = []
|
||||||
loop = False
|
loop = False
|
||||||
g = python_query(self, query)
|
q = Query( engine, python_query( engine, query) )
|
||||||
self.q = Query( engine, g )
|
for answer in q:
|
||||||
while self.q.next():
|
bindings += [answer]
|
||||||
bindings += [self.q.answer]
|
if g.done():
|
||||||
if self.q.port == "exit":
|
return bindings
|
||||||
break
|
|
||||||
if loop:
|
if loop:
|
||||||
continue
|
continue
|
||||||
s = input("more(;), all(*), no(\\n), python(#)? ").lstrip()
|
s = input("more(;), all(*), no(\\n), python(#)? ").lstrip()
|
||||||
@ -177,10 +180,8 @@ class YAPShell:
|
|||||||
if self.q:
|
if self.q:
|
||||||
self.q.close()
|
self.q.close()
|
||||||
self.q = None
|
self.q = None
|
||||||
if bindings:
|
|
||||||
return True,bindings
|
|
||||||
print("No (more) answers")
|
print("No (more) answers")
|
||||||
return False, None
|
return bindings
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if not self.q:
|
if not self.q:
|
||||||
return False, None
|
return False, None
|
||||||
|
@ -42,7 +42,7 @@ jupyter_cell(Caller, _, Line ) :-
|
|||||||
catch(
|
catch(
|
||||||
python_query(Query,Line),
|
python_query(Query,Line),
|
||||||
error(A,B),
|
error(A,B),
|
||||||
system_error(A,B)
|
(writeln(A,B),system_error(A,B))
|
||||||
).
|
).
|
||||||
|
|
||||||
restreams(call) :-
|
restreams(call) :-
|
||||||
|
@ -550,7 +550,7 @@ class YAPRun(InteractiveShell):
|
|||||||
self.yapeng.mgoal(errors(self,text),"user",True)
|
self.yapeng.mgoal(errors(self,text),"user",True)
|
||||||
return self.errors
|
return self.errors
|
||||||
|
|
||||||
def jupyter_query(self, s):
|
def prolog(self, s):
|
||||||
#
|
#
|
||||||
# construct a self.queryuery from a one-line string
|
# construct a self.queryuery from a one-line string
|
||||||
# self.query is opaque to Python
|
# self.query is opaque to Python
|
||||||
@ -590,7 +590,7 @@ class YAPRun(InteractiveShell):
|
|||||||
if found:
|
if found:
|
||||||
sys.stderr.write('Completed, with '+str(self.answers)+'\n')
|
sys.stderr.write('Completed, with '+str(self.answers)+'\n')
|
||||||
result.result = self.answers
|
result.result = self.answers
|
||||||
return result
|
return result.results
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sys.stderr.write('Exception '+str(e)+'in query '+ str(self.query)+
|
sys.stderr.write('Exception '+str(e)+'in query '+ str(self.query)+
|
||||||
@ -736,7 +736,7 @@ class YAPRun(InteractiveShell):
|
|||||||
# run the new command using the given tracer
|
# run the new command using the given tracer
|
||||||
#
|
#
|
||||||
# tracer.runfunc(f,self,cell,state)
|
# tracer.runfunc(f,self,cell,state)
|
||||||
self.jupyter_query( cell )
|
self.prolog( cell )
|
||||||
# state = tracer.runfunc(jupyter_query( self, cell ) )
|
# state = tracer.runfunc(jupyter_query( self, cell ) )
|
||||||
self.shell.last_execution_succeeded = True
|
self.shell.last_execution_succeeded = True
|
||||||
result.result = []
|
result.result = []
|
||||||
@ -814,12 +814,15 @@ class YAPRun(InteractiveShell):
|
|||||||
If the line terminates on a `*/` or starts on a `%` we assume the line
|
If the line terminates on a `*/` or starts on a `%` we assume the line
|
||||||
is a comment.
|
is a comment.
|
||||||
"""
|
"""
|
||||||
s0 = s.rstrip(' \n\t\i')
|
try:
|
||||||
[program,x,query] = s0.rpartition('\n')
|
s0 = s.rstrip(' \n\t\i')
|
||||||
if query[-1] == '.':
|
[program,x,query] = s0.rpartition('\n')
|
||||||
return s,'',False,0
|
if query[-1] == '.':
|
||||||
(query, _,loop, sols) = self.clean_end(query)
|
return s,'',False,0
|
||||||
return (program, query, loop, sols)
|
(query, _,loop, sols) = self.clean_end(query)
|
||||||
|
return (program, query, loop, sols)
|
||||||
|
except:
|
||||||
|
return (s,'',true,1)
|
||||||
|
|
||||||
# global
|
# global
|
||||||
#globals = {}
|
#globals = {}
|
||||||
|
@ -1,84 +1,68 @@
|
|||||||
|
|
||||||
# This is a CMake file for SWIG and Android
|
# This is a CMake file for SWIG and Android
|
||||||
|
|
||||||
set (SWIG_CXX_DIR ${YAP_APP_DIR}/src/generated/jni)
|
set(JAVA_SWIG_OUTDIR ${CMAKE_SOURCE_DIR}/../yaplib/src/generated/java/pt/up/yap/lib)
|
||||||
FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/java/pt/up/yap/lib )
|
set(SWIG_CXX_DIR ${CMAKE_BINARY_DIR}/src/generated/jni)
|
||||||
FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/assets)
|
FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/src/generated/java/pt/up/yap/lib)
|
||||||
FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/jni)
|
FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/src/generated/assets/Yap/pl)
|
||||||
set ( pllib ${YAP_APP_DIR}/src/generated/assets/Yap )
|
FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/src/generated/assets/so)
|
||||||
|
FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/src/generated/jni)
|
||||||
|
set(YAP_ASSETS ${CMAKE_SOURCE_DIR}/../yaplib/src/generated/assets/Yap)
|
||||||
|
|
||||||
set ( SWIG_SOURCES ${CMAKE_SOURCE_DIR}/packages/swig/yap.i )
|
set(SWIG_SOURCES ${CMAKE_SOURCE_DIR}/packages/swig/yap.i)
|
||||||
SET_SOURCE_FILES_PROPERTIES(${SWIG_SOURCES} PROPERTIES CPLUSPLUS ON)
|
SET_SOURCE_FILES_PROPERTIES(${SWIG_SOURCES} PROPERTIES CPLUSPLUS ON)
|
||||||
|
|
||||||
include_directories (
|
include_directories(
|
||||||
${CMAKE_SOURCE_DIR}/CXX
|
${CMAKE_SOURCE_DIR}/CXX
|
||||||
)
|
)
|
||||||
set( GMP_ROOT ${CMAKE_SOURCE_DIR}/../gmp/${ANDROID_ABI} )
|
set(GMP_ROOT ${CMAKE_SOURCE_DIR}/../gmp/${ANDROID_ABI})
|
||||||
set (GMP_INCLUDE_DIRS ${GMP_ROOT})
|
set(GMP_INCLUDE_DIRS ${GMP_ROOT})
|
||||||
set (GMP_LIBRARIES ${GMP_ROOT}/libgmp.so)
|
set(GMP_LIBRARIES ${GMP_ROOT}/libgmp.so)
|
||||||
|
|
||||||
#
|
|
||||||
# add_custom_target (pllib
|
|
||||||
# COMMAND ${CMAKE_COMMAND} -E make_directory ${YAP_INSTALL_DATADIR}
|
|
||||||
# COMMAND ${CMAKE_COMMAND} -E copy ${pl_library} ${YAP_INSTALL_DATADIR}
|
|
||||||
# COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/android.yap ${YAP_INSTALL_DATADIR}
|
|
||||||
# DEPENDS ${pl_library}
|
|
||||||
#)
|
|
||||||
#
|
|
||||||
# add_custom_target (pllibpl
|
|
||||||
# COMMAND ${CMAKE_COMMAND} -E make_directory ${YAP_INSTALL_DATADIR}/pl
|
|
||||||
# COMMAND ${CMAKE_COMMAND} -E copy ${pl_boot_library} ${YAP_INSTALL_DATADIR}/pl
|
|
||||||
#DEPENDS pllib ${pl_boot_library}
|
|
||||||
# )
|
|
||||||
# add_custom_target (pllibos ALL
|
|
||||||
# COMMAND ${CMAKE_COMMAND} -E make_directory ${YAP_INSTALL_DATADIR}/os
|
|
||||||
# COMMAND ${CMAKE_COMMAND} -E copy ${pl_os_library} ${YAP_INSTALL_DATADIR}/os
|
|
||||||
#DEPENDS pllibpl ${pl_os_library}
|
|
||||||
# )
|
|
||||||
#
|
|
||||||
# add_custom_command (OUTPUT ${CMAKE_SWIG_OUTPUT}/swig_streamer.cpp
|
|
||||||
# COMMAND ${SWIG_EXECUTABLE} -c++ -java -package ${SWIG_MODULE_NAME} -O -outdir ${CMAKE_SWIG_OUTDIR} -addextern -I${CMAKE_CURRENT_SOURCE_DIR} -o ${CMAKE_SWIG_OUTPUT}/swig_streamer.cpp -oh ${CMAKE_SWIG_OUTPUT}/swig_streamer.hh streamer.i
|
|
||||||
# DEPENDS streamer.i
|
|
||||||
# )
|
|
||||||
#
|
|
||||||
# add_custom_command (OUTPUT ${CMAKE_SWIG_OUTPUT}/yap_swig.cpp
|
|
||||||
# COMMAND ${SWIG_EXECUTABLE} -c++ -java -package ${SWIG_MODULE_NAME} -O -outdir ${CMAKE_SWIG_OUTDIR} -addextern -I${CMAKE_SOURCE_DIR}/CXX -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/H -I${CMAKE_SOURCE_DIR}/os -I${CMAKE_SOURCE_DIR}/OPTYap -I${CMAKE_BINARY_DIR} -I${GMP_INCLUDE_DIRS} -DX_API="" -o ${CMAKE_SWIG_OUTPUT}/yap_swig.cpp -oh ${CMAKE_SWIG_OUTPUT}/yap_swig.hh ${SWIG_SOURCES}
|
|
||||||
# DEPENDS pllibos ${SWIG_SOURCES} YAP++)
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
add_library(YAPJava OBJECT
|
file(INSTALL ${pl_library} DESTINATION ${YAP_ASSETS})
|
||||||
${SWIG_CXX_DIR}/streamer_swig.cxx
|
file(INSTALL ${CMAKE_CURRENT_SOURCE_DIR}/android.yap DESTINATION ${YAP_ASSETS})
|
||||||
${SWIG_CXX_DIR}/yapi_swig.cxx
|
|
||||||
streamer.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set_target_properties(YAPJava PROPERTIES LINKER_LANGUAGE CXX)
|
file(INSTALL ${pl_boot_library} DESTINATION ${YAP_ASSETS}/pl)
|
||||||
|
file(INSTALL ${pl_os_library} DESTINATION ${YAP_ASSETS}/os)
|
||||||
|
|
||||||
|
|
||||||
|
execute_process(COMMAND swig -c++ -java -package pt.up.yap.lib -O -outdir ${JAVA_SWIG_OUTDIR} -addextern -I${CMAKE_SOURCE_DIR}/CXX -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/H -I${CMAKE_SOURCE_DIR}/os -I${CMAKE_SOURCE_DIR}/OPTYap -I${CMAKE_BINARY_DIR} -I${GMP_INCLUDE_DIRS} -DX_API -o ${SWIG_CXX_DIR}/yapi_swig.cxx ${SWIG_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
|
execute_process(COMMAND ${SWIG_EXECUTABLE} -c++ -java -package pt.up.yap.lib -O -outdir ${JAVA_SWIG_OUTDIR} -addextern -I${CMAKE_CURRENT_SOURCE_DIR} -o ${SWIG_CXX_DIR}/streamer_swig.cxx streamer.i
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
add_library(YAPJava OBJECT
|
||||||
|
${CMAKE_BINARY_DIR}/src/generated/jni/streamer_swig.cxx
|
||||||
|
${CMAKE_BINARY_DIR}/src/generated/jni/yapi_swig.cxx
|
||||||
|
streamer.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(YAPJava PROPERTIES LINKER_LANGUAGE CXX)
|
||||||
|
|
||||||
# GMP_FOUND - true if GMP/MPIR was found
|
# GMP_FOUND - true if GMP/MPIR was found
|
||||||
# GMP_INCLUDE_DIRS - include search path
|
# GMP_INCLUDE_DIRS - include search path
|
||||||
# GMP_LIBRARIES - libraries to link with
|
# GMP_LIBRARIES - libraries to link with
|
||||||
#config.h needs this (TODO: change in code latter)
|
#config.h needs this (TODO: change in code latter)
|
||||||
include_directories( .;${GMP_INCLUDE_DIRS};${CMAKE_SOURCE_DIR}/include;${CMAKE_SOURCE_DIR}/H;${CMAKE_SOURCE_DIR}/H/generated;${CMAKE_SOURCE_DIR}/os;${CMAKE_SOURCE_DIR}/OPTYap;${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR} )
|
include_directories(.;${GMP_INCLUDE_DIRS};${CMAKE_SOURCE_DIR}/include;${CMAKE_SOURCE_DIR}/H;${CMAKE_SOURCE_DIR}/H/generated;${CMAKE_SOURCE_DIR}/os;${CMAKE_SOURCE_DIR}/OPTYap;${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (FALSE)
|
if (FALSE)
|
||||||
|
|
||||||
set (SWIG_ADD_MODULE YAPJava SHARED CPLUSPLUS ${SWIG_SOURCES} )
|
set(SWIG_ADD_MODULE YAPJava SHARED CPLUSPLUS ${SWIG_SOURCES})
|
||||||
# Define swig module with given name and specified language
|
# Define swig module with given name and specified language
|
||||||
|
|
||||||
|
|
||||||
set (SWIG_LINK_LIBRARIES YAPJava YAP++ libYAP )
|
set(SWIG_LINK_LIBRARIES YAPJava YAP++ libYAP)
|
||||||
#- Link libraries to swig module
|
#- Link libraries to swig module
|
||||||
|
|
||||||
|
|
||||||
add_library (YAPJavaTop SHARED
|
add_library(YAPJavaTop SHARED
|
||||||
main.cpp main.h
|
main.cpp main.h
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries( YAPJavaTop ${SWIG_MODULE_${YAPJava}_REAL_NAME} YAP++ libYap android)
|
target_link_libraries(YAPJavaTop ${SWIG_MODULE_${YAPJava}_REAL_NAME} YAP++ libYap android)
|
||||||
|
|
||||||
endif()
|
endif ()
|
||||||
|
@ -165,7 +165,7 @@ prolog:copy_term(Term, Copy, Gs) :-
|
|||||||
-> Gs = [],
|
-> Gs = [],
|
||||||
copy_term(Term, Copy)
|
copy_term(Term, Copy)
|
||||||
; findall(Term-Gs,
|
; findall(Term-Gs,
|
||||||
'$attributes':residuals_and_delete_attributes(Vs, Gs, Term),
|
attributes:residuals_and_delete_attributes(Vs, Gs, Term),
|
||||||
[Copy-Gs])
|
[Copy-Gs])
|
||||||
).
|
).
|
||||||
|
|
||||||
|
@ -476,9 +476,7 @@ If this hook preodicate succeeds it must instantiate the _Action_ argument to t
|
|||||||
|
|
||||||
:- ensure_loaded('../pl/pathconf.yap').
|
:- ensure_loaded('../pl/pathconf.yap').
|
||||||
|
|
||||||
:- current_prolog_fkag(android,true), ensure_loaded('../pl/android.yap').
|
:- current_prolog_flag(android,true), ensure_loaded('../android.yap').
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:- set_prolog_flag(unknown,error).
|
:- set_prolog_flag(unknown,error).
|
||||||
|
|
||||||
|
@ -494,6 +494,7 @@ write_query_answer( Bindings ) :-
|
|||||||
'$write_goal_output'(G1, First, NG, Next, IG),
|
'$write_goal_output'(G1, First, NG, Next, IG),
|
||||||
'$write_vars_and_goals'(LG, Next, IG).
|
'$write_vars_and_goals'(LG, Next, IG).
|
||||||
|
|
||||||
|
|
||||||
'$write_goal_output'(var([V|VL]), First, [var([V|VL])|L], next, L) :- !,
|
'$write_goal_output'(var([V|VL]), First, [var([V|VL])|L], next, L) :- !,
|
||||||
( First = first -> true ; format(user_error,',~n',[]) ),
|
( First = first -> true ; format(user_error,',~n',[]) ),
|
||||||
format(user_error,'~a',[V]),
|
format(user_error,'~a',[V]),
|
||||||
@ -513,13 +514,12 @@ write_query_answer( Bindings ) :-
|
|||||||
G = [_|_], !,
|
G = [_|_], !,
|
||||||
% dump on string first so that we can check whether we actually
|
% dump on string first so that we can check whether we actually
|
||||||
% had any output from the solver.
|
% had any output from the solver.
|
||||||
term_to_string( G, String),
|
format(string(String),Format,G),
|
||||||
( String == `` ->
|
( String == `` ->
|
||||||
% we didn't
|
% we didn't
|
||||||
IG = NG, First = Next
|
IG = NG, First = Next
|
||||||
;
|
;
|
||||||
% we did
|
% we did
|
||||||
( First = first -> true ; format(user_error,',~n',[]) ),
|
|
||||||
format(user_error, '~N~s', [String]),
|
format(user_error, '~N~s', [String]),
|
||||||
NG = [G|IG]
|
NG = [G|IG]
|
||||||
).
|
).
|
||||||
|
@ -102,29 +102,41 @@ undefined_query(G0, M0, Cut) :-
|
|||||||
'$undefp_search'(M0:G0, MG) :-
|
'$undefp_search'(M0:G0, MG) :-
|
||||||
'$pred_exists'(unknown_predicate_handler(_,_,_,_), user),
|
'$pred_exists'(unknown_predicate_handler(_,_,_,_), user),
|
||||||
'$yap_strip_module'(M0:G0, EM0, GM0),
|
'$yap_strip_module'(M0:G0, EM0, GM0),
|
||||||
user:unknown_predicate_handler(GM0,EM0,M1:G1),
|
user:unknown_predicate_handler(GM0,EM0,MG),
|
||||||
!,
|
!.
|
||||||
expand_goal(M1:G1, MG).
|
'$undefp_search'(M0:G0, M:G) :-
|
||||||
'$undefp_search'(MG, FMG) :-
|
'$get_undefined_predicates'(G, M0, G0, M), !.
|
||||||
expand_goal(MG, FMG).
|
|
||||||
|
|
||||||
|
|
||||||
:- abolish('$undefp'/2).
|
:- abolish('$undefp'/2).
|
||||||
|
|
||||||
|
|
||||||
% undef handler
|
% undef handler
|
||||||
'$undefp'([M0|G0], Action) :-
|
'$undefp'([M0|G0],_) :-
|
||||||
|
start_low_level_trace,
|
||||||
% make sure we do not loop on undefined predicates
|
% make sure we do not loop on undefined predicates
|
||||||
yap_flag( unknown, Action, fail),
|
setup_call_catcher_cleanup(
|
||||||
'$stop_creeping'(Current),
|
'$undef_set'(Action,Debug,Current),
|
||||||
% yap_flag( debug, Debug, false),
|
'$search_def'(M0,G0,MG),
|
||||||
(
|
Port,
|
||||||
'$undefp_search'(M0:G0, NM:NG),
|
'$undef_reset'(Port,M0:G0,MG,Action,Debug,Current)
|
||||||
( M0 \== NM -> true ; G0 \== NG ),
|
).
|
||||||
NG \= fail
|
|
||||||
->
|
'$undef_set'(Action,Debug,Current) :-
|
||||||
yap_flag( unknown, _, Action),
|
yap_flag( unknown, Action, fail),
|
||||||
% yap_flag( debug, _, Debug),
|
yap_flag( debug, Debug, false),
|
||||||
|
'$stop_creeping'(Current).
|
||||||
|
|
||||||
|
'$search_def'(M0,G0,NG:NM) :-
|
||||||
|
'$undefp_search'(M0:G0, NM:NG),
|
||||||
|
!,
|
||||||
|
'$pred_exists'(NG,NM).
|
||||||
|
|
||||||
|
'$undef_reset'(exit,_G0,NG:NM,Action,Debug,Current) :-
|
||||||
|
yap_flag( unknown, _, Action),
|
||||||
|
yap_flag( debug, _, Debug),
|
||||||
|
nonvar(NG),
|
||||||
|
nonvar(NM),
|
||||||
(
|
(
|
||||||
Current == true
|
Current == true
|
||||||
->
|
->
|
||||||
@ -132,11 +144,12 @@ undefined_query(G0, M0, Cut) :-
|
|||||||
'$start_creep'([NM|NG], creep)
|
'$start_creep'([NM|NG], creep)
|
||||||
;
|
;
|
||||||
'$execute0'(NG, NM)
|
'$execute0'(NG, NM)
|
||||||
)
|
).
|
||||||
;
|
'$undef_reset'(_,M0:G0,_NG,Action,Debug,_Current) :-
|
||||||
yap_flag( unknown, _, Action),
|
yap_flag( unknown, _, Action),
|
||||||
'$handle_error'(Action,G0,M0)
|
yap_flag( debug, _, Debug),
|
||||||
).
|
'$start_creep'([prolog|true], creep),
|
||||||
|
'$handle_error'(Action,G0,M0).
|
||||||
|
|
||||||
:- '$undefp_handler'('$undefp'(_,_), prolog).
|
:- '$undefp_handler'('$undefp'(_,_), prolog).
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user