From ea99d42897db987c9054e4e16633c035b7440363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Mon, 25 Nov 2013 23:57:05 +0100 Subject: [PATCH] current_predicate and imports --- pl/modules.yap | 4 +-- pl/preds.yap | 68 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/pl/modules.yap b/pl/modules.yap index 1788bb0dd..060ba2761 100644 --- a/pl/modules.yap +++ b/pl/modules.yap @@ -806,9 +806,9 @@ export_list(Module, List) :- G1=..[N1|Args], ( '$check_import'(M0,ContextMod,N1,K) -> ( ContextMod = user -> - ( recordzifnot('$import','$import'(M0,user,G0,G1,N1,K),_) -> Cl = (G1:- M0:G0), '$compile'(Cl, 0, Cl, user) ; true ) + ( recordzifnot('$import','$import'(M0,user,G0,G1,N1,K),_) -> true ; true ) ; - ( recordaifnot('$import','$import'(M0,ContextMod,G0,G1,N1,K),_) -> Cl = (G1:- M0:G0), '$compile'(Cl, 0, Cl, ContextMod) ; true ) + ( recordaifnot('$import','$import'(M0,ContextMod,G0,G1,N1,K),_) -> true ; true ) ) ; true diff --git a/pl/preds.yap b/pl/preds.yap index c01964be9..c34ac7672 100644 --- a/pl/preds.yap +++ b/pl/preds.yap @@ -964,18 +964,6 @@ current_predicate(A,T) :- % only for the predicate M \= prolog, '$pred_exists'(T,M). -current_predicate(F) :- - strip_module(F, M, F0), - '$$current_predicate'(F0,M). - -'$$current_predicate'(F0,M) :- - ( var(M) -> % only for the predicate - '$current_module'(M), - M \= prolog - ; - true ), - '$current_predicate3'(M, F0). - system_predicate(A,P) :- '$current_predicate_no_modules'(prolog,A,P), \+ '$hidden'(A). @@ -989,22 +977,48 @@ system_predicate(P) :- '$ifunctor'(T,A,Arity), '$pred_exists'(T,M). -'$current_predicate3'(M,A/Arity) :- - nonvar(M), - nonvar(A), - nonvar(Arity), !, - '$ifunctor'(Pred,A,Arity), - '$pred_exists'(Pred,M). -'$current_predicate3'(M,A/Arity) :- +current_predicate(F0) :- + strip_module(F0, M, F), + '$$current_predicate'(F, M). + +'$$current_predicate'(F, M) :- + ( var(M) -> % only for the predicate + '$current_module'(M), + M \= prolog + ; true), + '$current_predicate3'(F,M). + +'$current_predicate3'(A/Arity,M) :- nonvar(A), nonvar(Arity), !, - '$current_predicate'(M,A,Arity), - '$ifunctor'(T,A,Arity), - '$pred_exists'(T,M). -'$current_predicate3'(M,A/Arity) :- !, - '$current_predicate'(M,A,Arity), - '$ifunctor'(T,A,Arity), - '$pred_exists'(T,M). -'$current_predicate3'(M,BadSpec) :- % only for the predicate + ( '$ifunctor'(T,A,Arity), + '$pred_exists'(T,M) + -> + true + ; +% '$current_predicate'(prolog,A,Arity) +% -> +% functor(T,A,Arity), +% '$pred_exists'(T,M) +% ; + recorded('$import','$import'(NM,M,G,T,A,Arity),_) + -> + '$pred_exists'(G,NM) + ). +'$current_predicate3'(A/Arity,M) :- !, + ( + '$current_predicate'(M,A,Arity), + '$ifunctor'(T,A,Arity), + '$pred_exists'(T,M) + ; +% '$current_predicate'(prolog,A,Arity), +% functor(T,A,Arity), +% '$pred_exists'(T,M) +% ; + recorded('$import','$import'(NM,M,G,T,A,Arity),_), + functor(T,A,Arity), + '$pred_exists'(G,NM) + ). +'$current_predicate3'(BadSpec,M) :- % only for the predicate '$do_error'(type_error(predicate_indicator,BadSpec),current_predicate(M:BadSpec)). current_key(A,K) :-