first steps to allow mavars with tabling
fix trailing for tabling with multiple get_cons git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1356 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
71
C/mavar.c
71
C/mavar.c
@@ -110,53 +110,16 @@ p_setarg(void)
|
||||
== B->TR) we will add a little something ;-).
|
||||
*/
|
||||
|
||||
#if FROZEN_STACKS
|
||||
static void
|
||||
CreateTimedVar(Term val)
|
||||
{
|
||||
timed_var *tv = (timed_var *)H;
|
||||
tv->clock = MkIntegerTerm(B->cp_tr-(tr_fr_ptr)Yap_TrailBase);
|
||||
if (B->cp_tr == TR) {
|
||||
/* we run the risk of not making non-determinate bindings before
|
||||
the end of the night */
|
||||
/* so we just init a TR cell that will not harm anyone */
|
||||
Bind((CELL *)(TR+1),AbsAppl(H-1));
|
||||
}
|
||||
tv->value = val;
|
||||
H += sizeof(timed_var)/sizeof(CELL);
|
||||
}
|
||||
|
||||
static void
|
||||
CreateEmptyTimedVar(void)
|
||||
{
|
||||
timed_var *tv = (timed_var *)H;
|
||||
tv->clock = MkIntegerTerm(B->cp_tr-(tr_fr_ptr)Yap_TrailBase);
|
||||
if (B->cp_tr == TR) {
|
||||
/* we run the risk of not making non-determinate bindings before
|
||||
the end of the night */
|
||||
/* so we just init a TR cell that will not harm anyone */
|
||||
Bind((CELL *)(TR+1),AbsAppl(H-1));
|
||||
}
|
||||
RESET_VARIABLE(&(tv->value));
|
||||
H += sizeof(timed_var)/sizeof(CELL);
|
||||
}
|
||||
#endif
|
||||
|
||||
static Term
|
||||
NewTimedVar(CELL val)
|
||||
{
|
||||
Term out = AbsAppl(H);
|
||||
#if FROZEN_STACKS
|
||||
*H++ = (CELL)FunctorMutable;
|
||||
CreateTimedVar(val);
|
||||
#else
|
||||
timed_var *tv;
|
||||
*H++ = (CELL)FunctorMutable;
|
||||
tv = (timed_var *)H;
|
||||
RESET_VARIABLE(&(tv->clock));
|
||||
tv->value = val;
|
||||
H += sizeof(timed_var)/sizeof(CELL);
|
||||
#endif
|
||||
return(out);
|
||||
}
|
||||
|
||||
@@ -170,17 +133,12 @@ Term
|
||||
Yap_NewEmptyTimedVar(void)
|
||||
{
|
||||
Term out = AbsAppl(H);
|
||||
#if FROZEN_STACKS
|
||||
*H++ = (CELL)FunctorMutable;
|
||||
CreateEmptyTimedVar();
|
||||
#else
|
||||
timed_var *tv;
|
||||
*H++ = (CELL)FunctorMutable;
|
||||
tv = (timed_var *)H;
|
||||
RESET_VARIABLE(&(tv->clock));
|
||||
RESET_VARIABLE(&(tv->value));
|
||||
H += sizeof(timed_var)/sizeof(CELL);
|
||||
#endif
|
||||
return(out);
|
||||
}
|
||||
|
||||
@@ -204,31 +162,13 @@ UpdateTimedVar(Term inv, Term new)
|
||||
{
|
||||
timed_var *tv = (timed_var *)(RepAppl(inv)+1);
|
||||
CELL t = tv->value;
|
||||
#if FROZEN_STACKS
|
||||
tr_fr_ptr timestmp = (tr_fr_ptr)Yap_TrailBase + IntegerOfTerm(tv->clock);
|
||||
|
||||
if (B->cp_tr <= timestmp && timestmp <= TR) {
|
||||
/* last assignment more recent than last B */
|
||||
#if SBA
|
||||
if (Unsigned((Int)(tv)-(Int)(H_FZ)) >
|
||||
Unsigned((Int)(B_FZ)-(Int)(H_FZ)))
|
||||
*STACK_TO_SBA(&(tv->value)) = new;
|
||||
else
|
||||
#endif
|
||||
tv->value = new;
|
||||
if (Unsigned((Int)(tv)-(Int)(HBREG)) >
|
||||
Unsigned(BBREG)-(Int)(HBREG))
|
||||
TrailVal(timestmp-1) = new;
|
||||
} else {
|
||||
Term nclock;
|
||||
MaBind(&(tv->value), new);
|
||||
nclock = MkIntegerTerm(TR-(tr_fr_ptr)Yap_TrailBase);
|
||||
MaBind(&(tv->clock), nclock);
|
||||
}
|
||||
#else
|
||||
CELL* timestmp = (CELL *)(tv->clock);
|
||||
|
||||
if (B->cp_h <= timestmp) {
|
||||
if (timestmp > B->cp_h
|
||||
#if FROZEN_STACKS
|
||||
&& timestmp > H_FZ
|
||||
#endif
|
||||
) {
|
||||
/* last assignment more recent than last B */
|
||||
#if SBA
|
||||
if (Unsigned((Int)(tv)-(Int)(H_FZ)) >
|
||||
@@ -243,7 +183,6 @@ UpdateTimedVar(Term inv, Term new)
|
||||
*H++ = TermFoundVar;
|
||||
MaBind(&(tv->clock), nclock);
|
||||
}
|
||||
#endif
|
||||
return(t);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user