diff --git a/C/attvar.c b/C/attvar.c index c257ff77e..505d6d407 100644 --- a/C/attvar.c +++ b/C/attvar.c @@ -437,20 +437,31 @@ GetAllAtts(attvar_record *attv) { static Term AllAttVars(Term t) { - if (t == TermNil) { - return t; - } else { - attvar_record *attv = (attvar_record *)VarOfTerm(t); - if (!IsVarTerm(attv->Done) || !IsUnboundVar(&attv->Done)) - return AllAttVars(attv->NS); - else return MkPairTerm(t,AllAttVars(attv->NS)); + CELL *h0 = H; + + while (t != TermNil) { + attvar_record *attv; + + if (ASP - H < 1024) { + H = h0; + return 0L; + } + attv = (attvar_record *)VarOfTerm(t); + if (IsVarTerm(attv->Done) && IsUnboundVar(&attv->Done)) { + if (H != h0) { + H[-1] = AbsPair(H); + } + H[0] = t; + H += 2; + } + t = attv->NS; + } + if (H != h0) { + H[-1] = TermNil; + return AbsPair(h0); + } else { + return TermNil; } -} - -Term -Yap_CurrentAttVars(void) { - return(AllAttVars(Yap_ReadTimedVar(AttsMutableList))); - } static Int @@ -650,8 +661,14 @@ p_n_atts(void) static Int p_all_attvars(void) { - Term t = Yap_ReadTimedVar(AttsMutableList); - return Yap_unify(ARG1,AllAttVars(t)); + Term t = Yap_ReadTimedVar(AttsMutableList), out; + while ((out = AllAttVars(t)) == 0L) { + if (!Yap_gc(1, ENV, P)) { + Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage); + return FALSE; + } + } + return Yap_unify(ARG1,out); } static Int diff --git a/C/grow.c b/C/grow.c index 8ebee5fff..af0709313 100644 --- a/C/grow.c +++ b/C/grow.c @@ -22,6 +22,7 @@ #include "alloc.h" #include "sshift.h" #include "compile.h" +#include "attvar.h" #if HAVE_STRING_H #include #endif @@ -590,8 +591,11 @@ static_growglobal(long size, CELL **ptr) { UInt start_growth_time, growth_time; int gc_verbose; + char *omax = (ADDR)DelayTop(); /* adjust to a multiple of 256) */ + if (size < (omax-Yap_GlobalBase)/8) + size = (omax-Yap_GlobalBase)/8; size = AdjustPageSize(size); Yap_ErrorMessage = NULL; if (!Yap_ExtendWorkSpace(size)) { diff --git a/H/Yapproto.h b/H/Yapproto.h index fc19a669b..86e4376d0 100644 --- a/H/Yapproto.h +++ b/H/Yapproto.h @@ -10,7 +10,7 @@ * File: Yap.proto * * mods: * * comments: Function declarations for YAP * -* version: $Id: Yapproto.h,v 1.59 2005-08-04 15:45:53 ricroc Exp $ * +* version: $Id: Yapproto.h,v 1.60 2005-08-17 20:13:49 vsc Exp $ * *************************************************************************/ /* prototype file for Yap */ @@ -91,7 +91,6 @@ void STD_PROTO(Yap_InitAnalystPreds,(void)); void STD_PROTO(Yap_InitArrayPreds,(void)); /* attvar.c */ -Term STD_PROTO(Yap_CurrentAttVars,(void)); void STD_PROTO(Yap_InitAttVarPreds,(void)); /* bb.c */ diff --git a/pl/boot.yap b/pl/boot.yap index ca529adf8..369cf1400 100644 --- a/pl/boot.yap +++ b/pl/boot.yap @@ -14,14 +14,6 @@ * comments: boot file for Prolog * * * *************************************************************************/ -% process an input clause - -'$test'(I,D,H,[Y|L]) :- - arg(I,D,X), ( X=':' ; integer(X)), - arg(I,H,Y), var(Y), !, - I1 is I-1, - '$module_u_vars'(I1,D,H,L). - % This one should come first so that disjunctions and long distance % cuts are compiled right with co-routining.