metas
This commit is contained in:
parent
86decdddde
commit
17a75d79ff
107
C/globals.c
107
C/globals.c
@ -340,6 +340,7 @@ static inline void clean_dirty_tr(tr_fr_ptr TR0 USES_REGS) {
|
|||||||
if (IsVarTerm(p)) {
|
if (IsVarTerm(p)) {
|
||||||
RESET_VARIABLE(p);
|
RESET_VARIABLE(p);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* copy downwards */
|
/* copy downwards */
|
||||||
TrailTerm(TR0 + 1) = TrailTerm(pt);
|
TrailTerm(TR0 + 1) = TrailTerm(pt);
|
||||||
TrailTerm(TR0) = TrailTerm(TR0 + 2) = p;
|
TrailTerm(TR0) = TrailTerm(TR0 + 2) = p;
|
||||||
@ -361,7 +362,8 @@ static int copy_complex_term(register CELL *pt0, register CELL *pt0_end,
|
|||||||
CELL *HLow USES_REGS) {
|
CELL *HLow USES_REGS) {
|
||||||
|
|
||||||
int lvl = push_text_stack();
|
int lvl = push_text_stack();
|
||||||
struct cp_frame *to_visit0, *to_visit = Malloc(1024*sizeof(struct cp_frame));
|
struct cp_frame *to_visit0,
|
||||||
|
*to_visit = Malloc(1024*sizeof(struct cp_frame));
|
||||||
struct cp_frame *to_visit_max;
|
struct cp_frame *to_visit_max;
|
||||||
|
|
||||||
CELL *HB0 = HB;
|
CELL *HB0 = HB;
|
||||||
@ -375,59 +377,48 @@ loop:
|
|||||||
while (pt0 < pt0_end) {
|
while (pt0 < pt0_end) {
|
||||||
register CELL d0;
|
register CELL d0;
|
||||||
register CELL *ptd0;
|
register CELL *ptd0;
|
||||||
++pt0;
|
|
||||||
ptd0 = pt0;
|
ptd0 = ++pt0;
|
||||||
d0 = *ptd0;
|
d0 = *pt0;
|
||||||
|
if (d0 != TermNil)
|
||||||
|
Yap_DebugPlWriteln(d0);
|
||||||
|
deref:
|
||||||
deref_head(d0, copy_term_unk);
|
deref_head(d0, copy_term_unk);
|
||||||
copy_term_nvar : {
|
copy_term_nvar : {
|
||||||
if (IsPairTerm(d0)) {
|
if (IsPairTerm(d0)) {
|
||||||
CELL *ap2 = RepPair(d0);
|
CELL *ap2 = RepPair(d0);
|
||||||
if ((share && ap2 < HB) || (ap2 >= HB && ap2 < HR)) {
|
if (//(share && ap2 < HB) ||
|
||||||
|
(ap2 >= HB && ap2 < HR)) {
|
||||||
/* If this is newer than the current term, just reuse */
|
/* If this is newer than the current term, just reuse */
|
||||||
*ptf++ = d0;
|
*ptf++ = d0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
*ptf = AbsPair(HR);
|
|
||||||
ptf++;
|
|
||||||
#ifdef RATIONAL_TREES
|
|
||||||
if (to_visit >= to_visit_max-32) {
|
if (to_visit >= to_visit_max-32) {
|
||||||
expand_stack(to_visit0, to_visit, to_visit_max, struct cp_frame);
|
expand_stack(to_visit0, to_visit, to_visit_max, struct cp_frame);
|
||||||
}
|
}
|
||||||
|
pt0 = ap2;
|
||||||
to_visit->start_cp = pt0;
|
to_visit->start_cp = pt0;
|
||||||
to_visit->end_cp = pt0_end;
|
to_visit->end_cp = pt0_end = pt0+2;
|
||||||
to_visit->to = ptf;
|
to_visit->to = ptf;
|
||||||
to_visit->oldv = *pt0;
|
d0 = *pt0;
|
||||||
to_visit->ground = ground;
|
to_visit->ground = ground;
|
||||||
/* fool the system into thinking we had a variable there */
|
/* fool the system into thinking we had a variable there */
|
||||||
*pt0 = AbsPair(HR);
|
MaBind(pt0,AbsPair(HR));
|
||||||
to_visit++;
|
to_visit++;
|
||||||
#else
|
ground = true;
|
||||||
if (pt0 < pt0_end) {
|
|
||||||
if (to_visit + 32 >= to_visit_max - 32) {
|
|
||||||
expand_stack(to_visit0, to_visit, to_visit_max, struct cp_frame);
|
|
||||||
|
|
||||||
}
|
|
||||||
to_visit->start_cp = pt0;
|
|
||||||
to_visit->end_cp = pt0_end;
|
|
||||||
to_visit->to = ptf;
|
|
||||||
to_visit->ground = ground;
|
|
||||||
to_visit++;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
ground = TRUE;
|
|
||||||
pt0 = ap2 - 1;
|
|
||||||
pt0_end = ap2 + 1;
|
|
||||||
ptf = HR;
|
|
||||||
HR += 2;
|
HR += 2;
|
||||||
if (HR > ASP - MIN_ARENA_SIZE) {
|
if (HR > ASP - MIN_ARENA_SIZE) {
|
||||||
goto overflow;
|
goto overflow;
|
||||||
}
|
}
|
||||||
|
ptd0 = pt0;
|
||||||
|
goto deref;
|
||||||
} else if (IsApplTerm(d0)) {
|
} else if (IsApplTerm(d0)) {
|
||||||
register Functor f;
|
register Functor f;
|
||||||
register CELL *ap2;
|
register CELL *ap2;
|
||||||
/* store the terms to visit */
|
/* store the terms to visit */
|
||||||
ap2 = RepAppl(d0);
|
ap2 = RepAppl(d0);
|
||||||
if ((share && ap2 < HB) || (ap2 >= HB && ap2 < HR)) {
|
if (//(share && ap2 < HB) ||
|
||||||
|
(ap2 >= HB && ap2 < HR)) {
|
||||||
/* If this is newer than the current term, just reuse */
|
/* If this is newer than the current term, just reuse */
|
||||||
*ptf++ = d0;
|
*ptf++ = d0;
|
||||||
continue;
|
continue;
|
||||||
@ -498,44 +489,28 @@ loop:
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
*ptf = AbsAppl(HR);
|
|
||||||
ptf++;
|
|
||||||
/* store the terms to visit */
|
/* store the terms to visit */
|
||||||
#ifdef RATIONAL_TREES
|
|
||||||
if (to_visit + 32 >= to_visit_max) {
|
|
||||||
expand_stack(to_visit0, to_visit, to_visit_max, struct cp_frame);
|
|
||||||
}
|
|
||||||
to_visit->start_cp = pt0;
|
to_visit->start_cp = pt0;
|
||||||
to_visit->end_cp = pt0_end;
|
to_visit->end_cp = pt0_end;
|
||||||
to_visit->to = ptf;
|
to_visit->to = ptf;
|
||||||
to_visit->oldv = *pt0;
|
|
||||||
to_visit->ground = ground;
|
to_visit->ground = ground;
|
||||||
|
if (++to_visit >= to_visit_max-32) {
|
||||||
|
expand_stack(to_visit0, to_visit, to_visit_max, struct cp_frame);
|
||||||
|
}
|
||||||
/* fool the system into thinking we had a variable there */
|
/* fool the system into thinking we had a variable there */
|
||||||
*pt0 = AbsAppl(HR);
|
ptf = HR;
|
||||||
|
*ptf++ = d0 = *ap2;
|
||||||
|
MaBind(ap2++,AbsAppl(HR));
|
||||||
to_visit++;
|
to_visit++;
|
||||||
#else
|
ground = true;
|
||||||
if (pt0 < pt0_end) {
|
arity_t a = ArityOfFunctor((Functor)d0);
|
||||||
if (to_visit++ >= (CELL **)AuxSp) {
|
HR = ptf+a;
|
||||||
expand_stack(to_visit0, to_visit, to_visit_max, struct cp_frame);
|
|
||||||
}
|
|
||||||
to_visit->start_cp = pt0;
|
|
||||||
to_visit->end_cp = pt0_end;
|
|
||||||
to_visit->to = ptf;
|
|
||||||
to_visit->ground = ground;
|
|
||||||
to_visit++;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
ground = (f != FunctorMutable);
|
|
||||||
d0 = ArityOfFunctor(f);
|
|
||||||
pt0 = ap2;
|
|
||||||
pt0_end = ap2 + d0;
|
|
||||||
/* store the functor for the new term */
|
|
||||||
HR[0] = (CELL)f;
|
|
||||||
ptf = HR + 1;
|
|
||||||
HR += 1 + d0;
|
|
||||||
if (HR > ASP - MIN_ARENA_SIZE) {
|
if (HR > ASP - MIN_ARENA_SIZE) {
|
||||||
goto overflow;
|
goto overflow;
|
||||||
}
|
}
|
||||||
|
pt0 = ap2;
|
||||||
|
pt0_end = ap2+a;
|
||||||
|
ground = (f != FunctorMutable);
|
||||||
} else {
|
} else {
|
||||||
/* just copy atoms or integers */
|
/* just copy atoms or integers */
|
||||||
*ptf++ = d0;
|
*ptf++ = d0;
|
||||||
@ -544,13 +519,13 @@ loop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
derefa_body(d0, ptd0, copy_term_unk, copy_term_nvar);
|
derefa_body(d0, ptd0, copy_term_unk, copy_term_nvar);
|
||||||
ground = FALSE;
|
ground = false;
|
||||||
/* don't need to copy variables if we want to share the global term */
|
/* don't need to copy variables if we want to share the global term */
|
||||||
if ((share && ptd0 < HB && ptd0 > H0) || (ptd0 >= HLow && ptd0 < HR)) {
|
if (//(share && ptd0 < HB && ptd0 > H0) ||
|
||||||
|
(ptd0 >= HLow && ptd0 < HR)) {
|
||||||
/* we have already found this cell */
|
/* we have already found this cell */
|
||||||
*ptf++ = (CELL)ptd0;
|
*ptf++ = (CELL)ptd0;
|
||||||
} else {
|
} else {
|
||||||
#if COROUTINING
|
|
||||||
if (copy_att_vars && GlobalIsAttachedTerm((CELL)ptd0)) {
|
if (copy_att_vars && GlobalIsAttachedTerm((CELL)ptd0)) {
|
||||||
/* if unbound, call the standard copy term routine */
|
/* if unbound, call the standard copy term routine */
|
||||||
struct cp_frame *bp;
|
struct cp_frame *bp;
|
||||||
@ -572,16 +547,13 @@ loop:
|
|||||||
Bind_and_Trail(ptd0, new);
|
Bind_and_Trail(ptd0, new);
|
||||||
ptf++;
|
ptf++;
|
||||||
} else {
|
} else {
|
||||||
#endif
|
|
||||||
/* first time we met this term */
|
/* first time we met this term */
|
||||||
RESET_VARIABLE(ptf);
|
RESET_VARIABLE(ptf);
|
||||||
if ((ADDR)TR > LOCAL_TrailTop - MIN_ARENA_SIZE)
|
if ((ADDR)TR > LOCAL_TrailTop - MIN_ARENA_SIZE)
|
||||||
goto trail_overflow;
|
goto trail_overflow;
|
||||||
Bind_and_Trail(ptd0, (CELL)ptf);
|
MaBind(ptd0, (CELL)ptf);
|
||||||
ptf++;
|
ptf++;
|
||||||
#ifdef COROUTINING
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,9 +563,6 @@ loop:
|
|||||||
pt0 = to_visit->start_cp;
|
pt0 = to_visit->start_cp;
|
||||||
pt0_end = to_visit->end_cp;
|
pt0_end = to_visit->end_cp;
|
||||||
ptf = to_visit->to;
|
ptf = to_visit->to;
|
||||||
#ifdef RATIONAL_TREES
|
|
||||||
*pt0 = to_visit->oldv;
|
|
||||||
#endif
|
|
||||||
ground = (ground && to_visit->ground);
|
ground = (ground && to_visit->ground);
|
||||||
goto loop;
|
goto loop;
|
||||||
}
|
}
|
||||||
@ -611,7 +580,6 @@ overflow:
|
|||||||
/* we've done it */
|
/* we've done it */
|
||||||
/* restore our nice, friendly, term to its original state */
|
/* restore our nice, friendly, term to its original state */
|
||||||
HB = HB0;
|
HB = HB0;
|
||||||
#ifdef RATIONAL_TREES
|
|
||||||
while (to_visit > to_visit0) {
|
while (to_visit > to_visit0) {
|
||||||
to_visit--;
|
to_visit--;
|
||||||
pt0 = to_visit->start_cp;
|
pt0 = to_visit->start_cp;
|
||||||
@ -619,7 +587,6 @@ overflow:
|
|||||||
ptf = to_visit->to;
|
ptf = to_visit->to;
|
||||||
*pt0 = to_visit->oldv;
|
*pt0 = to_visit->oldv;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
reset_trail(TR0);
|
reset_trail(TR0);
|
||||||
pop_text_stack(lvl);
|
pop_text_stack(lvl);
|
||||||
return -1;
|
return -1;
|
||||||
@ -630,7 +597,6 @@ trail_overflow:
|
|||||||
/* we've done it */
|
/* we've done it */
|
||||||
/* restore our nice, friendly, term to its original state */
|
/* restore our nice, friendly, term to its original state */
|
||||||
HB = HB0;
|
HB = HB0;
|
||||||
#ifdef RATIONAL_TREES
|
|
||||||
while (to_visit > to_visit0) {
|
while (to_visit > to_visit0) {
|
||||||
to_visit--;
|
to_visit--;
|
||||||
pt0 = to_visit->start_cp;
|
pt0 = to_visit->start_cp;
|
||||||
@ -638,7 +604,6 @@ trail_overflow:
|
|||||||
ptf = to_visit->to;
|
ptf = to_visit->to;
|
||||||
*pt0 = to_visit->oldv;
|
*pt0 = to_visit->oldv;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
reset_trail(TR0);
|
reset_trail(TR0);
|
||||||
pop_text_stack(lvl);
|
pop_text_stack(lvl);
|
||||||
return -4;
|
return -4;
|
||||||
|
@ -24,7 +24,7 @@ static char SccsId[] = "%W% %G%";
|
|||||||
#include "YapHeap.h"
|
#include "YapHeap.h"
|
||||||
#include "Yatom.h"
|
#include "Yatom.h"
|
||||||
|
|
||||||
static Int currgent_module(USES_REGS1);
|
static Int current_module(USES_REGS1);
|
||||||
static Int current_module1(USES_REGS1);
|
static Int current_module1(USES_REGS1);
|
||||||
static ModEntry *LookupModule(Term a);
|
static ModEntry *LookupModule(Term a);
|
||||||
static ModEntry *LookupSystemModule(Term a);
|
static ModEntry *LookupSystemModule(Term a);
|
||||||
|
@ -52,6 +52,7 @@ typedef struct non_single_struct_t {
|
|||||||
}\
|
}\
|
||||||
LIST0;\
|
LIST0;\
|
||||||
ptd0 = RepPair(d0);\
|
ptd0 = RepPair(d0);\
|
||||||
|
if (*ptd0 == TermFreeTerm) continue;\
|
||||||
to_visit->pt0 = pt0;\
|
to_visit->pt0 = pt0;\
|
||||||
to_visit->pt0_end = pt0_end;\
|
to_visit->pt0_end = pt0_end;\
|
||||||
to_visit->ptd0 = ptd0;\
|
to_visit->ptd0 = ptd0;\
|
||||||
@ -59,7 +60,7 @@ typedef struct non_single_struct_t {
|
|||||||
to_visit ++;\
|
to_visit ++;\
|
||||||
d0 = ptd0[0];\
|
d0 = ptd0[0];\
|
||||||
pt0 = ptd0;\
|
pt0 = ptd0;\
|
||||||
*ptd0 = TermNil;\
|
*ptd0 = TermFreeTerm;\
|
||||||
pt0_end = pt0 + 1;\
|
pt0_end = pt0 + 1;\
|
||||||
goto list_loop;\
|
goto list_loop;\
|
||||||
} else if (IsApplTerm(d0)) {\
|
} else if (IsApplTerm(d0)) {\
|
||||||
@ -2269,9 +2270,8 @@ static Term free_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end
|
|||||||
*to_visit = Malloc(1024*sizeof( struct non_single_struct_t)),
|
*to_visit = Malloc(1024*sizeof( struct non_single_struct_t)),
|
||||||
*to_visit0 = to_visit,
|
*to_visit0 = to_visit,
|
||||||
*to_visit_max = to_visit+1024;
|
*to_visit_max = to_visit+1024;
|
||||||
|
Term o = TermNil;
|
||||||
CELL *InitialH = HR;
|
CELL *InitialH = HR;
|
||||||
*HR++ = MkAtomTerm(AtomDollar);
|
|
||||||
|
|
||||||
to_visit0 = to_visit;
|
to_visit0 = to_visit;
|
||||||
restart:
|
restart:
|
||||||
while (pt0 < pt0_end) {
|
while (pt0 < pt0_end) {
|
||||||
@ -2284,7 +2284,7 @@ static Term free_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end
|
|||||||
deref_head(d0, vars_within_term_unk);
|
deref_head(d0, vars_within_term_unk);
|
||||||
vars_within_term_nvar:
|
vars_within_term_nvar:
|
||||||
{
|
{
|
||||||
WALK_COMPLEX_TERM()
|
WALK_COMPLEX_TERM();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2293,10 +2293,13 @@ static Term free_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end
|
|||||||
*ptd0 = TermNil;
|
*ptd0 = TermNil;
|
||||||
/* leave an empty slot to fill in later */
|
/* leave an empty slot to fill in later */
|
||||||
if (HR+1024 > ASP) {
|
if (HR+1024 > ASP) {
|
||||||
|
o = TermNil;
|
||||||
goto global_overflow;
|
goto global_overflow;
|
||||||
}
|
}
|
||||||
HR[0] = (CELL)ptd0;
|
HR[0] = (CELL)ptd0;
|
||||||
HR ++;
|
HR[1] = o;
|
||||||
|
o = AbsPair(HR);
|
||||||
|
HR += 2;
|
||||||
/* next make sure noone will see this as a variable again */
|
/* next make sure noone will see this as a variable again */
|
||||||
if (TR > (tr_fr_ptr)LOCAL_TrailTop - 256) {
|
if (TR > (tr_fr_ptr)LOCAL_TrailTop - 256) {
|
||||||
/* Trail overflow */
|
/* Trail overflow */
|
||||||
@ -2319,12 +2322,7 @@ static Term free_vars_in_complex_term(register CELL *pt0, register CELL *pt0_end
|
|||||||
|
|
||||||
clean_tr(TR0 PASS_REGS);
|
clean_tr(TR0 PASS_REGS);
|
||||||
pop_text_stack(lvl);
|
pop_text_stack(lvl);
|
||||||
if (HR > InitialH+1) {
|
return o;
|
||||||
InitialH[0] = (CELL)Yap_MkFunctor(AtomDollar, (HR-InitialH)-1);
|
|
||||||
return AbsAppl(InitialH);
|
|
||||||
} else {
|
|
||||||
return MkAtomTerm(AtomDollar);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def_trail_overflow();
|
def_trail_overflow();
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
[
|
[
|
||||||
class_drop/2
|
class_drop/2
|
||||||
]).
|
]).
|
||||||
|
|
||||||
do_checks(Y,Ty,St,Li,Or,Cl,No,Later) :-
|
do_checks(Y,Ty,St,Li,Or,Cl,No,Later) :-
|
||||||
numbers_only(Y),
|
numbers_only(Y),
|
||||||
verify_nonzero(No,Y),
|
verify_nonzero(No,Y),
|
||||||
@ -76,7 +76,7 @@ numbers_only(Y) :-
|
|||||||
; throw(type_error(_X = Y,2,'a rational number',Y))
|
; throw(type_error(_X = Y,2,'a rational number',Y))
|
||||||
),
|
),
|
||||||
!.
|
!.
|
||||||
|
ø
|
||||||
% verify_nonzero(Nonzero,Y)
|
% verify_nonzero(Nonzero,Y)
|
||||||
%
|
%
|
||||||
% if Nonzero = nonzero, then verify that Y is not zero
|
% if Nonzero = nonzero, then verify that Y is not zero
|
||||||
|
@ -43,6 +43,10 @@
|
|||||||
project_nonlin/3,
|
project_nonlin/3,
|
||||||
collect_nonlin/3
|
collect_nonlin/3
|
||||||
]).
|
]).
|
||||||
|
:- use_module(library(maplist),
|
||||||
|
[
|
||||||
|
maplist/2
|
||||||
|
]).
|
||||||
|
|
||||||
% l2conj(List,Conj)
|
% l2conj(List,Conj)
|
||||||
%
|
%
|
||||||
|
@ -47,6 +47,10 @@
|
|||||||
dump_nonzero/3,
|
dump_nonzero/3,
|
||||||
clp_type/2
|
clp_type/2
|
||||||
]).
|
]).
|
||||||
|
:- use_module(library(maplist),
|
||||||
|
[
|
||||||
|
maplist/2
|
||||||
|
]).
|
||||||
|
|
||||||
|
|
||||||
clp_type(Var,Type) :-
|
clp_type(Var,Type) :-
|
||||||
|
@ -63,6 +63,10 @@
|
|||||||
[
|
[
|
||||||
class_drop/2
|
class_drop/2
|
||||||
]).
|
]).
|
||||||
|
:- use_module(library(maplist),
|
||||||
|
[
|
||||||
|
maplist/2
|
||||||
|
]).
|
||||||
|
|
||||||
do_checks(Y,Ty,St,Li,Or,Cl,No,Later) :-
|
do_checks(Y,Ty,St,Li,Or,Cl,No,Later) :-
|
||||||
numbers_only(Y),
|
numbers_only(Y),
|
||||||
|
Reference in New Issue
Block a user