| 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 2 | % |
|---|
| 3 | % Logtalk - Object oriented extension to Prolog |
|---|
| 4 | % Release 2.21.0 |
|---|
| 5 | % |
|---|
| 6 | % integration code for SWI Prolog 3.3.x and later versions |
|---|
| 7 | % to compile and load Logtalk files using SWI Prolog consult/1 |
|---|
| 8 | % |
|---|
| 9 | % last updated: August 3, 2004 |
|---|
| 10 | % |
|---|
| 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | :- dynamic(prolog_load_file/2). |
|---|
| 15 | :- multifile(prolog_load_file/2). |
|---|
| 16 | |
|---|
| 17 | user:prolog_load_file(_:Spec, Options) :- |
|---|
| 18 | absolute_file_name(Spec, [extensions([lgt, mlgt]), access(read), file_errors(fail)], Path), |
|---|
| 19 | file_directory_name(Path, Dir), |
|---|
| 20 | file_base_name(Path, File), |
|---|
| 21 | file_name_extension(Entity, _, File), |
|---|
| 22 | working_directory(Old, Dir), |
|---|
| 23 | '$lgt_filter_compiler_options'(Options, Options2), |
|---|
| 24 | call_cleanup(logtalk_load(Entity, Options2), working_directory(_, Old)). |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | '$lgt_filter_compiler_options'([], []). |
|---|
| 28 | |
|---|
| 29 | '$lgt_filter_compiler_options'([Option| Options], [Option| Options2]) :- |
|---|
| 30 | functor(Option, Functor, 1), |
|---|
| 31 | '$lgt_valid_flag'(Functor), |
|---|
| 32 | !, |
|---|
| 33 | '$lgt_filter_compiler_options'(Options, Options2). |
|---|
| 34 | |
|---|
| 35 | '$lgt_filter_compiler_options'([_| Options], Options2) :- |
|---|
| 36 | '$lgt_filter_compiler_options'(Options, Options2). |
|---|