2001-04-09 20:54:03 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* *
|
|
|
|
* YAP Prolog *
|
|
|
|
* *
|
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
|
|
|
* File: consult.yap *
|
|
|
|
* Last rev: 8/2/88 *
|
|
|
|
* mods: *
|
|
|
|
* comments: Consulting Files in YAP *
|
|
|
|
* *
|
|
|
|
*************************************************************************/
|
2014-04-09 12:39:29 +01:00
|
|
|
:- system_module( '$_consult', [compile/1,
|
|
|
|
consult/1,
|
|
|
|
db_files/1,
|
|
|
|
ensure_loaded/1,
|
|
|
|
exists_source/1,
|
|
|
|
exo_files/1,
|
|
|
|
(initialization)/2,
|
|
|
|
load_files/2,
|
|
|
|
make/0,
|
|
|
|
make_library_index/1,
|
|
|
|
module/2,
|
|
|
|
prolog_load_context/2,
|
|
|
|
reconsult/1,
|
|
|
|
source_file/1,
|
|
|
|
source_file/2,
|
|
|
|
source_file_property/2,
|
|
|
|
use_module/3], ['$add_multifile'/3,
|
|
|
|
'$csult'/2,
|
|
|
|
'$do_startup_reconsult'/1,
|
|
|
|
'$elif'/2,
|
|
|
|
'$else'/1,
|
|
|
|
'$endif'/1,
|
|
|
|
'$if'/2,
|
|
|
|
'$include'/2,
|
|
|
|
'$initialization'/1,
|
|
|
|
'$initialization'/2,
|
|
|
|
'$lf_opt'/3,
|
|
|
|
'$load_files'/3,
|
|
|
|
'$require'/2,
|
|
|
|
'$set_encoding'/1,
|
|
|
|
'$use_module'/3]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_absf', ['$full_filename'/3]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_boot', ['$clear_reconsulting'/0,
|
|
|
|
'$init_system'/0,
|
|
|
|
'$init_win_graphics'/0,
|
|
|
|
'$loop'/2,
|
|
|
|
'$system_catch'/4]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_checker', ['$init_style_check'/1]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_errors', ['$do_error'/2]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_load_foreign', ['$import_foreign'/3]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_modules', ['$add_to_imports'/3,
|
|
|
|
'$convert_for_export'/7,
|
|
|
|
'$extend_exports'/3]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_preds', ['$current_predicate_no_modules'/3]).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2005-10-18 18:04:43 +01:00
|
|
|
%
|
|
|
|
% SWI options
|
|
|
|
% autoload(true,false)
|
|
|
|
% derived_from(File) -> make
|
2007-11-06 17:02:13 +00:00
|
|
|
% encoding(Encoding) => implemented
|
2013-11-04 01:14:48 +00:00
|
|
|
% expand(true,false)
|
2007-11-06 17:02:13 +00:00
|
|
|
% if(changed,true,not_loaded) => implemented
|
|
|
|
% imports(all,List) => implemented
|
2005-10-18 18:04:43 +01:00
|
|
|
% qcompile(true,false)
|
|
|
|
% silent(true,false) => implemented
|
|
|
|
% stream(Stream) => implemented
|
2013-01-15 11:18:09 +00:00
|
|
|
% consult(consult,reconsult,exo,db) => implemented
|
2008-07-11 18:02:10 +01:00
|
|
|
% compilation_mode(compact,source,assert_all) => implemented
|
2013-11-04 01:14:48 +00:00
|
|
|
% register(true, false) => implemented
|
2005-10-18 18:04:43 +01:00
|
|
|
%
|
|
|
|
load_files(Files,Opts) :-
|
|
|
|
'$load_files'(Files,Opts,load_files(Files,Opts)).
|
|
|
|
|
2013-11-10 11:18:00 +00:00
|
|
|
'$lf_option'(autoload, 1, _).
|
2013-11-08 00:02:38 +00:00
|
|
|
'$lf_option'(derived_from, 2, false).
|
|
|
|
'$lf_option'(encoding, 3, default).
|
|
|
|
'$lf_option'(expand, 4, false).
|
|
|
|
'$lf_option'(if, 5, true).
|
|
|
|
'$lf_option'(imports, 6, all).
|
|
|
|
'$lf_option'(qcompile, 7, never).
|
|
|
|
'$lf_option'(silent, 8, _).
|
|
|
|
'$lf_option'(skip_unix_header, 9, false).
|
|
|
|
'$lf_option'(compilation_mode, 10, source).
|
|
|
|
'$lf_option'(consult, 11, reconsult).
|
|
|
|
'$lf_option'(stream, 12, _).
|
|
|
|
'$lf_option'(register, 13, true).
|
|
|
|
'$lf_option'('$files', 14, _).
|
|
|
|
'$lf_option'('$call', 15, _).
|
|
|
|
'$lf_option'('$use_module', 16, _).
|
|
|
|
'$lf_option'('$consulted_at', 17, _).
|
|
|
|
'$lf_option'('$options', 18, _).
|
|
|
|
'$lf_option'('$location', 19, _).
|
|
|
|
'$lf_option'(dialect, 20, yap).
|
|
|
|
'$lf_option'(format, 21, source).
|
2014-05-25 20:52:45 +01:00
|
|
|
'$lf_option'(redefine_module, 22, false).
|
2013-11-08 00:02:38 +00:00
|
|
|
'$lf_option'(reexport, 23, false).
|
|
|
|
'$lf_option'(sandboxed, 24, false).
|
|
|
|
'$lf_option'(scope_settings, 25, false).
|
|
|
|
'$lf_option'(modified, 26, _).
|
|
|
|
'$lf_option'('$context_module', 27, _).
|
|
|
|
'$lf_option'('$parent_topts', 28, _).
|
|
|
|
'$lf_option'(must_be_module, 29, false).
|
|
|
|
|
|
|
|
'$lf_option'(last_opt, 29).
|
2013-11-04 01:14:48 +00:00
|
|
|
|
|
|
|
'$lf_opt'( Op, TOpts, Val) :-
|
2013-11-08 00:02:38 +00:00
|
|
|
'$lf_option'(Op, Id, _),
|
2013-11-04 01:14:48 +00:00
|
|
|
arg( Id, TOpts, Val ).
|
|
|
|
|
|
|
|
'$load_files'(Files, Opts, Call) :-
|
2013-11-10 11:18:00 +00:00
|
|
|
( '$nb_getval'('$lf_status', OldTOpts, fail), nonvar(OldTOpts) ->
|
|
|
|
'$lf_opt'(silent, OldTOpts, OldVerbosity),
|
|
|
|
'$lf_opt'(autoload, OldTOpts, OldAutoload)
|
|
|
|
;
|
|
|
|
true ),
|
2010-03-02 23:13:39 +00:00
|
|
|
'$check_files'(Files,load_files(Files,Opts)),
|
2013-11-08 00:02:38 +00:00
|
|
|
'$lf_option'(last_opt, LastOpt),
|
2013-11-04 01:14:48 +00:00
|
|
|
functor( TOpts, opt, LastOpt ),
|
|
|
|
( source_location(ParentF, Line) -> true ; ParentF = user_input, Line = -1 ),
|
|
|
|
'$lf_opt'('$location', TOpts, ParentF:Line),
|
|
|
|
'$lf_opt'('$files', TOpts, Files),
|
|
|
|
'$lf_opt'('$call', TOpts, Call),
|
|
|
|
'$lf_opt'('$options', TOpts, Opts),
|
2013-11-08 00:02:38 +00:00
|
|
|
'$lf_opt'('$parent_topts', TOpts, OldTOpts),
|
2013-11-04 01:14:48 +00:00
|
|
|
'$process_lf_opts'(Opts,TOpts,Files,Call),
|
2013-11-08 00:02:38 +00:00
|
|
|
'$lf_default_opts'(1, LastOpt, TOpts),
|
2005-10-28 18:38:50 +01:00
|
|
|
'$check_use_module'(Call,UseModule),
|
2013-11-04 01:14:48 +00:00
|
|
|
'$lf_opt'('$use_module', TOpts, UseModule),
|
2001-11-15 00:01:43 +00:00
|
|
|
'$current_module'(M0),
|
2013-11-10 11:18:00 +00:00
|
|
|
( '$lf_opt'(silent, TOpts, Verbosity),
|
|
|
|
var(Verbosity) ->
|
|
|
|
Verbosity = OldVerbosity
|
|
|
|
;
|
|
|
|
true
|
|
|
|
),
|
|
|
|
( '$lf_opt'(autoload, TOpts, Autoload),
|
|
|
|
var(Autoload) ->
|
|
|
|
Autoload = OldAutoload
|
|
|
|
;
|
|
|
|
true
|
|
|
|
),
|
2013-09-09 22:11:12 +01:00
|
|
|
% make sure we can run consult
|
|
|
|
'$init_system',
|
2013-11-04 01:14:48 +00:00
|
|
|
'$lf'(Files, M0, Call, TOpts).
|
2005-10-18 18:04:43 +01:00
|
|
|
|
2013-11-04 01:14:48 +00:00
|
|
|
'$check_files'(Files, Call) :-
|
2010-03-02 23:13:39 +00:00
|
|
|
var(Files), !,
|
2013-11-04 01:14:48 +00:00
|
|
|
'$do_error'(instantiation_error, Call).
|
|
|
|
'$check_files'(M:Files, Call) :- !,
|
2010-03-02 23:13:39 +00:00
|
|
|
(var(M)
|
|
|
|
->
|
2013-11-04 01:14:48 +00:00
|
|
|
'$do_error'(instantiation_error, Call)
|
2010-03-02 23:13:39 +00:00
|
|
|
;
|
|
|
|
atom(M)
|
|
|
|
->
|
|
|
|
'$check_files'(Files,Call)
|
|
|
|
;
|
2013-11-04 01:14:48 +00:00
|
|
|
'$do_error'(type_error(atom,M), Call)
|
2010-03-02 23:13:39 +00:00
|
|
|
).
|
2013-11-04 01:14:48 +00:00
|
|
|
'$check_files'(Files, Call) :-
|
|
|
|
( ground(Files)
|
2010-03-02 23:13:39 +00:00
|
|
|
->
|
|
|
|
true
|
|
|
|
;
|
2013-11-04 01:14:48 +00:00
|
|
|
'$do_error'(instantiation_error, Call)
|
2010-03-02 23:13:39 +00:00
|
|
|
).
|
|
|
|
|
2013-11-04 01:14:48 +00:00
|
|
|
'$process_lf_opts'(V, _, _, Call) :-
|
2005-10-18 18:04:43 +01:00
|
|
|
var(V), !,
|
|
|
|
'$do_error'(instantiation_error,Call).
|
2013-11-04 01:14:48 +00:00
|
|
|
'$process_lf_opts'([], _, _, _).
|
|
|
|
'$process_lf_opts'([Opt|Opts],TOpt,Files,Call) :-
|
|
|
|
Opt =.. [Op, Val],
|
|
|
|
ground(Val),
|
|
|
|
'$lf_opt'(Op, TOpt, Val),
|
|
|
|
'$process_lf_opt'(Op, Val,Call), !,
|
|
|
|
'$process_lf_opts'(Opts, TOpt, Files, Call).
|
|
|
|
'$process_lf_opts'([Opt|_],_,_,Call) :-
|
2005-10-18 18:04:43 +01:00
|
|
|
'$do_error'(domain_error(unimplemented_option,Opt),Call).
|
|
|
|
|
2013-11-04 01:14:48 +00:00
|
|
|
'$process_lf_opt'(autoload, Val, Call) :-
|
|
|
|
( Val == false -> true ;
|
|
|
|
Val == true -> true ;
|
|
|
|
'$do_error'(domain_error(unimplemented_option,autoload(Val)),Call) ).
|
|
|
|
'$process_lf_opt'(derived_from, File, Call) :-
|
|
|
|
( atom(File) -> true ; '$do_error'(type_error(atom,File),Call) ).
|
2013-11-08 00:02:38 +00:00
|
|
|
'$process_lf_opt'(encoding, Encoding, _Call) :-
|
2011-09-02 21:03:41 +01:00
|
|
|
atom(Encoding).
|
2013-11-04 01:14:48 +00:00
|
|
|
'$process_lf_opt'(expand, Val, Call) :-
|
|
|
|
( Val == true -> '$do_error'(domain_error(unimplemented_option,expand),Call) ;
|
|
|
|
Val == false -> true ;
|
|
|
|
'$do_error'(domain_error(unimplemented_option,expand(Val)),Call) ).
|
|
|
|
'$process_lf_opt'(if, If, Call) :-
|
|
|
|
( If == changed -> true ;
|
|
|
|
If == true -> true ;
|
|
|
|
If == not_loaded -> true ;
|
|
|
|
'$do_error'(domain_error(unimplemented_option,if),Call) ).
|
2013-11-08 00:02:38 +00:00
|
|
|
'$process_lf_opt'(imports, Val, Call) :-
|
2013-11-04 01:14:48 +00:00
|
|
|
( Val == all -> true ;
|
2013-11-08 00:02:38 +00:00
|
|
|
var(Val) -> Val = all ;
|
|
|
|
is_list(Val) -> ( ground(Val) -> true ; '$do_error'(instantiation_error,Call) ) ;
|
2013-11-04 01:14:48 +00:00
|
|
|
'$do_error'(domain_error(unimplemented_option,imports(Val)),Call) ).
|
|
|
|
'$process_lf_opt'(qcompile, Val,Call) :-
|
|
|
|
( Val == true -> '$do_error'(domain_error(unimplemented_option,expand),Call) ;
|
|
|
|
Val == false -> true ;
|
|
|
|
'$do_error'(domain_error(unimplemented_option,expand(Val)),Call) ).
|
|
|
|
'$process_lf_opt'(silent, Val, Call) :-
|
|
|
|
( Val == false -> true ;
|
|
|
|
Val == true -> true ;
|
|
|
|
'$do_error'(domain_error(unimplemented_option,silent(Val)),Call) ).
|
|
|
|
'$process_lf_opt'(skip_unix_header, Val, Call) :-
|
|
|
|
( Val == false -> true ;
|
|
|
|
Val == true -> true ;
|
|
|
|
'$do_error'(domain_error(unimplemented_option,skip_unix_header(Val)),Call) ).
|
|
|
|
'$process_lf_opt'(compilation_mode, Val, Call) :-
|
2013-11-08 00:02:38 +00:00
|
|
|
( Val == source -> true ;
|
2013-11-04 01:14:48 +00:00
|
|
|
Val == compact -> true ;
|
|
|
|
Val == assert_all -> true ;
|
|
|
|
'$do_error'(domain_error(unimplemented_option,compilation_mode(Val)),Call) ).
|
|
|
|
'$process_lf_opt'(consult, Val , Call) :-
|
|
|
|
( Val == reconsult -> true ;
|
|
|
|
Val == consult -> true ;
|
|
|
|
Val == exo -> true ;
|
|
|
|
Val == db -> true ;
|
2013-11-08 00:02:38 +00:00
|
|
|
'$do_error'(domain_error(unimplemented_option,consult(Val)),Call) ).
|
|
|
|
'$process_lf_opt'(reexport, Val , Call) :-
|
|
|
|
( Val == true -> true ;
|
|
|
|
Val == false -> true ;
|
|
|
|
'$do_error'(domain_error(unimplemented_option,reexport(Val)),Call) ).
|
|
|
|
'$process_lf_opt'(must_be_module, Val , Call) :-
|
|
|
|
( Val == true -> true ;
|
|
|
|
Val == false -> true ;
|
|
|
|
'$do_error'(domain_error(unimplemented_option,must_be_module(Val)),Call) ).
|
2013-11-04 01:14:48 +00:00
|
|
|
'$process_lf_opt'(stream, Val, Call) :-
|
2014-04-06 17:05:17 +01:00
|
|
|
( current_stream(_,_,Val) -> true ;
|
2013-11-08 00:02:38 +00:00
|
|
|
'$do_error'(type_error(stream,Val),Call) ).
|
2013-11-04 01:14:48 +00:00
|
|
|
'$process_lf_opt'(register, Val, Call) :-
|
|
|
|
( Val == false -> true ;
|
|
|
|
Val == true -> true ;
|
|
|
|
'$do_error'(domain_error(unimplemented_option,register(Val)),Call) ).
|
2014-05-06 09:34:25 +01:00
|
|
|
'$process_lf_opt'('$context_module', Val, Call) :-
|
|
|
|
( atom(File) -> true ; '$do_error'(type_error(atom,File),Call) ).
|
|
|
|
|
2013-11-04 01:14:48 +00:00
|
|
|
|
2013-11-08 00:02:38 +00:00
|
|
|
'$lf_default_opts'(I, LastOpt, _TOpts) :- I > LastOpt, !.
|
|
|
|
'$lf_default_opts'(I, LastOpt, TOpts) :-
|
|
|
|
I1 is I+1,
|
|
|
|
arg(I, TOpts, A),
|
|
|
|
( nonvar(A) -> true ;
|
|
|
|
'$lf_option'(_Name, I, A)
|
|
|
|
),
|
|
|
|
'$lf_default_opts'(I1, LastOpt, TOpts).
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-11-04 01:14:48 +00:00
|
|
|
'$check_use_module'(use_module(_), use_module(_)) :- !.
|
|
|
|
'$check_use_module'(use_module(_,_), use_module(_)) :- !.
|
|
|
|
'$check_use_module'(use_module(M,_,_), use_module(M)) :- !.
|
|
|
|
'$check_use_module'(_, load_files) :- !.
|
|
|
|
|
|
|
|
'$lf'(V,_,Call, _ ) :- var(V), !,
|
2005-10-18 18:04:43 +01:00
|
|
|
'$do_error'(instantiation_error,Call).
|
2013-11-04 01:14:48 +00:00
|
|
|
'$lf'([], _, _, _) :- !.
|
|
|
|
'$lf'(M:X, _, Call, TOpts) :- !,
|
2005-10-18 18:04:43 +01:00
|
|
|
(
|
|
|
|
atom(M)
|
|
|
|
->
|
2013-11-04 01:14:48 +00:00
|
|
|
'$lf'(X, M, Call, TOpts)
|
2005-10-18 18:04:43 +01:00
|
|
|
;
|
|
|
|
'$do_error'(type_error(atom,M),Call)
|
|
|
|
).
|
2013-11-04 01:14:48 +00:00
|
|
|
'$lf'([F|Fs], Mod, Call, TOpts) :- !,
|
|
|
|
% clean up after each consult
|
|
|
|
( '$lf'(F,Mod,Call, TOpts), fail ;
|
|
|
|
'$lf'(Fs, Mod, Call, TOpts) ).
|
|
|
|
'$lf'(user, Mod, _, TOpts) :- !,
|
|
|
|
'$do_lf'(Mod, user_input, user_input, TOpts).
|
|
|
|
'$lf'(user_input, Mod, _, TOpts) :- !,
|
|
|
|
'$do_lf'(Mod, user_input, user_input, TOpts).
|
|
|
|
'$lf'(File, Mod, Call, TOpts) :-
|
|
|
|
'$lf_opt'(stream, TOpts, Stream),
|
|
|
|
( var(Stream) ->
|
|
|
|
/* need_to_open_file */
|
|
|
|
'$full_filename'(File, Y, Call),
|
2013-11-08 00:02:38 +00:00
|
|
|
open(Y, read, Stream)
|
2011-02-15 07:39:27 +00:00
|
|
|
;
|
2013-11-04 01:14:48 +00:00
|
|
|
true
|
|
|
|
), !,
|
2014-02-09 18:06:37 +00:00
|
|
|
'$lf_opt'(reexport, TOpts, Reexport),
|
2013-11-04 01:14:48 +00:00
|
|
|
'$lf_opt'(if, TOpts, If),
|
2013-11-08 00:02:38 +00:00
|
|
|
( var(If) -> If = true ; true ),
|
2013-11-04 01:14:48 +00:00
|
|
|
'$lf_opt'(imports, TOpts, Imports),
|
|
|
|
'$start_lf'(If, Mod, Stream, TOpts, File, Imports),
|
2011-02-14 22:55:59 +00:00
|
|
|
close(Stream).
|
2013-11-04 01:14:48 +00:00
|
|
|
'$lf'(X, _, Call, _) :-
|
2005-10-18 18:04:43 +01:00
|
|
|
'$do_error'(permission_error(input,stream,X),Call).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2013-11-04 01:14:48 +00:00
|
|
|
'$start_lf'(not_loaded, Mod, Stream, TOpts, UserFile, Imports) :-
|
2013-11-08 00:02:38 +00:00
|
|
|
'$file_loaded'(Stream, Mod, Imports, TOpts), !,
|
2013-11-04 01:14:48 +00:00
|
|
|
'$lf_opt'('$options', TOpts, Opts),
|
|
|
|
'$lf_opt'('$location', TOpts, ParentF:Line),
|
2014-01-06 18:28:22 +00:00
|
|
|
'$loaded'(Stream, UserFile, Mod, ParentF, Line, not_loaded, _File, _Dir, Opts),
|
2014-02-09 18:06:37 +00:00
|
|
|
'$reexport'( TOpts, ParentF, Imports, _File ).
|
2013-11-04 01:14:48 +00:00
|
|
|
'$start_lf'(changed, Mod, Stream, TOpts, UserFile, Imports) :-
|
2013-11-08 00:02:38 +00:00
|
|
|
'$file_unchanged'(Stream, Mod, Imports, TOpts), !,
|
2013-11-04 01:14:48 +00:00
|
|
|
'$lf_opt'('$options', TOpts, Opts),
|
|
|
|
'$lf_opt'('$location', TOpts, ParentF:Line),
|
2014-01-06 18:28:22 +00:00
|
|
|
'$loaded'(Stream, UserFile, Mod, ParentF, Line, changed, _File, _Dir, Opts),
|
2014-02-09 18:06:37 +00:00
|
|
|
'$reexport'( TOpts, ParentF, Imports, _File ).
|
2013-11-04 01:14:48 +00:00
|
|
|
'$start_lf'(_, Mod, Stream, TOpts, File, _) :-
|
|
|
|
'$do_lf'(Mod, Stream, File, TOpts).
|
2005-10-28 18:38:50 +01:00
|
|
|
|
2005-10-20 00:16:49 +01:00
|
|
|
ensure_loaded(Fs) :-
|
2013-11-08 00:02:38 +00:00
|
|
|
'$load_files'(Fs, [if(not_loaded)],ensure_loaded(Fs)).
|
2005-10-18 18:04:43 +01:00
|
|
|
|
|
|
|
compile(Fs) :-
|
|
|
|
'$load_files'(Fs, [], compile(Fs)).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2010-07-31 00:32:54 +01:00
|
|
|
% consult(Fs) :-
|
|
|
|
% '$has_yap_or',
|
|
|
|
% '$do_error'(context_error(consult(Fs),clause),query).
|
2004-02-12 18:23:29 +00:00
|
|
|
consult(V) :-
|
|
|
|
var(V), !,
|
|
|
|
'$do_error'(instantiation_error,consult(V)).
|
|
|
|
consult(M0:Fs) :- !,
|
|
|
|
'$consult'(Fs, M0).
|
2001-04-09 20:54:03 +01:00
|
|
|
consult(Fs) :-
|
2004-02-12 18:23:29 +00:00
|
|
|
'$current_module'(M0),
|
|
|
|
'$consult'(Fs, M0).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2005-10-18 18:04:43 +01:00
|
|
|
'$consult'(Fs,Module) :-
|
|
|
|
'$access_yap_flags'(8, 2), % SICStus Prolog compatibility
|
|
|
|
!,
|
2010-03-03 19:08:59 +00:00
|
|
|
'$load_files'(Module:Fs,[],consult(Fs)).
|
2007-01-24 14:20:04 +00:00
|
|
|
'$consult'(Fs, Module) :-
|
2010-03-03 19:08:59 +00:00
|
|
|
'$load_files'(Module:Fs,[consult(consult)],consult(Fs)).
|
2005-10-18 18:04:43 +01:00
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
reconsult(Fs) :-
|
2005-10-18 18:04:43 +01:00
|
|
|
'$load_files'(Fs, [], reconsult(Fs)).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2013-01-15 11:18:09 +00:00
|
|
|
exo_files(Fs) :-
|
|
|
|
'$load_files'(Fs, [consult(exo), if(not_loaded)], exo_files(Fs)).
|
|
|
|
|
|
|
|
db_files(Fs) :-
|
|
|
|
'$load_files'(Fs, [consult(db), if(not_loaded)], exo_files(Fs)).
|
|
|
|
|
2014-04-06 17:05:17 +01:00
|
|
|
%
|
|
|
|
% stub to prevent modules defined within the prolog module.
|
|
|
|
%
|
|
|
|
module(Mod, Decls) :-
|
|
|
|
'$current_module'(prolog, Mod), !,
|
|
|
|
'$export_preds'(Decls).
|
|
|
|
|
|
|
|
'$export_preds'([]).
|
|
|
|
'$export_preds'([N/A|Decls]) :-
|
|
|
|
functor(S, N, A),
|
|
|
|
'$sys_export'(S, prolog),
|
|
|
|
'$export_preds'(Decls).
|
2005-10-18 18:04:43 +01:00
|
|
|
|
|
|
|
|
2014-04-06 17:05:17 +01:00
|
|
|
% prevent modules within the kernel module...
|
2005-10-18 18:04:43 +01:00
|
|
|
use_module(M,F,Is) :-
|
2006-11-18 01:40:42 +00:00
|
|
|
'$use_module'(M,F,Is).
|
|
|
|
|
2014-05-06 09:34:25 +01:00
|
|
|
'$use_module'(M,F,Is) :-
|
2014-05-07 15:04:17 +01:00
|
|
|
var(Is), !,
|
|
|
|
'$use_module'(M,F,all).
|
|
|
|
'$use_module'(M,F,Is) :-
|
|
|
|
nonvar(F), !,
|
|
|
|
strip_module(F, M0, F0),
|
|
|
|
'$load_files'(M0:F0, [if(not_loaded),must_be_module(true),imports(Is)], use_module(M,F,Is)),
|
|
|
|
( var(M) -> true
|
|
|
|
;
|
|
|
|
absolute_file_name( F0, F1, [expand(true),file_type(prolog)] ),
|
|
|
|
recorded('$module','$module'(F1,M,_,_),_)
|
|
|
|
).
|
|
|
|
'$use_module'(M,F,Is) :-
|
|
|
|
nonvar(M), !,
|
|
|
|
strip_module(F, M0, F0),
|
2014-05-06 09:34:25 +01:00
|
|
|
(
|
|
|
|
recorded('$module','$module'(F1,M,_,_),_)
|
|
|
|
->
|
2014-05-07 15:04:17 +01:00
|
|
|
'$load_files'(M0:F1, [if(not_loaded),must_be_module(true),imports(Is)], use_module(M,F,Is))
|
2014-05-06 09:34:25 +01:00
|
|
|
),
|
2014-05-07 15:04:17 +01:00
|
|
|
(var(F0) -> F0 = F1 ; absolute_file_name( F1, F2, [expand(true),file_type(prolog)] ) -> F2 = F0 ).
|
2013-11-08 00:02:38 +00:00
|
|
|
'$use_module'(M,F,Is) :-
|
2014-05-07 15:04:17 +01:00
|
|
|
'$do_error'(instantiation_error,use_module(M,F,Is)).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2013-11-04 01:14:48 +00:00
|
|
|
'$csult'(Fs, M) :-
|
|
|
|
'$extract_minus'(Fs, MFs), !,
|
|
|
|
'$load_files'(M:MFs,[],[M:Fs]).
|
|
|
|
'$csult'(Fs, M) :-
|
|
|
|
'$load_files'(M:Fs,[consult(consult)],[M:Fs]).
|
|
|
|
|
|
|
|
'$extract_minus'([], []).
|
|
|
|
'$extract_minus'([-F|Fs], [F|MFs]) :-
|
|
|
|
'$extract_minus'(Fs, MFs).
|
2005-10-19 02:47:43 +01:00
|
|
|
|
2013-11-04 01:14:48 +00:00
|
|
|
|
2013-11-08 00:02:38 +00:00
|
|
|
'$do_lf'(ContextModule, Stream, UserFile, TOpts) :-
|
|
|
|
'$lf_opt'('$context_module', TOpts, ContextModule),
|
2013-11-04 01:14:48 +00:00
|
|
|
'$msg_level'( TOpts, Verbosity),
|
2013-11-10 11:18:00 +00:00
|
|
|
% format( 'I=~w~n', [Verbosity=UserFile] ),
|
2013-11-17 21:41:41 +00:00
|
|
|
'$lf_opt'(encoding, TOpts, Encoding),
|
|
|
|
'$set_encoding'(Stream, Encoding),
|
2013-11-04 01:14:48 +00:00
|
|
|
% export to process
|
|
|
|
b_setval('$lf_status', TOpts),
|
2012-02-27 16:37:31 +00:00
|
|
|
'$reset_if'(OldIfLevel),
|
2013-11-04 01:14:48 +00:00
|
|
|
% take care with [a:f], a is the ContextModule
|
|
|
|
'$current_module'(SourceModule, ContextModule),
|
2014-04-24 11:40:35 +01:00
|
|
|
'$lf_opt'(consult, TOpts, Reconsult0),
|
2013-11-04 01:14:48 +00:00
|
|
|
'$lf_opt'('$options', TOpts, Opts),
|
|
|
|
'$lf_opt'('$location', TOpts, ParentF:Line),
|
|
|
|
'$loaded'(Stream, UserFile, SourceModule, ParentF, Line, Reconsult, File, Dir, Opts),
|
|
|
|
working_directory(OldD, Dir),
|
2002-01-22 17:11:36 +00:00
|
|
|
H0 is heapused, '$cputime'(T0,_),
|
2011-07-11 15:40:58 +01:00
|
|
|
'$set_current_loop_stream'(OldStream, Stream),
|
2013-11-04 01:14:48 +00:00
|
|
|
'$swi_current_prolog_flag'(generate_debug_info, GenerateDebug),
|
|
|
|
'$lf_opt'(compilation_mode, TOpts, CompMode),
|
2007-11-08 11:22:05 +00:00
|
|
|
'$comp_mode'(OldCompMode, CompMode),
|
2010-12-13 19:13:33 +00:00
|
|
|
( get_value('$syntaxcheckflag',on) -> '$init_style_check'(File) ; true ),
|
2003-08-27 14:37:10 +01:00
|
|
|
recorda('$initialisation','$',_),
|
2014-04-24 11:40:35 +01:00
|
|
|
( Reconsult \== consult ->
|
2006-02-17 15:56:36 +00:00
|
|
|
'$start_reconsulting'(File),
|
2005-10-18 18:04:43 +01:00
|
|
|
'$start_consult'(Reconsult,File,LC),
|
|
|
|
'$remove_multifile_clauses'(File),
|
|
|
|
StartMsg = reconsulting,
|
|
|
|
EndMsg = reconsulted
|
|
|
|
;
|
|
|
|
'$start_consult'(Reconsult,File,LC),
|
2014-04-24 11:40:35 +01:00
|
|
|
( File \= user_input, File \= [] -> '$remove_multifile_clauses'(File) ; true ),
|
2005-10-18 18:04:43 +01:00
|
|
|
StartMsg = consulting,
|
|
|
|
EndMsg = consulted
|
|
|
|
),
|
2013-11-04 01:14:48 +00:00
|
|
|
print_message(Verbosity, loading(StartMsg, File)),
|
|
|
|
'$lf_opt'(skip_unix_header , TOpts, SkipUnixHeader),
|
|
|
|
( SkipUnixHeader == true->
|
|
|
|
'$skip_unix_header'(Stream)
|
2006-03-03 23:11:30 +00:00
|
|
|
;
|
|
|
|
true
|
|
|
|
),
|
2005-10-19 02:47:43 +01:00
|
|
|
'$loop'(Stream,Reconsult),
|
2008-02-22 15:08:37 +00:00
|
|
|
H is heapused-H0, '$cputime'(TF,_), T is TF-T0,
|
2013-11-04 01:14:48 +00:00
|
|
|
'$current_module'(Mod, SourceModule),
|
|
|
|
print_message(Verbosity, loaded(EndMsg, File, Mod, T, H)),
|
2002-01-22 17:11:36 +00:00
|
|
|
'$end_consult',
|
2005-10-19 02:47:43 +01:00
|
|
|
(
|
|
|
|
Reconsult = reconsult ->
|
|
|
|
'$clear_reconsulting'
|
|
|
|
;
|
|
|
|
true
|
|
|
|
),
|
2013-11-08 00:02:38 +00:00
|
|
|
'$set_current_loop_stream'(Stream, OldStream),
|
2013-11-04 01:14:48 +00:00
|
|
|
'$swi_set_prolog_flag'(generate_debug_info, GenerateDebug),
|
2013-11-08 08:24:06 +00:00
|
|
|
'$comp_mode'(_CompMode, OldCompMode),
|
2011-05-12 22:26:10 +01:00
|
|
|
working_directory(_,OldD),
|
2007-10-21 09:48:06 +01:00
|
|
|
% surely, we were in run mode or we would not have included the file!
|
|
|
|
nb_setval('$if_skip_mode',run),
|
|
|
|
% back to include mode!
|
2012-02-27 16:37:31 +00:00
|
|
|
nb_setval('$if_level',OldIfLevel),
|
2013-11-04 01:14:48 +00:00
|
|
|
'$lf_opt'('$use_module', TOpts, UseModule),
|
2005-10-28 18:38:50 +01:00
|
|
|
'$bind_module'(Mod, UseModule),
|
2013-11-08 00:02:38 +00:00
|
|
|
'$lf_opt'(imports, TOpts, Imports),
|
2013-11-17 21:41:41 +00:00
|
|
|
'$import_to_current_module'(File, ContextModule, Imports, _, TOpts),
|
2014-02-09 18:06:37 +00:00
|
|
|
'$reexport'( TOpts, ParentF, Imports, File ),
|
2002-11-19 14:43:17 +00:00
|
|
|
( LC == 0 -> prompt(_,' |: ') ; true),
|
2004-02-05 16:57:02 +00:00
|
|
|
'$exec_initialisation_goals',
|
2014-02-09 18:06:37 +00:00
|
|
|
% format( 'O=~w~n', [Mod=UserFile] ),
|
2001-04-09 20:54:03 +01:00
|
|
|
!.
|
|
|
|
|
2013-11-04 01:14:48 +00:00
|
|
|
% are we in autoload and autoload_flag is false?
|
|
|
|
'$msg_level'( TOpts, Verbosity) :-
|
|
|
|
'$lf_opt'(autoload, TOpts, AutoLoad),
|
|
|
|
AutoLoad == true,
|
|
|
|
'$swi_current_prolog_flag'(verbose_autoload, false), !,
|
|
|
|
Verbosity = silent.
|
2013-11-08 00:02:38 +00:00
|
|
|
'$msg_level'( _TOpts, Verbosity) :-
|
|
|
|
'$swi_current_prolog_flag'(verbose_load, false), !,
|
|
|
|
Verbosity = silent.
|
2013-11-04 01:14:48 +00:00
|
|
|
'$msg_level'( _TOpts, Verbosity) :-
|
|
|
|
'$swi_current_prolog_flag'(verbose, silent), !,
|
|
|
|
Verbosity = silent.
|
|
|
|
'$msg_level'( TOpts, Verbosity) :-
|
|
|
|
'$lf_opt'(silent, TOpts, Silent),
|
|
|
|
Silent == true, !,
|
|
|
|
Verbosity = silent.
|
|
|
|
'$msg_level'( _TOpts, informational).
|
|
|
|
|
2012-02-27 16:37:31 +00:00
|
|
|
'$reset_if'(OldIfLevel) :-
|
2012-12-07 08:08:32 +00:00
|
|
|
'$nb_getval'('$if_level', OldIfLevel, fail), !,
|
2012-02-27 16:37:31 +00:00
|
|
|
nb_setval('$if_level',0).
|
|
|
|
'$reset_if'(0) :-
|
|
|
|
nb_setval('$if_level',0).
|
|
|
|
|
2012-03-04 10:22:40 +00:00
|
|
|
'$get_if'(Level0) :-
|
2012-12-07 08:08:32 +00:00
|
|
|
'$nb_getval'('$if_level', Level, fail), !,
|
2012-03-04 10:22:40 +00:00
|
|
|
Level0 = Level.
|
|
|
|
'$get_if'(0).
|
|
|
|
|
2005-10-28 18:38:50 +01:00
|
|
|
'$bind_module'(_, load_files).
|
|
|
|
'$bind_module'(Mod, use_module(Mod)).
|
|
|
|
|
2014-02-09 18:06:37 +00:00
|
|
|
'$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.
|
|
|
|
|
2013-11-17 21:41:41 +00:00
|
|
|
'$import_to_current_module'(File, ContextModule, Imports, RemainingImports, TOpts) :-
|
2013-11-25 15:50:57 +00:00
|
|
|
recorded('$module','$module'(File, Module, ModExports, _),_),
|
2013-11-08 00:02:38 +00:00
|
|
|
Module \= ContextModule, !,
|
|
|
|
'$lf_opt'('$call', TOpts, Call),
|
2013-11-17 21:41:41 +00:00
|
|
|
'$convert_for_export'(Imports, ModExports, Module, ContextModule, TranslationTab, RemainingImports, Goal),
|
2013-11-08 00:02:38 +00:00
|
|
|
'$add_to_imports'(TranslationTab, Module, ContextModule).
|
2013-11-17 21:41:41 +00:00
|
|
|
'$import_to_current_module'(_, _, _, _, _).
|
2005-10-18 18:04:43 +01:00
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
'$start_reconsulting'(F) :-
|
2003-08-27 14:37:10 +01:00
|
|
|
recorda('$reconsulted','$',_),
|
|
|
|
recorda('$reconsulting',F,_).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
'$initialization'(V) :-
|
|
|
|
var(V), !,
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(instantiation_error,initialization(V)).
|
2001-04-09 20:54:03 +01:00
|
|
|
'$initialization'(C) :- number(C), !,
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(type_error(callable,C),initialization(C)).
|
2001-04-09 20:54:03 +01:00
|
|
|
'$initialization'(C) :- db_reference(C), !,
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(type_error(callable,C),initialization(C)).
|
2001-04-09 20:54:03 +01:00
|
|
|
'$initialization'(G) :-
|
2006-02-24 14:26:37 +00:00
|
|
|
'$show_consult_level'(Level1),
|
|
|
|
% it will be done after we leave the current consult level.
|
|
|
|
Level is Level1-1,
|
2010-05-28 16:07:20 +01:00
|
|
|
recordz('$initialisation',do(Level,G),_),
|
2001-04-09 20:54:03 +01:00
|
|
|
fail.
|
|
|
|
'$initialization'(_).
|
|
|
|
|
2010-06-17 00:24:19 +01:00
|
|
|
initialization(G,OPT) :-
|
|
|
|
'$initialization'(G,OPT).
|
|
|
|
|
2010-01-15 16:21:29 +00:00
|
|
|
'$initialization'(G,OPT) :-
|
|
|
|
(
|
|
|
|
var(G)
|
|
|
|
->
|
|
|
|
'$do_error'(instantiation_error,initialization(G,OPT))
|
|
|
|
;
|
|
|
|
number(G)
|
|
|
|
->
|
|
|
|
'$do_error'(type_error(callable,G),initialization(G,OPT))
|
|
|
|
;
|
|
|
|
db_reference(G)
|
|
|
|
->
|
|
|
|
'$do_error'(type_error(callable,G),initialization(G,OPT))
|
|
|
|
;
|
|
|
|
var(OPT)
|
|
|
|
->
|
|
|
|
'$do_error'(instantiation_error,initialization(G,OPT))
|
|
|
|
;
|
|
|
|
atom(OPT)
|
|
|
|
->
|
|
|
|
(
|
|
|
|
OPT == now
|
|
|
|
->
|
|
|
|
fail
|
|
|
|
;
|
|
|
|
OPT == after_load
|
|
|
|
->
|
|
|
|
fail
|
|
|
|
;
|
|
|
|
OPT == restore
|
|
|
|
->
|
|
|
|
fail
|
|
|
|
;
|
|
|
|
'$do_error'(domain_error(initialization,OPT),initialization(OPT))
|
|
|
|
)
|
|
|
|
;
|
|
|
|
'$do_error'(type_error(OPT),initialization(G,OPT))
|
|
|
|
).
|
|
|
|
'$initialization'(G,now) :-
|
2013-02-15 02:40:11 +00:00
|
|
|
( call(G) -> true ; format(user_error,':- ~w:~w failed.~n',[M,G]) ).
|
2010-01-15 16:21:29 +00:00
|
|
|
'$initialization'(G,after_load) :-
|
|
|
|
'$initialization'(G).
|
|
|
|
% ignore for now.
|
2013-11-08 00:02:38 +00:00
|
|
|
'$initialization'(_G,restore).
|
2010-01-15 16:21:29 +00:00
|
|
|
|
2009-04-21 21:19:26 +01:00
|
|
|
'$exec_initialisation_goals' :-
|
|
|
|
nb_setval('$initialization_goals',on),
|
|
|
|
fail.
|
2006-03-03 23:11:30 +00:00
|
|
|
'$exec_initialisation_goals' :-
|
|
|
|
recorded('$blocking_code',_,R),
|
|
|
|
erase(R),
|
|
|
|
fail.
|
|
|
|
% system goals must be performed first
|
|
|
|
'$exec_initialisation_goals' :-
|
|
|
|
recorded('$system_initialisation',G,R),
|
|
|
|
erase(R),
|
|
|
|
G \= '$',
|
2013-02-15 02:40:11 +00:00
|
|
|
once( call(G) ),
|
2006-03-03 23:11:30 +00:00
|
|
|
fail.
|
|
|
|
'$exec_initialisation_goals' :-
|
2010-04-12 18:30:39 +01:00
|
|
|
'$show_consult_level'(Level),
|
2006-03-03 23:11:30 +00:00
|
|
|
'$current_module'(M),
|
2012-12-07 08:08:32 +00:00
|
|
|
recorded('$initialisation',do(Level,_),_),
|
|
|
|
findall(G,
|
|
|
|
'$fetch_init_goal'(Level, G),
|
2010-05-28 16:07:20 +01:00
|
|
|
LGs),
|
|
|
|
lists:member(G,LGs),
|
2006-12-13 16:10:26 +00:00
|
|
|
% run initialization under user control (so allow debugging this stuff).
|
|
|
|
(
|
2013-12-13 08:42:57 +00:00
|
|
|
'$system_catch'(('$user_call'(G,M) -> true), M, Error, user:'$LoopError'(Error, top)),
|
2006-12-13 16:10:26 +00:00
|
|
|
fail
|
|
|
|
;
|
|
|
|
OldMode = on,
|
|
|
|
fail
|
|
|
|
).
|
2009-04-21 21:19:26 +01:00
|
|
|
'$exec_initialisation_goals' :-
|
|
|
|
nb_setval('$initialization_goals',off).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2012-12-07 08:08:32 +00:00
|
|
|
|
|
|
|
'$fetch_init_goal'(Level, G) :-
|
|
|
|
recorded('$initialisation',do(Level,G),R),
|
|
|
|
erase(R),
|
|
|
|
G\='$'.
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
'$include'(V, _) :- var(V), !,
|
2002-09-09 18:40:12 +01:00
|
|
|
'$do_error'(instantiation_error,include(V)).
|
2001-04-09 20:54:03 +01:00
|
|
|
'$include'([], _) :- !.
|
|
|
|
'$include'([F|Fs], Status) :- !,
|
|
|
|
'$include'(F, Status),
|
|
|
|
'$include'(Fs, Status).
|
2002-02-08 22:19:24 +00:00
|
|
|
'$include'(X, Status) :-
|
2013-11-04 01:14:48 +00:00
|
|
|
b_getval('$lf_status', TOpts),
|
|
|
|
'$msg_level'( TOpts, Verbosity),
|
|
|
|
'$full_filename'(X, Y , ( :- include(X)) ),
|
|
|
|
'$lf_opt'(stream, TOpts, OldStream),
|
|
|
|
source_location(F, L),
|
2004-09-30 20:51:54 +01:00
|
|
|
'$current_module'(Mod),
|
2013-11-04 01:14:48 +00:00
|
|
|
( open(Y, read, Stream) ->
|
|
|
|
true ;
|
2011-02-15 07:39:27 +00:00
|
|
|
'$do_error'(permission_error(input,stream,Y),include(X))
|
2001-04-09 20:54:03 +01:00
|
|
|
),
|
2013-11-08 00:02:38 +00:00
|
|
|
'$set_current_loop_stream'(OldStream, Stream),
|
2013-11-04 01:14:48 +00:00
|
|
|
H0 is heapused, '$cputime'(T0,_),
|
2013-11-08 00:02:38 +00:00
|
|
|
'$loaded'(Stream, X, Mod, F, L, include, Y, _Dir, []),
|
2013-11-04 01:14:48 +00:00
|
|
|
( '$nb_getval'('$included_file', OY, fail ) -> true ; OY = [] ),
|
2013-11-08 00:02:38 +00:00
|
|
|
'$lf_opt'(encoding, TOpts, Encoding),
|
|
|
|
'$set_encoding'(Stream, Encoding),
|
2013-11-04 01:14:48 +00:00
|
|
|
nb_setval('$included_file', Y),
|
|
|
|
print_message(Verbosity, loading(including, Y)),
|
|
|
|
'$loop'(Stream,Status),
|
2013-11-08 00:02:38 +00:00
|
|
|
'$set_current_loop_stream'(Stream, OldStream),
|
2013-11-04 01:14:48 +00:00
|
|
|
close(Stream),
|
2004-09-30 20:51:54 +01:00
|
|
|
H is heapused-H0, '$cputime'(TF,_), T is TF-T0,
|
2008-02-22 15:08:37 +00:00
|
|
|
print_message(Verbosity, loaded(included, Y, Mod, T, H)),
|
2007-11-26 23:43:10 +00:00
|
|
|
nb_setval('$included_file',OY).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2014-02-09 18:06:37 +00:00
|
|
|
'$reexport'( TOpts, File, Imports, OldF ) :-
|
2014-01-06 18:28:22 +00:00
|
|
|
'$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),
|
2014-02-09 18:06:37 +00:00
|
|
|
'$extend_exports'(File, Imports, OldF )
|
2014-01-06 18:28:22 +00:00
|
|
|
).
|
|
|
|
|
2014-03-16 18:59:54 +00:00
|
|
|
%
|
|
|
|
% reconsult at startup...
|
|
|
|
%
|
|
|
|
'$do_startup_reconsult'(_X) :-
|
|
|
|
'$init_win_graphics',
|
|
|
|
fail.
|
2001-04-09 20:54:03 +01:00
|
|
|
'$do_startup_reconsult'(X) :-
|
|
|
|
( '$access_yap_flags'(15, 0) ->
|
2013-11-04 01:14:48 +00:00
|
|
|
'$system_catch'(load_files(X, [silent(true)]), Module, Error, '$Error'(Error))
|
2001-04-09 20:54:03 +01:00
|
|
|
;
|
2013-11-04 01:14:48 +00:00
|
|
|
'$swi_set_prolog_flag'(verbose, silent),
|
|
|
|
'$system_catch'(load_files(X, [silent(true),skip_unix_header(true)]),Module,_,fail)
|
2006-12-13 16:10:26 +00:00
|
|
|
;
|
|
|
|
true
|
2001-04-09 20:54:03 +01:00
|
|
|
),
|
2006-12-13 16:10:26 +00:00
|
|
|
!,
|
2001-04-09 20:54:03 +01:00
|
|
|
( '$access_yap_flags'(15, 0) -> true ; halt).
|
2011-09-07 21:28:13 +01:00
|
|
|
'$do_startup_reconsult'(_).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2013-11-04 01:14:48 +00:00
|
|
|
'$skip_unix_header'(Stream) :-
|
2011-05-12 22:34:44 +01:00
|
|
|
peek_code(Stream, 0'#), !, % 35 is ASCII for '#
|
2011-02-15 14:43:28 +00:00
|
|
|
skip(Stream, 10),
|
2013-11-04 01:14:48 +00:00
|
|
|
'$skip_unix_header'(Stream).
|
|
|
|
'$skip_unix_header'(_).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
|
2010-02-28 22:24:51 +00:00
|
|
|
source_file(FileName) :-
|
2014-05-18 14:47:23 +01:00
|
|
|
recorded('$lf_loaded','$lf_loaded'(FileName, _, _),_).
|
2010-02-28 22:24:51 +00:00
|
|
|
|
|
|
|
source_file(Mod:Pred, FileName) :-
|
|
|
|
current_module(Mod),
|
|
|
|
Mod \= prolog,
|
|
|
|
'$current_predicate_no_modules'(Mod,_,Pred),
|
|
|
|
'$owned_by'(Pred, Mod, FileName).
|
|
|
|
|
|
|
|
'$owned_by'(T, Mod, FileName) :-
|
|
|
|
'$is_multifile'(T, Mod),
|
|
|
|
functor(T, Name, Arity),
|
|
|
|
setof(FileName, Ref^recorded('$multifile_defs','$defined'(FileName,Name,Arity,Mod), Ref), L),
|
|
|
|
lists:member(FileName, L).
|
|
|
|
'$owned_by'(T, Mod, FileName) :-
|
|
|
|
'$owner_file'(T, Mod, FileName).
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
prolog_load_context(directory, DirName) :-
|
2013-11-04 01:14:48 +00:00
|
|
|
source_location(F, _),
|
|
|
|
file_directory_name(F, DirName).
|
2001-04-09 20:54:03 +01:00
|
|
|
prolog_load_context(file, FileName) :-
|
2013-11-04 01:14:48 +00:00
|
|
|
source_location(FileName, _).
|
2001-04-09 20:54:03 +01:00
|
|
|
prolog_load_context(module, X) :-
|
2013-11-04 01:14:48 +00:00
|
|
|
'$nb_getval'('$consulting_file', _, fail),
|
2001-04-09 20:54:03 +01:00
|
|
|
'$current_module'(X).
|
2013-11-04 01:14:48 +00:00
|
|
|
prolog_load_context(source, F0) :-
|
|
|
|
source_location(F0, _) /*,
|
|
|
|
'$input_context'(Context),
|
|
|
|
'$top_file'(Context, F0, F) */.
|
2001-04-09 20:54:03 +01:00
|
|
|
prolog_load_context(stream, Stream) :-
|
2014-04-06 17:05:17 +01:00
|
|
|
'$nb_getval'('$consulting_file', _, fail),
|
2011-07-11 15:40:58 +01:00
|
|
|
'$current_loop_stream'(Stream).
|
2011-04-30 10:57:00 +01:00
|
|
|
% return this term for SWI compatibility.
|
|
|
|
prolog_load_context(term_position, '$stream_position'(0,Line,0,0,0)) :-
|
2013-11-04 01:14:48 +00:00
|
|
|
source_location(_, Line).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
|
2005-10-18 18:04:43 +01:00
|
|
|
% if the file exports a module, then we can
|
|
|
|
% be imported from any module.
|
2013-11-08 00:02:38 +00:00
|
|
|
'$file_loaded'(Stream, M, Imports, TOpts) :-
|
2005-10-18 18:04:43 +01:00
|
|
|
'$file_name'(Stream, F),
|
2013-11-17 21:41:41 +00:00
|
|
|
'$ensure_file_loaded'(F, M, F1),
|
|
|
|
% format( 'IL=~w~n', [(F1:Imports->M)] ),
|
|
|
|
'$import_to_current_module'(F1, M, Imports, _, TOpts).
|
2005-10-18 18:04:43 +01:00
|
|
|
|
2013-11-17 21:41:41 +00:00
|
|
|
'$ensure_file_loaded'(F, M, F1) :-
|
2013-11-25 15:50:57 +00:00
|
|
|
recorded('$module','$module'(F1,_NM,_P,_),_),
|
2014-05-18 14:47:23 +01:00
|
|
|
recorded('$lf_loaded','$lf_loaded'(F1, _, _),_),
|
2013-11-17 21:41:41 +00:00
|
|
|
same_file(F1,F), !.
|
2014-05-18 14:47:23 +01:00
|
|
|
'$ensure_file_loaded'(F, M, F1) :-
|
|
|
|
% loaded from the same module, but does not define a module.
|
|
|
|
recorded('$lf_loaded','$lf_loaded'(F1, _, M),_),
|
2011-02-14 22:55:59 +00:00
|
|
|
same_file(F1,F), !.
|
2006-11-27 17:42:03 +00:00
|
|
|
|
2003-11-29 23:41:28 +00:00
|
|
|
|
|
|
|
% if the file exports a module, then we can
|
|
|
|
% be imported from any module.
|
2013-11-08 00:02:38 +00:00
|
|
|
'$file_unchanged'(Stream, M, Imports, TOpts) :-
|
2005-10-18 18:04:43 +01:00
|
|
|
'$file_name'(Stream, F),
|
2013-11-17 21:41:41 +00:00
|
|
|
'$ensure_file_unchanged'(F, M, F1),
|
|
|
|
% format( 'IU=~w~n', [(F1:Imports->M)] ),
|
|
|
|
'$import_to_current_module'(F1, M, Imports, _, TOpts).
|
2005-10-18 18:04:43 +01:00
|
|
|
|
2013-11-17 21:41:41 +00:00
|
|
|
'$ensure_file_unchanged'(F, M, F1) :-
|
2013-11-25 15:50:57 +00:00
|
|
|
recorded('$module','$module'(F1,_NM,_P,_),_),
|
2014-05-18 14:47:23 +01:00
|
|
|
recorded('$lf_loaded','$lf_loaded'(F1,Age,_),R),
|
2011-02-14 22:55:59 +00:00
|
|
|
same_file(F1,F), !,
|
2013-11-17 21:41:41 +00:00
|
|
|
'$file_is_unchanged'(F, R, Age).
|
2014-05-18 14:47:23 +01:00
|
|
|
'$ensure_file_unchanged'(F, M, F1) :-
|
|
|
|
recorded('$lf_loaded','$lf_loaded'(F1, Age, M),R),
|
2011-02-14 22:55:59 +00:00
|
|
|
same_file(F1,F), !,
|
2005-10-18 18:04:43 +01:00
|
|
|
'$file_is_unchanged'(F, R, Age).
|
2003-11-29 23:41:28 +00:00
|
|
|
|
2005-10-18 18:04:43 +01:00
|
|
|
'$file_is_unchanged'(F, R, Age) :-
|
2013-06-07 18:00:27 +01:00
|
|
|
time_file64(F,CurrentAge),
|
|
|
|
( (Age == CurrentAge ; Age = -1) -> true; erase(R), fail).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
|
2004-10-06 17:55:48 +01:00
|
|
|
% add_multifile_predicate when we start consult
|
2003-11-26 18:36:35 +00:00
|
|
|
'$add_multifile'(Name,Arity,Module) :-
|
2013-11-04 01:14:48 +00:00
|
|
|
source_location(File,_),
|
2003-11-26 18:36:35 +00:00
|
|
|
'$add_multifile'(File,Name,Arity,Module).
|
|
|
|
|
|
|
|
'$add_multifile'(File,Name,Arity,Module) :-
|
2009-05-29 16:48:40 +01:00
|
|
|
recorded('$multifile_defs','$defined'(File,Name,Arity,Module), _), !.
|
|
|
|
% print_message(warning,declaration((multifile Module:Name/Arity),ignored)).
|
2005-04-20 21:06:26 +01:00
|
|
|
'$add_multifile'(File,Name,Arity,Module) :-
|
|
|
|
recordz('$multifile_defs','$defined'(File,Name,Arity,Module),_), !,
|
2003-11-26 18:36:35 +00:00
|
|
|
fail.
|
|
|
|
'$add_multifile'(File,Name,Arity,Module) :-
|
|
|
|
recorded('$mf','$mf_clause'(File,Name,Arity,Module,Ref),R),
|
|
|
|
erase(R),
|
2005-04-20 21:06:26 +01:00
|
|
|
'$erase_clause'(Ref,Module),
|
2003-11-26 18:36:35 +00:00
|
|
|
fail.
|
|
|
|
'$add_multifile'(_,_,_,_).
|
|
|
|
|
|
|
|
% retract old multifile clauses for current file.
|
|
|
|
'$remove_multifile_clauses'(FileName) :-
|
|
|
|
recorded('$multifile_defs','$defined'(FileName,_,_,_),R1),
|
|
|
|
erase(R1),
|
|
|
|
fail.
|
|
|
|
'$remove_multifile_clauses'(FileName) :-
|
|
|
|
recorded('$mf','$mf_clause'(FileName,_,_,Module,Ref),R),
|
|
|
|
'$erase_clause'(Ref, Module),
|
|
|
|
erase(R),
|
|
|
|
fail.
|
|
|
|
'$remove_multifile_clauses'(_).
|
|
|
|
|
2013-11-17 21:41:41 +00:00
|
|
|
% inform the file has been loaded and is now available.
|
2013-11-04 01:14:48 +00:00
|
|
|
'$loaded'(Stream, UserFile, M, OldF, Line, Reconsult, F, Dir, Opts) :-
|
|
|
|
'$file_name'(Stream, F0),
|
2013-11-08 00:02:38 +00:00
|
|
|
( F0 == user_input, nonvar(UserFile) -> UserFile = F ; F = F0 ),
|
2013-11-04 01:14:48 +00:00
|
|
|
( F == user_input -> working_directory(Dir,Dir) ; file_directory_name(F, Dir) ),
|
|
|
|
nb_setval('$consulting_file', F ),
|
2014-05-18 14:47:23 +01:00
|
|
|
( Reconsult \== consult, Reconsult \== not_loaded, Reconsult \== changed, recorded('$lf_loaded','$lf_loaded'(F, _,_),R), erase(R), fail ; var(Reconsult) -> Reconsult = consult ; true ),
|
2013-11-04 01:14:48 +00:00
|
|
|
( Reconsult \== consult, recorded('$lf_loaded','$lf_loaded'(F, _, _, _, _, _, _),R), erase(R), fail ; var(Reconsult) -> Reconsult = consult ; true ),
|
|
|
|
( F == user_input -> Age = 0 ; time_file64(F, Age) ),
|
2014-05-18 14:47:23 +01:00
|
|
|
( recordaifnot('$lf_loaded','$lf_loaded'( F, Age, M), _) -> true ; true ),
|
2013-11-04 01:14:48 +00:00
|
|
|
recorda('$lf_loaded','$lf_loaded'( F, M, Reconsult, UserFile, OldF, Line, Opts), _).
|
2005-10-19 02:47:43 +01:00
|
|
|
|
2011-09-02 21:03:41 +01:00
|
|
|
'$set_encoding'(Encoding) :-
|
2011-07-11 15:40:58 +01:00
|
|
|
'$current_loop_stream'(Stream),
|
2013-11-08 00:02:38 +00:00
|
|
|
'$set_encoding'(Stream, Encoding).
|
|
|
|
|
|
|
|
'$set_encoding'(Stream, Encoding) :-
|
2011-09-02 21:03:41 +01:00
|
|
|
( Encoding == default -> true ; set_stream(Stream, encoding(Encoding)) ).
|
2007-09-28 00:02:00 +01:00
|
|
|
|
2007-10-21 09:48:06 +01:00
|
|
|
%
|
|
|
|
% This is complicated because of embedded ifs.
|
|
|
|
%
|
|
|
|
'$if'(_,top) :- !, fail.
|
2013-11-08 00:02:38 +00:00
|
|
|
'$if'(_Goal,_) :-
|
2012-03-04 10:22:40 +00:00
|
|
|
'$get_if'(Level0),
|
2007-10-21 09:48:06 +01:00
|
|
|
Level is Level0 + 1,
|
|
|
|
nb_setval('$if_level',Level),
|
2013-10-30 09:41:45 +00:00
|
|
|
( '$nb_getval'('$endif', OldEndif, fail) -> true ; OldEndif=top),
|
|
|
|
( '$nb_getval'('$if_skip_mode', Mode, fail) -> true ; Mode = run ),
|
2007-10-21 09:48:06 +01:00
|
|
|
nb_setval('$endif',elif(Level,OldEndif,Mode)),
|
|
|
|
fail.
|
|
|
|
% we are in skip mode, ignore....
|
2013-11-08 00:02:38 +00:00
|
|
|
'$if'(_Goal,_) :-
|
2013-10-29 12:43:31 +00:00
|
|
|
'$nb_getval'('$endif',elif(Level, OldEndif, skip), fail), !,
|
2007-10-21 09:48:06 +01:00
|
|
|
nb_setval('$endif',endif(Level, OldEndif, skip)).
|
|
|
|
% we are in non skip mode, check....
|
|
|
|
'$if'(Goal,_) :-
|
|
|
|
('$if_call'(Goal)
|
|
|
|
->
|
|
|
|
% we will execute this branch, and later enter skip
|
2013-10-29 12:43:31 +00:00
|
|
|
'$nb_getval'('$endif', elif(Level,OldEndif,Mode), fail),
|
2007-10-21 09:48:06 +01:00
|
|
|
nb_setval('$endif',endif(Level,OldEndif,Mode))
|
2013-10-30 09:41:45 +00:00
|
|
|
|
2007-10-21 09:48:06 +01:00
|
|
|
;
|
|
|
|
% we are now in skip, but can start an elif.
|
|
|
|
nb_setval('$if_skip_mode',skip)
|
|
|
|
).
|
|
|
|
|
|
|
|
'$else'(top) :- !, fail.
|
|
|
|
'$else'(_) :-
|
2012-03-04 10:22:40 +00:00
|
|
|
'$get_if'(0), !,
|
2007-10-21 09:48:06 +01:00
|
|
|
'$do_error'(context_error(no_if),(:- else)).
|
|
|
|
% we have done an if, so just skip
|
|
|
|
'$else'(_) :-
|
2013-10-30 09:41:45 +00:00
|
|
|
nb_getval('$endif',endif(_Level,_,_)), !,
|
2007-10-21 09:48:06 +01:00
|
|
|
nb_setval('$if_skip_mode',skip).
|
|
|
|
% we can try the elif
|
|
|
|
'$else'(_) :-
|
2012-03-04 10:22:40 +00:00
|
|
|
'$get_if'(Level),
|
2007-10-21 09:48:06 +01:00
|
|
|
nb_getval('$endif',elif(Level,OldEndif,Mode)),
|
|
|
|
nb_setval('$endif',endif(Level,OldEndif,Mode)),
|
|
|
|
nb_setval('$if_skip_mode',run).
|
|
|
|
|
|
|
|
'$elif'(_,top) :- !, fail.
|
|
|
|
'$elif'(Goal,_) :-
|
2012-03-04 10:22:40 +00:00
|
|
|
'$get_if'(0),
|
2007-10-21 09:48:06 +01:00
|
|
|
'$do_error'(context_error(no_if),(:- elif(Goal))).
|
|
|
|
% we have done an if, so just skip
|
|
|
|
'$elif'(_,_) :-
|
|
|
|
nb_getval('$endif',endif(_,_,_)), !,
|
|
|
|
nb_setval('$if_skip_mode',skip).
|
|
|
|
% we can try the elif
|
|
|
|
'$elif'(Goal,_) :-
|
2012-03-04 10:22:40 +00:00
|
|
|
'$get_if'(Level),
|
2007-10-21 09:48:06 +01:00
|
|
|
nb_getval('$endif',elif(Level,OldEndif,Mode)),
|
|
|
|
('$if_call'(Goal)
|
|
|
|
->
|
|
|
|
% we will not skip, and we will not run any more branches.
|
|
|
|
nb_setval('$endif',endif(Level,OldEndif,Mode)),
|
|
|
|
nb_setval('$if_skip_mode',run)
|
|
|
|
;
|
|
|
|
% we will (keep) on skipping
|
|
|
|
nb_setval('$if_skip_mode',skip)
|
|
|
|
).
|
|
|
|
'$elif'(_,_).
|
|
|
|
|
|
|
|
'$endif'(top) :- !, fail.
|
|
|
|
'$endif'(_) :-
|
|
|
|
% unmmatched endif.
|
2012-03-04 10:22:40 +00:00
|
|
|
'$get_if'(0),
|
2007-10-21 09:48:06 +01:00
|
|
|
'$do_error'(context_error(no_if),(:- endif)).
|
|
|
|
'$endif'(_) :-
|
|
|
|
% back to where you belong.
|
2012-03-04 10:22:40 +00:00
|
|
|
'$get_if'(Level),
|
2007-10-21 09:48:06 +01:00
|
|
|
nb_getval('$endif',Endif),
|
|
|
|
Level0 is Level-1,
|
|
|
|
nb_setval('$if_level',Level0),
|
|
|
|
arg(2,Endif,OldEndif),
|
|
|
|
arg(3,Endif,OldMode),
|
|
|
|
nb_setval('$endif',OldEndif),
|
|
|
|
nb_setval('$if_skip_mode',OldMode).
|
|
|
|
|
|
|
|
|
|
|
|
'$if_call'(G) :-
|
|
|
|
catch('$eval_if'(G), E, (print_message(error, E), fail)).
|
|
|
|
|
|
|
|
'$eval_if'(Goal) :-
|
|
|
|
expand_term(Goal,TrueGoal),
|
|
|
|
once(TrueGoal).
|
|
|
|
|
|
|
|
'$if_directive'((:- if(_))).
|
|
|
|
'$if_directive'((:- else)).
|
|
|
|
'$if_directive'((:- elif(_))).
|
|
|
|
'$if_directive'((:- endif)).
|
|
|
|
|
2007-11-08 11:22:05 +00:00
|
|
|
|
2008-07-11 18:02:10 +01:00
|
|
|
'$comp_mode'(_OldCompMode, CompMode) :-
|
|
|
|
var(CompMode), !. % just do nothing.
|
|
|
|
'$comp_mode'(OldCompMode, assert_all) :-
|
|
|
|
'$fetch_comp_status'(OldCompMode),
|
|
|
|
nb_setval('$assert_all',on).
|
|
|
|
'$comp_mode'(OldCompMode, source) :-
|
|
|
|
'$fetch_comp_status'(OldCompMode),
|
|
|
|
'$set_yap_flags'(11,1).
|
|
|
|
'$comp_mode'(OldCompMode, compact) :-
|
|
|
|
'$fetch_comp_status'(OldCompMode),
|
|
|
|
'$set_yap_flags'(11,0).
|
|
|
|
|
|
|
|
'$fetch_comp_status'(assert_all) :-
|
2012-12-07 08:08:32 +00:00
|
|
|
'$nb_getval'('$assert_all',on, fail), !.
|
2008-07-11 18:02:10 +01:00
|
|
|
'$fetch_comp_status'(source) :-
|
2013-11-08 08:24:06 +00:00
|
|
|
'$access_yap_flags'(11,1), !.
|
2008-07-11 18:02:10 +01:00
|
|
|
'$fetch_comp_status'(compact).
|
2007-11-08 11:22:05 +00:00
|
|
|
|
2009-10-15 12:56:16 +01:00
|
|
|
make :-
|
2013-11-08 00:02:38 +00:00
|
|
|
recorded('$lf_loaded','$lf_loaded'(F1,_M,reconsult,_,_,_,_),_),
|
2009-10-15 12:56:16 +01:00
|
|
|
'$load_files'(F1, [if(changed)],make),
|
|
|
|
fail.
|
|
|
|
make.
|
|
|
|
|
2011-07-22 15:49:40 +01:00
|
|
|
make_library_index(_Directory).
|
|
|
|
|
2011-02-12 14:14:12 +00:00
|
|
|
'$file_name'(Stream,F) :-
|
|
|
|
stream_property(Stream, file_name(F)), !.
|
2014-04-24 11:40:35 +01:00
|
|
|
'$file_name'(user_input,user_input) :- !.
|
|
|
|
'$file_name'(user_output,user_ouput) :- !.
|
|
|
|
'$file_name'(user_error,user_error) :- !.
|
|
|
|
'$file_name'(_,[]).
|
2011-02-12 14:14:12 +00:00
|
|
|
|
|
|
|
|
2011-02-14 14:59:15 +00:00
|
|
|
'$fetch_stream_alias'(OldStream,Alias) :-
|
|
|
|
stream_property(OldStream, alias(Alias)), !.
|
|
|
|
|
2011-06-14 09:04:03 +01:00
|
|
|
'$require'(_Ps, _M).
|
|
|
|
|
2013-11-08 00:02:38 +00:00
|
|
|
'$store_clause'('$source_location'(File, _Line):Clause, File) :-
|
2011-06-14 09:04:03 +01:00
|
|
|
assert_static(Clause).
|
|
|
|
|
|
|
|
|
2011-07-11 15:40:58 +01:00
|
|
|
'$set_current_loop_stream'(OldStream, Stream) :-
|
|
|
|
'$current_loop_stream'(OldStream), !,
|
|
|
|
'$new_loop_stream'(Stream).
|
2013-11-08 00:02:38 +00:00
|
|
|
'$set_current_loop_stream'(_OldStream, Stream) :-
|
2011-07-11 15:40:58 +01:00
|
|
|
'$new_loop_stream'(Stream).
|
|
|
|
|
|
|
|
'$new_loop_stream'(Stream) :-
|
|
|
|
(var(Stream) ->
|
|
|
|
nb_delete('$loop_stream')
|
|
|
|
;
|
|
|
|
nb_setval('$loop_stream',Stream)
|
|
|
|
).
|
|
|
|
|
|
|
|
'$current_loop_stream'(Stream) :-
|
2012-12-07 08:08:32 +00:00
|
|
|
'$nb_getval'('$loop_stream',Stream, fail).
|
2011-07-11 15:40:58 +01:00
|
|
|
|
2012-02-13 09:36:44 +00:00
|
|
|
exists_source(File) :-
|
2013-11-08 00:02:38 +00:00
|
|
|
'$full_filename'(File, _AbsFile, exists_source(File)).
|
2012-02-13 09:36:44 +00:00
|
|
|
|
2013-11-04 01:14:48 +00:00
|
|
|
% reload_file(File) :-
|
|
|
|
% ' $source_base_name'(File, Compile),
|
|
|
|
% findall(M-Opts,
|
|
|
|
% source_file_property(File, load_context(M, _, Opts)),
|
|
|
|
% Modules),
|
|
|
|
% ( Modules = [First-OptsFirst|Rest]
|
|
|
|
% -> Extra = [ silent(false),
|
|
|
|
% register(false)
|
|
|
|
% ],
|
|
|
|
% merge_options([if(true)|Extra], OptsFirst, OFirst),
|
|
|
|
% % debug(make, 'Make: First load ~q', [load_files(First:Compile, OFirst)]),
|
|
|
|
% load_files(First:Compile, OFirst),
|
|
|
|
% forall(member(Context-Opts, Rest),
|
|
|
|
% ( merge_options([if(not_loaded)|Extra], Opts, O),
|
|
|
|
% % debug(make, 'Make: re-import: ~q',
|
|
|
|
% % [load_files(Context:Compile, O)]),
|
|
|
|
% load_files(Context:Compile, O)
|
|
|
|
% ))
|
|
|
|
% ; load_files(user:Compile)
|
|
|
|
% ).
|
|
|
|
|
|
|
|
% ' $source_base_name'(File, Compile) :-
|
|
|
|
% file_name_extension(Compile, Ext, File),
|
|
|
|
% user:prolog_file_type(Ext, prolog), !.
|
|
|
|
% ' $source_base_name'(File, File).
|
|
|
|
|
|
|
|
source_file_property( File0, Prop) :-
|
|
|
|
( nonvar(File0) -> absolute_file_name(File0,File) ; File = File0 ),
|
|
|
|
'$source_file_property'( File, Prop).
|
|
|
|
|
|
|
|
'$source_file_property'( OldF, includes(F, Age)) :-
|
2014-05-25 20:52:45 +01:00
|
|
|
recorded('$lf_loaded','$lf_loaded'( F, _M, _ include, _File, OldF, _Line, _), _),
|
2014-05-18 14:47:23 +01:00
|
|
|
recorded('$lf_loaded','$lf_loaded'( F, Age, _), _).
|
2013-11-04 01:14:48 +00:00
|
|
|
'$source_file_property'( F, included_in(OldF, Line)) :-
|
|
|
|
recorded('$lf_loaded','$lf_loaded'( F, _M, include, _File, OldF, Line, _), _).
|
|
|
|
'$source_file_property'( F, load_context(OldF, Line, Options)) :-
|
|
|
|
recorded('$lf_loaded','$lf_loaded'( F, _M, V, _File, OldF, Line, Options), _), V \== include.
|
|
|
|
'$source_file_property'( F, modified(Age)) :-
|
2014-05-18 14:47:23 +01:00
|
|
|
recorded('$lf_loaded','$lf_loaded'( F, Age, _), _).
|
2013-11-04 01:14:48 +00:00
|
|
|
'$source_file_property'( F, module(M)) :-
|
2013-11-25 15:50:57 +00:00
|
|
|
recorded('$module','$module'(F,M,_,_),_).
|
2013-11-11 00:52:13 +00:00
|
|
|
|