swig fixes for Android compatibility
This commit is contained in:
parent
1f301ded89
commit
5b19ccf6a8
@ -2298,16 +2298,13 @@ YAP_EnterGoal(PredEntry *pe, Term *ptr, YAP_dogoalinfo *dgi)
|
|||||||
Yap_PrepGoal(pe->ArityOfPE, ptr, B PASS_REGS);
|
Yap_PrepGoal(pe->ArityOfPE, ptr, B PASS_REGS);
|
||||||
P = pe->CodeOfPred;
|
P = pe->CodeOfPred;
|
||||||
dgi->b = LCL0-(CELL*)B;
|
dgi->b = LCL0-(CELL*)B;
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "EMUL IN Yap_regp=%p LCL0=(%p) %x", &Yap_REGS, LCL0, LCL0[-15]) ; }
|
|
||||||
out = run_emulator(dgi PASS_REGS);
|
out = run_emulator(dgi PASS_REGS);
|
||||||
//{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "EMUL DONE Yap_regp=%p LCL0=(%p) %x", &Yap_REGS, LCL0, LCL0[-15]) ; }
|
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
if (out) {
|
if (out) {
|
||||||
Yap_StartSlots( PASS_REGS1 );
|
Yap_StartSlots( PASS_REGS1 );
|
||||||
} else {
|
} else {
|
||||||
LOCAL_CurSlot = dgi->CurSlot; // ignore any slots created within the called goal
|
LOCAL_CurSlot = dgi->CurSlot; // ignore any slots created within the called goal
|
||||||
}
|
}
|
||||||
{ __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "EMUL DONE %d", out) ; }
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2991,7 +2988,6 @@ YAP_Init(YAP_init_args *yap_init)
|
|||||||
if (initialised)
|
if (initialised)
|
||||||
return YAP_BOOT_DONE_BEFOREHAND;
|
return YAP_BOOT_DONE_BEFOREHAND;
|
||||||
initialised = TRUE;
|
initialised = TRUE;
|
||||||
__android_log_print(ANDROID_LOG_INFO, "c_interface.c", "entered init %p", yap_init);
|
|
||||||
|
|
||||||
Yap_InitPageSize(); /* init memory page size, required by later functions */
|
Yap_InitPageSize(); /* init memory page size, required by later functions */
|
||||||
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
|
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
|
||||||
@ -3071,7 +3067,6 @@ YAP_Init(YAP_init_args *yap_init)
|
|||||||
if (restore_result == FAIL_RESTORE) {
|
if (restore_result == FAIL_RESTORE) {
|
||||||
yap_init->ErrorNo = LOCAL_Error_TYPE;
|
yap_init->ErrorNo = LOCAL_Error_TYPE;
|
||||||
yap_init->ErrorCause = LOCAL_ErrorMessage;
|
yap_init->ErrorCause = LOCAL_ErrorMessage;
|
||||||
__android_log_print(ANDROID_LOG_INFO, __FILE__, "restore failed, %s ", LOCAL_ErrorMessage);
|
|
||||||
/* shouldn't RECOVER_MACHINE_REGS(); be here ??? */
|
/* shouldn't RECOVER_MACHINE_REGS(); be here ??? */
|
||||||
return YAP_BOOT_ERROR;
|
return YAP_BOOT_ERROR;
|
||||||
}
|
}
|
||||||
@ -3108,7 +3103,6 @@ YAP_Init(YAP_init_args *yap_init)
|
|||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
RECOVER_MACHINE_REGS();
|
RECOVER_MACHINE_REGS();
|
||||||
}
|
}
|
||||||
__android_log_print(ANDROID_LOG_INFO, __FILE__, "after loading startup %p", yap_init);
|
|
||||||
/* make sure we do this after restore */
|
/* make sure we do this after restore */
|
||||||
if (yap_init->MaxStackSize) {
|
if (yap_init->MaxStackSize) {
|
||||||
GLOBAL_AllowLocalExpansion = FALSE;
|
GLOBAL_AllowLocalExpansion = FALSE;
|
||||||
@ -3133,7 +3127,6 @@ YAP_Init(YAP_init_args *yap_init)
|
|||||||
*/
|
*/
|
||||||
yap_flags[HALT_AFTER_CONSULT_FLAG] = yap_init->HaltAfterConsult;
|
yap_flags[HALT_AFTER_CONSULT_FLAG] = yap_init->HaltAfterConsult;
|
||||||
}
|
}
|
||||||
__android_log_print(ANDROID_LOG_INFO, __FILE__, "after loading startup %s",yap_init->YapPrologRCFile);
|
|
||||||
if (yap_init->YapPrologTopLevelGoal) {
|
if (yap_init->YapPrologTopLevelGoal) {
|
||||||
Yap_PutValue(AtomTopLevelGoal, MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologTopLevelGoal)));
|
Yap_PutValue(AtomTopLevelGoal, MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologTopLevelGoal)));
|
||||||
}
|
}
|
||||||
@ -3146,7 +3139,6 @@ YAP_Init(YAP_init_args *yap_init)
|
|||||||
if (yap_init->QuietMode) {
|
if (yap_init->QuietMode) {
|
||||||
yap_flags[QUIET_MODE_FLAG] = TRUE;
|
yap_flags[QUIET_MODE_FLAG] = TRUE;
|
||||||
}
|
}
|
||||||
__android_log_print(ANDROID_LOG_INFO, __FILE__, "after setting startup ");
|
|
||||||
if (BOOT_FROM_SAVED_STATE && !do_bootstrap) {
|
if (BOOT_FROM_SAVED_STATE && !do_bootstrap) {
|
||||||
if (restore_result == FAIL_RESTORE) {
|
if (restore_result == FAIL_RESTORE) {
|
||||||
yap_init->ErrorNo = LOCAL_Error_TYPE;
|
yap_init->ErrorNo = LOCAL_Error_TYPE;
|
||||||
@ -3162,10 +3154,8 @@ YAP_Init(YAP_init_args *yap_init)
|
|||||||
if (restore_result == DO_ONLY_CODE) {
|
if (restore_result == DO_ONLY_CODE) {
|
||||||
/* first, initialise the saved state */
|
/* first, initialise the saved state */
|
||||||
Term t_goal = MkAtomTerm(AtomInitProlog);
|
Term t_goal = MkAtomTerm(AtomInitProlog);
|
||||||
__android_log_print(ANDROID_LOG_INFO, __FILE__, "restore init goal ");
|
|
||||||
YAP_RunGoalOnce(t_goal);
|
YAP_RunGoalOnce(t_goal);
|
||||||
Yap_InitYaamRegs( 0 );
|
Yap_InitYaamRegs( 0 );
|
||||||
__android_log_print(ANDROID_LOG_INFO, __FILE__, "restore done, loaded startup ");
|
|
||||||
return YAP_BOOT_FROM_SAVED_CODE;
|
return YAP_BOOT_FROM_SAVED_CODE;
|
||||||
} else {
|
} else {
|
||||||
return YAP_BOOT_FROM_SAVED_STACKS;
|
return YAP_BOOT_FROM_SAVED_STACKS;
|
||||||
|
@ -789,7 +789,6 @@ PL_unify_wchars_diff(term_t t, term_t tail, int flags,
|
|||||||
|
|
||||||
if ( len == (size_t)-1 )
|
if ( len == (size_t)-1 )
|
||||||
len = wcslen(s);
|
len = wcslen(s);
|
||||||
|
|
||||||
text.text.w = (pl_wchar_t *)s;
|
text.text.w = (pl_wchar_t *)s;
|
||||||
text.encoding = ENC_WCHAR;
|
text.encoding = ENC_WCHAR;
|
||||||
text.storage = PL_CHARS_HEAP;
|
text.storage = PL_CHARS_HEAP;
|
||||||
@ -916,7 +915,6 @@ Yap_TermToString(Term t, char *s, size_t sz, size_t *length, int *encoding, int
|
|||||||
char *
|
char *
|
||||||
Yap_HandleToString(term_t l, size_t sz, size_t *length, int *encoding, int flags)
|
Yap_HandleToString(term_t l, size_t sz, size_t *length, int *encoding, int flags)
|
||||||
{
|
{
|
||||||
CACHE_REGS
|
|
||||||
|
|
||||||
char *r, buf[4096];
|
char *r, buf[4096];
|
||||||
|
|
||||||
@ -926,12 +924,10 @@ Yap_HandleToString(term_t l, size_t sz, size_t *length, int *encoding, int flags
|
|||||||
r = buf;
|
r = buf;
|
||||||
fd = Sopenmem(&r, &sz, "w");
|
fd = Sopenmem(&r, &sz, "w");
|
||||||
fd->encoding = ENC_UTF8;
|
fd->encoding = ENC_UTF8;
|
||||||
{ __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I %d LCL0+%s=(%p) %p", l, buf, LCL0, &LCL0 ); }
|
|
||||||
if ( PL_write_term(fd, l, 1200, flags) &&
|
if ( PL_write_term(fd, l, 1200, flags) &&
|
||||||
Sputcode(EOS, fd) >= 0 &&
|
Sputcode(EOS, fd) >= 0 &&
|
||||||
Sflush(fd) >= 0 )
|
Sflush(fd) >= 0 )
|
||||||
{
|
{
|
||||||
{ __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I LCL0+%s=(%p) %p", buf, LCL0, &LCL0 ); }
|
|
||||||
size = Stell64(fd);
|
size = Stell64(fd);
|
||||||
*length = size-1;
|
*length = size-1;
|
||||||
char *bf = malloc(*length+1);
|
char *bf = malloc(*length+1);
|
||||||
|
6
C/qlyr.c
6
C/qlyr.c
@ -828,7 +828,6 @@ ReadHash(IOSTREAM *stream)
|
|||||||
static void
|
static void
|
||||||
read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, UInt flags) {
|
read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, UInt flags) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__ , " ? read_uint %p %d %p", pp, nclauses, stream);
|
|
||||||
if (pp->PredFlags & LogUpdatePredFlag) {
|
if (pp->PredFlags & LogUpdatePredFlag) {
|
||||||
/* first, clean up whatever was there */
|
/* first, clean up whatever was there */
|
||||||
if (pp->cs.p_code.NOfClauses) {
|
if (pp->cs.p_code.NOfClauses) {
|
||||||
@ -1005,17 +1004,14 @@ read_module(IOSTREAM *stream) {
|
|||||||
InitHash();
|
InitHash();
|
||||||
read_header(stream);
|
read_header(stream);
|
||||||
ReadHash(stream);
|
ReadHash(stream);
|
||||||
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__ , " after read_hash %p", stream);
|
|
||||||
while ((x = read_tag(stream)) == QLY_START_MODULE) {
|
while ((x = read_tag(stream)) == QLY_START_MODULE) {
|
||||||
Term mod = (Term)read_uint(stream);
|
Term mod = (Term)read_uint(stream);
|
||||||
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__ , " after read_uint %x %p", mod, stream);
|
|
||||||
mod = MkAtomTerm(AtomAdjust(AtomOfTerm(mod)));
|
mod = MkAtomTerm(AtomAdjust(AtomOfTerm(mod)));
|
||||||
if (mod)
|
if (mod)
|
||||||
while ((x = read_tag(stream)) == QLY_START_PREDICATE) {
|
while ((x = read_tag(stream)) == QLY_START_PREDICATE) {
|
||||||
read_pred(stream, mod);
|
read_pred(stream, mod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__ , " %p", stream);
|
|
||||||
read_ops(stream);
|
read_ops(stream);
|
||||||
CloseHash();
|
CloseHash();
|
||||||
}
|
}
|
||||||
@ -1086,12 +1082,10 @@ Yap_Restore(char *s, char *lib_dir)
|
|||||||
IOSTREAM *stream = Yap_OpenRestore(s, lib_dir);
|
IOSTREAM *stream = Yap_OpenRestore(s, lib_dir);
|
||||||
if (!stream)
|
if (!stream)
|
||||||
return -1;
|
return -1;
|
||||||
__android_log_print(ANDROID_LOG_INFO, "qlyr.c", "loading startup %p", stream);
|
|
||||||
GLOBAL_RestoreFile = s;
|
GLOBAL_RestoreFile = s;
|
||||||
read_module(stream);
|
read_module(stream);
|
||||||
Sclose( stream );
|
Sclose( stream );
|
||||||
GLOBAL_RestoreFile = NULL;
|
GLOBAL_RestoreFile = NULL;
|
||||||
__android_log_print(ANDROID_LOG_INFO, "qlyr.c", "loading startup %p, done", stream);
|
|
||||||
return DO_ONLY_CODE;
|
return DO_ONLY_CODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
C/save.c
7
C/save.c
@ -250,12 +250,10 @@ open_file(char *my_file, int flag)
|
|||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
if (strstr(my_file, "/assets/") == my_file) {
|
if (strstr(my_file, "/assets/") == my_file) {
|
||||||
if (flag == O_RDONLY) {
|
if (flag == O_RDONLY) {
|
||||||
extern AAssetManager *assetManager;
|
|
||||||
my_file += strlen("/assets/");
|
my_file += strlen("/assets/");
|
||||||
AAsset* asset = AAssetManager_open(assetManager, my_file, AASSET_MODE_UNKNOWN);
|
AAsset* asset = AAssetManager_open(GLOBAL_assetManager, my_file, AASSET_MODE_UNKNOWN);
|
||||||
if (!asset)
|
if (!asset)
|
||||||
return -1;
|
return -1;
|
||||||
__android_log_print(ANDROID_LOG_ERROR, __FUNCTION__ , " %p", asset);
|
|
||||||
AAsset_close( asset );
|
AAsset_close( asset );
|
||||||
return 0; // usually the file will be compressed, so there is no point in actually trying to open it.
|
return 0; // usually the file will be compressed, so there is no point in actually trying to open it.
|
||||||
}
|
}
|
||||||
@ -1472,7 +1470,6 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
|
|||||||
if (!inpf)
|
if (!inpf)
|
||||||
inpf = YAPSTARTUP;
|
inpf = YAPSTARTUP;
|
||||||
#endif
|
#endif
|
||||||
__android_log_print(ANDROID_LOG_ERROR, "save.c", "saved state %s", inpf);
|
|
||||||
save_buffer[0] = '\0';
|
save_buffer[0] = '\0';
|
||||||
// LOCAL_ErrorMessage = NULL;
|
// LOCAL_ErrorMessage = NULL;
|
||||||
if (inpf == NULL) {
|
if (inpf == NULL) {
|
||||||
@ -1499,7 +1496,6 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
|
|||||||
!((splfild = open_file(inpf, O_RDONLY)) < 0))
|
!((splfild = open_file(inpf, O_RDONLY)) < 0))
|
||||||
{
|
{
|
||||||
if ((mode = try_open(inpf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) {
|
if ((mode = try_open(inpf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) {
|
||||||
__android_log_print(ANDROID_LOG_ERROR, "save.c", "saved state %p", *streamp);
|
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1605,7 +1601,6 @@ Yap_OpenRestore(char *inpf, char *YapLibDir)
|
|||||||
IOSTREAM *stream = NULL;
|
IOSTREAM *stream = NULL;
|
||||||
|
|
||||||
OpenRestore(inpf, YapLibDir, NULL, NULL, NULL, NULL, &stream);
|
OpenRestore(inpf, YapLibDir, NULL, NULL, NULL, NULL, &stream);
|
||||||
__android_log_print(ANDROID_LOG_ERROR, "save.c", "saved state %p", stream);
|
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
C/sysbits.c
30
C/sysbits.c
@ -134,7 +134,6 @@ Yap_WinError(char *yap_error)
|
|||||||
static int
|
static int
|
||||||
is_directory(char *FileName)
|
is_directory(char *FileName)
|
||||||
{
|
{
|
||||||
__android_log_print(ANDROID_LOG_INFO, __FUNCTION__, " %s ",FileName);
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
char s[YAP_FILENAME_MAX+1];
|
char s[YAP_FILENAME_MAX+1];
|
||||||
char *s0 = FileName;
|
char *s0 = FileName;
|
||||||
@ -2735,6 +2734,34 @@ p_yap_paths( USES_REGS1 ) {
|
|||||||
Yap_unify(out3,ARG3));
|
Yap_unify(out3,ARG3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Int
|
||||||
|
p_log_event( USES_REGS1 ) {
|
||||||
|
Term in = Deref(ARG1);
|
||||||
|
Atom at;
|
||||||
|
|
||||||
|
if (IsVarTerm(in))
|
||||||
|
return FALSE;
|
||||||
|
if (!IsAtomTerm(in))
|
||||||
|
return FALSE;
|
||||||
|
at = AtomOfTerm( in );
|
||||||
|
#if DEBUG
|
||||||
|
if (IsWideAtom(at) )
|
||||||
|
fprintf(stderr, "LOG %S\n", RepAtom(at)->WStrOfAE);
|
||||||
|
else if (IsBlob(at))
|
||||||
|
return FALSE;
|
||||||
|
else
|
||||||
|
fprintf(stderr, "LOG %s\n", RepAtom(at)->StrOfAE);
|
||||||
|
#endif
|
||||||
|
if (IsWideAtom(at) || IsBlob(at))
|
||||||
|
return FALSE;
|
||||||
|
#if __ANDROID__
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "YAP", " %s ",RepAtom(at)->StrOfAE);
|
||||||
|
#endif
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
p_env_separator( USES_REGS1 ) {
|
p_env_separator( USES_REGS1 ) {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
@ -3065,6 +3092,7 @@ Yap_InitSysPreds(void)
|
|||||||
Yap_InitCPred ("set_random_state", 2, p_set_random_state, SafePredFlag);
|
Yap_InitCPred ("set_random_state", 2, p_set_random_state, SafePredFlag);
|
||||||
Yap_InitCPred ("release_random_state", 1, p_release_random_state, SafePredFlag);
|
Yap_InitCPred ("release_random_state", 1, p_release_random_state, SafePredFlag);
|
||||||
#endif
|
#endif
|
||||||
|
Yap_InitCPred ("log_event", 1, p_log_event, SafePredFlag|SyncPredFlag);
|
||||||
Yap_InitCPred ("sh", 0, p_sh, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred ("sh", 0, p_sh, SafePredFlag|SyncPredFlag);
|
||||||
Yap_InitCPred ("$shell", 1, p_shell, SafePredFlag|SyncPredFlag|UserCPredFlag);
|
Yap_InitCPred ("$shell", 1, p_shell, SafePredFlag|SyncPredFlag|UserCPredFlag);
|
||||||
Yap_InitCPred ("system", 1, p_system, SafePredFlag|SyncPredFlag|UserCPredFlag);
|
Yap_InitCPred ("system", 1, p_system, SafePredFlag|SyncPredFlag|UserCPredFlag);
|
||||||
|
17
C/write.c
17
C/write.c
@ -574,7 +574,6 @@ putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb)
|
|||||||
wtype atom_or_symbol;
|
wtype atom_or_symbol;
|
||||||
wrf stream = wglb->stream;
|
wrf stream = wglb->stream;
|
||||||
|
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "AA LCL0=(%p) %p", LCL0, &LCL0 ); }
|
|
||||||
if (IsBlob(atom)) {
|
if (IsBlob(atom)) {
|
||||||
wrputblob(RepAtom(atom),Quote_illegal,wglb);
|
wrputblob(RepAtom(atom),Quote_illegal,wglb);
|
||||||
return;
|
return;
|
||||||
@ -594,11 +593,7 @@ putAtom(Atom atom, int Quote_illegal, struct write_globs *wglb)
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "AB LCL0=(%p) %p", LCL0, &LCL0 ); }
|
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "AB LCL0=(%p) %p", LCL0, RepAtom(atom)->StrOfAE ); }
|
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "AB LCL0=(%p) %c", LCL0, RepAtom(atom)->StrOfAE[0]); }
|
|
||||||
s = (unsigned char *)RepAtom(atom)->StrOfAE;
|
s = (unsigned char *)RepAtom(atom)->StrOfAE;
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "AC %s LCL0=(%p) %p", s, LCL0, &LCL0 ); }
|
|
||||||
/* #define CRYPT_FOR_STEVE 1*/
|
/* #define CRYPT_FOR_STEVE 1*/
|
||||||
#ifdef CRYPT_FOR_STEVE
|
#ifdef CRYPT_FOR_STEVE
|
||||||
if (Yap_GetValue(AtomCryptAtoms) != TermNil && Yap_GetAProp(atom, OpProperty) == NIL) {
|
if (Yap_GetValue(AtomCryptAtoms) != TermNil && Yap_GetAProp(atom, OpProperty) == NIL) {
|
||||||
@ -891,16 +886,12 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
|||||||
if (EX)
|
if (EX)
|
||||||
return;
|
return;
|
||||||
t = Deref(t);
|
t = Deref(t);
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
|
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "V %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
|
|
||||||
write_var((CELL *)t, wglb, &nrwt);
|
write_var((CELL *)t, wglb, &nrwt);
|
||||||
} else if (IsIntTerm(t)) {
|
} else if (IsIntTerm(t)) {
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
|
|
||||||
|
|
||||||
wrputn((Int) IntOfTerm(t),wglb);
|
wrputn((Int) IntOfTerm(t),wglb);
|
||||||
} else if (IsAtomTerm(t)) {
|
} else if (IsAtomTerm(t)) {
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "A %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
|
|
||||||
putAtom(AtomOfTerm(t), wglb->Quote_illegal, wglb);
|
putAtom(AtomOfTerm(t), wglb->Quote_illegal, wglb);
|
||||||
} else if (IsPairTerm(t)) {
|
} else if (IsPairTerm(t)) {
|
||||||
if (wglb->Ignore_ops) {
|
if (wglb->Ignore_ops) {
|
||||||
@ -933,18 +924,14 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
|||||||
if (yap_flags[WRITE_QUOTED_STRING_FLAG] && IsCodesTerm(t)) {
|
if (yap_flags[WRITE_QUOTED_STRING_FLAG] && IsCodesTerm(t)) {
|
||||||
putString(t, wglb);
|
putString(t, wglb);
|
||||||
} else {
|
} else {
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
|
|
||||||
wrputc('[', wglb->stream);
|
wrputc('[', wglb->stream);
|
||||||
lastw = separator;
|
lastw = separator;
|
||||||
/* we assume t was already saved in the stack */
|
/* we assume t was already saved in the stack */
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "II %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
|
|
||||||
write_list(t, 0, depth, wglb, rwt);
|
write_list(t, 0, depth, wglb, rwt);
|
||||||
wrputc(']', wglb->stream);
|
wrputc(']', wglb->stream);
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "III II%d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
|
|
||||||
lastw = separator;
|
lastw = separator;
|
||||||
}
|
}
|
||||||
} else { /* compound term */
|
} else { /* compound term */
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
|
|
||||||
Functor functor = FunctorOfTerm(t);
|
Functor functor = FunctorOfTerm(t);
|
||||||
int Arity;
|
int Arity;
|
||||||
Atom atom;
|
Atom atom;
|
||||||
@ -1101,7 +1088,6 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
|||||||
} else if (!wglb->Ignore_ops &&
|
} else if (!wglb->Ignore_ops &&
|
||||||
Arity == 2 && Yap_IsInfixOp(atom, &op, &lp,
|
Arity == 2 && Yap_IsInfixOp(atom, &op, &lp,
|
||||||
&rp) ) {
|
&rp) ) {
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "II %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
|
|
||||||
Term tleft = ArgOfTerm(1, t);
|
Term tleft = ArgOfTerm(1, t);
|
||||||
Term tright = ArgOfTerm(2, t);
|
Term tright = ArgOfTerm(2, t);
|
||||||
int bracket_left =
|
int bracket_left =
|
||||||
@ -1119,9 +1105,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
|
|||||||
if (bracket_left) {
|
if (bracket_left) {
|
||||||
wropen_bracket(wglb, TRUE);
|
wropen_bracket(wglb, TRUE);
|
||||||
}
|
}
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "III %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
|
|
||||||
writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), lp, depth + 1, rinfixarg, wglb, &nrwt);
|
writeTerm(from_pointer(RepAppl(t)+1, &nrwt, wglb), lp, depth + 1, rinfixarg, wglb, &nrwt);
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "IV %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
|
|
||||||
t = AbsAppl(restore_from_write(&nrwt, wglb)-1);
|
t = AbsAppl(restore_from_write(&nrwt, wglb)-1);
|
||||||
if (bracket_left) {
|
if (bracket_left) {
|
||||||
wrclose_bracket(wglb, TRUE);
|
wrclose_bracket(wglb, TRUE);
|
||||||
@ -1256,7 +1240,6 @@ Yap_plwrite(Term t, void *mywrite, int max_depth, int flags, int priority)
|
|||||||
wglb.Ignore_ops = flags & Ignore_ops_f;
|
wglb.Ignore_ops = flags & Ignore_ops_f;
|
||||||
wglb.Write_strings = flags & BackQuote_String_f;
|
wglb.Write_strings = flags & BackQuote_String_f;
|
||||||
/* protect slots for portray */
|
/* protect slots for portray */
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "I %d LCL0=(%p) %p", t, LCL0, &LCL0 ); }
|
|
||||||
writeTerm(from_pointer(&t, &rwt, &wglb), priority, 1, FALSE, &wglb, &rwt);
|
writeTerm(from_pointer(&t, &rwt, &wglb), priority, 1, FALSE, &wglb, &rwt);
|
||||||
restore_from_write(&rwt, &wglb);
|
restore_from_write(&rwt, &wglb);
|
||||||
}
|
}
|
||||||
|
14
CXX/yapi.cpp
14
CXX/yapi.cpp
@ -256,7 +256,7 @@ bool YAPTerm::variant(YAPTerm t1) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
intptr_t YAPTerm::hash(size_t sz, size_t depth, bool variant) {
|
intptr_t YAPTerm::hashTerm(size_t sz, size_t depth, bool variant) {
|
||||||
intptr_t out;
|
intptr_t out;
|
||||||
|
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
@ -374,12 +374,14 @@ char *YAPAtom::getName(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
YAPPredicate::YAPPredicate(const char *s, Term **outp, term_t &vnames) {
|
YAPPredicate::YAPPredicate(const char *s, Term **outp, term_t &vnames) throw (int) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
vnames = Yap_NewSlots(1 PASS_REGS);
|
vnames = Yap_NewSlots(1 PASS_REGS);
|
||||||
Term t = Yap_StringToTerm(s, strlen(s)+1, vnames);
|
Term t = Yap_StringToTerm(s, strlen(s)+1, vnames);
|
||||||
|
if (t == 0L)
|
||||||
|
throw YAPError::SYNTAX_ERROR;
|
||||||
ap = getPred( t, outp );
|
ap = getPred( t, outp );
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "OUT vnames=%d ap=%p LCL0=%p", vnames, ap, LCL0) ; }
|
//{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "OUT vnames=%d ap=%p LCL0=%p", vnames, ap, LCL0) ; }
|
||||||
}
|
}
|
||||||
|
|
||||||
YAPPredicate::YAPPredicate(YAPAtom at) {
|
YAPPredicate::YAPPredicate(YAPAtom at) {
|
||||||
@ -477,7 +479,6 @@ YAPQuery::YAPQuery(YAPPredicate p, YAPTerm t[]): YAPPredicate(p.ap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
YAPListTerm YAPQuery::namedVars() {
|
YAPListTerm YAPQuery::namedVars() {
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "vnames=%d LCL0=%p %x", vnames, LCL0, LCL0[vnames]) ; }
|
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Term o = Yap_GetFromSlot( vnames PASS_REGS );
|
Term o = Yap_GetFromSlot( vnames PASS_REGS );
|
||||||
return YAPListTerm( o );
|
return YAPListTerm( o );
|
||||||
@ -487,7 +488,6 @@ bool YAPQuery::next()
|
|||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
int result;
|
int result;
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, " CALL vnames=%d ap=%p LCL0=%p %x", vnames, ap, LCL0, LCL0[vnames]) ; }
|
|
||||||
if (this->q_open != 1) return false;
|
if (this->q_open != 1) return false;
|
||||||
if (setjmp(((YAPQuery *)LOCAL_execution)->q_env))
|
if (setjmp(((YAPQuery *)LOCAL_execution)->q_env))
|
||||||
return false;
|
return false;
|
||||||
@ -501,12 +501,10 @@ bool YAPQuery::next()
|
|||||||
result = (bool)YAP_RetryGoal(&this->q_h);
|
result = (bool)YAP_RetryGoal(&this->q_h);
|
||||||
}
|
}
|
||||||
this->q_state = 1;
|
this->q_state = 1;
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "FAIL vnames=%d %d LCL0=(%p) %x", vnames, result, LCL0, LCL0[vnames]) ; }
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
YAP_LeaveGoal(FALSE, &this->q_h);
|
YAP_LeaveGoal(FALSE, &this->q_h);
|
||||||
this->q_open = 0;
|
this->q_open = 0;
|
||||||
}
|
}
|
||||||
{ CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "SUCCESS vnames=%d ap=%p LCL0=(%p) %x", vnames, ap, LCL0, LCL0[vnames]) ; }
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -599,7 +597,7 @@ YAPEngine::YAPEngine( char *savedState,
|
|||||||
YAPCallback *cb): _callback(0)
|
YAPCallback *cb): _callback(0)
|
||||||
{ // a single engine can be active
|
{ // a single engine can be active
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
if (assetManager == (AAssetManager *)NULL)
|
if (GLOBAL_assetManager == (AAssetManager *)NULL)
|
||||||
return;
|
return;
|
||||||
Yap_DisplayWithJava = displayWithJava;
|
Yap_DisplayWithJava = displayWithJava;
|
||||||
Yap_AndroidBufp = (char *)malloc(Yap_AndroidMax = 4096);
|
Yap_AndroidBufp = (char *)malloc(Yap_AndroidMax = 4096);
|
||||||
|
18
CXX/yapi.hh
18
CXX/yapi.hh
@ -18,6 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
// Bad export from Python
|
||||||
|
#ifdef HAVE_STAT
|
||||||
|
#undef HAVE_STAT
|
||||||
|
#endif
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -90,6 +94,8 @@ class YAPApplTerm;
|
|||||||
class YAPPairTerm;
|
class YAPPairTerm;
|
||||||
class YAPQuery;
|
class YAPQuery;
|
||||||
|
|
||||||
|
#include "yapie.hh"
|
||||||
|
|
||||||
class TypeError {};
|
class TypeError {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,7 +132,7 @@ public:
|
|||||||
bool unify(YAPTerm t1); /// t = t1
|
bool unify(YAPTerm t1); /// t = t1
|
||||||
bool unifiable(YAPTerm t1); /// we can unify t and t1
|
bool unifiable(YAPTerm t1); /// we can unify t and t1
|
||||||
bool variant(YAPTerm t1); /// t =@= t1, the two terms are equal up to variable renaming
|
bool variant(YAPTerm t1); /// t =@= t1, the two terms are equal up to variable renaming
|
||||||
intptr_t hash(size_t sz, size_t depth, bool variant); /// term hash,
|
intptr_t hashTerm(size_t sz, size_t depth, bool variant); /// term hash,
|
||||||
bool isVar() { return IsVarTerm( gt() ); } /// type check for unbound
|
bool isVar() { return IsVarTerm( gt() ); } /// type check for unbound
|
||||||
bool isAtom() { return IsAtomTerm( gt() ); } /// type check for atom
|
bool isAtom() { return IsAtomTerm( gt() ); } /// type check for atom
|
||||||
bool isInteger() { return IsIntegerTerm( gt() ); } /// type check for integer
|
bool isInteger() { return IsIntegerTerm( gt() ); } /// type check for integer
|
||||||
@ -356,7 +362,7 @@ private:
|
|||||||
///
|
///
|
||||||
/// It also communicates the array of arguments t[] abd the array of variables
|
/// It also communicates the array of arguments t[] abd the array of variables
|
||||||
/// back to yapquery
|
/// back to yapquery
|
||||||
YAPPredicate(const char *s, Term **outp, yhandle_t& vnames );
|
YAPPredicate(const char *s, Term **outp, yhandle_t& vnames ) throw (int);
|
||||||
|
|
||||||
/// Term constructor for predicates
|
/// Term constructor for predicates
|
||||||
///
|
///
|
||||||
@ -415,9 +421,11 @@ public:
|
|||||||
/// String constructor for predicates.
|
/// String constructor for predicates.
|
||||||
///
|
///
|
||||||
/// String is a Prolog term, we extract the main functor after considering the module qualifiers.
|
/// String is a Prolog term, we extract the main functor after considering the module qualifiers.
|
||||||
inline YAPPredicate(char *s) {
|
inline YAPPredicate(char *s) throw (int) {
|
||||||
Term t, tp;
|
Term t, tp;
|
||||||
t = YAP_ReadBuffer(s,&tp);
|
t = YAP_ReadBuffer(s,&tp);
|
||||||
|
if (t == 0L)
|
||||||
|
throw YAPError::SYNTAX_ERROR;
|
||||||
ap = getPred( t, (Term **)NULL );
|
ap = getPred( t, (Term **)NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,9 +433,11 @@ public:
|
|||||||
/// String constructor for predicates, also keeps arguments in tp[]
|
/// String constructor for predicates, also keeps arguments in tp[]
|
||||||
///
|
///
|
||||||
/// String is a Prolog term, we extract the main functor after considering the module qualifiers.
|
/// String is a Prolog term, we extract the main functor after considering the module qualifiers.
|
||||||
inline YAPPredicate(char *s, Term **outp) {
|
inline YAPPredicate(char *s, Term **outp) throw (int) {
|
||||||
Term t, tp;
|
Term t, tp;
|
||||||
t = YAP_ReadBuffer(s,&tp);
|
t = YAP_ReadBuffer(s,&tp);
|
||||||
|
if (t == 0L)
|
||||||
|
throw YAPError::SYNTAX_ERROR;
|
||||||
ap = getPred( t, (Term **)NULL );
|
ap = getPred( t, (Term **)NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
H/Yap.h
4
H/Yap.h
@ -37,6 +37,10 @@
|
|||||||
#error THREADS only works with YAPOR_THREADS
|
#error THREADS only works with YAPOR_THREADS
|
||||||
#endif /* THREADS && (YAPOR_COW || YAPOR_SBA || YAPOR_COPY) */
|
#endif /* THREADS && (YAPOR_COW || YAPOR_SBA || YAPOR_COPY) */
|
||||||
|
|
||||||
|
// Bad export from Python
|
||||||
|
#ifdef HAVE_STAT
|
||||||
|
#undef HAVE_STAT
|
||||||
|
#endif
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#define FunAdr(X) X
|
#define FunAdr(X) X
|
||||||
|
@ -34,6 +34,10 @@
|
|||||||
|
|
||||||
#define GLOBAL_AGcThreshold Yap_global->AGcThreshold_
|
#define GLOBAL_AGcThreshold Yap_global->AGcThreshold_
|
||||||
#define GLOBAL_AGCHook Yap_global->AGCHook_
|
#define GLOBAL_AGCHook Yap_global->AGCHook_
|
||||||
|
#if __ANDROID__
|
||||||
|
|
||||||
|
#define GLOBAL_assetManager Yap_global->assetManager_
|
||||||
|
#endif
|
||||||
|
|
||||||
#if THREADS
|
#if THREADS
|
||||||
|
|
||||||
|
11
H/dlocals.h
11
H/dlocals.h
@ -97,14 +97,14 @@
|
|||||||
#define REMOTE_ScannerExtraBlocks(wid) REMOTE(wid)->ScannerExtraBlocks_
|
#define REMOTE_ScannerExtraBlocks(wid) REMOTE(wid)->ScannerExtraBlocks_
|
||||||
#define LOCAL_BallTerm LOCAL->BallTerm_
|
#define LOCAL_BallTerm LOCAL->BallTerm_
|
||||||
#define REMOTE_BallTerm(wid) REMOTE(wid)->BallTerm_
|
#define REMOTE_BallTerm(wid) REMOTE(wid)->BallTerm_
|
||||||
#define LOCAL_ActiveSignals LOCAL->ActiveSignals_
|
|
||||||
#define REMOTE_ActiveSignals(wid) REMOTE(wid)->ActiveSignals_
|
|
||||||
#define LOCAL_MaxActiveSignals LOCAL->MaxActiveSignals_
|
#define LOCAL_MaxActiveSignals LOCAL->MaxActiveSignals_
|
||||||
#define REMOTE_MaxActiveSignals(wid) REMOTE(wid)->MaxActiveSignals_
|
#define REMOTE_MaxActiveSignals(wid) REMOTE(wid)->MaxActiveSignals_
|
||||||
#define LOCAL_FirstActiveSignal LOCAL->FirstActiveSignal_
|
#define LOCAL_FirstActiveSignal LOCAL->FirstActiveSignal_
|
||||||
#define REMOTE_FirstActiveSignal(wid) REMOTE(wid)->FirstActiveSignal_
|
#define REMOTE_FirstActiveSignal(wid) REMOTE(wid)->FirstActiveSignal_
|
||||||
#define LOCAL_LastActiveSignal LOCAL->LastActiveSignal_
|
#define LOCAL_LastActiveSignal LOCAL->LastActiveSignal_
|
||||||
#define REMOTE_LastActiveSignal(wid) REMOTE(wid)->LastActiveSignal_
|
#define REMOTE_LastActiveSignal(wid) REMOTE(wid)->LastActiveSignal_
|
||||||
|
#define LOCAL_ActiveSignals LOCAL->ActiveSignals_
|
||||||
|
#define REMOTE_ActiveSignals(wid) REMOTE(wid)->ActiveSignals_
|
||||||
#define LOCAL_IPredArity LOCAL->IPredArity_
|
#define LOCAL_IPredArity LOCAL->IPredArity_
|
||||||
#define REMOTE_IPredArity(wid) REMOTE(wid)->IPredArity_
|
#define REMOTE_IPredArity(wid) REMOTE(wid)->IPredArity_
|
||||||
#define LOCAL_ProfEnd LOCAL->ProfEnd_
|
#define LOCAL_ProfEnd LOCAL->ProfEnd_
|
||||||
@ -404,6 +404,13 @@
|
|||||||
#define REMOTE_ImportFAILCODE(wid) REMOTE(wid)->ImportFAILCODE_
|
#define REMOTE_ImportFAILCODE(wid) REMOTE(wid)->ImportFAILCODE_
|
||||||
#define LOCAL_FunctorVar LOCAL->FunctorVar_
|
#define LOCAL_FunctorVar LOCAL->FunctorVar_
|
||||||
#define REMOTE_FunctorVar(wid) REMOTE(wid)->FunctorVar_
|
#define REMOTE_FunctorVar(wid) REMOTE(wid)->FunctorVar_
|
||||||
|
#if __ANDROID__
|
||||||
|
|
||||||
|
#define LOCAL_assetManager LOCAL->assetManager_
|
||||||
|
#define REMOTE_assetManager(wid) REMOTE(wid)->assetManager_
|
||||||
|
#define LOCAL_InAssetDir LOCAL->InAssetDir_
|
||||||
|
#define REMOTE_InAssetDir(wid) REMOTE(wid)->InAssetDir_
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LOCAL_ibnds LOCAL->ibnds_
|
#define LOCAL_ibnds LOCAL->ibnds_
|
||||||
#define REMOTE_ibnds(wid) REMOTE(wid)->ibnds_
|
#define REMOTE_ibnds(wid) REMOTE(wid)->ibnds_
|
||||||
|
@ -34,6 +34,10 @@ typedef struct global_data {
|
|||||||
|
|
||||||
UInt AGcThreshold_;
|
UInt AGcThreshold_;
|
||||||
Agc_hook AGCHook_;
|
Agc_hook AGCHook_;
|
||||||
|
#if __ANDROID__
|
||||||
|
|
||||||
|
struct AAssetManager* assetManager_;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if THREADS
|
#if THREADS
|
||||||
|
|
||||||
|
@ -55,10 +55,10 @@ typedef struct worker_local {
|
|||||||
char* ScannerStack_;
|
char* ScannerStack_;
|
||||||
struct scanner_extra_alloc* ScannerExtraBlocks_;
|
struct scanner_extra_alloc* ScannerExtraBlocks_;
|
||||||
struct DB_TERM* BallTerm_;
|
struct DB_TERM* BallTerm_;
|
||||||
UInt* ActiveSignals_;
|
|
||||||
UInt MaxActiveSignals_;
|
UInt MaxActiveSignals_;
|
||||||
UInt FirstActiveSignal_;
|
UInt FirstActiveSignal_;
|
||||||
UInt LastActiveSignal_;
|
UInt LastActiveSignal_;
|
||||||
|
UInt* ActiveSignals_;
|
||||||
UInt IPredArity_;
|
UInt IPredArity_;
|
||||||
yamop* ProfEnd_;
|
yamop* ProfEnd_;
|
||||||
int UncaughtThrow_;
|
int UncaughtThrow_;
|
||||||
@ -227,6 +227,11 @@ typedef struct worker_local {
|
|||||||
UInt ImportDBRefHashTableNum_;
|
UInt ImportDBRefHashTableNum_;
|
||||||
yamop *ImportFAILCODE_;
|
yamop *ImportFAILCODE_;
|
||||||
Functor FunctorVar_;
|
Functor FunctorVar_;
|
||||||
|
#if __ANDROID__
|
||||||
|
|
||||||
|
struct AAssetManager* assetManager_;
|
||||||
|
char* InAssetDir_;
|
||||||
|
#endif
|
||||||
|
|
||||||
UInt ibnds_[256];
|
UInt ibnds_[256];
|
||||||
struct index_t* exo_it_;
|
struct index_t* exo_it_;
|
||||||
@ -236,7 +241,7 @@ typedef struct worker_local {
|
|||||||
|
|
||||||
struct scan_atoms* search_atoms_;
|
struct scan_atoms* search_atoms_;
|
||||||
|
|
||||||
Int CurSlot_;
|
yhandle_t CurSlot_;
|
||||||
Term SourceModule_;
|
Term SourceModule_;
|
||||||
size_t MAX_SIZE_;
|
size_t MAX_SIZE_;
|
||||||
} w_local;
|
} w_local;
|
||||||
|
@ -34,6 +34,10 @@ static void InitGlobal(void) {
|
|||||||
|
|
||||||
GLOBAL_AGcThreshold = 10000;
|
GLOBAL_AGcThreshold = 10000;
|
||||||
GLOBAL_AGCHook = NULL;
|
GLOBAL_AGCHook = NULL;
|
||||||
|
#if __ANDROID__
|
||||||
|
|
||||||
|
GLOBAL_assetManager = GLOBAL_assetManager;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if THREADS
|
#if THREADS
|
||||||
|
|
||||||
|
@ -227,6 +227,11 @@ static void InitWorker(int wid) {
|
|||||||
REMOTE_ImportDBRefHashTableNum(wid) = 0;
|
REMOTE_ImportDBRefHashTableNum(wid) = 0;
|
||||||
REMOTE_ImportFAILCODE(wid) = NULL;
|
REMOTE_ImportFAILCODE(wid) = NULL;
|
||||||
REMOTE_FunctorVar(wid) = FunctorVar;
|
REMOTE_FunctorVar(wid) = FunctorVar;
|
||||||
|
#if __ANDROID__
|
||||||
|
|
||||||
|
REMOTE_assetManager(wid) = GLOBAL_assetManager;
|
||||||
|
REMOTE_InAssetDir(wid) = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
REMOTE_exo_it(wid) = NULL;
|
REMOTE_exo_it(wid) = NULL;
|
||||||
|
@ -34,6 +34,10 @@ static void RestoreGlobal(void) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if __ANDROID__
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#if THREADS
|
#if THREADS
|
||||||
|
|
||||||
|
@ -227,6 +227,11 @@ static void RestoreWorker(int wid USES_REGS) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if __ANDROID__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,17 +26,17 @@ extern int Yap_page_size;
|
|||||||
/* #define SHMMAX 0x800000 - 8 Mbytes: shmget limit for Solaris (?) */
|
/* #define SHMMAX 0x800000 - 8 Mbytes: shmget limit for Solaris (?) */
|
||||||
|
|
||||||
#if SIZEOF_INT_P == 4
|
#if SIZEOF_INT_P == 4
|
||||||
#define ALIGN 3
|
#define OPTYAP_ALIGN 3
|
||||||
#define ALIGNMASK 0xfffffffc
|
#define ALIGNMASK 0xfffffffc
|
||||||
#elif SIZEOF_INT_P == 8
|
#elif SIZEOF_INT_P == 8
|
||||||
#define ALIGN 7
|
#define OPTYAP_ALIGN 7
|
||||||
#define ALIGNMASK 0xfffffff8
|
#define ALIGNMASK 0xfffffff8
|
||||||
#else
|
#else
|
||||||
#define ALIGN OOOOPPS!!! Unknown Pointer Sizeof
|
#define ALIGN OOOOPPS!!! Unknown Pointer Sizeof
|
||||||
#define ALIGNMASK OOOOPPS!!! Unknown Pointer Sizeof
|
#define ALIGNMASK OOOOPPS!!! Unknown Pointer Sizeof
|
||||||
#endif /* SIZEOF_INT_P */
|
#endif /* SIZEOF_INT_P */
|
||||||
|
|
||||||
#define ADJUST_SIZE(SIZE) ((SIZE + ALIGN) & ALIGNMASK)
|
#define ADJUST_SIZE(SIZE) ((SIZE + OPTYAP_ALIGN) & ALIGNMASK)
|
||||||
#define ADJUST_SIZE_TO_PAGE(SIZE) ((SIZE) - (SIZE) % Yap_page_size + Yap_page_size)
|
#define ADJUST_SIZE_TO_PAGE(SIZE) ((SIZE) - (SIZE) % Yap_page_size + Yap_page_size)
|
||||||
#define PAGE_HEADER(STR) (pg_hd_ptr)((unsigned long int)STR - (unsigned long int)STR % Yap_page_size)
|
#define PAGE_HEADER(STR) (pg_hd_ptr)((unsigned long int)STR - (unsigned long int)STR % Yap_page_size)
|
||||||
#define STRUCT_NEXT(STR) ((STR)->next)
|
#define STRUCT_NEXT(STR) ((STR)->next)
|
||||||
|
@ -36,6 +36,10 @@ UInt SizeOfOverflow =0
|
|||||||
UInt AGcThreshold =10000
|
UInt AGcThreshold =10000
|
||||||
Agc_hook AGCHook =NULL
|
Agc_hook AGCHook =NULL
|
||||||
|
|
||||||
|
#if __ANDROID__
|
||||||
|
// no need to perform initialization, it is done before we start the Prolog engine.
|
||||||
|
struct AAssetManager* assetManager =GLOBAL_assetManager
|
||||||
|
#endif
|
||||||
|
|
||||||
/* multi-thread support */
|
/* multi-thread support */
|
||||||
#if THREADS
|
#if THREADS
|
||||||
|
@ -257,6 +257,13 @@ yamop *ImportFAILCODE =NULL
|
|||||||
|
|
||||||
Functor FunctorVar =FunctorVar
|
Functor FunctorVar =FunctorVar
|
||||||
|
|
||||||
|
#if __ANDROID__
|
||||||
|
// current virtual directory.
|
||||||
|
struct AAssetManager* assetManager =GLOBAL_assetManager
|
||||||
|
char* InAssetDir =NULL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// exo indexing
|
// exo indexing
|
||||||
|
|
||||||
UInt ibnds[256] void
|
UInt ibnds[256] void
|
||||||
@ -269,7 +276,7 @@ UInt exo_arg =0
|
|||||||
struct scan_atoms* search_atoms void
|
struct scan_atoms* search_atoms void
|
||||||
|
|
||||||
// Slots
|
// Slots
|
||||||
handle_t CurSlot =0
|
yhandle_t CurSlot =0
|
||||||
|
|
||||||
|
|
||||||
Term SourceModule =0
|
Term SourceModule =0
|
||||||
|
@ -373,8 +373,8 @@ PL_EXPORT(int) StryLock(IOSTREAM *s);
|
|||||||
PL_EXPORT(int) Sunlock(IOSTREAM *s);
|
PL_EXPORT(int) Sunlock(IOSTREAM *s);
|
||||||
PL_EXPORT(IOSTREAM *) Snew(void *handle, int flags, IOFUNCTIONS *functions);
|
PL_EXPORT(IOSTREAM *) Snew(void *handle, int flags, IOFUNCTIONS *functions);
|
||||||
PL_EXPORT(IOSTREAM *) Sopen_file(const char *path, const char *how);
|
PL_EXPORT(IOSTREAM *) Sopen_file(const char *path, const char *how);
|
||||||
#if __ANDROID__
|
#ifdef ANDROID_ASSET_MANAGER_H
|
||||||
PL_EXPORT(IOSTREAM *) Sopen_asset(char *bufp, const char *how);
|
PL_EXPORT(IOSTREAM *) Sopen_asset(char *bufp, const char *how, AAssetManager* mgr);
|
||||||
#endif
|
#endif
|
||||||
PL_EXPORT(IOSTREAM *) Sfdopen(int fd, const char *type);
|
PL_EXPORT(IOSTREAM *) Sfdopen(int fd, const char *type);
|
||||||
PL_EXPORT(int) Sfileno(IOSTREAM *s);
|
PL_EXPORT(int) Sfileno(IOSTREAM *s);
|
||||||
|
27
os/pl-file.c
27
os/pl-file.c
@ -3251,7 +3251,7 @@ openStream(term_t file, term_t mode, term_t options)
|
|||||||
{
|
{
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
if (strstr(path,"/assets/")) {
|
if (strstr(path,"/assets/")) {
|
||||||
if (!(s=Sopen_asset(path+8, "r")))
|
if (!(s=Sopen_asset(path+8, "r", GLOBAL_assetManager)))
|
||||||
{ PL_error(NULL, 0, OsError(), ERR_FILE_OPERATION,
|
{ PL_error(NULL, 0, OsError(), ERR_FILE_OPERATION,
|
||||||
ATOM_open, ATOM_source_sink, file);
|
ATOM_open, ATOM_source_sink, file);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -5143,6 +5143,31 @@ static const PL_extension foreigns[] = {
|
|||||||
LFRG((char *)NULL, 0, NULL, 0)
|
LFRG((char *)NULL, 0, NULL, 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if __ANDROID__
|
||||||
|
JNIEnv *Yap_jenv;
|
||||||
|
|
||||||
|
void Java_org_swig_simple_SwigSimple_load(JNIEnv *env0, jobject obj, jobject mgr);
|
||||||
|
|
||||||
|
void Java_org_swig_simple_SwigSimple_load
|
||||||
|
(JNIEnv *env0, jobject obj, jobject mgr0)
|
||||||
|
{
|
||||||
|
AAssetManager *mgr = AAssetManager_fromJava(env0, mgr0);
|
||||||
|
Yap_jenv = env0;
|
||||||
|
if (mgr == NULL) {
|
||||||
|
} else {
|
||||||
|
GLOBAL_assetManager = mgr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AAssetManager *Yap_assetManager( void );
|
||||||
|
|
||||||
|
AAssetManager *Yap_assetManager( void )
|
||||||
|
{
|
||||||
|
return GLOBAL_assetManager;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
struct PL_local_data *Yap_InitThreadIO(int wid)
|
struct PL_local_data *Yap_InitThreadIO(int wid)
|
||||||
{
|
{
|
||||||
struct PL_local_data *p;
|
struct PL_local_data *p;
|
||||||
|
140
os/pl-files.c
140
os/pl-files.c
@ -121,6 +121,29 @@ LastModifiedFile(const char *name, double *tp)
|
|||||||
#else
|
#else
|
||||||
char tmp[MAXPATHLEN];
|
char tmp[MAXPATHLEN];
|
||||||
statstruct buf;
|
statstruct buf;
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
if (strstr(name,"/assets")) {
|
||||||
|
AAssetManager* mgr = GLOBAL_assetManager;
|
||||||
|
*tp = (double)0;
|
||||||
|
if (!strcmp(name,"/assets"))
|
||||||
|
return TRUE;
|
||||||
|
const char *bufp=name+strlen("/assets/");
|
||||||
|
// check if file is a directory.
|
||||||
|
AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp);
|
||||||
|
if (assetDir) {
|
||||||
|
const char *ptr = AAssetDir_getNextFileName(assetDir) ;
|
||||||
|
AAssetDir_close(assetDir);
|
||||||
|
if (ptr)
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
AAsset *asset = AAssetManager_open(mgr, bufp, AASSET_MODE_UNKNOWN);
|
||||||
|
if (!asset)
|
||||||
|
return FALSE;
|
||||||
|
AAsset_close(asset);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( statfunc(OsPath(name, tmp), &buf) < 0 )
|
if ( statfunc(OsPath(name, tmp), &buf) < 0 )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -178,6 +201,29 @@ LastModifiedFile64(const char *name, int64_t *tp)
|
|||||||
#else
|
#else
|
||||||
char tmp[MAXPATHLEN];
|
char tmp[MAXPATHLEN];
|
||||||
statstruct buf;
|
statstruct buf;
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
if (strstr(name,"/assets")) {
|
||||||
|
AAssetManager* mgr = GLOBAL_assetManager;
|
||||||
|
*tp = (int64_t)0;
|
||||||
|
if (!strcmp(name,"/assets"))
|
||||||
|
return TRUE;
|
||||||
|
const char *bufp=name+strlen("/assets/");
|
||||||
|
// check if file is a directory.
|
||||||
|
AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp);
|
||||||
|
if (assetDir) {
|
||||||
|
const char *ptr = AAssetDir_getNextFileName(assetDir) ;
|
||||||
|
AAssetDir_close(assetDir);
|
||||||
|
if (ptr)
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
AAsset *asset = AAssetManager_open(mgr, bufp, AASSET_MODE_UNKNOWN);
|
||||||
|
if (!asset)
|
||||||
|
return FALSE;
|
||||||
|
AAsset_close(asset);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( statfunc(OsPath(name, tmp), &buf) < 0 )
|
if ( statfunc(OsPath(name, tmp), &buf) < 0 )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -199,6 +245,28 @@ SizeFile(const char *path)
|
|||||||
{ char tmp[MAXPATHLEN];
|
{ char tmp[MAXPATHLEN];
|
||||||
statstruct buf;
|
statstruct buf;
|
||||||
|
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
if (strstr(path,"/assets")) {
|
||||||
|
AAssetManager* mgr = GLOBAL_assetManager;
|
||||||
|
if (!strcmp(path,"/assets"))
|
||||||
|
return 0;
|
||||||
|
const char *bufp=path+strlen("/assets/");
|
||||||
|
// check if file is a directory.
|
||||||
|
AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp);
|
||||||
|
if (assetDir) {
|
||||||
|
const char *ptr = AAssetDir_getNextFileName(assetDir) ;
|
||||||
|
AAssetDir_close(assetDir);
|
||||||
|
if (ptr)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
AAsset *asset = AAssetManager_open(mgr, bufp, AASSET_MODE_UNKNOWN);
|
||||||
|
if (!asset)
|
||||||
|
return -1;
|
||||||
|
AAsset_close(asset);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
if ( statfunc(OsPath(path, tmp), &buf) < 0 )
|
if ( statfunc(OsPath(path, tmp), &buf) < 0 )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -220,6 +288,36 @@ ACCESS_WRITE and ACCESS_EXECUTE.
|
|||||||
int
|
int
|
||||||
AccessFile(const char *path, int mode)
|
AccessFile(const char *path, int mode)
|
||||||
{ char tmp[MAXPATHLEN];
|
{ char tmp[MAXPATHLEN];
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
if (strstr(path,"/assets")) {
|
||||||
|
AAssetManager* mgr = GLOBAL_assetManager;
|
||||||
|
if (!strcmp(path,"/assets"))
|
||||||
|
return !(mode & ACCESS_WRITE );
|
||||||
|
const char *bufp=path+strlen("/assets/");
|
||||||
|
// check if file is a directory.
|
||||||
|
AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp);
|
||||||
|
if (assetDir) {
|
||||||
|
const char *ptr = AAssetDir_getNextFileName(assetDir) ;
|
||||||
|
AAssetDir_close(assetDir);
|
||||||
|
if (ptr)
|
||||||
|
return !(mode & ACCESS_WRITE );
|
||||||
|
}
|
||||||
|
AAsset *asset = AAssetManager_open(mgr, bufp, AASSET_MODE_UNKNOWN);
|
||||||
|
if (!asset)
|
||||||
|
return FALSE;
|
||||||
|
AAsset_close(asset);
|
||||||
|
if ( mode == ACCESS_EXIST )
|
||||||
|
return TRUE;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( mode & ACCESS_WRITE ) return FALSE;
|
||||||
|
#ifdef X_OK
|
||||||
|
if ( mode & ACCESS_EXECUTE ) return FALSE;
|
||||||
|
#endif
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef HAVE_ACCESS
|
#ifdef HAVE_ACCESS
|
||||||
int m = 0;
|
int m = 0;
|
||||||
|
|
||||||
@ -249,6 +347,27 @@ ExistsFile(const char *path)
|
|||||||
char tmp[MAXPATHLEN];
|
char tmp[MAXPATHLEN];
|
||||||
statstruct buf;
|
statstruct buf;
|
||||||
|
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
if (strstr(path,"/assets")) {
|
||||||
|
AAssetManager* mgr = GLOBAL_assetManager;
|
||||||
|
if (!strcmp(path,"/assets"))
|
||||||
|
return TRUE;
|
||||||
|
const char *bufp=path+strlen("/assets/");
|
||||||
|
// check if file is a directory.
|
||||||
|
AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp);
|
||||||
|
if (assetDir) {
|
||||||
|
const char *ptr = AAssetDir_getNextFileName(assetDir) ;
|
||||||
|
AAssetDir_close(assetDir);
|
||||||
|
if (ptr)
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
AAsset *asset = AAssetManager_open(mgr, bufp, AASSET_MODE_UNKNOWN);
|
||||||
|
if (!asset)
|
||||||
|
return FALSE;
|
||||||
|
AAsset_close(asset);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if ( statfunc(OsPath(path, tmp), &buf) == -1 || !S_ISREG(buf.st_mode) )
|
if ( statfunc(OsPath(path, tmp), &buf) == -1 || !S_ISREG(buf.st_mode) )
|
||||||
{ DEBUG(2, perror(tmp));
|
{ DEBUG(2, perror(tmp));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -268,6 +387,24 @@ ExistsDirectory(const char *path)
|
|||||||
char *ospath = OsPath(path, tmp);
|
char *ospath = OsPath(path, tmp);
|
||||||
statstruct buf;
|
statstruct buf;
|
||||||
|
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
if (strstr(ospath,"/assets")) {
|
||||||
|
AAssetManager* mgr = GLOBAL_assetManager;
|
||||||
|
const char *ptr = NULL;
|
||||||
|
|
||||||
|
if (!strcmp(path,"/assets"))
|
||||||
|
return TRUE;
|
||||||
|
const char *bufp=path+strlen("/assets/");
|
||||||
|
// check if file is a directory.
|
||||||
|
AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp);
|
||||||
|
if (assetDir)
|
||||||
|
ptr = AAssetDir_getNextFileName(assetDir);
|
||||||
|
if (assetDir) {
|
||||||
|
AAssetDir_close(assetDir);
|
||||||
|
}
|
||||||
|
return ptr != NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if ( statfunc(ospath, &buf) < 0 )
|
if ( statfunc(ospath, &buf) < 0 )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -1016,7 +1153,8 @@ PRED_IMPL("working_directory", 2, working_directory, 0)
|
|||||||
{ char *n;
|
{ char *n;
|
||||||
|
|
||||||
if ( PL_get_file_name(new, &n, 0) )
|
if ( PL_get_file_name(new, &n, 0) )
|
||||||
{ if ( ChDir(n) )
|
{
|
||||||
|
if ( ChDir(n) )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if ( truePrologFlag(PLFLAG_FILEERRORS) )
|
if ( truePrologFlag(PLFLAG_FILEERRORS) )
|
||||||
|
56
os/pl-os.c
56
os/pl-os.c
@ -1525,10 +1525,6 @@ PL_changed_cwd(void)
|
|||||||
UNLOCK();
|
UNLOCK();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __ANDROID__
|
|
||||||
char *Yap_InAssetDir;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
cwd_unlocked(char *cwd, size_t cwdlen)
|
cwd_unlocked(char *cwd, size_t cwdlen)
|
||||||
{ GET_LD
|
{ GET_LD
|
||||||
@ -1548,9 +1544,9 @@ to be implemented directly. What about other Unixes?
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
if (Yap_InAssetDir) {
|
if (LOCAL_InAssetDir) {
|
||||||
rval = strncpy(buf, Yap_InAssetDir, sizeof(buf));
|
rval = strncpy(buf, LOCAL_InAssetDir, sizeof(buf));
|
||||||
}
|
} else
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_GETWD) && !defined(HAVE_GETCWD)
|
#if defined(HAVE_GETWD) && !defined(HAVE_GETCWD)
|
||||||
rval = getwd(buf);
|
rval = getwd(buf);
|
||||||
@ -1647,9 +1643,6 @@ bool
|
|||||||
ChDir(const char *path)
|
ChDir(const char *path)
|
||||||
{ char ospath[MAXPATHLEN];
|
{ char ospath[MAXPATHLEN];
|
||||||
char tmp[MAXPATHLEN];
|
char tmp[MAXPATHLEN];
|
||||||
int hyper_path = FALSE;
|
|
||||||
|
|
||||||
__android_log_print(ANDROID_LOG_INFO, __FUNCTION__, " %s ",ospath);
|
|
||||||
|
|
||||||
OsPath(path, ospath);
|
OsPath(path, ospath);
|
||||||
|
|
||||||
@ -1662,37 +1655,38 @@ ChDir(const char *path)
|
|||||||
/* treat "/assets" as a directory (actually as a mounted file system).
|
/* treat "/assets" as a directory (actually as a mounted file system).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
if (LOCAL_InAssetDir) {
|
||||||
|
free(LOCAL_InAssetDir);
|
||||||
|
LOCAL_InAssetDir = NULL;
|
||||||
|
}
|
||||||
if (strstr(ospath, "/assets/") == ospath) {
|
if (strstr(ospath, "/assets/") == ospath) {
|
||||||
extern AAssetManager *assetManager;
|
|
||||||
const char *dirName = ospath+strlen("/assets/");
|
const char *dirName = ospath+strlen("/assets/");
|
||||||
AAssetManager* mgr = assetManager;
|
AAssetManager* mgr = GLOBAL_assetManager;
|
||||||
AAssetDir* dir;
|
AAssetDir* dir;
|
||||||
|
|
||||||
if (( dir = AAssetManager_openDir(mgr, dirName))) {
|
if (( dir = AAssetManager_openDir(mgr, dirName) ) &&
|
||||||
|
AAssetDir_getNextFileName( dir ) ) {
|
||||||
|
// valid directpry
|
||||||
|
size_t sz = strlen(ospath)+1;
|
||||||
AAssetDir_close(dir);
|
AAssetDir_close(dir);
|
||||||
hyper_path = TRUE;
|
LOCAL_InAssetDir = (char *)malloc(sz);
|
||||||
|
strncpy(LOCAL_InAssetDir, ospath, sz-1);
|
||||||
|
succeed;
|
||||||
|
} else {
|
||||||
|
fail;
|
||||||
}
|
}
|
||||||
hyper_path = FALSE;
|
} else if ( !strcmp(ospath,"/assets") ||
|
||||||
} else if (!strcmp(ospath, "/assets"))
|
!strcmp(ospath,"/assets/") ) {
|
||||||
hyper_path = TRUE;
|
// valid directpry
|
||||||
if (hyper_path) {
|
size_t sz = strlen("/assets")+1;
|
||||||
if (Yap_InAssetDir) {
|
LOCAL_InAssetDir = (char *)malloc(sz);
|
||||||
free(Yap_InAssetDir);
|
strncpy(LOCAL_InAssetDir, ospath, sz);
|
||||||
Yap_InAssetDir = NULL;
|
succeed;
|
||||||
}
|
|
||||||
Yap_InAssetDir = (char *)malloc(strlen(ospath)+1);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( hyper_path ||
|
if ( chdir(ospath) == 0 )
|
||||||
chdir(ospath) == 0 )
|
|
||||||
{ size_t len;
|
{ size_t len;
|
||||||
#if __ANDROID__
|
|
||||||
if (Yap_InAssetDir) {
|
|
||||||
free(Yap_InAssetDir);
|
|
||||||
Yap_InAssetDir = NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
len = strlen(tmp);
|
len = strlen(tmp);
|
||||||
if ( len == 0 || tmp[len-1] != '/' )
|
if ( len == 0 || tmp[len-1] != '/' )
|
||||||
{ tmp[len++] = '/';
|
{ tmp[len++] = '/';
|
||||||
|
@ -895,7 +895,6 @@ put_code(int c, IOSTREAM *s)
|
|||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
|
|
||||||
if (Yap_AndroidBufp && (s == Soutput || s == Serror) ) {
|
if (Yap_AndroidBufp && (s == Soutput || s == Serror) ) {
|
||||||
__android_log_print(ANDROID_LOG_INFO, __FUNCTION__, "get char %c %p",c, Yap_AndroidBufp);
|
|
||||||
(Yap_DisplayWithJava)(c);
|
(Yap_DisplayWithJava)(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2903,8 +2902,9 @@ Sopen_file(const char *path, const char *how)
|
|||||||
|
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
if (strstr(path, "/assets/") == path) {
|
if (strstr(path, "/assets/") == path) {
|
||||||
|
AAssetManager *Yap_assetManager( void );
|
||||||
char * p = (char *)path + strlen("/assets/");
|
char * p = (char *)path + strlen("/assets/");
|
||||||
return Sopen_asset( p, how-1);
|
return Sopen_asset( p, how-1, Yap_assetManager());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -3311,23 +3311,6 @@ IOFUNCTIONS Sassetfunctions =
|
|||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
AAssetManager *assetManager;
|
|
||||||
JNIEnv *env;
|
|
||||||
|
|
||||||
void Java_org_swig_simple_SwigSimple_load(JNIEnv *env0, jobject obj, jobject mgr);
|
|
||||||
|
|
||||||
void Java_org_swig_simple_SwigSimple_load
|
|
||||||
(JNIEnv *env0, jobject obj, jobject mgr)
|
|
||||||
{
|
|
||||||
assetManager = AAssetManager_fromJava(env0, mgr);
|
|
||||||
env = env0;
|
|
||||||
if (assetManager == NULL) {
|
|
||||||
__android_log_print(ANDROID_LOG_DEBUG, "os-stream.c", "error loading asset manager");
|
|
||||||
} else {
|
|
||||||
__android_log_print(ANDROID_LOG_DEBUG, "os-stream.c", "loaded asset manager");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Sopen_asset(char **buffer, size_t *sizep, const char* mode)
|
Sopen_asset(char **buffer, size_t *sizep, const char* mode)
|
||||||
@ -3335,14 +3318,13 @@ Sopen_asset(char **buffer, size_t *sizep, const char* mode)
|
|||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|
||||||
IOSTREAM *
|
IOSTREAM *
|
||||||
Sopen_asset(char *bufp, const char *how)
|
Sopen_asset(char *bufp, const char *how, AAssetManager* mgr)
|
||||||
{
|
{
|
||||||
AAsset* asset;
|
AAsset* asset;
|
||||||
int flags = SIO_FILE|SIO_TEXT|SIO_RECORDPOS|SIO_FBUF;
|
int flags = SIO_FILE|SIO_TEXT|SIO_RECORDPOS|SIO_FBUF;
|
||||||
int op = *how++;
|
int op = *how++;
|
||||||
IOSTREAM *s;
|
IOSTREAM *s;
|
||||||
IOENC enc = ENC_UNKNOWN;
|
IOENC enc = ENC_UNKNOWN;
|
||||||
AAssetManager* mgr = assetManager;
|
|
||||||
|
|
||||||
for( ; *how; how++)
|
for( ; *how; how++)
|
||||||
{ switch(*how)
|
{ switch(*how)
|
||||||
@ -3383,7 +3365,6 @@ Sopen_asset(char *bufp, const char *how)
|
|||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
__android_log_print(ANDROID_LOG_INFO, "os-stream.c", "got asset %s -> %p", bufp, asset);\
|
|
||||||
|
|
||||||
if ( !asset )
|
if ( !asset )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -38,7 +38,8 @@ jni/libyap.@SO@: jni/yap_wrap.o
|
|||||||
$(CXX) -shared $(LDSOFLAGS) -o $@ ../../yapi.o $< $(LIBS) @JPLLDFLAGS@ -L ../.. -lYap -lpthread
|
$(CXX) -shared $(LDSOFLAGS) -o $@ ../../yapi.o $< $(LIBS) @JPLLDFLAGS@ -L ../.. -lYap -lpthread
|
||||||
|
|
||||||
jni/yap_wrap.cpp java/yap.java: $(srcdir)/yap.i
|
jni/yap_wrap.cpp java/yap.java: $(srcdir)/yap.i
|
||||||
$(SWIG) -c++ -java -package pt.up.fc.dcc.yap -outdir java -o $@ $(CXXFLAGS) -Wall $<
|
mkdir -p jni
|
||||||
|
$(SWIG) -c++ -java -package pt.up.fc.dcc.yap -outdir java -o jni/yap_wrap.cpp $(CXXFLAGS) -Wall $<
|
||||||
|
|
||||||
jni/yap_wrap.o: jni/yap_wrap.cpp
|
jni/yap_wrap.o: jni/yap_wrap.cpp
|
||||||
$(CXX) -c $(CXXFLAGS) @JPLCFLAGS@ $< -o $@
|
$(CXX) -c $(CXXFLAGS) @JPLCFLAGS@ $< -o $@
|
||||||
|
@ -12,6 +12,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import java.text.ParseException;
|
||||||
|
|
||||||
public class SwigSimple extends Activity
|
public class SwigSimple extends Activity
|
||||||
{
|
{
|
||||||
@ -22,6 +23,39 @@ public class SwigSimple extends Activity
|
|||||||
String str;
|
String str;
|
||||||
String buf;
|
String buf;
|
||||||
|
|
||||||
|
void runQuery(String str)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
YAPQuery q = eng.query( str );
|
||||||
|
|
||||||
|
YAPListTerm vs0 = q.namedVars();
|
||||||
|
// text.setText("");
|
||||||
|
if (vs0.nil()) {
|
||||||
|
if (q.next()) {
|
||||||
|
outputText.append( "yes\n" );
|
||||||
|
} else {
|
||||||
|
outputText.append( "no\n" );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int i=1;
|
||||||
|
while (q.next()) {
|
||||||
|
YAPListTerm vs = vs0;
|
||||||
|
while(!vs.nil()){
|
||||||
|
YAPTerm eq = vs.car();
|
||||||
|
//outputText.append(Integer.toString(i) + ": " + eq.text() );
|
||||||
|
outputText.append(Integer.toString(i++) + ":\t" + eq.getArg(1).text() + " = " + eq.getArg(2).text() +"\n" );
|
||||||
|
vs = vs.cdr();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
q.close();
|
||||||
|
} catch(Exception e){
|
||||||
|
outputText.append("Exception thrown :" + e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
@ -44,7 +78,7 @@ public class SwigSimple extends Activity
|
|||||||
|
|
||||||
text = (EditText)findViewById(R.id.EditText01);
|
text = (EditText)findViewById(R.id.EditText01);
|
||||||
outputText = (TextView)findViewById(R.id.OutputText);
|
outputText = (TextView)findViewById(R.id.OutputText);
|
||||||
outputText.setText("Application " + s + "\nPress 'Run' to start...\n");
|
outputText.setText("Application " + s + "\nPress 'Query' to start...\n");
|
||||||
outputText.setMovementMethod(new ScrollingMovementMethod());
|
outputText.setMovementMethod(new ScrollingMovementMethod());
|
||||||
scroller = (ScrollView)findViewById(R.id.Scroller);
|
scroller = (ScrollView)findViewById(R.id.Scroller);
|
||||||
eng = new YAPEngine( );
|
eng = new YAPEngine( );
|
||||||
@ -57,10 +91,10 @@ public class SwigSimple extends Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onResetButtonClick(View view)
|
public void onClearButtonClick(View view)
|
||||||
{
|
{
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
Log.i(TAG, "onReseButtonClick called");
|
Log.i(TAG, "onClearButtonClick called");
|
||||||
}
|
}
|
||||||
// Ensure scroll to end of text
|
// Ensure scroll to end of text
|
||||||
scroller.post(new Runnable() {
|
scroller.post(new Runnable() {
|
||||||
@ -71,10 +105,10 @@ public class SwigSimple extends Activity
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRunButtonClick(View view)
|
public void onQueryButtonClick(View view)
|
||||||
{
|
{
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
Log.i(TAG, "onRunButtonClick 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() {
|
||||||
@ -82,36 +116,16 @@ public class SwigSimple extends Activity
|
|||||||
scroller.fullScroll(ScrollView.FOCUS_DOWN);
|
scroller.fullScroll(ScrollView.FOCUS_DOWN);
|
||||||
str = text.getText().toString();
|
str = text.getText().toString();
|
||||||
outputText.append("?- " + str);
|
outputText.append("?- " + str);
|
||||||
YAPQuery q = eng.query( str );
|
Log.i(TAG, "onQueryButtonClick "+str + "\n");
|
||||||
YAPListTerm vs = q.namedVars();
|
runQuery(str);
|
||||||
// text.setText("");
|
|
||||||
if (vs.nil()) {
|
|
||||||
if (q.next()) {
|
|
||||||
outputText.append( "yes\n" );
|
|
||||||
} else {
|
|
||||||
outputText.append( "no\n" );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
int i=1;
|
|
||||||
while (q.next()) {
|
|
||||||
// outputText.append(Integer.toString(i++) + ": " + vs.text() +"\n");
|
|
||||||
while(!vs.nil()){
|
|
||||||
YAPTerm eq = vs.car();
|
|
||||||
//outputText.append(Integer.toString(i) + ": " + eq.text() );
|
|
||||||
outputText.append(Integer.toString(i++) + ":\t" + eq.getArg(1).text() + " = " + eq.getArg(2).text() +"\n" );
|
|
||||||
vs = vs.cdr();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
q.close();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRunSelectionButtonClick(View view)
|
public void onQuerySelectionButtonClick(View view)
|
||||||
{
|
{
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
Log.i(TAG, "onRunButtonClick called");
|
Log.i(TAG, "onQuerySelectionButtonClick called");
|
||||||
}
|
}
|
||||||
// Ensure scroll to end of text
|
// Ensure scroll to end of text
|
||||||
scroller.post(new Runnable() {
|
scroller.post(new Runnable() {
|
||||||
@ -120,29 +134,9 @@ public class SwigSimple extends Activity
|
|||||||
int startSelection = text.getSelectionStart();
|
int startSelection = text.getSelectionStart();
|
||||||
int endSelection = text.getSelectionEnd();
|
int endSelection = text.getSelectionEnd();
|
||||||
str = text.getText().toString().substring( startSelection, endSelection );
|
str = text.getText().toString().substring( startSelection, endSelection );
|
||||||
outputText.append("?- " + str);
|
Log.i(TAG, "onQuerySelectionButtonClick "+str);
|
||||||
YAPQuery q = eng.query( str );
|
outputText.append("?- " + str + "\n");
|
||||||
YAPListTerm vs = q.namedVars();
|
runQuery(str);
|
||||||
// text.setText("");
|
|
||||||
if (vs.nil()) {
|
|
||||||
if (q.next()) {
|
|
||||||
outputText.append( "yes\n" );
|
|
||||||
} else {
|
|
||||||
outputText.append( "no\n" );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
while (q.next()) {
|
|
||||||
int i=1;
|
|
||||||
// outputText.append(Integer.toString(i++) + ": " + vs.text() +"\n");
|
|
||||||
while(!vs.nil()){
|
|
||||||
YAPTerm eq = vs.car();
|
|
||||||
//outputText.append(Integer.toString(i) + ": " + eq.text() );
|
|
||||||
outputText.append(Integer.toString(i++) + ":\t" + eq.getArg(1).text() + " = " + eq.getArg(2).text() +"\n" );
|
|
||||||
vs = vs.cdr();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
q.close();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,50 +1,29 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
android:orientation="vertical" android:layout_width="fill_parent"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent">
|
android:layout_height="fill_parent">
|
||||||
<LinearLayout
|
<LinearLayout android:orientation="horizontal"
|
||||||
android:orientation="horizontal"
|
android:layout_width="fill_parent" android:layout_height="wrap_content">
|
||||||
android:layout_width="fill_parent"
|
<EditText android:id="@+id/EditText01" android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content" android:layout_weight="1.0"
|
||||||
<EditText
|
|
||||||
android:id="@+id/EditText01"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1.0"
|
|
||||||
android:lines="6" />
|
android:lines="6" />
|
||||||
<Button
|
<LinearLayout android:orientation="vertical"
|
||||||
android:id="@+id/RunButton"
|
android:layout_width="wrap_content" android:layout_height="fill_parent">
|
||||||
android:layout_width="wrap_content"
|
<Button android:id="@+id/QueryButton" android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content" android:text="Query..."
|
||||||
android:text="Run..."
|
android:onClick="onQueryButtonClick" />
|
||||||
android:onClick="onRunButtonClick"
|
<Button android:id="@+id/QuerySelectionButton"
|
||||||
/>
|
android:layout_width="fill_parent" android:layout_height="wrap_content"
|
||||||
<Button
|
android:text="Select" android:onClick="onQuerySelectionButtonClick" />
|
||||||
android:id="@+id/RunSelectionButton"
|
<Button android:id="@+id/ClearButton" android:layout_width="fill_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="wrap_content" android:text="Reset"
|
||||||
android:layout_height="wrap_content"
|
android:onClick="onClearButtonClick" />
|
||||||
android:text="Select"
|
|
||||||
android:onClick="onRunSelectionButtonClick"
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
android:id="@+id/ClearButton"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Reset"
|
|
||||||
android:onClick="onClearButtonClick"
|
|
||||||
/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<ScrollView
|
</LinearLayout>
|
||||||
android:id="@+id/Scroller"
|
<ScrollView android:id="@+id/Scroller" android:layout_width="fill_parent"
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent">
|
android:layout_height="fill_parent">
|
||||||
<TextView
|
<TextView android:id="@+id/OutputText" android:layout_width="wrap_content"
|
||||||
android:id="@+id/OutputText"
|
android:layout_height="wrap_content" android:singleLine = "false"/>
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
/>
|
|
||||||
<!-- Set MaxLegth EditText -->
|
<!-- Set MaxLegth EditText -->
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -25,6 +25,7 @@ mkdir -p packages/swig/python
|
|||||||
mkdir -p packages/swig/R
|
mkdir -p packages/swig/R
|
||||||
mkdir -p packages/swig/java
|
mkdir -p packages/swig/java
|
||||||
mkdir -p packages/swig/fli
|
mkdir -p packages/swig/fli
|
||||||
|
mkdir -p packages/swig/jni
|
||||||
|
|
||||||
AC_SUBST(SWIG)
|
AC_SUBST(SWIG)
|
||||||
AC_SUBST(SWIG_TARGET)
|
AC_SUBST(SWIG_TARGET)
|
||||||
|
@ -9,7 +9,10 @@ engine = yap.YAPEngine();
|
|||||||
def go():
|
def go():
|
||||||
while True:
|
while True:
|
||||||
s = raw_input("Prolog Query: ")
|
s = raw_input("Prolog Query: ")
|
||||||
|
try:
|
||||||
q = engine.query(s)
|
q = engine.query(s)
|
||||||
|
except:
|
||||||
|
... print "Oops! That was no valid number. Try again..."
|
||||||
while q.next():
|
while q.next():
|
||||||
vs = q.namedVars();
|
vs = q.namedVars();
|
||||||
while vs.length() > 0:
|
while vs.length() > 0:
|
||||||
|
@ -26,6 +26,32 @@ extern "C" {
|
|||||||
/* turn on director wrapping Callback */
|
/* turn on director wrapping Callback */
|
||||||
%feature("director") YAPCallback;
|
%feature("director") YAPCallback;
|
||||||
|
|
||||||
|
class YAPPredicate;
|
||||||
|
|
||||||
|
#ifdef SWIGPYTHON
|
||||||
|
%exception YAPPredicate {
|
||||||
|
try {
|
||||||
|
$action
|
||||||
|
} catch (...) {
|
||||||
|
fprintf(stderr,"here\n");
|
||||||
|
PyErr_SetString(PyExc_SyntaxError, "syntax error");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
%include "yapi.hh"
|
%include "yapi.hh"
|
||||||
|
|
||||||
|
#ifdef SWIGJAVA
|
||||||
|
%javaexception("java.text.ParseException") YAPPredicate {
|
||||||
|
try {
|
||||||
|
$action
|
||||||
|
} catch (YAPError::SYNTAX_ERROR &e) {
|
||||||
|
jclass clazz = jenv->FindClass("java/text/ParseException");
|
||||||
|
jenv->ThrowNew(clazz, "Syntax error");
|
||||||
|
return $null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -329,7 +329,6 @@ absolute_file_name(File0,File) :-
|
|||||||
atom_concat([File,NExt],F).
|
atom_concat([File,NExt],F).
|
||||||
'$add_extensions'([_|Extensions],File,F) :-
|
'$add_extensions'([_|Extensions],File,F) :-
|
||||||
'$add_extensions'(Extensions,File,F).
|
'$add_extensions'(Extensions,File,F).
|
||||||
|
|
||||||
'$mk_sure_true_ext'(Ext,NExt) :-
|
'$mk_sure_true_ext'(Ext,NExt) :-
|
||||||
atom_codes(Ext,[C|L]),
|
atom_codes(Ext,[C|L]),
|
||||||
C \= 0'.,
|
C \= 0'.,
|
||||||
|
@ -1345,6 +1345,7 @@ catch_ball(C, C).
|
|||||||
fail.
|
fail.
|
||||||
'$run_at_thread_start'.
|
'$run_at_thread_start'.
|
||||||
|
|
||||||
|
log_event( String, Args ) :-
|
||||||
|
format( atom( M ), String, Args),
|
||||||
|
log_event( M ).
|
||||||
|
|
||||||
|
@ -91,6 +91,8 @@ otherwise.
|
|||||||
:- bootstrap('lists.yap').
|
:- bootstrap('lists.yap').
|
||||||
:- bootstrap('consult.yap').
|
:- bootstrap('consult.yap').
|
||||||
:- bootstrap('preddecls.yap').
|
:- bootstrap('preddecls.yap').
|
||||||
|
|
||||||
|
|
||||||
:- bootstrap('atoms.yap').
|
:- bootstrap('atoms.yap').
|
||||||
:- bootstrap('os.yap').
|
:- bootstrap('os.yap').
|
||||||
:- bootstrap('absf.yap').
|
:- bootstrap('absf.yap').
|
||||||
@ -137,6 +139,8 @@ otherwise.
|
|||||||
'qly.yap',
|
'qly.yap',
|
||||||
'udi.yap'].
|
'udi.yap'].
|
||||||
|
|
||||||
|
:- meta_predicate(log_event(+,:)).
|
||||||
|
|
||||||
:- dynamic prolog:'$user_defined_flag'/4.
|
:- dynamic prolog:'$user_defined_flag'/4.
|
||||||
|
|
||||||
:- dynamic prolog:'$parent_module'/2.
|
:- dynamic prolog:'$parent_module'/2.
|
||||||
|
@ -30,6 +30,7 @@ cd :-
|
|||||||
cd('~').
|
cd('~').
|
||||||
|
|
||||||
cd(F) :-
|
cd(F) :-
|
||||||
|
format( atom( M ), 'before absolute_file_name ~w', [F]), log_event( M ),
|
||||||
absolute_file_name(F, Dir, [file_type(directory),file_errors(fail),access(execute),expand(true)]),
|
absolute_file_name(F, Dir, [file_type(directory),file_errors(fail),access(execute),expand(true)]),
|
||||||
working_directory(_, Dir).
|
working_directory(_, Dir).
|
||||||
|
|
||||||
|
@ -303,5 +303,3 @@ nb_current(GlobalVariable, Val) :-
|
|||||||
|
|
||||||
subsumes_term(A,B) :-
|
subsumes_term(A,B) :-
|
||||||
\+ \+ terms:subsumes(A,B).
|
\+ \+ terms:subsumes(A,B).
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user