From 18eca09bd0e821b7a368dc09b687a5f1b3d0e681 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Tue, 31 Mar 2009 21:55:17 +0100 Subject: [PATCH] multiple assignment variables should always be globalised. --- C/mavar.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/C/mavar.c b/C/mavar.c index af36cae61..2e553c517 100644 --- a/C/mavar.c +++ b/C/mavar.c @@ -121,8 +121,15 @@ p_setarg(void) static Term NewTimedVar(CELL val) { - Term out = AbsAppl(H); + Term out; timed_var *tv; + if (IsVarTerm((val = Deref(val))) && + VarOfTerm(val) > H) { + Term nval = MkVarTerm(); + Bind_Local(VarOfTerm(val), nval); + val = nval; + } + out = AbsAppl(H); *H++ = (CELL)FunctorMutable; tv = (timed_var *)H; RESET_VARIABLE(&(tv->clock)); @@ -171,7 +178,12 @@ UpdateTimedVar(Term inv, Term new) timed_var *tv = (timed_var *)(RepAppl(inv)+1); CELL t = tv->value; CELL* timestmp = (CELL *)(tv->clock); - + if (IsVarTerm((new = Deref(new))) && + VarOfTerm(new) > H) { + Term nnew = MkVarTerm(); + Bind_Local(VarOfTerm(new), nnew); + new = nnew; + } if (timestmp > B->cp_h #if FROZEN_STACKS && timestmp > H_FZ