2011-08-03 16:30:39 +01:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* *
|
|
|
|
* YAP Prolog *
|
|
|
|
* *
|
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2011 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
|
|
|
* File: qly.yap *
|
|
|
|
* Last rev: *
|
|
|
|
* mods: *
|
|
|
|
* comments: fast save/restore *
|
|
|
|
* *
|
|
|
|
*************************************************************************/
|
2014-04-09 12:39:29 +01:00
|
|
|
:- system_module( '$_qly', [qload_module/1,
|
|
|
|
qsave_file/1,
|
|
|
|
qsave_module/1,
|
|
|
|
qsave_program/1,
|
|
|
|
qsave_program/2,
|
|
|
|
restore/1,
|
|
|
|
save_program/1,
|
|
|
|
save_program/2], ['$init_state'/0]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_absf', ['$system_library_directories'/2]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_boot', ['$system_catch'/4]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_consult', ['$do_startup_reconsult'/1]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_control', ['$run_atom_goal'/1]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_errors', ['$do_error'/2]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_preds', ['$init_preds'/0]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_protect', ['$protect'/0]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_threads', ['$reinit_thread0'/0]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_yio', ['$extend_file_search_path'/1]).
|
2011-08-03 16:30:39 +01:00
|
|
|
|
2014-07-27 01:14:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
@defgroup YAPSaving Saving and Loading Prolog States
|
2015-01-04 23:58:23 +00:00
|
|
|
@ingroup consult
|
2014-07-27 01:14:15 +01:00
|
|
|
|
|
|
|
YAP can save and read images of its current state to files, known as
|
|
|
|
saved states. It is possible to save the entire state or just a module
|
|
|
|
or a file. Notice that saved states in YAP depend on the architecture
|
|
|
|
where they were made, and may also depend on the version of YAP being
|
|
|
|
saved.
|
|
|
|
|
|
|
|
YAP always tries to find saved states from the current directory
|
|
|
|
first. If it cannot it will use the environment variable [YAPLIBDIR](@ref YAPLIBDIR), if
|
|
|
|
defined, or search the default library directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @pred save_program(+ _F_)
|
|
|
|
Saves the current state of the data-base in file _F_ .
|
|
|
|
|
|
|
|
The result is a resource archive containing a saved state that
|
|
|
|
expresses all Prolog data from the running program and all
|
|
|
|
user-defined resources. Depending on the stand_alone option, the
|
|
|
|
resource is headed by the emulator, a Unix shell script or nothing.
|
|
|
|
|
|
|
|
**/
|
2012-06-11 09:22:53 +01:00
|
|
|
save_program(File) :-
|
|
|
|
qsave_program(File).
|
|
|
|
|
2014-07-27 01:14:15 +01:00
|
|
|
/** @pred save_program(+ _F_, : _G_)
|
|
|
|
|
|
|
|
Saves an image of the current state of the YAP database in file
|
|
|
|
_F_, and guarantee that execution of the restored code will start by
|
|
|
|
trying goal _G_.
|
|
|
|
**/
|
2011-08-28 01:29:04 +01:00
|
|
|
qsave_program(File) :-
|
2012-06-26 10:09:10 +01:00
|
|
|
'$save_program_status'([], qsave_program(File)),
|
2011-08-28 01:29:04 +01:00
|
|
|
open(File, write, S, [type(binary)]),
|
|
|
|
'$qsave_program'(S),
|
|
|
|
close(S).
|
|
|
|
|
2014-07-27 01:14:15 +01:00
|
|
|
/** @pred qsave_program(+ _F_, Opts)
|
|
|
|
|
|
|
|
Saves an image of the current state of the YAP database in file
|
|
|
|
_F_, currently the options in _Opts_ are ignored:
|
|
|
|
|
|
|
|
+ stack(+ _KBytes_)
|
|
|
|
Limit for the local and global stack.
|
|
|
|
|
|
|
|
+ trail(+ _KBytes_)
|
|
|
|
Limit for the trail stack.
|
|
|
|
|
|
|
|
+ goal(: _Callable_)
|
2014-12-24 15:32:29 +00:00
|
|
|
Initialization goal for the new executable (see `-g`).
|
2014-07-27 01:14:15 +01:00
|
|
|
|
|
|
|
+ init_file(+ _Atom_)
|
2014-12-24 15:32:29 +00:00
|
|
|
Default initialization file for the new executable. See `-f`.
|
2014-07-27 01:14:15 +01:00
|
|
|
|
2014-12-24 15:32:29 +00:00
|
|
|
*/
|
2012-06-26 10:09:10 +01:00
|
|
|
qsave_program(File, Opts) :-
|
|
|
|
'$save_program_status'(Opts, qsave_program(File,Opts)),
|
|
|
|
open(File, write, S, [type(binary)]),
|
|
|
|
'$qsave_program'(S),
|
|
|
|
% make sure we're not going to bootstrap from this file.
|
|
|
|
close(S).
|
|
|
|
|
2014-07-27 01:14:15 +01:00
|
|
|
/** @pred save_program(+ _F_, : _G_)
|
|
|
|
|
|
|
|
Saves an image of the current state of the YAP database in file
|
|
|
|
_F_, and guarantee that execution of the restored code will start by
|
|
|
|
trying goal _G_.
|
|
|
|
**/
|
2014-10-07 01:35:41 +01:00
|
|
|
save_program(_File, Goal) :-
|
2012-06-11 09:22:53 +01:00
|
|
|
recorda('$restore_goal', Goal ,_R),
|
|
|
|
fail.
|
|
|
|
save_program(File, _Goal) :-
|
|
|
|
qsave_program(File).
|
|
|
|
|
2014-12-14 11:45:11 +00:00
|
|
|
/** @pred qsave_program
|
|
|
|
|
|
|
|
Saves an image of the current state of the YAP database in default
|
|
|
|
filee, usually `startup.yss`.
|
|
|
|
**/
|
|
|
|
qend_program :-
|
|
|
|
module(user),
|
|
|
|
qsave_program('startup.yss'),
|
|
|
|
halt(0).
|
|
|
|
|
2012-06-26 10:09:10 +01:00
|
|
|
'$save_program_status'(Flags, G) :-
|
|
|
|
findall(F:V,'$x_yap_flag'(F,V),L),
|
|
|
|
recordz('$program_state',L,_),
|
|
|
|
'$cvt_qsave_flags'(Flags, G),
|
|
|
|
fail.
|
|
|
|
'$save_program_status'(_Flags, _G).
|
|
|
|
|
|
|
|
'$cvt_qsave_flags'(Flags, G) :-
|
|
|
|
nonvar(Flags),
|
|
|
|
strip_module(Flags, M, LFlags),
|
|
|
|
'$skip_list'(_Len, LFlags, []),
|
|
|
|
'$cvt_qsave_lflags'(LFlags, G, M).
|
|
|
|
'$cvt_qsave_flags'(Flags, G,_OFlags) :-
|
|
|
|
var(Flags),
|
|
|
|
'$do_error'(instantiation_error,G).
|
|
|
|
'$cvt_qsave_flags'(Flags, G,_OFlags) :-
|
|
|
|
'$do_error'(type_error(list,Flags),G).
|
|
|
|
|
|
|
|
'$cvt_qsave_lflags'([], _, _).
|
|
|
|
'$cvt_qsave_lflags'([Flag|Flags], G, M) :-
|
|
|
|
'$cvt_qsave_flag'(Flag, G, M),
|
|
|
|
'$cvt_qsave_lflags'(Flags, G, M).
|
|
|
|
|
|
|
|
'$cvt_qsave_flag'(Flag, G, _) :-
|
|
|
|
var(Flag), !,
|
|
|
|
'$do_error'(instantiation_error,G).
|
|
|
|
'$cvt_qsave_flag'(local(B), G, _) :- !,
|
|
|
|
( number(B) ->
|
|
|
|
(
|
|
|
|
B > 0 -> recordz('$restore_flag',local(B),_) ;
|
|
|
|
B =:= 0 -> true ;
|
|
|
|
'$do_error'(domain_error(not_less_than_zero,B),G))
|
|
|
|
;
|
|
|
|
'$do_error'(type_error(integer,B),G)
|
|
|
|
).
|
|
|
|
'$cvt_qsave_flag'(global(B), G, _) :- !,
|
|
|
|
( number(B) ->
|
|
|
|
(
|
|
|
|
B > 0 -> recordz('$restore_flag',global(B),_) ;
|
|
|
|
B =:= 0 -> true ;
|
|
|
|
'$do_error'(domain_error(not_less_than_zero,B),G))
|
|
|
|
;
|
|
|
|
'$do_error'(type_error(integer,B),G)
|
|
|
|
).
|
|
|
|
'$cvt_qsave_flag'(stack(B), G, _) :- !,
|
|
|
|
( number(B) ->
|
|
|
|
(
|
|
|
|
B > 0 -> recordz('$restore_flag',stack(B),_) ;
|
|
|
|
B =:= 0 -> true ;
|
|
|
|
'$do_error'(domain_error(not_less_than_zero,B),G))
|
|
|
|
;
|
|
|
|
'$do_error'(type_error(integer,B),G)
|
|
|
|
).
|
|
|
|
'$cvt_qsave_flag'(trail(B), G, _) :- !,
|
|
|
|
( number(B) ->
|
|
|
|
(
|
|
|
|
B > 0 -> recordz('$restore_flag',trail(B),_) ;
|
|
|
|
B =:= 0 -> true ;
|
|
|
|
'$do_error'(domain_error(not_less_than_zero,B),G))
|
|
|
|
;
|
|
|
|
'$do_error'(type_error(integer,B),G)
|
|
|
|
).
|
|
|
|
'$cvt_qsave_flag'(goal(B), G, M) :- !,
|
|
|
|
( callable(B) ->
|
|
|
|
strip_module(M:B, M1, G1),
|
|
|
|
recordz('$restore_flag',goal(M1:G1),_)
|
|
|
|
;
|
2014-10-19 12:48:14 +01:00
|
|
|
strip_module(M:B, M1, G1),
|
2014-10-20 09:20:56 +01:00
|
|
|
'$do_error'(type_error(callable,G1),G)
|
2012-06-26 10:09:10 +01:00
|
|
|
).
|
|
|
|
'$cvt_qsave_flag'(toplevel(B), G, M) :- !,
|
|
|
|
( callable(B) ->
|
|
|
|
strip_module(M:B, M1, G1),
|
|
|
|
recordz('$restore_flag',toplevel(M1:G1),_)
|
|
|
|
;
|
2014-10-19 12:48:14 +01:00
|
|
|
strip_module(M:B, M1, G1),
|
2014-10-20 09:20:56 +01:00
|
|
|
'$do_error'(type_error(callable,G1),G)
|
2012-06-26 10:09:10 +01:00
|
|
|
).
|
|
|
|
'$cvt_qsave_flag'(init_file(B), G, M) :- !,
|
|
|
|
( atom(B) ->
|
|
|
|
recordz('$restore_flag', init_file(M:B), _)
|
|
|
|
;
|
|
|
|
'$do_error'(type_error(atom,B),G)
|
|
|
|
).
|
|
|
|
%% '$cvt_qsave_flag'(autoload(_B), G, autoload(_B)).
|
|
|
|
%% '$cvt_qsave_flag'(op(_B), G, op(_B)).
|
|
|
|
%% '$cvt_qsave_flag'(stand_alone(_B), G, stand_alone(_B)).
|
|
|
|
%% '$cvt_qsave_flag'(emulator(_B), G, emulator(_B)).
|
|
|
|
%% '$cvt_qsave_flag'(foreign(_B), G, foreign(_B)).
|
|
|
|
'$cvt_qsave_flag'(Opt, G, _M) :-
|
|
|
|
'$do_error'(domain_error(qsave_program,Opt), G).
|
2011-08-31 21:59:30 +01:00
|
|
|
|
2011-09-01 05:12:25 +01:00
|
|
|
% there is some ordering between flags.
|
2014-10-07 01:35:41 +01:00
|
|
|
'$x_yap_flag'(goal, _Goal).
|
|
|
|
'$x_yap_flag'(language, _V).
|
2013-11-13 10:38:20 +00:00
|
|
|
'$x_yap_flag'(M:unknown, V) :-
|
|
|
|
current_module(M),
|
|
|
|
yap_flag(M:unknown, V).
|
2011-09-01 05:12:25 +01:00
|
|
|
'$x_yap_flag'(X, V) :-
|
|
|
|
yap_flag(X, V),
|
2014-08-04 15:45:30 +01:00
|
|
|
X \= gc_margin, % different machines will have different needs,
|
2014-10-26 17:39:13 +00:00
|
|
|
X \= argv,
|
2014-09-02 20:19:23 +01:00
|
|
|
X \= os_argv,
|
2012-04-19 07:00:29 +01:00
|
|
|
X \= language,
|
2014-08-04 15:45:30 +01:00
|
|
|
X \= max_threads,
|
|
|
|
X \= max_workers,
|
2013-01-17 10:12:08 +00:00
|
|
|
X \= readline,
|
2012-04-19 07:00:29 +01:00
|
|
|
X \= timezone,
|
2013-01-18 14:33:41 +00:00
|
|
|
X \= tty_control,
|
2013-11-13 10:38:20 +00:00
|
|
|
X \= undefined,
|
2012-04-19 07:00:29 +01:00
|
|
|
X \= user_input,
|
|
|
|
X \= user_output,
|
|
|
|
X \= user_error,
|
2013-01-31 10:18:07 +00:00
|
|
|
X \= version,
|
|
|
|
X \= version_data.
|
2011-09-01 05:12:25 +01:00
|
|
|
|
2011-08-31 21:59:30 +01:00
|
|
|
'$init_state' :-
|
|
|
|
recorded('$program_state', _, _), !,
|
|
|
|
'$do_init_state'.
|
|
|
|
'$init_state'.
|
|
|
|
|
|
|
|
'$do_init_state' :-
|
2011-09-07 21:17:23 +01:00
|
|
|
compile_expressions,
|
2011-08-31 21:59:30 +01:00
|
|
|
'$init_preds',
|
|
|
|
fail.
|
|
|
|
'$do_init_state' :-
|
|
|
|
recorded('$program_state',L,R),
|
|
|
|
erase(R),
|
|
|
|
lists:member(F:V,L),
|
|
|
|
catch(yap_flag(F,V),_,fail),
|
|
|
|
fail.
|
2012-08-22 17:32:05 +01:00
|
|
|
'$do_init_state' :-
|
|
|
|
'$reinit_thread0',
|
|
|
|
fail.
|
2011-08-31 21:59:30 +01:00
|
|
|
'$do_init_state' :-
|
2011-09-09 21:39:15 +01:00
|
|
|
set_value('$user_module',user),
|
|
|
|
'$protect',
|
|
|
|
fail.
|
2011-08-31 21:59:30 +01:00
|
|
|
'$do_init_state' :-
|
|
|
|
'$current_module'(prolog),
|
|
|
|
module(user),
|
|
|
|
fail.
|
|
|
|
'$do_init_state' :-
|
2011-09-09 21:39:15 +01:00
|
|
|
'$init_from_saved_state_and_args',
|
|
|
|
fail.
|
2011-08-31 21:59:30 +01:00
|
|
|
'$do_init_state'.
|
|
|
|
|
2011-09-09 21:39:15 +01:00
|
|
|
%
|
|
|
|
% first, recover what we need from the saved state...
|
|
|
|
%
|
|
|
|
'$init_from_saved_state_and_args' :-
|
|
|
|
'$init_path_extensions',
|
|
|
|
fail.
|
|
|
|
% use if we come from a save_program and we have SWI's shlib
|
2012-06-08 12:55:23 +01:00
|
|
|
'$init_from_saved_state_and_args' :-
|
|
|
|
current_prolog_flag(hwnd, _HWND),
|
|
|
|
load_files(library(win_menu), [silent(true)]),
|
|
|
|
fail.
|
2011-09-09 21:39:15 +01:00
|
|
|
'$init_from_saved_state_and_args' :-
|
2014-10-07 01:35:41 +01:00
|
|
|
recorded('$reload_foreign_libraries',_G,R),
|
2011-09-09 21:39:15 +01:00
|
|
|
erase(R),
|
|
|
|
shlib:reload_foreign_libraries,
|
|
|
|
fail.
|
2012-01-13 23:23:18 +00:00
|
|
|
% this should be done before -l kicks in.
|
2011-09-09 21:39:15 +01:00
|
|
|
'$init_from_saved_state_and_args' :-
|
|
|
|
'$access_yap_flags'(16,0),
|
|
|
|
( exists('~/.yaprc') -> load_files('~/.yaprc', []) ; true ),
|
|
|
|
( exists('~/.prologrc') -> load_files('~/.prologrc', []) ; true ),
|
|
|
|
( exists('~/prolog.ini') -> load_files('~/prolog.ini', []) ; true ),
|
|
|
|
fail.
|
2012-01-13 23:23:18 +00:00
|
|
|
% use if we come from a save_program and we have a goal to execute
|
|
|
|
'$init_from_saved_state_and_args' :-
|
|
|
|
get_value('$consult_on_boot',X), X \= [],
|
|
|
|
set_value('$consult_on_boot',[]),
|
|
|
|
'$do_startup_reconsult'(X),
|
|
|
|
fail.
|
2012-06-26 10:09:10 +01:00
|
|
|
'$init_from_saved_state_and_args' :-
|
2012-08-23 21:02:41 +01:00
|
|
|
recorded('$restore_flag', init_file(M:B), R),
|
|
|
|
erase(R),
|
|
|
|
'$do_startup_reconsult'(M:B),
|
|
|
|
fail.
|
2013-11-13 10:38:20 +00:00
|
|
|
'$init_from_saved_state_and_args' :-
|
|
|
|
recorded('$restore_flag', unknown(M:B), R),
|
|
|
|
erase(R),
|
|
|
|
yap_flag(M:unknown,B),
|
|
|
|
fail.
|
2011-09-09 21:39:15 +01:00
|
|
|
'$init_from_saved_state_and_args' :-
|
|
|
|
'$startup_goals',
|
|
|
|
fail.
|
|
|
|
'$init_from_saved_state_and_args' :-
|
|
|
|
recorded('$restore_goal',G,R),
|
|
|
|
erase(R),
|
|
|
|
prompt(_,'| '),
|
|
|
|
'$system_catch'('$do_yes_no'((G->true),user),user,Error,user:'$Error'(Error)),
|
|
|
|
fail.
|
|
|
|
'$init_from_saved_state_and_args'.
|
|
|
|
|
|
|
|
'$init_path_extensions' :-
|
2012-08-23 21:02:41 +01:00
|
|
|
get_value('$extend_file_search_path',P), !,
|
|
|
|
P \= [],
|
|
|
|
set_value('$extend_file_search_path',[]),
|
|
|
|
'$extend_file_search_path'(P).
|
2011-09-09 21:39:15 +01:00
|
|
|
'$init_path_extensions'.
|
|
|
|
|
|
|
|
% then we can execute the programs.
|
|
|
|
'$startup_goals' :-
|
|
|
|
recorded('$startup_goal',G,_),
|
|
|
|
'$current_module'(Module),
|
|
|
|
'$system_catch'('$query'(once(G), []),Module,Error,user:'$Error'(Error)),
|
|
|
|
fail.
|
|
|
|
'$startup_goals' :-
|
|
|
|
get_value('$init_goal',GA),
|
|
|
|
GA \= [],
|
|
|
|
set_value('$init_goal',[]),
|
|
|
|
'$run_atom_goal'(GA),
|
|
|
|
fail.
|
2012-06-26 10:09:10 +01:00
|
|
|
'$startup_goals' :-
|
|
|
|
recorded('$restore_flag', goal(Module:GA), R),
|
|
|
|
erase(R),
|
|
|
|
'$system_catch'('$query'(once(GA), []),Module,Error,user:'$Error'(Error)),
|
|
|
|
fail.
|
2011-09-09 21:39:15 +01:00
|
|
|
'$startup_goals' :-
|
|
|
|
get_value('$myddas_goal',GA), GA \= [],
|
|
|
|
set_value('$myddas_goal',[]),
|
|
|
|
get_value('$myddas_user',User), User \= [],
|
|
|
|
set_value('$myddas_user',[]),
|
|
|
|
get_value('$myddas_db',Db), Db \= [],
|
|
|
|
set_value('$myddas_db',[]),
|
|
|
|
get_value('$myddas_host',HostT),
|
|
|
|
( HostT \= [] ->
|
|
|
|
Host = HostT,
|
|
|
|
set_value('$myddas_host',[])
|
|
|
|
;
|
|
|
|
Host = localhost
|
|
|
|
),
|
|
|
|
get_value('$myddas_pass',PassT),
|
|
|
|
( PassT \= [] ->
|
|
|
|
Pass = PassT,
|
|
|
|
set_value('$myddas_pass',[])
|
|
|
|
;
|
|
|
|
Pass = ''
|
|
|
|
),
|
|
|
|
use_module(library(myddas)),
|
|
|
|
call(db_open(mysql,myddas,Host/Db,User,Pass)),
|
|
|
|
'$myddas_import_all',
|
|
|
|
fail.
|
|
|
|
'$startup_goals'.
|
|
|
|
|
|
|
|
%
|
|
|
|
% MYDDAS: Import all the tables from one database
|
|
|
|
%
|
|
|
|
|
|
|
|
'$myddas_import_all':-
|
|
|
|
call(db_my_show_tables(myddas,table(Table))),
|
|
|
|
call(db_import(myddas,Table,Table)),
|
|
|
|
fail.
|
|
|
|
'$myddas_import_all'.
|
2014-10-02 14:57:50 +01:00
|
|
|
|
|
|
|
qsave_file(F0) :-
|
|
|
|
ensure_loaded( F0 ),
|
|
|
|
absolute_file_name( F0, File, [expand(true),file_type(prolog),access(read),file_errors(fail),solutions(first)]),
|
|
|
|
absolute_file_name( F0, State, [expand(true),file_type(qly)]),
|
|
|
|
'$qsave_file_'(File, State).
|
|
|
|
|
2014-07-27 01:14:15 +01:00
|
|
|
/** @pred qsave_file(+ _File_, +_State_)
|
|
|
|
|
2014-09-22 18:13:35 +01:00
|
|
|
Saves an image of all the information compiled by the system from file _F_ to _State_.
|
2014-10-02 14:57:50 +01:00
|
|
|
This includes modules and predicates eventually including multi-predicates.
|
2014-07-27 01:14:15 +01:00
|
|
|
**/
|
2014-09-22 18:13:35 +01:00
|
|
|
qsave_file(F0, State) :-
|
2014-10-02 14:57:50 +01:00
|
|
|
ensure_loaded( F0 ),
|
|
|
|
absolute_file_name( F0, File, [expand(true),file_type(prolog),access(read),file_errors(fail),solutions(first)]),
|
2014-09-22 18:13:35 +01:00
|
|
|
'$qsave_file_'(File, State).
|
|
|
|
|
2014-10-02 14:57:50 +01:00
|
|
|
'$qsave_file_'(File, UserF, _State) :-
|
|
|
|
( File == user_input -> Age = 0 ; time_file64(File, Age) ),
|
2014-10-07 01:35:41 +01:00
|
|
|
'$current_module'(M),
|
2014-10-02 14:57:50 +01:00
|
|
|
assert(user:'$file_property'( '$lf_loaded'( UserF, Age, M) ) ),
|
|
|
|
'$set_owner_file'( '$file_property'( _ ), user, File ),
|
|
|
|
fail.
|
2014-10-07 01:35:41 +01:00
|
|
|
'$qsave_file_'(File, UserF, _State) :-
|
2014-10-02 14:57:50 +01:00
|
|
|
recorded('$lf_loaded','$lf_loaded'( File, M, Reconsult, UserFile, OldF, Line, Opts), _),
|
|
|
|
assert(user:'$file_property'( '$lf_loaded'( UserF, M, Reconsult, UserFile, OldF, Line, Opts) ) ),
|
|
|
|
'$set_owner_file'( '$file_property'( _ ), user, File ),
|
2014-09-22 18:13:35 +01:00
|
|
|
fail.
|
2014-10-02 14:57:50 +01:00
|
|
|
'$qsave_file_'(File, _UserF, _State) :-
|
|
|
|
recorded('$directive',directive( File, M:G, Mode, VL, Pos ), _),
|
|
|
|
assert(user:'$file_property'( directive( M:G, Mode, VL, Pos ) ) ),
|
|
|
|
'$set_owner_file'('$file_property'( _ ), user, File ),
|
2014-09-22 18:13:35 +01:00
|
|
|
fail.
|
2014-10-02 14:57:50 +01:00
|
|
|
'$qsave_file_'(File, _UserF, _State) :-
|
2014-09-22 18:13:35 +01:00
|
|
|
'$fetch_multi_files_file'(File, MultiFiles),
|
2014-10-02 14:57:50 +01:00
|
|
|
assert(user:'$file_property'( multifile(MultiFiles ) ) ),
|
|
|
|
'$set_owner_file'('$file_property'( _ ), user, File ),
|
2014-09-22 18:13:35 +01:00
|
|
|
fail.
|
2014-10-02 14:57:50 +01:00
|
|
|
'$qsave_file_'( File, _UserF, State ) :-
|
2014-09-22 18:13:35 +01:00
|
|
|
(
|
|
|
|
is_stream( State )
|
|
|
|
->
|
2014-10-02 14:57:50 +01:00
|
|
|
'$qsave_file_preds'(State, File)
|
2014-09-22 18:13:35 +01:00
|
|
|
;
|
2014-07-27 01:14:15 +01:00
|
|
|
open(State, write, S, [type(binary)]),
|
2014-09-22 18:13:35 +01:00
|
|
|
'$qsave_file_preds'(S, File),
|
|
|
|
close(S)
|
2014-10-02 14:57:50 +01:00
|
|
|
),
|
|
|
|
abolish(user:'$file_property'/1).
|
2014-09-22 18:13:35 +01:00
|
|
|
|
|
|
|
'$fetch_multi_files_file'(File, Multi_Files) :-
|
|
|
|
setof(Info, '$fetch_multi_file_module'(File, Info), Multi_Files).
|
|
|
|
|
|
|
|
'$fetch_multi_file_file'(FileName, (M:G :- Body)) :-
|
2014-10-07 01:35:41 +01:00
|
|
|
recorded('$multifile_defs','$defined'(FileName,Name,Arity,M), _),
|
2014-09-22 18:13:35 +01:00
|
|
|
functor(G, Name, Arity ),
|
|
|
|
clause(M:G, Body, ClauseRef),
|
|
|
|
clause_property(ClauseRef, file(FileName) ).
|
|
|
|
|
2012-08-22 17:32:05 +01:00
|
|
|
|
2014-07-27 01:14:15 +01:00
|
|
|
/** @pred qsave_module(+ _Module_, +_State_)
|
|
|
|
Saves an image of all the information compiled by the systemm on module _F_ to _State_.
|
|
|
|
**/
|
|
|
|
|
2014-09-23 22:40:40 +01:00
|
|
|
qsave_module(Mod, OF) :-
|
2014-10-07 01:35:41 +01:00
|
|
|
recorded('$module', '$module'(_F,Mod,Source,Exps,L), _),
|
2011-08-28 01:29:04 +01:00
|
|
|
'$fetch_parents_module'(Mod, Parents),
|
|
|
|
'$fetch_imports_module'(Mod, Imps),
|
|
|
|
'$fetch_multi_files_module'(Mod, MFs),
|
|
|
|
'$fetch_meta_predicates_module'(Mod, Metas),
|
|
|
|
'$fetch_module_transparents_module'(Mod, ModTransps),
|
2014-09-25 09:45:25 +01:00
|
|
|
'$fetch_term_expansions_module'(Mod, TEs),
|
2014-09-22 18:13:35 +01:00
|
|
|
'$fetch_foreigns_module'(Mod, Foreigns),
|
2014-10-02 14:57:50 +01:00
|
|
|
asserta(Mod:'@mod_info'(Source, Exps, MFs, L, Parents, Imps, Metas, ModTransps, Foreigns, TEs)),
|
2011-08-28 01:29:04 +01:00
|
|
|
open(OF, write, S, [type(binary)]),
|
|
|
|
'$qsave_module_preds'(S, Mod),
|
|
|
|
close(S),
|
2014-10-02 14:57:50 +01:00
|
|
|
abolish(Mod:'@mod_info'/10),
|
2011-08-28 01:29:04 +01:00
|
|
|
fail.
|
2014-09-25 09:45:25 +01:00
|
|
|
qsave_module(_, _).
|
|
|
|
|
|
|
|
/** @pred qsave_module(+ _Module_)
|
|
|
|
|
|
|
|
Saves an image of all the information compiled by the systemm on
|
|
|
|
module _F_ to a file _State.qly_ in the current directory.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
qsave_module(Mod) :-
|
|
|
|
atom_concat(Mod,'.qly',OF),
|
|
|
|
qsave_module(Mod, OF).
|
2011-08-03 16:30:39 +01:00
|
|
|
|
2014-07-27 01:14:15 +01:00
|
|
|
/**
|
|
|
|
@pred restore(+ _F_)
|
|
|
|
Restores a previously saved state of YAP from file _F_.
|
|
|
|
|
|
|
|
*/
|
2012-06-11 09:22:53 +01:00
|
|
|
restore(File) :-
|
2011-08-28 01:29:04 +01:00
|
|
|
open(File, read, S, [type(binary)]),
|
2011-08-31 21:59:30 +01:00
|
|
|
'$qload_program'(S),
|
2011-08-24 04:11:54 +01:00
|
|
|
close(S).
|
|
|
|
|
2014-07-27 01:14:15 +01:00
|
|
|
/**
|
2014-09-22 18:13:35 +01:00
|
|
|
@pred qload_module(+ _M_)
|
|
|
|
|
|
|
|
Restores a previously save image of module _M_. This built-in searches
|
|
|
|
for a file M.qly or M according to the rules for qly files.
|
|
|
|
|
|
|
|
The q_load_module/1 built-in tries to reload any modules it imports
|
|
|
|
from and any foreign files that had been loaded with the original
|
|
|
|
module. It tries first reloading from qly images, but if they are not
|
|
|
|
available it tries reconsulting the source file.
|
2014-07-27 01:14:15 +01:00
|
|
|
|
|
|
|
*/
|
2011-08-28 01:29:04 +01:00
|
|
|
qload_module(Mod) :-
|
2014-09-25 09:45:25 +01:00
|
|
|
( '$swi_current_prolog_flag'(verbose_load, false)
|
|
|
|
->
|
|
|
|
Verbosity = silent
|
|
|
|
;
|
|
|
|
Verbosity = informational
|
|
|
|
),
|
|
|
|
StartMsg = loading_module,
|
2014-10-07 01:35:41 +01:00
|
|
|
EndMsg = module_loaded,
|
2014-09-25 09:45:25 +01:00
|
|
|
'$current_module'(SourceModule, Mod),
|
|
|
|
H0 is heapused, '$cputime'(T0,_),
|
|
|
|
absolute_file_name( Mod, File, [expand(true),file_type(qly)]),
|
|
|
|
print_message(Verbosity, loading(StartMsg, File)),
|
|
|
|
file_directory_name( File, Dir),
|
|
|
|
working_directory(OldD, Dir),
|
|
|
|
'$qload_module'(Mod, File, SourceModule ),
|
|
|
|
H is heapused-H0, '$cputime'(TF,_), T is TF-T0,
|
|
|
|
print_message(Verbosity, loaded(EndMsg, File, Mod, T, H)),
|
|
|
|
'$current_module'(_, SourceModule),
|
|
|
|
working_directory(_, OldD).
|
|
|
|
|
2014-10-02 14:57:50 +01:00
|
|
|
'$qload_module'(Mod, S, SourceModule) :-
|
|
|
|
is_stream( S ), !,
|
|
|
|
'$q_header'( S, Type ),
|
|
|
|
stream_property( S, file_name( File )),
|
|
|
|
( Type == module ->
|
|
|
|
'$qload_module'(S , Mod, File, SourceModule)
|
|
|
|
;
|
|
|
|
Type == file ->
|
|
|
|
'$qload_file'(S, File)
|
|
|
|
).
|
2014-09-25 09:45:25 +01:00
|
|
|
'$qload_module'(Mod, File, SourceModule) :-
|
2014-10-02 14:57:50 +01:00
|
|
|
open(File, read, S, [type(binary)]),
|
|
|
|
'$q_header'( S, Type ),
|
|
|
|
( Type == module ->
|
|
|
|
'$qload_module'(S , Mod, File, SourceModule)
|
|
|
|
;
|
|
|
|
Type == file ->
|
|
|
|
'$qload_file'(S, File)
|
|
|
|
),
|
|
|
|
close(S).
|
2014-09-22 18:13:35 +01:00
|
|
|
|
2014-10-02 14:57:50 +01:00
|
|
|
'$qload_module'(_S, Mod, _File, _SourceModule) :-
|
|
|
|
unload_module( Mod ), fail.
|
|
|
|
'$qload_module'(S, _Mod, _File, _SourceModule) :-
|
|
|
|
'$qload_module_preds'(S), fail.
|
|
|
|
'$qload_module'(_S, Mod, File, SourceModule) :-
|
2014-09-25 09:45:25 +01:00
|
|
|
Mod:'@mod_info'(F, Exps, MFs, Line,Parents, Imps, Metas, ModTransps, Foreigns, TEs),
|
2014-10-02 14:57:50 +01:00
|
|
|
abolish(Mod:'@mod_info'/10),
|
2014-09-25 09:45:25 +01:00
|
|
|
recorda('$module', '$module'(File, Mod, F, Exps, Line), _),
|
2014-09-23 22:40:40 +01:00
|
|
|
'$install_parents_module'(Mod, Parents),
|
2014-09-25 09:45:25 +01:00
|
|
|
'$install_imports_module'(Mod, Imps, []),
|
2014-09-23 22:40:40 +01:00
|
|
|
'$install_multi_files_module'(Mod, MFs),
|
|
|
|
'$install_meta_predicates_module'(Mod, Metas),
|
2014-09-25 09:45:25 +01:00
|
|
|
'$install_foreigns_module'(Mod, Foreigns),
|
2014-09-23 22:40:40 +01:00
|
|
|
'$install_module_transparents_module'(Mod, ModTransps),
|
2014-09-25 09:45:25 +01:00
|
|
|
'$install_term_expansions_module'(Mod, TEs),
|
2014-09-23 22:40:40 +01:00
|
|
|
% last, export everything to the host: if the loading crashed you didn't actually do
|
|
|
|
% no evil.
|
2014-10-07 01:35:41 +01:00
|
|
|
'$convert_for_export'(all, Exps, Mod, SourceModule, TranslationTab, _AllExports0, qload_module),
|
|
|
|
'$add_to_imports'(TranslationTab, Mod, SourceModule). % insert ops, at least for now
|
2014-09-25 09:45:25 +01:00
|
|
|
|
2011-08-28 01:29:04 +01:00
|
|
|
'$fetch_imports_module'(Mod, Imports) :-
|
|
|
|
findall(Info, '$fetch_import_module'(Mod, Info), Imports).
|
|
|
|
|
2014-09-22 18:13:35 +01:00
|
|
|
% detect an import that is local to the module.
|
|
|
|
'$fetch_import_module'(Mod, '$import'(Mod0,Mod,G0,G,N,K) - S) :-
|
|
|
|
recorded('$import', '$import'(Mod0,Mod,G0,G,N,K), _),
|
2014-10-07 01:35:41 +01:00
|
|
|
( recorded('$module','$module'(_, Mod0, S, _, _), _) -> true ; S = user_input ).
|
2011-08-28 01:29:04 +01:00
|
|
|
|
|
|
|
'$fetch_parents_module'(Mod, Parents) :-
|
|
|
|
findall(Parent, prolog:'$parent_module'(Mod,Parent), Parents).
|
|
|
|
|
2014-10-07 01:35:41 +01:00
|
|
|
'$fetch_module_transparents_module'(Mod, Module_Transparents) :-
|
2014-09-25 09:45:25 +01:00
|
|
|
findall(Info, '$fetch_module_transparent_module'(Mod, Info), Module_Transparents).
|
2011-08-28 01:29:04 +01:00
|
|
|
|
|
|
|
% detect an module_transparenterator that is local to the module.
|
|
|
|
'$fetch_module_transparent_module'(Mod, '$module_transparent'(F,Mod,N,P)) :-
|
|
|
|
prolog:'$module_transparent'(F,Mod0,N,P), Mod0 == Mod.
|
|
|
|
|
|
|
|
'$fetch_meta_predicates_module'(Mod, Meta_Predicates) :-
|
2014-09-25 09:45:25 +01:00
|
|
|
findall(Info, '$fetch_meta_predicate_module'(Mod, Info), Meta_Predicates).
|
2011-08-28 01:29:04 +01:00
|
|
|
|
2014-09-22 18:13:35 +01:00
|
|
|
% detect a meta_predicate that is local to the module.
|
2011-08-28 01:29:04 +01:00
|
|
|
'$fetch_meta_predicate_module'(Mod, '$meta_predicate'(F,Mod,N,P)) :-
|
2014-09-25 09:45:25 +01:00
|
|
|
prolog:'$meta_predicate'(F,M,N,P), M==Mod.
|
2011-08-28 01:29:04 +01:00
|
|
|
|
|
|
|
'$fetch_multi_files_module'(Mod, Multi_Files) :-
|
2014-09-25 09:45:25 +01:00
|
|
|
findall(Info, '$fetch_multi_file_module'(Mod, Info), Multi_Files).
|
2011-08-28 01:29:04 +01:00
|
|
|
|
2014-09-22 18:13:35 +01:00
|
|
|
% detect an multi_file that is local to the module.
|
2011-08-28 01:29:04 +01:00
|
|
|
'$fetch_multi_file_module'(Mod, '$defined'(FileName,Name,Arity,Mod)) :-
|
|
|
|
recorded('$multifile_defs','$defined'(FileName,Name,Arity,Mod), _).
|
2014-10-07 01:35:41 +01:00
|
|
|
'$fetch_multi_file_module'(Mod, '$mf_clause'(FileName,_Name,_Arity,Mod,Clause), _) :-
|
|
|
|
recorded('$mf','$mf_clause'(FileName,_Name,_Arity,Mod,ClauseRef), _),
|
|
|
|
instance(ClauseRef, Clause ).
|
2011-08-28 01:29:04 +01:00
|
|
|
|
2014-10-02 14:57:50 +01:00
|
|
|
'$fetch_term_expansions_module'(Mod, TEs) :-
|
|
|
|
findall(Info, '$fetch_term_expansion_module'(Mod, Info), TEs).
|
2011-08-28 01:29:04 +01:00
|
|
|
|
|
|
|
% detect an term_expansionerator that is local to the module.
|
2014-09-25 09:45:25 +01:00
|
|
|
'$fetch_term_expansion_module'(Mod, ( user:term_expansion(G, GI) :- Bd )) :-
|
|
|
|
clause( user:term_expansion(G, GI), Bd, _),
|
|
|
|
strip_module(G, Mod, _).
|
|
|
|
% detect an term_expansionerator that is local to the module.
|
|
|
|
'$fetch_term_expansion_module'(Mod, ( system:term_expansion(G, GI) :- Bd )) :-
|
|
|
|
clause( system:term_expansion(G, GI), Bd, _),
|
|
|
|
strip_module(G, Mod, _).
|
|
|
|
% detect an term_expansionerator that is local to the module.
|
|
|
|
'$fetch_term_expansion_module'(Mod, ( user:goal_expansion(G, CurMod, GI) :- Bd )) :-
|
|
|
|
clause( user:goal_expansion(G, CurMod, GI), Bd, _),
|
|
|
|
Mod == CurMod.
|
|
|
|
% detect an term_expansionerator that is local to the module.
|
|
|
|
'$fetch_term_expansion_module'(Mod, ( user:goal_expansion(G, GI) :- Bd )) :-
|
|
|
|
clause( user:goal_expansion(G, GI), Bd, _),
|
|
|
|
strip_module(G, Mod, _).
|
|
|
|
% detect an term_expansionerator that is local to the module.
|
|
|
|
'$fetch_term_expansion_module'(Mod, ( system:goal_expansion(G, GI) :- Bd )) :-
|
|
|
|
clause( system:goal_expansion(G, GI), Bd, _),
|
|
|
|
strip_module(G, Mod, _).
|
2011-08-28 01:29:04 +01:00
|
|
|
|
2014-09-22 18:13:35 +01:00
|
|
|
'$fetch_foreigns_module'(Mod, Foreigns) :-
|
2014-09-25 09:45:25 +01:00
|
|
|
findall(Info, '$fetch_foreign_module'(Mod, Info), Foreigns).
|
2011-08-28 01:29:04 +01:00
|
|
|
|
2014-09-22 18:13:35 +01:00
|
|
|
% detect an term_expansionerator that is local to the module.
|
|
|
|
'$fetch_foreign_module'(Mod,Foreign) :-
|
|
|
|
recorded( '$foreign', Mod:Foreign, _).
|
2011-08-28 01:29:04 +01:00
|
|
|
|
2014-09-25 09:45:25 +01:00
|
|
|
'$install_term_expansions_module'(_, []).
|
|
|
|
'$install_term_expansions_module'(Mod, [TE|TEs]) :-
|
|
|
|
assert(TE),
|
|
|
|
'$install_term_expansions_module'(Mod, TEs).
|
2011-08-28 01:29:04 +01:00
|
|
|
|
2014-09-22 18:13:35 +01:00
|
|
|
'$install_imports_module'(_, [], Fs0) :-
|
|
|
|
sort(Fs0, Fs),
|
|
|
|
'$restore_load_files'(Fs).
|
|
|
|
'$install_imports_module'(Mod, [Import-F|Imports], Fs0) :-
|
2011-08-28 01:29:04 +01:00
|
|
|
recordz('$import', Import, _),
|
2014-09-22 18:13:35 +01:00
|
|
|
arg(1, Import, M),
|
|
|
|
'$install_imports_module'(Mod, Imports, [M-F|Fs0]).
|
|
|
|
|
|
|
|
'$restore_load_files'([]).
|
|
|
|
'$restore_load_files'([M-F0|Fs]) :-
|
|
|
|
(
|
2014-10-07 01:35:41 +01:00
|
|
|
absolute_file_name( M,_File, [expand(true),file_type(qly),access(read),file_errors(fail)])
|
2014-09-22 18:13:35 +01:00
|
|
|
->
|
|
|
|
qload_module(M)
|
|
|
|
;
|
|
|
|
use_module(M, F0, _)
|
|
|
|
),
|
|
|
|
'$restore_load_files'(Fs).
|
2011-08-28 01:29:04 +01:00
|
|
|
|
|
|
|
'$install_parents_module'(_, []).
|
2014-09-22 18:13:35 +01:00
|
|
|
'$install_parents_module'(Mod, [Parent|Parents]) :-
|
2011-08-28 01:29:04 +01:00
|
|
|
assert(prolog:Parent),
|
|
|
|
'$install_parents_module'(Mod, Parents).
|
|
|
|
|
|
|
|
'$install_module_transparents_module'(_, []).
|
2014-09-22 18:13:35 +01:00
|
|
|
'$install_module_transparents_module'(Mod, [Module_Transparent|Module_Transparents]) :-
|
2011-08-28 01:29:04 +01:00
|
|
|
assert(prolog:Module_Transparent),
|
|
|
|
'$install_module_transparents_module'(Mod, Module_Transparents).
|
|
|
|
|
|
|
|
'$install_meta_predicates_module'(_, []).
|
2014-09-22 18:13:35 +01:00
|
|
|
'$install_meta_predicates_module'(Mod, [Meta_Predicate|Meta_Predicates]) :-
|
2011-08-28 01:29:04 +01:00
|
|
|
assert(prolog:Meta_Predicate),
|
|
|
|
'$install_meta_predicates_module'(Mod, Meta_Predicates).
|
|
|
|
|
|
|
|
'$install_multi_files_module'(_, []).
|
2014-09-22 18:13:35 +01:00
|
|
|
'$install_multi_files_module'(Mod, [Multi_File|Multi_Files]) :-
|
|
|
|
recordz('$multifile_defs',Multi_File, _),
|
2011-08-28 01:29:04 +01:00
|
|
|
'$install_multi_files_module'(Mod, Multi_Files).
|
|
|
|
|
2014-09-22 18:13:35 +01:00
|
|
|
'$install_foreigns_module'(_, []).
|
|
|
|
'$install_foreigns_module'(Mod, [Foreign|Foreigns]) :-
|
|
|
|
'$do_foreign'(Foreign, Foreigns),
|
|
|
|
'$install_foreigns_module'(Mod, Foreigns).
|
|
|
|
|
|
|
|
'$do_foreign'('$foreign'(Objs,Libs,Entry), _) :-
|
|
|
|
load_foreign_files(Objs,Libs,Entry).
|
|
|
|
'$do_foreign'('$swi_foreign'(File, Opts, Handle), More) :-
|
|
|
|
open_shared_object(File, Opts, Handle, NewHandle),
|
|
|
|
'$init_foreigns'(More, NewHandle).
|
2014-10-07 01:35:41 +01:00
|
|
|
'$do_foreign'('$swi_foreign'(_,_), _More).
|
2014-09-22 18:13:35 +01:00
|
|
|
|
2014-10-07 01:35:41 +01:00
|
|
|
'$init_foreigns'([], _Handle, _NewHandle).
|
2014-09-22 18:13:35 +01:00
|
|
|
'$init_foreigns'(['$swi_foreign'( Handle, Function )|More], Handle, NewHandle) :-
|
|
|
|
!,
|
|
|
|
call_shared_object_function( NewHandle, Function),
|
|
|
|
'$init_foreigns'(More, Handle, NewHandle).
|
|
|
|
'$init_foreigns'([_|More], Handle, NewHandle) :-
|
|
|
|
'$init_foreigns'(More, Handle, NewHandle).
|
|
|
|
|
|
|
|
/**
|
|
|
|
@pred qload_file(+ _F_)
|
|
|
|
|
|
|
|
Restores a previously saved state of YAP contaianing a qly file _F_.
|
|
|
|
|
|
|
|
*/
|
2014-10-02 14:57:50 +01:00
|
|
|
qload_file( F0 ) :-
|
|
|
|
( '$swi_current_prolog_flag'(verbose_load, false)
|
|
|
|
->
|
|
|
|
Verbosity = silent
|
|
|
|
;
|
|
|
|
Verbosity = informational
|
|
|
|
),
|
|
|
|
StartMsg = loading_module,
|
2014-10-07 01:35:41 +01:00
|
|
|
EndMsg = module_loaded,
|
2014-10-02 14:57:50 +01:00
|
|
|
'$current_module'( SourceModule ),
|
|
|
|
H0 is heapused,
|
|
|
|
'$cputime'(T0,_),
|
|
|
|
( is_stream( F0 )
|
2014-09-22 18:13:35 +01:00
|
|
|
->
|
|
|
|
stream_property(F0, file_name(File) ),
|
2014-10-02 14:57:50 +01:00
|
|
|
File = FilePl,
|
|
|
|
S = File
|
2014-09-22 18:13:35 +01:00
|
|
|
;
|
|
|
|
absolute_file_name( F0, File, [expand(true),file_type(qly)]),
|
2014-10-02 14:57:50 +01:00
|
|
|
absolute_file_name( F0, FilePl, [expand(true),file_type(prolog)]),
|
|
|
|
unload_file( FilePl ),
|
2014-09-22 18:13:35 +01:00
|
|
|
open(File, read, S, [type(binary)])
|
|
|
|
),
|
2014-10-02 14:57:50 +01:00
|
|
|
print_message(Verbosity, loading(StartMsg, File)),
|
2014-09-22 18:13:35 +01:00
|
|
|
file_directory_name(File, DirName),
|
2014-10-02 14:57:50 +01:00
|
|
|
working_directory(OldD, DirName),
|
|
|
|
'$q_header'( S, Type ),
|
|
|
|
( Type == module ->
|
|
|
|
'$qload_module'(S , Mod, File, SourceModule)
|
|
|
|
;
|
|
|
|
Type == file ->
|
2014-10-09 10:45:38 +01:00
|
|
|
'$lf_option'(last_opt, LastOpt),
|
|
|
|
functor( TOpts, opt, LastOpt ),
|
|
|
|
'$lf_default_opts'(1, LastOpt, TOpts),
|
2014-10-08 00:28:14 +01:00
|
|
|
'$qload_file'(S, SourceModule, File, FilePl, F0, all, TOpts)
|
2014-10-02 14:57:50 +01:00
|
|
|
),
|
|
|
|
close(S),
|
2014-09-22 18:13:35 +01:00
|
|
|
working_directory( _, OldD),
|
|
|
|
H is heapused-H0, '$cputime'(TF,_), T is TF-T0,
|
2014-10-02 14:57:50 +01:00
|
|
|
'$current_module'(Mod, Mod ),
|
|
|
|
print_message(Verbosity, loaded(EndMsg, File, Mod, T, H)),
|
|
|
|
'$exec_initialisation_goals'.
|
|
|
|
|
2014-10-08 00:28:14 +01:00
|
|
|
'$qload_file'(_S, SourceModule, _F, FilePl, _F0, _ImportList, _TOpts) :-
|
2015-04-21 23:08:58 +01:00
|
|
|
recorded('$source_file','$source_file'( FilePl, _Age, SourceModule), _),
|
2014-10-02 14:57:50 +01:00
|
|
|
!.
|
2014-10-08 00:28:14 +01:00
|
|
|
'$qload_file'(_S, SourceModule, _F, FilePl, _F0, _ImportList, _TOpts) :-
|
2014-10-05 10:20:36 +01:00
|
|
|
( FilePl == user_input -> Age = 0 ; time_file64(FilePl, Age) ),
|
2015-04-21 23:08:58 +01:00
|
|
|
recordaifnot('$source_file','$source_file'( FilePl, Age, SourceModule), _),
|
2014-10-05 10:20:36 +01:00
|
|
|
fail.
|
2014-10-08 00:28:14 +01:00
|
|
|
'$qload_file'(S, _SourceModule, _File, _FilePl, _F0, _ImportList, _TOpts) :-
|
2014-10-02 14:57:50 +01:00
|
|
|
'$qload_file_preds'(S),
|
|
|
|
fail.
|
2014-10-08 00:28:14 +01:00
|
|
|
'$qload_file'(_S, SourceModule, F, _FilePl, _F0, _ImportList, _TOpts) :-
|
2014-10-07 01:35:41 +01:00
|
|
|
user:'$file_property'( '$lf_loaded'( F, Age, _ ) ),
|
2015-04-21 23:08:58 +01:00
|
|
|
recordaifnot('$source_file','$source_file'( F, Age, SourceModule), _),
|
2014-09-22 18:13:35 +01:00
|
|
|
fail.
|
2014-10-08 00:28:14 +01:00
|
|
|
'$qload_file'(_S, _SourceModule, _File, FilePl, F0, _ImportList, _TOpts) :-
|
2014-10-02 14:57:50 +01:00
|
|
|
b_setval('$source_file', F0 ),
|
|
|
|
'$process_directives'( FilePl ),
|
|
|
|
fail.
|
2014-10-08 00:28:14 +01:00
|
|
|
'$qload_file'(_S, SourceModule, _File, FilePl, _F0, ImportList, TOpts) :-
|
|
|
|
'$import_to_current_module'(FilePl, SourceModule, ImportList, _, TOpts).
|
2014-09-22 18:13:35 +01:00
|
|
|
|
2014-10-02 14:57:50 +01:00
|
|
|
'$process_directives'( FilePl ) :-
|
|
|
|
user:'$file_property'( '$lf_loaded'( FilePl, M, Reconsult, UserFile, OldF, Line, Opts) ),
|
|
|
|
recorda('$lf_loaded','$lf_loaded'( FilePl, M, Reconsult, UserFile, OldF, Line, Opts), _),
|
|
|
|
fail.
|
|
|
|
'$process_directives'( _FilePl ) :-
|
|
|
|
user:'$file_property'( multifile( List ) ),
|
2014-09-22 18:13:35 +01:00
|
|
|
lists:member( Clause, List ),
|
|
|
|
assert( Clause ),
|
|
|
|
fail.
|
2014-10-02 14:57:50 +01:00
|
|
|
'$process_directives'( FilePl ) :-
|
2014-10-07 01:35:41 +01:00
|
|
|
user:'$file_property'( directive( MG, _Mode, VL, Pos ) ),
|
2014-10-02 14:57:50 +01:00
|
|
|
'$set_source'( FilePl, Pos ),
|
|
|
|
strip_module(MG, M, G),
|
|
|
|
'$process_directive'(G, reconsult, M, VL, Pos),
|
2014-09-22 18:13:35 +01:00
|
|
|
fail.
|
2014-10-02 14:57:50 +01:00
|
|
|
'$process_directives'( _FilePl ) :-
|
|
|
|
abolish(user:'$file_property'/1).
|
2011-08-28 01:29:04 +01:00
|
|
|
|
|
|
|
|