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,1333 @@
1
+ /* Part of SWI-Prolog
2
+
3
+ Author: Jan Wielemaker
4
+ E-mail: jan@swi-prolog.org
5
+ WWW: https://www.swi-prolog.org
6
+ Copyright (c) 2006-2024, University of Amsterdam
7
+ VU University Amsterdam
8
+ SWI-Prolog Solutions b.v.
9
+ All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions
13
+ are met:
14
+
15
+ 1. Redistributions of source code must retain the above copyright
16
+ notice, this list of conditions and the following disclaimer.
17
+
18
+ 2. Redistributions in binary form must reproduce the above copyright
19
+ notice, this list of conditions and the following disclaimer in
20
+ the documentation and/or other materials provided with the
21
+ distribution.
22
+
23
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26
+ FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
+ COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
+ POSSIBILITY OF SUCH DAMAGE.
35
+ */
36
+
37
+ :- module(prolog_coverage,
38
+ [ coverage/1, % :Goal
39
+ coverage/2, % :Goal, +Options
40
+ show_coverage/1, % :Options
41
+ show_coverage/2, % :Goal, +Options (deprecated)
42
+ cov_save_data/2, % +File, +Options
43
+ cov_load_data/2, % +File, +Options
44
+ cov_reset/0, %
45
+ cov_property/1 % ?Property
46
+ ]).
47
+ :- autoload(library(apply),
48
+ [exclude/3, maplist/2, convlist/3, maplist/3, maplist/4]).
49
+ :- autoload(library(ordsets), [ord_intersection/3, ord_subtract/3, ord_union/3]).
50
+ :- autoload(library(pairs),
51
+ [ group_pairs_by_key/2,
52
+ pairs_keys_values/3,
53
+ pairs_values/2,
54
+ map_list_to_pairs/3
55
+ ]).
56
+ :- autoload(library(ansi_term), [ansi_format/3]).
57
+ :- autoload(library(filesex), [directory_file_path/3, make_directory_path/1]).
58
+ :- autoload(library(lists),
59
+ [append/3, flatten/2, max_list/2, member/2, append/2, sum_list/2]).
60
+ :- autoload(library(option), [option/2, option/3]).
61
+ :- autoload(library(readutil), [read_line_to_string/2]).
62
+ :- use_module(library(prolog_breakpoints), []).
63
+ :- autoload(library(prolog_clause), [clause_info/4]).
64
+ :- autoload(library(solution_sequences), [call_nth/2, distinct/2]).
65
+ :- use_module(library(debug), [debug/3, assertion/1]).
66
+ :- autoload(library(error), [must_be/2]).
67
+ :- autoload(library(prolog_code), [pi_head/2]).
68
+ :- autoload(library(terms), [mapsubterms/3]).
69
+
70
+ :- set_prolog_flag(generate_debug_info, false).
71
+
72
+ /** <module> Coverage analysis tool
73
+
74
+ The purpose of this module is to find which part of the program has been
75
+ used by a certain goal. Usage is defined in terms of clauses for which
76
+ the _head unification_ succeeded. For each clause we count how often it
77
+ succeeded and how often it failed. In addition we track all _call
78
+ sites_, creating goal-by-goal annotated clauses.
79
+
80
+ The result is represented as a list of clause-references. As the
81
+ references to clauses of dynamic predicates cannot be guaranteed, these
82
+ are omitted from the result.
83
+
84
+ Using coverage/2 with the option annotate(true), implied by ext(Ext) or
85
+ dir(Dir), the analysis creates a line-by-line copy of the source files
86
+ that is annotated with how many times this line was executed and with
87
+ what logical results. These annotations rely on relating executable code
88
+ to source locations which is shared by the source level debugger. Source
89
+ level rewrites due to term or goal expansion may harm the results.
90
+
91
+ The typical usage is to load the program and run the query below to get
92
+ a report by file with percentages and a directory `cov` holding
93
+ annotated files that provide line-by-line annotations. See
94
+ show_coverage/1 for details.
95
+
96
+ ?- coverage(Goal, [dir(cov)]).
97
+
98
+ ## Coverage collection and threads {#coverage-threads}
99
+
100
+ The coverage collect data structure is shared by threads created from
101
+ the thread that is collecting coverage data. Currently, this thread
102
+ should be _joined_ before we can operate on the coverage data.
103
+
104
+ ## Combining coverage data from multiple runs {#coverage-merge}
105
+
106
+ The coverage tools allow both combining data from running multiple
107
+ queries as combining data from multiple Prolog processes.
108
+
109
+ For multiple queries in the same process, coverage data may be collected
110
+ using coverage/1 which, unlike coverage/2, does not change the
111
+ non-deterministic semantics of the `Goal` and adds to the already
112
+ collected data. If no current collection is in progress, the currently
113
+ collected data can be displayed using show_coverage/1.
114
+
115
+ Coverage data may be saved to a file using cov_save_data/2. Saved data
116
+ can be reloaded using cov_load_data/2. Data from multiple Prolog runs
117
+ can be combined in the same file using cov_save_data/2 with the
118
+ append(true) option. When possible, file locking is used to ensure that
119
+ concurrect processes can safely use the same data file. The result can
120
+ be shown by loading the code that was relevant to all runs, use
121
+ cov_load_data/2 and show the result using show_coverage/1.
122
+
123
+ Note that saving an loading the coverage data saves and restores
124
+ references to the clauses as the Nth clause of a predicate defined in a
125
+ specific file. This implies that the program must be loaded in exactly
126
+ the same way, including optimization level, term/goal expansion and
127
+ order of _multifile_ predicates.
128
+
129
+ ## Predicate reference {#coverage-predicates}
130
+ */
131
+
132
+ :- meta_predicate
133
+ coverage(0),
134
+ coverage(0,+), % :Goal, +Options
135
+ show_coverage(:), % +Options
136
+ show_coverage(0,+). % :Goal, +Options (deprecated)
137
+
138
+ :- predicate_options(show_coverage/1, 1,
139
+ [ all(boolean),
140
+ modules(list(atom)),
141
+ roots(list),
142
+ annotate(boolean),
143
+ ext(atom),
144
+ dir(atom),
145
+ line_numbers(boolean),
146
+ color(boolean)
147
+ ]).
148
+ :- predicate_options(coverage/2, 2,
149
+ [ show(boolean),
150
+ pass_to(prolog_coverage:show_coverage/1,1)
151
+ ]).
152
+ :- predicate_options(cov_save_data/2, 2,
153
+ [ append(boolean)
154
+ ]).
155
+ :- predicate_options(cov_load_data/2, 2,
156
+ [ load(boolean),
157
+ silent(boolean)
158
+ ]).
159
+
160
+
161
+ %! coverage(:Goal)
162
+ %
163
+ % As call(Goal), collecting coverage information while Goal is
164
+ % running. If Goal succeeds with a choice point, coverage collection
165
+ % is suspended and resumed if we backtrack into Goal. Calls to
166
+ % coverage/1 may be nested.
167
+
168
+ coverage(Goal) :-
169
+ setup_call_cleanup(
170
+ '$cov_start'(Level),
171
+ cov_run(Goal, Level),
172
+ '$cov_stop'(Level)).
173
+
174
+ cov_run(Goal, Level) :-
175
+ call(Goal),
176
+ deterministic(Det),
177
+ ( Det == true
178
+ -> true
179
+ ; ( '$cov_stop'(Level)
180
+ ; '$cov_start'(Level),
181
+ fail
182
+ )
183
+ ).
184
+
185
+ %! coverage(:Goal, +Options) is semidet.
186
+ %
187
+ % Collect and optionally report coverage by Goal. Goal is executed as
188
+ % in once/1. Options processed:
189
+ %
190
+ % - show(+Boolean)
191
+ % When `true` (default), call show_coverage/1 passing Options
192
+ % to show the collected coverage data and reset the data. When
193
+ % `false`, collect the data but do not reset it. If there is
194
+ % already existing data the new data is added.
195
+
196
+ coverage(Goal, Options) :-
197
+ clean_output(Options),
198
+ setup_call_cleanup(
199
+ '$cov_start'(Level),
200
+ once(Goal),
201
+ cov_finish(Level, Options)).
202
+
203
+ show_coverage(Goal, Options) :-
204
+ print_message(warning, coverage(deprecated(show_coverage/2))),
205
+ coverage(Goal, Options).
206
+
207
+ cov_finish(Level, Options) :-
208
+ option(show(true), Options, true),
209
+ !,
210
+ '$cov_stop'(Level),
211
+ ( Level == 1
212
+ -> show_coverage(Options),
213
+ cov_reset
214
+ ; true
215
+ ).
216
+ cov_finish(Level, _) :-
217
+ '$cov_stop'(Level).
218
+
219
+
220
+ %! show_coverage(+Options) is det.
221
+ %
222
+ % Show collected coverage data. By default it reports the percentage
223
+ % of called and failed clauses related to covered files. Using
224
+ % dir(Dir), detailed line-by-line annotated files are created in the
225
+ % directory Dir. Other options control the level of detail.
226
+ %
227
+ % - all(+Boolean)
228
+ % When true, report on any file in which some predicate was
229
+ % called.
230
+ % - modules(+Modules)
231
+ % Only report on files that implement one of the given Modules.
232
+ % - roots(+Directories)
233
+ % Only report on files below one of the given roots. Each
234
+ % directory in Directories can be a specification for
235
+ % absolute_file_name/3.
236
+ % - annotate(+Bool)
237
+ % Create an annotated file for the detailed results.
238
+ % This is implied if the `ext` or `dir` option are
239
+ % specified.
240
+ % - ext(+Ext)
241
+ % Extension to use for the annotated file. Default is
242
+ % `.cov`.
243
+ % - dir(+Dir)
244
+ % Dump the annotations in the given directory. If not
245
+ % given, the annotated files are created in the same
246
+ % directory as the source file. Each clause that is
247
+ % related to a physical line in the file is annotated
248
+ % with one of:
249
+ %
250
+ % | ### | Clause was never executed. |
251
+ % | ++N | Clause was entered N times and always succeeded |
252
+ % | --N | Clause was entered N times and never succeeded |
253
+ % | +N-M | Clause has succeeded N times and failed M times |
254
+ % | +N*M | Clause was entered N times and succeeded M times |
255
+ %
256
+ % All _call sites_ are annotated using the same conventions,
257
+ % except that `---` is used to annotate subgoals that were
258
+ % never called.
259
+ % - line_numbers(Boolean)
260
+ % If `true` (default), add line numbers to the annotated file.
261
+ % - color(Boolean)
262
+ % Controls using ANSI escape sequences to color the output
263
+ % in the annotated source. Default is `true`.
264
+ % - width(+Columns)
265
+ % Presumed width of the output window. A value of 40 is
266
+ % considered the minimum. Smaller values are handled as 40.
267
+ %
268
+ % For example, run a goal and create annotated files in a directory
269
+ % `cov` using:
270
+ %
271
+ % ?- show_coverage([dir(cov)]).
272
+ %
273
+ % @bug Color annotations are created using ANSI escape sequences. On
274
+ % most systems these are displayed if the file is printed on the
275
+ % terminal. On most systems `less` may be used with the ``-r`` flag.
276
+ % Alternatively, programs such as `ansi2html` (Linux) may be used to
277
+ % convert the files to HTML. It would probably be better to integrate
278
+ % the output generation with library(pldoc/doc_htmlsrc).
279
+
280
+ show_coverage(_:Options), is_list(Options) =>
281
+ covered(Succeeded, Failed),
282
+ ( report_hook(Succeeded, Failed)
283
+ -> true
284
+ ; file_coverage(Succeeded, Failed, Options)
285
+ ).
286
+ show_coverage(_:Goal), Goal=_:Call, callable(Call) =>
287
+ print_message(warning, cov_deprecated(show_coverage)),
288
+ coverage(Goal, []).
289
+ show_coverage(_:Options) =>
290
+ must_be(list, Options).
291
+
292
+ %! covered(-Succeeded, -Failed) is det.
293
+ %
294
+ % Collect failed and succeeded clauses.
295
+
296
+ covered(Succeeded, Failed) :-
297
+ findall(Cl, ('$cov_data'(clause(Cl), Enter, 0), Enter > 0), Failed0),
298
+ findall(Cl, ('$cov_data'(clause(Cl), _, Exit), Exit > 0), Succeeded0),
299
+ sort(Failed0, Failed),
300
+ sort(Succeeded0, Succeeded).
301
+
302
+
303
+ /*******************************
304
+ * REPORTING *
305
+ *******************************/
306
+
307
+ %! file_coverage(+Succeeded, +Failed, +Options) is det.
308
+ %
309
+ % Write a report on the clauses covered organised by file to current
310
+ % output. Show detailed information about the non-coverered clauses
311
+ % defined in the modules Modules.
312
+
313
+ file_coverage(Succeeded, Failed, Options) :-
314
+ abolish_module_tables(prolog_coverage),
315
+ findall(File-PrintFile,
316
+ report_file(File, PrintFile, Succeeded, Failed, Options),
317
+ Pairs),
318
+ Pairs \== [],
319
+ !,
320
+
321
+ ( option(width(W0), Options)
322
+ -> W is max(40, W0)
323
+ ; pairs_values(Pairs, PrintFiles),
324
+ maplist(atom_length, PrintFiles, Lengths),
325
+ max_list(Lengths, Longest),
326
+ IdealWidth is Longest+21,
327
+
328
+ tty_width(Width, Options),
329
+ W is min(IdealWidth, Width - 2)
330
+ ),
331
+ CovCol is W - 6,
332
+ ClausesCol is CovCol - 6,
333
+
334
+ header('Coverage by File', W),
335
+ ansi_format(bold, '~w~t~w~*|~t~w~*|~t~w~*|~n',
336
+ ['File', 'Clauses', ClausesCol, '%Cov', CovCol, '%Fail', W]),
337
+ hr(W),
338
+ forall(member(File-_, Pairs),
339
+ file_summary(File, Succeeded, Failed,
340
+ W, CovCol, ClausesCol,
341
+ Options)),
342
+ hr(W),
343
+
344
+ ( annotate_files(Options)
345
+ -> forall(member(File-_, Pairs),
346
+ file_details(File, Succeeded, Failed, Options)),
347
+ progress_done('done', [])
348
+ ; true
349
+ ).
350
+ file_coverage(_Succeeded, _Failed, _Options) :-
351
+ print_message(warning, coverage(no_files_to_report)).
352
+
353
+ %! report_file(?File, -PrintFile, -Succeeded, -Failed, +Options) is semidet
354
+
355
+ report_file(File, PrintFile, Succeeded, Failed, Options) :-
356
+ ( nonvar(File)
357
+ -> true
358
+ ; ( source_file(File)
359
+ ; distinct(File, source_includes(_, File))
360
+ )
361
+ ),
362
+ cov_report_file(File, PrintFile, Options),
363
+ cov_clause_sets(File, Succeeded, Failed, Sets),
364
+ \+ ( Sets.failed == [],
365
+ Sets.succeeded == []
366
+ ).
367
+
368
+ %! source_includes(?Main, ?Included) is nondet.
369
+ %
370
+ % True when Included is (recursively) included in the "true" source
371
+ % fine Main.
372
+
373
+ :- table source_includes/2.
374
+
375
+ source_includes(Main, Included) :-
376
+ nonvar(Main),
377
+ !,
378
+ source_file_property(Main, includes(File, _Time)),
379
+ ( Included = File
380
+ ; source_includes(File, Included)
381
+ ).
382
+ source_includes(Main, Included) :-
383
+ nonvar(Included),
384
+ !,
385
+ source_file_property(Included, included_in(Parent, _Time)),
386
+ ( no_included_file(Parent)
387
+ -> Main = Parent
388
+ ; source_includes(Main, Parent)
389
+ ).
390
+ source_includes(Main, Included) :-
391
+ source_file(Main), % generator
392
+ source_includes(Main, Included).
393
+
394
+ main_source(File, Main) :-
395
+ no_included_file(File),
396
+ !,
397
+ Main = File.
398
+ main_source(File, Main) :-
399
+ source_includes(Main, File).
400
+
401
+ %! file_summary(+File, +Succeeded, +Failed,
402
+ %! +Width, +CovCol, +ClausesCol, +Options) is det.
403
+ %
404
+ % Write a summary with the file and clause percentages on a single
405
+ % line.
406
+
407
+ file_summary(File, Succeeded, Failed, W, CovCol, ClausesCol, Options) :-
408
+ cov_report_file(File, PrintFile, Options),
409
+ cov_clause_sets(File, Succeeded, Failed, Sets0),
410
+ \+ ( Sets0.failed == [],
411
+ Sets0.succeeded == []
412
+ ),
413
+ !,
414
+ deduplicate_clauses(File, Sets0, Sets),
415
+
416
+ length(Sets.clauses, AC),
417
+ length(Sets.uncovered, UC),
418
+ length(Sets.failed, FC),
419
+
420
+ CP is 100-100*UC/AC,
421
+ FCP is 100*FC/AC,
422
+ summary(PrintFile, ClausesCol-8, SFile),
423
+ format('~w ~`.t ~D~*| ~t~1f~*| ~t~1f~*|~n',
424
+ [SFile, AC, ClausesCol, CP, CovCol, FCP, W]).
425
+ file_summary(_,_,_,_,_,_,_).
426
+
427
+ file_details(File, Succeeded, Failed, Options) :-
428
+ cov_report_file(File, _PrintFile, Options),
429
+ cov_clause_sets(File, Succeeded, Failed, Sets0),
430
+ \+ ( Sets0.failed == [],
431
+ Sets0.succeeded == []
432
+ ),
433
+ !,
434
+ deduplicate_clauses(File, Sets0, Sets),
435
+ ord_union(Sets.failed, Sets.succeeded, Covered),
436
+ detailed_report(Sets.uncovered, Covered, File, Options).
437
+ file_details(_,_,_,_).
438
+
439
+ %! cov_clause_sets(+File, +Succeeded, +Failed, -Sets) is det.
440
+
441
+ cov_clause_sets(File, Succeeded, Failed,
442
+ #{ clauses: All_wo_system,
443
+ succeeded: Succeeded_wo_system,
444
+ failed: Failed_wo_system,
445
+ uncovered: Uncovered_wo_system
446
+ }) :-
447
+ file_clauses(File, FileClauses),
448
+ ord_intersection(FileClauses, Failed, FailedInFile),
449
+ ord_intersection(FileClauses, Succeeded, SucceededInFile),
450
+ ord_subtract(FileClauses, SucceededInFile, UnCov1),
451
+ ord_subtract(UnCov1, FailedInFile, Uncovered),
452
+
453
+ clean_set(FileClauses, All_wo_system),
454
+ clean_set(SucceededInFile, Succeeded_wo_system),
455
+ clean_set(FailedInFile, Failed_wo_system),
456
+ clean_set(Uncovered, Uncovered_wo_system).
457
+
458
+ clean_set(Clauses, UserClauses) :-
459
+ exclude(is_pldoc, Clauses, Clauses_wo_pldoc),
460
+ exclude(is_system_clause, Clauses_wo_pldoc, UserClauses).
461
+
462
+ is_system_clause(Clause) :-
463
+ clause_pi(Clause, Name),
464
+ Name = system:_.
465
+
466
+ is_pldoc(Clause) :-
467
+ clause_pi(Clause, _Module:Name2/_Arity),
468
+ pldoc_predicate(Name2).
469
+
470
+ pldoc_predicate('$pldoc').
471
+ pldoc_predicate('$mode').
472
+ pldoc_predicate('$pred_option').
473
+ pldoc_predicate('$exported_op'). % not really PlDoc ...
474
+
475
+ summary(String, MaxLen, Summary) :-
476
+ string_length(String, Len),
477
+ ( Len < MaxLen
478
+ -> Summary = String
479
+ ; SLen is MaxLen - 5,
480
+ sub_string(String, _, SLen, 0, End),
481
+ string_concat('...', End, Summary)
482
+ ).
483
+
484
+ %! file_clauses(+File, -Set) is det.
485
+ %
486
+ % Set are all clauses in File as an ordered set.
487
+
488
+ file_clauses(File, Set) :-
489
+ findall(Cl, clause_source(Cl, File, _), Clauses),
490
+ sort(Clauses, Set).
491
+
492
+ %! clause_source(+Clause, -File, -Line) is semidet.
493
+ %! clause_source(-Clause, +File, -Line) is semidet.
494
+
495
+ clause_source(Clause, File, Line) :-
496
+ nonvar(Clause),
497
+ !,
498
+ clause_property(Clause, file(File)),
499
+ clause_property(Clause, line_count(Line)).
500
+ clause_source(Clause, File, Line) :-
501
+ clause_in_file(File, File, Clause, Line).
502
+ clause_source(Clause, File, Line) :-
503
+ source_includes(Main, File),
504
+ clause_in_file(Main, File, Clause, Line).
505
+
506
+ clause_in_file(Main, Source, Clause, Line) :-
507
+ Pred = _:_,
508
+ source_file(Pred, Main),
509
+ \+ predicate_property(Pred, multifile),
510
+ nth_clause(Pred, _Index, Clause),
511
+ clause_property(Clause, file(Source)),
512
+ clause_property(Clause, line_count(Line)).
513
+ clause_in_file(_Main, Source, Clause, Line) :-
514
+ Pred = _:_,
515
+ predicate_property(Pred, multifile),
516
+ nth_clause(Pred, _Index, Clause),
517
+ clause_property(Clause, file(Source)),
518
+ clause_property(Clause, line_count(Line)).
519
+
520
+ %! deduplicate_clauses(+File, +ClauseSetsIn, -ClauseSetsOut) is det.
521
+ %
522
+ % @arg ClauseSetsIn is a dict with `clauses`, `uncovered`, `failed`
523
+ % and `succeeded`.
524
+
525
+ deduplicate_clauses(File, Set, Set) :-
526
+ no_included_file(File),
527
+ !.
528
+ deduplicate_clauses(_File, SetIn, SetOut) :-
529
+ _{clauses:AC, uncovered:UC, failed:FC, succeeded:FS} :< SetIn,
530
+ clause_duplicates(AC, AC1),
531
+ clause_duplicates(UC, UC1),
532
+ clause_duplicates(FC, FC1),
533
+ clause_duplicates(FS, FS1),
534
+ exclude(covered_in_some_file(AC1, FC, FS), UC1, UC2),
535
+ exclude(succeeded_in_some_file(AC1, FS), FC1, FC2),
536
+ SetOut = SetIn.put(_{clauses:AC1, uncovered:UC2, failed:FC2, succeeded:FS1}).
537
+
538
+ no_included_file(File) :-
539
+ source_file(File).
540
+
541
+ %! clause_duplicates(+Clauses, -Sets) is det.
542
+ %
543
+ % Assuming Clauses is a list of clauses associated with a file that
544
+ % was included multiple times, get the equivalent clauses as sets.
545
+ % Note that we know all Clauses come from the same file.
546
+ %
547
+ % @arg Sets is an ordered set of ordered sets of clause references
548
+ % that form an equivalence group.
549
+
550
+ clause_duplicates(Clauses, Sets) :-
551
+ maplist(clause_dedup_data, Clauses, Dedups),
552
+ sort(2, @=<, Dedups, ByMain), % first my line
553
+ sort(1, @=<, ByMain, ByLine), % then by main
554
+ clause_sets(ByLine, Sets0),
555
+ sort(Sets0, Sets).
556
+
557
+ clause_dedup_data(Clause, dd(Line, Main, Clause)) :-
558
+ clause_property(Clause, line_count(Line)),
559
+ clause_property(Clause, source(Main)).
560
+
561
+ clause_sets([], []).
562
+ clause_sets([H|T0], Sets) :-
563
+ same_line_clauses(H, SameL, T0, T1),
564
+ same_line_clause_sets([H|SameL], Sets, More),
565
+ clause_sets(T1, More).
566
+
567
+ same_line_clauses(CRef, [H|TS], [H|T0], T) :-
568
+ arg(1, CRef, Line),
569
+ arg(1, H, Line),
570
+ !,
571
+ same_line_clauses(CRef, TS, T0, T).
572
+ same_line_clauses(_, [], L, L).
573
+
574
+ %! same_line_clause_sets(+DDClauses, -Sets, ?Tail) is det.
575
+ %
576
+ % Given that DDClauses is a list of dd(Line, File, Clause) each with
577
+ % the same `Line` and ordered on File, compute the sets of equivalent
578
+ % clauses.
579
+ %
580
+ % First we deal with the common case where there is at most one clause
581
+ % per file. Then we consider them all the same.
582
+
583
+ same_line_clause_sets([], Sets, Sets) :-
584
+ !.
585
+ same_line_clause_sets(SameL, Sets, More) :-
586
+ map_list_to_pairs(arg(2), SameL, Pairs),
587
+ group_pairs_by_key(Pairs, ByFile),
588
+ pairs_values(ByFile, FileSets),
589
+ \+ member([_,_|_], FileSets),
590
+ !,
591
+ maplist(arg(3), SameL, Clauses0),
592
+ sort(Clauses0, Clauses),
593
+ Sets = [Clauses|More].
594
+ same_line_clause_sets([H|T0], [Clauses|Sets], More) :-
595
+ same_clauses(H, Same, T0, T),
596
+ maplist(arg(3), [H|Same], Clauses0),
597
+ sort(Clauses0, Clauses),
598
+ same_line_clause_sets(T, Sets, More).
599
+
600
+ same_clauses(CRef, [Same|TS], L0, L) :-
601
+ select(Same, L0, L1),
602
+ same_clause(CRef, Same),
603
+ !,
604
+ same_clauses(CRef, TS, L1, L).
605
+ same_clauses(_, [], L, L).
606
+
607
+ same_clause(dd(L1, F1, C1), dd(L2, F2, C2)) :-
608
+ assertion(L1 == L2),
609
+ F1 \== F2,
610
+ clause_property(C1, size(Size)),
611
+ clause_property(C2, size(Size)),
612
+ clause(Head0, Body1, C1),
613
+ clause(Head1, Body2, C2),
614
+ mapsubterms(unqualify, (Head0:-Body1), Clause1),
615
+ mapsubterms(unqualify, (Head1:-Body2), Clause2),
616
+ Clause1 =@= Clause2.
617
+
618
+ unqualify(_:X, X).
619
+
620
+ covered_in_some_file(AllEQ, Failed, Succeeded, UncoveredSet) :-
621
+ member(Clause, UncoveredSet),
622
+ member(EQSet, AllEQ),
623
+ memberchk(Clause, EQSet),
624
+ !,
625
+ member(Cl2, EQSet),
626
+ ( memberchk(Cl2, Succeeded)
627
+ ; memberchk(Cl2, Failed)
628
+ ),
629
+ !.
630
+ covered_in_some_file(_AllEQ, _Failed, _Succeeded, _UncoveredSet) :-
631
+ assertion(fail).
632
+
633
+ succeeded_in_some_file(AllEQ, Succeeded, FailedSet) :-
634
+ member(Clause, FailedSet),
635
+ member(EQSet, AllEQ),
636
+ memberchk(Clause, EQSet),
637
+ !,
638
+ member(Cl2, EQSet),
639
+ memberchk(Cl2, Succeeded),
640
+ !.
641
+ succeeded_in_some_file(_AllEQ, _Succeeded, _FailedSet) :-
642
+ assertion(fail).
643
+
644
+ %! cov_report_file(+File, -PrintFile, +Options) is semidet.
645
+ %
646
+ % Whether or not to report on File. Scenarios:
647
+ %
648
+ % - all(true)
649
+ % Report on every file.
650
+ % - modules(List)
651
+ % Report of the file implements one of the modules in List.
652
+ % - roots(+Dirs)
653
+ % Report if the file appears below one of Dirs.
654
+ % - (default)
655
+ % Report if the file implements a `user` or `test` module.
656
+
657
+ cov_report_file(File, _, _) :-
658
+ source_file(cov_report_file(_,_,_), File),
659
+ !,
660
+ fail. % do not report on myself
661
+ cov_report_file(File, File, Options) :-
662
+ option(all(true), Options),
663
+ !.
664
+ cov_report_file(File, File, Options) :-
665
+ option(modules(Modules), Options),
666
+ file_module(File, M),
667
+ memberchk(M, Modules),
668
+ !.
669
+ cov_report_file(File, PrintFile, Options) :-
670
+ option(roots(Roots), Options),
671
+ !,
672
+ must_be(list, Roots),
673
+ member(Root, Roots),
674
+ absolute_file_name(Root, Path,
675
+ [ file_type(directory),
676
+ solutions(all),
677
+ file_errors(fail)
678
+ ]),
679
+ ensure_slash(Path, Path1),
680
+ atom_concat(Path1, PrintFile, File),
681
+ !.
682
+ cov_report_file(File, File, _Options) :-
683
+ ( file_module(File, M),
684
+ module_property(M, class(user))
685
+ -> true
686
+ ; forall(source_file_property(File, module(M)),
687
+ module_property(M, class(test)))
688
+ ).
689
+
690
+ file_module(File, Module) :-
691
+ source_file_property(File, module(Module)).
692
+ file_module(File, Module) :-
693
+ source_includes(Main, File),
694
+ file_module(Main, Module).
695
+
696
+ ensure_slash(Path, Path) :-
697
+ sub_atom(Path, _, _, 0, /),
698
+ !.
699
+ ensure_slash(Path, Path1) :-
700
+ atom_concat(Path, /, Path1).
701
+
702
+ %! annotate_files(+Options) is semidet.
703
+
704
+ annotate_files(Options) :-
705
+ ( option(annotate(true), Options)
706
+ ; option(dir(_), Options)
707
+ ; option(ext(_), Options)
708
+ ),
709
+ !.
710
+
711
+ %! detailed_report(+Uncovered, +Covered, +File:atom, +Options) is det
712
+ %
713
+ % Generate a detailed report for File. Depending on Options, this
714
+ % either creates an annotated version of File or it generates a per
715
+ % clause report of non-covered clauses.
716
+ %
717
+ % @arg Uncovered is a list of uncovered clauses. If File is an
718
+ % included file, it is a list of sets of clause references that
719
+ % represent the same clause.
720
+ % @arg Covered is a list of covered clauses. As with Uncovered,
721
+ % this is a list of sets for an included File
722
+
723
+ detailed_report(Uncovered, Covered, File, Options):-
724
+ annotate_files(Options),
725
+ !,
726
+ convlist(line_annotation(File, uncovered), Uncovered, Annot1),
727
+ convlist(line_annotation(File, covered), Covered, Annot20),
728
+ flatten(Annot20, Annot2),
729
+ append(Annot1, Annot2, AnnotationsLen),
730
+ pairs_keys_values(AnnotationsLen, Annotations, Lens),
731
+ max_list(Lens, MaxLen),
732
+ Margin is MaxLen+1,
733
+ annotate_file(File, Annotations, [margin(Margin)|Options]).
734
+ detailed_report(Uncovered, _, File, _Options):-
735
+ convlist(uncovered_clause_line(File), Uncovered, Pairs),
736
+ sort(Pairs, Pairs_sorted),
737
+ group_pairs_by_key(Pairs_sorted, Compact_pairs),
738
+ nl,
739
+ file_base_name(File, Base),
740
+ format('~2|Clauses not covered from file ~p~n', [Base]),
741
+ format('~4|Predicate ~59|Clauses at lines ~n', []),
742
+ maplist(print_clause_line, Compact_pairs),
743
+ nl.
744
+
745
+ line_annotation(File, uncovered, Clause, Annotation) :-
746
+ !,
747
+ clause_or_set_source_location(Clause, File, Line),
748
+ Annotation = (Line-ansi(error,###))-3.
749
+ line_annotation(File, covered, ClauseOrSet, [HeadAllot|CallSites]) :-
750
+ clause_or_set_source_location(ClauseOrSet, File, Line),
751
+ clause_or_set_cov_data(ClauseOrSet, Entered, Exited),
752
+ line_annotation_msg(line_anot(Line, 0, Entered, Exited), HeadAllot),
753
+ flatten([ClauseOrSet], Clauses),
754
+ maplist(clause_call_site_annotations, Clauses, AnnotSets),
755
+ append(AnnotSets, Annots),
756
+ join_annots(Annots, Joined),
757
+ maplist(line_annotation_msg, Joined, CallSites),
758
+ check_correct_offsets(Clauses, AnnotSets).
759
+
760
+ clause_or_set_source_location([Clause|_], File, Line) =>
761
+ clause_property(Clause, file(File)),
762
+ clause_property(Clause, line_count(Line)).
763
+ clause_or_set_source_location(Clause, File, Line) =>
764
+ clause_property(Clause, file(File)),
765
+ clause_property(Clause, line_count(Line)).
766
+
767
+ clause_or_set_cov_data(Clause, Entered, Exited),
768
+ blob(Clause, clause) =>
769
+ '$cov_data'(clause(Clause), Entered, Exited).
770
+ clause_or_set_cov_data(Clauses, Entered, Exited) =>
771
+ maplist(clause_or_set_cov_data, Clauses, LEntered, LExited),
772
+ sum_list(LEntered, Entered),
773
+ sum_list(LExited, Exited).
774
+
775
+ line_annotation_msg(line_anot(Line, _PC, Entered, Exited), (Line-Annot)-Len) :-
776
+ ( Exited == Entered
777
+ -> format(string(Text), '++~D', [Entered]),
778
+ Annot = ansi(comment, Text)
779
+ ; Exited == 0
780
+ -> format(string(Text), '--~D', [Entered]),
781
+ Annot = ansi(warning, Text)
782
+ ; Exited < Entered
783
+ -> Failed is Entered - Exited,
784
+ format(string(Text), '+~D-~D', [Exited, Failed]),
785
+ Annot = ansi(comment, Text)
786
+ ; format(string(Text), '+~D*~D', [Entered, Exited]),
787
+ Annot = ansi(fg(cyan), Text)
788
+ ),
789
+ string_length(Text, Len).
790
+
791
+ uncovered_clause_line(File, Code, Name-Line) :-
792
+ clause_or_set_source_location(Clause, File, Line),
793
+ ( Code = [Clause|_] % included file; omit module
794
+ -> clause_pi(Clause, _:Name)
795
+ ; clause_pi(Code, Name)
796
+ ).
797
+
798
+ %! clause_pi(+Clause, -Name) is det.
799
+ %
800
+ % Return the clause predicate indicator as Module:Name/Arity.
801
+
802
+ clause_pi(Clause, Name) :-
803
+ clause(Module:Head, _, Clause),
804
+ functor(Head,F,A),
805
+ Name=Module:F/A.
806
+
807
+ print_clause_line((Module:Name/Arity)-Lines):-
808
+ term_string(Module:Name, Complete_name),
809
+ summary(Complete_name, 54, SName),
810
+ format('~4|~w~t~59|~p~n', [SName/Arity, Lines]).
811
+
812
+
813
+ /*******************************
814
+ * LINE LEVEL CALL SITES *
815
+ *******************************/
816
+
817
+ join_annots(Annots, Joined) :-
818
+ sort(2, @=<, Annots, ByPC),
819
+ join_annots_(ByPC, Joined0),
820
+ sort(1, @=<, Joined0, Joined).
821
+
822
+ join_annots_([], []).
823
+ join_annots_([H0|T0], [H|T]) :-
824
+ sum_annot_counts(H0, H, T0, T1),
825
+ join_annots_(T1, T).
826
+
827
+ sum_annot_counts(line_anot(Line, PC, Enter1, Exit1),
828
+ Final,
829
+ [line_anot(Line, PC, Enter2, Exit2)|T0],
830
+ T) :-
831
+ !,
832
+ Enter is Enter1 + Enter2,
833
+ Exit is Exit1 + Exit2,
834
+ sum_annot_counts(line_anot(Line, PC, Enter, Exit),
835
+ Final, T0, T).
836
+ sum_annot_counts(Sum, Sum, T, T).
837
+
838
+ %! clause_call_site_annotations(+Clause, -Annotations) is det.
839
+ %
840
+ % @arg Annotations is a list line_anot(Line, PC, Entered, Exited)
841
+
842
+ clause_call_site_annotations(Clause, Annots) :-
843
+ findall(Annot,
844
+ clause_call_site_annotation(Clause, Annot),
845
+ Annots).
846
+
847
+ clause_call_site_annotation(ClauseRef,
848
+ line_anot(Line, NextPC, Entered, Exited)) :-
849
+ clause_call_site(ClauseRef, PC-NextPC, Line:_LPos),
850
+ ( '$cov_data'(call_site(ClauseRef, NextPC), Entered, Exited)
851
+ -> true
852
+ ; '$fetch_vm'(ClauseRef, PC, _, VMI),
853
+ \+ no_annotate_call_site(VMI)
854
+ -> Entered = 0, Exited = 0
855
+ ).
856
+
857
+ no_annotate_call_site(i_enter).
858
+ no_annotate_call_site(i_exit).
859
+ no_annotate_call_site(i_cut).
860
+
861
+ clause_call_site(ClauseRef, PC-NextPC, Pos) :-
862
+ clause_info(ClauseRef, File, TermPos, _NameOffset),
863
+ '$break_pc'(ClauseRef, PC, NextPC),
864
+ '$clause_term_position'(ClauseRef, NextPC, List),
865
+ catch(prolog_breakpoints:range(List, TermPos, SubPos), E, true),
866
+ ( var(E)
867
+ -> arg(1, SubPos, A),
868
+ file_offset_pos(File, A, Pos)
869
+ ; print_message(warning, coverage(clause_info(ClauseRef))),
870
+ fail
871
+ ).
872
+
873
+ file_offset_pos(File, A, Line:LPos) :-
874
+ file_text(File, String),
875
+ State = start(1, 0),
876
+ call_nth(sub_string(String, S, _, _, "\n"), NLine),
877
+ ( S >= A
878
+ -> !,
879
+ State = start(Line, SLine),
880
+ LPos is A-SLine
881
+ ; NS is S+1,
882
+ NLine1 is NLine+1,
883
+ nb_setarg(1, State, NLine1),
884
+ nb_setarg(2, State, NS),
885
+ fail
886
+ ).
887
+
888
+ file_text(File, String) :-
889
+ setup_call_cleanup(
890
+ open(File, read, In),
891
+ read_string(In, _, String),
892
+ close(In)).
893
+
894
+ %! check_correct_offsets(+Clauses, +Annotations) is det.
895
+ %
896
+ % Verify that all PC's that were annotated have been generated as
897
+ % possible call sites.
898
+
899
+ check_correct_offsets([Clause|_], [Annots|_]) :-
900
+ maplist(arg(2), Annots, PCs),
901
+ check_covered_call_sites(Clause, PCs).
902
+
903
+ check_covered_call_sites(Clause, Reported) :-
904
+ findall(PC, ('$cov_data'(call_site(Clause,PC), Enter, _), Enter > 0), Seen),
905
+ sort(Reported, SReported),
906
+ sort(Seen, SSeen),
907
+ ord_subtract(SSeen, SReported, Missed),
908
+ ( Missed == []
909
+ -> true
910
+ ; print_message(warning, coverage(unreported_call_sites(Clause, Missed)))
911
+ ).
912
+
913
+
914
+ /*******************************
915
+ * ANNOTATE *
916
+ *******************************/
917
+
918
+ clean_output(Options) :-
919
+ option(dir(Dir), Options),
920
+ !,
921
+ option(ext(Ext), Options, cov),
922
+ format(atom(Pattern), '~w/*.~w', [Dir, Ext]),
923
+ expand_file_name(Pattern, Files),
924
+ maplist(delete_file, Files).
925
+ clean_output(Options) :-
926
+ forall(source_file(File),
927
+ clean_output(File, Options)).
928
+
929
+ clean_output(File, Options) :-
930
+ option(ext(Ext), Options, cov),
931
+ file_name_extension(File, Ext, CovFile),
932
+ ( exists_file(CovFile)
933
+ -> E = error(_,_),
934
+ catch(delete_file(CovFile), E,
935
+ print_message(warning, E))
936
+ ; true
937
+ ).
938
+
939
+
940
+ %! annotate_file(+File, +Annotations, +Options) is det.
941
+ %
942
+ % Create an annotated copy of File. Annotations is a list of
943
+ % `LineNo-Annotation`, where `Annotation` is atomic or a term
944
+ % Format-Args, optionally embedded in ansi(Code, Annotation).
945
+
946
+ annotate_file(Source, Annotations, Options) :-
947
+ option(ext(Ext), Options, cov),
948
+ ( option(dir(Dir), Options)
949
+ -> file_base_name(Source, Base),
950
+ file_name_extension(Base, Ext, CovFile),
951
+ directory_file_path(Dir, CovFile, CovPath),
952
+ make_directory_path(Dir)
953
+ ; file_name_extension(Source, Ext, CovPath)
954
+ ),
955
+ summary(Source, 30, SSource),
956
+ progress('Annotating ~w in ~w ... ', [SSource,CovPath]),
957
+ keysort(Annotations, SortedAnnotations),
958
+ setup_call_cleanup(
959
+ open(Source, read, In),
960
+ setup_call_cleanup(
961
+ open(CovPath, write, Out),
962
+ annotate(In, Out, SortedAnnotations, Options),
963
+ close(Out)),
964
+ close(In)).
965
+
966
+ annotate(In, Out, Annotations, Options) :-
967
+ ( option(color(true), Options, true)
968
+ -> set_stream(Out, tty(true))
969
+ ; true
970
+ ),
971
+ annotate(In, Out, Annotations, 0, Options).
972
+
973
+ annotate(In, Out, Annotations, LineNo0, Options) :-
974
+ read_line_to_string(In, Line),
975
+ ( Line == end_of_file
976
+ -> true
977
+ ; succ(LineNo0, LineNo),
978
+ margins(LMargin, CMargin, Options),
979
+ line_no(LineNo, Out, LMargin),
980
+ annotations(LineNo, Out, LMargin, Annotations, Annotations1),
981
+ format(Out, '~t~*|~s~n', [CMargin, Line]),
982
+ annotate(In, Out, Annotations1, LineNo, Options)
983
+ ).
984
+
985
+ annotations(Line, Out, LMargin, [Line-Annot|T0], T) :-
986
+ !,
987
+ write_annotation(Out, Annot),
988
+ ( T0 = [Line-_|_]
989
+ -> with_output_to(Out, ansi_format(bold, ' \u2bb0~n~t~*|', [LMargin])),
990
+ annotations(Line, Out, LMargin, T0, T)
991
+ ; T = T0
992
+ ).
993
+ annotations(_, _, _, Annots, Annots).
994
+
995
+ write_annotation(Out, ansi(Code, Fmt-Args)) =>
996
+ with_output_to(Out, ansi_format(Code, Fmt, Args)).
997
+ write_annotation(Out, ansi(Code, Fmt)) =>
998
+ with_output_to(Out, ansi_format(Code, Fmt, [])).
999
+ write_annotation(Out, Fmt-Args) =>
1000
+ format(Out, Fmt, Args).
1001
+ write_annotation(Out, Fmt) =>
1002
+ format(Out, Fmt, []).
1003
+
1004
+ line_no(_, _, 0) :- !.
1005
+ line_no(Line, Out, LMargin) :-
1006
+ with_output_to(Out, ansi_format(fg(127,127,127), '~t~d ~*|',
1007
+ [Line, LMargin])).
1008
+
1009
+ margins(LMargin, Margin, Options) :-
1010
+ option(line_numbers(true), Options, true),
1011
+ !,
1012
+ option(line_number_margin(LMargin), Options, 6),
1013
+ option(margin(AMargin), Options, 4),
1014
+ Margin is LMargin+AMargin.
1015
+ margins(0, Margin, Options) :-
1016
+ option(margin(Margin), Options, 4).
1017
+
1018
+ %! report_hook(+Succeeded, +Failed) is semidet.
1019
+ %
1020
+ % This hook is called after the data collection. It is passed a list
1021
+ % of objects that have succeeded as well as a list of objects that
1022
+ % have failed. The objects are one of
1023
+ %
1024
+ % - ClauseRef
1025
+ % The specified clause
1026
+ % - call_site(ClauseRef, PC)
1027
+ % A call was make in ClauseRef at the given program counter.
1028
+
1029
+ :- multifile
1030
+ report_hook/2.
1031
+
1032
+ /*******************************
1033
+ * SAVE/RELOAD *
1034
+ *******************************/
1035
+
1036
+ %! cov_save_data(+File, +Options) is det.
1037
+ %
1038
+ % Save the coverage information to File. Options:
1039
+ %
1040
+ % - append(true)
1041
+ % Append to File rather than truncating the data if the file
1042
+ % exists.
1043
+ %
1044
+ % The File is opened using lock(exclusive), which implies that,
1045
+ % provided the OS and file system implements file locking, multiple
1046
+ % processes may save coverage data to the same file.
1047
+ %
1048
+ % The saved data is highly specific to the setup in which it has been
1049
+ % created. It can typically only be reloaded using cov_load_data/2 in
1050
+ % the same Prolog executable using the same options and with all
1051
+ % relevant source file unmodified at the same location.
1052
+ %
1053
+ % Reproducibility can be improved by using `.qlf` files or _saved
1054
+ % states_.
1055
+
1056
+ :- thread_local
1057
+ saved_clause/2. % Clause, Ref
1058
+
1059
+ cov_save_data(File, Options) :-
1060
+ ( option(append(true), Options)
1061
+ -> Mode = append
1062
+ ; Mode = write
1063
+ ),
1064
+ absolute_file_name(File, Path, [ access(write) ]),
1065
+ setup_call_cleanup(
1066
+ open(Path, Mode, Out,
1067
+ [ encoding(utf8),
1068
+ lock(exclusive)
1069
+ ]),
1070
+ cov_save_to_stream(Out),
1071
+ ( retractall(saved_clause(_,_)),
1072
+ close(Out))).
1073
+
1074
+ cov_save_to_stream(Out) :-
1075
+ get_time(Now),
1076
+ format(Out, 'cov_begin_data(~1f).~n', [Now]),
1077
+ forall('$cov_data'(Site, Enter, Exit),
1078
+ cov_save_entry(Out, Site, Enter, Exit)),
1079
+ format(Out, 'cov_end_data.~n', []).
1080
+
1081
+ :- det(cov_save_entry/4).
1082
+ cov_save_entry(Out, call_site(Clause, PC), Enter, Exit) =>
1083
+ save_clause(Out, Clause, Ref),
1084
+ ( nonvar(Ref)
1085
+ -> format(Out, '~q.~n', [cs(Ref, PC, Enter, Exit)])
1086
+ ; true
1087
+ ).
1088
+ cov_save_entry(Out, clause(Clause), Enter, Exit) =>
1089
+ save_clause(Out, Clause, Ref),
1090
+ ( nonvar(Ref)
1091
+ -> format(Out, '~q.~n', [cs(Ref, Enter, Exit)])
1092
+ ; true
1093
+ ).
1094
+
1095
+ save_clause(_Out, Clause, Ref) :-
1096
+ saved_clause(Clause, Ref),
1097
+ !.
1098
+ save_clause(Out, Clause, Ref) :-
1099
+ clause_property(Clause, file(File)),
1100
+ clause_property(Clause, line_count(Line)),
1101
+ clause_property(Clause, size(Bytes)),
1102
+ clause_property(Clause, predicate(PI)),
1103
+ main_source(File, Main),
1104
+ source_file_property(Main, load_context(Module, Location, Options)),
1105
+ nth_clause(_, Nth, Clause),
1106
+ !,
1107
+ ( predicate_property(saved_clause(_,_), number_of_clauses(N))
1108
+ -> Ref is N+1
1109
+ ; Ref = 1
1110
+ ),
1111
+ format(Out, '~q.~n', [cl(PI, Nth, Bytes, Main, File:Line, Module, Location, Options, Ref)]),
1112
+ assertz(saved_clause(Clause, Ref)).
1113
+ save_clause(_Out, Clause, _Ref) :-
1114
+ debug(cov(save), 'Could not save clause ~p', [Clause]).
1115
+
1116
+ %! cov_load_data(+File, +Options) is det.
1117
+ %
1118
+ % Reload coverage data from File. Options:
1119
+ %
1120
+ % - load(true)
1121
+ % If specified and the file in which a clauses is expected to
1122
+ % exist, load the file using load_files/2 with the same options
1123
+ % as used to initially load the file.
1124
+ % - silent(+Boolean)
1125
+ % When `true`, do not emit messages on not loaded source files.
1126
+ %
1127
+ % Data is assumed to be reliable if the Nth-clause of a predicate is
1128
+ % loaded from the same file at the same line number and has the same
1129
+ % size. Unreliable data is ignored, silently if silent(true) is used.
1130
+
1131
+ :- thread_local
1132
+ warned/1.
1133
+
1134
+ cov_load_data(File, Options) :-
1135
+ absolute_file_name(File, Path, [ access(read) ]),
1136
+ setup_call_cleanup(
1137
+ open(Path, read, In, [encoding(utf8)]),
1138
+ cov_load_data_from_stream(In, Options),
1139
+ ( retractall(saved_clause(_,_)),
1140
+ retractall(warned(_)),
1141
+ close(In))).
1142
+
1143
+ cov_load_data_from_stream(In, Options) :-
1144
+ read_term(In, Term, []),
1145
+ cov_load_data_from_stream(Term, In, Options).
1146
+
1147
+ cov_load_data_from_stream(end_of_file, _, _) :-
1148
+ !.
1149
+ cov_load_data_from_stream(Term, In, Options) :-
1150
+ cov_restore_data(Term, Options),
1151
+ read_term(In, Term2, []),
1152
+ cov_load_data_from_stream(Term2, In, Options).
1153
+
1154
+ cov_restore_data(cov_begin_data(_), _Options) =>
1155
+ true.
1156
+ cov_restore_data(cl(PI, Nth,
1157
+ Bytes, Main, File:Line, Module, _Location, LoadOptions,
1158
+ Ref), Options) =>
1159
+ ( restore_clause(PI, Nth, Bytes, File, Line, Ref)
1160
+ -> true
1161
+ ; source_file(File)
1162
+ -> warn(File, coverage(source_changed(File, PI)))
1163
+ ; option(load(true), Options)
1164
+ -> load_files(Module:Main, [if(not_loaded)|LoadOptions]),
1165
+ ( restore_clause(PI, Nth, Bytes, File, Line, Ref)
1166
+ -> true
1167
+ ; warn(File, coverage(source_changed(File, PI)))
1168
+ )
1169
+ ; option(silent(true), Options)
1170
+ -> true
1171
+ ; warn(File, coverage(no_source(File)))
1172
+ ).
1173
+ cov_restore_data(cs(Ref, PC, Enter, Exit), _Options) =>
1174
+ ( saved_clause(Clause, Ref)
1175
+ -> '$cov_add'(call_site(Clause, PC), Enter, Exit)
1176
+ ; true
1177
+ ).
1178
+ cov_restore_data(cs(Ref, Enter, Exit), _Options) =>
1179
+ ( saved_clause(Clause, Ref)
1180
+ -> '$cov_add'(clause(Clause), Enter, Exit)
1181
+ ; true
1182
+ ).
1183
+ cov_restore_data(cov_end_data, _Options) =>
1184
+ retractall(saved_clause(_,_)).
1185
+
1186
+ restore_clause(PI, _Nth, Bytes, File, Line, Ref) :-
1187
+ pi_head(PI, Head),
1188
+ predicate_property(Head, multifile),
1189
+ !,
1190
+ ( nth_clause(Head, _, Clause),
1191
+ clause_property(Clause, file(File)),
1192
+ clause_property(Clause, line_count(Line)),
1193
+ clause_property(Clause, size(Bytes))
1194
+ -> assertz(saved_clause(Clause, Ref))
1195
+ ; warn(File, coverage(no_multifile_source(File:Line, PI)))
1196
+ ).
1197
+ restore_clause(PI, Nth, Bytes, File, Line, Ref) :-
1198
+ pi_head(PI, Head),
1199
+ ( nth_clause(Head, Nth, Clause)
1200
+ -> ( clause_property(Clause, file(File)),
1201
+ clause_property(Clause, line_count(Line)),
1202
+ clause_property(Clause, size(Bytes))
1203
+ -> assertz(saved_clause(Clause, Ref))
1204
+ ; warn(File, coverage(source_changed(File:Line, PI, Nth)))
1205
+ )
1206
+ ).
1207
+
1208
+ warn(Term, _Msg) :-
1209
+ warned(Term),
1210
+ !.
1211
+ warn(Term, Msg) :-
1212
+ assertz(warned(Term)),
1213
+ print_message(warning, Msg).
1214
+
1215
+
1216
+ %! cov_reset is det.
1217
+ %
1218
+ % Discard all collected coverage data. This predicate raises a
1219
+ % permission error if coverage collection is in progress.
1220
+
1221
+ cov_reset :-
1222
+ '$cov_reset'.
1223
+
1224
+
1225
+ %! cov_property(?Property)
1226
+ %
1227
+ % True when coverage analysis satisfies Property. Currently defined
1228
+ % properties are:
1229
+ %
1230
+ % - active(?Nesting)
1231
+ % True when coverage data is being collected. Nesting expresses
1232
+ % the nesting of coverage/1 calls and is normally 1 (one).
1233
+
1234
+ cov_property(active(Level)) :-
1235
+ '$cov_active'(Level).
1236
+
1237
+
1238
+ /*******************************
1239
+ * MESSAGES *
1240
+ *******************************/
1241
+
1242
+ :- multifile
1243
+ prolog:message//1.
1244
+
1245
+ prolog:message(coverage(Msg)) -->
1246
+ message(Msg).
1247
+
1248
+ message(no_files_to_report) -->
1249
+ [ 'No coverage events in selected files'-[] ].
1250
+ message(clause_info(ClauseRef)) -->
1251
+ [ 'Inconsistent clause info for '-[] ],
1252
+ clause_msg(ClauseRef).
1253
+ message(unreported_call_sites(ClauseRef, PCList)) -->
1254
+ [ 'Failed to report call sites for '-[] ],
1255
+ clause_msg(ClauseRef),
1256
+ [ nl, ' Missed at these PC offsets: ~p'-[PCList] ].
1257
+ message(source_changed(File, PI)) -->
1258
+ [ 'Predicate ', ansi(code, '~p', [PI]), ' cannot be found while file ',
1259
+ url(File), ' is loaded.'
1260
+ ].
1261
+ message(no_source(File)) -->
1262
+ [ 'File ', url(File), ' is not loaded. Please re-run with ', nl,
1263
+ 'file loaded or use the ', ansi(code, 'load(true)', []), ' option.'
1264
+ ].
1265
+ message(no_multifile_source(Location, PI)) -->
1266
+ [ 'Could not find matching clause for multifile predicate ',
1267
+ ansi(code, '~p', [PI]), ' at ', url(Location)
1268
+ ].
1269
+ message(source_changed(File:Line, PI, Nth)) -->
1270
+ [ '~D-th clause for '-[Nth], ansi(code, '~p', [PI]),
1271
+ ' cannot be found at ', url(File:Line), '.'
1272
+ ].
1273
+ message(deprecated(show_coverage/2)) -->
1274
+ [ 'show_coverage/2 is deprecated. Please use coverage/2', nl,
1275
+ 'with the same arguments.'
1276
+ ].
1277
+
1278
+
1279
+ clause_msg(ClauseRef) -->
1280
+ { clause_pi(ClauseRef, PI),
1281
+ clause_property(ClauseRef, file(File)),
1282
+ clause_property(ClauseRef, line_count(Line))
1283
+ },
1284
+ [ '~p at'-[PI], nl, ' ', url(File:Line) ].
1285
+
1286
+
1287
+ /*******************************
1288
+ * TTY PRINT SUPPORT *
1289
+ *******************************/
1290
+
1291
+ progress(_, _) :-
1292
+ current_prolog_flag(verbose, silent),
1293
+ !.
1294
+ progress(Format, Args) :-
1295
+ stream_property(user_output, tty(true)),
1296
+ !,
1297
+ format(user_output, '\r\e[2K', []),
1298
+ ansi_format(comment, Format, Args),
1299
+ flush_output(user_output).
1300
+ progress(Format, Args) :-
1301
+ format(Format, Args),
1302
+ nl.
1303
+
1304
+ progress_done(_,_) :-
1305
+ current_prolog_flag(verbose, silent),
1306
+ !.
1307
+ progress_done(Format, Args) :-
1308
+ stream_property(user_output, tty(true)),
1309
+ !,
1310
+ ansi_format(comment, Format, Args),
1311
+ nl.
1312
+ progress_done(_, _).
1313
+
1314
+ header(Title, Width) :-
1315
+ hr(Width),
1316
+ ansi_format([bold], '~t~w~t~*|', [Title,Width]),
1317
+ nl.
1318
+
1319
+ hr(Width) :-
1320
+ format('~N~`\u2015t~*|~n', [Width]).
1321
+
1322
+ %! tty_width(-Width, +Options) is det.
1323
+
1324
+ tty_width(W, Options) :-
1325
+ option(width(W), Options),
1326
+ !.
1327
+ :- if(current_predicate(tty_size/2)).
1328
+ tty_width(W, _Options) :-
1329
+ catch(tty_size(_, TtyW), _, fail),
1330
+ !,
1331
+ W is max(60, TtyW).
1332
+ :- endif.
1333
+ tty_width(78, _).