reexport again

This commit is contained in:
Vitor Santos Costa 2014-02-09 18:06:37 +00:00
parent 93859706e3
commit e0642dbaa3
3 changed files with 36 additions and 11 deletions

View File

@ -245,6 +245,7 @@ load_files(Files,Opts) :-
;
true
), !,
'$lf_opt'(reexport, TOpts, Reexport),
'$lf_opt'(if, TOpts, If),
( var(If) -> If = true ; true ),
'$lf_opt'(imports, TOpts, Imports),
@ -258,13 +259,13 @@ load_files(Files,Opts) :-
'$lf_opt'('$options', TOpts, Opts),
'$lf_opt'('$location', TOpts, ParentF:Line),
'$loaded'(Stream, UserFile, Mod, ParentF, Line, not_loaded, _File, _Dir, Opts),
'$reexport'( TOpts, UserFile, Imports, Mod ).
'$reexport'( TOpts, ParentF, Imports, _File ).
'$start_lf'(changed, Mod, Stream, TOpts, UserFile, Imports) :-
'$file_unchanged'(Stream, Mod, Imports, TOpts), !,
'$lf_opt'('$options', TOpts, Opts),
'$lf_opt'('$location', TOpts, ParentF:Line),
'$loaded'(Stream, UserFile, Mod, ParentF, Line, changed, _File, _Dir, Opts),
'$reexport'( TOpts, UserFile, Imports, Mod ).
'$reexport'( TOpts, ParentF, Imports, _File ).
'$start_lf'(_, Mod, Stream, TOpts, File, _) :-
'$do_lf'(Mod, Stream, File, TOpts).
@ -391,13 +392,12 @@ use_module(M,F,Is) :-
nb_setval('$if_level',OldIfLevel),
'$lf_opt'('$use_module', TOpts, UseModule),
'$bind_module'(Mod, UseModule),
% ( File = '/Users/vsc/Yap/bins/threads/share/Yap/error.pl' -> start_low_level_trace ; stop_low_level_trace ),
'$lf_opt'(imports, TOpts, Imports),
'$import_to_current_module'(File, ContextModule, Imports, _, TOpts),
'$reexport'( TOpts, File, Imports, ContextModule ),
'$reexport'( TOpts, ParentF, Imports, File ),
( LC == 0 -> prompt(_,' |: ') ; true),
'$exec_initialisation_goals',
% format( 'O=~w~n', [Mod=UserFile] ),
% format( 'O=~w~n', [Mod=UserFile] ),
!.
% are we in autoload and autoload_flag is false?
@ -432,6 +432,13 @@ use_module(M,F,Is) :-
'$bind_module'(_, load_files).
'$bind_module'(Mod, use_module(Mod)).
'$import_to_current_module'(File, ContextModule, Imports, RemainingImports, TOpts) :-
\+ recorded('$module','$module'(File, _Module, _ModExports, _),_),
% enable loading C-predicates from a different file
recorded( '$load_foreign_done', [File, M0], _),
'$import_foreign'(File, M0, ContextModule ),
fail.
'$import_to_current_module'(File, ContextModule, Imports, RemainingImports, TOpts) :-
recorded('$module','$module'(File, Module, ModExports, _),_),
Module \= ContextModule, !,
@ -578,13 +585,13 @@ initialization(G,OPT) :-
print_message(Verbosity, loaded(included, Y, Mod, T, H)),
nb_setval('$included_file',OY).
'$reexport'( TOpts, File, Imports, ContextModule ) :-
'$reexport'( TOpts, File, Imports, OldF ) :-
'$lf_opt'(reexport, TOpts, Reexport),
( Reexport == false -> true ;
'$lf_opt'('$parent_topts', TOpts, OldTOpts),
'$lf_opt'('$context_module', OldTOpts, OldContextModule),
'$import_to_current_module'(File, OldContextModule, Imports, _, TOpts),
'$extend_exports'(ContextModule, Imports)
'$extend_exports'(File, Imports, OldF )
).
'$do_startup_reconsult'(X) :-

View File

@ -15,11 +15,19 @@
* *
*************************************************************************/
load_foreign_files(_Objs,_Libs,_Entry) :-
prolog_load_context(file, F),
prolog_load_context(module, M),
recorded( '$load_foreign_done', [F, M0], _), !,
'$import_foreign'(F, M0, M).
load_foreign_files(Objs,Libs,Entry) :-
'$check_objs_for_load_foreign_files'(Objs,NewObjs,load_foreign_files(Objs,Libs,Entry)),
'$check_libs_for_load_foreign_files'(Libs,NewLibs,load_foreign_files(Objs,Libs,Entry)),
'$check_entry_for_load_foreign_files'(Entry,load_foreign_files(Objs,Libs,Entry)),
'$load_foreign_files'(NewObjs,NewLibs,Entry).
'$load_foreign_files'(NewObjs,NewLibs,Entry),
prolog_load_context(file, F),
prolog_load_context(module, M),
ignore( recordzifnot( '$load_foreign_done', [F, M], _) ), !.
'$check_objs_for_load_foreign_files'(V,_,G) :- var(V), !,
'$do_error'(instantiation_error,G).
@ -67,6 +75,14 @@ load_foreign_files(Objs,Libs,Entry) :-
'$checklib_prefix'(F, Lib) :-
atom_concat(lib, F, Lib).
'$import_foreign'(F, M0, M) :-
M \= M0,
predicate_property(M0:P,built_in),
predicate_property(M0:P,file(F)),
functor(P, N, K),
'$do_import'(N/K-N/K, M0, M),
fail.
'$import_foreign'(_F, _M0, _M).
'$check_entry_for_load_foreign_files'(V,G) :- var(V), !,
'$do_error'(instantiation_error,G).

View File

@ -86,9 +86,11 @@ module(N) :-
( source_location(_, Line) -> true ; Line = 0 ),
recorda('$module','$module'(F,Module,AllExports, Line),_).
'$extend_exports'(Module, NewExports) :-
'$convert_for_export'(all, NewExports, Module, Module, _TranslationTab, NewExports1, load_files),
recorded('$module','$module'(F,Module,OriginalExports,Line),R),
'$extend_exports'(F, Exps , NewF) :-
writeln( (Exps, F, NewF ) ),
recorded('$module','$module'(NewF,NMod, NewExports, _),_R),
recorded('$module','$module'(F, Module,OriginalExports,Line),R),
'$convert_for_export'(Exps, NewExports, NMod, NMod, _TranslationTab, NewExports1, load_files),
'$add_exports'( NewExports1, OriginalExports, Exports ),
erase(R),
sort( Exports, AllExports ),