root/tags/lgt2306/configs/ciao_aux.config

Revision 3867, 13.9 KB (checked in by pmoura, 16 months ago)

Changed handling of the encoding/1 directive by the Logtalk compiler in order to improve compatibility with YAP and SICStus Prolog. Removed from the config files the now obsolete '$lgt_set_stream_encoding'/2 predicate definition. Renamed the compiler option "supports_encoding_dir" to "encoding_directive" and changed its possible values to "unsupported", "full" (used in both Logtalk source files and compiler generated Prolog files), and "source" (used only in Logtalk source files).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%
3%  Logtalk - Open source object-oriented logic programming language
4%  Release 2.30.6
5%
6%  configuration file for CIAO Prolog 1.8p2 and later versions
7%
8%  last updated: September 28, 2007
9%
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
12
13:- use_package(iso).
14
15:- use_package(runtime_ops).
16:- use_package(hiord).
17
18:- use_module(library(compiler)).
19:- use_module(library(system)).
20:- use_module(library(prolog_sys)).
21:- use_module(library(sort)).
22:- use_module(library(filenames)).
23
24:- include(engine(builtin_exports)).
25
26:- set_prolog_flag(multi_arity_warnings, off).
27
28:- op(1200, xfx, [(-->)]).
29
30
31
32%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33%
34%  ISO Prolog Standard predicates that we must define because they are
35%  not built-in
36%
37%  add a clause for lgt_iso_predicate/1 declaring each ISO predicate that
38%  we must define; there must be at least one clause for this predicate
39%  whose call should fail if we don't define any ISO predicates
40%
41%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42
43
44% '$lgt_iso_predicate'(?callable).
45
46'$lgt_iso_predicate'(_) :-
47    fail.
48
49
50
51%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52%
53%  predicate properties
54%
55%  this predicate must return at least static, dynamic, and built_in
56%  properties for an existing predicate
57%
58%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59
60
61% '$lgt_predicate_property'(+callable, ?predicate_property)
62
63'$lgt_predicate_property'(Pred, built_in) :-
64    functor(Pred, Functor, Arity),
65    builtin_export(_, Functor, Arity, _).
66
67'$lgt_predicate_property'(Pred, built_in) :-
68    lgt_ciao_iso_builtin(Pred).
69
70'$lgt_predicate_property'(Pred, static) :-
71    predicate_property(Pred, compiled).
72
73'$lgt_predicate_property'(Pred, static) :-
74    functor(Pred, Functor, Arity),
75    atom_concat('user:', Functor, Functor2),
76    functor(Pred2, Functor2, Arity),
77    predicate_property(Pred2, compiled).
78
79'$lgt_predicate_property'(Pred, Prop) :-
80    predicate_property(Pred, Prop).
81
82'$lgt_predicate_property'(Pred, Prop) :-
83    functor(Pred, Functor, Arity),
84    atom_concat('user:', Functor, Functor2),
85    functor(Pred2, Functor2, Arity),
86    predicate_property(Pred2, Prop).
87
88
89lgt_ciao_iso_builtin(write(_)).
90lgt_ciao_iso_builtin(write(_, _)).
91lgt_ciao_iso_builtin(writeq(_)).
92lgt_ciao_iso_builtin(writeq(_, _)).
93lgt_ciao_iso_builtin(write_canonical(_)).
94lgt_ciao_iso_builtin(write_canonical(_, _)).
95lgt_ciao_iso_builtin(write_term(_, _)).
96lgt_ciao_iso_builtin(write_term(_, _, _)).
97
98lgt_ciao_iso_builtin(read(_)).
99lgt_ciao_iso_builtin(read(_, _)).
100lgt_ciao_iso_builtin(read_term(_, _)).
101lgt_ciao_iso_builtin(read_term(_, _, _)).
102
103lgt_ciao_iso_builtin(open(_, _, _, _)).
104lgt_ciao_iso_builtin(close(_, _)).
105lgt_ciao_iso_builtin(stream_property(_, _)).
106
107lgt_ciao_iso_builtin(op(_, _, _)).
108lgt_ciao_iso_builtin(current_op(_, _, _)).
109
110lgt_ciao_iso_builtin(_ \= _).
111lgt_ciao_iso_builtin(once(_)).
112lgt_ciao_iso_builtin(compound(_)).
113lgt_ciao_iso_builtin(sub_atom(_, _, _, _, _)).
114lgt_ciao_iso_builtin(unify_with_occurs_check(_, _)).
115
116lgt_ciao_iso_builtin(char_code(_, _)).
117lgt_ciao_iso_builtin(atom_chars(_, _)).
118lgt_ciao_iso_builtin(number_chars(_, _)).
119lgt_ciao_iso_builtin(get_byte(_)).
120lgt_ciao_iso_builtin(get_byte(_, _)).
121lgt_ciao_iso_builtin(peek_byte(_)).
122lgt_ciao_iso_builtin(peek_byte(_, _)).
123lgt_ciao_iso_builtin(put_byte(_)).
124lgt_ciao_iso_builtin(put_byte(_, _)).
125lgt_ciao_iso_builtin(get_char(_)).
126lgt_ciao_iso_builtin(get_char(_, _)).
127lgt_ciao_iso_builtin(peek_char(_)).
128lgt_ciao_iso_builtin(peek_char(_, _)).
129lgt_ciao_iso_builtin(put_char(_)).
130lgt_ciao_iso_builtin(put_char(_, _)).
131
132
133
134%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
135%
136%  meta-predicates
137%
138%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
139
140
141% call_cleanup(+callable, +callble)
142
143call_cleanup(_, _) :-
144    throw(not_supported(call_cleanup/2)).
145
146
147% forall(+callable, +callble) -- built-in
148
149forall(Generate, Test) :-
150    \+ (call(Generate), \+ call(Test)).
151
152
153% retractall(+callable) -- built-in
154
155
156% call_with_args/2-9
157%
158% use these definitions only if your compiler does
159% not provide call_with_args/2-9 as built-in predicates
160
161call_with_args(F, A) :-
162    call(F, A).
163
164call_with_args(F, A1, A2) :-
165    call(F, A1, A2).
166
167call_with_args(F, A1, A2, A3) :-
168    call(F, A1, A2, A3).
169
170call_with_args(F, A1, A2, A3, A4) :-
171    call(F, A1, A2, A3, A4).
172
173call_with_args(F, A1, A2, A3, A4, A5) :-
174    call(F, A1, A2, A3, A4, A5).
175
176call_with_args(F, A1, A2, A3, A4, A5, A6) :-
177    call(F, A1, A2, A3, A4, A5, A6).
178
179call_with_args(F, A1, A2, A3, A4, A5, A6, A7) :-
180    call(F, A1, A2, A3, A4, A5, A6, A7).
181
182call_with_args(F, A1, A2, A3, A4, A5, A6, A7, A8) :-
183    call(F, A1, A2, A3, A4, A5, A6, A7, A8).
184
185
186
187%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
188%
189%  Prolog built-in meta-predicates
190%
191%  (excluding ISO Prolog Standard meta-predicates)
192%
193%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
194
195
196% '$lgt_pl_meta_predicate'(?callable).
197
198'$lgt_pl_meta_predicate'(_) :-
199    fail.
200
201
202
203%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
204%
205%  file extension predicates
206%
207%  these extensions are used by Logtalk load/compile predicates
208%
209%  you may want to change the extension for Prolog files to match
210%  the one expected by your Prolog compiler
211%
212%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
213
214
215% '$lgt_file_extension'(?atom, ?atom)
216
217'$lgt_file_extension'(logtalk, '.lgt').
218'$lgt_file_extension'(prolog, '.pl').
219'$lgt_file_extension'(xml, '.xml').
220
221
222
223%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
224%
225%  default flag values
226%
227%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
228
229
230% '$lgt_default_flag'(?atom, ?atom)
231%
232% default values for all flags
233
234'$lgt_default_flag'(xmldocs, on).
235'$lgt_default_flag'(xslfile, 'lgtxml.xsl').
236'$lgt_default_flag'(xmlspec, dtd).
237'$lgt_default_flag'(xmlsref, local).
238
239'$lgt_default_flag'(unknown, warning).
240'$lgt_default_flag'(misspelt, warning).
241'$lgt_default_flag'(singletons, warning).
242'$lgt_default_flag'(lgtredef, warning).
243'$lgt_default_flag'(plredef, silent).
244'$lgt_default_flag'(portability, silent).
245
246'$lgt_default_flag'(report, on).
247
248'$lgt_default_flag'(smart_compilation, off).
249'$lgt_default_flag'(reload, always).
250
251'$lgt_default_flag'(startup_message, flags(verbose)).
252
253'$lgt_default_flag'(underscore_variables, dont_care).
254
255'$lgt_default_flag'(code_prefix, '').
256
257'$lgt_default_flag'(debug, off).
258'$lgt_default_flag'(break_predicate, false).
259
260'$lgt_default_flag'(events, off).
261
262'$lgt_default_flag'(altdirs, off).
263'$lgt_default_flag'(tmpdir, 'lgt_tmp/').
264'$lgt_default_flag'(xmldir, 'xml_docs/').
265
266'$lgt_default_flag'(encoding_directive, unsupported).
267'$lgt_default_flag'(threads, unsupported).
268
269
270
271%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
272%
273%  list predicates
274%
275%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
276
277
278'$lgt_append'([], List, List).
279'$lgt_append'([Head| Tail], List, [Head| Tail2]) :-
280    '$lgt_append'(Tail, List, Tail2).
281
282
283'$lgt_member'(Head, List) :-
284    member(Head, List).
285
286
287'$lgt_member_var'(V, [H| _]) :-
288    V == H.
289'$lgt_member_var'(V, [_| T]) :-
290    '$lgt_member_var'(V, T).
291
292
293'$lgt_is_list'([]) :-
294    !.
295'$lgt_is_list'([_| Tail]) :-
296    '$lgt_is_list'(Tail).
297
298
299'$lgt_is_proper_list'(List) :-
300    List == [], !.
301'$lgt_is_proper_list'([_| Tail]) :-
302    nonvar(Tail),
303    '$lgt_is_proper_list'(Tail).
304
305
306
307%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
308%
309%  file predicates
310%
311%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
312
313
314% '$lgt_file_exists'(+atom)
315%
316% see if a file exist in the current directory
317
318'$lgt_file_exists'(File) :-
319    file_exists(File).
320
321
322% '$lgt_directory_exists'(+atom)
323%
324% checks if a directory exists
325
326'$lgt_directory_exists'(Directory) :-
327    file_exists(Directory),
328    file_property(Directory, type(directory)).
329
330
331% '$lgt_current_directory'(-atom)
332%
333% gets current working directory
334
335'$lgt_current_directory'(Directory) :-
336    working_directory(Directory, Directory).
337
338
339% '$lgt_change_directory'(+atom)
340%
341% changes current working directory
342
343'$lgt_change_directory'(Directory) :-
344    cd(Directory).
345
346
347% '$lgt_make_directory'(+atom)
348%
349% makes a new directory; succeeds if the directory already exists
350
351'$lgt_make_directory'(Directory) :-
352    file_exists(Directory) ->
353        true
354        ;
355        make_directory(Directory).
356
357
358% '$lgt_load_prolog_code'(+atom, +atom)
359%
360% compile and load a Prolog file
361
362'$lgt_load_prolog_code'(File, _) :-
363    set_prolog_flag(multi_arity_warnings, off),
364    ensure_loaded(File).
365
366
367% '$lgt_compare_file_mtimes'(?atom, +atom, +atom)
368%
369% compare file modification times
370
371'$lgt_compare_file_mtimes'(Result, File1, File2) :-
372    file_property(File1, mod_time(Time1)),
373    file_property(File2, mod_time(Time2)),
374    compare(Result, Time1, Time2).
375
376
377
378%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
379%
380%  sorting predicate
381%
382%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383
384
385% '$lgt_keysort'(+list, -list)
386
387'$lgt_keysort'(List, Sorted) :-
388    keysort(List, Sorted).
389
390
391% '$lgt_sort'(+list, -list)
392
393'$lgt_sort'(List, Sorted) :-
394    sort(List, Sorted).
395
396
397
398%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
399%
400%  time and date predicates
401%
402%  if your Prolog compiler does not provide access to the operating system
403%  time and date just write dummy definitions
404%
405%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
406
407
408% '$lgt_current_date'(?Year, ?Month, ?Day)
409
410'$lgt_current_date'(Year, Month, Day) :-
411    datime(_, Year, Month, Day, _, _, _, _, _).
412
413
414% '$lgt_current_time'(?Hours, ?Mins, ?Secs)
415
416'$lgt_current_time'(Hours, Mins, Secs) :-
417    datime(_, _, _, _, Hours, Mins, Secs, _, _).
418
419
420
421%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
422%
423%  timing predicate
424%
425%  if your Prolog compiler does not provide access to a timing predicate
426%  just write dummy definition
427%
428%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
429
430
431% '$lgt_cpu_time'(-Seconds)
432
433'$lgt_cpu_time'(Seconds) :-
434    statistics(runtime, [Miliseconds| _]),
435    Seconds is Miliseconds / 1000.
436
437
438
439%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
440%
441%  comparison predicate
442%
443%  the usual compare/3 definition
444%
445%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
446
447
448% compare(?atom, @term, @term) -- built-in
449
450
451
452%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
453%
454%  callable predicate
455%
456%  the usual callable/1 definition
457%
458%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
459
460
461% callable(@term) -- built-in
462
463
464
465%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
466%
467%  read character predicate
468%
469%  read a single character echoing it and writing a newline after
470%
471%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
472
473
474'$lgt_read_single_char'(Char) :-
475    get_char(Char),
476    (   peek_code(10) ->    % hack to workaround the lack of built-in
477        get_code(_)         % support for unbuffered character input
478    ;   true
479    ).
480
481
482
483%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
484%
485%  pretty print a term by naming its free variables
486%  (avoid instantiating variables in term by using double negation if necessary)
487%
488%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
489
490
491'$lgt_pretty_print_vars'(Stream, Term) :-
492    \+ \+ (
493        numbervars(Term, 0, _),
494        write_term(Stream, Term, [numbervars(true)])).
495
496
497'$lgt_pretty_print_vars_quoted'(Stream, Term) :-
498    \+ \+ (
499        numbervars(Term, 0, _),
500        write_term(Stream, Term, [numbervars(true), quoted(true)])).
501
502
503
504%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
505%
506%  getting stream current line number
507%  (needed for improved compiler error messages)
508%
509%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
510
511
512% '$lgt_stream_current_line_number'(@stream, -integer)
513
514'$lgt_stream_current_line_number'(Stream, Line) :-
515    line_count(Stream, Last),
516    Line is Last + 1.
517
518
519
520%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
521%
522%  handling of Prolog-proprietary directives on Logtalk source files
523%
524%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
525
526
527% '$lgt_ignore_pl_directive'(@callable)
528
529'$lgt_ignore_pl_directive'(comment(_, _)).
530
531
532% '$lgt_copy_pl_directive'(@callable, -callable)
533
534'$lgt_rewrite_and_copy_pl_directive'(_, _) :-
535    fail.
536
537
538% '$lgt_rewrite_pl_directive'(@callable, -callable)
539
540'$lgt_rewrite_and_recompile_pl_directive'(imports(Module, Imports), uses(Module, Imports)).
541'$lgt_rewrite_and_recompile_pl_directive'(module(Module, Exports, []), module(Module, Exports)) :-
542    (   var(Module) ->      % module name taken from file name
543        '$lgt_ciao_find_module_name'(Module)
544    ;   true
545    ).
546'$lgt_rewrite_and_recompile_pl_directive'(module(Module, Exports, [assertions]), module(Module, Exports)) :-
547    (   var(Module) ->      % module name taken from file name
548        '$lgt_ciao_find_module_name'(Module)
549    ;   true
550    ).
551
552
553'$lgt_ciao_find_module_name'(Module) :-
554    stream_property(Stream, mode(read)),
555    stream_property(Stream, file_name(Path)),
556    no_path_file_name(Path, File),
557    extension(File, '.lgt'),
558    basename(File, Module),
559    !.
560
561
562
563%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
564%
565%  Shortcut to the Logtalk built-in predicate logtalk_load/1
566%
567%  defined in the config files in order to be able to comment it out in case
568%  of conflict with some Prolog native feature; it implies conformance with
569%  the ISO Prolog standard regarding the definition of the {}/1 syntax
570%
571%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
572
573{File, Files} :-
574    !,
575    logtalk_load(File),
576    {Files}.
577{File} :-
578    logtalk_load(File).
579
580
581
582%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
583%
584%  end!
585%
586%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracBrowser for help on using the browser.