| 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 2 | % |
|---|
| 3 | % Logtalk - Open source object-oriented logic programming language |
|---|
| 4 | % Release 2.33.3 |
|---|
| 5 | % |
|---|
| 6 | % Copyright (c) 1998-2008 Paulo Moura. All Rights Reserved. |
|---|
| 7 | % Logtalk is free software. You can redistribute it and/or modify |
|---|
| 8 | % it under the terms of the "Artistic License 2.0" as published by |
|---|
| 9 | % The Perl Foundation. Consult the "LICENSE.txt" file for details. |
|---|
| 10 | % |
|---|
| 11 | % |
|---|
| 12 | % integration code for SWI Prolog 3.3.x and later versions to compile and |
|---|
| 13 | % load Logtalk files using SWI Prolog consult/1 and to support edit/1 and |
|---|
| 14 | % make/0 |
|---|
| 15 | % |
|---|
| 16 | % last updated: June 29, 2008 |
|---|
| 17 | % |
|---|
| 18 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | :- dynamic(prolog_load_file/2). |
|---|
| 23 | :- multifile(prolog_load_file/2). |
|---|
| 24 | |
|---|
| 25 | user:prolog_load_file(_:Spec, Options) :- |
|---|
| 26 | \+ '$lgt_member'(must_be_module(true), Options), % exclude calls to use_module/1-2 |
|---|
| 27 | ( atom(Spec) -> |
|---|
| 28 | expand_file_name(Spec, [SpecExp]), |
|---|
| 29 | absolute_file_name(SpecExp, [extensions([lgt]), access(read), file_errors(fail)], Path) |
|---|
| 30 | ; Spec =.. [Library, File], |
|---|
| 31 | '$lgt_expand_library_path'(Library, LibPath), |
|---|
| 32 | atom_concat(LibPath, File, Spec2), |
|---|
| 33 | expand_file_name(Spec2, [SpecExp]), |
|---|
| 34 | absolute_file_name(SpecExp, [extensions([lgt]), access(read), file_errors(fail)], Path) |
|---|
| 35 | ), |
|---|
| 36 | file_directory_name(Path, Dir), |
|---|
| 37 | file_base_name(Path, BaseName), |
|---|
| 38 | file_name_extension(Entity, _, BaseName), |
|---|
| 39 | working_directory(Old, Dir), |
|---|
| 40 | '$lgt_filter_compiler_options'(Options, Options2), |
|---|
| 41 | call_cleanup(logtalk_load(Entity, Options2), working_directory(_, Old)). |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | '$lgt_filter_compiler_options'([], []). |
|---|
| 45 | |
|---|
| 46 | '$lgt_filter_compiler_options'([Option| Options], [Option| Options2]) :- |
|---|
| 47 | functor(Option, Functor, 1), |
|---|
| 48 | '$lgt_valid_flag'(Functor), |
|---|
| 49 | !, |
|---|
| 50 | '$lgt_filter_compiler_options'(Options, Options2). |
|---|
| 51 | |
|---|
| 52 | '$lgt_filter_compiler_options'([_| Options], Options2) :- |
|---|
| 53 | '$lgt_filter_compiler_options'(Options, Options2). |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | :- multifile(prolog_edit:locate/3). |
|---|
| 58 | |
|---|
| 59 | prolog_edit:locate(Name, source_file(Source), [file(Source)]) :- |
|---|
| 60 | atom(Name), |
|---|
| 61 | source_file(Path), |
|---|
| 62 | file_base_name(Path, File), |
|---|
| 63 | file_name_extension(Name, 'pl', File), |
|---|
| 64 | file_name_extension(Plain, _, Path), |
|---|
| 65 | file_name_extension(Plain, 'lgt', Source), |
|---|
| 66 | exists_file(Source), |
|---|
| 67 | !. |
|---|