current_predicate and imports

This commit is contained in:
Vítor Santos Costa 2013-11-25 23:57:05 +01:00
parent 67b23a2ae4
commit ea99d42897
2 changed files with 43 additions and 29 deletions

View File

@ -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

View File

@ -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) :-