module_property
This commit is contained in:
parent
def97602e2
commit
b3ee389d5e
@ -310,7 +310,7 @@ use_module(M,F,Is) :-
|
|||||||
'$use_module'(M,F,Is).
|
'$use_module'(M,F,Is).
|
||||||
|
|
||||||
'$use_module'(M,F,Is) :- nonvar(M), !,
|
'$use_module'(M,F,Is) :- nonvar(M), !,
|
||||||
recorded('$module','$module'(F1,M,_),_),
|
recorded('$module','$module'(F1,M,_,_),_),
|
||||||
'$load_files'(F1, [if(not_loaded),must_be_module(true),imports(Is)], use_module(M,F,Is)),
|
'$load_files'(F1, [if(not_loaded),must_be_module(true),imports(Is)], use_module(M,F,Is)),
|
||||||
( F1 = F -> true ; true ).
|
( F1 = F -> true ; true ).
|
||||||
'$use_module'(M,F,Is) :-
|
'$use_module'(M,F,Is) :-
|
||||||
@ -443,7 +443,7 @@ use_module(M,F,Is) :-
|
|||||||
'$bind_module'(Mod, use_module(Mod)).
|
'$bind_module'(Mod, use_module(Mod)).
|
||||||
|
|
||||||
'$import_to_current_module'(File, ContextModule, Imports, RemainingImports, TOpts) :-
|
'$import_to_current_module'(File, ContextModule, Imports, RemainingImports, TOpts) :-
|
||||||
recorded('$module','$module'(File, Module, ModExports),_),
|
recorded('$module','$module'(File, Module, ModExports, _),_),
|
||||||
Module \= ContextModule, !,
|
Module \= ContextModule, !,
|
||||||
'$lf_opt'('$call', TOpts, Call),
|
'$lf_opt'('$call', TOpts, Call),
|
||||||
'$convert_for_export'(Imports, ModExports, Module, ContextModule, TranslationTab, RemainingImports, Goal),
|
'$convert_for_export'(Imports, ModExports, Module, ContextModule, TranslationTab, RemainingImports, Goal),
|
||||||
@ -657,7 +657,7 @@ prolog_load_context(term_position, '$stream_position'(0,Line,0,0,0)) :-
|
|||||||
'$import_to_current_module'(F1, M, Imports, _, TOpts).
|
'$import_to_current_module'(F1, M, Imports, _, TOpts).
|
||||||
|
|
||||||
'$ensure_file_loaded'(F, M, F1) :-
|
'$ensure_file_loaded'(F, M, F1) :-
|
||||||
recorded('$module','$module'(F1,_NM,_P),_),
|
recorded('$module','$module'(F1,_NM,_P,_),_),
|
||||||
recorded('$lf_loaded','$lf_loaded'(F1,_),_),
|
recorded('$lf_loaded','$lf_loaded'(F1,_),_),
|
||||||
same_file(F1,F), !.
|
same_file(F1,F), !.
|
||||||
'$ensure_file_loaded'(F, _M, F1) :-
|
'$ensure_file_loaded'(F, _M, F1) :-
|
||||||
@ -674,7 +674,7 @@ prolog_load_context(term_position, '$stream_position'(0,Line,0,0,0)) :-
|
|||||||
'$import_to_current_module'(F1, M, Imports, _, TOpts).
|
'$import_to_current_module'(F1, M, Imports, _, TOpts).
|
||||||
|
|
||||||
'$ensure_file_unchanged'(F, M, F1) :-
|
'$ensure_file_unchanged'(F, M, F1) :-
|
||||||
recorded('$module','$module'(F1,_NM,_P),_),
|
recorded('$module','$module'(F1,_NM,_P,_),_),
|
||||||
recorded('$lf_loaded','$lf_loaded'(F1,Age),R),
|
recorded('$lf_loaded','$lf_loaded'(F1,Age),R),
|
||||||
same_file(F1,F), !,
|
same_file(F1,F), !,
|
||||||
'$file_is_unchanged'(F, R, Age).
|
'$file_is_unchanged'(F, R, Age).
|
||||||
@ -964,5 +964,5 @@ source_file_property( File0, Prop) :-
|
|||||||
'$source_file_property'( F, modified(Age)) :-
|
'$source_file_property'( F, modified(Age)) :-
|
||||||
recorded('$lf_loaded','$lf_loaded'( F, Age), _).
|
recorded('$lf_loaded','$lf_loaded'( F, Age), _).
|
||||||
'$source_file_property'( F, module(M)) :-
|
'$source_file_property'( F, module(M)) :-
|
||||||
recorded('$module','$module'(F,M,_),_).
|
recorded('$module','$module'(F,M,_,_),_).
|
||||||
|
|
||||||
|
@ -77,21 +77,22 @@ module(N) :-
|
|||||||
'$add_module_on_file'(N, F, Ps).
|
'$add_module_on_file'(N, F, Ps).
|
||||||
|
|
||||||
'$add_module_on_file'(Mod, F, Exports) :-
|
'$add_module_on_file'(Mod, F, Exports) :-
|
||||||
recorded('$module','$module'(F0,Mod,_),R), !,
|
recorded('$module','$module'(F0,Mod,_,_),R), !,
|
||||||
'$add_preexisting_module_on_file'(F, F0, Mod, Exports, R).
|
'$add_preexisting_module_on_file'(F, F0, Mod, Exports, R).
|
||||||
'$add_module_on_file'(Module, F, Exports) :-
|
'$add_module_on_file'(Module, F, Exports) :-
|
||||||
'$convert_for_export'(all, Exports, Module, Module, TranslationTab, AllExports0, load_files),
|
'$convert_for_export'(all, Exports, Module, Module, TranslationTab, AllExports0, load_files),
|
||||||
'$add_to_imports'(TranslationTab, Module, Module), % insert ops, at least for now
|
'$add_to_imports'(TranslationTab, Module, Module), % insert ops, at least for now
|
||||||
sort( AllExports0, AllExports ),
|
sort( AllExports0, AllExports ),
|
||||||
recorda('$module','$module'(F,Module,AllExports),_).
|
( source_location(_, Line) -> true ; Line = 0 ),
|
||||||
|
recorda('$module','$module'(F,Module,AllExports, Line),_).
|
||||||
|
|
||||||
'$extend_exports'(Module, NewExports) :-
|
'$extend_exports'(Module, NewExports) :-
|
||||||
'$convert_for_export'(all, NewExports, Module, Module, _TranslationTab, NewExports1, load_files),
|
'$convert_for_export'(all, NewExports, Module, Module, _TranslationTab, NewExports1, load_files),
|
||||||
recorded('$module','$module'(F,Module,OriginalExports),R),
|
recorded('$module','$module'(F,Module,OriginalExports,Line),R),
|
||||||
'$add_exports'( NewExports1, OriginalExports, Exports ),
|
'$add_exports'( NewExports1, OriginalExports, Exports ),
|
||||||
erase(R),
|
erase(R),
|
||||||
sort( Exports, AllExports ),
|
sort( Exports, AllExports ),
|
||||||
recorda('$module','$module'(F,Module,AllExports),_),
|
recorda('$module','$module'(F,Module,AllExports,Line),_),
|
||||||
fail.
|
fail.
|
||||||
'$extend_exports'(_F, _Module, _NewExports).
|
'$extend_exports'(_F, _Module, _NewExports).
|
||||||
|
|
||||||
@ -105,7 +106,8 @@ module(N) :-
|
|||||||
'$add_preexisting_module_on_file'(F, F, Mod, Exports, R) :- !,
|
'$add_preexisting_module_on_file'(F, F, Mod, Exports, R) :- !,
|
||||||
erase(R),
|
erase(R),
|
||||||
( recorded('$import','$import'(Mod,_,_,_,_,_),R), erase(R), fail; true),
|
( recorded('$import','$import'(Mod,_,_,_,_,_),R), erase(R), fail; true),
|
||||||
recorda('$module','$module'(F,Mod,Exports),_).
|
( source_location(_, Line) -> true ; Line = 0 ),
|
||||||
|
recorda('$module','$module'(F,Mod,Exports, Line),_).
|
||||||
'$add_preexisting_module_on_file'(F,F0,Mod,Exports,R) :-
|
'$add_preexisting_module_on_file'(F,F0,Mod,Exports,R) :-
|
||||||
repeat,
|
repeat,
|
||||||
format(user_error, "The module ~a is being redefined.~n Old file: ~a~n New file: ~a~nDo you really want to redefine it? (y or n)",[Mod,F0,F]),
|
format(user_error, "The module ~a is being redefined.~n Old file: ~a~n New file: ~a~nDo you really want to redefine it? (y or n)",[Mod,F0,F]),
|
||||||
@ -505,7 +507,7 @@ current_module(Mod) :-
|
|||||||
|
|
||||||
current_module(Mod,TFN) :-
|
current_module(Mod,TFN) :-
|
||||||
'$all_current_modules'(Mod),
|
'$all_current_modules'(Mod),
|
||||||
( recorded('$module','$module'(TFN,Mod,_Publics),_) -> true ; TFN = user ).
|
( recorded('$module','$module'(TFN,Mod,_Publics, _),_) -> true ; TFN = user ).
|
||||||
|
|
||||||
source_module(Mod) :-
|
source_module(Mod) :-
|
||||||
'$current_module'(Mod).
|
'$current_module'(Mod).
|
||||||
@ -617,7 +619,7 @@ source_module(Mod) :-
|
|||||||
% get rid of a module and of all predicates included in the module.
|
% get rid of a module and of all predicates included in the module.
|
||||||
%
|
%
|
||||||
abolish_module(Mod) :-
|
abolish_module(Mod) :-
|
||||||
recorded('$module','$module'(_,Mod,_),R), erase(R),
|
recorded('$module','$module'(_,Mod,_,_),R), erase(R),
|
||||||
fail.
|
fail.
|
||||||
abolish_module(Mod) :-
|
abolish_module(Mod) :-
|
||||||
recorded('$import','$import'(Mod,_,_,_,_,_),R), erase(R),
|
recorded('$import','$import'(Mod,_,_,_,_,_),R), erase(R),
|
||||||
@ -644,23 +646,23 @@ export_resource(Resource) :-
|
|||||||
export_resource(P) :-
|
export_resource(P) :-
|
||||||
P = F/N, atom(F), number(N), N >= 0, !,
|
P = F/N, atom(F), number(N), N >= 0, !,
|
||||||
'$current_module'(Mod),
|
'$current_module'(Mod),
|
||||||
( recorded('$module','$module'(File,Mod,ExportedPreds),R) ->
|
( recorded('$module','$module'(File,Mod,ExportedPreds,Line),R) ->
|
||||||
erase(R),
|
erase(R),
|
||||||
recorda('$module','$module'(File,Mod,[P|ExportedPreds]),_)
|
recorda('$module','$module'(File,Mod,[P|ExportedPreds],Line),_)
|
||||||
; prolog_load_context(file, File) ->
|
; prolog_load_context(file, File) ->
|
||||||
recorda('$module','$module'(File,Mod,[P]),_)
|
recorda('$module','$module'(File,Mod,[P],Line),_)
|
||||||
; recorda('$module','$module'(user_input,Mod,[P]),_)
|
; recorda('$module','$module'(user_input,Mod,[P],1),_)
|
||||||
).
|
).
|
||||||
export_resource(P0) :-
|
export_resource(P0) :-
|
||||||
P0 = F//N, atom(F), number(N), N >= 0, !,
|
P0 = F//N, atom(F), number(N), N >= 0, !,
|
||||||
N1 is N+2, P = F/N1,
|
N1 is N+2, P = F/N1,
|
||||||
'$current_module'(Mod),
|
'$current_module'(Mod),
|
||||||
( recorded('$module','$module'(File,Mod,ExportedPreds),R) ->
|
( recorded('$module','$module'(File,Mod,ExportedPreds,Line),R) ->
|
||||||
erase(R),
|
erase(R),
|
||||||
recorda('$module','$module'(File,Mod,[P|ExportedPreds]),_)
|
recorda('$module','$module'(File,Mod,[P|ExportedPreds],Line ),_)
|
||||||
; prolog_load_context(file, File) ->
|
; prolog_load_context(file, File) ->
|
||||||
recorda('$module','$module'(File,Mod,[P]),_)
|
recorda('$module','$module'(File,Mod,[P],Line),_)
|
||||||
; recorda('$module','$module'(user_input,Mod,[P]),_)
|
; recorda('$module','$module'(user_input,Mod,[P],1),_)
|
||||||
).
|
).
|
||||||
export_resource(op(Prio,Assoc,Name)) :- !,
|
export_resource(op(Prio,Assoc,Name)) :- !,
|
||||||
op(Prio,Assoc,prolog:Name).
|
op(Prio,Assoc,prolog:Name).
|
||||||
@ -668,7 +670,7 @@ export_resource(Resource) :-
|
|||||||
'$do_error'(type_error(predicate_indicator,Resource),export(Resource)).
|
'$do_error'(type_error(predicate_indicator,Resource),export(Resource)).
|
||||||
|
|
||||||
export_list(Module, List) :-
|
export_list(Module, List) :-
|
||||||
recorded('$module','$module'(_,Module,List),_).
|
recorded('$module','$module'(_,Module,List,_),_).
|
||||||
|
|
||||||
'$convert_for_export'(all, Exports, _Module, _ContextModule, Tab, MyExports, _) :-
|
'$convert_for_export'(all, Exports, _Module, _ContextModule, Tab, MyExports, _) :-
|
||||||
'$simple_conversion'(Exports, Tab, MyExports).
|
'$simple_conversion'(Exports, Tab, MyExports).
|
||||||
@ -792,7 +794,7 @@ export_list(Module, List) :-
|
|||||||
op(Prio,Assoc,ContextMod:Name).
|
op(Prio,Assoc,ContextMod:Name).
|
||||||
'$do_import'(N0/K0-N0/K0, Mod, Mod) :- !.
|
'$do_import'(N0/K0-N0/K0, Mod, Mod) :- !.
|
||||||
'$do_import'(_N/K-N1/K, _Mod, ContextMod) :-
|
'$do_import'(_N/K-N1/K, _Mod, ContextMod) :-
|
||||||
recorded('$module','$module'(_F, ContextMod, MyExports),_),
|
recorded('$module','$module'(_F, ContextMod, MyExports,_),_),
|
||||||
once(lists:member(N1/K, MyExports)),
|
once(lists:member(N1/K, MyExports)),
|
||||||
functor(S, N1, K),
|
functor(S, N1, K),
|
||||||
% reexport predicates if they are undefined in the current module.
|
% reexport predicates if they are undefined in the current module.
|
||||||
@ -838,7 +840,7 @@ export_list(Module, List) :-
|
|||||||
( C =:= 0'e -> halt(1) ;
|
( C =:= 0'e -> halt(1) ;
|
||||||
C =:= 0'y ).
|
C =:= 0'y ).
|
||||||
'$redefine_action'(true, M1, _, _, _) :- !,
|
'$redefine_action'(true, M1, _, _, _) :- !,
|
||||||
recorded('$module','$module'(F, M1, _MyExports),_),
|
recorded('$module','$module'(F, M1, _MyExports,_Line),_),
|
||||||
unload_file(F).
|
unload_file(F).
|
||||||
'$redefine_action'(false, M1,M2, M, N/K) :-
|
'$redefine_action'(false, M1,M2, M, N/K) :-
|
||||||
'$do_error'(permission_error(import,M1:N/K,redefined,M2),module(M)).
|
'$do_error'(permission_error(import,M1:N/K,redefined,M2),module(M)).
|
||||||
@ -944,10 +946,12 @@ Start a new (source-)module
|
|||||||
'$declare_module'(Name, _Test, Context, _File, _Line) :-
|
'$declare_module'(Name, _Test, Context, _File, _Line) :-
|
||||||
add_import_module(Name, Context, start).
|
add_import_module(Name, Context, start).
|
||||||
|
|
||||||
|
module_property(Mod, line_count(L)) :-
|
||||||
|
recorded('$module','$module'(_F,Mod,_,L),_).
|
||||||
module_property(Mod, file(F)) :-
|
module_property(Mod, file(F)) :-
|
||||||
recorded('$module','$module'(F,Mod,_),_).
|
recorded('$module','$module'(F,Mod,_,_),_).
|
||||||
module_property(Mod, exports(Es)) :-
|
module_property(Mod, exports(Es)) :-
|
||||||
recorded('$module','$module'(_,Mod,Es),_).
|
recorded('$module','$module'(_,Mod,Es,_),_).
|
||||||
|
|
||||||
ls_imports :-
|
ls_imports :-
|
||||||
recorded('$import','$import'(M0,M,G0,G,_N,_K),_R),
|
recorded('$import','$import'(M0,M,G0,G,_N,_K),_R),
|
||||||
|
@ -897,7 +897,7 @@ predicate_property(Pred,Prop) :-
|
|||||||
'$is_public'(P,M).
|
'$is_public'(P,M).
|
||||||
'$predicate_property'(P,M,M,exported) :-
|
'$predicate_property'(P,M,M,exported) :-
|
||||||
functor(P,N,A),
|
functor(P,N,A),
|
||||||
once(recorded('$module','$module'(_TFN,M,Publics),_)),
|
once(recorded('$module','$module'(_TFN,M,Publics,_L),_)),
|
||||||
lists:memberchk(N/A,Publics).
|
lists:memberchk(N/A,Publics).
|
||||||
'$predicate_property'(P,Mod,_,number_of_clauses(NCl)) :-
|
'$predicate_property'(P,Mod,_,number_of_clauses(NCl)) :-
|
||||||
'$number_of_clauses'(P,Mod,NCl).
|
'$number_of_clauses'(P,Mod,NCl).
|
||||||
|
18
pl/qly.yap
18
pl/qly.yap
@ -299,34 +299,34 @@ writeln(M:B),
|
|||||||
|
|
||||||
|
|
||||||
qsave_file(File) :-
|
qsave_file(File) :-
|
||||||
recorded('$module', '$module'(F,Mod,Exps), _),
|
recorded('$module', '$module'(F,Mod,Exps,Line), _),
|
||||||
'$fetch_parents_module'(Mod, Parents),
|
'$fetch_parents_module'(Mod, Parents),
|
||||||
'$fetch_imports_module'(Mod, Imps),
|
'$fetch_imports_module'(Mod, Imps),
|
||||||
'$fetch_multi_files_module'(Mod, MFs),
|
'$fetch_multi_files_module'(Mod, MFs),
|
||||||
'$fetch_meta_predicates_module'(Mod, Metas),
|
'$fetch_meta_predicates_module'(Mod, Metas),
|
||||||
'$fetch_module_transparents_module'(Mod, ModTransps),
|
'$fetch_module_transparents_module'(Mod, ModTransps),
|
||||||
asserta(Mod:'@mod_info'(F, Exps, Parents, Imps, Metas, ModTransps)),
|
asserta(Mod:'@mod_info'(F, Exps, Line, Parents, Imps, Metas, ModTransps)),
|
||||||
atom_concat(Mod,'.qly',OF),
|
atom_concat(Mod,'.qly',OF),
|
||||||
open(OF, write, S, [type(binary)]),
|
open(OF, write, S, [type(binary)]),
|
||||||
'$qsave_module_preds'(S, Mod),
|
'$qsave_module_preds'(S, Mod),
|
||||||
close(S),
|
close(S),
|
||||||
abolish(Mod:'@mod_info'/6),
|
abolish(Mod:'@mod_info'/7),
|
||||||
fail.
|
fail.
|
||||||
qsave_file(_).
|
qsave_file(_).
|
||||||
|
|
||||||
qsave_module(Mod) :-
|
qsave_module(Mod) :-
|
||||||
recorded('$module', '$module'(F,Mod,Exps), _),
|
recorded('$module', '$module'(F,Mod,Exps,L), _),
|
||||||
'$fetch_parents_module'(Mod, Parents),
|
'$fetch_parents_module'(Mod, Parents),
|
||||||
'$fetch_imports_module'(Mod, Imps),
|
'$fetch_imports_module'(Mod, Imps),
|
||||||
'$fetch_multi_files_module'(Mod, MFs),
|
'$fetch_multi_files_module'(Mod, MFs),
|
||||||
'$fetch_meta_predicates_module'(Mod, Metas),
|
'$fetch_meta_predicates_module'(Mod, Metas),
|
||||||
'$fetch_module_transparents_module'(Mod, ModTransps),
|
'$fetch_module_transparents_module'(Mod, ModTransps),
|
||||||
asserta(Mod:'@mod_info'(F, Exps, Parents, Imps, Metas, ModTransps)),
|
asserta(Mod:'@mod_info'(F, Exps, L, Parents, Imps, Metas, ModTransps)),
|
||||||
atom_concat(Mod,'.qly',OF),
|
atom_concat(Mod,'.qly',OF),
|
||||||
open(OF, write, S, [type(binary)]),
|
open(OF, write, S, [type(binary)]),
|
||||||
'$qsave_module_preds'(S, Mod),
|
'$qsave_module_preds'(S, Mod),
|
||||||
close(S),
|
close(S),
|
||||||
abolish(Mod:'@mod_info'/6),
|
abolish(Mod:'@mod_info'/7),
|
||||||
fail.
|
fail.
|
||||||
qsave_module(_).
|
qsave_module(_).
|
||||||
|
|
||||||
@ -345,9 +345,9 @@ qload_module(Mod) :-
|
|||||||
'$complete_read'(Mod).
|
'$complete_read'(Mod).
|
||||||
|
|
||||||
'$complete_read'(Mod) :-
|
'$complete_read'(Mod) :-
|
||||||
retract(Mod:'@mod_info'(F, Exps, Parents, Imps, Metas, ModTransps)),
|
retract(Mod:'@mod_info'(F, Exps, Line,Parents, Imps, Metas, ModTransps)),
|
||||||
abolish(Mod:'$mod_info'/6),
|
abolish(Mod:'$mod_info'/7),
|
||||||
recorda('$module', '$module'(F,Mod,Exps), _),
|
recorda('$module', '$module'(F,Mod,Exps,Line), _),
|
||||||
'$install_parents_module'(Mod, Parents),
|
'$install_parents_module'(Mod, Parents),
|
||||||
'$install_imports_module'(Mod, Imps),
|
'$install_imports_module'(Mod, Imps),
|
||||||
'$install_multi_files_module'(Mod, MFs),
|
'$install_multi_files_module'(Mod, MFs),
|
||||||
|
Reference in New Issue
Block a user