fix module stuff.
This commit is contained in:
parent
d3fd980474
commit
7d3d9bcf41
12
pl/boot.yap
12
pl/boot.yap
@ -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'(_, _).
|
||||||
|
|
||||||
|
|
||||||
|
@ -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])) -->
|
||||||
|
@ -142,18 +142,24 @@ module(N) :-
|
|||||||
'$use_preds'(P,Publics,Mod,M),
|
'$use_preds'(P,Publics,Mod,M),
|
||||||
'$use_preds'(Ps,Publics,Mod,M).
|
'$use_preds'(Ps,Publics,Mod,M).
|
||||||
'$use_preds'(N/K,Publics,M,Mod) :-
|
'$use_preds'(N/K,Publics,M,Mod) :-
|
||||||
( lists:memberchk(N/K,Publics) -> true ;
|
( lists:memberchk(N/K,Publics) -> true ;
|
||||||
print_message(warning,import(N/K,Mod,M,private))
|
|
||||||
),
|
|
||||||
'$do_import'(N, K, M, Mod).
|
|
||||||
'$use_preds'(N//K0,Publics,M,Mod) :-
|
|
||||||
K is K0+2,
|
|
||||||
( lists:memberchk(N/K,Publics) -> true ;
|
|
||||||
print_message(warning,import(N/K,Mod,M,private))
|
print_message(warning,import(N/K,Mod,M,private))
|
||||||
),
|
),
|
||||||
'$do_import'(N, K, M, Mod).
|
'$do_import'(N, K, M, Mod).
|
||||||
|
'$use_preds'(N//K0,Publics,M,Mod) :-
|
||||||
|
K is K0+2,
|
||||||
|
( lists:memberchk(N/K,Publics) -> true ;
|
||||||
|
print_message(warning,import(N/K,Mod,M,private))
|
||||||
|
),
|
||||||
|
'$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,16 +175,16 @@ 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).
|
||||||
|
|
||||||
'$check_import'(M,T,N,K) :-
|
'$check_import'(M,T,N,K) :-
|
||||||
recorded('$import','$import'(MI,T,_,_,N,K),R),
|
recorded('$import','$import'(MI,T,_,_,N,K),R),
|
||||||
\+ '$module_produced by'(M,T,N,K), !,
|
\+ '$module_produced by'(M,T,N,K), !,
|
||||||
format(user_error,"NAME CLASH: ~w was already imported to module ~w;~n",[MI:N/K,T]),
|
format(user_error,"NAME CLASH: ~w was already imported to module ~w;~n",[MI:N/K,T]),
|
||||||
format(user_error," Do you want to import it from ~w ? [y or n] ",M),
|
format(user_error," Do you want to import it from ~w ? [y or n] ",M),
|
||||||
repeat,
|
repeat,
|
||||||
get0(C), '$skipeol'(C),
|
get0(C), '$skipeol'(C),
|
||||||
( C is "y" -> erase(R), !;
|
( C is "y" -> erase(R), !;
|
||||||
C is "n" -> !, fail;
|
C is "n" -> !, fail;
|
||||||
|
Reference in New Issue
Block a user