This commit is contained in:
Vitor Santos Costa 2018-03-19 15:41:06 +00:00
parent 31fd3eb344
commit 2e9be3d0d4
30 changed files with 194 additions and 110 deletions

View File

@ -1452,11 +1452,10 @@ X_API Term YAP_ReadBuffer(const char *s, Term *tp) {
if (*tp) if (*tp)
tv = *tp; tv = *tp;
else else
tv = 0; tv = (Term)0;
LOCAL_ErrorMessage = NULL; LOCAL_ErrorMessage = NULL;
const unsigned char *us = (const unsigned char *)s; const unsigned char *us = (const unsigned char *)s;
while (!(t = Yap_BufferToTermWithPrioBindings(us, strlen(s) + 1, TermNil, while (!(t = Yap_BufferToTermWithPrioBindings(us, TermNil, tv, strlen(s) + 1, GLOBAL_MaxPriority))) {
GLOBAL_MaxPriority, tv))) {
if (LOCAL_ErrorMessage) { if (LOCAL_ErrorMessage) {
if (!strcmp(LOCAL_ErrorMessage, "Stack Overflow")) { if (!strcmp(LOCAL_ErrorMessage, "Stack Overflow")) {
if (!Yap_dogc(0, NULL PASS_REGS)) { if (!Yap_dogc(0, NULL PASS_REGS)) {

View File

@ -36,6 +36,7 @@ static char SccsId[] = "@(#)cdmgr.c 1.1 05/02/98";
#include <assert.h> #include <assert.h>
#include <heapgc.h> #include <heapgc.h>
#include <iopreds.h> #include <iopreds.h>
#include <Yatom.h>
static void retract_all(PredEntry *, int); static void retract_all(PredEntry *, int);
static void add_first_static(PredEntry *, yamop *, int); static void add_first_static(PredEntry *, yamop *, int);
@ -1741,7 +1742,7 @@ bool Yap_addclause(Term t, yamop *cp, Term tmode, Term mod, Term *t4ref)
/* The only problem we have now is when we need to throw away /* The only problem we have now is when we need to throw away
Indexing blocks Indexing blocks
*/ */
if (pflags & IndexedPredFlag) { if (pflags & IndexedPredFlag && p->cs.p_code.NOfClauses > 1) {
Yap_AddClauseToIndex(p, cp, mode == asserta); Yap_AddClauseToIndex(p, cp, mode == asserta);
} }
if (pflags & (SpiedPredFlag | CountPredFlag | ProfiledPredFlag)) { if (pflags & (SpiedPredFlag | CountPredFlag | ProfiledPredFlag)) {

View File

@ -1319,8 +1319,7 @@ static bool setInitialValue(bool bootstrap, flag_func f, const char *s,
} }
CACHE_REGS CACHE_REGS
const unsigned char *us = (const unsigned char *)s; const unsigned char *us = (const unsigned char *)s;
t0 = Yap_BufferToTermWithPrioBindings(us, strlen(s) + 1, TermNil, t0 = Yap_BufferToTermWithPrioBindings(us, TermNil, 0L, strlen(s) + 1, GLOBAL_MaxPriority);
GLOBAL_MaxPriority, 0L);
if (!t0) if (!t0)
return false; return false;
if (IsAtomTerm(t0) || IsIntTerm(t0)) { if (IsAtomTerm(t0) || IsIntTerm(t0)) {

View File

@ -45,6 +45,9 @@ Int p_load_foreign(USES_REGS1) {
StringList new; StringList new;
bool returncode = FALSE; bool returncode = FALSE;
yhandle_t CurSlot = Yap_StartSlots(); yhandle_t CurSlot = Yap_StartSlots();
#if __ANDROID__
return true;
#endif
// Yap_DebugPlWrite(ARG1); printf("%s\n", " \n"); // Yap_DebugPlWrite(ARG1); printf("%s\n", " \n");
// Yap_DebugPlWrite(ARG2); printf("%s\n", " \n"); // Yap_DebugPlWrite(ARG2); printf("%s\n", " \n");
@ -94,7 +97,7 @@ Int p_load_foreign(USES_REGS1) {
} else { } else {
f = RepAtom(libs->name)->StrOfAE; f = RepAtom(libs->name)->StrOfAE;
} }
Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, ARG3, Yap_Error(SYSTEM_ERROR_OPERATING_SYSTEM, ARG3,
"Foreign module %s does not have initialization function %s", f, "Foreign module %s does not have initialization function %s", f,
InitProcName); InitProcName);
return false; return false;

View File

@ -455,7 +455,7 @@ bool low_level_trace__(yap_low_level_port port, PredEntry *pred, CELL *args) {
} }
UNLOCK(Yap_low_level_trace_lock); UNLOCK(Yap_low_level_trace_lock);
#if __ANDROID__ #if __ANDROID__
__android_log_print(ANDROID_LOG_DEBUG, "YAPDroid", "%s\n", buf); __android_log_print(ANDROID_LOG_ERROR, "YAPDroid", "%s\n", buf);
#else #else
*b++ = '\n'; *b++ = '\n';
*b = '\0'; *b = '\0';
@ -510,7 +510,7 @@ not being output.
static Int stop_low_level_trace(USES_REGS1) { static Int stop_low_level_trace(USES_REGS1) {
Yap_do_low_level_trace = FALSE; Yap_do_low_level_trace = FALSE;
LOCAL_do_trace_primitives = TRUE; LOCAL_do_trace_primitives = TRUE;
#if DEBUG_LOCKS #if DEBUG_LOCKS////
debug_locks = TRUE; debug_locks = TRUE;
#endif #endif
return (TRUE); return (TRUE);

View File

@ -146,7 +146,7 @@ static void init_globals(YAP_init_args *yap_init) {
} }
const char *Yap_BINDIR, *Yap_ROOTDIR, *Yap_SHAREDIR, *Yap_LIBDIR, *Yap_DLLDIR, const char *Yap_BINDIR, *Yap_ROOTDIR, *Yap_SHAREDIR, *Yap_LIBDIR, *Yap_DLLDIR,
*Yap_PLDIR, *Yap_BOOTSTRAP, *Yap_COMMONSDIR, *Yap_STARTUP, *Yap_PLDIR, *Yap_BOOTSTRAP, *Yap_COMMONSDIR,
*Yap_INPUT_STARTUP, *Yap_OUTPUT_STARTUP, *Yap_BOOTFILE, *Yap_INCLUDEDIR; *Yap_INPUT_STARTUP, *Yap_OUTPUT_STARTUP, *Yap_BOOTFILE, *Yap_INCLUDEDIR;
/* do initial boot by consulting the file boot.yap */ /* do initial boot by consulting the file boot.yap */
@ -272,7 +272,7 @@ static void Yap_set_locations(YAP_init_args *iap) {
/// 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(true, iap->DLLDIR != NULL, iap->DLLDIR, true,
#if __ANDROID__ #if __ANDROID__
NULL NULL,
#else #else
join(getenv("DESTDIR"), YAP_DLLDIR), join(getenv("DESTDIR"), YAP_DLLDIR),
#endif #endif
@ -312,12 +312,12 @@ static void Yap_set_locations(YAP_init_args *iap) {
/// 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(true, iap->BOOTSTRAP != NULL, iap->BOOTSTRAP, true,
#if __ANDROID__ #if __ANDROID__
"/assets/Yap/pl", "/assets/Yap/pl/boot,yap",
#else #else
join(getenv("DESTDIR"), YAP_BOOTSTRAP), join(getenv("DESTDIR"), YAP_BOOTSTRAP),
#endif #endif
false); false);
/// BOOTFILE: where we can find the core Prolog bootstrap file /// BOOTFILE: where we can find the core Prolog boot file
Yap_BOOTFILE = sel(false, iap->BOOTFILE != NULL, iap->BOOTFILE, true, Yap_BOOTFILE = sel(false, iap->BOOTFILE != NULL, iap->BOOTFILE, true,
#if __ANDROID__ #if __ANDROID__
"/assets/Yap/pl/boot.yap", "/assets/Yap/pl/boot.yap",
@ -453,7 +453,7 @@ X_API YAP_file_type_t Yap_InitDefaults(void *x, char *saved_state, int argc,
memset(iap, 0, sizeof(YAP_init_args)); memset(iap, 0, sizeof(YAP_init_args));
#if __ANDROID__ #if __ANDROID__
iap->boot_file_type = YAP_BOOT_PL; iap->boot_file_type = YAP_BOOT_PL;
iap->SavedState = NULL; iap->INPUT_STARTUP = NULL;
iap->assetManager = NULL; iap->assetManager = NULL;
#else #else
iap->boot_file_type = YAP_QLY; iap->boot_file_type = YAP_QLY;
@ -970,6 +970,7 @@ static void init_hw(YAP_init_args *yap_init, struct ssz_t *spt) {
static YAP_file_type_t end_init(YAP_init_args *yap_init, YAP_file_type_t rc) { static YAP_file_type_t end_init(YAP_init_args *yap_init, YAP_file_type_t rc) {
YAP_initialized = true; YAP_initialized = true;
LOCAL_PrologMode &= ~BootMode; LOCAL_PrologMode &= ~BootMode;
CurrentModule = USER_MODULE;
return rc; return rc;
} }
@ -1039,7 +1040,7 @@ X_API YAP_file_type_t YAP_Init(YAP_init_args *yap_init) {
init_globals(yap_init); init_globals(yap_init);
start_modules(); start_modules();
consult(Yap_BOOTSTRAP PASS_REGS); consult(Yap_BOOTFILE PASS_REGS);
if (yap_init->install && Yap_OUTPUT_STARTUP) { if (yap_init->install && Yap_OUTPUT_STARTUP) {
Term t = MkAtomTerm(Yap_LookupAtom(Yap_OUTPUT_STARTUP)); Term t = MkAtomTerm(Yap_LookupAtom(Yap_OUTPUT_STARTUP));
Term g = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("qsave_program"), 1), Term g = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("qsave_program"), 1),

View File

@ -706,9 +706,8 @@ IF ( ANDROID)
#target_link_libraries(libYap ${CMAKE_SOURCE_DIR}/../sqlite-android/jni/${ANDROID_ABI}/libsqliteX.so android log ) target_link_libraries(libYap ${CMAKE_SOURCE_DIR}/../sqlite-android/jni/${ANDROID_ABI}/libsqliteX.so android log )
target_link_libraries(libYap android log )
ENDIF () ENDIF ()

View File

@ -110,7 +110,7 @@ protected:
const unsigned char *us = (const unsigned char *)s0; const unsigned char *us = (const unsigned char *)s0;
tnames = MkVarTerm(); tnames = MkVarTerm();
tout = tout =
Yap_BufferToTermWithPrioBindings(us, strlen(s0), TermNil, 1200, tnames); Yap_BufferToTermWithPrioBindings(us, TermNil, tnames, strlen(s0), 1200);
// fprintf(stderr,"ap=%p arity=%d text=%s", ap, ap->ArityOfPE, s); // fprintf(stderr,"ap=%p arity=%d text=%s", ap, ap->ArityOfPE, s);
// Yap_DebugPlWrite(out); // Yap_DebugPlWrite(out);
if (tout == 0L) { if (tout == 0L) {

View File

@ -338,7 +338,7 @@ public:
/// current directory for the engine /// current directory for the engine
bool call(YAPPredicate ap, YAPTerm ts[]); bool call(YAPPredicate ap, YAPTerm ts[]);
/// current directory for the engine /// current directory for the engine
bool goalt(YAPTerm Yt) { return Yt.term(); }; bool goal(YAPTerm Yt, YAPModule module) { return mgoal(Yt.term(),module.term()); };
/// current directory for the engine /// current directory for the engine
bool mgoal(Term t, Term tmod); bool mgoal(Term t, Term tmod);
/// current directory for the engine /// current directory for the engine

View File

@ -76,7 +76,7 @@ public:
YAPTerm(void *ptr); YAPTerm(void *ptr);
/// parse string s and construct a term. /// parse string s and construct a term.
YAPTerm(char *s) { YAPTerm(char *s) {
Term tp; Term tp = 0;
mk(YAP_ReadBuffer(s, &tp)); mk(YAP_ReadBuffer(s, &tp));
} }
@ -322,20 +322,27 @@ public:
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
}; };
YAPApplTerm(YAPFunctor f, YAPTerm ts[]); YAPApplTerm(YAPFunctor f, YAPTerm ts[]);
YAPApplTerm(const std::string s, std::vector<YAPTerm> ts); YAPApplTerm(const std::string s, unsigned int arity) { mk(Yap_MkNewApplTerm(Yap_MkFunctor(Yap_LookupAtom(s.c_str()), arity), arity)); };
YAPApplTerm(const std::string s, std::vector<YAPTerm> ts);
YAPApplTerm(YAPFunctor f); YAPApplTerm(YAPFunctor f);
inline Functor functor() { return FunctorOfTerm(gt()); } inline Functor functor() { return FunctorOfTerm(gt()); }
inline YAPFunctor getFunctor() { return YAPFunctor(FunctorOfTerm(gt())); } inline YAPFunctor getFunctor() { return YAPFunctor(FunctorOfTerm(gt())); }
Term getArg(arity_t i) { Term getArg(arity_t i) {
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
Term t0 = gt(); Term t0 = gt();
Term tf; Term tf;
tf = ArgOfTerm(i, t0); tf = ArgOfTerm(i, t0);
RECOVER_MACHINE_REGS(); RECOVER_MACHINE_REGS();
return tf; return tf;
}; };
virtual bool isVar() { return false; } /// type check for unbound void putArg(int i, YAPTerm t) {
BACKUP_MACHINE_REGS();
Term t0 = gt();
RepAppl(t0)[i] = t.term();
RECOVER_MACHINE_REGS();
};
virtual bool isVar() { return false; } /// type check for unbound
virtual bool isAtom() { return false; } /// type check for atom virtual bool isAtom() { return false; } /// type check for atom
virtual bool isInteger() { return false; } /// type check for integer virtual bool isInteger() { return false; } /// type check for integer
virtual bool isFloat() { return false; } /// type check for floating-point virtual bool isFloat() { return false; } /// type check for floating-point

View File

@ -263,6 +263,7 @@ extern size_t Yap_page_size;
#define M1 ((CELL)(1024 * 1024)) #define M1 ((CELL)(1024 * 1024))
#define M2 ((CELL)(2048 * 1024)) #define M2 ((CELL)(2048 * 1024))
typedef YAP_UInt CELL;
#if ALIGN_LONGS #if ALIGN_LONGS
typedef CELL SFLAGS; typedef CELL SFLAGS;
#else #else

View File

@ -226,8 +226,4 @@ atom_t ATOM_;
intptr_t system_thread_id(void); intptr_t system_thread_id(void);
#endif #endif
extern Term Yap_BufferToTermWithPrioBindings(const char *s, size_t len,
encoding_t enc, int prio,
Term *bindingsp);
#endif /* PL_YAP_H */ #endif /* PL_YAP_H */

View File

@ -41,8 +41,8 @@ static char SccsId[] = "%W% %G%";
#include <android/native_activity.h> #include <android/native_activity.h>
extern void extern X_API void
Java_pt_up_yap_YAPIO_setAssetManager(JNIEnv *env, jclass clazz, jobject assetManager); Java_pt_up_yap_yapdroid_YAPDroid_loadAssetManager(JNIEnv *env, jclass clazz, jobject assetManager);
jobject *Yap_aref; jobject *Yap_aref;
JNIEnv *Yap_env; JNIEnv *Yap_env;
@ -52,8 +52,8 @@ AAssetManager *Yap_assetManager(void)
return AAssetManager_fromJava(Yap_env, Yap_aref); return AAssetManager_fromJava(Yap_env, Yap_aref);
} }
void X_API void
Java_pt_up_yap_YAPIO_setAssetManager(JNIEnv *env, jclass clazz, jobject assetManager) { Java_pt_up_yap_yapdroid_YAPDroid_loadAssetManager(JNIEnv *env, jclass clazz, jobject assetManager) {
Yap_aref = (*env)->NewGlobalRef(env,assetManager); Yap_aref = (*env)->NewGlobalRef(env,assetManager);
Yap_env = env; Yap_env = env;
} }

View File

@ -1385,9 +1385,8 @@ Term Yap_BufferToTerm(const unsigned char *s, Term opts) {
return rval; return rval;
} }
X_API Term Yap_BufferToTermWithPrioBindings(const unsigned char *s, size_t len, X_API Term Yap_BufferToTermWithPrioBindings(const unsigned char *s, Term opts, Term bindings, size_t len,
Term opts, int prio, int prio) {
Term bindings) {
CACHE_REGS CACHE_REGS
Term ctl; Term ctl;

View File

@ -117,9 +117,9 @@ extern int Yap_open_buf_read_stream(const char *buf, size_t nchars,
encoding_t *encp, memBufSource src); encoding_t *encp, memBufSource src);
extern int Yap_open_buf_write_stream(encoding_t enc, memBufSource src); extern int Yap_open_buf_write_stream(encoding_t enc, memBufSource src);
extern Term Yap_BufferToTerm(const unsigned char *s, Term opts); extern Term Yap_BufferToTerm(const unsigned char *s, Term opts);
extern X_API Term Yap_BufferToTermWithPrioBindings(const unsigned char *s, extern X_API Term
size_t sz, Term opts, Yap_BufferToTermWithPrioBindings(const unsigned char *s, Term opts, Term bindings, size_t sz,
int prio, Term bindings); int prio);
extern FILE *Yap_GetInputStream(Term t, const char *m); extern FILE *Yap_GetInputStream(Term t, const char *m);
extern FILE *Yap_GetOutputStream(Term t, const char *m); extern FILE *Yap_GetOutputStream(Term t, const char *m);
extern char *Yap_guessFileName(FILE *f, int sno, char *nameb, size_t max); extern char *Yap_guessFileName(FILE *f, int sno, char *nameb, size_t max);

View File

@ -15,6 +15,7 @@
typedef struct myddas_global *MYDDAS_GLOBAL; typedef struct myddas_global *MYDDAS_GLOBAL;
#include "myddas_util.h" #include "myddas_util.h"
#ifdef MYDDAS_STATS #ifdef MYDDAS_STATS
typedef struct myddas_stats_time_struct *MYDDAS_STATS_TIME; typedef struct myddas_stats_time_struct *MYDDAS_STATS_TIME;
typedef struct myddas_global_stats *MYDDAS_GLOBAL_STATS; typedef struct myddas_global_stats *MYDDAS_GLOBAL_STATS;

View File

@ -680,26 +680,16 @@ void Yap_MYDDAS_delete_all_myddas_structs(void) {
void init_myddas(void) { void init_myddas(void) {
CACHE_REGS CACHE_REGS
if (myddas_initialised) if (myddas_initialised)
return; return;
init_sqlite3();
myddas_initialised = TRUE; myddas_initialised = TRUE;
#if defined MYDDAS_ODBC #if defined MYDDAS_ODBC
Yap_InitBackMYDDAS_ODBCPreds(); Yap_InitBackMYDDAS_ODBCPreds();
#endif #endif
#if WIN32
Yap_InitBackMYDDAS_SQLITE3Preds();
#endif
#if defined USE_MYDDAS
Yap_InitBackMYDDAS_SharedPreds();
#endif
#if defined MYDDAS_MYSQL
Yap_InitMYDDAS_MySQLPreds();
#endif #endif
#if defined MYDDAS_ODBC #if defined MYDDAS_ODBC
Yap_InitMYDDAS_ODBCPreds(); Yap_InitMYDDAS_ODBCPreds();
#endif #endif
#if WIN32
Yap_InitMYDDAS_SQLITE3Preds();
#endif
#if defined USE_MYDDAS #if defined USE_MYDDAS
Yap_InitMYDDAS_SharedPreds(); Yap_InitMYDDAS_SharedPreds();
#endif #endif
@ -743,4 +733,3 @@ int WINAPI win_myddas(HANDLE hinst, DWORD reason, LPVOID reserved) {
} }
#endif #endif
#endif /* USE_MYDDAS*/

View File

@ -72,6 +72,7 @@ foreach (driver ${MYDDAS_DBMS})
cpp_driver(MYDDAS_YAP ${driver} myddas_driver.ypp) cpp_driver(MYDDAS_YAP ${driver} myddas_driver.ypp)
endforeach () endforeach ()
list (APPEND MYDDAS_YAP ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/test.yap ${CMAKE_CURRENT_SOURCE_DIR}/../sqlite3/chinook.db)
add_to_group(MYDDAS_YAP pl_library ) add_to_group(MYDDAS_YAP pl_library )
add_custom_target(plmyddas ALL DEPENDS ${MYDDAS_YAP} ) add_custom_target(plmyddas ALL DEPENDS ${MYDDAS_YAP} )
@ -79,4 +80,3 @@ add_custom_target(plmyddas ALL DEPENDS ${MYDDAS_YAP} )
install(FILES ${MYDDAS_YAP} install(FILES ${MYDDAS_YAP}
DESTINATION ${libpl} DESTINATION ${libpl}
) )

View File

@ -243,8 +243,7 @@ db_open(odbc,Connection,ODBCEntry,User,Password) :-
%% sqlite3 %% sqlite3
db_open(sqlite3,Connection,File,User,Password) :- db_open(sqlite3,Connection,File,User,Password) :-
'$error_checks'(db_open(sqlite3,Connection,File,User,Password)), '$error_checks'(db_open(sqlite3,Connection,File,User,Password)),
absolute_file_name(File,FullFile,[access(exist),file_errors(error),expand(true)]), c_sqlite3_connect(File,User,Password,Con),
c_sqlite3_connect(FullFile,User,Password,Con),
set_value(Connection,Con). set_value(Connection,Con).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View File

@ -53,3 +53,6 @@ install(TARGETS sqlite4YAP
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR} LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
) )
endif() endif()
file (INSTALL chinook.db test.yap DESTINATION ${libpl})

View File

@ -77,7 +77,7 @@ static Int c_sqlite3_get_database(USES_REGS1);
static Int c_sqlite3_change_database(USES_REGS1); static Int c_sqlite3_change_database(USES_REGS1);
static Int c_sqlite3_connect(USES_REGS1) { static Int c_sqlite3_connect(USES_REGS1) {
printf("hello darkness\n");
Term arg_file = Deref(ARG1); Term arg_file = Deref(ARG1);
Term arg_db = ARG4; Term arg_db = ARG4;
@ -96,7 +96,56 @@ static Int c_sqlite3_connect(USES_REGS1) {
if (new == NULL) { if (new == NULL) {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "ERROR: ** c_db_my_connect ** Error allocating memory\n"); fprintf(stderr, "ERROR: ** c_db_my_connect ** Error allocating memory\n");135761 )
03-16 17:31:30.590 25588-25588/? E/YAPDroid: 4011d 240 0 FAIL RETRY: prolog:$user_expansion(user:main, _135757:_135758 )
03-16 17:31:30.590 25588-25588/? E/YAPDroid: 4012d 173 0 CALL: prolog:$import_expansion(user:main, _135760:_135761 )
03-16 17:31:30.590 25588-25588/? E/YAPDroid: 4013d 239 0 CALL: prolog:$imported_predicate(main, user, _135761, _135760 )
03-16 17:31:30.590 25588-25588/? E/YAPDroid: 4014d 255 0 CALL: prolog:$is_system_predicate(main, prolog )
03-16 17:31:30.590 25588-25588/? E/YAPDroid: 4015d 255 0 FAIL RETRY: prolog:$imported_predicate(main, user, _135761, _135760 )
03-16 17:31:30.590 25588-25588/? E/YAPDroid: 4016d 239 0 CALL: prolog:$undefined(main, user )
03-16 17:31:30.590 25588-25588/? E/YAPDroid: 4017d 239 0 FAIL RETRY: prolog:$import_expansion(user:main, _135760:_135761 )
03-16 17:31:30.590 25588-25588/? E/YAPDroid: 4018d 173 0 CALL: prolog:$meta_expansion(user:main, user, [], _1048348 )
03-16 17:31:30.590 25588-25588/? E/YAPDroid: 4019d 238 0 CALL: prolog:$yap_strip_module(user:main, _135763, _1048327 )
03-16 17:31:30.590 25588-25588/? E/YAPDroid: 4020d 238 0 CALL: prolog:functor(main, _135766, _135767 )
03-16 17:31:30.590 25588-25588/? E/YAPDroid: 4021d 238 0 CALL: prolog:$meta_predicate(main, user, 0, _1048328 )
03-16 17:31:30.590 25588-25588/? E/YAPDroid: 4022d 238 0 FAIL RETRY: prolog:$meta_expansion(user:main, user, [], _1048348 )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4023d 173 0 CALL: prolog:$yap_strip_module(user:main, _135763, _135764 )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4024d 173 0 CALL: prolog:$yap_strip_module(user:main, _135765, _135766 )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4025d 173 0 CALL: prolog:$end_goal_expansion(main, _135738, _135740, user, user, user, :-user:main )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4026d 173 0 CALL: prolog:$match_mod(main, user, user, user, _135738 )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4027d 173 0 CALL: prolog:$is_system_predicate(main, user )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4028d 173 0 TRY_OR
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4029d 216 0 CALL: prolog:==(user, user )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4030d 216 0 CALL: prolog:==(user, user )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4031d 173 0 CALL: prolog:$c_built_in(main, user, :-user:main, _1048378 )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4032d 209 0 CALL: prolog:get_value('$c_arith', true )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4033d 173 0 CALL: prolog:do_c_built_in(main, user, :-user:main, _1048378 )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4034d 220 0 CALL: prolog:$compop(main, _1048340, _1048341, _1048343 )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4035d 220 0 FAIL RETRY: prolog:do_c_built_in(main, user, :-user:main, _1048378 )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4036d 220 0 CALL: prolog:$yap_strip_module(user:main, _135770, _135771 )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4037d 220 0 CALL: prolog:$match_mod(main, user, user, user, _135740 )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4038d 220 0 CALL: prolog:$is_system_predicate(main, user )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4039d 220 0 TRY_OR
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4040d 236 0 CALL: prolog:==(user, user )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4041d 236 0 CALL: prolog:==(user, user )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4042d 220 0 CALL: prolog:$yap_strip_module(user: (:-main), _135727, _135728 )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4043d 158 0 TRY_OR
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4044d 172 0 CALL: prolog:==(158, 158 )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4045d 105 0 CALL: prolog:$yap_strip_module(user: (:-main), _1048434, _135775 )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4046d 105 0 TRY_OR
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4047d 105 0 CALL: prolog:$process_directive(main, reconsult, user, [], '$stream_position'(1342,80,1,0) )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4048d 130 0 FAIL RETRY: prolog:$process_directive(main, reconsult, user, [], '$stream_position'(1342,80,1,0) )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4049d 130 0 FAIL RETRY: prolog:$process_directive(main, reconsult, user, [], '$stream_position'(1342,80,1,0) )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4050d 130 0 CALL: prolog:$all_directives(main )
03-16 17:31:30.591 25588-25588/? E/YAPDroid: 4051d 130 0 CALL: prolog:$directive(main )
03-16 17:31:30.592 25588-25588/? E/YAPDroid: 4052d 130 0 FAIL RETRY: prolog:$process_directive(main, reconsult, user, [], '$stream_position'(1342,80,1,0) )
03-16 17:31:30.592 25588-25588/? E/YAPDroid: 4053d 130 0 CALL: prolog:current_prolog_flag(language_mode, iso )
03-16 17:31:30.592 25588-25588/? E/YAPDroid: 4054d 130 0 FAIL RETRY: prolog:$process_directive(main, reconsult, user, [], '$stream_position'(1342,80,1,0) )
03-16 17:31:30.592 25588-25588/? E/YAPDroid: 4055d 130 0 CALL: prolog:$execute(user:main )
03-16 17:31:30.592 25588-25588/? E/YAPDroid: 4056d 130 0 CALL: user:main
03-16 17:31:30.592 25588-25588/? E/YAPDroid: 4057d 130 0 CALL: user:init
03-16 17:31:30.592 25588-25588/? E/YAPDroid: 4058d 130 0 CALL: user:db_open(sqlite3, '/data/user/0/pt.up.yap.yapdroid/files/Yap/chinook.db', _1048428, _1048429 )
03-16 17:31:30.592 25588-25588/? E/YAPDroid: 4059d 130 0 CALL: user:db_open(sqlite3, myddas, '/data/user/0/pt.up.yap.yapdr
#endif #endif
return FALSE; return FALSE;
} }
@ -664,15 +713,18 @@ static void Yap_InitBackMYDDAS_SQLITE3Preds(void) {
} }
X_API void init_sqlite3(void) { X_API void init_sqlite3(void) {
// Yap_InitMYDDAS_SQLITE3Preds(); Term cm = CurrentModule;
// Yap_InitBackMYDDAS_SQLITE3Preds(); CurrentModule = PROLOG_MODULE;
Yap_InitMYDDAS_SQLITE3Preds();
Yap_InitBackMYDDAS_SQLITE3Preds();
CurrentModule = cm;
} }
#if _ANDROID_ #if _ANDROID_
//JNIEXPORT void JNICALL lib_yap_up_pt_init_sqlite(JNIEnv *env); //JNIEXPORT void JNICALL lib_yap_up_pt_init_sqlite(JNIEnv *env);
// JNIEXPORT void JNICALL lib_yap_up_pt_init_sqlite(JNIEnv *env) { // JNIEXPORT void JNICALL lib_yap_up_pt_init_sqlite(JNIEnv *env) {
// init_sqlite3(); init_sqlite3();
} }
#endif #endif

View File

@ -1,21 +1,18 @@
:- [library(myddas)]. :- compile(library(myddas)).
:- initialization(main).
main :- main :-
setup_call_cleanup( init,
init, main_,
main_ , close.
(trace,
close)).
main_ :- main_ :-
go, go,
fail. fail.
main_ . main_ .
init :- init :-
db_open(sqlite3, '~/Yap/Chinook/Chinook_Sqlite.sqlite', _, _), db_open(sqlite3, '/data/user/0/pt.up.yap.yapdroid/files/Yap/chinook.db', _, _),
writeln('chinook has landed'),
db_import('Artist', artist), db_import('Artist', artist),
db_import('Album', album), db_import('Album', album),
db_import('Track', track). db_import('Track', track).
@ -25,26 +22,24 @@ init :-
db_get_attributes_types(track,Ts), db_get_attributes_types(track,Ts),
db_get_attributes_types(artist,As), db_get_attributes_types(artist,As),
writeln(As:Als:Ts). writeln(As:Als:Ts).
go :- go :-
db_number_of_fields(album,Als), db_number_of_fields(album,Als),
db_number_of_fields(track,Ts), db_number_of_fields(track,Ts),
db_number_of_fields(artist,As), db_number_of_fields(artist,As),
writeln(As:Als:Ts). writeln(As:Als:Ts).
go :- go :-
db_describe(album, Desc), writeln(Desc) ; db_describe(album, Desc), writeln(Desc) ;
db_describe(track, Desc), writeln(Desc) ; db_describe(track, Desc), writeln(Desc) ;
db_describe(artist, Desc), writeln(Desc). db_describe(artist, Desc), writeln(Desc).
go :-
go :-
db_show_tables(Desc), writeln(Desc). db_show_tables(Desc), writeln(Desc).
go :- go :-
db_show_tables(table(T)), db_show_tables(table(T)),
db_describe(T,tableinfo(FieldID,Type,Null,Primary,Default,'')), db_describe(T,tableinfo(FieldID,Type,Null,Primary,Default,'')),
writeln(T:tableinfo(FieldID,Type,Null,Primary,Default,'')). writeln(T:tableinfo(FieldID,Type,Null,Primary,Default,'')).
go :- go :-
go_cut0. go_cut0.
@ -79,3 +74,6 @@ go_cut1 :-
close :- close :-
db_close. db_close.
:- main.

View File

@ -20,6 +20,7 @@ FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/jni)
add_custom_target (pllib add_custom_target (pllib
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib} COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}
COMMAND ${CMAKE_COMMAND} -E copy ${pl_library} ${pllib} COMMAND ${CMAKE_COMMAND} -E copy ${pl_library} ${pllib}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/android.yap ${pllib}
DEPENDS ${pl_library} DEPENDS ${pl_library}
) )

View File

@ -1,15 +1,21 @@
// //
// Created by vsc on 7/6/17. // Created by vsc on 7/6/17->
// //
/* File : example.cxx */ /* File : example->cxx */
#include "streamer.h" #include "streamer.h"
extern "C" {
extern void Java_pt_up_yap_streamerJNI_swig_1module_1init(void);
}
static AndroidStreamer * streamerInstance = 0; static AndroidStreamer * streamerInstance = 0;
void setStreamer(AndroidStreamer* streamer) { void setStreamer(AndroidStreamer* streamer) {
streamerInstance = streamer; streamerInstance = streamer;
Java_pt_up_yap_streamerJNI_swig_1module_1init();
} }
AndroidStreamer& getStreamer() { AndroidStreamer& getStreamer() {
@ -25,13 +31,11 @@ extern "C" {
#include <yapio.h> #include <yapio.h>
#include <iopreds.h> #include <iopreds.h>
extern void Java_pt_up_yap_streamerJNI_swig_1module_1init__(void);
static VFS_t andstream;
void Java_pt_up_yap_streamerJNI_swig_1module_1init__(void) {
// streamerInstance = 0; static VFS_t *andstream;
} ;
static std::string buff0; static std::string buff0;
@ -83,21 +87,34 @@ streamerInstance->display(buff0);
} }
void
AndroidStreamer::bind() { extern "C" {
buff0 = *new std::string[256];
andstream.name = "/android/user_error";
andstream.vflags = VFS_CAN_WRITE | VFS_HAS_PREFIX; void Java_pt_up_yap_streamerJNI_swig_1module_1init(void) {
andstream.prefix = "/android"; if (andstream)
andstream.suffix = NULL; return;
andstream.open = and_open; andstream = new VFS_t();
andstream.close = and_close;
andstream.get_char = and_get; andstream->name = "android output window";
andstream.put_char = and_put; andstream->vflags = VFS_CAN_WRITE | VFS_HAS_PREFIX;
andstream.flush = and_flush; andstream->prefix = "/android";
andstream.seek = and_seek; andstream->suffix = NULL;
andstream.next = GLOBAL_VFS; andstream->open = and_open;
GLOBAL_VFS = &andstream; andstream->close = and_close;
Yap_InitStdStream(StdOutStream, Output_Stream_f | Append_Stream_f, NULL, &andstream); andstream->get_char = and_get;
Yap_InitStdStream(StdErrStream, Output_Stream_f | Append_Stream_f, NULL, &andstream); andstream->put_char = and_put;
andstream->flush = and_flush;
andstream->seek = and_seek;
andstream->next = GLOBAL_VFS;
GLOBAL_VFS = andstream;
YAP_Term ts[1], args[1], goal;
ts[0] = MkAtomTerm(Yap_LookupAtom("android"));
args[0] = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("library"),1), 1, ts);
goal = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("compile"),1), 1, args);
YAP_RunGoalOnce(goal);
}
} }

View File

@ -9,10 +9,14 @@
#include <string> #include <string>
#include <sstream> #include <sstream>
struct AndroidStreamer { struct AndroidStreamer {
std::string *buff0;
virtual void display(std::string text) const = 0; virtual void display(std::string text) const = 0;
virtual ~AndroidStreamer() {} virtual ~AndroidStreamer() {}
void bind(); AndroidStreamer() { buff0 = new std::string[256];
};
}; };
void setStreamer(AndroidStreamer* streamer); void setStreamer(AndroidStreamer* streamer);
AndroidStreamer& getStreamer(); AndroidStreamer& getStreamer();

View File

@ -60,7 +60,11 @@ class YAPEngine;
return NULL; return NULL;
} }
#endif #endif
} #ifdef SWIGJAVA0
%typemap(javapackage) std::vector<YAPTerm> "pt.up.yap.YAPTerm"
%template(VectorOfTerm) std::vector<YAPTerm>;
#endif
}
%} %}
#ifdef SWIGPYTHON #ifdef SWIGPYTHON

