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