loops
This commit is contained in:
parent
71940dec67
commit
302519868f
42
C/terms.c
42
C/terms.c
@ -164,6 +164,9 @@ var_in_term_nvar : { \
|
|||||||
/* store the terms to visit */ \
|
/* store the terms to visit */ \
|
||||||
ptd0 = RepAppl(d0); \
|
ptd0 = RepAppl(d0); \
|
||||||
f = (Functor)(d0 = *ptd0); \
|
f = (Functor)(d0 = *ptd0); \
|
||||||
|
if (IsExtensionFunctor(f)) {\
|
||||||
|
continue;\
|
||||||
|
}\
|
||||||
\
|
\
|
||||||
if (to_visit + 32 >= to_visit_max) { \
|
if (to_visit + 32 >= to_visit_max) { \
|
||||||
goto aux_overflow; \
|
goto aux_overflow; \
|
||||||
@ -363,15 +366,15 @@ static int cycles_in_complex_term(register CELL *pt0,
|
|||||||
/* store the terms to visit */
|
/* store the terms to visit */
|
||||||
ptd0 = RepAppl(d0);
|
ptd0 = RepAppl(d0);
|
||||||
f = (Functor)(d0 = *ptd0);
|
f = (Functor)(d0 = *ptd0);
|
||||||
|
if (IsExtensionFunctor(f)) {
|
||||||
|
*ptf++ = d0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (IS_VISIT_MARKER) {
|
if (IS_VISIT_MARKER) {
|
||||||
rc++;
|
rc++;
|
||||||
*ptf++ = BREAK_LOOP(to_visit - to_visit0);
|
*ptf++ = BREAK_LOOP(to_visit - to_visit0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (IsExtensionFunctor(f)) {
|
|
||||||
*ptf++ = d0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (to_visit + 32 >= to_visit_max) {
|
if (to_visit + 32 >= to_visit_max) {
|
||||||
goto aux_overflow;
|
goto aux_overflow;
|
||||||
}
|
}
|
||||||
@ -1382,30 +1385,31 @@ static Int create_entry(Term t, Int i, Int j, cl_connector * q, Int max) {
|
|||||||
Term ref, h, *s, *ostart;
|
Term ref, h, *s, *ostart;
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
// first time, create a new term
|
// first time, create a new term
|
||||||
if (i==0)
|
|
||||||
return 0;
|
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (IsPairTerm(t)) {
|
if (IsPairTerm(t)) {
|
||||||
|
Int me;
|
||||||
s = RepPair(t);
|
s = RepPair(t);
|
||||||
h = s[0];
|
h = s[0];
|
||||||
if (IsAtomTerm(h)) {
|
if (IsAtomTerm(h) &&
|
||||||
return t_ref((cl_connector*)AtomOfTerm(h),q,max);
|
(me = t_ref((cl_connector*)AtomOfTerm(h),q,max)) >= 0 ) {
|
||||||
|
return me;
|
||||||
}
|
}
|
||||||
n = 2;
|
n = 2;
|
||||||
ostart = HR;
|
ostart = HR;
|
||||||
ref = AbsPair(ostart);
|
ref = AbsPair(ostart);
|
||||||
HR += 2;
|
HR += 2;
|
||||||
q[max].header = Deref(s[0]);
|
|
||||||
} else if (IsApplTerm(t)) {
|
} else if (IsApplTerm(t)) {
|
||||||
|
Int me;
|
||||||
h = (CELL)FunctorOfTerm(t);
|
h = (CELL)FunctorOfTerm(t);
|
||||||
n = ArityOfFunctor((Functor)h);
|
n = ArityOfFunctor((Functor)h);
|
||||||
if (IsExtensionFunctor((Functor)h)) {
|
if (IsExtensionFunctor((Functor)h)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (IsAtomTerm(h)) {
|
if (IsAtomTerm(h) &&
|
||||||
return t_ref((cl_connector*)AtomOfTerm(h),q,max);
|
(me = t_ref((cl_connector*)AtomOfTerm(h),q,max)) >= 0) {
|
||||||
|
return me;
|
||||||
}
|
}
|
||||||
s = RepAppl(t);
|
s = RepAppl(t);
|
||||||
q[max].header = s[0];
|
q[max].header = s[0];
|
||||||
@ -1413,13 +1417,16 @@ static Int create_entry(Term t, Int i, Int j, cl_connector * q, Int max) {
|
|||||||
ref = AbsAppl(ostart);
|
ref = AbsAppl(ostart);
|
||||||
*ostart++ = s[0];
|
*ostart++ = s[0];
|
||||||
HR=ostart+n;
|
HR=ostart+n;
|
||||||
} else if (IsAtomTerm(t) &&
|
} else {
|
||||||
(max = t_ref((cl_connector*)AtomOfTerm(t),q,max)) >= 0) {
|
Int me;
|
||||||
return max;
|
if (IsAtomTerm(t) &&
|
||||||
|
(me = t_ref((cl_connector*)AtomOfTerm(t),q,max)) >= 0 ) {
|
||||||
|
return me;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
q[max].header = h;
|
||||||
q[max].parent = q[i].copy+j;
|
q[max].parent = q[i].copy+j;
|
||||||
q[max].source = t;
|
q[max].source = t;
|
||||||
q[max].copy = ostart;
|
q[max].copy = ostart;
|
||||||
@ -1494,6 +1501,11 @@ Term Yap_BreakCycles(Term inp, UInt arity, Term * listp USES_REGS) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i=0; i< qlen; i++) {
|
||||||
|
CELL *p = IsPairTerm(q[i].source) ? RepPair(q[i].source) : RepAppl(q[i].source);
|
||||||
|
p[0] = q[i].header;
|
||||||
|
}
|
||||||
|
|
||||||
pop_text_stack(lvl);
|
pop_text_stack(lvl);
|
||||||
|
|
||||||
HB = B->cp_h;
|
HB = B->cp_h;
|
||||||
|
@ -85,7 +85,7 @@ native_sources = ["yap4py/yap_wrap.cxx","yap4py/yapi.cpp"]
|
|||||||
|
|
||||||
extensions = [Extension('_yap', native_sources,
|
extensions = [Extension('_yap', native_sources,
|
||||||
define_macros=[('MAJOR_VERSION', '6'),
|
define_macros=[('MAJOR_VERSION', '6'),
|
||||||
('MINOR_VERSION', '4'),
|
('MINOR_VERSION', '5'),
|
||||||
('_YAP_NOT_INSTALLED_', '1'),
|
('_YAP_NOT_INSTALLED_', '1'),
|
||||||
('YAP_PYTHON', '1'),
|
('YAP_PYTHON', '1'),
|
||||||
('PYTHONSWIG', '1'),
|
('PYTHONSWIG', '1'),
|
||||||
@ -115,7 +115,7 @@ package_data = {
|
|||||||
|
|
||||||
data_files=[]
|
data_files=[]
|
||||||
|
|
||||||
version_ns = {'__version__': '6.4.1', 'major-version': '6', 'minor-version': '4', 'patch': '1'}
|
version_ns = {'__version__': '6.5.0', 'major-version': '6', 'minor-version': '5', 'patch': '0'}
|
||||||
|
|
||||||
setup_args = dict(
|
setup_args = dict(
|
||||||
name=name,
|
name=name,
|
||||||
|
@ -94,7 +94,7 @@ undefined_query(G0, M0, Cut) :-
|
|||||||
'$get_undefined_predicates'(M0:G0, MG), !.
|
'$get_undefined_predicates'(M0:G0, MG), !.
|
||||||
|
|
||||||
% undef handler
|
% undef handler
|
||||||
'$undefp_'([M0|G0],MG) :-
|
'$undefp'([M0|G0],MG) :-
|
||||||
% make sure we do not loop on undefined predicates
|
% make sure we do not loop on undefined predicates
|
||||||
'$undef_setup'(M0:G0, Action,Debug,Current, MGI),
|
'$undef_setup'(M0:G0, Action,Debug,Current, MGI),
|
||||||
('$get_undefined_predicates'( MGI, MG )
|
('$get_undefined_predicates'( MGI, MG )
|
||||||
|
@ -72,6 +72,7 @@ d(X, ( X= f(A,A,X)) ).
|
|||||||
d(X, ( X= f(A,A,g(A))) ).
|
d(X, ( X= f(A,A,g(A))) ).
|
||||||
d(X, ( X= f(A,g(X,[A|A]),X)) ).
|
d(X, ( X= f(A,g(X,[A|A]),X)) ).
|
||||||
d(X, ( X= f(X,[X,X])) ).
|
d(X, ( X= f(X,[X,X])) ).
|
||||||
|
d(X, ( X= f(3.14,[22.3,X])) ).
|
||||||
d(X, ( X= f(X,[X,g(X)])) ).
|
d(X, ( X= f(X,[X,g(X)])) ).
|
||||||
d(X, ( X= f(_,X/[X])) ).
|
d(X, ( X= f(_,X/[X])) ).
|
||||||
d(X, ( X= f(_,A/[A]), A= f(X,[X,g(X)])) ).
|
d(X, ( X= f(_,A/[A]), A= f(X,[X,g(X)])) ).
|
||||||
|
Reference in New Issue
Block a user