From f9e687a971496b053f99df2c37440dfdc6eb4fde Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Fri, 24 Sep 2010 00:36:10 +0100 Subject: [PATCH] Fix block/1 declarations and remove uses of $recorded (patch from David Powers). --- pl/corout.yap | 17 +++++++++++------ pl/preds.yap | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/pl/corout.yap b/pl/corout.yap index 3184b324d..64ba88575 100644 --- a/pl/corout.yap +++ b/pl/corout.yap @@ -60,15 +60,20 @@ attgoal_for_delay(redo_dif(Done, X, Y), V) --> [prolog:dif(X,Y)]. attgoal_for_delay(redo_freeze(Done, V, Goal), V) --> { var(Done) }, !, - [prolog:freeze(V,Goal)]. + { remove_when_declarations(Goal, NoWGoal) }, + [ prolog:freeze(V,NoWGoal) ]. attgoal_for_delay(redo_eq(Done, X, Y, Goal), V) --> { var(Done), first_att(Goal, V) }, !, - [prolog:when(X=Y,Goal)]. + [ prolog:when(X=Y,Goal) ]. attgoal_for_delay(redo_ground(Done, X, Goal), V) --> { var(Done) }, !, - [prolog:when(ground(X),Goal)]. + [ prolog:when(ground(X),Goal) ]. attgoal_for_delay(_, V) --> []. +remove_when_declarations(when(Cond,Goal,_), when(Cond,NoWGoal)) :- !, + remove_when_declarations(Goal, NoWGoal). +remove_when_declarations(Goal, Goal). + % % operators defined in this module: % @@ -215,7 +220,7 @@ prolog:when(_,Goal) :- % % support for when/2 like declaration. -% +v% % % when will block on a conjunction or disjunction of nonvar, ground, % ?=, where ?= is both terms being bound together @@ -357,8 +362,8 @@ prolog:'$block'(Conds) :- prolog:'$block'(_). generate_blocking_code(Conds, G, Code) :- - '$extract_head_for_block'(Conds, G), - '$recorded'('$blocking_code','$code'(G,OldConds),R), !, + extract_head_for_block(Conds, G), + recorded('$blocking_code','$code'(G,OldConds),R), !, erase(R), functor(G, Na, Ar), '$current_module'(M), diff --git a/pl/preds.yap b/pl/preds.yap index ae3098ad4..8b8789465 100644 --- a/pl/preds.yap +++ b/pl/preds.yap @@ -234,7 +234,7 @@ assertz_static(C) :- '$erase_all_mf_dynamic'(Na,A,M) :- get_value('$consulting_file',F), - '$recorded'('$multifile_dynamic'(_,_,_), '$mf'(Na,A,M,F,R), R1), + recorded('$multifile_dynamic'(_,_,_), '$mf'(Na,A,M,F,R), R1), erase(R1), erase(R), fail. @@ -649,12 +649,6 @@ abolish(X) :- '$undefined'(G, Module), functor(G,Name,Arity), print_message(warning,no_match(abolish(Module:Name/Arity))). -% I cannot allow modifying static procedures in YAPOR -% this code has to be here because of abolish/2 -% '$abolishs'(G, Module) :- -% '$has_yap_or', !, -% functor(G,A,N), -% '$do_error'(permission_error(modify,static_procedure,A/N),abolish(Module:G)). '$abolishs'(G, M) :- '$is_multifile'(G,M), !, functor(G,Name,Arity), @@ -927,7 +921,8 @@ current_predicate(A,T) :- current_predicate(A) :- '$current_predicate_inside'(A). -'$current_predicate_inside'(F) :- var(F), !, % only for the predicate +'$current_predicate_inside'(F) :- + var(F), !, % only for the predicate '$current_module'(M), '$current_predicate3'(M,F). '$current_predicate_inside'(M:F) :- % module specified @@ -955,7 +950,14 @@ system_predicate(P) :- '$ifunctor'(T,A,Arity), '$pred_exists'(T,M). -'$current_predicate3'(M,A/Arity) :- nonvar(A), nonvar(Arity), !, +'$current_predicate3'(M,A/Arity) :- + nonvar(M), + nonvar(A), + nonvar(Arity), !, + '$ifunctor'(Pred,A,Arity), + '$pred_exists'(Pred,M). +'$current_predicate3'(M,A/Arity) :- + nonvar(A), nonvar(Arity), !, ( '$current_predicate'(M,A,Arity) ->