smallbugs
This commit is contained in:
parent
31f1c25ee7
commit
6b545c8f71
2
C/save.c
2
C/save.c
@ -1427,7 +1427,7 @@ OpenRestore(const char *inpf, const char *YapLibDir, CELL *Astate, CELL *ATrail,
|
|||||||
char fname[YAP_FILENAME_MAX +1];
|
char fname[YAP_FILENAME_MAX +1];
|
||||||
|
|
||||||
if (!Yap_findFile( inpf, YAP_STARTUP, YapLibDir, fname, true, YAP_SAVED_STATE, true, true))
|
if (!Yap_findFile( inpf, YAP_STARTUP, YapLibDir, fname, true, YAP_SAVED_STATE, true, true))
|
||||||
return false;
|
return FAIL_RESTORE;
|
||||||
if (fname[0] &&
|
if (fname[0] &&
|
||||||
(mode = try_open(fname,Astate,ATrail,AStack,AHeap,streamp)) != FAIL_RESTORE) {
|
(mode = try_open(fname,Astate,ATrail,AStack,AHeap,streamp)) != FAIL_RESTORE) {
|
||||||
return mode;
|
return mode;
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "inline-only.h"
|
#include "inline-only.h"
|
||||||
|
|
||||||
EXTERN Int Yap_unify(Term a, Term b);
|
EXTERN bool Yap_unify(Term a, Term b);
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline Term Deref(Term a);
|
INLINE_ONLY EXTERN inline Term Deref(Term a);
|
||||||
|
|
||||||
@ -39,7 +39,6 @@ INLINE_ONLY EXTERN inline Term Deref(Term a) {
|
|||||||
|
|
||||||
INLINE_ONLY EXTERN inline CELL *GetTermAdress(Term a);
|
INLINE_ONLY EXTERN inline CELL *GetTermAdress(Term a);
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline Term Derefa(CELL *b);
|
INLINE_ONLY EXTERN inline Term Derefa(CELL *b);
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline Term Derefa(CELL *b) {
|
INLINE_ONLY EXTERN inline Term Derefa(CELL *b) {
|
||||||
|
@ -374,19 +374,19 @@ close_attvar_chain(CELL *dvarsmin, CELL *dvarsmax) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline
|
INLINE_ONLY EXTERN inline
|
||||||
Int Yap_unify(Term t0, Term t1);
|
bool Yap_unify(Term t0, Term t1);
|
||||||
|
|
||||||
INLINE_ONLY EXTERN inline
|
INLINE_ONLY EXTERN inline
|
||||||
Int Yap_unify(Term t0, Term t1)
|
bool Yap_unify(Term t0, Term t1)
|
||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
tr_fr_ptr TR0 = TR;
|
tr_fr_ptr TR0 = TR;
|
||||||
|
|
||||||
if (Yap_IUnify(t0,t1)) {
|
if (Yap_IUnify(t0,t1)) {
|
||||||
return TRUE;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
reset_trail(TR0);
|
reset_trail(TR0);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,36 +4,31 @@
|
|||||||
|
|
||||||
extern PyObject *py_Local, *py_Global;
|
extern PyObject *py_Local, *py_Global;
|
||||||
|
|
||||||
PyObject *YE(term_t t, int line, const char *file, const char *code)
|
PyObject *YE(term_t t, int line, const char *file, const char *code) {
|
||||||
{
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
YAP_WriteBuffer(YAP_GetFromSlot(t), buf, 1023, 0);
|
YAP_WriteBuffer(YAP_GetFromSlot(t), buf, 1023, 0);
|
||||||
fprintf(stderr, "**** Warning,%s@%s:%d: failed on expression %s\n", code, file, line, buf);
|
fprintf(stderr, "**** Warning,%s@%s:%d: failed on expression %s\n", code,
|
||||||
|
file, line, buf);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YEM(const char *exp, int line, const char *file, const char *code)
|
void YEM(const char *exp, int line, const char *file, const char *code) {
|
||||||
{
|
fprintf(stderr, "**** Warning,%s@%s:%d: failed while executing %s\n", code,
|
||||||
fprintf(stderr, "**** Warning,%s@%s:%d: failed while executing %s\n", code, file, line, exp);
|
file, line, exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *s_to_python( const char *s, bool eval, PyObject *p0)
|
static PyObject *s_to_python(const char *s, bool eval, PyObject *p0) {
|
||||||
{
|
|
||||||
PyObject *o;
|
PyObject *o;
|
||||||
if (eval)
|
if (eval) {
|
||||||
{
|
|
||||||
o = PythonLookup(s, p0);
|
o = PythonLookup(s, p0);
|
||||||
/* if (!o)
|
/* if (!o)
|
||||||
return o;
|
return o;
|
||||||
*/
|
*/
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
o = PythonLookupSpecial(s);
|
o = PythonLookupSpecial(s);
|
||||||
}
|
}
|
||||||
if (o)
|
if (o) {
|
||||||
{
|
|
||||||
Py_INCREF(o);
|
Py_INCREF(o);
|
||||||
return CHECKNULL(YAP_MkStringTerm(s), o);
|
return CHECKNULL(YAP_MkStringTerm(s), o);
|
||||||
} else {
|
} else {
|
||||||
@ -50,8 +45,7 @@ static PyObject *s_to_python( const char *s, bool eval, PyObject *p0)
|
|||||||
*
|
*
|
||||||
* @return a Python object descriptor or NULL if failed
|
* @return a Python object descriptor or NULL if failed
|
||||||
*/
|
*/
|
||||||
X_API PyObject *string_to_python( const char *s, bool eval, PyObject *p0)
|
X_API PyObject *string_to_python(const char *s, bool eval, PyObject *p0) {
|
||||||
{
|
|
||||||
char *buf = malloc(strlen(s) + 1), *child;
|
char *buf = malloc(strlen(s) + 1), *child;
|
||||||
while ((child = strchr(s, '.')) != NULL) {
|
while ((child = strchr(s, '.')) != NULL) {
|
||||||
size_t len = child - s;
|
size_t len = child - s;
|
||||||
@ -71,77 +65,58 @@ X_API PyObject *string_to_python( const char *s, bool eval, PyObject *p0)
|
|||||||
*
|
*
|
||||||
* @return a Python object descriptor or NULL if failed
|
* @return a Python object descriptor or NULL if failed
|
||||||
*/
|
*/
|
||||||
PyObject *term_to_python(term_t t, bool eval, PyObject *o)
|
PyObject *term_to_python(term_t t, bool eval, PyObject *o) {
|
||||||
{
|
|
||||||
// o≈
|
// o≈
|
||||||
YAP_Term yt = YAP_GetFromSlot(t);
|
YAP_Term yt = YAP_GetFromSlot(t);
|
||||||
// Yap_DebugPlWriteln(yt);
|
// Yap_DebugPlWriteln(yt);
|
||||||
switch (PL_term_type(t))
|
switch (PL_term_type(t)) {
|
||||||
{
|
case PL_VARIABLE: {
|
||||||
case PL_VARIABLE:
|
if (t == 0) {
|
||||||
{
|
|
||||||
if (t == 0)
|
|
||||||
{
|
|
||||||
Yap_ThrowError(SYSTEM_ERROR_INTERNAL, yt, "in term_to_python");
|
Yap_ThrowError(SYSTEM_ERROR_INTERNAL, yt, "in term_to_python");
|
||||||
}
|
}
|
||||||
PyObject *out = PyTuple_New(1);
|
PyObject *out = PyTuple_New(1);
|
||||||
PyTuple_SET_ITEM(out, 0, PyLong_FromLong(t));
|
PyTuple_SET_ITEM(out, 0, PyLong_FromLong(t));
|
||||||
return term_to_nametuple("v", 1, out);
|
return term_to_nametuple("v", 1, out);
|
||||||
};
|
};
|
||||||
case PL_ATOM:
|
case PL_ATOM: {
|
||||||
{
|
|
||||||
YAP_Atom at = YAP_AtomOfTerm(yt);
|
YAP_Atom at = YAP_AtomOfTerm(yt);
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
||||||
s = YAP_AtomName(at);
|
s = YAP_AtomName(at);
|
||||||
if (eval)
|
if (eval) {
|
||||||
{
|
|
||||||
o = PythonLookup(s, o);
|
o = PythonLookup(s, o);
|
||||||
/* if (!o)
|
/* if (!o)
|
||||||
return o;
|
return o;
|
||||||
*/
|
*/
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
o = PythonLookupSpecial(s);
|
o = PythonLookupSpecial(s);
|
||||||
}
|
}
|
||||||
if (o)
|
if (o) {
|
||||||
{
|
|
||||||
Py_INCREF(o);
|
Py_INCREF(o);
|
||||||
return CHECKNULL(t, o);
|
return CHECKNULL(t, o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case PL_STRING:
|
case PL_STRING: {
|
||||||
{
|
|
||||||
const char *s = NULL;
|
const char *s = NULL;
|
||||||
if (YAP_IsAtomTerm(yt))
|
if (YAP_IsAtomTerm(yt)) {
|
||||||
{
|
|
||||||
s = YAP_AtomName(YAP_AtomOfTerm(yt));
|
s = YAP_AtomName(YAP_AtomOfTerm(yt));
|
||||||
}
|
} else if (YAP_IsStringTerm(yt)) {
|
||||||
else if (YAP_IsStringTerm(yt))
|
|
||||||
{
|
|
||||||
s = YAP_StringOfTerm(yt);
|
s = YAP_StringOfTerm(yt);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return CHECKNULL(t, NULL);
|
return CHECKNULL(t, NULL);
|
||||||
}
|
}
|
||||||
#if PY_MAJOR_VERSION < 3
|
#if PY_MAJOR_VERSION < 3
|
||||||
if (proper_ascii_string(s))
|
if (proper_ascii_string(s)) {
|
||||||
{
|
|
||||||
PyObject *o = PyString_FromStringAndSize(s, strlen(s));
|
PyObject *o = PyString_FromStringAndSize(s, strlen(s));
|
||||||
return CHECKNULL(t, o);
|
return CHECKNULL(t, o);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
PyObject *pobj = PyUnicode_DecodeUTF8(s, strlen(s), NULL);
|
PyObject *pobj = PyUnicode_DecodeUTF8(s, strlen(s), NULL);
|
||||||
return CHECKNULL(t, pobj);
|
return CHECKNULL(t, pobj);
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
case PL_INTEGER: {
|
||||||
case PL_INTEGER:
|
|
||||||
{
|
|
||||||
int64_t j;
|
int64_t j;
|
||||||
if (!PL_get_int64_ex(t, &j))
|
if (!PL_get_int64_ex(t, &j))
|
||||||
return CHECKNULL(t, NULL);
|
return CHECKNULL(t, NULL);
|
||||||
@ -154,8 +129,7 @@ PyObject *term_to_python(term_t t, bool eval, PyObject *o)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
case PL_FLOAT:
|
case PL_FLOAT: {
|
||||||
{
|
|
||||||
PyObject *out;
|
PyObject *out;
|
||||||
double fl;
|
double fl;
|
||||||
if (!PL_get_float(t, &fl))
|
if (!PL_get_float(t, &fl))
|
||||||
@ -163,45 +137,39 @@ PyObject *term_to_python(term_t t, bool eval, PyObject *o)
|
|||||||
out = PyFloat_FromDouble(fl);
|
out = PyFloat_FromDouble(fl);
|
||||||
return CHECKNULL(t, out);
|
return CHECKNULL(t, out);
|
||||||
}
|
}
|
||||||
default:
|
default: {
|
||||||
{
|
|
||||||
term_t tail = PL_new_term_ref(), arg;
|
term_t tail = PL_new_term_ref(), arg;
|
||||||
size_t len, i;
|
size_t len, i;
|
||||||
if (PL_skip_list(t, tail, &len) && PL_get_nil(tail))
|
if (PL_skip_list(t, tail, &len) && PL_get_nil(tail)) {
|
||||||
{
|
|
||||||
PyObject *out, *a;
|
PyObject *out, *a;
|
||||||
|
|
||||||
arg = tail;
|
arg = tail;
|
||||||
out = PyList_New(len);
|
out = PyList_New(len);
|
||||||
if (!out)
|
if (!out) {
|
||||||
|
PL_reset_term_refs(tail);
|
||||||
return CHECKNULL(t, Py_None);
|
return CHECKNULL(t, Py_None);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++) {
|
||||||
{
|
if (!PL_get_list(t, arg, t)) {
|
||||||
if (!PL_get_list(t, arg, t))
|
|
||||||
{
|
|
||||||
PL_reset_term_refs(tail);
|
PL_reset_term_refs(tail);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
a = term_to_python(arg, eval, o);
|
a = term_to_python(arg, eval, o);
|
||||||
if (a )
|
if (a) {
|
||||||
{
|
if (PyList_SetItem(out, i, a) < 0) {
|
||||||
if (PyList_SetItem(out, i, a) < 0)
|
PL_reset_term_refs(tail);
|
||||||
{
|
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PL_reset_term_refs(tail);
|
PL_reset_term_refs(tail);
|
||||||
return CHECKNULL(t, out);
|
return CHECKNULL(t, out);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
functor_t fun;
|
functor_t fun;
|
||||||
PyObject *rc;
|
PyObject *rc;
|
||||||
|
|
||||||
if (!PL_get_functor(t, &fun))
|
if (!PL_get_functor(t, &fun)) {
|
||||||
{
|
|
||||||
PL_reset_term_refs(tail);
|
PL_reset_term_refs(tail);
|
||||||
return CHECKNULL(t, Py_None);
|
return CHECKNULL(t, Py_None);
|
||||||
}
|
}
|
||||||
@ -217,8 +185,7 @@ PyObject *term_to_python(term_t t, bool eval, PyObject *o)
|
|||||||
return CHECKNULL(t, Py_None);
|
return CHECKNULL(t, Py_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *yap_to_python(YAP_Term t, bool eval, PyObject *o)
|
PyObject *yap_to_python(YAP_Term t, bool eval, PyObject *o) {
|
||||||
{
|
|
||||||
if (t == 0)
|
if (t == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
term_t yt = YAP_InitSlot(t);
|
term_t yt = YAP_InitSlot(t);
|
||||||
@ -227,13 +194,11 @@ PyObject *yap_to_python(YAP_Term t, bool eval, PyObject *o)
|
|||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *deref_term_to_python(term_t t)
|
PyObject *deref_term_to_python(term_t t) {
|
||||||
{
|
|
||||||
// Yap_DebugPlWrite(YAP_GetFromSlot(t)); fprintf(stderr, " here I
|
// Yap_DebugPlWrite(YAP_GetFromSlot(t)); fprintf(stderr, " here I
|
||||||
// am\n");
|
// am\n");
|
||||||
YAP_Term yt = YAP_GetFromSlot(t);
|
YAP_Term yt = YAP_GetFromSlot(t);
|
||||||
if (YAP_IsVarTerm(yt))
|
if (YAP_IsVarTerm(yt)) {
|
||||||
{
|
|
||||||
char s[32];
|
char s[32];
|
||||||
char *o = YAP_WriteBuffer(yt, s, 31, 0);
|
char *o = YAP_WriteBuffer(yt, s, 31, 0);
|
||||||
PyObject *p = PyUnicode_FromString(o);
|
PyObject *p = PyUnicode_FromString(o);
|
||||||
|
@ -25,11 +25,14 @@ foreign_t assign_to_symbol(term_t t, PyObject *e) {
|
|||||||
foreign_t python_to_term(PyObject *pVal, term_t t) {
|
foreign_t python_to_term(PyObject *pVal, term_t t) {
|
||||||
bool rc = true;
|
bool rc = true;
|
||||||
term_t to = PL_new_term_ref();
|
term_t to = PL_new_term_ref();
|
||||||
// fputs(" <<*** ",stderr); PyObject_Print(pVal,stderr,0); fputs("<<***\n",stderr);
|
// fputs(" <<*** ",stderr); PyObject_Print(pVal,stderr,0);
|
||||||
|
// fputs("<<***\n",stderr);
|
||||||
if (pVal == Py_None) {
|
if (pVal == Py_None) {
|
||||||
//fputs("<<*** ",stderr);Yap_DebugPlWrite(YAP_GetFromSlot(t)); fputs(" >>***\n",stderr);
|
// fputs("<<*** ",stderr);Yap_DebugPlWrite(YAP_GetFromSlot(t)); fputs("
|
||||||
|
// >>***\n",stderr);
|
||||||
rc = PL_unify_atom(t, ATOM_none);
|
rc = PL_unify_atom(t, ATOM_none);
|
||||||
//fputs("<<*** ",stderr);Yap_DebugPlWrite(YAP_GetFromSlot(t)); fputs(" >>***\n",stderr);
|
// fputs("<<*** ",stderr);Yap_DebugPlWrite(YAP_GetFromSlot(t)); fputs("
|
||||||
|
// >>***\n",stderr);
|
||||||
} else if (PyBool_Check(pVal)) {
|
} else if (PyBool_Check(pVal)) {
|
||||||
rc = rc && PL_unify_bool(t, PyObject_IsTrue(pVal));
|
rc = rc && PL_unify_bool(t, PyObject_IsTrue(pVal));
|
||||||
} else if (PyLong_Check(pVal)) {
|
} else if (PyLong_Check(pVal)) {
|
||||||
@ -41,8 +44,7 @@ foreign_t python_to_term(PyObject *pVal, term_t t) {
|
|||||||
} else if (PyFloat_Check(pVal)) {
|
} else if (PyFloat_Check(pVal)) {
|
||||||
rc = rc && PL_unify_float(t, PyFloat_AsDouble(pVal));
|
rc = rc && PL_unify_float(t, PyFloat_AsDouble(pVal));
|
||||||
} else if (PyComplex_Check(pVal)) {
|
} else if (PyComplex_Check(pVal)) {
|
||||||
term_t t1 = PL_new_term_ref(),
|
term_t t1 = PL_new_term_ref(), t2 = PL_new_term_ref();
|
||||||
t2 = PL_new_term_ref();
|
|
||||||
if (!PL_put_float(t1, PyComplex_RealAsDouble(pVal)) ||
|
if (!PL_put_float(t1, PyComplex_RealAsDouble(pVal)) ||
|
||||||
!PL_put_float(t2, PyComplex_ImagAsDouble(pVal)) ||
|
!PL_put_float(t2, PyComplex_ImagAsDouble(pVal)) ||
|
||||||
!PL_cons_functor(to, FUNCTOR_complex2, t1, t2)) {
|
!PL_cons_functor(to, FUNCTOR_complex2, t1, t2)) {
|
||||||
@ -113,7 +115,8 @@ foreign_t python_to_term(PyObject *pVal, term_t t) {
|
|||||||
} else {
|
} else {
|
||||||
rc = false;
|
rc = false;
|
||||||
}
|
}
|
||||||
//fputs(" ||*** ",stderr); Yap_DebugPlWrite(YAP_GetFromSlot(t)); fputs(" ||***\n",stderr);
|
// fputs(" ||*** ",stderr); Yap_DebugPlWrite(YAP_GetFromSlot(t)); fputs("
|
||||||
|
// ||***\n",stderr);
|
||||||
}
|
}
|
||||||
} else if (PyList_Check(pVal)) {
|
} else if (PyList_Check(pVal)) {
|
||||||
Py_ssize_t i, sz = PyList_GET_SIZE(pVal);
|
Py_ssize_t i, sz = PyList_GET_SIZE(pVal);
|
||||||
@ -131,7 +134,6 @@ foreign_t python_to_term(PyObject *pVal, term_t t) {
|
|||||||
obj = Py_None;
|
obj = Py_None;
|
||||||
}
|
}
|
||||||
rc = rc && python_to_term(obj, to);
|
rc = rc && python_to_term(obj, to);
|
||||||
|
|
||||||
}
|
}
|
||||||
rc = rc && PL_unify_nil(t);
|
rc = rc && PL_unify_nil(t);
|
||||||
}
|
}
|
||||||
@ -168,7 +170,8 @@ foreign_t python_to_term(PyObject *pVal, term_t t) {
|
|||||||
rc = false;
|
rc = false;
|
||||||
}
|
}
|
||||||
if (!PL_unify(ti, tint)) {
|
if (!PL_unify(ti, tint)) {
|
||||||
rc = false; }
|
rc = false;
|
||||||
|
}
|
||||||
ti = tnew;
|
ti = tnew;
|
||||||
PL_reset_term_refs(tkey);
|
PL_reset_term_refs(tkey);
|
||||||
}
|
}
|
||||||
@ -183,9 +186,10 @@ foreign_t python_to_term(PyObject *pVal, term_t t) {
|
|||||||
|
|
||||||
X_API YAP_Term pythonToYAP(PyObject *pVal) {
|
X_API YAP_Term pythonToYAP(PyObject *pVal) {
|
||||||
term_t t = PL_new_term_ref();
|
term_t t = PL_new_term_ref();
|
||||||
if (pVal == NULL ||
|
if (pVal == NULL || !python_to_term(pVal, t)) {
|
||||||
!python_to_term(pVal, t))
|
PL_reset_term_refs(t);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
YAP_Term tt = YAP_GetFromSlot(t);
|
YAP_Term tt = YAP_GetFromSlot(t);
|
||||||
PL_reset_term_refs(t);
|
PL_reset_term_refs(t);
|
||||||
Py_DECREF(pVal);
|
Py_DECREF(pVal);
|
||||||
|
@ -105,7 +105,6 @@ PyObject *find_obj(PyObject *ob, term_t l, bool eval) {
|
|||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
yt = YAP_TailOfTerm(yt);
|
yt = YAP_TailOfTerm(yt);
|
||||||
|
|
||||||
}
|
}
|
||||||
YAP_PutInSlot(l, yt);
|
YAP_PutInSlot(l, yt);
|
||||||
return ob;
|
return ob;
|
||||||
@ -456,8 +455,8 @@ static PyObject *bip_sum(term_t t) {
|
|||||||
}
|
}
|
||||||
#if PY_MAJOR_VERSION < 3
|
#if PY_MAJOR_VERSION < 3
|
||||||
if (PyInt_CheckExact(item)) {
|
if (PyInt_CheckExact(item)) {
|
||||||
764PyFPE_START_PROTECT("add", Py_DECREF(item); Py_DECREF(iter); return 0)
|
764PyFPE_START_PROTECT("add", Py_DECREF(item); Py_DECREF(iter);
|
||||||
f_result += (double)PyInt_AS_LONG(item);
|
return 0)f_result += (double)PyInt_AS_LONG(item);
|
||||||
PyFPE_END_PROTECT(f_result) Py_DECREF(item);
|
PyFPE_END_PROTECT(f_result) Py_DECREF(item);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -561,15 +560,14 @@ static long get_len_of_range(long lo, long hi, long step) {
|
|||||||
|
|
||||||
#if PY_MAJOR_VERSION >= 3
|
#if PY_MAJOR_VERSION >= 3
|
||||||
static PyStructSequence_Field pnull[] = {
|
static PyStructSequence_Field pnull[] = {
|
||||||
{"A1", NULL}, {"A2", NULL}, {"A3", NULL}, {"A4", NULL},
|
{"A1", NULL}, {"A2", NULL}, {"A3", NULL}, {"A4", NULL}, {"A5", NULL},
|
||||||
{"A5", NULL}, {"A6", NULL}, {"A7", NULL}, {"A8", NULL},
|
{"A6", NULL}, {"A7", NULL}, {"A8", NULL}, {"A9", NULL}, {"A9", NULL},
|
||||||
{"A9", NULL}, {"A9", NULL}, {"A10", NULL}, {"A11", NULL},
|
{"A10", NULL}, {"A11", NULL}, {"A12", NULL}, {"A13", NULL}, {"A14", NULL},
|
||||||
{"A12", NULL}, {"A13", NULL}, {"A14", NULL}, {"A15", NULL},
|
{"A15", NULL}, {"A16", NULL}, {"A17", NULL}, {"A18", NULL}, {"A19", NULL},
|
||||||
{"A16", NULL}, {"A17", NULL}, {"A18", NULL}, {"A19", NULL},
|
{"A19", NULL}, {"A20", NULL}, {"A21", NULL}, {"A22", NULL}, {"A23", NULL},
|
||||||
{"A19", NULL}, {"A20", NULL}, {"A21", NULL}, {"A22", NULL},
|
{"A24", NULL}, {"A25", NULL}, {"A26", NULL}, {"A27", NULL}, {"A28", NULL},
|
||||||
{"A23", NULL}, {"A24", NULL}, {"A25", NULL}, {"A26", NULL},
|
{"A29", NULL}, {"A29", NULL}, {"A30", NULL}, {"A31", NULL}, {"A32", NULL},
|
||||||
{"A27", NULL}, {"A28", NULL}, {"A29", NULL}, {"A29", NULL},
|
{NULL, NULL}};
|
||||||
{"A30", NULL}, {"A31", NULL}, {"A32", NULL}, {NULL,NULL}};
|
|
||||||
|
|
||||||
static PyObject *structseq_str(PyObject *iobj) {
|
static PyObject *structseq_str(PyObject *iobj) {
|
||||||
|
|
||||||
@ -698,7 +696,6 @@ static PyObject *structseq_repr(PyObject *iobj) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
|
PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
|
||||||
PyObject *o;
|
PyObject *o;
|
||||||
#if PY_MAJOR_VERSION >= 3
|
#if PY_MAJOR_VERSION >= 3
|
||||||
@ -784,7 +781,8 @@ static PyObject *bip_range(term_t t) {
|
|||||||
else
|
else
|
||||||
bign = get_len_of_range(ihigh, ilow, -istep);
|
bign = get_len_of_range(ihigh, ilow, -istep);
|
||||||
n = (Py_ssize_t)bign;
|
n = (Py_ssize_t)bign;
|
||||||
AOK ( ( (bign >= 0 && (long)n == bign) || "range() result has too many items" ), NULL );
|
AOK(((bign >= 0 && (long)n == bign) || "range() result has too many items"),
|
||||||
|
NULL);
|
||||||
v = PyList_New(n);
|
v = PyList_New(n);
|
||||||
|
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
@ -842,7 +840,6 @@ static bool copy_to_dictionary(PyObject *dict, term_t targ, term_t taux,
|
|||||||
// Py_DECREF(rhs);
|
// Py_DECREF(rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PyObject *compound_to_data(term_t t, PyObject *o, functor_t fun, bool exec) {
|
PyObject *compound_to_data(term_t t, PyObject *o, functor_t fun, bool exec) {
|
||||||
atom_t name;
|
atom_t name;
|
||||||
int len;
|
int len;
|
||||||
@ -1214,7 +1211,7 @@ PyObject *compound_to_pyeval(term_t t, PyObject *context) {
|
|||||||
pArg = Py_None;
|
pArg = Py_None;
|
||||||
} else {
|
} else {
|
||||||
pArg = term_to_python(tleft, true, NULL);
|
pArg = term_to_python(tleft, true, NULL);
|
||||||
PyObject_Print(pArg,fdopen(2,"w"),0);
|
// PyObject_Print(pArg,fdopen(2,"w"),0);
|
||||||
if (pArg == NULL) {
|
if (pArg == NULL) {
|
||||||
pArg = Py_None;
|
pArg = Py_None;
|
||||||
}
|
}
|
||||||
|
@ -638,7 +638,7 @@ static YAP_Int p_python_threaded(void) {
|
|||||||
static PyGILState_STATE gstate;
|
static PyGILState_STATE gstate;
|
||||||
|
|
||||||
term_t python_acquire_GIL(void) {
|
term_t python_acquire_GIL(void) {
|
||||||
term_t curSlot = 1; //PL_new_term_ref();
|
term_t curSlot = PL_new_term_ref();
|
||||||
if (!_threaded)
|
if (!_threaded)
|
||||||
pyErrorAndReturn(curSlot, false);
|
pyErrorAndReturn(curSlot, false);
|
||||||
// extern int Yap_do_low_level_trace;
|
// extern int Yap_do_low_level_trace;
|
||||||
@ -652,7 +652,7 @@ term_t python_acquire_GIL(void) {
|
|||||||
|
|
||||||
bool python_release_GIL(term_t curBlock) {
|
bool python_release_GIL(term_t curBlock) {
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
// PL_reset_term_refs(curBlock);
|
PL_reset_term_refs(curBlock);
|
||||||
if (_threaded) {
|
if (_threaded) {
|
||||||
PyGILState_Release(gstate);
|
PyGILState_Release(gstate);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user