kibi-swipl-linux-x64-gnu 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (550) hide show
  1. package/README.md +29 -0
  2. package/bin/swipl +0 -0
  3. package/bin/swipl-win +0 -0
  4. package/build-manifest.json +70 -0
  5. package/lib/cmake/swipl/SWIPLConfig.cmake +21 -0
  6. package/lib/cmake/swipl/SWIPLConfigVersion.cmake +65 -0
  7. package/lib/cmake/swipl/SWIPLTargets-release.cmake +28 -0
  8. package/lib/cmake/swipl/SWIPLTargets.cmake +109 -0
  9. package/lib/swipl/ABI +1 -0
  10. package/lib/swipl/LICENSE +41 -0
  11. package/lib/swipl/README.md +116 -0
  12. package/lib/swipl/app/README.md +25 -0
  13. package/lib/swipl/app/app.pl +87 -0
  14. package/lib/swipl/app/pack.pl +350 -0
  15. package/lib/swipl/app/qlf.pl +521 -0
  16. package/lib/swipl/app/splfr.pl +177 -0
  17. package/lib/swipl/app/sys.pl +310 -0
  18. package/lib/swipl/bin/swipl.home +1 -0
  19. package/lib/swipl/boot/apply.pl +73 -0
  20. package/lib/swipl/boot/attvar.pl +344 -0
  21. package/lib/swipl/boot/autoload.pl +1226 -0
  22. package/lib/swipl/boot/bags.pl +283 -0
  23. package/lib/swipl/boot/dcg.pl +388 -0
  24. package/lib/swipl/boot/dicts.pl +193 -0
  25. package/lib/swipl/boot/dwim.pl +485 -0
  26. package/lib/swipl/boot/engines.pl +152 -0
  27. package/lib/swipl/boot/expand.pl +1628 -0
  28. package/lib/swipl/boot/gc.pl +65 -0
  29. package/lib/swipl/boot/history.pl +304 -0
  30. package/lib/swipl/boot/init.pl +4682 -0
  31. package/lib/swipl/boot/iri.pl +64 -0
  32. package/lib/swipl/boot/license.pl +390 -0
  33. package/lib/swipl/boot/load.pl +81 -0
  34. package/lib/swipl/boot/messages.pl +2521 -0
  35. package/lib/swipl/boot/packs.pl +306 -0
  36. package/lib/swipl/boot/predopts.pl +154 -0
  37. package/lib/swipl/boot/qlf.pl +141 -0
  38. package/lib/swipl/boot/rc.pl +263 -0
  39. package/lib/swipl/boot/syspred.pl +1634 -0
  40. package/lib/swipl/boot/tabling.pl +2321 -0
  41. package/lib/swipl/boot/threads.pl +42 -0
  42. package/lib/swipl/boot/toplevel.pl +2248 -0
  43. package/lib/swipl/boot/topvars.pl +261 -0
  44. package/lib/swipl/boot.prc +0 -0
  45. package/lib/swipl/cmake/swipl.cmake +131 -0
  46. package/lib/swipl/customize/README.md +23 -0
  47. package/lib/swipl/customize/edit +101 -0
  48. package/lib/swipl/customize/init.pl +164 -0
  49. package/lib/swipl/demo/README.md +33 -0
  50. package/lib/swipl/demo/likes.pl +44 -0
  51. package/lib/swipl/doc/packages/examples/chr/bool.chr +281 -0
  52. package/lib/swipl/doc/packages/examples/chr/chrdif.chr +87 -0
  53. package/lib/swipl/doc/packages/examples/chr/chrfreeze.chr +6 -0
  54. package/lib/swipl/doc/packages/examples/chr/family.chr +116 -0
  55. package/lib/swipl/doc/packages/examples/chr/fib.chr +24 -0
  56. package/lib/swipl/doc/packages/examples/chr/fibonacci.chr +31 -0
  57. package/lib/swipl/doc/packages/examples/chr/gcd.chr +28 -0
  58. package/lib/swipl/doc/packages/examples/chr/leq.chr +34 -0
  59. package/lib/swipl/doc/packages/examples/chr/listdom.chr +138 -0
  60. package/lib/swipl/doc/packages/examples/chr/primes.chr +29 -0
  61. package/lib/swipl/doc/packages/examples/http/README.md +98 -0
  62. package/lib/swipl/doc/packages/examples/http/calc.pl +92 -0
  63. package/lib/swipl/doc/packages/examples/http/demo_body.pl +232 -0
  64. package/lib/swipl/doc/packages/examples/http/demo_client.pl +165 -0
  65. package/lib/swipl/doc/packages/examples/http/demo_daemon.pl +38 -0
  66. package/lib/swipl/doc/packages/examples/http/demo_files.pl +50 -0
  67. package/lib/swipl/doc/packages/examples/http/demo_hello.pl +15 -0
  68. package/lib/swipl/doc/packages/examples/http/demo_login.pl +280 -0
  69. package/lib/swipl/doc/packages/examples/http/demo_openid.pl +177 -0
  70. package/lib/swipl/doc/packages/examples/http/demo_pwp.pl +20 -0
  71. package/lib/swipl/doc/packages/examples/http/demo_rest.pl +56 -0
  72. package/lib/swipl/doc/packages/examples/http/demo_threads.pl +52 -0
  73. package/lib/swipl/doc/packages/examples/http/linux-init-script +126 -0
  74. package/lib/swipl/doc/packages/examples/http/pwp/context.pwp +23 -0
  75. package/lib/swipl/doc/packages/examples/http/pwp/index.pwp +25 -0
  76. package/lib/swipl/doc/packages/examples/http/pwp/pwp1.pwp +12 -0
  77. package/lib/swipl/doc/packages/examples/http/pwp/pwp2.pwp +10 -0
  78. package/lib/swipl/doc/packages/examples/http/pwp/pwp3.pwp +25 -0
  79. package/lib/swipl/doc/packages/examples/http/pwp/pwp4.pwp +23 -0
  80. package/lib/swipl/doc/packages/examples/http/pwp/pwp5.pwp +11 -0
  81. package/lib/swipl/doc/packages/examples/http/pwp/pwp6.pwp +3 -0
  82. package/lib/swipl/doc/packages/examples/http/pwp/pwp7.pwp +3 -0
  83. package/lib/swipl/doc/packages/examples/http/pwp/pwp8.pwp +3 -0
  84. package/lib/swipl/doc/packages/examples/http/pwp/pwpdb.pl +12 -0
  85. package/lib/swipl/doc/packages/examples/http/systemd-script.service +18 -0
  86. package/lib/swipl/doc/packages/examples/http/upstart-script.conf +20 -0
  87. package/lib/swipl/doc/packages/examples/plunit/read.pl +17 -0
  88. package/lib/swipl/doc/packages/examples/plunit/simple.pl +33 -0
  89. package/lib/swipl/doc/packages/examples/ssl/client.pl +83 -0
  90. package/lib/swipl/doc/packages/examples/ssl/etc/README +52 -0
  91. package/lib/swipl/doc/packages/examples/ssl/etc/client/client-cert.p12 +0 -0
  92. package/lib/swipl/doc/packages/examples/ssl/etc/client/client-cert.pem +85 -0
  93. package/lib/swipl/doc/packages/examples/ssl/etc/client/client-key.pem +30 -0
  94. package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/cacert.pem +82 -0
  95. package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/careq.pem +18 -0
  96. package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/crlnumber +1 -0
  97. package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/index.txt +3 -0
  98. package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/index.txt.attr +1 -0
  99. package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/newcerts/9DC08797A0F63F7C.pem +85 -0
  100. package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/newcerts/9DC08797A0F63F7D.pem +85 -0
  101. package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/private/cakey.pem +30 -0
  102. package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/serial +1 -0
  103. package/lib/swipl/doc/packages/examples/ssl/etc/server/server-cert.pem +85 -0
  104. package/lib/swipl/doc/packages/examples/ssl/etc/server/server-key.pem +30 -0
  105. package/lib/swipl/doc/packages/examples/ssl/https.pl +267 -0
  106. package/lib/swipl/doc/packages/examples/ssl/server.pl +106 -0
  107. package/lib/swipl/include/SWI-Prolog.h +1544 -0
  108. package/lib/swipl/include/SWI-Stream.h +537 -0
  109. package/lib/swipl/include/Yap/YapInterface.h +283 -0
  110. package/lib/swipl/include/sicstus/sicstus.h +452 -0
  111. package/lib/swipl/lib/x86_64-linux/cgi.so +0 -0
  112. package/lib/swipl/lib/x86_64-linux/crypt.so +0 -0
  113. package/lib/swipl/lib/x86_64-linux/crypto4pl.so +0 -0
  114. package/lib/swipl/lib/x86_64-linux/double_metaphone.so +0 -0
  115. package/lib/swipl/lib/x86_64-linux/files.so +0 -0
  116. package/lib/swipl/lib/x86_64-linux/hashstream.so +0 -0
  117. package/lib/swipl/lib/x86_64-linux/http_stream.so +0 -0
  118. package/lib/swipl/lib/x86_64-linux/isub.so +0 -0
  119. package/lib/swipl/lib/x86_64-linux/json.so +0 -0
  120. package/lib/swipl/lib/x86_64-linux/libswipl.so.10 +0 -0
  121. package/lib/swipl/lib/x86_64-linux/mallocinfo.so +0 -0
  122. package/lib/swipl/lib/x86_64-linux/md54pl.so +0 -0
  123. package/lib/swipl/lib/x86_64-linux/memfile.so +0 -0
  124. package/lib/swipl/lib/x86_64-linux/ntriples.so +0 -0
  125. package/lib/swipl/lib/x86_64-linux/pcre4pl.so +0 -0
  126. package/lib/swipl/lib/x86_64-linux/porter_stem.so +0 -0
  127. package/lib/swipl/lib/x86_64-linux/process.so +0 -0
  128. package/lib/swipl/lib/x86_64-linux/prolog_stream.so +0 -0
  129. package/lib/swipl/lib/x86_64-linux/rdf_db.so +0 -0
  130. package/lib/swipl/lib/x86_64-linux/readutil.so +0 -0
  131. package/lib/swipl/lib/x86_64-linux/rlimit.so +0 -0
  132. package/lib/swipl/lib/x86_64-linux/sched.so +0 -0
  133. package/lib/swipl/lib/x86_64-linux/sgml2pl.so +0 -0
  134. package/lib/swipl/lib/x86_64-linux/sha4pl.so +0 -0
  135. package/lib/swipl/lib/x86_64-linux/snowball.so +0 -0
  136. package/lib/swipl/lib/x86_64-linux/socket.so +0 -0
  137. package/lib/swipl/lib/x86_64-linux/ssl4pl.so +0 -0
  138. package/lib/swipl/lib/x86_64-linux/streaminfo.so +0 -0
  139. package/lib/swipl/lib/x86_64-linux/syslog.so +0 -0
  140. package/lib/swipl/lib/x86_64-linux/time.so +0 -0
  141. package/lib/swipl/lib/x86_64-linux/turtle.so +0 -0
  142. package/lib/swipl/lib/x86_64-linux/uid.so +0 -0
  143. package/lib/swipl/lib/x86_64-linux/unix.so +0 -0
  144. package/lib/swipl/lib/x86_64-linux/uri.so +0 -0
  145. package/lib/swipl/lib/x86_64-linux/websocket.so +0 -0
  146. package/lib/swipl/lib/x86_64-linux/zlib4pl.so +0 -0
  147. package/lib/swipl/library/INDEX.pl +1020 -0
  148. package/lib/swipl/library/aggregate.pl +755 -0
  149. package/lib/swipl/library/ansi_term.pl +653 -0
  150. package/lib/swipl/library/apply.pl +426 -0
  151. package/lib/swipl/library/apply_macros.pl +497 -0
  152. package/lib/swipl/library/arithmetic.pl +320 -0
  153. package/lib/swipl/library/assoc.pl +522 -0
  154. package/lib/swipl/library/atom.pl +169 -0
  155. package/lib/swipl/library/backcomp.pl +688 -0
  156. package/lib/swipl/library/base32.pl +291 -0
  157. package/lib/swipl/library/base64.pl +441 -0
  158. package/lib/swipl/library/broadcast.pl +161 -0
  159. package/lib/swipl/library/build/cmake.pl +137 -0
  160. package/lib/swipl/library/build/conan.pl +232 -0
  161. package/lib/swipl/library/build/make.pl +168 -0
  162. package/lib/swipl/library/build/tools.pl +825 -0
  163. package/lib/swipl/library/charsio.pl +195 -0
  164. package/lib/swipl/library/check.pl +1097 -0
  165. package/lib/swipl/library/check_installation.pl +912 -0
  166. package/lib/swipl/library/clp/INDEX.pl +157 -0
  167. package/lib/swipl/library/clp/bounds.pl +2036 -0
  168. package/lib/swipl/library/clp/clp_distinct.pl +263 -0
  169. package/lib/swipl/library/clp/clp_events.pl +92 -0
  170. package/lib/swipl/library/clp/clpb.pl +1896 -0
  171. package/lib/swipl/library/clp/clpfd.pl +7906 -0
  172. package/lib/swipl/library/clp/simplex.pl +1580 -0
  173. package/lib/swipl/library/codesio.pl +182 -0
  174. package/lib/swipl/library/coinduction.pl +183 -0
  175. package/lib/swipl/library/console_input.pl +289 -0
  176. package/lib/swipl/library/csv.pl +611 -0
  177. package/lib/swipl/library/ctypes.pl +161 -0
  178. package/lib/swipl/library/date.pl +370 -0
  179. package/lib/swipl/library/dcg/INDEX.pl +35 -0
  180. package/lib/swipl/library/dcg/basics.pl +514 -0
  181. package/lib/swipl/library/dcg/high_order.pl +227 -0
  182. package/lib/swipl/library/debug.pl +499 -0
  183. package/lib/swipl/library/dialect/bim.pl +186 -0
  184. package/lib/swipl/library/dialect/commons.pl +77 -0
  185. package/lib/swipl/library/dialect/eclipse/test_util_iso.pl +355 -0
  186. package/lib/swipl/library/dialect/hprolog/format.pl +44 -0
  187. package/lib/swipl/library/dialect/hprolog.pl +314 -0
  188. package/lib/swipl/library/dialect/ifprolog.pl +1317 -0
  189. package/lib/swipl/library/dialect/iso/iso_predicates.pl +277 -0
  190. package/lib/swipl/library/dialect/sicstus/README.TXT +1 -0
  191. package/lib/swipl/library/dialect/sicstus/arrays.pl +121 -0
  192. package/lib/swipl/library/dialect/sicstus/block.pl +278 -0
  193. package/lib/swipl/library/dialect/sicstus/lists.pl +167 -0
  194. package/lib/swipl/library/dialect/sicstus/ordsets.pl +52 -0
  195. package/lib/swipl/library/dialect/sicstus/sockets.pl +174 -0
  196. package/lib/swipl/library/dialect/sicstus/system.pl +262 -0
  197. package/lib/swipl/library/dialect/sicstus/terms.pl +57 -0
  198. package/lib/swipl/library/dialect/sicstus/timeout.pl +92 -0
  199. package/lib/swipl/library/dialect/sicstus.pl +582 -0
  200. package/lib/swipl/library/dialect/sicstus4/aggregate.pl +60 -0
  201. package/lib/swipl/library/dialect/sicstus4/between.pl +62 -0
  202. package/lib/swipl/library/dialect/sicstus4/clpfd.pl +75 -0
  203. package/lib/swipl/library/dialect/sicstus4/file_systems.pl +413 -0
  204. package/lib/swipl/library/dialect/sicstus4/lists.pl +274 -0
  205. package/lib/swipl/library/dialect/sicstus4/ordsets.pl +54 -0
  206. package/lib/swipl/library/dialect/sicstus4/samsort.pl +86 -0
  207. package/lib/swipl/library/dialect/sicstus4/sets.pl +124 -0
  208. package/lib/swipl/library/dialect/sicstus4/sockets.pl +164 -0
  209. package/lib/swipl/library/dialect/sicstus4/system.pl +80 -0
  210. package/lib/swipl/library/dialect/sicstus4/terms.pl +89 -0
  211. package/lib/swipl/library/dialect/sicstus4/timeout.pl +43 -0
  212. package/lib/swipl/library/dialect/sicstus4/types.pl +103 -0
  213. package/lib/swipl/library/dialect/sicstus4.pl +200 -0
  214. package/lib/swipl/library/dialect/swi/syspred_options.pl +250 -0
  215. package/lib/swipl/library/dialect/xsb/README.md +20 -0
  216. package/lib/swipl/library/dialect/xsb/basics.pl +318 -0
  217. package/lib/swipl/library/dialect/xsb/consult.pl +87 -0
  218. package/lib/swipl/library/dialect/xsb/curr_sym.pl +57 -0
  219. package/lib/swipl/library/dialect/xsb/error_handler.pl +111 -0
  220. package/lib/swipl/library/dialect/xsb/gensym.pl +53 -0
  221. package/lib/swipl/library/dialect/xsb/gpp.pl +138 -0
  222. package/lib/swipl/library/dialect/xsb/intern.pl +48 -0
  223. package/lib/swipl/library/dialect/xsb/lists.pl +47 -0
  224. package/lib/swipl/library/dialect/xsb/machine.pl +295 -0
  225. package/lib/swipl/library/dialect/xsb/ordsets.pl +53 -0
  226. package/lib/swipl/library/dialect/xsb/setof.pl +54 -0
  227. package/lib/swipl/library/dialect/xsb/source.pl +308 -0
  228. package/lib/swipl/library/dialect/xsb/standard.pl +169 -0
  229. package/lib/swipl/library/dialect/xsb/storage.pl +70 -0
  230. package/lib/swipl/library/dialect/xsb/string.pl +76 -0
  231. package/lib/swipl/library/dialect/xsb/thread.pl +62 -0
  232. package/lib/swipl/library/dialect/xsb/timed_call.pl +158 -0
  233. package/lib/swipl/library/dialect/xsb.pl +688 -0
  234. package/lib/swipl/library/dialect/yap/README.TXT +8 -0
  235. package/lib/swipl/library/dialect/yap.pl +283 -0
  236. package/lib/swipl/library/dialect.pl +123 -0
  237. package/lib/swipl/library/dicts.pl +399 -0
  238. package/lib/swipl/library/dif.pl +426 -0
  239. package/lib/swipl/library/edinburgh.pl +138 -0
  240. package/lib/swipl/library/edit.pl +783 -0
  241. package/lib/swipl/library/error.pl +495 -0
  242. package/lib/swipl/library/exceptions.pl +231 -0
  243. package/lib/swipl/library/explain.pl +543 -0
  244. package/lib/swipl/library/ext/RDF/INDEX.pl +25 -0
  245. package/lib/swipl/library/ext/RDF/rdf.pl +450 -0
  246. package/lib/swipl/library/ext/RDF/rdf_parser.pl +649 -0
  247. package/lib/swipl/library/ext/RDF/rdf_triple.pl +448 -0
  248. package/lib/swipl/library/ext/RDF/rdf_write.pl +701 -0
  249. package/lib/swipl/library/ext/RDF/rewrite_term.pl +177 -0
  250. package/lib/swipl/library/ext/chr/chr/a_star.pl +80 -0
  251. package/lib/swipl/library/ext/chr/chr/binomialheap.pl +142 -0
  252. package/lib/swipl/library/ext/chr/chr/builtins.pl +629 -0
  253. package/lib/swipl/library/ext/chr/chr/chr_compiler_errors.pl +179 -0
  254. package/lib/swipl/library/ext/chr/chr/chr_compiler_options.pl +382 -0
  255. package/lib/swipl/library/ext/chr/chr/chr_compiler_utility.pl +338 -0
  256. package/lib/swipl/library/ext/chr/chr/chr_debug.pl +59 -0
  257. package/lib/swipl/library/ext/chr/chr/chr_hashtable_store.pl +425 -0
  258. package/lib/swipl/library/ext/chr/chr/chr_integertable_store.pl +139 -0
  259. package/lib/swipl/library/ext/chr/chr/chr_messages.pl +176 -0
  260. package/lib/swipl/library/ext/chr/chr/chr_op.pl +53 -0
  261. package/lib/swipl/library/ext/chr/chr/chr_runtime.pl +1016 -0
  262. package/lib/swipl/library/ext/chr/chr/chr_translate.pl +25424 -0
  263. package/lib/swipl/library/ext/chr/chr/clean_code.pl +252 -0
  264. package/lib/swipl/library/ext/chr/chr/find.pl +78 -0
  265. package/lib/swipl/library/ext/chr/chr/guard_entailment.pl +19432 -0
  266. package/lib/swipl/library/ext/chr/chr/listmap.pl +108 -0
  267. package/lib/swipl/library/ext/chr/chr/pairlist.pl +78 -0
  268. package/lib/swipl/library/ext/chr/chr.pl +686 -0
  269. package/lib/swipl/library/ext/clib/INDEX.pl +158 -0
  270. package/lib/swipl/library/ext/clib/cgi.pl +86 -0
  271. package/lib/swipl/library/ext/clib/crypt.pl +44 -0
  272. package/lib/swipl/library/ext/clib/filesex.pl +644 -0
  273. package/lib/swipl/library/ext/clib/hash_stream.pl +119 -0
  274. package/lib/swipl/library/ext/clib/mallocinfo.pl +138 -0
  275. package/lib/swipl/library/ext/clib/md5.pl +68 -0
  276. package/lib/swipl/library/ext/clib/memfile.pl +61 -0
  277. package/lib/swipl/library/ext/clib/process.pl +573 -0
  278. package/lib/swipl/library/ext/clib/prolog_server.pl +157 -0
  279. package/lib/swipl/library/ext/clib/prolog_stream.pl +80 -0
  280. package/lib/swipl/library/ext/clib/rlimit.pl +54 -0
  281. package/lib/swipl/library/ext/clib/sched.pl +85 -0
  282. package/lib/swipl/library/ext/clib/sha.pl +162 -0
  283. package/lib/swipl/library/ext/clib/socket.pl +1102 -0
  284. package/lib/swipl/library/ext/clib/streaminfo.pl +103 -0
  285. package/lib/swipl/library/ext/clib/streampool.pl +136 -0
  286. package/lib/swipl/library/ext/clib/syslog.pl +180 -0
  287. package/lib/swipl/library/ext/clib/time.pl +194 -0
  288. package/lib/swipl/library/ext/clib/udp_broadcast.pl +975 -0
  289. package/lib/swipl/library/ext/clib/uid.pl +220 -0
  290. package/lib/swipl/library/ext/clib/unix.pl +317 -0
  291. package/lib/swipl/library/ext/clib/uri.pl +530 -0
  292. package/lib/swipl/library/ext/clib/uuid.pl +207 -0
  293. package/lib/swipl/library/ext/http/http/INDEX.pl +266 -0
  294. package/lib/swipl/library/ext/http/http/README.md +34 -0
  295. package/lib/swipl/library/ext/http/http/ax.pl +189 -0
  296. package/lib/swipl/library/ext/http/http/dcg_basics.pl +49 -0
  297. package/lib/swipl/library/ext/http/http/graphql.pl +1367 -0
  298. package/lib/swipl/library/ext/http/http/html_decl.pl +416 -0
  299. package/lib/swipl/library/ext/http/http/html_head.pl +654 -0
  300. package/lib/swipl/library/ext/http/http/html_quasiquotations.pl +120 -0
  301. package/lib/swipl/library/ext/http/http/html_write.pl +1425 -0
  302. package/lib/swipl/library/ext/http/http/htmx.pl +139 -0
  303. package/lib/swipl/library/ext/http/http/http_authenticate.pl +364 -0
  304. package/lib/swipl/library/ext/http/http/http_client.pl +412 -0
  305. package/lib/swipl/library/ext/http/http/http_cookie.pl +245 -0
  306. package/lib/swipl/library/ext/http/http/http_cors.pl +176 -0
  307. package/lib/swipl/library/ext/http/http/http_digest.pl +820 -0
  308. package/lib/swipl/library/ext/http/http/http_dirindex.pl +296 -0
  309. package/lib/swipl/library/ext/http/http/http_dispatch.pl +1552 -0
  310. package/lib/swipl/library/ext/http/http/http_dyn_workers.pl +214 -0
  311. package/lib/swipl/library/ext/http/http/http_error.pl +126 -0
  312. package/lib/swipl/library/ext/http/http/http_exception.pl +225 -0
  313. package/lib/swipl/library/ext/http/http/http_files.pl +163 -0
  314. package/lib/swipl/library/ext/http/http/http_header.pl +2820 -0
  315. package/lib/swipl/library/ext/http/http/http_hook.pl +106 -0
  316. package/lib/swipl/library/ext/http/http/http_host.pl +204 -0
  317. package/lib/swipl/library/ext/http/http/http_load.pl +113 -0
  318. package/lib/swipl/library/ext/http/http/http_log.pl +738 -0
  319. package/lib/swipl/library/ext/http/http/http_multipart_plugin.pl +232 -0
  320. package/lib/swipl/library/ext/http/http/http_open.pl +1821 -0
  321. package/lib/swipl/library/ext/http/http/http_openid.pl +1561 -0
  322. package/lib/swipl/library/ext/http/http/http_parameters.pl +504 -0
  323. package/lib/swipl/library/ext/http/http/http_path.pl +380 -0
  324. package/lib/swipl/library/ext/http/http/http_proxy.pl +80 -0
  325. package/lib/swipl/library/ext/http/http/http_pwp.pl +351 -0
  326. package/lib/swipl/library/ext/http/http/http_redis_plugin.pl +332 -0
  327. package/lib/swipl/library/ext/http/http/http_server.pl +105 -0
  328. package/lib/swipl/library/ext/http/http/http_server_files.pl +126 -0
  329. package/lib/swipl/library/ext/http/http/http_server_health.pl +186 -0
  330. package/lib/swipl/library/ext/http/http/http_session.pl +1040 -0
  331. package/lib/swipl/library/ext/http/http/http_sgml_plugin.pl +137 -0
  332. package/lib/swipl/library/ext/http/http/http_stream.pl +376 -0
  333. package/lib/swipl/library/ext/http/http/http_unix_daemon.pl +989 -0
  334. package/lib/swipl/library/ext/http/http/http_wrapper.pl +559 -0
  335. package/lib/swipl/library/ext/http/http/hub.pl +600 -0
  336. package/lib/swipl/library/ext/http/http/js_write.pl +461 -0
  337. package/lib/swipl/library/ext/http/http/mimepack.pl +224 -0
  338. package/lib/swipl/library/ext/http/http/mimetype.pl +276 -0
  339. package/lib/swipl/library/ext/http/http/term_html.pl +797 -0
  340. package/lib/swipl/library/ext/http/http/thread_httpd.pl +1181 -0
  341. package/lib/swipl/library/ext/http/http/web/css/dirindex.css +24 -0
  342. package/lib/swipl/library/ext/http/http/web/css/openid.css +57 -0
  343. package/lib/swipl/library/ext/http/http/web/icons/back.png +0 -0
  344. package/lib/swipl/library/ext/http/http/web/icons/c.png +0 -0
  345. package/lib/swipl/library/ext/http/http/web/icons/compressed.png +0 -0
  346. package/lib/swipl/library/ext/http/http/web/icons/folder.png +0 -0
  347. package/lib/swipl/library/ext/http/http/web/icons/generic.png +0 -0
  348. package/lib/swipl/library/ext/http/http/web/icons/layout.png +0 -0
  349. package/lib/swipl/library/ext/http/http/web/icons/openid-logo-square.png +0 -0
  350. package/lib/swipl/library/ext/http/http/web/icons/openid-logo-tiny.png +0 -0
  351. package/lib/swipl/library/ext/http/http/websocket.pl +729 -0
  352. package/lib/swipl/library/ext/http/http/yadis.pl +205 -0
  353. package/lib/swipl/library/ext/json/INDEX.pl +36 -0
  354. package/lib/swipl/library/ext/json/http/INDEX.pl +16 -0
  355. package/lib/swipl/library/ext/json/http/http_json.pl +490 -0
  356. package/lib/swipl/library/ext/json/http/js_grammar.pl +53 -0
  357. package/lib/swipl/library/ext/json/http/json.pl +48 -0
  358. package/lib/swipl/library/ext/json/http/json_convert.pl +48 -0
  359. package/lib/swipl/library/ext/json/json.pl +1215 -0
  360. package/lib/swipl/library/ext/json/json_convert.pl +681 -0
  361. package/lib/swipl/library/ext/json/json_grammar.pl +349 -0
  362. package/lib/swipl/library/ext/json/json_rpc_client.pl +423 -0
  363. package/lib/swipl/library/ext/json/json_rpc_common.pl +104 -0
  364. package/lib/swipl/library/ext/json/json_rpc_server.pl +489 -0
  365. package/lib/swipl/library/ext/json/json_schema.pl +2111 -0
  366. package/lib/swipl/library/ext/nlp/INDEX.pl +15 -0
  367. package/lib/swipl/library/ext/nlp/double_metaphone.pl +86 -0
  368. package/lib/swipl/library/ext/nlp/isub.pl +162 -0
  369. package/lib/swipl/library/ext/nlp/porter_stem.pl +50 -0
  370. package/lib/swipl/library/ext/nlp/snowball.pl +97 -0
  371. package/lib/swipl/library/ext/pcre/INDEX.pl +17 -0
  372. package/lib/swipl/library/ext/pcre/pcre.pl +974 -0
  373. package/lib/swipl/library/ext/plunit/INDEX.pl +20 -0
  374. package/lib/swipl/library/ext/plunit/plunit.pl +2631 -0
  375. package/lib/swipl/library/ext/plunit/test_wizard.pl +249 -0
  376. package/lib/swipl/library/ext/semweb/semweb/INDEX.pl +288 -0
  377. package/lib/swipl/library/ext/semweb/semweb/rdf11.pl +2106 -0
  378. package/lib/swipl/library/ext/semweb/semweb/rdf11_containers.pl +299 -0
  379. package/lib/swipl/library/ext/semweb/semweb/rdf_cache.pl +278 -0
  380. package/lib/swipl/library/ext/semweb/semweb/rdf_compare.pl +132 -0
  381. package/lib/swipl/library/ext/semweb/semweb/rdf_db.pl +3468 -0
  382. package/lib/swipl/library/ext/semweb/semweb/rdf_edit.pl +1145 -0
  383. package/lib/swipl/library/ext/semweb/semweb/rdf_http_plugin.pl +274 -0
  384. package/lib/swipl/library/ext/semweb/semweb/rdf_library.pl +1021 -0
  385. package/lib/swipl/library/ext/semweb/semweb/rdf_litindex.pl +1035 -0
  386. package/lib/swipl/library/ext/semweb/semweb/rdf_ntriples.pl +422 -0
  387. package/lib/swipl/library/ext/semweb/semweb/rdf_persistency.pl +1576 -0
  388. package/lib/swipl/library/ext/semweb/semweb/rdf_portray.pl +182 -0
  389. package/lib/swipl/library/ext/semweb/semweb/rdf_prefixes.pl +681 -0
  390. package/lib/swipl/library/ext/semweb/semweb/rdf_sandbox.pl +153 -0
  391. package/lib/swipl/library/ext/semweb/semweb/rdf_turtle.pl +54 -0
  392. package/lib/swipl/library/ext/semweb/semweb/rdf_turtle_write.pl +1587 -0
  393. package/lib/swipl/library/ext/semweb/semweb/rdf_zlib_plugin.pl +52 -0
  394. package/lib/swipl/library/ext/semweb/semweb/rdfa.pl +1510 -0
  395. package/lib/swipl/library/ext/semweb/semweb/rdfs.pl +475 -0
  396. package/lib/swipl/library/ext/semweb/semweb/sparql_client.pl +643 -0
  397. package/lib/swipl/library/ext/semweb/semweb/turtle.pl +455 -0
  398. package/lib/swipl/library/ext/sgml/DTD/HTML4.dcl +88 -0
  399. package/lib/swipl/library/ext/sgml/DTD/HTML4.dtd +1092 -0
  400. package/lib/swipl/library/ext/sgml/DTD/HTML4.soc +6 -0
  401. package/lib/swipl/library/ext/sgml/DTD/HTML5.dtd +906 -0
  402. package/lib/swipl/library/ext/sgml/DTD/HTMLlat1.ent +195 -0
  403. package/lib/swipl/library/ext/sgml/DTD/HTMLspec.ent +77 -0
  404. package/lib/swipl/library/ext/sgml/DTD/HTMLsym.ent +241 -0
  405. package/lib/swipl/library/ext/sgml/INDEX.pl +64 -0
  406. package/lib/swipl/library/ext/sgml/c14n2.pl +203 -0
  407. package/lib/swipl/library/ext/sgml/iso_639.pl +631 -0
  408. package/lib/swipl/library/ext/sgml/pwp.pl +705 -0
  409. package/lib/swipl/library/ext/sgml/sgml.pl +815 -0
  410. package/lib/swipl/library/ext/sgml/sgml_write.pl +1003 -0
  411. package/lib/swipl/library/ext/sgml/xpath.pl +620 -0
  412. package/lib/swipl/library/ext/sgml/xsdp_types.pl +232 -0
  413. package/lib/swipl/library/ext/ssl/INDEX.pl +60 -0
  414. package/lib/swipl/library/ext/ssl/crypto.pl +1015 -0
  415. package/lib/swipl/library/ext/ssl/http/INDEX.pl +5 -0
  416. package/lib/swipl/library/ext/ssl/http/http_ssl_plugin.pl +296 -0
  417. package/lib/swipl/library/ext/ssl/saml.pl +609 -0
  418. package/lib/swipl/library/ext/ssl/ssl.pl +647 -0
  419. package/lib/swipl/library/ext/ssl/xmldsig.pl +391 -0
  420. package/lib/swipl/library/ext/ssl/xmlenc.pl +354 -0
  421. package/lib/swipl/library/ext/zlib/INDEX.pl +8 -0
  422. package/lib/swipl/library/ext/zlib/zlib.pl +112 -0
  423. package/lib/swipl/library/fastrw.pl +105 -0
  424. package/lib/swipl/library/files.pl +80 -0
  425. package/lib/swipl/library/gensym.pl +111 -0
  426. package/lib/swipl/library/git.pl +1027 -0
  427. package/lib/swipl/library/hashtable.pl +365 -0
  428. package/lib/swipl/library/heaps.pl +252 -0
  429. package/lib/swipl/library/hotfix.pl +239 -0
  430. package/lib/swipl/library/http/jquery.pl +103 -0
  431. package/lib/swipl/library/http/web/js/jquery-3.6.0.min.js +2 -0
  432. package/lib/swipl/library/increval.pl +217 -0
  433. package/lib/swipl/library/intercept.pl +263 -0
  434. package/lib/swipl/library/iostream.pl +237 -0
  435. package/lib/swipl/library/iri_scheme/file.pl +70 -0
  436. package/lib/swipl/library/lazy_lists.pl +481 -0
  437. package/lib/swipl/library/listing.pl +1362 -0
  438. package/lib/swipl/library/lists.pl +860 -0
  439. package/lib/swipl/library/lynx/INDEX.pl +14 -0
  440. package/lib/swipl/library/lynx/format.pl +380 -0
  441. package/lib/swipl/library/lynx/html_style.pl +129 -0
  442. package/lib/swipl/library/lynx/html_text.pl +865 -0
  443. package/lib/swipl/library/lynx/pldoc_style.pl +87 -0
  444. package/lib/swipl/library/macros.pl +451 -0
  445. package/lib/swipl/library/main.pl +1200 -0
  446. package/lib/swipl/library/make.pl +197 -0
  447. package/lib/swipl/library/modules.pl +129 -0
  448. package/lib/swipl/library/nb_rbtrees.pl +267 -0
  449. package/lib/swipl/library/nb_set.pl +203 -0
  450. package/lib/swipl/library/obfuscate.pl +115 -0
  451. package/lib/swipl/library/occurs.pl +241 -0
  452. package/lib/swipl/library/operators.pl +182 -0
  453. package/lib/swipl/library/option.pl +388 -0
  454. package/lib/swipl/library/optparse.pl +966 -0
  455. package/lib/swipl/library/ordsets.pl +518 -0
  456. package/lib/swipl/library/oset.pl +160 -0
  457. package/lib/swipl/library/pairs.pl +187 -0
  458. package/lib/swipl/library/persistency.pl +713 -0
  459. package/lib/swipl/library/pio.pl +47 -0
  460. package/lib/swipl/library/portray_text.pl +277 -0
  461. package/lib/swipl/library/pprint.pl +940 -0
  462. package/lib/swipl/library/predicate_options.pl +975 -0
  463. package/lib/swipl/library/prolog_autoload.pl +233 -0
  464. package/lib/swipl/library/prolog_breakpoints.pl +396 -0
  465. package/lib/swipl/library/prolog_clause.pl +1104 -0
  466. package/lib/swipl/library/prolog_code.pl +416 -0
  467. package/lib/swipl/library/prolog_codewalk.pl +1248 -0
  468. package/lib/swipl/library/prolog_colour.pl +3301 -0
  469. package/lib/swipl/library/prolog_colour.qlf +0 -0
  470. package/lib/swipl/library/prolog_config.pl +154 -0
  471. package/lib/swipl/library/prolog_coverage.pl +1333 -0
  472. package/lib/swipl/library/prolog_debug.pl +404 -0
  473. package/lib/swipl/library/prolog_deps.pl +675 -0
  474. package/lib/swipl/library/prolog_evaluable.pl +234 -0
  475. package/lib/swipl/library/prolog_format.pl +219 -0
  476. package/lib/swipl/library/prolog_history.pl +161 -0
  477. package/lib/swipl/library/prolog_jiti.pl +333 -0
  478. package/lib/swipl/library/prolog_locale.pl +61 -0
  479. package/lib/swipl/library/prolog_metainference.pl +307 -0
  480. package/lib/swipl/library/prolog_pack.pl +3906 -0
  481. package/lib/swipl/library/prolog_profile.pl +346 -0
  482. package/lib/swipl/library/prolog_qlfmake.pl +533 -0
  483. package/lib/swipl/library/prolog_source.pl +1188 -0
  484. package/lib/swipl/library/prolog_stack.pl +794 -0
  485. package/lib/swipl/library/prolog_trace.pl +365 -0
  486. package/lib/swipl/library/prolog_versions.pl +347 -0
  487. package/lib/swipl/library/prolog_wrap.pl +164 -0
  488. package/lib/swipl/library/prolog_xref.pl +3090 -0
  489. package/lib/swipl/library/prolog_xref.qlf +0 -0
  490. package/lib/swipl/library/pure_input.pl +266 -0
  491. package/lib/swipl/library/qpforeign.pl +695 -0
  492. package/lib/swipl/library/qsave.pl +1516 -0
  493. package/lib/swipl/library/quasi_quotations.pl +300 -0
  494. package/lib/swipl/library/quintus.pl +437 -0
  495. package/lib/swipl/library/random.pl +459 -0
  496. package/lib/swipl/library/rbtrees.pl +1153 -0
  497. package/lib/swipl/library/readln.pl +256 -0
  498. package/lib/swipl/library/readutil.pl +304 -0
  499. package/lib/swipl/library/record.pl +544 -0
  500. package/lib/swipl/library/rwlocks.pl +172 -0
  501. package/lib/swipl/library/sandbox.pl +1384 -0
  502. package/lib/swipl/library/semweb/dc.rdfs +198 -0
  503. package/lib/swipl/library/semweb/eor.rdfs +95 -0
  504. package/lib/swipl/library/semweb/owl.owl +287 -0
  505. package/lib/swipl/library/semweb/rdf_library.ttl +90 -0
  506. package/lib/swipl/library/semweb/rdfs.rdfs +251 -0
  507. package/lib/swipl/library/settings.pl +755 -0
  508. package/lib/swipl/library/shell.pl +462 -0
  509. package/lib/swipl/library/shlib.pl +670 -0
  510. package/lib/swipl/library/solution_sequences.pl +439 -0
  511. package/lib/swipl/library/sort.pl +119 -0
  512. package/lib/swipl/library/statistics.pl +541 -0
  513. package/lib/swipl/library/streams.pl +118 -0
  514. package/lib/swipl/library/strings.pl +469 -0
  515. package/lib/swipl/library/system.pl +95 -0
  516. package/lib/swipl/library/tables.pl +381 -0
  517. package/lib/swipl/library/tableutil.pl +771 -0
  518. package/lib/swipl/library/tabling.pl +42 -0
  519. package/lib/swipl/library/terms.pl +457 -0
  520. package/lib/swipl/library/theme/auto.pl +61 -0
  521. package/lib/swipl/library/theme/dark.pl +455 -0
  522. package/lib/swipl/library/theme/light.pl +45 -0
  523. package/lib/swipl/library/thread.pl +810 -0
  524. package/lib/swipl/library/thread_pool.pl +508 -0
  525. package/lib/swipl/library/threadutil.pl +574 -0
  526. package/lib/swipl/library/tty.pl +316 -0
  527. package/lib/swipl/library/ugraphs.pl +644 -0
  528. package/lib/swipl/library/unicode/INDEX.pl +6 -0
  529. package/lib/swipl/library/unicode/blocks.pl +414 -0
  530. package/lib/swipl/library/url.pl +1129 -0
  531. package/lib/swipl/library/utf8.pl +145 -0
  532. package/lib/swipl/library/varnumbers.pl +221 -0
  533. package/lib/swipl/library/vm.pl +251 -0
  534. package/lib/swipl/library/wfs.pl +205 -0
  535. package/lib/swipl/library/when.pl +263 -0
  536. package/lib/swipl/library/writef.pl +278 -0
  537. package/lib/swipl/library/www_browser.pl +251 -0
  538. package/lib/swipl/library/yall.pl +574 -0
  539. package/lib/swipl/library/zip.pl +211 -0
  540. package/lib/swipl/swipl.home +1 -0
  541. package/lib/vendor/libcrypto.so.3 +0 -0
  542. package/lib/vendor/libpcre2-8.so.0 +0 -0
  543. package/lib/vendor/libssl.so.3 +0 -0
  544. package/lib/vendor/libz.so.1 +0 -0
  545. package/licenses/OpenSSL-LICENSE.txt +177 -0
  546. package/licenses/PCRE2-COPYING +5 -0
  547. package/licenses/README.md +12 -0
  548. package/licenses/SWI-Prolog-LICENSE +41 -0
  549. package/licenses/zlib-LICENSE +22 -0
  550. package/package.json +27 -0
