From 27a98ecdde5ef8401b6bfd7865b242b0cf4db821 Mon Sep 17 00:00:00 2001 From: vsc Date: Fri, 10 Sep 2004 20:18:01 +0000 Subject: [PATCH] add attvar/1 to system. sort before printing attributed variables to get rid of duplicates. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1132 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/attvar.c | 4 +++- C/iopreds.c | 8 +++++--- C/tracer.c | 2 -- docs/yap.tex | 9 ++++++++- pl/corout.yap | 14 +++++++------- pl/ground.yap | 5 +++++ 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/C/attvar.c b/C/attvar.c index f785f8177..4faa0ba9d 100644 --- a/C/attvar.c +++ b/C/attvar.c @@ -149,6 +149,8 @@ WakeAttVar(CELL* pt1, CELL reg2) CELL *bind_ptr; if (IsVarTerm(reg2)) { + if (pt1 == VarOfTerm(reg2)) + return; if (IsAttachedTerm(reg2)) { attvar_record *susp2 = (attvar_record *)VarOfTerm(reg2); @@ -711,7 +713,7 @@ void Yap_InitAttVarPreds(void) #endif /* COROUTINING */ Yap_InitCPred("all_attvars", 1, p_all_attvars, SafePredFlag); CurrentModule = OldCurrentModule; - Yap_InitCPred("$is_att_variable", 1, p_is_attvar, SafePredFlag|TestPredFlag); + Yap_InitCPred("attvar", 1, p_is_attvar, SafePredFlag|TestPredFlag); Yap_InitCPred("$att_bound", 1, p_attvar_bound, SafePredFlag|TestPredFlag); } diff --git a/C/iopreds.c b/C/iopreds.c index 7f18faba1..a24a13c3f 100644 --- a/C/iopreds.c +++ b/C/iopreds.c @@ -2799,10 +2799,11 @@ syntax_error (TokEntry * tokptr) Term ts[2]; if (H > ASP-1024) { - H = Hi; tf[3] = TermNil; err = 0; end = 0; + /* for some reason moving this earlier confuses gcc on solaris */ + H = Hi; break; } if (tokptr == Yap_toktide) { @@ -2813,8 +2814,9 @@ syntax_error (TokEntry * tokptr) switch (tokptr->Tok) { case Name_tok: { - Term t0 = MkAtomTerm((Atom)info); - ts[0] = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("atom"),1),1,&t0); + Term t0[1]; + t0[0] = MkAtomTerm((Atom)info); + ts[0] = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("atom"),1),1,t0); } break; case Number_tok: diff --git a/C/tracer.c b/C/tracer.c index d8abbfe13..413f95013 100644 --- a/C/tracer.c +++ b/C/tracer.c @@ -120,8 +120,6 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) /* extern int gc_calls; */ vsc_count++; - if (vsc_count < 464900) - return; #ifdef COMMENTED // if (vsc_count == 218280) // vsc_xstop = 1; diff --git a/docs/yap.tex b/docs/yap.tex index 4439aef26..83cc221d9 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -9017,7 +9017,6 @@ these builtins are rewritten by the system into internal builtins, and that the rewriting process @emph{depends} on the module on which the builtins have been invoked. -@table @code @item @var{Module}:get_atts(@var{-Var},@var{?ListOfAttributes}) @findex get_atts/2 @syindex get_atts/2 @@ -9080,8 +9079,16 @@ unification will fail. Notice that the @t{verify_attributes/3} may be called even if @var{Var} has no attributes in module @t{Module}. In this case the routine should simply succeed with @var{Goals} unified with the empty list. +@table @code +@item attvar(@var{-Var}) +@findex attvar/1 +@snindex attvar/1 +@cnindex attvar/1 +Succeed if @var{Var} is an attributed variable. @end table + + @node Displaying Attributes, Projecting Attributes,Attributed Unification, Attributed Variables @section Displaying Attributes diff --git a/pl/corout.yap b/pl/corout.yap index a66c45bff..04d6d7ed7 100644 --- a/pl/corout.yap +++ b/pl/corout.yap @@ -214,7 +214,7 @@ dif(_, _). % % We still have some more conditions: continue the analysis. % -'$redo_freeze'(Done, V, '$when'(C, G, Done)) :- !, +'$redo_freeze'(Done, _, '$when'(C, G, Done)) :- !, '$when'(C, G, Done). % @@ -503,13 +503,13 @@ frozen(V, LG) :- '$simplify_list_of_frozen_goals'(Gs,NGs). '$find_att_vars'([], []). -'$find_att_vars'([V|LGs], [V|AttVars]) :- '$is_att_variable'(V), !, +'$find_att_vars'([V|LGs], [V|AttVars]) :- attvar(V), !, '$find_att_vars'(LGs, AttVars). '$find_att_vars'([_|LGs], AttVars) :- '$find_att_vars'(LGs, AttVars). '$purge_done_goals'([], []). -'$purge_done_goals'([V|G0], GF) :- '$is_att_variable'(V), !, +'$purge_done_goals'([V|G0], GF) :- attvar(V), !, '$purge_done_goals'(G0, GF). '$purge_done_goals'(['$redo_dif'(Done, _ , _)|G0], GF) :- nonvar(Done), !, '$purge_done_goals'(G0, GF). @@ -523,14 +523,14 @@ frozen(V, LG) :- '$purge_done_goals'(G0, GF). -'$convert_frozen_goal'(V, _, _, V, _) :- '$is_att_variable'(V), !. +'$convert_frozen_goal'(V, _, _, V, _) :- attvar(V), !. '$convert_frozen_goal'('$redo_dif'(Done, X, Y), LV, Done, [X,Y|LV], dif(X,Y)). '$convert_frozen_goal'('$redo_freeze'(Done, FV, G), LV, Done, [FV|LV], G). '$convert_frozen_goal'('$redo_eq'(Done, X, Y, G), LV, Done, [X,Y|LV], G). '$convert_frozen_goal'('$redo_ground'(Done, V, G), LV, Done, [V|LV], G). '$fetch_same_done_goals'([], _, [], []). -'$fetch_same_done_goals'([V|G0], Done, NL, GF) :- '$is_att_variable'(V), !, +'$fetch_same_done_goals'([V|G0], Done, NL, GF) :- attvar(V), !, '$fetch_same_done_goals'(G0, Done, NL, GF). '$fetch_same_done_goals'(['$redo_dif'(Done, X , Y)|G0], D0, [X,Y|LV], GF) :- Done == D0, !, @@ -573,7 +573,7 @@ call_residue(Goal,Residue) :- '$purge_and_set_done_goals'([], L, L). '$purge_and_set_done_goals'([AttV|G0], [_-GS|GF], Atts) :- - '$is_att_variable'(AttV), !, + attvar(AttV), !, attributes:convert_att_var(AttV, GS), '$purge_and_set_done_goals'(G0, GF, Atts). '$purge_and_set_done_goals'(['$redo_dif'(Done, X , Y)|G0], [LVars-dif(X,Y)|GF], Atts) :- @@ -632,7 +632,7 @@ call_residue(Goal,Residue) :- '$undefined'(convert_att_var(Vs,LIV),attributes), !. '$convert_att_vars'(Vs0, LIV, LGs) :- '$sort'(Vs0, Vs), - '$do_convert_att_vars'(Vs0, LIV, LGs). + '$do_convert_att_vars'(Vs, LIV, LGs). '$do_convert_att_vars'([], _, []). '$do_convert_att_vars'([V|LAV], LIV, NGs) :- diff --git a/pl/ground.yap b/pl/ground.yap index 0e3dbeb05..56194dfba 100644 --- a/pl/ground.yap +++ b/pl/ground.yap @@ -55,6 +55,11 @@ numbervars(Term, M, N) :- '$numbermarked_vars'(L, M, N). '$numbermarked_vars'([], M, M). +/* + '$numbermarked_vars'([V|L], M, N) :- + attvar(V), !, + '$numbermarked_vars'(L, M, N). +*/ '$numbermarked_vars'(['$VAR'(M)|L], M, N) :- M1 is M+1, '$numbermarked_vars'(L, M1, N).