fix module stuff.

This commit is contained in:
Vítor Santos Costa 2012-03-28 14:35:09 +01:00
parent d3fd980474
commit 7d3d9bcf41
3 changed files with 32 additions and 18 deletions

View File

@ -422,11 +422,17 @@ true :- true.
'$compile'(G, L, G0, Mod) '$compile'(G, L, G0, Mod)
). ).
%
% check if current module redefines an imported predicate.
% and remove import.
%
'$not_imported'(H, Mod) :- '$not_imported'(H, Mod) :-
recorded('$import','$import'(NM,Mod,NH,H,_,_),_), recorded('$import','$import'(NM,Mod,NH,H,_,_),R),
NM \= Mod, !, NM \= Mod,
functor(NH,N,Ar), functor(NH,N,Ar),
'$do_error'(permission_error(modify, static_procedure, NM:N/Ar), consult). print_message(warning,redefine_imported(Mod,NM,N/Ar)),
erase(R),
fail.
'$not_imported'(_, _). '$not_imported'(_, _).

View File

@ -126,6 +126,8 @@ system_message(functionality(Library)) -->
[ '~q not available' - [Library] ]. [ '~q not available' - [Library] ].
system_message(import(Pred,To,From,private)) --> system_message(import(Pred,To,From,private)) -->
[ 'Importing private predicate ~w:~w to ~w.' - [From,Pred,To] ]. [ 'Importing private predicate ~w:~w to ~w.' - [From,Pred,To] ].
system_message(redefine_imported(M,M0,PI)) -->
[ 'Module ~w redefines imported predicate ~w:~w.' - [M,M0,PI] ].
system_message(leash([])) --> system_message(leash([])) -->
[ 'No leashing.' ]. [ 'No leashing.' ].
system_message(leash([A|B])) --> system_message(leash([A|B])) -->

View File

@ -154,6 +154,12 @@ module(N) :-
'$do_import'(N, K, M, Mod). '$do_import'(N, K, M, Mod).
%
% ignore imports that we do export
%
'$do_import'(N, K, M, T) :-
recorded('$module','$module'(_F,T,MyExports),_),
lists:member(N/K,MyExports), !.
'$do_import'(N, K, M, T) :- '$do_import'(N, K, M, T) :-
functor(G,N,K), functor(G,N,K),
'$follow_import_chain'(M,G,M0,G0), '$follow_import_chain'(M,G,M0,G0),
@ -169,7 +175,7 @@ module(N) :-
). ).
'$follow_import_chain'(M,G,M0,G0) :- '$follow_import_chain'(M,G,M0,G0) :-
recorded('$import','$import'(M1,M,G1,G,_,_),_), !, recorded('$import','$import'(M1,M,G1,G,_,_),_), M \= M1, !,
'$follow_import_chain'(M1,G1,M0,G0). '$follow_import_chain'(M1,G1,M0,G0).
'$follow_import_chain'(M,G,M,G). '$follow_import_chain'(M,G,M,G).