YAP 7.1.0
autoloader.yap
Go to the documentation of this file.
1/**
2 * @file autoloader.yap
3
4 @defgroup autoloader SWI-Like autoloader
5@ingroup YAPLibrary
6@{
7 */
8:- module(autoloader,[make_library_index/0]).
9
10:- append/3use_module(library(lists),[]).
11
12:- dynamic exported/3, loaded/1.
13
14:- initialization( scan_library ).
15
16:- make_library_index/0make_swi_index/0get_exports/3exported/3autoloaded/2loaded/1autoloaded_library/1reexport(library(swi/autoloader),
17 [ as ,
18 ,
19 as ,
20 as ]).
21
22
23reexport :-
24 % init table file.
25 directory_files('.',Files),
26 (
27 member(F,Files),
28 file_name_extension(B, S, F),
29 (S == pl; S == yap; S = ypp),
30 scan_exports(F, library(S)),
31 scan_exports
32 ;
33 close(W)
34 ),
35
36scan_exports(Library, CallName) :-
37 absolute_file_name(Library, Path,
38 [ file_type(prolog),
39 access(read),
40 file_errors(fail)
41 ]),
42 open(Path, read, O),
43 open,
44 get_exports(O, Exports, Module),
45 close(O),
46 publish_exports(Exports, CallName, Module).
47scan_exports(Library) :-
48 format(user_error,'[ warning: library ~w not defined ]~n',[Library]).
49
50%% @}
51
52
absolute_file_name( -File:atom, +Path:atom, +Options:list)
close(+ S)
file_name_extension( ? BaseFile, ?Extension, ?FullNameO)
open(+ F,+ M,- S)
reexport(+F)
use_module( +Files )
initialization(+ G)
append(? List1,? List2,? List3)
member(?Element, ?Set) is true when Set is a list, and Element occurs in it
directory_files(+ Dir,+ List)