This commit is contained in:
Vitor Santos Costa 2018-08-07 17:20:43 +01:00
parent f6596da27d
commit 05733938c1
6 changed files with 67 additions and 50 deletions

View File

@ -255,19 +255,31 @@ YAPApplTerm::YAPApplTerm(YAPFunctor f, YAPTerm ts[]) {
RECOVER_H();
}
YAPApplTerm::YAPApplTerm(std::string f, std::vector<Term> ts) {
BACKUP_H();
arity_t arity = ts.size();
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
Term o = Yap_MkNewApplTerm(ff, arity);
Term *tt = RepAppl(o) + 1;
for (arity_t i = 0; i < arity; i++)
tt[i] = ts[i];
mk(o);
YAPApplTerm::YAPApplTerm(const std::string f, std::vector<Term> ts) {
BACKUP_H();
arity_t arity = ts.size();
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
Term o = Yap_MkNewApplTerm(ff, arity);
Term *tt = RepAppl(o) + 1;
for (arity_t i = 0; i < arity; i++)
tt[i] = ts[i];
mk(o);
RECOVER_H();
}
YAPApplTerm::YAPApplTerm(std::string f, YAPTerm a1) {
YAPApplTerm::YAPApplTerm(const std::string f, std::vector<YAPTerm> ts) {
BACKUP_H();
arity_t arity = ts.size();
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
Term o = Yap_MkNewApplTerm(ff, arity);
Term *tt = RepAppl(o) + 1;
for (arity_t i = 0; i < arity; i++)
tt[i] = ts[i].term();
mk(o);
RECOVER_H();
}
YAPApplTerm::YAPApplTerm(const std::string f, YAPTerm a1) {
BACKUP_H();
arity_t arity = 1;
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
@ -278,7 +290,7 @@ YAPApplTerm::YAPApplTerm(std::string f, YAPTerm a1) {
RECOVER_H();
}
YAPApplTerm::YAPApplTerm(std::string f, YAPTerm a1, YAPTerm a2) {
YAPApplTerm::YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2) {
BACKUP_H();
arity_t arity = 2;
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
@ -290,7 +302,7 @@ YAPApplTerm::YAPApplTerm(std::string f, YAPTerm a1, YAPTerm a2) {
RECOVER_H();
}
YAPApplTerm::YAPApplTerm(std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3) {
YAPApplTerm::YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3) {
BACKUP_H();
arity_t arity = 3;
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);
@ -303,7 +315,7 @@ YAPApplTerm::YAPApplTerm(std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3) {
RECOVER_H();
}
YAPApplTerm::YAPApplTerm(std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3, YAPTerm a4) {
YAPApplTerm::YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3, YAPTerm a4) {
BACKUP_H();
arity_t arity = 4;
Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity);

View File

@ -307,12 +307,17 @@ YAPApplTerm(Functor f, Term ts[]) {
mk(Yap_MkNewApplTerm(Yap_MkFunctor(Yap_LookupAtom(s.c_str()), arity),
arity));
};
YAPApplTerm(const std::string s, std::vector<YAPTerm> ts);
YAPApplTerm(const std::string s, std::vector<Term> ts);
YAPApplTerm(const std::string s, std::vector<YAPTerm> ts);
YAPApplTerm(YAPFunctor f);
inline Functor functor() { return FunctorOfTerm(gt()); }
inline YAPFunctor getFunctor() { return YAPFunctor(FunctorOfTerm(gt())); }
YAPApplTerm(const std::string f, YAPTerm a1);
YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2);
YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3);
YAPApplTerm(const std::string f, YAPTerm a1, YAPTerm a2, YAPTerm a3, YAPTerm a4);
Term getArg(arity_t i) {
Term getArg(arity_t i) {
BACKUP_MACHINE_REGS();
Term t0 = gt();
Term tf;

View File

@ -835,11 +835,6 @@ static parser_state_t initParser(Term opts, FEnv *fe, REnv *re, int inp_stream,
LOCAL_ErrorMessage = NULL;
fe->old_TR = TR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
__android_log_print(ANDROID_LOG_INFO, "YAPDroid ", " open %s, %d",
CurrentModule == 0
? "prolog"
: RepAtom(AtomOfTerm(CurrentModule))->StrOfAE,
inp_stream);
LOCAL_SourceFileName = GLOBAL_Stream[inp_stream].name;
LOCAL_eot_before_eof = false;
fe->tpos = StreamPosition(inp_stream);

View File

@ -15,12 +15,15 @@
* *
*************************************************************************/
#include "Yap.h"
#ifdef USE_MYDDAS
#include "Yatom.h"
#include "cut_c.h"
#include "myddas.h"
#include <stdlib.h>
#ifdef USE_MYDDAS
#include "myddas.h"
#ifdef MYDDAS_STATS
#include "myddas_statistics.h"
#endif
@ -678,6 +681,8 @@ void Yap_MYDDAS_delete_all_myddas_structs(void) {
#endif
}
#endif
void init_myddas(void) {
CACHE_REGS
if (myddas_initialised)
@ -701,9 +706,6 @@ void init_myddas(void) {
Yap_MYDDAS_delete_all_myddas_structs();
#if defined MYDDAS_ODBC
Yap_InitBackMYDDAS_ODBCPreds();
#endif
#endif
#if defined MYDDAS_ODBC
Yap_InitMYDDAS_ODBCPreds();
#endif
#if defined MYDDAS_TOP_LEVEL && \
@ -711,9 +713,9 @@ void init_myddas(void) {
Yap_InitMYDDAS_TopLevelPreds();
#endif
c_db_initialize_myddas(PASS_REGS1);
#ifdef __ANDROiD__
#ifdef __ANDROID__
init_sqlite3();
#endif
#endif
#endif
myddas_initialised = true;
CurrentModule = cm;

View File

@ -13,12 +13,14 @@ main_ :-
fail.
main_ .
:- if yap_flag(android,true).
:- if( yap_flag(android,true) ).
init :-
db_open(sqlite3, '/data/user/0/pt.up.yap/files/chinook.db', _, _),
!,
writeln('chinook has landed').
init :-
catch(db_open(sqlite3,'chinook.db',_,_), _, fail),
!.
init :-
db_open(sqlite3, '/data/user/0/pt.up.yap.yapdroid/files/Yap/chinook.db', _, _),
% db_open(sqlite3, 'chinook.db', _, _),
writeln('chinook has landed').
:- else.
@ -26,7 +28,7 @@ init :-
db_open(sqlite3, '/data/user/0/pt.up.yap.yapdroid/files/Yap/chinook.db', _, _),
% db_open(sqlite3, 'chinook.db', _, _),
writeln('chinook has landed').
:-endif
:-endif.
go :-
writeln(('db_import')),

View File

@ -124,6 +124,19 @@ YAPError = _yap.YAPError
%typecheck(0) YAPTerm { $1 = !PyUnicode_Check($input); }
%exception {
try {
$action
} catch (const std::out_of_range& e) {
SWIG_exception(SWIG_IndexError, e.what());
} catch (const std::exception& e) {
SWIG_exception(SWIG_RuntimeError, e.what());
} catch (...) {
SWIG_exception(SWIG_RuntimeError, "unknown exception");
}
}
#else
%typemap(in) arity_t { (jlong)($input); }
@ -139,19 +152,6 @@ YAPError = _yap.YAPError
// Language independent exception handler
// simplified version
%include <exception.i>
%exception {
try {
$action
} catch (const std::out_of_range& e) {
SWIG_exception(SWIG_IndexError, e.what());
} catch (const std::exception& e) {
SWIG_exception(SWIG_RuntimeError, e.what());
} catch (...) {
SWIG_exception(SWIG_RuntimeError, "unknown exception");
}
}
#endif
@ -351,8 +351,9 @@ static void
};
%init %{
PyObject * pYAPError = PyErr_NewException("_yap.YAPError", NULL, NULL);
Py_INCREF(pYAPError);
PyModule_AddObject(m, "YAPError", pYAPError);
#ifdef SWIGYTHON
PyObject * pYAPError = PyErr_NewException("_yap.YAPError", NULL, NULL);
Py_INCREF(pYAPError);
PyModule_AddObject(m, "YAPError", pYAPError);
#endif
%}