init handling
This commit is contained in:
parent
ed4b76ddc6
commit
9ffe2ddddc
@ -189,7 +189,7 @@ following flags:
|
|||||||
% autoload(true,false)
|
% autoload(true,false)
|
||||||
% derived_from(File) -> make
|
% derived_from(File) -> make
|
||||||
% encoding(Encoding) => implemented
|
% encoding(Encoding) => implemented
|
||||||
% expand(true,false)
|
% expand(true,false)
|
||||||
% if(changed,true,not_loaded) => implemented
|
% if(changed,true,not_loaded) => implemented
|
||||||
% imports(all,List) => implemented
|
% imports(all,List) => implemented
|
||||||
% qcompile() => implemented
|
% qcompile() => implemented
|
||||||
@ -457,20 +457,26 @@ load_files(Files,Opts) :-
|
|||||||
'$loaded'(File, UserFile, Mod, ParentF, Line, not_loaded, _, _Dir, Opts),
|
'$loaded'(File, UserFile, Mod, ParentF, Line, not_loaded, _, _Dir, Opts),
|
||||||
'$reexport'( TOpts, ParentF, Reexport, Imports, File ).
|
'$reexport'( TOpts, ParentF, Reexport, Imports, File ).
|
||||||
'$start_lf'(changed, Mod, _Stream, TOpts, UserFile, File, Reexport, Imports) :-
|
'$start_lf'(changed, Mod, _Stream, TOpts, UserFile, File, Reexport, Imports) :-
|
||||||
'$file_unchanged'(File, Mod, Imports, TOpts), !,
|
'$file_unchanged'(File, Mod, Imports, TOpts), !,
|
||||||
'$lf_opt'('$options', TOpts, Opts),
|
'$lf_opt'('$options', TOpts, Opts),
|
||||||
'$lf_opt'('$location', TOpts, ParentF:Line),
|
'$lf_opt'('$location', TOpts, ParentF:Line),
|
||||||
'$loaded'(File, UserFile, Mod, ParentF, Line, changed, _, _Dir, Opts),
|
'$loaded'(File, UserFile, Mod, ParentF, Line, changed, _, _Dir, Opts),
|
||||||
'$reexport'( TOpts, ParentF, Reexport, Imports, File ).
|
'$reexport'( TOpts, ParentF, Reexport, Imports, File ).
|
||||||
'$start_lf'(_, Mod, PlStream, TOpts, _UserFile, File, Reexport, ImportList) :-
|
'$start_lf'(_, Mod, PlStream, TOpts, _UserFile, File, Reexport, ImportList) :-
|
||||||
% check if there is a qly file
|
% check if there is a qly file
|
||||||
% start_low_level_trace,
|
% start_low_level_trace,
|
||||||
'$absolute_file_name'(File,[access(read),file_type(qly),file_errors(fail),solutions(first),expand(true)],F,qload_file(File)),
|
'$absolute_file_name'(File,[access(read),file_type(qly),file_errors(fail),solutions(first),expand(true)],F,qload_file(File)),
|
||||||
open( F, read, Stream , [type(binary)] ),
|
open( F, read, Stream , [type(binary)] ),
|
||||||
'$q_header'( Stream, Type ),
|
(
|
||||||
( Type == file
|
'$q_header'( Stream, Type ),
|
||||||
->
|
Type == file
|
||||||
H0 is heapused, '$cputime'(T0,_),
|
->
|
||||||
|
!
|
||||||
|
;
|
||||||
|
close(Stream),
|
||||||
|
fail
|
||||||
|
),
|
||||||
|
H0 is heapused, '$cputime'(T0,_),
|
||||||
time_file64(F, T0F),
|
time_file64(F, T0F),
|
||||||
stream_property(PlStream, file_name(FilePl)),
|
stream_property(PlStream, file_name(FilePl)),
|
||||||
time_file64(FilePl, T0Fl),
|
time_file64(FilePl, T0Fl),
|
||||||
@ -488,11 +494,7 @@ load_files(Files,Opts) :-
|
|||||||
'$reexport'( TOpts, ParentF, Reexport, ImportList, File ),
|
'$reexport'( TOpts, ParentF, Reexport, ImportList, File ),
|
||||||
'$early_print'(Verbosity, loaded( loaded, F, M, T, H)),
|
'$early_print'(Verbosity, loaded( loaded, F, M, T, H)),
|
||||||
% stop_low_level_trace,
|
% stop_low_level_trace,
|
||||||
'$exec_initialisation_goals'
|
'$exec_initialization_goals'.
|
||||||
;
|
|
||||||
close( Stream),
|
|
||||||
fail
|
|
||||||
).
|
|
||||||
'$start_lf'(_, Mod, Stream, TOpts, UserFile, File, _Reexport, _Imports) :-
|
'$start_lf'(_, Mod, Stream, TOpts, UserFile, File, _Reexport, _Imports) :-
|
||||||
'$do_lf'(Mod, Stream, UserFile, File, TOpts).
|
'$do_lf'(Mod, Stream, UserFile, File, TOpts).
|
||||||
|
|
||||||
@ -674,7 +676,6 @@ db_files(Fs) :-
|
|||||||
current_prolog_flag(generate_debug_info, GenerateDebug),
|
current_prolog_flag(generate_debug_info, GenerateDebug),
|
||||||
'$lf_opt'(compilation_mode, TOpts, CompMode),
|
'$lf_opt'(compilation_mode, TOpts, CompMode),
|
||||||
'$comp_mode'(OldCompMode, CompMode),
|
'$comp_mode'(OldCompMode, CompMode),
|
||||||
recorda('$initialisation','$',_),
|
|
||||||
( Reconsult \== consult ->
|
( Reconsult \== consult ->
|
||||||
'$start_reconsulting'(File),
|
'$start_reconsulting'(File),
|
||||||
'$start_consult'(Reconsult,File,LC),
|
'$start_consult'(Reconsult,File,LC),
|
||||||
@ -722,7 +723,7 @@ db_files(Fs) :-
|
|||||||
'$reexport'( TOpts, ParentF, Reexport, Imports, File ),
|
'$reexport'( TOpts, ParentF, Reexport, Imports, File ),
|
||||||
nb_setval('$qcompile', ContextQCompiling),
|
nb_setval('$qcompile', ContextQCompiling),
|
||||||
( LC == 0 -> prompt(_,' |: ') ; true),
|
( LC == 0 -> prompt(_,' |: ') ; true),
|
||||||
'$exec_initialisation_goals',
|
'$exec_initialization_goals',
|
||||||
% format( 'O=~w~n', [Mod=UserFile] ),
|
% format( 'O=~w~n', [Mod=UserFile] ),
|
||||||
!.
|
!.
|
||||||
|
|
||||||
@ -785,30 +786,38 @@ nb_setval('$if_le1vel',0).
|
|||||||
recorda('$reconsulted','$',_),
|
recorda('$reconsulted','$',_),
|
||||||
recorda('$reconsulting',F,_).
|
recorda('$reconsulting',F,_).
|
||||||
|
|
||||||
'$exec_initialisation_goals' :-
|
'$exec_initialization_goals' :-
|
||||||
recorded('$blocking_code',_,R),
|
recorded('$blocking_code',_,R),
|
||||||
erase(R),
|
erase(R),
|
||||||
fail.
|
fail.
|
||||||
% system goals must be performed first
|
% system goals must be performed first
|
||||||
'$exec_initialisation_goals' :-
|
'$exec_initialization_goals' :-
|
||||||
recorded('$system_initialisation',G,R),
|
recorded('$system_initialization',G,R),
|
||||||
erase(R),
|
erase(R),
|
||||||
G \= '$',
|
G \= '$',
|
||||||
'$system_catch'(ignore(M:G), M, Error, user:'$LoopError'(Error, top)),
|
( catch(user:G, Error, user:'$LoopError'(Error, top))
|
||||||
|
->
|
||||||
|
true
|
||||||
|
;
|
||||||
|
format(user_error,':- ~w failed.~n',[G])
|
||||||
|
),
|
||||||
fail.
|
fail.
|
||||||
'$exec_initialisation_goals' :-
|
'$exec_initialization_goals' :-
|
||||||
b_getval('$lf_status', TOpts),
|
|
||||||
writeln(ok),
|
|
||||||
'$lf_opt'( initialization, TOpts, Ref),
|
|
||||||
writeln(Ref),
|
|
||||||
nb:nb_queue_close(Ref, Answers, []),
|
|
||||||
writeln( Answers ),
|
|
||||||
'$current_module'(M),
|
'$current_module'(M),
|
||||||
lists:member(G, Answers),
|
b_getval('$lf_status', TOpts),
|
||||||
writeln(G),
|
'$lf_opt'( initialization, TOpts, Ref),
|
||||||
'$system_catch'(ignore(M:G), M, Error, user:'$LoopError'(Error, top)),
|
nb:nb_queue_close(Ref, Answers, []),
|
||||||
fail.
|
lists:member(G, Answers),
|
||||||
'$exec_initialisation_goals'.
|
% start_low_level_trace,
|
||||||
|
(
|
||||||
|
catch(M:G, Error, user:'$LoopError'(Error, top))
|
||||||
|
->
|
||||||
|
true
|
||||||
|
; format(user_error,':- ~w:~w failed.~n',[M,G])
|
||||||
|
),
|
||||||
|
% stop_low_level_trace,
|
||||||
|
fail.
|
||||||
|
'$exec_initialization_goals'.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@pred include(+ _F_) is directive
|
@pred include(+ _F_) is directive
|
||||||
@ -865,14 +874,7 @@ nb_setval('$if_le1vel',0).
|
|||||||
'$init_win_graphics',
|
'$init_win_graphics',
|
||||||
fail.
|
fail.
|
||||||
'$do_startup_reconsult'(X) :-
|
'$do_startup_reconsult'(X) :-
|
||||||
( current_prolog_flag(halt_after_consult, false) ->
|
catch(load_files(user:X, [silent(true)]), Error, '$Error'(Error)),
|
||||||
'$system_catch'(load_files(X, [silent(true)]), Module, Error, '$Error'(Error))
|
|
||||||
;
|
|
||||||
set_prolog_flag(verbose, silent),
|
|
||||||
'$system_catch'(load_files(X, [silent(true),skip_unix_header(true)]),Module,_,fail)
|
|
||||||
;
|
|
||||||
true
|
|
||||||
),
|
|
||||||
!,
|
!,
|
||||||
( current_prolog_flag(halt_after_consult, false) -> true ; halt).
|
( current_prolog_flag(halt_after_consult, false) -> true ; halt).
|
||||||
'$do_startup_reconsult'(_).
|
'$do_startup_reconsult'(_).
|
||||||
@ -1376,9 +1378,9 @@ environment. Use initialization/2 for more flexible behavior.
|
|||||||
'$initialization'(C) :- db_reference(C), !,
|
'$initialization'(C) :- db_reference(C), !,
|
||||||
'$do_error'(type_error(callable,C),initialization(C)).
|
'$do_error'(type_error(callable,C),initialization(C)).
|
||||||
'$initialization'(G) :-
|
'$initialization'(G) :-
|
||||||
b_getval('$lf_status', TOpts),
|
b_getval('$lf_status', TOpts),
|
||||||
'$lf_opt'( initialization, TOpts, Ref),
|
'$lf_opt'( initialization, TOpts, Ref),
|
||||||
nb:nb_queue_enqueue(Ref, G),
|
nb:nb_queue_enqueue(Ref, G),
|
||||||
fail.
|
fail.
|
||||||
'$initialization'(_).
|
'$initialization'(_).
|
||||||
|
|
||||||
@ -1441,8 +1443,10 @@ initialization(_G,_OPT).
|
|||||||
'$do_error'(type_error(atom,OPT),initialization(OPT))
|
'$do_error'(type_error(atom,OPT),initialization(OPT))
|
||||||
).
|
).
|
||||||
'$initialization'(G,now) :-
|
'$initialization'(G,now) :-
|
||||||
( call(G) -> true ;
|
'$current_module'(M),
|
||||||
format(user_error,':- ~w failed.~n',[G]) ).
|
( catch(M:G, Error, user:'$LoopError'(Error, top)) -> true
|
||||||
|
; format(user_error,':- ~w:~w failed.~n',[M,G])
|
||||||
|
).
|
||||||
'$initialization'(G,after_load) :-
|
'$initialization'(G,after_load) :-
|
||||||
'$initialization'(G).
|
'$initialization'(G).
|
||||||
% ignore for now.
|
% ignore for now.
|
||||||
|
14
pl/qly.yap
14
pl/qly.yap
@ -236,6 +236,9 @@ qend_program :-
|
|||||||
X \= language,
|
X \= language,
|
||||||
X \= encoding.
|
X \= encoding.
|
||||||
|
|
||||||
|
'$init_state' :-
|
||||||
|
once('$handle_throw'(_,_,_)),
|
||||||
|
fail.
|
||||||
'$init_state' :-
|
'$init_state' :-
|
||||||
recorded('$program_state', _P, _), !,
|
recorded('$program_state', _P, _), !,
|
||||||
'$do_init_state'.
|
'$do_init_state'.
|
||||||
@ -249,7 +252,7 @@ qend_program :-
|
|||||||
recorded('$program_state',L,R),
|
recorded('$program_state',L,R),
|
||||||
erase(R),
|
erase(R),
|
||||||
lists:member(F-V,L),
|
lists:member(F-V,L),
|
||||||
catch(yap_flag(F,V),_,fail),
|
catch(yap_flag(F,V),Error,user:'$Error'(Error)),
|
||||||
fail.
|
fail.
|
||||||
'$do_init_state' :-
|
'$do_init_state' :-
|
||||||
'$reinit_thread0',
|
'$reinit_thread0',
|
||||||
@ -313,7 +316,7 @@ qend_program :-
|
|||||||
recorded('$restore_goal',G,R),
|
recorded('$restore_goal',G,R),
|
||||||
erase(R),
|
erase(R),
|
||||||
prompt(_,'| '),
|
prompt(_,'| '),
|
||||||
'$system_catch'('$do_yes_no'((G->true),user),user,Error,user:'$Error'(Error)),
|
catch(once(user:G),Error,user:'$Error'(Error)),
|
||||||
fail.
|
fail.
|
||||||
'$init_from_saved_state_and_args'.
|
'$init_from_saved_state_and_args'.
|
||||||
|
|
||||||
@ -330,8 +333,7 @@ qend_program :-
|
|||||||
fail.
|
fail.
|
||||||
'$startup_goals' :-
|
'$startup_goals' :-
|
||||||
recorded('$startup_goal',G,_),
|
recorded('$startup_goal',G,_),
|
||||||
'$current_module'(Module),
|
catch(once(user:G),Error,user:'$Error'(Error)),
|
||||||
'$system_catch'('$query'(once(G), []),Module,Error,user:'$Error'(Error)),
|
|
||||||
fail.
|
fail.
|
||||||
'$startup_goals' :-
|
'$startup_goals' :-
|
||||||
get_value('$init_goal',GA),
|
get_value('$init_goal',GA),
|
||||||
@ -342,7 +344,7 @@ qend_program :-
|
|||||||
'$startup_goals' :-
|
'$startup_goals' :-
|
||||||
recorded('$restore_flag', goal(Module:GA), R),
|
recorded('$restore_flag', goal(Module:GA), R),
|
||||||
erase(R),
|
erase(R),
|
||||||
'$system_catch'('$query'(once(GA), []),Module,Error,user:'$Error'(Error)),
|
catch(once(Module:GA),Error,user:'$Error'(Error)),
|
||||||
fail.
|
fail.
|
||||||
'$startup_goals' :-
|
'$startup_goals' :-
|
||||||
get_value('$myddas_goal',GA), GA \= [],
|
get_value('$myddas_goal',GA), GA \= [],
|
||||||
@ -736,7 +738,7 @@ qload_file( F0 ) :-
|
|||||||
H is heapused-H0, '$cputime'(TF,_), T is TF-T0,
|
H is heapused-H0, '$cputime'(TF,_), T is TF-T0,
|
||||||
'$current_module'(Mod, Mod ),
|
'$current_module'(Mod, Mod ),
|
||||||
print_message(Verbosity, loaded(EndMsg, File, Mod, T, H)),
|
print_message(Verbosity, loaded(EndMsg, File, Mod, T, H)),
|
||||||
'$exec_initialisation_goals'.
|
'$exec_initialization_goals'.
|
||||||
|
|
||||||
'$qload_file'(_S, SourceModule, _F, FilePl, _F0, _ImportList, _TOpts) :-
|
'$qload_file'(_S, SourceModule, _F, FilePl, _F0, _ImportList, _TOpts) :-
|
||||||
recorded('$source_file','$source_file'( FilePl, _Age, SourceModule), _),
|
recorded('$source_file','$source_file'( FilePl, _Age, SourceModule), _),
|
||||||
|
Reference in New Issue
Block a user