more ezo stuff
This commit is contained in:
parent
ec5f7ebb28
commit
459ab89d7d
@ -159,7 +159,7 @@ Yap_AllocCodeSpace(size_t size)
|
||||
}
|
||||
|
||||
static inline char *
|
||||
call_realloc(char *p, unsigned long int size)
|
||||
call_realloc(char *p, size_t size)
|
||||
{
|
||||
CACHE_REGS
|
||||
char *out;
|
||||
|
4
C/exo.c
4
C/exo.c
@ -186,13 +186,13 @@ HASH_FVN_1A(UInt arity, CELL *cl, UInt bnds[], UInt sz);
|
||||
spread over j quadrants.
|
||||
*/
|
||||
extern inline BITS32
|
||||
HASH_FVN_1A(UInt arity, CELL *cl, UInt bnds[], UInt sz)
|
||||
HASH_FVN_1A(UInt ar, CELL *cl, UInt bnds[], UInt sz)
|
||||
{
|
||||
UInt hash;
|
||||
UInt j=0;
|
||||
|
||||
hash = FNV32_OFFSET;
|
||||
while (j < arity) {
|
||||
while (j < ar) {
|
||||
if (bnds[j]) {
|
||||
unsigned char *i=(unsigned char*)(cl+j);
|
||||
unsigned char *m=(unsigned char*)(cl+(j+1));
|
||||
|
64
C/exo_udi.c
64
C/exo_udi.c
@ -137,7 +137,7 @@ IntervalUDIRefitIndex(struct index_t **ip, UInt b[] USES_REGS)
|
||||
/* it is bound, use hash */
|
||||
if (it->bmap & b[i]) return;
|
||||
/* no constraints, nothing to gain */
|
||||
if (!IsAttVar(VarOfTerm(XREGS[i+1]))) return;
|
||||
//if (!IsAttVar(VarOfTerm(Deref(XREGS[i+1])))) return;
|
||||
LOCAL_exo_it = it;
|
||||
LOCAL_exo_base = it->bcls;
|
||||
LOCAL_exo_arity = it->arity;
|
||||
@ -161,9 +161,9 @@ IntervalUDIRefitIndex(struct index_t **ip, UInt b[] USES_REGS)
|
||||
|
||||
/* be conservative */
|
||||
if (it->udi_free_args)
|
||||
sz = sizeof(BITS32)*(3*it->ntrys+2*it->nentries);
|
||||
sz = sizeof(BITS32)*(3*it->ntrys+3*it->nentries);
|
||||
else
|
||||
sz = sizeof(BITS32)*(2*it->ntrys+it->nentries);
|
||||
sz = sizeof(BITS32)*(2*it->ntrys+2*it->nentries);
|
||||
/* allocate space */
|
||||
if (!(it->udi_data = (BITS32*)Yap_AllocCodeSpace(sz)))
|
||||
return;
|
||||
@ -364,36 +364,44 @@ Interval(struct index_t *it, Term min, Term max, Term op, BITS32 off USES_REGS)
|
||||
} else if (at == AtomMin) {
|
||||
Int x0, xe, x;
|
||||
|
||||
x0 = pt-pt0;
|
||||
xe = end-pt0;
|
||||
S = EXO_OFFSET_TO_ADDRESS(it, pt[0]);
|
||||
x = NEXT_DIFFERENT(x0, x0, end0, xe);
|
||||
if (x < xe ) {
|
||||
YENV[-5] = (CELL)( pt0 ); // base for array of pointed pointers
|
||||
YENV[-4] = MkIntegerTerm( x ); // where we are in pt0 array
|
||||
YENV[-3] = MkIntegerTerm( xe ); // our visit will end here
|
||||
YENV[-2] = MkIntegerTerm( x0 ); // our visit started here
|
||||
YENV[-1] = (CELL)( end0 ); // base for array into pt
|
||||
YENV -= 5;
|
||||
return it->code;
|
||||
if (!(it->udi_free_args)) {
|
||||
S = EXO_OFFSET_TO_ADDRESS(it, pt[0]);
|
||||
} else {
|
||||
x0 = pt-pt0;
|
||||
xe = end-pt0;
|
||||
S = EXO_OFFSET_TO_ADDRESS(it, pt[0]);
|
||||
x = NEXT_DIFFERENT(x0, x0, end0, xe);
|
||||
if (x < xe ) {
|
||||
YENV[-5] = (CELL)( pt0 ); // base for array of pointed pointers
|
||||
YENV[-4] = MkIntegerTerm( x ); // where we are in pt0 array
|
||||
YENV[-3] = MkIntegerTerm( xe ); // our visit will end here
|
||||
YENV[-2] = MkIntegerTerm( x0 ); // our visit started here
|
||||
YENV[-1] = (CELL)( end0 ); // base for array into pt
|
||||
YENV -= 5;
|
||||
return it->code;
|
||||
}
|
||||
}
|
||||
return NEXTOP(NEXTOP(it->code,lp),lp);
|
||||
} else if (at == AtomMax) {
|
||||
Int x0, xe, x, y;
|
||||
|
||||
x0 = pt-pt0;
|
||||
xe = end-pt0;
|
||||
y = BIGGEST_EL( x0, end0, xe );
|
||||
S = EXO_OFFSET_TO_ADDRESS(it, pt[0]);
|
||||
x = NEXT_DIFFERENT(x0, x0, end0, xe);
|
||||
if (x < xe ) {
|
||||
YENV[-5] = (CELL)( pt0 ); // base for array of pointed pointers
|
||||
YENV[-4] = MkIntegerTerm( -x ); // where we are in pt0 array
|
||||
YENV[-3] = MkIntegerTerm( xe ); // our visit will end here
|
||||
YENV[-2] = MkIntegerTerm( x0 ); // our visit started here
|
||||
YENV[-1] = (CELL)( end0 ); // base for array into pt
|
||||
YENV -= 5;
|
||||
return it->code;
|
||||
if (!(it->udi_free_args)) {
|
||||
S = EXO_OFFSET_TO_ADDRESS(it, end[0]);
|
||||
} else {
|
||||
x0 = pt-pt0;
|
||||
xe = end-pt0;
|
||||
y = BIGGEST_EL( x0, end0, xe );
|
||||
S = EXO_OFFSET_TO_ADDRESS(it, pt[0]);
|
||||
x = NEXT_DIFFERENT(x0, x0, end0, xe);
|
||||
if (x < xe ) {
|
||||
YENV[-5] = (CELL)( pt0 ); // base for array of pointed pointers
|
||||
YENV[-4] = MkIntegerTerm( -x ); // where we are in pt0 array
|
||||
YENV[-3] = MkIntegerTerm( xe ); // our visit will end here
|
||||
YENV[-2] = MkIntegerTerm( x0 ); // our visit started here
|
||||
YENV[-1] = (CELL)( end0 ); // base for array into pt
|
||||
YENV -= 5;
|
||||
return it->code;
|
||||
}
|
||||
}
|
||||
return NEXTOP(NEXTOP(it->code,lp),lp);
|
||||
}
|
||||
|
@ -9,13 +9,12 @@
|
||||
:- module(exo_interval,
|
||||
[max/2,
|
||||
min/2,
|
||||
any/2,
|
||||
max/1,
|
||||
min/1,
|
||||
any/2,
|
||||
maximum/1,
|
||||
minimum/1,
|
||||
any/1,
|
||||
max/3,
|
||||
min/3,
|
||||
any/3,
|
||||
(#<)/2,
|
||||
(#>)/2,
|
||||
(#=<)/2,
|
||||
@ -27,31 +26,33 @@
|
||||
op(700, xfx, (#=<)),
|
||||
op(700, xfx, (#=))]).
|
||||
|
||||
:- meta_predicate max(?,0,?), min(?,0,?), any(?,0,?).
|
||||
:- meta_predicate max(?,0), min(?,0), any(?,0).
|
||||
|
||||
max(X, G, X) :-
|
||||
max(X, G) :-
|
||||
insert_atts(X, i(_,_,max)),
|
||||
call(G).
|
||||
|
||||
min(X, G, X) :-
|
||||
min(X, G) :-
|
||||
insert_atts(X, i(_,_,min)),
|
||||
call(G).
|
||||
|
||||
max(X, X) :-
|
||||
insert_atts(X, i(_,_,max)).
|
||||
|
||||
min(X, X) :-
|
||||
insert_atts(X, i(_,_,min)).
|
||||
|
||||
max(X) :-
|
||||
insert_atts(X, i(_,_,max)).
|
||||
|
||||
maximum(X) :-
|
||||
insert_atts(X, i(_,_,maximum)).
|
||||
|
||||
any(X) :-
|
||||
insert_atts(X, i(_,_,any)).
|
||||
|
||||
min(X) :-
|
||||
insert_atts(X, i(_,_,min)).
|
||||
|
||||
minimum(X) :-
|
||||
insert_atts(X, i(_,_,minimum)).
|
||||
|
||||
least(X) :-
|
||||
insert_atts(X, i(_,_,least)).
|
||||
|
||||
X #> Y :-
|
||||
( var(X) -> insert_atts(X, i(Y,_,_))
|
||||
|
Reference in New Issue
Block a user