View File

@ -8,6 +8,7 @@ set(PL_BOOT_SOURCES
boot.yap boot.yap
bootlists.yap bootlists.yap
bootutils.yap bootutils.yap
builtins.yap
callcount.yap callcount.yap
checker.yap checker.yap
consult.yap consult.yap
@ -26,6 +27,7 @@ set(PL_BOOT_SOURCES
grammar.yap grammar.yap
ground.yap ground.yap
hacks.yap hacks.yap
imports.yap
init.yap init.yap
listing.yap listing.yap
load_foreign.yap load_foreign.yap

View File

@ -342,7 +342,7 @@ expand_expr(Op, X, Y, O, Q, P) :-
%% contains_illegal_dcgnt(+Term) is semidet. %% contains_illegal_dcgnt(+Term) is semidet.
% %
% True if Term contains a non-terminal we cannot deal with using % True if Term contains a non-terminal we cannot deal with using
% goal-expansion. The test is too general approximation, but safe. % goal-expansion. The test is too general an approximation, but safe.
'$contains_illegal_dcgnt'(NT) :- '$contains_illegal_dcgnt'(NT) :-
functor(NT, _, A), functor(NT, _, A),
@ -356,7 +356,6 @@ expand_expr(Op, X, Y, O, Q, P) :-
'$harmless_dcgexception'(instantiation_error). % ex: phrase(([1],x:X,[3]),L) '$harmless_dcgexception'(instantiation_error). % ex: phrase(([1],x:X,[3]),L)
'$harmless_dcgexception'(type_error(callable,_)). % ex: phrase(27,L) '$harmless_dcgexception'(type_error(callable,_)). % ex: phrase(27,L)
:- set_value('$c_arith',true). :- set_value('$c_arith',true).
/** /**
@} @}

View File

@ -293,7 +293,7 @@ initialize_prolog :-
'qly.yap', 'qly.yap',
'spy.yap', 'spy.yap',
'udi.yap']. 'udi.yap'].
:- stop_low_level_trace. %:- stop_low_level_trace.
:- meta_predicate(log_event(+,:)). :- meta_predicate(log_event(+,:)).
@ -461,3 +461,12 @@ If this hook predicate succeeds it must instantiate the _Action_ argument to th
:- ensure_loaded('../pl/pathconf.yap'). :- ensure_loaded('../pl/pathconf.yap').
:- yap_flag(user:unknown,error). :- yap_flag(user:unknown,error).
:- compile('../myddas').
:- start_low_level_trace.
%:- db_open(sqlite3, '/asssets/Yap/chinook.db', _, _).
:- compile('../test').

View File

@ -1,5 +1,6 @@
:- '$mk_dynamic'('$parent_module'(_,_),prolog). :- '$mk_dynamic'('$parent_module'(_,_),prolog).
'$get_undefined_predicates'(G, ImportingMod, G0, ExportingMod) :- '$get_undefined_predicates'(G, ImportingMod, G0, ExportingMod) :-
recorded('$import','$import'(ExportingModI,ImportingMod,G0I,G,_,_),_), recorded('$import','$import'(ExportingModI,ImportingMod,G0I,G,_,_),_),
'$continue_imported'(ExportingMod, ExportingModI, G0, G0I). '$continue_imported'(ExportingMod, ExportingModI, G0, G0I).