this is hard

This commit is contained in:
Vitor Santos Costa 2016-07-31 10:41:54 -05:00
parent 2fef5ffcea
commit bb4820a086

View File

@ -603,7 +603,7 @@ current_predicate(A,T0) :-
( (
'$current_predicate'(A,M, T, user) '$current_predicate'(A,M, T, user)
; ;
'$imported_predicate'(T, M, T1, M1), '$imported_predicate'(A, T, M, T1, M1),
\+ '$is_system_predicate'(T1,M1) \+ '$is_system_predicate'(T1,M1)
). ).
@ -659,7 +659,7 @@ system_predicate(P0) :-
YAP also supports the ISO standard built-in system_predicate/1, that YAP also supports the ISO standard built-in system_predicate/1, that
provides similar functionality and is compatible with most other Prolog provides similar functionality and is compatible with most other Prolog
systems. systems.
*/ */
system_predicate(A, P0) :- system_predicate(A, P0) :-
'$yap_strip_module'(P0, M, P), '$yap_strip_module'(P0, M, P),
@ -683,50 +683,38 @@ system_predicate(A, P0) :-
*/ */
current_predicate(F0) :- current_predicate(F0) :-
'$yap_strip_module'(F0, M, F), '$yap_strip_module'(F0, M, F),
(var(F) -> '$c_i_predicate'( F, M ).
F = A/N,
current_predicate(A, M:S), '$c_i_predicate'( A/N, M ) :-
functor(S, A, N) !,
( nonvar(A), nonvar(N) ->
functor(S, A, N),
current_predicate(A, M:S)
; ;
( current_predicate(A, M:S),
functor(F,AN,2) functor(S, A, N)
-> ).
true '$c_i_predicate'( A//N, M ) :-
; !,
'$do_error'(type_error(predicate_indicator,F0), ( nonvar(A), nonvar(N) ->
current_predicate(F0)) N2 is N+2,
), functor(S, A, N2),
arg(1,F,A), current_predicate(A, M:S)
(atom(A) -> true ; ;
var(A) -> true ; current_predicate(A, M:S),
'$do_error'(type_error(predicate_indicator,F0),current_predicate(F0)) functor(S, A, N2),
), N is N-2
arg(2,F,N), ).
(integer(N) -> true ; '$c_i_predicate'( F, M ) :-
var(N) -> true ; '$do_error'(type_error(predicate_indicator,F),
'$do_error'(type_error(predicate_indicator,F0),current_predicate(F0)) current_predicate(M:F)).
),
( AN == '/'
->
current_predicate(A, M:S),
functor( S, A, N)
;
AN == '//'
->
current_predicate(A, M:S),
Ar2 is N+2,
functor( S, A, Ar2)
;
'$do_error'(type_error(predicate_indicator,F0),current_predicate(F0))
)
).
'$imported_predicate'(A, ImportingMod, A/Arity, G, Flags) :- '$imported_predicate'(A, G, ImportingMod, G, Flags) :-
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod), '$get_undefined_pred'(G, ImportingMod, G0, ExportingMod),
functor(G, A, Arity), '$pred_exists'(G0, ExportingMod),
'$pred_exists'(G, ExportingMod), '$predicate_flags'(G0, ExportingMod, Flags, Flags),
'$predicate_flags'(G0, ExportingMod, Flags, Flags). functor(G, A, _Arity).
/** @pred current_key(? _A_,? _K_) /** @pred current_key(? _A_,? _K_)
@ -816,6 +804,13 @@ clause_property(ClauseRef, predicate(PredicateIndicator)) :-
functor(P, N, Ar), functor(P, N, Ar),
'$set_flag'(P, M, Flag, V). '$set_flag'(P, M, Flag, V).
%% '$set_flag'(P, M, trace, off) :-
% set a predicate flag
%
'$set_flag'(P, M, trace, off) :-
'$predicate_flags'(P,M,F,F),
FN is F \/ 0x400000000,
'$predicate_flags'(P,M,F,FN).
/** /**
@} @}