current_predicate
This commit is contained in:
parent
58357b1af4
commit
7a8f57eb63
33
pl/preds.yap
33
pl/preds.yap
@ -1164,11 +1164,17 @@ predicate_erased_statistics(P,NCls,Sz,ISz) :-
|
|||||||
|
|
||||||
/** @pred current_predicate( _A_, _P_)
|
/** @pred current_predicate( _A_, _P_)
|
||||||
|
|
||||||
Defines the relation: _P_ is a currently defined predicate whose name is the atom _A_.
|
Defines the relation: _P_ is a currently defined predicate whose name
|
||||||
|
is the atom _A_. This includes all predicates defined
|
||||||
|
within the module and all predicates explicitely imported by the
|
||||||
|
module, but not that system predicates that are visible by default.
|
||||||
|
|
||||||
|
YAP does not use autoloader by default, so autoloaded predicates are not
|
||||||
|
included.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
current_predicate(A,T) :-
|
current_predicate(A,T) :-
|
||||||
'$system_module'(M),
|
strip_module(T, M, T0),
|
||||||
'$ground_module'(T, M, T0),
|
|
||||||
(
|
(
|
||||||
'$current_predicate'(A, M, T0, _)
|
'$current_predicate'(A, M, T0, _)
|
||||||
;
|
;
|
||||||
@ -1205,17 +1211,28 @@ system_predicate(P) :-
|
|||||||
library predicate. The indicator _F_ is of the form _Mod_:_Na_/_Ar_ or _Na/Ar_,
|
library predicate. The indicator _F_ is of the form _Mod_:_Na_/_Ar_ or _Na/Ar_,
|
||||||
where the atom _Mod_ is the module of the predicate,
|
where the atom _Mod_ is the module of the predicate,
|
||||||
_Na_ is the name of the predicate, and _Ar_ its arity.
|
_Na_ is the name of the predicate, and _Ar_ its arity.
|
||||||
|
|
||||||
|
Notice that this built-in differs from current_predicate/2 in that it also returns all system predicates, as they are available to every module.
|
||||||
*/
|
*/
|
||||||
current_predicate(F0) :-
|
current_predicate(F0) :-
|
||||||
'$ground_module'(F0, M, F),
|
strip_module(F0, M, F),
|
||||||
|
F = A/Arity,
|
||||||
(
|
(
|
||||||
'$current_predicate'(N, M, S, _),
|
'$current_predicate'(A, M, T, _),
|
||||||
functor( S, N, Ar),
|
functor( T, A, Arity )
|
||||||
F = N/Ar
|
|
||||||
;
|
;
|
||||||
'$imported_predicate'(_Name, M, F, _S, _)
|
'$imported_predicate'(A, M, A/Arity, _T0, _)
|
||||||
|
;
|
||||||
|
M \= prolog,
|
||||||
|
'$current_predicate'(A, prolog, T, _),
|
||||||
|
functor( T, A, Arity )
|
||||||
|
;
|
||||||
|
M \= system,
|
||||||
|
'$current_predicate'(A, system, T, _),
|
||||||
|
functor( T, A, Arity )
|
||||||
).
|
).
|
||||||
|
|
||||||
|
|
||||||
'$imported_predicate'(A, ImportingMod, A/Arity, G, Flags) :-
|
'$imported_predicate'(A, ImportingMod, A/Arity, G, Flags) :-
|
||||||
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod),
|
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod),
|
||||||
functor(G, A, Arity),
|
functor(G, A, Arity),
|
||||||
|
Reference in New Issue
Block a user