2001-06-06 20:40:57 +01:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% Logtalk - Object oriented extension to Prolog
|
2007-02-19 18:58:28 +00:00
|
|
|
% Release 2.29.4
|
2001-06-06 20:40:57 +01:00
|
|
|
%
|
2004-04-26 00:57:46 +01:00
|
|
|
% configuration file for YAP Prolog 4.3.23 and later versions
|
2001-06-06 20:40:57 +01:00
|
|
|
%
|
2007-02-19 18:58:28 +00:00
|
|
|
% last updated: February 15, 2007
|
2001-06-06 20:40:57 +01:00
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
2002-08-26 17:45:50 +01:00
|
|
|
% the following initialization is not needed to run Logtalk altough is
|
|
|
|
% recommended; you can comment out the set_prolog_flag/2 calls if needed
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
:- initialization(
|
|
|
|
(set_prolog_flag(update_semantics, logical),
|
2002-08-26 17:45:50 +01:00
|
|
|
set_prolog_flag(unknown, error),
|
2002-10-07 11:55:21 +01:00
|
|
|
use_module(library(system)),
|
2002-08-26 17:45:50 +01:00
|
|
|
'$lgt_hide_predicates')).
|
|
|
|
|
|
|
|
|
|
|
|
'$lgt_hide_predicates' :-
|
|
|
|
predicate_property(hide_predicate(_), built_in) ->
|
|
|
|
dynamic('$lgt_before_'/5), hide_predicate('$lgt_before_'/5),
|
|
|
|
dynamic('$lgt_after_'/5), hide_predicate('$lgt_after_'/5),
|
2004-10-25 12:13:58 +01:00
|
|
|
dynamic('$lgt_current_protocol_'/3), hide_predicate('$lgt_current_protocol_'/3),
|
|
|
|
dynamic('$lgt_current_category_'/3), hide_predicate('$lgt_current_category_'/3),
|
2007-02-19 18:58:28 +00:00
|
|
|
dynamic('$lgt_current_object_'/8), hide_predicate('$lgt_current_object_'/8),
|
2002-08-26 17:45:50 +01:00
|
|
|
dynamic('$lgt_implements_protocol_'/3), hide_predicate('$lgt_implements_protocol_'/3),
|
|
|
|
dynamic('$lgt_imports_category_'/3), hide_predicate('$lgt_imports_category_'/3),
|
|
|
|
dynamic('$lgt_instantiates_class_'/3), hide_predicate('$lgt_instantiates_class_'/3),
|
|
|
|
dynamic('$lgt_specializes_class_'/3), hide_predicate('$lgt_specializes_class_'/3),
|
|
|
|
dynamic('$lgt_extends_protocol_'/3), hide_predicate('$lgt_extends_protocol_'/3),
|
2004-04-26 00:57:46 +01:00
|
|
|
dynamic('$lgt_extends_object_'/3), hide_predicate('$lgt_extends_object_'/3),
|
2004-07-09 00:48:59 +01:00
|
|
|
dynamic('$lgt_debugging_'/1), hide_predicate('$lgt_debugging_'/1),
|
2004-10-25 12:13:58 +01:00
|
|
|
dynamic('$lgt_dbg_debugging_'/0), hide_predicate('$lgt_dbg_debugging_'/0),
|
2005-02-10 00:02:06 +00:00
|
|
|
dynamic('$lgt_dbg_tracing_'/0), hide_predicate('$lgt_dbg_tracing_'/0),
|
|
|
|
dynamic('$lgt_dbg_skipping_'/0), hide_predicate('$lgt_dbg_skipping_'/0),
|
|
|
|
dynamic('$lgt_dbg_spying_'/2), hide_predicate('$lgt_dbg_spying_'/2),
|
|
|
|
dynamic('$lgt_dbg_spying_'/4), hide_predicate('$lgt_dbg_spying_'/4),
|
2004-10-25 12:13:58 +01:00
|
|
|
dynamic('$lgt_dbg_leashing_'/1), hide_predicate('$lgt_dbg_leashing_'/1),
|
2005-02-10 00:02:06 +00:00
|
|
|
dynamic('$lgt_obj_lookup_cache_'/4), hide_predicate('$lgt_obj_lookup_cache_'/4),
|
|
|
|
dynamic('$lgt_self_lookup_cache_'/4), hide_predicate('$lgt_self_lookup_cache_'/4),
|
2005-04-23 00:57:45 +01:00
|
|
|
dynamic('$lgt_super_lookup_cache_'/5), hide_predicate('$lgt_super_lookup_cache_'/5),
|
2006-12-29 09:48:32 +00:00
|
|
|
dynamic('$lgt_db_lookup_cache_'/6), hide_predicate('$lgt_db_lookup_cache_'/6),
|
2005-04-23 00:57:45 +01:00
|
|
|
dynamic('$lgt_pp_warnings_top_argument_'/1), hide_predicate('$lgt_pp_warnings_top_argument_'/1),
|
|
|
|
dynamic('$lgt_pp_comp_warnings_counter_'/1), hide_predicate('$lgt_pp_comp_warnings_counter_'/1),
|
|
|
|
dynamic('$lgt_pp_load_warnings_counter_'/1), hide_predicate('$lgt_pp_load_warnings_counter_'/1)
|
2002-08-26 17:45:50 +01:00
|
|
|
;
|
|
|
|
true.
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% ISO Prolog Standard predicates that we must define because they are
|
|
|
|
% not built-in
|
|
|
|
%
|
|
|
|
% add a clause for lgt_iso_predicate/1 declaring each ISO predicate that
|
|
|
|
% we must define; there must be at least one clause for this predicate
|
|
|
|
% whose call should fail if we don't define any ISO predicates
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
% '$lgt_iso_predicate'(?callable).
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
'$lgt_iso_predicate'(_) :-
|
2001-06-06 20:40:57 +01:00
|
|
|
fail.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% predicate properties
|
|
|
|
%
|
2002-08-26 17:45:50 +01:00
|
|
|
% this predicate must return at least static, dynamic, and built_in
|
2001-06-06 20:40:57 +01:00
|
|
|
% properties for an existing predicate
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
% '$lgt_predicate_property'(+callable, ?predicate_property)
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
'$lgt_predicate_property'(Pred, Prop) :-
|
2001-06-06 20:40:57 +01:00
|
|
|
predicate_property(Pred, Prop).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
2006-11-07 17:11:47 +00:00
|
|
|
% meta-predicates
|
2001-06-06 20:40:57 +01:00
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
2006-11-07 17:11:47 +00:00
|
|
|
% call_cleanup(+callable, +callble) -- built-in
|
|
|
|
|
|
|
|
|
|
|
|
% forall(+callable, +callble) -- built-in
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
forall(Generate, Test) :-
|
2005-02-10 00:02:06 +00:00
|
|
|
\+ (call(Generate), \+ call(Test)).
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
|
2005-02-10 00:02:06 +00:00
|
|
|
% retractall(+callable) -- built-in
|
|
|
|
|
|
|
|
|
2006-11-07 17:11:47 +00:00
|
|
|
% call_with_args/2-9
|
2001-06-06 20:40:57 +01:00
|
|
|
%
|
|
|
|
% use these definitions only if your compiler does
|
2006-11-07 17:11:47 +00:00
|
|
|
% not provide call_with_args/2-9 as built-in predicates
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2006-11-07 17:11:47 +00:00
|
|
|
% call_with_args(F, A) -- built-in
|
2005-02-10 00:02:06 +00:00
|
|
|
|
2006-11-07 17:11:47 +00:00
|
|
|
% call_with_args(F, A1, A2) -- built-in
|
2005-02-10 00:02:06 +00:00
|
|
|
|
2006-11-07 17:11:47 +00:00
|
|
|
% call_with_args(F, A1, A2, A3) -- built-in
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2006-11-07 17:11:47 +00:00
|
|
|
% call_with_args(F, A1, A2, A3, A4) -- built-in
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2006-11-07 17:11:47 +00:00
|
|
|
% call_with_args(F, A1, A2, A3, A4, A5) -- built-in
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2006-11-07 17:11:47 +00:00
|
|
|
% call_with_args(F, A1, A2, A3, A4, A5, A6) -- built-in
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2006-11-07 17:11:47 +00:00
|
|
|
% call_with_args(F, A1, A2, A3, A4, A5, A6, A7) -- built-in
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2006-11-07 17:11:47 +00:00
|
|
|
% call_with_args(F, A1, A2, A3, A4, A5, A6, A7, A8) -- built-in
|
2005-02-10 00:02:06 +00:00
|
|
|
|
|
|
|
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2004-03-03 04:07:59 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
2006-11-07 17:11:47 +00:00
|
|
|
% Prolog built-in meta-predicates
|
2004-03-03 04:07:59 +00:00
|
|
|
%
|
2006-11-07 17:11:47 +00:00
|
|
|
% (excluding ISO Prolog Standard meta-predicates)
|
2004-03-03 04:07:59 +00:00
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
2006-11-07 17:11:47 +00:00
|
|
|
% '$lgt_pl_meta_predicate'(?callable).
|
2004-03-03 04:07:59 +00:00
|
|
|
|
2006-11-07 17:11:47 +00:00
|
|
|
'$lgt_pl_meta_predicate'(all(*, ::, *)).
|
|
|
|
'$lgt_pl_meta_predicate'(call_cleanup(::)).
|
|
|
|
'$lgt_pl_meta_predicate'(call_cleanup(::, ::)).
|
|
|
|
'$lgt_pl_meta_predicate'(call_residue(::, *)).
|
|
|
|
'$lgt_pl_meta_predicate'(if(::, ::, ::)).
|
|
|
|
'$lgt_pl_meta_predicate'(on_cleanup(::)).
|
|
|
|
'$lgt_pl_meta_predicate'(freeze(*, ::)).
|
|
|
|
'$lgt_pl_meta_predicate'(time_out(::, *, *)).
|
|
|
|
'$lgt_pl_meta_predicate'(when(*, ::)).
|
2004-03-23 17:51:43 +00:00
|
|
|
|
2006-11-07 17:11:47 +00:00
|
|
|
'$lgt_pl_meta_predicate'(thread_at_exit(::)).
|
|
|
|
'$lgt_pl_meta_predicate'(thread_create(::, *, *)).
|
|
|
|
'$lgt_pl_meta_predicate'(thread_signal(*, ::)).
|
|
|
|
'$lgt_pl_meta_predicate'(with_mutex(*, ::)).
|
2004-03-03 04:07:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-06-06 20:40:57 +01:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% file extension predicates
|
|
|
|
%
|
|
|
|
% these extensions are used by Logtalk load/compile predicates
|
|
|
|
%
|
|
|
|
% you may want to change the extension for Prolog files to match
|
|
|
|
% the one expected by your Prolog compiler
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
% '$lgt_file_extension'(?atom, ?atom)
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
'$lgt_file_extension'(logtalk, '.lgt').
|
|
|
|
'$lgt_file_extension'(prolog, '.pl').
|
|
|
|
'$lgt_file_extension'(xml, '.xml').
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2004-11-16 19:37:30 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% alternate directory predicates
|
|
|
|
%
|
|
|
|
% these alternate directories are used by Logtalk load/compile predicates
|
2005-12-24 18:00:21 +00:00
|
|
|
% when the flag altdirs is used; the directory paths should always end
|
2004-11-16 19:37:30 +00:00
|
|
|
% with the path separator character
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
|
|
|
% '$lgt_alt_directory'(?atom, ?atom)
|
|
|
|
|
2006-03-26 18:31:34 +01:00
|
|
|
'$lgt_alt_directory'(prolog, 'lgt_temp/').
|
|
|
|
'$lgt_alt_directory'(xml, 'xml_docs/').
|
2004-11-16 19:37:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-06-06 20:40:57 +01:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
2002-02-08 19:57:23 +00:00
|
|
|
% default flag values
|
2001-06-06 20:40:57 +01:00
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
% '$lgt_default_flag'(?atom, ?atom)
|
2001-06-06 20:40:57 +01:00
|
|
|
%
|
2002-02-08 19:57:23 +00:00
|
|
|
% default values for all flags
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2005-12-24 18:00:21 +00:00
|
|
|
'$lgt_default_flag'(xmldocs, on).
|
|
|
|
'$lgt_default_flag'(xslfile, 'lgtxml.xsl').
|
2004-02-09 14:18:27 +00:00
|
|
|
'$lgt_default_flag'(xmlspec, dtd).
|
2005-12-24 18:00:21 +00:00
|
|
|
'$lgt_default_flag'(xmlsref, local).
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
'$lgt_default_flag'(unknown, warning).
|
|
|
|
'$lgt_default_flag'(misspelt, warning).
|
|
|
|
'$lgt_default_flag'(singletons, warning).
|
|
|
|
'$lgt_default_flag'(lgtredef, warning).
|
|
|
|
'$lgt_default_flag'(plredef, silent).
|
|
|
|
'$lgt_default_flag'(portability, silent).
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
'$lgt_default_flag'(report, on).
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
'$lgt_default_flag'(smart_compilation, off).
|
2002-05-06 14:10:02 +01:00
|
|
|
|
2005-12-24 18:00:21 +00:00
|
|
|
'$lgt_default_flag'(startup_message, flags(verbose)).
|
2002-08-01 00:34:42 +01:00
|
|
|
|
2004-02-09 14:18:27 +00:00
|
|
|
'$lgt_default_flag'(underscore_vars, singletons).
|
2002-08-01 00:34:42 +01:00
|
|
|
|
|
|
|
'$lgt_default_flag'(code_prefix, '').
|
2002-05-06 14:10:02 +01:00
|
|
|
|
2004-04-26 00:57:46 +01:00
|
|
|
'$lgt_default_flag'(debug, off).
|
|
|
|
'$lgt_default_flag'(supports_break_predicate, true).
|
|
|
|
|
2006-12-29 09:48:32 +00:00
|
|
|
'$lgt_default_flag'(events, off).
|
2004-11-03 00:13:01 +00:00
|
|
|
|
2004-11-16 19:37:30 +00:00
|
|
|
'$lgt_default_flag'(altdirs, off).
|
|
|
|
|
2005-04-23 00:57:45 +01:00
|
|
|
'$lgt_default_flag'(supports_encoding_dir, false).
|
2006-11-07 17:11:47 +00:00
|
|
|
'$lgt_default_flag'(threads, off).
|
2005-04-23 00:57:45 +01:00
|
|
|
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% list predicates
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
'$lgt_append'([], List, List).
|
|
|
|
'$lgt_append'([Head| Tail], List, [Head| Tail2]) :-
|
|
|
|
'$lgt_append'(Tail, List, Tail2).
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
'$lgt_member'(Head, [Head| _]).
|
|
|
|
'$lgt_member'(Head, [_| Tail]) :-
|
|
|
|
'$lgt_member'(Head, Tail).
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
'$lgt_member_var'(V, [H| _]) :-
|
2001-06-06 20:40:57 +01:00
|
|
|
V == H.
|
2002-08-01 00:34:42 +01:00
|
|
|
'$lgt_member_var'(V, [_| T]) :-
|
|
|
|
'$lgt_member_var'(V, T).
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
|
2006-02-10 17:44:05 +00:00
|
|
|
'$lgt_is_list'([]) :-
|
|
|
|
!.
|
|
|
|
'$lgt_is_list'([_| Tail]) :-
|
|
|
|
'$lgt_is_list'(Tail).
|
|
|
|
|
|
|
|
|
|
|
|
'$lgt_is_proper_list'(List) :-
|
|
|
|
List == [], !.
|
|
|
|
'$lgt_is_proper_list'([_| Tail]) :-
|
|
|
|
nonvar(Tail),
|
|
|
|
'$lgt_is_proper_list'(Tail).
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
|
2004-07-25 19:47:43 +01:00
|
|
|
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% file predicates
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
% '$lgt_file_exists'(+atom)
|
2001-06-06 20:40:57 +01:00
|
|
|
%
|
2005-12-24 18:00:21 +00:00
|
|
|
% checks if a file exist in the current directory
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
'$lgt_file_exists'(File) :-
|
2002-10-07 11:55:21 +01:00
|
|
|
file_exists(File).
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
|
2005-12-24 18:00:21 +00:00
|
|
|
% '$lgt_directory_exists'(+atom)
|
|
|
|
%
|
|
|
|
% checks if a directory exists
|
|
|
|
|
|
|
|
'$lgt_directory_exists'(Directory) :-
|
2006-11-07 17:11:47 +00:00
|
|
|
( atom_concat(Directory2, '/', Directory) ->
|
|
|
|
true
|
|
|
|
; Directory2 = Directory
|
|
|
|
),
|
|
|
|
absolute_file_name(Directory2, Path),
|
2005-12-24 18:00:21 +00:00
|
|
|
file_exists(Path),
|
|
|
|
file_property(Path, type(directory)).
|
|
|
|
|
|
|
|
|
2004-11-29 20:36:31 +00:00
|
|
|
% '$lgt_current_directory'(-atom)
|
|
|
|
%
|
|
|
|
% gets current working directory
|
|
|
|
|
|
|
|
'$lgt_current_directory'(Directory) :-
|
|
|
|
getcwd(Directory).
|
|
|
|
|
|
|
|
|
|
|
|
% '$lgt_change_directory'(+atom)
|
|
|
|
%
|
|
|
|
% changes current working directory
|
|
|
|
|
|
|
|
'$lgt_change_directory'(Directory) :-
|
|
|
|
cd(Directory).
|
|
|
|
|
|
|
|
|
2004-11-16 19:37:30 +00:00
|
|
|
% '$lgt_make_directory'(+atom)
|
|
|
|
%
|
|
|
|
% makes a new directory; succeeds if the directory already exists
|
|
|
|
|
|
|
|
'$lgt_make_directory'(Directory) :-
|
2007-02-19 18:58:28 +00:00
|
|
|
( '$lgt_directory_exists'(Directory) ->
|
2004-11-16 19:37:30 +00:00
|
|
|
true
|
2007-02-19 18:58:28 +00:00
|
|
|
; make_directory(Directory)
|
|
|
|
).
|
2004-11-16 19:37:30 +00:00
|
|
|
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
% '$lgt_load_prolog_code'(+atom)
|
2001-06-06 20:40:57 +01:00
|
|
|
%
|
|
|
|
% compile and load a Prolog file
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
'$lgt_load_prolog_code'(File) :-
|
2001-06-06 20:40:57 +01:00
|
|
|
reconsult(File).
|
|
|
|
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
% '$lgt_compare_file_mtimes'(?atom, +atom, +atom)
|
2002-05-06 14:10:02 +01:00
|
|
|
%
|
|
|
|
% compare file modification times
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
'$lgt_compare_file_mtimes'(Result, File1, File2) :-
|
2002-05-06 14:10:02 +01:00
|
|
|
file_property(File1, mod_time(Time1)),
|
|
|
|
file_property(File2, mod_time(Time2)),
|
|
|
|
compare(Result, Time1, Time2).
|
|
|
|
|
|
|
|
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% sorting predicates
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
% '$lgt_keysort'(+list, -list)
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
'$lgt_keysort'(List, Sorted) :-
|
2001-06-06 20:40:57 +01:00
|
|
|
keysort(List, Sorted).
|
|
|
|
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
% '$lgt_sort'(+list, -list)
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
'$lgt_sort'(List, Sorted) :-
|
2001-06-06 20:40:57 +01:00
|
|
|
sort(List, Sorted).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% time and date predicates
|
|
|
|
%
|
|
|
|
% if your Prolog compiler does not provide access to the operating system
|
|
|
|
% time and date just write dummy definitions
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
% '$lgt_current_date'(?Year, ?Month, ?Day)
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2002-10-07 11:55:21 +01:00
|
|
|
'$lgt_current_date'(Year, Month, Day) :-
|
|
|
|
datime(datime(Year, Month, Day, _, _, _)).
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
% '$lgt_current_time'(?Hours, ?Mins, ?Secs)
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2002-10-07 11:55:21 +01:00
|
|
|
'$lgt_current_time'(Hours, Mins, Secs) :-
|
|
|
|
datime(datime(_, _, _, Hours, Mins, Secs)).
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% timing predicate
|
|
|
|
%
|
|
|
|
% if your Prolog compiler does not provide access to a timing predicate
|
|
|
|
% just write dummy definition
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
% '$lgt_cpu_time'(-Seconds)
|
2001-06-06 20:40:57 +01:00
|
|
|
|
2002-08-01 00:34:42 +01:00
|
|
|
'$lgt_cpu_time'(Seconds) :-
|
2004-10-25 12:13:58 +01:00
|
|
|
statistics(cputime, [Miliseconds, _]),
|
|
|
|
Seconds is Miliseconds/1000.
|
2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% comparison predicate
|
|
|
|
%
|
|
|
|
% the usual compare/3 definition
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
|
|
|
% compare(?atom, @term, @term) -- built-in
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-07-09 00:48:59 +01:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% callable predicate
|
|
|
|
%
|
|
|
|
% the usual callable/1 definition
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
|
|
|
% callable(@term) -- built-in
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-04-26 00:57:46 +01:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% read character predicate
|
|
|
|
%
|
|
|
|
% read a single character echoing it and writing a newline after
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
|
|
|
'$lgt_read_single_char'(Char) :-
|
|
|
|
get_char(Char).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% pretty print a term by naming its free variables
|
2004-06-06 23:46:45 +01:00
|
|
|
% (avoid instantiating variables in term by using double negation if necessary)
|
2004-04-26 00:57:46 +01:00
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
2004-06-06 23:46:45 +01:00
|
|
|
'$lgt_pretty_print_vars'(Stream, Term) :-
|
|
|
|
\+ \+ (
|
|
|
|
numbervars(Term, 0, _),
|
|
|
|
write_term(Stream, Term, [numbervars(true)])).
|
|
|
|
|
|
|
|
|
|
|
|
'$lgt_pretty_print_vars_quoted'(Stream, Term) :-
|
|
|
|
\+ \+ (
|
|
|
|
numbervars(Term, 0, _),
|
|
|
|
write_term(Stream, Term, [numbervars(true), quoted(true)])).
|
2004-04-26 00:57:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2006-11-07 17:11:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
2006-12-29 09:48:32 +00:00
|
|
|
% getting stream current line number
|
2006-11-07 17:11:47 +00:00
|
|
|
% (needed for improved compiler error messages)
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
2006-12-29 09:48:32 +00:00
|
|
|
% '$lgt_stream_current_line_number'(@stream, -integer)
|
|
|
|
|
|
|
|
'$lgt_stream_current_line_number'(Stream, Line) :-
|
|
|
|
stream_property(Stream, position('$stream_position'(_, Last, _))),
|
|
|
|
Line is Last + 1.
|
2006-11-07 17:11:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-23 00:57:45 +01:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% setting of text stream character encoding
|
|
|
|
% (needed for processing encoding/1 directives)
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
|
|
|
% '$lgt_set_stream_encoding'(@stream, +atom)
|
|
|
|
|
|
|
|
'$lgt_set_stream_encoding'(_, _).
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-12-24 18:00:21 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% handling of Prolog-proprietary directives on Logtalk source files
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
|
|
|
% '$lgt_ignore_pl_directive'(@callable)
|
|
|
|
|
|
|
|
'$lgt_ignore_pl_directive'(load_foreign_files(Files,Libs,InitRoutine)) :-
|
|
|
|
load_foreign_files(Files,Libs,InitRoutine).
|
|
|
|
|
|
|
|
|
|
|
|
% '$lgt_copy_pl_directive'(@callable)
|
|
|
|
|
|
|
|
'$lgt_copy_pl_directive'(_) :-
|
|
|
|
fail.
|
|
|
|
|
|
|
|
|
|
|
|
% '$lgt_rewrite_pl_directive'(@callable, -callable)
|
|
|
|
|
|
|
|
'$lgt_rewrite_pl_directive'(_, _) :-
|
|
|
|
fail.
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-11-07 17:11:47 +00:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% multi-threading predicates
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
|
|
|
|
% current_thread(+atom, ?nonvar) -- built-in
|
|
|
|
|
|
|
|
|
|
|
|
% thread_self(?atom) -- built-in
|
|
|
|
|
|
|
|
|
|
|
|
% thread_create(@callable, -thread_id, +list) -- built-in
|
|
|
|
|
|
|
|
|
|
|
|
% thread_join(+atom, -nonvar) -- built-in
|
|
|
|
|
|
|
|
|
|
|
|
% thread_detach(+atom) -- built-in
|
|
|
|
|
|
|
|
|
|
|
|
% thread_exit(@term) -- built-in
|
|
|
|
|
|
|
|
|
|
|
|
% thread_send_message(+atom, @callable) -- built-in
|
|
|
|
|
|
|
|
|
|
|
|
% thread_peek_message(+atom, ?callable) -- built-in
|
|
|
|
|
|
|
|
|
|
|
|
% thread_get_message(+atom, ?callable) -- built-in
|
|
|
|
|
|
|
|
|
|
|
|
% thread_get_message(?callable) -- built-in
|
|
|
|
|
|
|
|
|
2007-01-10 12:46:10 +00:00
|
|
|
% thread_sleep(+number) -- built-in
|
|
|
|
|
|
|
|
|
2006-11-07 17:11:47 +00:00
|
|
|
|
2001-06-06 20:40:57 +01:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%
|
|
|
|
% end!
|
|
|
|
%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|