@@ -0,0 +1,1226 @@
1
+ /* Part of SWI-Prolog
2
+
3
+ Author: Jan Wielemaker
4
+ E-mail: J.Wielemaker@vu.nl
5
+ WWW: http://www.swi-prolog.org
6
+ Copyright (c) 1985-2025, University of Amsterdam
7
+ VU University Amsterdam
8
+ CWI, Amsterdam
9
+ SWI-Prolog Solutions b.v.
10
+ All rights reserved.
11
+
12
+ Redistribution and use in source and binary forms, with or without
13
+ modification, are permitted provided that the following conditions
14
+ are met:
15
+
16
+ 1. Redistributions of source code must retain the above copyright
17
+ notice, this list of conditions and the following disclaimer.
18
+
19
+ 2. Redistributions in binary form must reproduce the above copyright
20
+ notice, this list of conditions and the following disclaimer in
21
+ the documentation and/or other materials provided with the
22
+ distribution.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27
+ FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28
+ COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
+ POSSIBILITY OF SUCH DAMAGE.
36
+ */
37
+
38
+ :- module('$autoload',
39
+ [ '$find_library'/5,
40
+ '$in_library'/3,
41
+ '$define_predicate'/1,
42
+ '$update_library_index'/1, % +Options
43
+ '$autoload'/1,
44
+
45
+ make_library_index/1,
46
+ make_library_index/2,
47
+ reload_library_index/0,
48
+ autoload_path/1,
49
+
50
+ autoload/1, % +File
51
+ autoload/2, % +File, +Imports
52
+
53
+ autoload_call/1, % :Goal
54
+
55
+ require/1 % +Predicates
56
+ ]).
57
+
58
+ :- meta_predicate
59
+ '$autoload'(:),
60
+ autoload(:),
61
+ autoload(:, +),
62
+ autoload_call(0),
63
+ require(:).
64
+
65
+ :- dynamic
66
+ library_index/3, % Head x Module x Path
67
+ autoload_directories/1, % List
68
+ index_checked_at/1. % Time
69
+ :- volatile
70
+ library_index/3,
71
+ autoload_directories/1,
72
+ index_checked_at/1.
73
+
74
+ user:file_search_path(autoload, swi(library)).
75
+ user:file_search_path(autoload, pce(prolog/lib)).
76
+ user:file_search_path(autoload, app_config(lib)).
77
+ user:file_search_path(autoload, Dir) :-
78
+ '$ext_library_directory'(Dir).
79
+
80
+ :- create_prolog_flag(warn_autoload, false, []).
81
+
82
+ %! '$find_library'(+Module, +Name, +Arity, -LoadModule, -Library) is semidet.
83
+ %
84
+ % Locate a predicate in the library. Name and arity are the name
85
+ % and arity of the predicate searched for. `Module' is the
86
+ % preferred target module. The return values are the full path
87
+ % name (excluding extension) of the library and module declared in
88
+ % that file.
89
+
90
+ '$find_library'(_Module, :, 2, _LoadModule, _Library) :-
91
+ !, fail.
92
+ '$find_library'(Module, Name, Arity, LoadModule, Library) :-
93
+ load_library_index(Name, Arity),
94
+ functor(Head, Name, Arity),
95
+ ( library_index(Head, Module, Library),
96
+ LoadModule = Module
97
+ ; library_index(Head, LoadModule, Library)
98
+ ),
99
+ !.
100
+
101
+ %! '$in_library'(+Name, +Arity, -Path) is semidet.
102
+ %! '$in_library'(-Name, -Arity, -Path) is nondet.
103
+ %
104
+ % Is true if Name/Arity is in the autoload libraries.
105
+
106
+ '$in_library'(Name, Arity, Path) :-
107
+ atom(Name), integer(Arity),
108
+ !,
109
+ Name/Arity \= (:)/2,
110
+ load_library_index(Name, Arity),
111
+ functor(Head, Name, Arity),
112
+ library_index(Head, _, Path).
113
+ '$in_library'(Name, Arity, Path) :-
114
+ load_library_index(Name, Arity),
115
+ library_index(Head, _, Path),
116
+ Head \= _:_,
117
+ functor(Head, Name, Arity).
118
+
119
+ %! '$define_predicate'(:Head)
120
+ %
121
+ % Make sure PredInd can be called. First test if the predicate is
122
+ % defined. If not, invoke the autoloader.
123
+
124
+ :- meta_predicate
125
+ '$define_predicate'(:).
126
+
127
+ '$define_predicate'(Head) :-
128
+ '$defined_predicate'(Head),
129
+ !.
130
+ '$define_predicate'(Term) :-
131
+ Term = Module:Head,
132
+ ( compound(Head)
133
+ -> compound_name_arity(Head, Name, Arity)
134
+ ; Name = Head, Arity = 0
135
+ ),
136
+ '$undefined_procedure'(Module, Name, Arity, retry).
137
+
138
+
139
+ /********************************
140
+ * UPDATE INDEX *
141
+ ********************************/
142
+
143
+ :- thread_local
144
+ silent/0.
145
+
146
+ %! '$update_library_index'(+Options)
147
+ %
148
+ % Called from make/0 to update the index of the library for each
149
+ % library directory that has a writable index. Note that in the
150
+ % Windows version access_file/2 is mostly bogus. We assert
151
+ % silent/0 to suppress error messages. Options:
152
+ %
153
+ % - system(+Boolean)
154
+ % Do (not) include system libraries. Default `false`.
155
+ % - user(+Boolean)
156
+ % Do (not) include user libraries. Default `true`.
157
+
158
+ '$update_library_index'(Options) :-
159
+ setof(Dir, writable_indexed_directory(Dir, Options), Dirs),
160
+ !,
161
+ setup_call_cleanup(
162
+ asserta(silent, Ref),
163
+ guarded_make_library_index(Dirs),
164
+ erase(Ref)),
165
+ ( flag('$modified_index', true, false)
166
+ -> reload_library_index
167
+ ; true
168
+ ).
169
+ '$update_library_index'(_).
170
+
171
+ guarded_make_library_index([]).
172
+ guarded_make_library_index([Dir|Dirs]) :-
173
+ ( catch(make_library_index(Dir), E,
174
+ print_message(error, E))
175
+ -> true
176
+ ; print_message(warning, goal_failed(make_library_index(Dir)))
177
+ ),
178
+ guarded_make_library_index(Dirs).
179
+
180
+ %! writable_indexed_directory(-Dir, +Options) is nondet.
181
+ %
182
+ % True when Dir is an indexed library directory with a writable
183
+ % index, i.e., an index that can be updated.
184
+
185
+ writable_indexed_directory(Dir, Options) :-
186
+ current_prolog_flag(home, Home),
187
+ writable_indexed_directory(Dir),
188
+ ( sub_atom(Dir, 0, _, _, Home)
189
+ -> '$option'(system(true), Options, false)
190
+ ; '$option'(user(true), Options, true)
191
+ ).
192
+
193
+ writable_indexed_directory(Dir) :-
194
+ index_file_name(IndexFile, autoload('INDEX'), [access([read,write])]),
195
+ file_directory_name(IndexFile, Dir).
196
+ writable_indexed_directory(Dir) :-
197
+ absolute_file_name(library('MKINDEX'),
198
+ [ file_type(prolog),
199
+ access(read),
200
+ solutions(all),
201
+ file_errors(fail)
202
+ ], MkIndexFile),
203
+ file_directory_name(MkIndexFile, Dir),
204
+ plfile_in_dir(Dir, 'INDEX', _, IndexFile),
205
+ access_file(IndexFile, write).
206
+
207
+
208
+ /********************************
209
+ * LOAD INDEX *
210
+ ********************************/
211
+
212
+ %! reload_library_index
213
+ %
214
+ % Reload the index on the next call
215
+
216
+ reload_library_index :-
217
+ context_module(M),
218
+ reload_library_index(M).
219
+
220
+ reload_library_index(M) :-
221
+ with_mutex('$autoload', clear_library_index(M)).
222
+
223
+ clear_library_index(M) :-
224
+ retractall(M:library_index(_, _, _)),
225
+ retractall(M:autoload_directories(_)),
226
+ retractall(M:index_checked_at(_)).
227
+
228
+
229
+ %! load_library_index(?Name, ?Arity) is det.
230
+ %! load_library_index(?Name, ?Arity, :IndexSpec) is det.
231
+ %
232
+ % Try to find Name/Arity in the library. If the predicate is
233
+ % there, we are happy. If not, we check whether the set of loaded
234
+ % libraries has changed and if so we reload the index.
235
+
236
+ :- meta_predicate load_library_index(?, ?, :).
237
+ :- public load_library_index/3.
238
+
239
+ load_library_index(Name, Arity) :-
240
+ load_library_index(Name, Arity, autoload('INDEX')).
241
+
242
+ load_library_index(Name, Arity, M:_Spec) :-
243
+ atom(Name), integer(Arity),
244
+ functor(Head, Name, Arity),
245
+ M:library_index(Head, _, _),
246
+ !.
247
+ load_library_index(_, _, Spec) :-
248
+ notrace(with_mutex('$autoload', load_library_index_p(Spec))).
249
+
250
+ load_library_index_p(M:_) :-
251
+ M:index_checked_at(Time),
252
+ get_time(Now),
253
+ Now-Time < 60,
254
+ !.
255
+ load_library_index_p(M:Spec) :-
256
+ findall(Index, index_file_name(Index, Spec, [access(read)]), List0),
257
+ '$list_to_set'(List0, List),
258
+ retractall(M:index_checked_at(_)),
259
+ get_time(Now),
260
+ assert(M:index_checked_at(Now)),
261
+ ( M:autoload_directories(List)
262
+ -> true
263
+ ; retractall(M:library_index(_, _, _)),
264
+ retractall(M:autoload_directories(_)),
265
+ read_index(List, M),
266
+ assert(M:autoload_directories(List))
267
+ ).
268
+
269
+ %! index_file_name(-IndexFile, +Spec, +Options) is nondet.
270
+ %
271
+ % True if IndexFile is an autoload index file. Options is passed
272
+ % to absolute_file_name/3. This predicate searches the path
273
+ % =autoload=.
274
+ %
275
+ % @see file_search_path/2.
276
+
277
+ index_file_name(IndexFile, FileSpec, Options) :-
278
+ absolute_file_name(FileSpec,
279
+ IndexFile,
280
+ [ file_type(prolog),
281
+ solutions(all),
282
+ file_errors(fail)
283
+ | Options
284
+ ]).
285
+
286
+ read_index([], _) :- !.
287
+ read_index([H|T], M) :-
288
+ !,
289
+ read_index(H, M),
290
+ read_index(T, M).
291
+ read_index(Index, M) :-
292
+ print_message(silent, autoload(read_index(Dir))),
293
+ file_directory_name(Index, Dir),
294
+ setup_call_cleanup(
295
+ '$push_input_context'(autoload_index),
296
+ setup_call_cleanup(
297
+ win_open_index(Index, In),
298
+ read_index_from_stream(Dir, In, M),
299
+ close(In)),
300
+ '$pop_input_context').
301
+
302
+ %! win_open_index(+Index, -Stream) is det.
303
+ %
304
+ % Open an INDEX.pl file. When concurrently building the index we may
305
+ % run into sharing violations on Windows.
306
+
307
+ :- if(current_prolog_flag(windows, true)).
308
+ win_open_index(Index, In) :-
309
+ between(1, 10, _),
310
+ catch(open(Index, read, In, [encoding(utf8)]),
311
+ error(permission_error(open, source_sink, _),_), (sleep(0.1),fail)),
312
+ !.
313
+ :- endif.
314
+ win_open_index(Index, In) :-
315
+ open(Index, read, In, [encoding(utf8)]).
316
+
317
+ read_index_from_stream(Dir, In, M) :-
318
+ repeat,
319
+ read(In, Term),
320
+ assert_index(Term, Dir, M),
321
+ !.
322
+
323
+ assert_index(end_of_file, _, _) :- !.
324
+ assert_index(index(Term, Module, File), Dir, M) :-
325
+ !,
326
+ atomic_list_concat([Dir, '/', File], Path),
327
+ assertz(M:library_index(Term, Module, Path)),
328
+ fail.
329
+ assert_index(index(Name, Arity, Module, File), Dir, M) :-
330
+ !, % Read old index format
331
+ functor(Head, Name, Arity),
332
+ head_meta_any(Head),
333
+ assert_index(index(Head, Module, File), Dir, M).
334
+ assert_index(Term, Dir, _) :-
335
+ print_message(error, illegal_autoload_index(Dir, Term)),
336
+ fail.
337
+
338
+
339
+ /********************************
340
+ * CREATE INDEX.pl *
341
+ ********************************/
342
+
343
+ %! make_library_index(+Dir) is det.
344
+ %
345
+ % Create an index for autoloading from the directory Dir. The
346
+ % index file is called INDEX.pl. In Dir contains a file
347
+ % MKINDEX.pl, this file is loaded and we assume that the index is
348
+ % created by directives that appearin this file. Otherwise, all
349
+ % source files are scanned for their module-header and all
350
+ % exported predicates are added to the autoload index.
351
+ %
352
+ % @see make_library_index/2
353
+
354
+ make_library_index(Dir0) :-
355
+ forall(absolute_file_name(Dir0, Dir,
356
+ [ expand(true),
357
+ file_type(directory),
358
+ file_errors(fail),
359
+ solutions(all)
360
+ ]),
361
+ make_library_index2(Dir)).
362
+
363
+ make_library_index2(Dir) :-
364
+ plfile_in_dir(Dir, 'MKINDEX', _MkIndex, AbsMkIndex),
365
+ access_file(AbsMkIndex, read),
366
+ !,
367
+ load_files(user:AbsMkIndex, [silent(true)]).
368
+ make_library_index2(Dir) :-
369
+ findall(Pattern, source_file_pattern(Pattern), PatternList),
370
+ make_library_index2(Dir, PatternList).
371
+
372
+ %! make_library_index(+Dir, +Patterns:list(atom)) is det.
373
+ %
374
+ % Create an autoload index INDEX.pl for Dir by scanning all files
375
+ % that match any of the file-patterns in Patterns. Typically, this
376
+ % appears as a directive in MKINDEX.pl. For example:
377
+ %
378
+ % ```
379
+ % :- prolog_load_context(directory, Dir),
380
+ % make_library_index(Dir, ['*.pl']).
381
+ % ```
382
+ %
383
+ % @see make_library_index/1.
384
+
385
+ make_library_index(Dir0, Patterns) :-
386
+ forall(absolute_file_name(Dir0, Dir,
387
+ [ expand(true),
388
+ file_type(directory),
389
+ file_errors(fail),
390
+ solutions(all)
391
+ ]),
392
+ make_library_index2(Dir, Patterns)).
393
+
394
+ make_library_index2(Dir, Patterns) :-
395
+ plfile_in_dir(Dir, 'INDEX', _Index, AbsIndex),
396
+ ensure_slash(Dir, DirS),
397
+ pattern_files(Patterns, DirS, Files),
398
+ ( library_index_out_of_date(Dir, AbsIndex, Files)
399
+ -> do_make_library_index(AbsIndex, DirS, Files),
400
+ set_flag('$modified_index', true)
401
+ ; true
402
+ ).
403
+
404
+ ensure_slash(Dir, DirS) :-
405
+ ( sub_atom(Dir, _, _, 0, /)
406
+ -> DirS = Dir
407
+ ; atom_concat(Dir, /, DirS)
408
+ ).
409
+
410
+ source_file_pattern(Pattern) :-
411
+ user:prolog_file_type(PlExt, prolog),
412
+ PlExt \== qlf,
413
+ atom_concat('*.', PlExt, Pattern).
414
+
415
+ plfile_in_dir(Dir, Base, PlBase, File) :-
416
+ file_name_extension(Base, pl, PlBase),
417
+ atomic_list_concat([Dir, '/', PlBase], File).
418
+
419
+ pattern_files([], _, []).
420
+ pattern_files([H|T], DirS, Files) :-
421
+ atom_concat(DirS, H, P0),
422
+ expand_file_name(P0, Files0),
423
+ '$append'(Files0, Rest, Files),
424
+ pattern_files(T, DirS, Rest).
425
+
426
+ library_index_out_of_date(_Dir, Index, _Files) :-
427
+ \+ exists_file(Index),
428
+ !.
429
+ library_index_out_of_date(Dir, Index, Files) :-
430
+ time_file(Index, IndexTime),
431
+ ( time_file(Dir, DotTime),
432
+ DotTime - IndexTime > 0.001 % compensate for jitter
433
+ ; '$member'(File, Files), % and rounding
434
+ time_file(File, FileTime),
435
+ FileTime - IndexTime > 0.001
436
+ ),
437
+ !.
438
+
439
+
440
+ do_make_library_index(Index, Dir, Files) :-
441
+ ensure_slash(Dir, DirS),
442
+ '$stage_file'(Index, StagedIndex),
443
+ setup_call_catcher_cleanup(
444
+ open(StagedIndex, write, Out),
445
+ ( print_message(informational, make(library_index(Dir))),
446
+ index_header(Out),
447
+ index_files(Files, DirS, Out)
448
+ ),
449
+ Catcher,
450
+ install_index(Out, Catcher, StagedIndex, Index)).
451
+
452
+ install_index(Out, Catcher, StagedIndex, Index) :-
453
+ catch(close(Out), Error, true),
454
+ ( silent
455
+ -> OnError = silent
456
+ ; OnError = error
457
+ ),
458
+ ( var(Error)
459
+ -> TheCatcher = Catcher
460
+ ; TheCatcher = exception(Error)
461
+ ),
462
+ '$install_staged_file'(TheCatcher, StagedIndex, Index, OnError).
463
+
464
+ %! index_files(+Files, +Directory, +Out:stream) is det.
465
+ %
466
+ % Write index for Files in Directory to the stream Out.
467
+
468
+ index_files([], _, _).
469
+ index_files([File|Files], DirS, Fd) :-
470
+ ( catch(exports(File, Module, Exports, Meta, Public), E,
471
+ print_message(warning, E)),
472
+ nonvar(Module)
473
+ -> atom_concat(DirS, Local, File),
474
+ file_name_extension(Base, _, Local),
475
+ forall(index_term(Exports, Meta, Public, Term),
476
+ format(Fd, 'index(~k, ~k, ~k).~n',
477
+ [Term, Module, Base]))
478
+ ; true
479
+ ),
480
+ index_files(Files, DirS, Fd).
481
+
482
+ index_term(Exports, Meta, _Public, Term) :-
483
+ '$member'(Export, Exports),
484
+ ground(Export),
485
+ export_term(Export, Meta, Term).
486
+ index_term(_Exports, _Meta, Publics, (public):Head) :-
487
+ '$member'(Public, Publics),
488
+ '$pi_head'(Public, Head).
489
+
490
+ export_term(Op, _Meta, Term) :-
491
+ Op = op(_Pri,_Type,_Name),
492
+ !,
493
+ Term = op:Op.
494
+ export_term(PI, Meta, Head) :-
495
+ '$pi_head'(PI, Head),
496
+ ( '$member'(Head, Meta)
497
+ -> true
498
+ ; head_meta_any(Head)
499
+ ).
500
+
501
+ head_meta_any(Head) :-
502
+ ( atom(Head)
503
+ -> true
504
+ ; compound_name_arguments(Head, _, Args),
505
+ meta_any(Args)
506
+ ).
507
+
508
+ meta_any([]).
509
+ meta_any([?|T]) :-
510
+ meta_any(T).
511
+
512
+ index_header(Fd):-
513
+ format(Fd, '/* Creator: make/0~n~n', []),
514
+ format(Fd, ' Purpose: Provide index for autoload~n', []),
515
+ format(Fd, '*/~n~n', []).
516
+
517
+ %! exports(+File, -Module, -Exports) is det.
518
+ %! exports(+File, -Module, -Exports, -Meta) is det.
519
+ %
520
+ % Get the exports from a library as a list of PIs. Exports are all
521
+ % exports of the module header (including op/3 terms) and encountered
522
+ % export/1 directives. Meta are all heads in meta_predicate/1
523
+ % declarations.
524
+
525
+ :- public exports/3. % using by library(prolog_deps).
526
+ exports(File, Module, Exports) :-
527
+ exports(File, Module, Exports, _Meta, _Public).
528
+
529
+ exports(File, Module, Exports, Meta, Public) :-
530
+ ( current_prolog_flag(xref, Old)
531
+ -> true
532
+ ; Old = false
533
+ ),
534
+ setup_call_cleanup(
535
+ set_prolog_flag(xref, true),
536
+ snapshot(exports_(File, Module, Exports, Meta, Public)),
537
+ set_prolog_flag(xref, Old)).
538
+
539
+ exports_(File, Module, Exports, Meta, Public) :-
540
+ State = state(true, _, [], [], []),
541
+ ( '$source_term'(File,
542
+ _Read,_RLayout,
543
+ Term,_TermLayout,
544
+ _Stream,
545
+ [ syntax_errors(quiet)
546
+ ]),
547
+ ( Term = (:- module(M,ModuleExports)),
548
+ is_list(ModuleExports),
549
+ arg(1, State, true)
550
+ -> nb_setarg(1, State, false),
551
+ nb_setarg(2, State, M),
552
+ nb_setarg(3, State, ModuleExports),
553
+ fail
554
+ ; nb_setarg(1, State, false),
555
+ fail
556
+ ; Term = (:- export(Export))
557
+ -> phrase(export_pi(Export), PIs),
558
+ arg(3, State, E0),
559
+ '$append'(E0, PIs, E1),
560
+ nb_setarg(3, State, E1),
561
+ fail
562
+ ; Term = (:- public(Public))
563
+ -> phrase(export_pi(Public), PIs),
564
+ arg(5, State, E0),
565
+ '$append'(E0, PIs, E1),
566
+ nb_setarg(5, State, E1),
567
+ fail
568
+ ; Term = (:- meta_predicate(Heads)),
569
+ phrase(meta(Heads), M1),
570
+ arg(4, State, M0),
571
+ '$append'(M0, M1, M2),
572
+ nb_setarg(4, State, M2)
573
+ ; Term = (:- use_foreign_library(Lib)),
574
+ nonvar(Lib),
575
+ arg(2, State, M),
576
+ atom(M)
577
+ -> catch('$syspreds':use_foreign_library_noi(M:Lib), error(_,_), true),
578
+ fail
579
+ ; Term = (:- Directive),
580
+ nonvar(Directive)
581
+ -> fail
582
+ ; Term == [] % Expansion for conditionals
583
+ -> fail
584
+ ; !
585
+ )
586
+ ; true
587
+ ),
588
+ arg(2, State, Module),
589
+ arg(3, State, Exports),
590
+ arg(4, State, Meta),
591
+ arg(5, State, Public).
592
+
593
+ export_pi(Var) -->
594
+ { var(Var) },
595
+ !.
596
+ export_pi((A,B)) -->
597
+ !,
598
+ export_pi(A),
599
+ export_pi(B).
600
+ export_pi(PI) -->
601
+ { ground(PI) },
602
+ [PI].
603
+
604
+ meta(Var) -->
605
+ { var(Var) },
606
+ !.
607
+ meta((A,B)) -->
608
+ !,
609
+ meta(A),
610
+ meta(B).
611
+ meta(Head) -->
612
+ { callable(Head) },
613
+ [Head].
614
+
615
+
616
+ /*******************************
617
+ * EXTENDING *
618
+ *******************************/
619
+
620
+ %! autoload_path(+Path) is det.
621
+ %
622
+ % Add Path to the libraries that are used by the autoloader. This
623
+ % extends the search path =autoload= and reloads the library
624
+ % index. For example:
625
+ %
626
+ % ==
627
+ % :- autoload_path(library(http)).
628
+ % ==
629
+ %
630
+ % If this call appears as a directive, it is term-expanded into a
631
+ % clause for user:file_search_path/2 and a directive calling
632
+ % reload_library_index/0. This keeps source information and allows
633
+ % for removing this directive.
634
+
635
+ autoload_path(Alias) :-
636
+ ( user:file_search_path(autoload, Alias)
637
+ -> true
638
+ ; assertz(user:file_search_path(autoload, Alias)),
639
+ reload_library_index
640
+ ).
641
+
642
+ system:term_expansion((:- autoload_path(Alias)),
643
+ [ user:file_search_path(autoload, Alias),
644
+ (:- reload_library_index)
645
+ ]).
646
+
647
+
648
+ /*******************************
649
+ * RUNTIME AUTOLOADER *
650
+ *******************************/
651
+
652
+ %! $autoload'(:PI) is semidet.
653
+ %
654
+ % Provide PI by autoloading. This checks:
655
+ %
656
+ % - Explicit autoload/2 declarations
657
+ % - Explicit autoload/1 declarations
658
+ % - The library if current_prolog_flag(autoload, true) holds.
659
+
660
+ '$autoload'(PI) :-
661
+ source_location(File, _Line),
662
+ !,
663
+ setup_call_cleanup(
664
+ '$start_aux'(File, Context),
665
+ '$autoload2'(PI),
666
+ '$end_aux'(File, Context)).
667
+ '$autoload'(PI) :-
668
+ '$autoload2'(PI).
669
+
670
+ '$autoload2'(PI) :-
671
+ setup_call_cleanup(
672
+ leave_sandbox(Old),
673
+ '$autoload3'(PI),
674
+ restore_sandbox(Old)).
675
+
676
+ leave_sandbox(Sandboxed) :-
677
+ current_prolog_flag(sandboxed_load, Sandboxed),
678
+ set_prolog_flag(sandboxed_load, false).
679
+ restore_sandbox(Sandboxed) :-
680
+ set_prolog_flag(sandboxed_load, Sandboxed).
681
+
682
+ '$autoload3'(PI) :-
683
+ autoload_from(PI, LoadModule, FullFile),
684
+ do_autoload(FullFile, PI, LoadModule).
685
+
686
+ %! autoload_from(+PI, -LoadModule, -PlFile) is semidet.
687
+ %
688
+ % True when PI can be defined by loading File which is defined the
689
+ % module LoadModule.
690
+
691
+ autoload_from(Module:PI, LoadModule, FullFile) :-
692
+ autoload_in(Module, explicit),
693
+ current_autoload(Module:File, Ctx, import(Imports)),
694
+ memberchk(PI, Imports),
695
+ library_info(File, Ctx, FullFile, LoadModule, Exports),
696
+ ( pi_in_exports(PI, Exports)
697
+ -> !
698
+ ; autoload_error(Ctx, not_exported(PI, File, FullFile, Exports)),
699
+ fail
700
+ ).
701
+ autoload_from(Module:Name/Arity, LoadModule, FullFile) :-
702
+ autoload_in(Module, explicit),
703
+ PI = Name/Arity,
704
+ current_autoload(Module:File, Ctx, all),
705
+ library_info(File, Ctx, FullFile, LoadModule, Exports),
706
+ pi_in_exports(PI, Exports).
707
+ autoload_from(Module:Name/Arity, LoadModule, Library) :-
708
+ autoload_in(Module, general),
709
+ '$find_library'(Module, Name, Arity, LoadModule, Library).
710
+
711
+ :- public autoload_in/2. % used in syspred
712
+
713
+ autoload_in(Module, How) :-
714
+ current_prolog_flag(autoload, AutoLoad),
715
+ autoload_in(AutoLoad, How, Module),
716
+ !.
717
+
718
+ %! autoload_in(+AutoloadFlag, +AutoloadMode, +TargetModule) is semidet.
719
+
720
+ autoload_in(true, _, _).
721
+ autoload_in(explicit, explicit, _).
722
+ autoload_in(user, _, user).
723
+ autoload_in(user_or_explicit, explicit, _).
724
+ autoload_in(user_or_explicit, _, user).
725
+
726
+
727
+ %! do_autoload(Library, :PI, +LoadModule) is det.
728
+ %
729
+ % Load File, importing PI into the qualified module. File is known to
730
+ % define LoadModule. There are three cases:
731
+ %
732
+ % - The target is the autoload module itself. Uncommon.
733
+ % - We already loaded this module. Note that
734
+ % '$get_predicate_attribute'/3 alone is not enough as it will
735
+ % consider auto-import from `user`. '$c_current_predicate'/2
736
+ % verifies the predicate really exists, but doesn't validate
737
+ % that it is defined.
738
+ % - We must load the module and import the target predicate.
739
+ %
740
+ % @arg Library is an absolute file name, either without extension or
741
+ % with the source (.pl) extension.
742
+
743
+ do_autoload(Library, Module:Name/Arity, LoadModule) :-
744
+ functor(Head, Name, Arity),
745
+ '$update_autoload_level'([autoload(true)], Old),
746
+ verbose_autoload(Module:Name/Arity, Library),
747
+ loadable_file(Library, File),
748
+ '$compilation_mode'(OldComp, database),
749
+ ( Module == LoadModule
750
+ -> ensure_loaded(Module:File)
751
+ ; ( '$c_current_predicate'(_, LoadModule:Head),
752
+ '$get_predicate_attribute'(LoadModule:Head, defined, 1),
753
+ \+ '$loading'(Library)
754
+ -> Module:import(LoadModule:Name/Arity)
755
+ ; use_module(Module:File, [Name/Arity])
756
+ ),
757
+ warn_autoload(Module, LoadModule:Name/Arity)
758
+ ),
759
+ '$set_compilation_mode'(OldComp),
760
+ '$set_autoload_level'(Old),
761
+ '$c_current_predicate'(_, Module:Head).
762
+
763
+ loadable_file(PlFile, File) :-
764
+ exists_file(PlFile), !,
765
+ File = PlFile.
766
+ loadable_file(PlFile, Base) :-
767
+ file_name_extension(Base, pl, PlFile),
768
+ !.
769
+ loadable_file(File, File).
770
+
771
+ verbose_autoload(PI, Library) :-
772
+ current_prolog_flag(verbose_autoload, true),
773
+ !,
774
+ set_prolog_flag(verbose_autoload, false),
775
+ print_message(informational, autoload(PI, Library)),
776
+ set_prolog_flag(verbose_autoload, true).
777
+ verbose_autoload(PI, Library) :-
778
+ print_message(silent, autoload(PI, Library)).
779
+
780
+ %! autoload_call(:Goal)
781
+ %
782
+ % Call Goal, optionally autoloading it first.
783
+
784
+ autoload_call(Goal) :-
785
+ '$pi_head'(PI, Goal),
786
+ ( current_predicate(PI)
787
+ -> true
788
+ ; '$autoload'(PI)
789
+ ),
790
+ call(Goal).
791
+
792
+ %! autoloadable(:Head, -File) is nondet.
793
+ %
794
+ % True when Head can be autoloaded from File. This implements the
795
+ % predicate_property/2 property autoload(File). The module must be
796
+ % instantiated.
797
+
798
+ :- public % used from predicate_property/2
799
+ autoloadable/2.
800
+
801
+ autoloadable(M:Head, FullFile) :-
802
+ atom(M),
803
+ current_module(M),
804
+ autoload_in(M, explicit),
805
+ ( callable(Head)
806
+ -> goal_name_arity(Head, Name, Arity),
807
+ autoload_from(M:Name/Arity, _, FullFile)
808
+ ; findall((M:H)-F, autoloadable_2(M:H, F), Pairs),
809
+ ( '$member'(M:Head-FullFile, Pairs)
810
+ ; current_autoload(M:File, Ctx, all),
811
+ library_info(File, Ctx, FullFile, _, Exports),
812
+ '$member'(PI, Exports),
813
+ '$pi_head'(PI, Head),
814
+ \+ memberchk(M:Head-_, Pairs)
815
+ )
816
+ ).
817
+ autoloadable(M:Head, FullFile) :-
818
+ ( var(M)
819
+ -> autoload_in(any, general)
820
+ ; autoload_in(M, general)
821
+ ),
822
+ ( callable(Head)
823
+ -> goal_name_arity(Head, Name, Arity),
824
+ ( '$find_library'(_, Name, Arity, _, FullFile)
825
+ -> true
826
+ )
827
+ ; '$in_library'(Name, Arity, autoload),
828
+ functor(Head, Name, Arity)
829
+ ).
830
+
831
+
832
+ autoloadable_2(M:Head, FullFile) :-
833
+ current_autoload(M:File, Ctx, import(Imports)),
834
+ library_info(File, Ctx, FullFile, _LoadModule, _Exports),
835
+ '$member'(PI, Imports),
836
+ '$pi_head'(PI, Head).
837
+
838
+ goal_name_arity(Head, Name, Arity) :-
839
+ compound(Head),
840
+ !,
841
+ compound_name_arity(Head, Name, Arity).
842
+ goal_name_arity(Head, Head, 0).
843
+
844
+ %! library_info(+Spec, +AutoloadContext, -FullFile, -Module, -Exports)
845
+ %
846
+ % Find information about a library. Spec is the file specification as
847
+ % it appears in the autoload/1,2 call. AutoloadContext is a term
848
+ % File:Line, providing the location of the directive.
849
+ %
850
+ % @arg FullFile is the source (.pl) file in canonical (absolute)
851
+ % notation.
852
+ % @arg Module is the module defined in FullFile
853
+ % @arg Exports is a list of predicate indicators.
854
+
855
+ library_info(Spec, _, FullFile, Module, Exports) :-
856
+ '$resolved_source_path'(Spec, FullFile, []),
857
+ !,
858
+ ( \+ '$loading_file'(FullFile, _Queue, _LoadThread)
859
+ -> '$current_module'(Module, FullFile),
860
+ '$module_property'(Module, exports(Exports))
861
+ ; library_info_from_file(FullFile, _, Module, Exports)
862
+ ).
863
+ library_info(Spec, Context, FullFile, Module, Exports) :-
864
+ ( Context = (Path:_Line)
865
+ -> Extra = [relative_to(Path)]
866
+ ; Extra = []
867
+ ),
868
+ ( absolute_file_name(Spec, AbsFile,
869
+ [ file_type(prolog),
870
+ access(read),
871
+ file_errors(fail)
872
+ | Extra
873
+ ])
874
+ -> library_info_from_file(AbsFile, FullFile, Module, Exports),
875
+ '$register_resolved_source_path'(Spec, FullFile)
876
+ ; absolute_file_name(Spec, FullFile,
877
+ [ file_type(prolog),
878
+ solutions(all),
879
+ file_errors(fail)
880
+ | Extra
881
+ ]),
882
+ source_file(FullFile),
883
+ '$current_module'(Module, FullFile)
884
+ -> '$module_property'(Module, exports(Exports))
885
+ ; autoload_error(Context, no_file(Spec)),
886
+ fail
887
+ ).
888
+
889
+ library_info_from_file(QlfFile, PlFile, Module, Exports) :-
890
+ file_name_extension(_, qlf, QlfFile),
891
+ !,
892
+ '$qlf_module'(QlfFile, Info),
893
+ _{module:Module, exports:Exports, file:PlFile} :< Info.
894
+ library_info_from_file(PlFile, PlFile, Module, Exports) :-
895
+ setup_call_cleanup(
896
+ '$set_source_module'(OldModule, system),
897
+ setup_call_cleanup(
898
+ '$open_source'(PlFile, In, State, [], []),
899
+ '$term_in_file'(In, _Read, _RLayout, Term, _TLayout, _Stream,
900
+ [PlFile], []),
901
+ '$close_source'(State, true)),
902
+ '$set_source_module'(OldModule)),
903
+ ( Term = (:- module(Module, Exports))
904
+ -> !
905
+ ; nonvar(Term),
906
+ skip_header(Term)
907
+ -> fail
908
+ ; '$domain_error'(module_header, Term)
909
+ ).
910
+
911
+ skip_header(begin_of_file).
912
+
913
+
914
+ :- dynamic printed/3.
915
+ :- volatile printed/3.
916
+
917
+ autoload_error(Context, Error) :-
918
+ suppress(Context, Error),
919
+ !.
920
+ autoload_error(Context, Error) :-
921
+ get_time(Now),
922
+ assertz(printed(Context, Error, Now)),
923
+ print_message(warning, error(autoload(Error), autoload(Context))).
924
+
925
+ suppress(Context, Error) :-
926
+ printed(Context, Error, Printed),
927
+ get_time(Now),
928
+ ( Now - Printed < 1
929
+ -> true
930
+ ; retractall(printed(Context, Error, _)),
931
+ fail
932
+ ).
933
+
934
+
935
+ /*******************************
936
+ * CALLBACK *
937
+ *******************************/
938
+
939
+ :- public
940
+ set_autoload/1.
941
+
942
+ %! set_autoload(+Value) is det.
943
+ %
944
+ % Hook called from set_prolog_flag/2 when autoloading is switched. If
945
+ % the desired value is `false` we should materialize all registered
946
+ % requests for autoloading. We must do so before disabling autoloading
947
+ % as loading the files may require autoloading.
948
+
949
+ set_autoload(FlagValue) :-
950
+ current_prolog_flag(autoload, FlagValue),
951
+ !.
952
+ set_autoload(FlagValue) :-
953
+ \+ autoload_in(FlagValue, explicit, any),
954
+ !,
955
+ setup_call_cleanup(
956
+ nb_setval('$autoload_disabling', true),
957
+ materialize_autoload(Count),
958
+ nb_delete('$autoload_disabling')),
959
+ print_message(informational, autoload(disabled(Count))).
960
+ set_autoload(_).
961
+
962
+ materialize_autoload(Count) :-
963
+ State = state(0),
964
+ forall(current_predicate(M:'$autoload'/3),
965
+ materialize_autoload(M, State)),
966
+ arg(1, State, Count).
967
+
968
+ materialize_autoload(M, State) :-
969
+ ( current_autoload(M:File, Context, Import),
970
+ library_info(File, Context, PlFile, _LoadModule, _Exports),
971
+ arg(1, State, N0),
972
+ N is N0+1,
973
+ nb_setarg(1, State, N),
974
+ loadable_file(PlFile, LoadFile),
975
+ ( Import == all
976
+ -> verbose_autoload(M:all, PlFile),
977
+ use_module(M:LoadFile)
978
+ ; Import = import(Preds)
979
+ -> verbose_autoload(M:Preds, PlFile),
980
+ use_module(M:LoadFile, Preds)
981
+ ),
982
+ fail
983
+ ; true
984
+ ),
985
+ abolish(M:'$autoload'/3).
986
+
987
+
988
+ /*******************************
989
+ * AUTOLOAD/2 *
990
+ *******************************/
991
+
992
+ autoload(M:File) :-
993
+ ( \+ autoload_in(M, explicit)
994
+ ; nb_current('$autoload_disabling', true)
995
+ ),
996
+ !,
997
+ use_module(M:File).
998
+ autoload(M:File) :-
999
+ '$must_be'(filespec, File),
1000
+ source_context(Context),
1001
+ assert_autoload(M, File, Context, all).
1002
+
1003
+ autoload(M:File, Imports) :-
1004
+ ( \+ autoload_in(M, explicit)
1005
+ ; nb_current('$autoload_disabling', true)
1006
+ ),
1007
+ !,
1008
+ use_module(M:File, Imports).
1009
+ autoload(M:File, Imports0) :-
1010
+ '$must_be'(filespec, File),
1011
+ valid_imports(Imports0, Imports),
1012
+ source_context(Context),
1013
+ register_autoloads(Imports, M, File, Context),
1014
+ assert_autoload(M, File, Context, import(Imports)).
1015
+
1016
+ source_context(Path:Line) :-
1017
+ source_location(Path, Line),
1018
+ !.
1019
+ source_context(-).
1020
+
1021
+ %! assert_autoload(+Module, +File, +Context, +Imports) is det.
1022
+ %
1023
+ % Assert that Module can autoload predicates defines in Imports by
1024
+ % loading File. Context provides the file owner of the declaration.
1025
+ %
1026
+ % @arg Imports is either `all` or imports(List). That latter comes
1027
+ % from an autoload/2 directive.
1028
+
1029
+ assert_autoload(Module, File, _, Imports) :-
1030
+ current_autoload(Module:File, _, Imports),
1031
+ !.
1032
+ assert_autoload(Module, File, Context, Imports) :-
1033
+ set_admin_properties(Module),
1034
+ Clause = Module:'$autoload'(File, Context, Imports),
1035
+ '$initialization_context'(Source, Ctx),
1036
+ '$store_admin_clause2'(Clause, _Layout, Source, Ctx).
1037
+
1038
+ set_admin_properties(Module) :-
1039
+ predicate_property(Module:'$autoload'(_,_,_), discontiguous),
1040
+ !.
1041
+ set_admin_properties(Module) :-
1042
+ discontiguous(Module:'$autoload'/3).
1043
+
1044
+ valid_imports(Imports0, Imports) :-
1045
+ '$must_be'(list, Imports0),
1046
+ valid_import_list(Imports0, Imports).
1047
+
1048
+ valid_import_list([], []).
1049
+ valid_import_list([H0|T0], [H|T]) :-
1050
+ '$pi_head'(H0, Head),
1051
+ '$pi_head'(H, Head),
1052
+ valid_import_list(T0, T).
1053
+
1054
+ %! register_autoloads(+ListOfPI, +Module, +File, +Context)
1055
+ %
1056
+ % Put an `autoload` flag on all predicates declared using autoload/2
1057
+ % to prevent duplicates or the user defining the same predicate.
1058
+ %
1059
+ % @arg File is the first argument of autoload/1,2
1060
+
1061
+ register_autoloads([], _, _, _).
1062
+ register_autoloads([PI|T], Module, File, Context) :-
1063
+ PI = Name/Arity,
1064
+ functor(Head, Name, Arity),
1065
+ ( '$get_predicate_attribute'(Module:Head, autoload, 1)
1066
+ -> ( current_autoload(Module:_File0, _Ctx0, import(Imports)),
1067
+ memberchk(PI, Imports)
1068
+ -> '$permission_error'(redefine, imported_procedure, PI),
1069
+ fail
1070
+ ; Done = true
1071
+ )
1072
+ ; '$c_current_predicate'(_, Module:Head), % no auto-import
1073
+ '$get_predicate_attribute'(Module:Head, imported, From)
1074
+ -> ( ( '$resolved_source_path'(File, FullFile)
1075
+ -> true
1076
+ ; '$resolve_source_path'(File, FullFile, [])
1077
+ ),
1078
+ module_property(From, file(FullFile))
1079
+ -> Done = true
1080
+ ; print_message(warning,
1081
+ autoload(already_defined(Module:PI, From))),
1082
+ Done = true
1083
+ )
1084
+ ; true
1085
+ ),
1086
+ ( Done == true
1087
+ -> true
1088
+ ; '$set_predicate_attribute'(Module:Head, autoload, 1)
1089
+ ),
1090
+ register_autoloads(T, Module, File, Context).
1091
+
1092
+ pi_in_exports(PI, Exports) :-
1093
+ '$member'(E, Exports),
1094
+ canonical_pi(E, PI),
1095
+ !.
1096
+
1097
+ canonical_pi(Var, _) :-
1098
+ var(Var), !, fail.
1099
+ canonical_pi(Name/Arity, Name/Arity).
1100
+ canonical_pi(Name//A0, Name/Arity) :-
1101
+ Arity is A0 + 2.
1102
+
1103
+ current_autoload(M:File, Context, Term) :-
1104
+ '$get_predicate_attribute'(M:'$autoload'(_,_,_), defined, 1),
1105
+ M:'$autoload'(File, Context, Term).
1106
+
1107
+ /*******************************
1108
+ * CHECK *
1109
+ *******************************/
1110
+
1111
+ %! warn_autoload(+TargetModule, :PI) is det.
1112
+ %
1113
+ % @arg PI is of the shape LoadModule:Name/Arity.
1114
+
1115
+ warn_autoload(TargetModule, PI) :-
1116
+ current_prolog_flag(warn_autoload, true),
1117
+ \+ current_prolog_flag(xref, true),
1118
+ \+ nb_current('$autoload_warning', true),
1119
+ \+ nowarn_autoload(TargetModule, PI),
1120
+ '$pi_head'(PI, Head),
1121
+ source_file(Head, File),
1122
+ '$source_defines_expansion'(File),
1123
+ setup_call_cleanup(
1124
+ b_setval('$autoload_warning', true),
1125
+ print_message(warning,
1126
+ deprecated(autoload(TargetModule, File, PI, expansion))),
1127
+ nb_delete('$autoload_warning')).
1128
+ warn_autoload(_, _).
1129
+
1130
+ %! nowarn_autoload(+TargetModule, +LoadModulePI) is semidet.
1131
+ %
1132
+ % True when LoadModule:'$nowarn_autoload'(PI,TargetModule) is defined
1133
+ % and true.
1134
+ %
1135
+ % @tbd As is, these facts must be defined by the library being
1136
+ % autoloaded. Possibly we want a specific autoload declaration. As all
1137
+ % this only affects the Prolog libraries, we can always change this.
1138
+ % One option might be this, where `How` is one of `true`, `false` or
1139
+ % `warning`.
1140
+ %
1141
+ % :- autoloadable(PI, How)
1142
+
1143
+ nowarn_autoload(TargetModule, LoadModule:PI) :-
1144
+ NoWarn = LoadModule:'$nowarn_autoload'(PI,TargetModule),
1145
+ '$c_current_predicate'(_, NoWarn),
1146
+ \+ '$get_predicate_attribute'(NoWarn, imported, _From),
1147
+ call(NoWarn).
1148
+
1149
+
1150
+ /*******************************
1151
+ * REQUIRE *
1152
+ *******************************/
1153
+
1154
+ %! require(:ListOfPredIndicators) is det.
1155
+ %
1156
+ % Register the predicates in ListOfPredIndicators for autoloading
1157
+ % using autoload/2 if they are not system predicates.
1158
+
1159
+ require(M:Spec) :-
1160
+ ( is_list(Spec)
1161
+ -> List = Spec
1162
+ ; phrase(comma_list(Spec), List)
1163
+ ), !,
1164
+ require(List, M, FromLib),
1165
+ keysort(FromLib, Sorted),
1166
+ by_file(Sorted, Autoload),
1167
+ forall('$member'(File-Import, Autoload),
1168
+ autoload(M:File, Import)).
1169
+ require(_:Spec) :-
1170
+ '$type_error'(list, Spec).
1171
+
1172
+ require([],_, []).
1173
+ require([H|T], M, Needed) :-
1174
+ '$pi_head'(H, Head),
1175
+ ( '$get_predicate_attribute'(system:Head, defined, 1)
1176
+ -> require(T, M, Needed)
1177
+ ; '$pi_head'(Module:Name/Arity, M:Head),
1178
+ ( '$find_library'(Module, Name, Arity, LoadModule, Library)
1179
+ -> ( current_predicate(LoadModule:Name/Arity)
1180
+ -> Module:import(LoadModule:Name/Arity),
1181
+ require(T, M, Needed)
1182
+ ; Needed = [Library-H|More],
1183
+ require(T, M, More)
1184
+ )
1185
+ ; print_message(error, error(existence_error(procedure, Name/Arity), _)),
1186
+ require(T, M, Needed)
1187
+ )
1188
+ ).
1189
+
1190
+ by_file([], []).
1191
+ by_file([File-PI|T0], [Spec-[PI|PIs]|T]) :-
1192
+ on_path(File, Spec),
1193
+ same_file(T0, File, PIs, T1),
1194
+ by_file(T1, T).
1195
+
1196
+ on_path(Library, library(Base)) :-
1197
+ file_base_name(Library, Base),
1198
+ findall(Path, plain_source(library(Base), Path), [Library]),
1199
+ !.
1200
+ on_path(Library, Library).
1201
+
1202
+ plain_source(Spec, Path) :-
1203
+ absolute_file_name(Spec, PathExt,
1204
+ [ file_type(prolog),
1205
+ access(read),
1206
+ file_errors(fail),
1207
+ solutions(all)
1208
+ ]),
1209
+ file_name_extension(Path, _, PathExt).
1210
+
1211
+ same_file([File-PI|T0], File, [PI|PIs], T) :-
1212
+ !,
1213
+ same_file(T0, File, PIs, T).
1214
+ same_file(List, _, [], List).
1215
+
1216
+ comma_list(Var) -->
1217
+ { var(Var),
1218
+ !,
1219
+ '$instantiation_error'(Var)
1220
+ }.
1221
+ comma_list((A,B)) -->
1222
+ !,
1223
+ comma_list(A),
1224
+ comma_list(B).
1225
+ comma_list(A) -->
1226
+ [A].