qload
This commit is contained in:
10
pl/absf.yap
10
pl/absf.yap
@@ -76,7 +76,7 @@
|
||||
|
||||
3. `executable` implies `['.so', ',dylib', '.dll']` depending on the Operating system,
|
||||
|
||||
4. `qlf` implies `['.qlf', '']`,
|
||||
4. `qly` implies `['.qly', '']`,
|
||||
|
||||
5. `directory` implies `['']`,
|
||||
|
||||
@@ -209,7 +209,7 @@ absolute_file_name(File0,File) :-
|
||||
'$check_fn_type'(prolog,_) :- !.
|
||||
'$check_fn_type'(source,_) :- !.
|
||||
'$check_fn_type'(executable,_) :- !.
|
||||
'$check_fn_type'(qlf,_) :- !.
|
||||
'$check_fn_type'(qly,_) :- !.
|
||||
'$check_fn_type'(directory,_) :- !.
|
||||
'$check_fn_type'(T,G) :- atom(T), !,
|
||||
'$do_error'(domain_error(file_type,T),G).
|
||||
@@ -563,6 +563,8 @@ remove_from_path(New) :- '$check_path'(New,Path),
|
||||
prolog_file_type(yap, prolog).
|
||||
prolog_file_type(pl, prolog).
|
||||
prolog_file_type(prolog, prolog).
|
||||
prolog_file_type(qly, prolog).
|
||||
prolog_file_type(qly, qly).
|
||||
prolog_file_type(A, prolog) :-
|
||||
current_prolog_flag(associate, A),
|
||||
A \== prolog,
|
||||
@@ -586,8 +588,8 @@ user:prolog_file_type(A, prolog) :-
|
||||
A \== prolog,
|
||||
A \==pl,
|
||||
A \== yap.
|
||||
%user:prolog_file_type(qlf, prolog).
|
||||
%user:prolog_file_type(qlf, qlf).
|
||||
user:prolog_file_type(qly, prolog).
|
||||
user:prolog_file_type(qly, qly).
|
||||
user:prolog_file_type(A, executable) :-
|
||||
current_prolog_flag(shared_object_extension, A).
|
||||
|
||||
|
147
pl/consult.yap
147
pl/consult.yap
@@ -30,7 +30,8 @@
|
||||
source_file/1,
|
||||
source_file/2,
|
||||
source_file_property/2,
|
||||
use_module/3], ['$add_multifile'/3,
|
||||
use_module/3],
|
||||
['$add_multifile'/3,
|
||||
'$csult'/2,
|
||||
'$do_startup_reconsult'/1,
|
||||
'$elif'/2,
|
||||
@@ -92,62 +93,79 @@ files and to set-up the Prolog environment. We discuss
|
||||
General implementation of the consult/1 family. Execution is controlled by the
|
||||
following flags:
|
||||
|
||||
+ consult(+ _Mode_)
|
||||
This extension controls the type of file to load. If _Mode_ is:
|
||||
`consult`, clauses are added to the data-base, unless from the same file;
|
||||
`reconsult`, clauses are recompiled,
|
||||
`db`, these are facts that need to be added to the data-base,
|
||||
`exo`, these are facts with atoms and integers that can be stored in a compact representation (see load_exo/1).
|
||||
+ consult(+ _Mode_)
|
||||
|
||||
+ silent(+ _Bool_)
|
||||
If true, load the file without printing a message. The specified value is the default for all files loaded as a result of loading the specified files.
|
||||
This extension controls the type of file to load. If _Mode_ is:
|
||||
|
||||
`consult`, clauses are added to the data-base, unless from the same file;
|
||||
`reconsult`, clauses are recompiled,
|
||||
`db`, these are facts that need to be added to the data-base,
|
||||
`exo`, these are facts with atoms and integers that can be stored in a compact representation (see load_exo/1).
|
||||
|
||||
+ stream(+ _Input_)
|
||||
This SWI-Prolog extension compiles the data from the stream _Input_. If this option is used, _Files_ must be a single atom which is used to identify the source-location of the loaded
|
||||
clauses as well as remove all clauses if the data is re-consulted.
|
||||
+ silent(+ _Bool_)
|
||||
|
||||
This option is added to allow compiling from non-file locations such as databases, the web, the user (see consult/1) or other servers.
|
||||
If true, load the file without printing a message. The specified
|
||||
value is the default for all files loaded as a result of loading
|
||||
the specified files.
|
||||
|
||||
+ compilation_mode(+ _Mode_)
|
||||
This extension controls how procedures are compiled. If _Mode_
|
||||
is `compact` clauses are compiled and no source code is stored;
|
||||
if it is `source` clauses are compiled and source code is stored;
|
||||
if it is `assert_all` clauses are asserted into the data-base.
|
||||
+ stream(+ _Input_)
|
||||
|
||||
+ encoding(+ _Encoding_)
|
||||
Character encoding used in consulting files. Please (see [Encoding](@ref Encoding)) for
|
||||
supported encodings.
|
||||
This SWI-Prolog extension compiles the data from the stream
|
||||
_Input_. If this option is used, _Files_ must be a single atom
|
||||
which is used to identify the source-location of the loaded
|
||||
clauses as well as remove all clauses if the data is re-consulted.
|
||||
|
||||
+ expand(+ _Bool_)
|
||||
If `true`, run the
|
||||
filenames through expand_file_name/2 and load the returned
|
||||
files. Default is false, except for consult/1 which is
|
||||
intended for interactive use.
|
||||
This option is added to allow compiling from non-file locations
|
||||
such as databases, the web, the user (see consult/1) or other
|
||||
servers.
|
||||
|
||||
+ if(+ _Condition_)
|
||||
Load the file only if the specified _Condition_ is
|
||||
satisfied. The value `true` the file unconditionally,
|
||||
`changed` loads the file if it was not loaded before, or has
|
||||
been modified since it was loaded the last time, `not_loaded`
|
||||
loads the file if it was not loaded before.
|
||||
+ compilation_mode(+ _Mode_)
|
||||
|
||||
+ imports(+ _ListOrAll_)
|
||||
If `all` and the file is a module file, import all public
|
||||
predicates. Otherwise import only the named predicates. Each
|
||||
predicate is referred to as `\<name\>/\<arity\>`. This option has
|
||||
no effect if the file is not a module file.
|
||||
This extension controls how procedures are compiled. If _Mode_ is
|
||||
`compact` clauses are compiled and no source code is stored; if it
|
||||
is `source` clauses are compiled and source code is stored; if it
|
||||
is `assert_all` clauses are asserted into the data-base.
|
||||
|
||||
+ must_be_module(+ _Bool_)
|
||||
If true, raise an error if the file is not a module file. Used by
|
||||
` use_module/1 and use_module/2.
|
||||
+ encoding(+ _Encoding_)
|
||||
|
||||
+ autoload(+ _Autoload_)
|
||||
SWI-compatible option where if _Autoload_ is `true` undefined predicates
|
||||
are loaded on first call.
|
||||
Character encoding used in consulting files. Please (see
|
||||
[Encoding](@ref Encoding)) for supported encodings.
|
||||
|
||||
+ expand(+ _Bool_)
|
||||
|
||||
If `true`, run the filenames through expand_file_name/2 and load
|
||||
the returned files. Default is false, except for consult/1 which
|
||||
is intended for interactive use.
|
||||
|
||||
+ if(+ _Condition_)
|
||||
|
||||
Load the file only if the specified _Condition_ is satisfied. The
|
||||
value `true` the file unconditionally, `changed` loads the file if
|
||||
it was not loaded before, or has been modified since it was loaded
|
||||
the last time, `not_loaded` loads the file if it was not loaded
|
||||
before.
|
||||
|
||||
+ imports(+ _ListOrAll_)
|
||||
|
||||
If `all` and the file is a module file, import all public
|
||||
predicates. Otherwise import only the named predicates. Each
|
||||
predicate is referred to as `\<name\>/\<arity\>`. This option has
|
||||
no effect if the file is not a module file.
|
||||
|
||||
+ must_be_module(+ _Bool_)
|
||||
|
||||
If true, raise an error if the file is not a module file. Used by
|
||||
` use_module/1 and use_module/2.
|
||||
|
||||
+ autoload(+ _Autoload_)
|
||||
|
||||
SWI-compatible option where if _Autoload_ is `true` undefined
|
||||
predicates are loaded on first call.
|
||||
|
||||
+ derived_from(+ _File_)
|
||||
|
||||
SWI-compatible option to control make/0. Currently not supported.
|
||||
|
||||
+ derived_from(+ _File_)
|
||||
SWI-compatible option to control make/0. Currently
|
||||
not supported.
|
||||
*/
|
||||
%
|
||||
% SWI options
|
||||
@@ -368,13 +386,18 @@ load_files(Files,Opts) :-
|
||||
'$lf'([F|Fs], Mod, Call, TOpts) :- !,
|
||||
% clean up after each consult
|
||||
( '$lf'(F,Mod,Call, TOpts), fail ;
|
||||
'$lf'(Fs, Mod, Call, TOpts) ).
|
||||
'$lf'(Fs, Mod, Call, TOpts), fail;
|
||||
true
|
||||
).
|
||||
'$lf'(user, Mod, _, TOpts) :- !,
|
||||
b_setval('$source_file', user_input),
|
||||
'$do_lf'(Mod, user_input, user_input, TOpts).
|
||||
'$lf'(user_input, Mod, _, TOpts) :- !,
|
||||
b_setval('$source_file', user_input),
|
||||
'$do_lf'(Mod, user_input, user_input, TOpts).
|
||||
'$lf'(File, Mod, Call, TOpts) :-
|
||||
'$lf_opt'(stream, TOpts, Stream),
|
||||
b_setval('$source_file', File),
|
||||
( var(Stream) ->
|
||||
/* need_to_open_file */
|
||||
'$full_filename'(File, Y, Call),
|
||||
@@ -664,16 +687,16 @@ db_files(Fs) :-
|
||||
'$bind_module'(Mod, use_module(Mod)).
|
||||
|
||||
'$import_to_current_module'(File, ContextModule, Imports, RemainingImports, TOpts) :-
|
||||
\+ recorded('$module','$module'(File, _Module, _ModExports, _),_),
|
||||
\+ recorded('$module','$module'(File, _Module, _, |