YAP 7.1.0
qly.yap
Go to the documentation of this file.
1/*************************************************************************
2* *
3* YAP Prolog *
4* *
5* Yap Prolog was developed at NCCUP - Universidade do Porto *
6* *
7* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2011 *
8* *
9**************************************************************************
10* *
11* File: qly.yap *
12* Last rev: *
13* mods: *
14* comments: fast save/restore *
15* *
16*************************************************************************/
17
18%% @file qly.yap
19
20/**
21@defgroup QLY Creating and Using a saved state
22@ingroup YAPConsulting
23@{
24*/
25
26:- system_module( '$_qly', [qload_module/1,
27 qsave_file/1,
29 qsave_program/1,
33 save_program/2], ['$init_state'/0]).
34
35:- '$system_library_directories'/2use_system_module( '$_absf', []).
36
37:- '$system_catch'/4use_system_module( '$_boot', []).
38
39:- '$do_startup_reconsult'/1use_system_module( '$_consult', []).
40
41:- '$run_atom_goal'/1use_system_module( '$_control', []).
42
43:- '$do_error'/2use_system_module( '$_errors', []).
44
45:- '$init_preds'/0use_system_module( '$_preds', []).
46
47:- '$protect'/0use_system_module( '$_protect', []).
48
49:- '$reinit_thread0'/0use_system_module( '$_threads', []).
50
51:- '$extend_file_search_path'/1use_system_module( '$_yio', []).
52
53/**
54YAP can save and read images of its current state to files, known as
55saved states. It is possible to save the entire state or just a module
56or a file. Notice that saved states in YAP depend on the architecture
57where they were made, and may also depend on the version of YAP being
58saved.
59
60YAP always tries to find saved states from the current directory
61first. If it cannot it will use the environment variable [YAPLIBDIR](@ref YAPLIBDIR), if
62defined, or search the default library directory.
63
64*/
65
66/** @pred save_program(+ _F_)
67Saves the current state of the data-base in file _F_ .
68
69The result is a resource archive containing a saved state that
70expresses all Prolog data from the running program and all
71user-defined resources. Depending on the stand_alone option, the
72resource is headed by the emulator, a Unix shell script or nothing.
73
74**/
75use_system_module:save_program(File) :-
76 qsave_program(File).
77
78/** @pred save_program(+ _F_, : _G_)
79
80Saves an image of the current state of the YAP database in file
81 _F_, and guarantee that execution of the restored code will start by
82trying goal _G_.
83**/
84qsave_program:qsave_program(File) :-
85 '$save_program_status'([], qsave_program(File)),
86 open(File, write, S, [type(binary)]),
87 '$qsave_program'(S),
88 close(S).
89
90/** @pred qsave_program(+ _F_, Opts)
91
92Saves an image of the current state of the YAP database in file
93 _F_, currently the options in _Opts_ are ignored:
94
95 + stack(+ _KBytes_)
96 Limit for the local and global stack.
97
98 + trail(+ _KBytes_)
99 Limit for the trail stack.
100
101 + goal(: _Callable_)
102 Initialization goal for the new executable (see `-g`).
103
104 + init_file(+ _Atom_)
105 Default initialization file for the new executable. See `-f`.
106
107*/
108qsave_program(File, Opts) :-
109 '$save_program_status'(Opts, qsave_program(File,Opts)),
110 open(File, write, S, [type(binary)]),
111 '$qsave_program'(S),
112 % make sure we're not going to bootstrap from this file.
113 close(S).
114
115/** @pred save_program(+ _F_, : _G_)
116
117Saves an image of the current state of the YAP database in file
118 _F_, and guarantee that execution of the restored code will start by
119trying goal _G_.
120**/
121save_program(_File, Goal) :-
122 recorda('$restore_goal', Goal ,_R),
123 recorda.
124save_program(File, _Goal) :-
125 qsave_program(File).
126
127/** @pred qend_program
128
129 Saves an image of the current state of the YAP database in default
130 filee, usually `startup.yss`.
131 **/
132qsave_program :-
133 module(user),
134 qsave_program('startup.yss'),
135 halt(0).
136
137'$save_program_status'(Flags, G) :-
138 findall(F-V, '$x_yap_flag'(F,V),L),
139 recordz('$program_state',L,_),
140 '$cvt_qsave_flags'(Flags, G),
141 '$cvt_qsave_flags'.
142'$save_program_status'(_Flags, _G).
143
144'$cvt_qsave_flags'(Flags, G) :-
145 nonvar(Flags),
146 strip_module(Flags, M, LFlags),
147 '$skip_list'(_Len, LFlags, []),
148 '$cvt_qsave_lflags'(LFlags, G, M).
149'$cvt_qsave_flags'(Flags, G,_OFlags) :-
150 var(Flags),
151 '$do_error'(instantiation_error,G).
152'$cvt_qsave_flags'(Flags, G,_OFlags) :-
153 '$do_error'(type_error(list,Flags),G).
154
155'$cvt_qsave_lflags'([], _, _).
156'$cvt_qsave_lflags'([Flag|Flags], G, M) :-
157 '$cvt_qsave_flag'(Flag, G, M),
158 '$cvt_qsave_lflags'(Flags, G, M).
159
160'$cvt_qsave_flag'(Flag, G, _) :-
161 var(Flag), var,
162 '$do_error'(instantiation_error,G).
163'$cvt_qsave_flag'(local(B), G, _) :- '$cvt_qsave_flag',
164 ( number(B) ->
165 (
166 B > 0 -> recordz('$restore_flag',local(B),_) ;
167 B =:= 0 -> recordz ;
168 '$do_error'(domain_error(not_less_than_zero,B),G))
169 ;
170 '$do_error'(type_error(integer,B),G)
171 ).
172'$cvt_qsave_flag'(global(B), G, _) :- '$cvt_qsave_flag',
173 ( number(B) ->
174 (
175 B > 0 -> recordz('$restore_flag',global(B),_) ;
176 B =:= 0 -> recordz ;
177 '$do_error'(domain_error(not_less_than_zero,B),G))
178 ;
179 '$do_error'(type_error(integer,B),G)
180 ).
181'$cvt_qsave_flag'(stack(B), G, _) :- '$cvt_qsave_flag',
182 ( number(B) ->
183 (
184 B > 0 -> recordz('$restore_flag',stack(B),_) ;
185 B =:= 0 -> recordz ;
186 '$do_error'(domain_error(not_less_than_zero,B),G))
187 ;
188 '$do_error'(type_error(integer,B),G)
189 ).
190'$cvt_qsave_flag'(trail(B), G, _) :- '$cvt_qsave_flag',
191 ( number(B) ->
192 (
193 B > 0 -> recordz('$restore_flag',trail(B),_) ;
194 B =:= 0 -> recordz ;
195 '$do_error'(domain_error(not_less_than_zero,B),G))
196 ;
197 '$do_error'(type_error(integer,B),G)
198 ).
199'$cvt_qsave_flag'(goal(B), G, M) :- '$cvt_qsave_flag',
200 ( must_be_callable(B) ->
201 strip_module(M:B, M1, G1),
202 recordz('$restore_flag',goal(M1:G1),_)
203 ;
204 strip_module(M:B, M1, G1),
205 '$do_error'(type_error(callable,G1),G)
206 ).
207'$cvt_qsave_flag'(toplevel(B), G, M) :- '$cvt_qsave_flag',
208 ( must_be_callable(B) ->
209 strip_module(M:B, M1, G1),
210 recordz('$restore_flag',toplevel(M1:G1),_)
211 ;
212 strip_module(M:B, M1, G1),
213 '$do_error'(type_error(callable,G1),G)
214 ).
215'$cvt_qsave_flag'(init_file(B), G, M) :- '$cvt_qsave_flag',
216 ( atom(B) ->
217 recordz('$restore_flag', init_file(M:B), _)
218 ;
219 '$do_error'(type_error(atom,B),G)
220 ).
221%% '$cvt_qsave_flag'(autoload(_B), G, autoload(_B)).
222%% '$cvt_qsave_flag'(op(_B), G, op(_B)).
223%% '$cvt_qsave_flag'(stand_alone(_B), G, stand_alone(_B)).
224%% '$cvt_qsave_flag'(emulator(_B), G, emulator(_B)).
225%% '$cvt_qsave_flag'(foreign(_B), G, foreign(_B)).
226'$cvt_qsave_flag'(Opt, G, _M) :-
227 '$do_error'(domain_error(qsave_program,Opt), G).
228
229% there is some ordering between flags.
230'$x_yap_flag'(language, V) :-
231 yap_flag(language, V).
232'$x_yap_flag'(M:P, V) :-
234 yap_flag(M:P, V).
235'$x_yap_flag'(X, V) :-
236 prolog_flag_property(X, [access(read_write)]),
237 atom(X),
238 X \= atom, % different machines will have different needs,
239 X \= atom,
240 X \= atom,
241 X \= atom,
242 X \= atom,
243 X \= atom,
244 X \= atom,
245 X \= atom,
246 X \= atom,
247 yap_flag(X, V),
248 yap_flag.
249
250qsave_file(F0) :-
251 ensure_loaded( F0 ),
252 absolute_file_name( F0, File, [expand(true),file_type(prolog),access(read),file_errors(fail),solutions(first)]),
253 absolute_file_name( F0, State, [expand(true),file_type(qly)]),
254 '$qsave_file_'(File, State).
255
256/** @pred qsave_file(+ _File_, +_State_)
257
258Saves an image of all the information compiled by the system from file _F_ to _State_.
259This includes modules and predicates eventually including multi-predicates.
260**/
261qsave_file(F0, State) :-
262 ensure_loaded( F0 ),
263 absolute_file_name( F0, File, [expand(true),file_type(prolog),access(read),file_errors(fail),solutions(first)]),
264 '$qsave_file_'(File, State).
265
266
267'$qsave_file_'(File, UserF, _State) :-
268 ( File == user_input -> Age = 0 ; time_file64(File, Age) ),
269 '$current_module'(M),
270 assert(user:'$file_property'( '$lf_loaded'( UserF, Age, M) ) ),
271 '$set_owner_file'( '$file_property'( _ ), user, File ),
272 '$set_owner_file'.
273'$qsave_file_'(File, UserF, _State) :-
274 recorded('$lf_loaded','$lf_loaded'( File, M, Reconsult, UserFile, OldF, Line, Opts), _),
275 assert(user:'$file_property'( '$lf_loaded'( UserF, M, Reconsult, UserFile, OldF, Line, Opts) ) ),
276 '$set_owner_file'( '$file_property'( _ ), user, File ),
277 '$set_owner_file'.
278'$qsave_file_'(File, _UserF, _State) :-
279 recorded('$directive',directive( File, M:G, Mode, VL, Pos ), _),
280 assert(user:'$file_property'( directive( M:G, Mode, VL, Pos ) ) ),
281 '$set_owner_file'('$file_property'( _ ), user, File ),
282 '$set_owner_file'.
283'$qsave_file_'(File, _UserF, _State) :-
284 '$fetch_multi_files_file'(File, MultiFiles),
285 assert(user:'$file_property'( multifile(MultiFiles ) ) ),
286 '$set_owner_file'('$file_property'( _ ), user, File ),
287 '$set_owner_file'.
288'$qsave_file_'( File, _UserF, State ) :-
289 (
290 is_stream( State )
291 ->
292 '$qsave_file_preds'(State, File)
293 ;
294 open(State, write, S, [type(binary)]),
295 '$qsave_file_preds'(S, File),
296 close(S)
297 ),
298 user:'$file_property'/1abolish().
299
300'$fetch_multi_files_file'(File, Multi_Files) :-
301 setof(Info, '$fetch_multi_file_module'(File, Info), Multi_Files).
302
303'$fetch_multi_file_file'(FileName, (M:G :- Body)) :-
304 recorded('$multifile_defs','$defined'(FileName,Name,Arity,M), _),
305 functor(G, Name, Arity ),
306 clause(M:G, Body, ClauseRef),
307 clause_property(ClauseRef, file(FileName) ).
308
309
310/** @pred qsave_module(+ _Module_, +_State_)
311Saves an image of all the information compiled by the systemm on module _F_ to _State_.
312**/
313
314qsave_module(Mod, OF) :-
315 recorded('$module', '$module'(_F,Mod,Source,Exps,L), _),
316 '$fetch_parents_module'(Mod, Parents),
317 '$fetch_imports_module'(Mod, Imps),
318 '$fetch_multi_files_module'(Mod, MFs),
319 '$fetch_meta_predicates_module'(Mod, Metas),
320 '$fetch_module_transparents_module'(Mod, ModTransps),
321 '$fetch_term_expansions_module'(Mod, TEs),
322 '$fetch_foreigns_module'(Mod, Foreigns),
323 asserta(Mod:'@mod_info'(Source, Exps, MFs, L, Parents, Imps, Metas, ModTransps, Foreigns, TEs)),
324 open(OF, write, S, [type(binary)]),
325 '$qsave_module_preds'(S, Mod),
326 close(S),
327 '@mod_info'/10abolish(Mod:),
328 abolish.
329qsave_module(_, _).
330
331/** @pred qsave_module(+ Module x)
332
333Saves an image of all the information compiled by the systemm on
334module _F_ to a file _State.qly_ in the current directory.
335
336**/
337
338qsave_module(Mod) :-
339 atom_concat(Mod,'.qly',OF),
340 qsave_module(Mod, OF).
341
342/**
343 @pred restore(+ _F_)
344Restores a previously saved state of YAP from file _F_.
345
346*/
347restore(File) :-
348 open(File, read, S, [type(binary)]),
349 '$qload_program'(S),
350 close(S).
351
352/**
353@pred qload_module(+ _M_)
354
355Restores a previously save image of module _M_. This built-in searches
356for a file M.qly or M according to the rules for qly files.
357
358The q_load_module/1 built-in tries to reload any modules it imports
359from and any foreign files that had been loaded with the original
360module. It tries first reloading from qly images, but if they are not
361available it tries reconsulting the source file.
362
363*/
364qload_module(Mod) :-
365 StartMsg = qload_module,
366 EndMsg = qload_module,
367 '$current_module'(SourceModule, Mod),
368 H0 is '$current_module', '$cputime'(T0,_),
369 absolute_file_name( Mod, File, [expand(true),file_type(qly)]),
370 print_message(informational, loading(StartMsg, File)),
371 file_directory_name( File, Dir),
372 working_directory(OldD, Dir),
373 '$qload_module'(Mod, File, SourceModule ),
374 H is '$qload_module'-H0, '$cputime'(TF,_), T is TF-T0,
375 print_message(informational, loaded(EndMsg, File, Mod, T, H)),
376 '$current_module'(_, SourceModule),
377 working_directory(_, OldD).
378
379'$qload_module'(Mod, S, SourceModule) :-
380 is_stream( S ), is_stream,
381 '$q_header'( S, Type ),
382 stream_property( S, file_name( File )),
383 ( Type == module ->
384 '$qload_module'(S , Mod, File, SourceModule)
385 ;
386 Type == '$qload_module' ->
387 '$qload_file'(S, File)
388 ).
389'$qload_module'(Mod, File, SourceModule) :-
390 open(File, read, S, [type(binary)]),
391 %check verifies if a saved state;
392 '$q_header'( S, Type ), '$q_header',
393 ( Type == module ->
394 '$qload_module'(S , Mod, File, SourceModule)
395 ;
396 Type == '$qload_module' ->
397 '$qload_file'(S, File)
398 ),
399 !,
400 close(S).
401
402'$qload_module'(_S, Mod, _File, _SourceModule) :-
403 unload_module( Mod ), unload_module.
404'$qload_module'(S, _Mod, _File, _SourceModule) :-
405 '$qload_module_preds'(S), '$qload_module_preds'.
406
407
408'$qload_module'(_S, Mod, File, SourceModule) :-
409 Mod:'@mod_info'(F, Exps, MFs, Line,Parents, Imps, Metas, ModTransps, Foreigns, TEs),
410 %abolish(Mod:'@mod_info'/10),
411 recorda('$module', '$module'(File, Mod, F, Exps, Line), _),
412 '$install_parents_module'(Mod, Parents),
413 '$install_imports_module'(Mod, Imps, []),
414 '$install_multi_files_module'(Mod, MFs),
415 '$install_meta_predicates_module'(Mod, Metas),
416 '$install_foreigns_module'(Mod, Foreigns),
417 '$install_module_transparents_module'(Mod, ModTransps),
418 '$install_term_expansions_module'(Mod, TEs),
419 % last, export everything to the host: if the loading crashed you didn't actually do
420 % no evil.
421 '$convert_for_export'(all, Exps, Mod, SourceModule, TranslationTab, _AllExports0),
422 '$add_to_imports'(TranslationTab, Mod, SourceModule). % insert ops, at least for now
423
424'$fetch_imports_module'(Mod, Imports) :-
425 findall(Info, '$fetch_import_module'(Mod, Info), Imports).
426
427% detect an import that is local to the module.
428'$fetch_import_module'(Mod, '$impcort'(Mod0,Mod,G0,G,N,K) - S) :-
429 recorded('$import', '$import'(Mod0,Mod,G0,G,N,K), _),
430 ( recorded('$module','$module'(_, Mod0, S, _, _), _) -> recorded ; S = recorded ).
431
432'$fetch_parents_module'(Mod, Parents) :-
433 findall(Parent, prolog:'$parent_module'(Mod,Parent), Parents).
434
435'$fetch_module_transparents_module'(Mod, Module_Transparents) :-
436 findall(Info, '$fetch_module_transparent_module'(Mod, Info), Module_Transparents).
437
438% detect an module_transparenterator that is local to the module.
439'$fetch_module_transparent_module'(Mod, '$module_transparent'(F,Mod,N,P)) :-
440 '$fetch_module_transparent_module':'$module_transparent'(F,Mod0,N,P), Mod0 == Mod.
441
442'$fetch_meta_predicates_module'(Mod, Meta_Predicates) :-
443 findall(Info, '$fetch_meta_predicate_module'(Mod, Info), Meta_Predicates).
444
445% detect a meta_predicate that is local to the module.
446'$fetch_meta_predicate_module'(Mod, meta_predicate( Mod:P)) :-
447 recorded('$m',meta_predicate(M,P),_),
448 M==Mod.
449
450'$fetch_multi_files_module'(Mod, Multi_Files) :-
451 findall(Info, '$fetch_multi_file_module'(Mod, Info), Multi_Files).
452
453% detect an multi_file that is local to the module.
454'$fetch_multi_file_module'(Mod, '$defined'(FileName,Name,Arity,Mod)) :-
455 recorded('$multifile_defs','$defined'(FileName,Name,Arity,Mod), _).
456'$fetch_multi_file_module'(Mod, '$mf_clause'(FileName,_Name,_Arity,Mod,Clause), _) :-
457 recorded('$mf','$mf_clause'(FileName,_Name,_Arity,Mod,ClauseRef), _),
458 instance(ClauseRef, Clause ).
459
460'$fetch_term_expansions_module'(Mod, TEs) :-
461 findall(Info, '$fetch_term_expansion_module'(Mod, Info), TEs).
462
463% detect an term_expansionerator that is local to the module.
464'$fetch_term_expansion_module'(Mod, ( user:term_expansion(G, GI) :- Bd )) :-
465 clause( user:term_expansion(G, GI), Bd, _),
466 strip_module(G, Mod, _).
467% detect an term_expansionerator that is local to the module.
468'$fetch_term_expansion_module'(Mod, ( system:term_expansion(G, GI) :- Bd )) :-
469 clause( system:term_expansion(G, GI), Bd, _),
470 strip_module(G, Mod, _).
471% detect an term_expansionerator that is local to the module.
472'$fetch_term_expansion_module'(Mod, ( user:goal_expansion(G, CurMod, GI) :- Bd )) :-
473 clause( user:goal_expansion(G, CurMod, GI), Bd, _),
474 Mod == CurMod.
475% detect an term_expansionerator that is local to the module.
476'$fetch_term_expansion_module'(Mod, ( user:goal_expansion(G, GI) :- Bd )) :-
477 clause( user:goal_expansion(G, GI), Bd, _),
478 strip_module(G, Mod, _).
479% detect an term_expansionerator that is local to the module.
480'$fetch_term_expansion_module'(Mod, ( system:goal_expansion(G, GI) :- Bd )) :-
481 clause( system:goal_expansion(G, GI), Bd, _),
482 strip_module(G, Mod, _).
483
484'$fetch_foreigns_module'(Mod, Foreigns) :-
485 findall(Info, '$fetch_foreign_module'(Mod, Info), Foreigns).
486
487% detect an term_expansionerator that is local to the module.
488'$fetch_foreign_module'(Mod,Foreign) :-
489 recorded( '$foreign', Mod:Foreign, _).
490
491'$install_term_expansions_module'(_, []).
492'$install_term_expansions_module'(Mod, [TE|TEs]) :-
493 assert(TE),
494 '$install_term_expansions_module'(Mod, TEs).
495
496'$install_imports_module'(_, [], Fs0) :-
497 sort(Fs0, Fs),
498 '$restore_load_files'(Fs).
499'$install_imports_module'(Mod, [Import-F|Imports], Fs0) :-
500 recordz('$import', Import, _),
501 arg(1, Import, M),
502 '$install_imports_module'(Mod, Imports, [M-F|Fs0]).
503
504'$restore_load_files'([]).
505'$restore_load_files'([M-F0|Fs]) :-
506 (
507 absolute_file_name( M,_File, [expand(true),file_type(qly),access(read),file_errors(fail)])
508 ->
509 qload_module(M)
510 ;
511
512 load_files(M:F0,[silent(true)])
513 ),
514 '$restore_load_files'(Fs).
515
516'$install_parents_module'(_, []).
517'$install_parents_module'(Mod, [Parent|Parents]) :-
518 assert(prolog:Parent),
519 '$install_parents_module'(Mod, Parents).
520
521'$install_module_transparents_module'(_, []).
522'$install_module_transparents_module'(Mod, [Module_Transparent|Module_Transparents]) :-
523 assert(prolog:Module_Transparent),
524 '$install_module_transparents_module'(Mod, Module_Transparents).
525
526'$install_meta_predicates_module'(_, []).
527'$install_meta_predicates_module'(Mod, [Meta_Predicate|Meta_Predicates]) :-
528 call(Meta_Predicate),
529 '$install_meta_predicates_module'(Mod, Meta_Predicates).
530
531'$install_multi_files_module'(_, []).
532'$install_multi_files_module'(Mod, [Multi_File|Multi_Files]) :-
533 recordz('$multifile_defs',Multi_File, _),
534 '$install_multi_files_module'(Mod, Multi_Files).
535
536'$install_foreigns_module'(_, []).
537'$install_foreigns_module'(Mod, [Foreign|Foreigns]) :-
538 '$do_foreign'(Foreign, Foreigns),
539 '$install_foreigns_module'(Mod, Foreigns).
540
541'$do_foreign'('$foreign'(Objs,Libs,Entry), _) :-
542 load_foreign_files(Objs,Libs,Entry).
543'$do_foreign'('$swi_foreign'(File, Opts, Handle), More) :-
544 open_shared_object(File, Opts, Handle, NewHandle),
545 '$init_foreigns'(More, NewHandle).
546'$do_foreign'('$swi_foreign'(_,_), _More).
547
548'$init_foreigns'([], _Handle, _NewHandle).
549'$init_foreigns'(['$swi_foreign'( Handle, Function )|More], Handle, NewHandle) :-
550 '$init_foreigns',
551 call_shared_object_function( NewHandle, Function),
552 '$init_foreigns'(More, Handle, NewHandle).
553'$init_foreigns'([_|More], Handle, NewHandle) :-
554 '$init_foreigns'(More, Handle, NewHandle).
555
556/**
557@pred qload_file(+ _F_)
558
559Restores a previously saved state of YAP contaianing a qly file _F_.
560
561*/
562qload_file( F0 ) :-
563 StartMsg = qload_file,
564 EndMsg = qload_file,
565 '$current_module'( SourceModule ),
566 H0 is '$current_module',
567 '$cputime'(T0,_),
568 ( is_stream( F0 )
569 ->
570 stream_property(F0, file_name(File) ),
571 File = FilePl,
572 S = File
573 ;
574 absolute_file_name( F0, File, [expand(true),file_type(qly)]),
575 absolute_file_name( F0, FilePl, [expand(true),file_type(prolog)]),
576 unload_file( FilePl ),
577 open(File, read, S, [type(binary)])
578 ),
579 print_message(informational, loading(StartMsg, File)),
580 file_directory_name(File, DirName),
581 working_directory(OldD, DirName),
582 '$q_header'( S, Type ),
583 '$lf_option'(last_opt, LastOpt),
584 functor( TOpts, opt, LastOpt ),
585 '$lf_default_opts'(1, LastOpt, TOpts),
586 ( Type == module ->
587 '$qload_module'(S , Mod, File, SourceModule)
588 ;
589 Type == '$qload_module' ->
590 '$qload_file'(S, SourceModule, File, FilePl, F0, all, TOpts)
591 ),
592 close(S),
593 working_directory( _, OldD),
594 H is working_directory-H0, '$cputime'(TF,_), T is TF-T0,
595 '$current_module'(Mod, Mod ),
596 print_message(informational, loaded(EndMsg, File, Mod, T, H)),
597 '$exec_initialization_goals'.
598
599'$qload_file'(_S, SourceModule, _F, FilePl, _F0, _ImportList, _TOpts) :-
600 recorded('$source_file','$source_file'( FilePl, _Age, SourceModule), _),
601 recorded.
602'$qload_file'(_S, SourceModule, _F, FilePl, _F0, _ImportList, _TOpts) :-
603 ( FilePl == user_input -> Age = 0 ; time_file64(FilePl, Age) ),
604 recordaifnot('$source_file','$source_file'( FilePl, Age, SourceModule), _),
605 recordaifnot.
606'$qload_file'(S, _SourceModule, _File, _FilePl, _F0, _ImportList, _TOpts) :-
607 '$qload_file_preds'(S),
608 '$qload_file_preds'.
609'$qload_file'(_S, SourceModule, F, _FilePl, _F0, _ImportList, _TOpts) :-
610 '$qload_file':'$file_property'( '$lf_loaded'( F, Age, _ ) ),
611 recordaifnot('$source_file','$source_file'( F, Age, SourceModule), _),
612 recordaifnot.
613'$qload_file'(_S, _SourceModule, _File, FilePl, F0, _ImportList, _TOpts) :-
614 b_setval('$user_source_file', F0 ),
615 '$ql_process_directives'( FilePl ),
616 '$ql_process_directives'.
617'$qload_file'(_S, SourceModule, _File, FilePl, _F0, ImportList, TOpts) :-
618 '$import_to_current_module'(FilePl, SourceModule, ImportList, _, TOpts).
619
620'$ql_process_directives'( FilePl ) :-
621 '$ql_process_directives':'$file_property'( '$lf_loaded'( FilePl, M, Reconsult, UserFile, OldF, Line, Opts) ),
622 recorda('$lf_loaded','$lf_loaded'( FilePl, M, Reconsult, UserFile, OldF, Line, Opts), _),
623 recorda.
624'$ql_process_directives'( _FilePl ) :-
625 '$ql_process_directives':'$file_property'( multifile( List ) ),
626 '$file_property':member( Clause, List ),
627 assert( Clause ),
628 assert.
629'$ql_process_directives'( FilePl ) :-
630 '$ql_process_directives':'$file_property'( directive( MG, _Mode, VL, Pos ) ),
631 '$set_source'( FilePl, Pos ),
632 '$yap_strip_module'(MG, M, G),
633 '$process_directive'(G, reconsult, M, VL, Pos),
634 '$process_directive'.
635'$ql_process_directives'( _FilePl ) :-
636 user:'$file_property'/1abolish().
637
638%% @}
639
abolish(+ PredSpec)
absolute_file_name( -File:atom, +Path:atom, +Options:list)
clause(+ H, B,- R)
close(+ S)
module(+M)
must_be_callable( ?_Goal_ )
open(+ F,+ M,- S,+ Opts)
recordaifnot(+ K, T,- R)
sort(+ L,- S)
stream_property( Stream, Prop )
Definition: top.yap:2
working_directory( ?_CurDir_,? NextDir)
yap_flag( ?Param, ?Value)
assert(+ C)
asserta(+ C)
instance(+ R,- T)
recordz(+ K, T,- R)
call_shared_object_function(+ Handle, + Function)
load_foreign_files( Files, Libs, InitRoutine)
current_module( ? Mod:atom)
qload_file(+ F)
qload_module(+ M)
'$cvt_qsave_flag'(autoload(_B), G, autoload(_B))
Definition: qly.yap:132
qsave_module(+ Module x)
qsave_module(+ Module, +_State_)
qsave_program(+ F, Opts)
restore(+ F)
YAP can save and read images of its current state to files, known as saved states.
save_program(+ F, : G)
findall( T,+ G,- L)
Definition: setof.yap:70
setof( X,+ P,- B)
call( 0:P )
halt(+ I)
prolog_flag_property(+ Flag,+ Prooperties)
print_message(+ Severity, +Term)
ensure_loaded(+ F)
load_files(+_Files_, +_Options_)
arg(+ N,+ T, A)
atom( T)
functor( T, F, N)
nonvar( T)
number( T)
var( T)
member(?Element, ?Set) is true when Set is a list, and Element occurs in it