| 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 2 | % |
|---|
| 3 | % Logtalk - Open source object-oriented logic programming language |
|---|
| 4 | % Release 2.31.1 |
|---|
| 5 | % |
|---|
| 6 | % integration code for SWI Prolog 3.3.x and later versions to compile and |
|---|
| 7 | % load Logtalk files using SWI Prolog consult/1 and to support edit/1 and |
|---|
| 8 | % make/0 |
|---|
| 9 | % |
|---|
| 10 | % last updated: August 24, 2006 |
|---|
| 11 | % |
|---|
| 12 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | :- dynamic(prolog_load_file/2). |
|---|
| 17 | :- multifile(prolog_load_file/2). |
|---|
| 18 | |
|---|
| 19 | user:prolog_load_file(_:Spec, Options) :- |
|---|
| 20 | ( atom(Spec) -> |
|---|
| 21 | expand_file_name(Spec, [SpecExp]), |
|---|
| 22 | absolute_file_name(SpecExp, [extensions([lgt]), access(read), file_errors(fail)], Path) |
|---|
| 23 | ; Spec =.. [Library, File], |
|---|
| 24 | '$lgt_expand_library_path'(Library, LibPath), |
|---|
| 25 | atom_concat(LibPath, File, Spec2), |
|---|
| 26 | expand_file_name(Spec2, [SpecExp]), |
|---|
| 27 | absolute_file_name(SpecExp, [extensions([lgt]), access(read), file_errors(fail)], Path) |
|---|
| 28 | ), |
|---|
| 29 | file_directory_name(Path, Dir), |
|---|
| 30 | file_base_name(Path, BaseName), |
|---|
| 31 | file_name_extension(Entity, _, BaseName), |
|---|
| 32 | working_directory(Old, Dir), |
|---|
| 33 | '$lgt_filter_compiler_options'(Options, Options2), |
|---|
| 34 | call_cleanup(logtalk_load(Entity, Options2), working_directory(_, Old)). |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | '$lgt_filter_compiler_options'([], []). |
|---|
| 38 | |
|---|
| 39 | '$lgt_filter_compiler_options'([Option| Options], [Option| Options2]) :- |
|---|
| 40 | functor(Option, Functor, 1), |
|---|
| 41 | '$lgt_valid_flag'(Functor), |
|---|
| 42 | !, |
|---|
| 43 | '$lgt_filter_compiler_options'(Options, Options2). |
|---|
| 44 | |
|---|
| 45 | '$lgt_filter_compiler_options'([_| Options], Options2) :- |
|---|
| 46 | '$lgt_filter_compiler_options'(Options, Options2). |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | :- multifile(prolog_edit:locate/3). |
|---|
| 51 | |
|---|
| 52 | prolog_edit:locate(Name, source_file(Source), [file(Source)]) :- |
|---|
| 53 | atom(Name), |
|---|
| 54 | source_file(Path), |
|---|
| 55 | file_base_name(Path, File), |
|---|
| 56 | file_name_extension(Name, 'pl', File), |
|---|
| 57 | file_name_extension(Plain, _, Path), |
|---|
| 58 | file_name_extension(Plain, 'lgt', Source), |
|---|
| 59 | exists_file(Source), |
|---|
| 60 | !. |
|---|