This commit is contained in:
Vitor Santos Costa 2018-06-15 11:09:04 +01:00
parent 31fd3eb344
commit 521a5df611
22 changed files with 86 additions and 86 deletions

View File

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

View File

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

View File

@ -633,6 +633,7 @@ type_of_verb(rest,passive).
*/
#include <Yatom.h>
#include "absmi.h"
#include "YapCompile.h"
#if DEBUG
@ -2940,13 +2941,15 @@ yamop *Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc) {
cint.cls = NULL;
LOCAL_Error_Size = 0;
if (ap->cs.p_code.NOfClauses < 2)
return NULL;
if ((setjres = sigsetjmp(cint.CompilerBotch, 0)) == 3) {
restore_machine_regs();
recover_from_failed_susp_on_cls(&cint, 0);
if (!Yap_gcl(LOCAL_Error_Size, ap->ArityOfPE + NSlots, ENV, next_pc)) {
CleanCls(&cint);
Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
return FAILCODE;
return NULL;
}
} else if (setjres == 2) {
restore_machine_regs();
@ -2954,7 +2957,7 @@ yamop *Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc) {
if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) {
CleanCls(&cint);
Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage);
return FAILCODE;
return NULL;
}
} else if (setjres == 4) {
restore_machine_regs();
@ -2962,7 +2965,7 @@ yamop *Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc) {
if (!Yap_growtrail(LOCAL_Error_Size, FALSE)) {
CleanCls(&cint);
Yap_Error(RESOURCE_ERROR_TRAIL, TermNil, LOCAL_ErrorMessage);
return FAILCODE;
return NULL;
}
} else if (setjres != 0) {
restore_machine_regs();
@ -2970,7 +2973,7 @@ yamop *Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc) {
if (!Yap_growheap(FALSE, LOCAL_Error_Size, NULL)) {
Yap_Error(RESOURCE_ERROR_HEAP, TermNil, LOCAL_ErrorMessage);
CleanCls(&cint);
return FAILCODE;
return NULL;
}
}
restart_index:
@ -2983,7 +2986,7 @@ restart_index:
if (compile_index(&cint) == (UInt)FAILCODE) {
Yap_ReleaseCMem(&cint);
CleanCls(&cint);
return FAILCODE;
return NULL;
}
#if DEBUG
if (GLOBAL_Option['i' - 'a' + 1]) {

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);
#if __ANDROID__
__android_log_print(ANDROID_LOG_DEBUG, "YAPDroid", "%s\n", buf);
__android_log_print(ANDROID_LOG_ERROR, "YAPDroid", "%s\n", buf);
#else
*b++ = '\n';
*b = '\0';
@ -510,7 +510,7 @@ not being output.
static Int stop_low_level_trace(USES_REGS1) {
Yap_do_low_level_trace = FALSE;
LOCAL_do_trace_primitives = TRUE;
#if DEBUG_LOCKS
#if DEBUG_LOCKS////
debug_locks = TRUE;
#endif
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,
*Yap_PLDIR, *Yap_BOOTSTRAP, *Yap_COMMONSDIR, *Yap_STARTUP,
*Yap_PLDIR, *Yap_BOOTSTRAP, *Yap_COMMONSDIR,
*Yap_INPUT_STARTUP, *Yap_OUTPUT_STARTUP, *Yap_BOOTFILE, *Yap_INCLUDEDIR;
/* 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
Yap_DLLDIR = sel(true, iap->DLLDIR != NULL, iap->DLLDIR, true,
#if __ANDROID__
NULL
NULL,
#else
join(getenv("DESTDIR"), YAP_DLLDIR),
#endif
@ -312,12 +312,12 @@ static void Yap_set_locations(YAP_init_args *iap) {
/// BOOTPLDIR: where we can find Prolog bootstrap files
Yap_BOOTSTRAP = sel(true, iap->BOOTSTRAP != NULL, iap->BOOTSTRAP, true,
#if __ANDROID__
"/assets/Yap/pl",
"/assets/Yap/pl/boot,yap",
#else
join(getenv("DESTDIR"), YAP_BOOTSTRAP),
#endif
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,
#if __ANDROID__
"/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));
#if __ANDROID__
iap->boot_file_type = YAP_BOOT_PL;
iap->SavedState = NULL;
iap->INPUT_STARTUP = NULL;
iap->assetManager = NULL;
#else
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) {
YAP_initialized = true;
LOCAL_PrologMode &= ~BootMode;
CurrentModule = USER_MODULE;
return rc;
}
@ -1039,7 +1040,7 @@ X_API YAP_file_type_t YAP_Init(YAP_init_args *yap_init) {
init_globals(yap_init);
start_modules();
consult(Yap_BOOTSTRAP PASS_REGS);
consult(Yap_BOOTFILE PASS_REGS);
if (yap_init->install && Yap_OUTPUT_STARTUP) {
Term t = MkAtomTerm(Yap_LookupAtom(Yap_OUTPUT_STARTUP));
Term g = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("qsave_program"), 1),

View File

@ -110,7 +110,7 @@ protected:
const unsigned char *us = (const unsigned char *)s0;
tnames = MkVarTerm();
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);
// Yap_DebugPlWrite(out);
if (tout == 0L) {

View File

@ -76,7 +76,7 @@ public:
YAPTerm(void *ptr);
/// parse string s and construct a term.
YAPTerm(char *s) {
Term tp;
Term tp = 0;
mk(YAP_ReadBuffer(s, &tp));
}

View File

@ -20,28 +20,21 @@
#ifndef YATOM_H
#define YATOM_H 1
#ifdef USE_OFFSETS
INLINE_ONLY inline EXTERN Atom AbsAtom(AtomEntry *p);
INLINE_ONLY inline EXTERN AtomEntry *RepAtom(Atom a);
#ifdef USE_OFFSETS
INLINE_ONLY inline EXTERN Atom AbsAtom(AtomEntry *p) {
return (Atom)(Addr(p) - AtomBase);
}
INLINE_ONLY inline EXTERN AtomEntry *RepAtom(Atom a);
INLINE_ONLY inline EXTERN AtomEntry *RepAtom(Atom a) {
return (AtomEntry *) (AtomBase + Unsigned (a);
}
#else
INLINE_ONLY inline EXTERN Atom AbsAtom(AtomEntry *p);
INLINE_ONLY inline EXTERN Atom AbsAtom(AtomEntry *p) { return (Atom)(p); }
INLINE_ONLY inline EXTERN AtomEntry *RepAtom(Atom a);
INLINE_ONLY inline EXTERN AtomEntry *RepAtom(Atom a) {
return (AtomEntry *)(a);
}

View File

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

View File

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

View File

@ -1385,9 +1385,8 @@ Term Yap_BufferToTerm(const unsigned char *s, Term opts) {
return rval;
}
X_API Term Yap_BufferToTermWithPrioBindings(const unsigned char *s, size_t len,
Term opts, int prio,
Term bindings) {
X_API Term Yap_BufferToTermWithPrioBindings(const unsigned char *s, Term opts, Term bindings, size_t len,
int prio) {
CACHE_REGS
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);
extern int Yap_open_buf_write_stream(encoding_t enc, memBufSource src);
extern Term Yap_BufferToTerm(const unsigned char *s, Term opts);
extern X_API Term Yap_BufferToTermWithPrioBindings(const unsigned char *s,
size_t sz, Term opts,
int prio, Term bindings);
extern X_API Term
Yap_BufferToTermWithPrioBindings(const unsigned char *s, Term opts, Term bindings, size_t sz,
int prio);
extern FILE *Yap_GetInputStream(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);

View File

@ -15,6 +15,10 @@
typedef struct myddas_global *MYDDAS_GLOBAL;
#include "myddas_util.h"
static void Yap_InitMYDDAS_SQLITE3Preds(void);
static void Yap_InitBackMYDDAS_SQLITE3Preds(void);
#ifdef MYDDAS_STATS
typedef struct myddas_stats_time_struct *MYDDAS_STATS_TIME;
typedef struct myddas_global_stats *MYDDAS_GLOBAL_STATS;

View File

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

View File

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

View File

@ -1,7 +1,7 @@
//
// Created by vsc on 7/6/17.
// Created by vsc on 7/6/17->
//
/* File : example.cxx */
/* File : example->cxx */
#include "streamer.h"
@ -25,13 +25,12 @@ extern "C" {
#include <yapio.h>
#include <iopreds.h>
extern void Java_pt_up_yap_streamerJNI_swig_1module_1init__(void);
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;
@ -83,21 +82,28 @@ streamerInstance->display(buff0);
}
void
AndroidStreamer::bind() {
buff0 = *new std::string[256];
andstream.name = "/android/user_error";
andstream.vflags = VFS_CAN_WRITE | VFS_HAS_PREFIX;
andstream.prefix = "/android";
andstream.suffix = NULL;
andstream.open = and_open;
andstream.close = and_close;
andstream.get_char = and_get;
andstream.put_char = and_put;
andstream.flush = and_flush;
andstream.seek = and_seek;
andstream.next = GLOBAL_VFS;
GLOBAL_VFS = &andstream;
Yap_InitStdStream(StdOutStream, Output_Stream_f | Append_Stream_f, NULL, &andstream);
Yap_InitStdStream(StdErrStream, Output_Stream_f | Append_Stream_f, NULL, &andstream);
extern "C" {
void Java_pt_up_yap_streamerJNI_swig_1module_1init(void) {
andstream = new VFS_t();
andstream->name = "/android/user_error";
andstream->vflags = VFS_CAN_WRITE | VFS_HAS_PREFIX;
andstream->prefix = "/android";
andstream->suffix = NULL;
andstream->open = and_open;
andstream->close = and_close;
andstream->get_char = and_get;
andstream->put_char = and_put;
andstream->flush = and_flush;
andstream->seek = and_seek;
andstream->next = GLOBAL_VFS;
GLOBAL_VFS = andstream;
Yap_InitStdStream(StdOutStream, Output_Stream_f | Append_Stream_f, NULL, andstream);
Yap_InitStdStream(StdErrStream, Output_Stream_f | Append_Stream_f, NULL, andstream); //streamerInstance = 0;
} ;
}

View File

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

View File

@ -59,6 +59,10 @@ class YAPEngine;
// no way to translate
return NULL;
}
#endif
#ifdef SWIGJAVA0
%typemap(javapackage) std::vector<YAPTerm> "pt.up.yap.YAPTerm"
%template(VectorOfTerm) std::vector<YAPTerm>;
#endif
}
%}

View File

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

View File

@ -342,7 +342,7 @@ expand_expr(Op, X, Y, O, Q, P) :-
%% contains_illegal_dcgnt(+Term) is semidet.
%
% 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) :-
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'(type_error(callable,_)). % ex: phrase(27,L)
:- set_value('$c_arith',true).
/**
@}

View File

@ -293,7 +293,7 @@ initialize_prolog :-
'qly.yap',
'spy.yap',
'udi.yap'].
:- stop_low_level_trace.
%:- stop_low_level_trace.
:- meta_predicate(log_event(+,:)).

View File

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