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.
- package/README.md +29 -0
- package/bin/swipl +0 -0
- package/bin/swipl-win +0 -0
- package/build-manifest.json +70 -0
- package/lib/cmake/swipl/SWIPLConfig.cmake +21 -0
- package/lib/cmake/swipl/SWIPLConfigVersion.cmake +65 -0
- package/lib/cmake/swipl/SWIPLTargets-release.cmake +28 -0
- package/lib/cmake/swipl/SWIPLTargets.cmake +109 -0
- package/lib/swipl/ABI +1 -0
- package/lib/swipl/LICENSE +41 -0
- package/lib/swipl/README.md +116 -0
- package/lib/swipl/app/README.md +25 -0
- package/lib/swipl/app/app.pl +87 -0
- package/lib/swipl/app/pack.pl +350 -0
- package/lib/swipl/app/qlf.pl +521 -0
- package/lib/swipl/app/splfr.pl +177 -0
- package/lib/swipl/app/sys.pl +310 -0
- package/lib/swipl/bin/swipl.home +1 -0
- package/lib/swipl/boot/apply.pl +73 -0
- package/lib/swipl/boot/attvar.pl +344 -0
- package/lib/swipl/boot/autoload.pl +1226 -0
- package/lib/swipl/boot/bags.pl +283 -0
- package/lib/swipl/boot/dcg.pl +388 -0
- package/lib/swipl/boot/dicts.pl +193 -0
- package/lib/swipl/boot/dwim.pl +485 -0
- package/lib/swipl/boot/engines.pl +152 -0
- package/lib/swipl/boot/expand.pl +1628 -0
- package/lib/swipl/boot/gc.pl +65 -0
- package/lib/swipl/boot/history.pl +304 -0
- package/lib/swipl/boot/init.pl +4682 -0
- package/lib/swipl/boot/iri.pl +64 -0
- package/lib/swipl/boot/license.pl +390 -0
- package/lib/swipl/boot/load.pl +81 -0
- package/lib/swipl/boot/messages.pl +2521 -0
- package/lib/swipl/boot/packs.pl +306 -0
- package/lib/swipl/boot/predopts.pl +154 -0
- package/lib/swipl/boot/qlf.pl +141 -0
- package/lib/swipl/boot/rc.pl +263 -0
- package/lib/swipl/boot/syspred.pl +1634 -0
- package/lib/swipl/boot/tabling.pl +2321 -0
- package/lib/swipl/boot/threads.pl +42 -0
- package/lib/swipl/boot/toplevel.pl +2248 -0
- package/lib/swipl/boot/topvars.pl +261 -0
- package/lib/swipl/boot.prc +0 -0
- package/lib/swipl/cmake/swipl.cmake +131 -0
- package/lib/swipl/customize/README.md +23 -0
- package/lib/swipl/customize/edit +101 -0
- package/lib/swipl/customize/init.pl +164 -0
- package/lib/swipl/demo/README.md +33 -0
- package/lib/swipl/demo/likes.pl +44 -0
- package/lib/swipl/doc/packages/examples/chr/bool.chr +281 -0
- package/lib/swipl/doc/packages/examples/chr/chrdif.chr +87 -0
- package/lib/swipl/doc/packages/examples/chr/chrfreeze.chr +6 -0
- package/lib/swipl/doc/packages/examples/chr/family.chr +116 -0
- package/lib/swipl/doc/packages/examples/chr/fib.chr +24 -0
- package/lib/swipl/doc/packages/examples/chr/fibonacci.chr +31 -0
- package/lib/swipl/doc/packages/examples/chr/gcd.chr +28 -0
- package/lib/swipl/doc/packages/examples/chr/leq.chr +34 -0
- package/lib/swipl/doc/packages/examples/chr/listdom.chr +138 -0
- package/lib/swipl/doc/packages/examples/chr/primes.chr +29 -0
- package/lib/swipl/doc/packages/examples/http/README.md +98 -0
- package/lib/swipl/doc/packages/examples/http/calc.pl +92 -0
- package/lib/swipl/doc/packages/examples/http/demo_body.pl +232 -0
- package/lib/swipl/doc/packages/examples/http/demo_client.pl +165 -0
- package/lib/swipl/doc/packages/examples/http/demo_daemon.pl +38 -0
- package/lib/swipl/doc/packages/examples/http/demo_files.pl +50 -0
- package/lib/swipl/doc/packages/examples/http/demo_hello.pl +15 -0
- package/lib/swipl/doc/packages/examples/http/demo_login.pl +280 -0
- package/lib/swipl/doc/packages/examples/http/demo_openid.pl +177 -0
- package/lib/swipl/doc/packages/examples/http/demo_pwp.pl +20 -0
- package/lib/swipl/doc/packages/examples/http/demo_rest.pl +56 -0
- package/lib/swipl/doc/packages/examples/http/demo_threads.pl +52 -0
- package/lib/swipl/doc/packages/examples/http/linux-init-script +126 -0
- package/lib/swipl/doc/packages/examples/http/pwp/context.pwp +23 -0
- package/lib/swipl/doc/packages/examples/http/pwp/index.pwp +25 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp1.pwp +12 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp2.pwp +10 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp3.pwp +25 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp4.pwp +23 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp5.pwp +11 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp6.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp7.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp8.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwpdb.pl +12 -0
- package/lib/swipl/doc/packages/examples/http/systemd-script.service +18 -0
- package/lib/swipl/doc/packages/examples/http/upstart-script.conf +20 -0
- package/lib/swipl/doc/packages/examples/plunit/read.pl +17 -0
- package/lib/swipl/doc/packages/examples/plunit/simple.pl +33 -0
- package/lib/swipl/doc/packages/examples/ssl/client.pl +83 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/README +52 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-cert.p12 +0 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-cert.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-key.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/cacert.pem +82 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/careq.pem +18 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/crlnumber +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/index.txt +3 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/index.txt.attr +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/newcerts/9DC08797A0F63F7C.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/newcerts/9DC08797A0F63F7D.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/private/cakey.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/serial +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/server/server-cert.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/server/server-key.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/https.pl +267 -0
- package/lib/swipl/doc/packages/examples/ssl/server.pl +106 -0
- package/lib/swipl/include/SWI-Prolog.h +1544 -0
- package/lib/swipl/include/SWI-Stream.h +537 -0
- package/lib/swipl/include/Yap/YapInterface.h +283 -0
- package/lib/swipl/include/sicstus/sicstus.h +452 -0
- package/lib/swipl/lib/x86_64-linux/cgi.so +0 -0
- package/lib/swipl/lib/x86_64-linux/crypt.so +0 -0
- package/lib/swipl/lib/x86_64-linux/crypto4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/double_metaphone.so +0 -0
- package/lib/swipl/lib/x86_64-linux/files.so +0 -0
- package/lib/swipl/lib/x86_64-linux/hashstream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/http_stream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/isub.so +0 -0
- package/lib/swipl/lib/x86_64-linux/json.so +0 -0
- package/lib/swipl/lib/x86_64-linux/libswipl.so.10 +0 -0
- package/lib/swipl/lib/x86_64-linux/mallocinfo.so +0 -0
- package/lib/swipl/lib/x86_64-linux/md54pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/memfile.so +0 -0
- package/lib/swipl/lib/x86_64-linux/ntriples.so +0 -0
- package/lib/swipl/lib/x86_64-linux/pcre4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/porter_stem.so +0 -0
- package/lib/swipl/lib/x86_64-linux/process.so +0 -0
- package/lib/swipl/lib/x86_64-linux/prolog_stream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/rdf_db.so +0 -0
- package/lib/swipl/lib/x86_64-linux/readutil.so +0 -0
- package/lib/swipl/lib/x86_64-linux/rlimit.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sched.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sgml2pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sha4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/snowball.so +0 -0
- package/lib/swipl/lib/x86_64-linux/socket.so +0 -0
- package/lib/swipl/lib/x86_64-linux/ssl4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/streaminfo.so +0 -0
- package/lib/swipl/lib/x86_64-linux/syslog.so +0 -0
- package/lib/swipl/lib/x86_64-linux/time.so +0 -0
- package/lib/swipl/lib/x86_64-linux/turtle.so +0 -0
- package/lib/swipl/lib/x86_64-linux/uid.so +0 -0
- package/lib/swipl/lib/x86_64-linux/unix.so +0 -0
- package/lib/swipl/lib/x86_64-linux/uri.so +0 -0
- package/lib/swipl/lib/x86_64-linux/websocket.so +0 -0
- package/lib/swipl/lib/x86_64-linux/zlib4pl.so +0 -0
- package/lib/swipl/library/INDEX.pl +1020 -0
- package/lib/swipl/library/aggregate.pl +755 -0
- package/lib/swipl/library/ansi_term.pl +653 -0
- package/lib/swipl/library/apply.pl +426 -0
- package/lib/swipl/library/apply_macros.pl +497 -0
- package/lib/swipl/library/arithmetic.pl +320 -0
- package/lib/swipl/library/assoc.pl +522 -0
- package/lib/swipl/library/atom.pl +169 -0
- package/lib/swipl/library/backcomp.pl +688 -0
- package/lib/swipl/library/base32.pl +291 -0
- package/lib/swipl/library/base64.pl +441 -0
- package/lib/swipl/library/broadcast.pl +161 -0
- package/lib/swipl/library/build/cmake.pl +137 -0
- package/lib/swipl/library/build/conan.pl +232 -0
- package/lib/swipl/library/build/make.pl +168 -0
- package/lib/swipl/library/build/tools.pl +825 -0
- package/lib/swipl/library/charsio.pl +195 -0
- package/lib/swipl/library/check.pl +1097 -0
- package/lib/swipl/library/check_installation.pl +912 -0
- package/lib/swipl/library/clp/INDEX.pl +157 -0
- package/lib/swipl/library/clp/bounds.pl +2036 -0
- package/lib/swipl/library/clp/clp_distinct.pl +263 -0
- package/lib/swipl/library/clp/clp_events.pl +92 -0
- package/lib/swipl/library/clp/clpb.pl +1896 -0
- package/lib/swipl/library/clp/clpfd.pl +7906 -0
- package/lib/swipl/library/clp/simplex.pl +1580 -0
- package/lib/swipl/library/codesio.pl +182 -0
- package/lib/swipl/library/coinduction.pl +183 -0
- package/lib/swipl/library/console_input.pl +289 -0
- package/lib/swipl/library/csv.pl +611 -0
- package/lib/swipl/library/ctypes.pl +161 -0
- package/lib/swipl/library/date.pl +370 -0
- package/lib/swipl/library/dcg/INDEX.pl +35 -0
- package/lib/swipl/library/dcg/basics.pl +514 -0
- package/lib/swipl/library/dcg/high_order.pl +227 -0
- package/lib/swipl/library/debug.pl +499 -0
- package/lib/swipl/library/dialect/bim.pl +186 -0
- package/lib/swipl/library/dialect/commons.pl +77 -0
- package/lib/swipl/library/dialect/eclipse/test_util_iso.pl +355 -0
- package/lib/swipl/library/dialect/hprolog/format.pl +44 -0
- package/lib/swipl/library/dialect/hprolog.pl +314 -0
- package/lib/swipl/library/dialect/ifprolog.pl +1317 -0
- package/lib/swipl/library/dialect/iso/iso_predicates.pl +277 -0
- package/lib/swipl/library/dialect/sicstus/README.TXT +1 -0
- package/lib/swipl/library/dialect/sicstus/arrays.pl +121 -0
- package/lib/swipl/library/dialect/sicstus/block.pl +278 -0
- package/lib/swipl/library/dialect/sicstus/lists.pl +167 -0
- package/lib/swipl/library/dialect/sicstus/ordsets.pl +52 -0
- package/lib/swipl/library/dialect/sicstus/sockets.pl +174 -0
- package/lib/swipl/library/dialect/sicstus/system.pl +262 -0
- package/lib/swipl/library/dialect/sicstus/terms.pl +57 -0
- package/lib/swipl/library/dialect/sicstus/timeout.pl +92 -0
- package/lib/swipl/library/dialect/sicstus.pl +582 -0
- package/lib/swipl/library/dialect/sicstus4/aggregate.pl +60 -0
- package/lib/swipl/library/dialect/sicstus4/between.pl +62 -0
- package/lib/swipl/library/dialect/sicstus4/clpfd.pl +75 -0
- package/lib/swipl/library/dialect/sicstus4/file_systems.pl +413 -0
- package/lib/swipl/library/dialect/sicstus4/lists.pl +274 -0
- package/lib/swipl/library/dialect/sicstus4/ordsets.pl +54 -0
- package/lib/swipl/library/dialect/sicstus4/samsort.pl +86 -0
- package/lib/swipl/library/dialect/sicstus4/sets.pl +124 -0
- package/lib/swipl/library/dialect/sicstus4/sockets.pl +164 -0
- package/lib/swipl/library/dialect/sicstus4/system.pl +80 -0
- package/lib/swipl/library/dialect/sicstus4/terms.pl +89 -0
- package/lib/swipl/library/dialect/sicstus4/timeout.pl +43 -0
- package/lib/swipl/library/dialect/sicstus4/types.pl +103 -0
- package/lib/swipl/library/dialect/sicstus4.pl +200 -0
- package/lib/swipl/library/dialect/swi/syspred_options.pl +250 -0
- package/lib/swipl/library/dialect/xsb/README.md +20 -0
- package/lib/swipl/library/dialect/xsb/basics.pl +318 -0
- package/lib/swipl/library/dialect/xsb/consult.pl +87 -0
- package/lib/swipl/library/dialect/xsb/curr_sym.pl +57 -0
- package/lib/swipl/library/dialect/xsb/error_handler.pl +111 -0
- package/lib/swipl/library/dialect/xsb/gensym.pl +53 -0
- package/lib/swipl/library/dialect/xsb/gpp.pl +138 -0
- package/lib/swipl/library/dialect/xsb/intern.pl +48 -0
- package/lib/swipl/library/dialect/xsb/lists.pl +47 -0
- package/lib/swipl/library/dialect/xsb/machine.pl +295 -0
- package/lib/swipl/library/dialect/xsb/ordsets.pl +53 -0
- package/lib/swipl/library/dialect/xsb/setof.pl +54 -0
- package/lib/swipl/library/dialect/xsb/source.pl +308 -0
- package/lib/swipl/library/dialect/xsb/standard.pl +169 -0
- package/lib/swipl/library/dialect/xsb/storage.pl +70 -0
- package/lib/swipl/library/dialect/xsb/string.pl +76 -0
- package/lib/swipl/library/dialect/xsb/thread.pl +62 -0
- package/lib/swipl/library/dialect/xsb/timed_call.pl +158 -0
- package/lib/swipl/library/dialect/xsb.pl +688 -0
- package/lib/swipl/library/dialect/yap/README.TXT +8 -0
- package/lib/swipl/library/dialect/yap.pl +283 -0
- package/lib/swipl/library/dialect.pl +123 -0
- package/lib/swipl/library/dicts.pl +399 -0
- package/lib/swipl/library/dif.pl +426 -0
- package/lib/swipl/library/edinburgh.pl +138 -0
- package/lib/swipl/library/edit.pl +783 -0
- package/lib/swipl/library/error.pl +495 -0
- package/lib/swipl/library/exceptions.pl +231 -0
- package/lib/swipl/library/explain.pl +543 -0
- package/lib/swipl/library/ext/RDF/INDEX.pl +25 -0
- package/lib/swipl/library/ext/RDF/rdf.pl +450 -0
- package/lib/swipl/library/ext/RDF/rdf_parser.pl +649 -0
- package/lib/swipl/library/ext/RDF/rdf_triple.pl +448 -0
- package/lib/swipl/library/ext/RDF/rdf_write.pl +701 -0
- package/lib/swipl/library/ext/RDF/rewrite_term.pl +177 -0
- package/lib/swipl/library/ext/chr/chr/a_star.pl +80 -0
- package/lib/swipl/library/ext/chr/chr/binomialheap.pl +142 -0
- package/lib/swipl/library/ext/chr/chr/builtins.pl +629 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_errors.pl +179 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_options.pl +382 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_utility.pl +338 -0
- package/lib/swipl/library/ext/chr/chr/chr_debug.pl +59 -0
- package/lib/swipl/library/ext/chr/chr/chr_hashtable_store.pl +425 -0
- package/lib/swipl/library/ext/chr/chr/chr_integertable_store.pl +139 -0
- package/lib/swipl/library/ext/chr/chr/chr_messages.pl +176 -0
- package/lib/swipl/library/ext/chr/chr/chr_op.pl +53 -0
- package/lib/swipl/library/ext/chr/chr/chr_runtime.pl +1016 -0
- package/lib/swipl/library/ext/chr/chr/chr_translate.pl +25424 -0
- package/lib/swipl/library/ext/chr/chr/clean_code.pl +252 -0
- package/lib/swipl/library/ext/chr/chr/find.pl +78 -0
- package/lib/swipl/library/ext/chr/chr/guard_entailment.pl +19432 -0
- package/lib/swipl/library/ext/chr/chr/listmap.pl +108 -0
- package/lib/swipl/library/ext/chr/chr/pairlist.pl +78 -0
- package/lib/swipl/library/ext/chr/chr.pl +686 -0
- package/lib/swipl/library/ext/clib/INDEX.pl +158 -0
- package/lib/swipl/library/ext/clib/cgi.pl +86 -0
- package/lib/swipl/library/ext/clib/crypt.pl +44 -0
- package/lib/swipl/library/ext/clib/filesex.pl +644 -0
- package/lib/swipl/library/ext/clib/hash_stream.pl +119 -0
- package/lib/swipl/library/ext/clib/mallocinfo.pl +138 -0
- package/lib/swipl/library/ext/clib/md5.pl +68 -0
- package/lib/swipl/library/ext/clib/memfile.pl +61 -0
- package/lib/swipl/library/ext/clib/process.pl +573 -0
- package/lib/swipl/library/ext/clib/prolog_server.pl +157 -0
- package/lib/swipl/library/ext/clib/prolog_stream.pl +80 -0
- package/lib/swipl/library/ext/clib/rlimit.pl +54 -0
- package/lib/swipl/library/ext/clib/sched.pl +85 -0
- package/lib/swipl/library/ext/clib/sha.pl +162 -0
- package/lib/swipl/library/ext/clib/socket.pl +1102 -0
- package/lib/swipl/library/ext/clib/streaminfo.pl +103 -0
- package/lib/swipl/library/ext/clib/streampool.pl +136 -0
- package/lib/swipl/library/ext/clib/syslog.pl +180 -0
- package/lib/swipl/library/ext/clib/time.pl +194 -0
- package/lib/swipl/library/ext/clib/udp_broadcast.pl +975 -0
- package/lib/swipl/library/ext/clib/uid.pl +220 -0
- package/lib/swipl/library/ext/clib/unix.pl +317 -0
- package/lib/swipl/library/ext/clib/uri.pl +530 -0
- package/lib/swipl/library/ext/clib/uuid.pl +207 -0
- package/lib/swipl/library/ext/http/http/INDEX.pl +266 -0
- package/lib/swipl/library/ext/http/http/README.md +34 -0
- package/lib/swipl/library/ext/http/http/ax.pl +189 -0
- package/lib/swipl/library/ext/http/http/dcg_basics.pl +49 -0
- package/lib/swipl/library/ext/http/http/graphql.pl +1367 -0
- package/lib/swipl/library/ext/http/http/html_decl.pl +416 -0
- package/lib/swipl/library/ext/http/http/html_head.pl +654 -0
- package/lib/swipl/library/ext/http/http/html_quasiquotations.pl +120 -0
- package/lib/swipl/library/ext/http/http/html_write.pl +1425 -0
- package/lib/swipl/library/ext/http/http/htmx.pl +139 -0
- package/lib/swipl/library/ext/http/http/http_authenticate.pl +364 -0
- package/lib/swipl/library/ext/http/http/http_client.pl +412 -0
- package/lib/swipl/library/ext/http/http/http_cookie.pl +245 -0
- package/lib/swipl/library/ext/http/http/http_cors.pl +176 -0
- package/lib/swipl/library/ext/http/http/http_digest.pl +820 -0
- package/lib/swipl/library/ext/http/http/http_dirindex.pl +296 -0
- package/lib/swipl/library/ext/http/http/http_dispatch.pl +1552 -0
- package/lib/swipl/library/ext/http/http/http_dyn_workers.pl +214 -0
- package/lib/swipl/library/ext/http/http/http_error.pl +126 -0
- package/lib/swipl/library/ext/http/http/http_exception.pl +225 -0
- package/lib/swipl/library/ext/http/http/http_files.pl +163 -0
- package/lib/swipl/library/ext/http/http/http_header.pl +2820 -0
- package/lib/swipl/library/ext/http/http/http_hook.pl +106 -0
- package/lib/swipl/library/ext/http/http/http_host.pl +204 -0
- package/lib/swipl/library/ext/http/http/http_load.pl +113 -0
- package/lib/swipl/library/ext/http/http/http_log.pl +738 -0
- package/lib/swipl/library/ext/http/http/http_multipart_plugin.pl +232 -0
- package/lib/swipl/library/ext/http/http/http_open.pl +1821 -0
- package/lib/swipl/library/ext/http/http/http_openid.pl +1561 -0
- package/lib/swipl/library/ext/http/http/http_parameters.pl +504 -0
- package/lib/swipl/library/ext/http/http/http_path.pl +380 -0
- package/lib/swipl/library/ext/http/http/http_proxy.pl +80 -0
- package/lib/swipl/library/ext/http/http/http_pwp.pl +351 -0
- package/lib/swipl/library/ext/http/http/http_redis_plugin.pl +332 -0
- package/lib/swipl/library/ext/http/http/http_server.pl +105 -0
- package/lib/swipl/library/ext/http/http/http_server_files.pl +126 -0
- package/lib/swipl/library/ext/http/http/http_server_health.pl +186 -0
- package/lib/swipl/library/ext/http/http/http_session.pl +1040 -0
- package/lib/swipl/library/ext/http/http/http_sgml_plugin.pl +137 -0
- package/lib/swipl/library/ext/http/http/http_stream.pl +376 -0
- package/lib/swipl/library/ext/http/http/http_unix_daemon.pl +989 -0
- package/lib/swipl/library/ext/http/http/http_wrapper.pl +559 -0
- package/lib/swipl/library/ext/http/http/hub.pl +600 -0
- package/lib/swipl/library/ext/http/http/js_write.pl +461 -0
- package/lib/swipl/library/ext/http/http/mimepack.pl +224 -0
- package/lib/swipl/library/ext/http/http/mimetype.pl +276 -0
- package/lib/swipl/library/ext/http/http/term_html.pl +797 -0
- package/lib/swipl/library/ext/http/http/thread_httpd.pl +1181 -0
- package/lib/swipl/library/ext/http/http/web/css/dirindex.css +24 -0
- package/lib/swipl/library/ext/http/http/web/css/openid.css +57 -0
- package/lib/swipl/library/ext/http/http/web/icons/back.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/c.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/compressed.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/folder.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/generic.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/layout.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/openid-logo-square.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/openid-logo-tiny.png +0 -0
- package/lib/swipl/library/ext/http/http/websocket.pl +729 -0
- package/lib/swipl/library/ext/http/http/yadis.pl +205 -0
- package/lib/swipl/library/ext/json/INDEX.pl +36 -0
- package/lib/swipl/library/ext/json/http/INDEX.pl +16 -0
- package/lib/swipl/library/ext/json/http/http_json.pl +490 -0
- package/lib/swipl/library/ext/json/http/js_grammar.pl +53 -0
- package/lib/swipl/library/ext/json/http/json.pl +48 -0
- package/lib/swipl/library/ext/json/http/json_convert.pl +48 -0
- package/lib/swipl/library/ext/json/json.pl +1215 -0
- package/lib/swipl/library/ext/json/json_convert.pl +681 -0
- package/lib/swipl/library/ext/json/json_grammar.pl +349 -0
- package/lib/swipl/library/ext/json/json_rpc_client.pl +423 -0
- package/lib/swipl/library/ext/json/json_rpc_common.pl +104 -0
- package/lib/swipl/library/ext/json/json_rpc_server.pl +489 -0
- package/lib/swipl/library/ext/json/json_schema.pl +2111 -0
- package/lib/swipl/library/ext/nlp/INDEX.pl +15 -0
- package/lib/swipl/library/ext/nlp/double_metaphone.pl +86 -0
- package/lib/swipl/library/ext/nlp/isub.pl +162 -0
- package/lib/swipl/library/ext/nlp/porter_stem.pl +50 -0
- package/lib/swipl/library/ext/nlp/snowball.pl +97 -0
- package/lib/swipl/library/ext/pcre/INDEX.pl +17 -0
- package/lib/swipl/library/ext/pcre/pcre.pl +974 -0
- package/lib/swipl/library/ext/plunit/INDEX.pl +20 -0
- package/lib/swipl/library/ext/plunit/plunit.pl +2631 -0
- package/lib/swipl/library/ext/plunit/test_wizard.pl +249 -0
- package/lib/swipl/library/ext/semweb/semweb/INDEX.pl +288 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf11.pl +2106 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf11_containers.pl +299 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_cache.pl +278 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_compare.pl +132 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_db.pl +3468 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_edit.pl +1145 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_http_plugin.pl +274 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_library.pl +1021 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_litindex.pl +1035 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_ntriples.pl +422 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_persistency.pl +1576 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_portray.pl +182 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_prefixes.pl +681 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_sandbox.pl +153 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_turtle.pl +54 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_turtle_write.pl +1587 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_zlib_plugin.pl +52 -0
- package/lib/swipl/library/ext/semweb/semweb/rdfa.pl +1510 -0
- package/lib/swipl/library/ext/semweb/semweb/rdfs.pl +475 -0
- package/lib/swipl/library/ext/semweb/semweb/sparql_client.pl +643 -0
- package/lib/swipl/library/ext/semweb/semweb/turtle.pl +455 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.dcl +88 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.dtd +1092 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.soc +6 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML5.dtd +906 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLlat1.ent +195 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLspec.ent +77 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLsym.ent +241 -0
- package/lib/swipl/library/ext/sgml/INDEX.pl +64 -0
- package/lib/swipl/library/ext/sgml/c14n2.pl +203 -0
- package/lib/swipl/library/ext/sgml/iso_639.pl +631 -0
- package/lib/swipl/library/ext/sgml/pwp.pl +705 -0
- package/lib/swipl/library/ext/sgml/sgml.pl +815 -0
- package/lib/swipl/library/ext/sgml/sgml_write.pl +1003 -0
- package/lib/swipl/library/ext/sgml/xpath.pl +620 -0
- package/lib/swipl/library/ext/sgml/xsdp_types.pl +232 -0
- package/lib/swipl/library/ext/ssl/INDEX.pl +60 -0
- package/lib/swipl/library/ext/ssl/crypto.pl +1015 -0
- package/lib/swipl/library/ext/ssl/http/INDEX.pl +5 -0
- package/lib/swipl/library/ext/ssl/http/http_ssl_plugin.pl +296 -0
- package/lib/swipl/library/ext/ssl/saml.pl +609 -0
- package/lib/swipl/library/ext/ssl/ssl.pl +647 -0
- package/lib/swipl/library/ext/ssl/xmldsig.pl +391 -0
- package/lib/swipl/library/ext/ssl/xmlenc.pl +354 -0
- package/lib/swipl/library/ext/zlib/INDEX.pl +8 -0
- package/lib/swipl/library/ext/zlib/zlib.pl +112 -0
- package/lib/swipl/library/fastrw.pl +105 -0
- package/lib/swipl/library/files.pl +80 -0
- package/lib/swipl/library/gensym.pl +111 -0
- package/lib/swipl/library/git.pl +1027 -0
- package/lib/swipl/library/hashtable.pl +365 -0
- package/lib/swipl/library/heaps.pl +252 -0
- package/lib/swipl/library/hotfix.pl +239 -0
- package/lib/swipl/library/http/jquery.pl +103 -0
- package/lib/swipl/library/http/web/js/jquery-3.6.0.min.js +2 -0
- package/lib/swipl/library/increval.pl +217 -0
- package/lib/swipl/library/intercept.pl +263 -0
- package/lib/swipl/library/iostream.pl +237 -0
- package/lib/swipl/library/iri_scheme/file.pl +70 -0
- package/lib/swipl/library/lazy_lists.pl +481 -0
- package/lib/swipl/library/listing.pl +1362 -0
- package/lib/swipl/library/lists.pl +860 -0
- package/lib/swipl/library/lynx/INDEX.pl +14 -0
- package/lib/swipl/library/lynx/format.pl +380 -0
- package/lib/swipl/library/lynx/html_style.pl +129 -0
- package/lib/swipl/library/lynx/html_text.pl +865 -0
- package/lib/swipl/library/lynx/pldoc_style.pl +87 -0
- package/lib/swipl/library/macros.pl +451 -0
- package/lib/swipl/library/main.pl +1200 -0
- package/lib/swipl/library/make.pl +197 -0
- package/lib/swipl/library/modules.pl +129 -0
- package/lib/swipl/library/nb_rbtrees.pl +267 -0
- package/lib/swipl/library/nb_set.pl +203 -0
- package/lib/swipl/library/obfuscate.pl +115 -0
- package/lib/swipl/library/occurs.pl +241 -0
- package/lib/swipl/library/operators.pl +182 -0
- package/lib/swipl/library/option.pl +388 -0
- package/lib/swipl/library/optparse.pl +966 -0
- package/lib/swipl/library/ordsets.pl +518 -0
- package/lib/swipl/library/oset.pl +160 -0
- package/lib/swipl/library/pairs.pl +187 -0
- package/lib/swipl/library/persistency.pl +713 -0
- package/lib/swipl/library/pio.pl +47 -0
- package/lib/swipl/library/portray_text.pl +277 -0
- package/lib/swipl/library/pprint.pl +940 -0
- package/lib/swipl/library/predicate_options.pl +975 -0
- package/lib/swipl/library/prolog_autoload.pl +233 -0
- package/lib/swipl/library/prolog_breakpoints.pl +396 -0
- package/lib/swipl/library/prolog_clause.pl +1104 -0
- package/lib/swipl/library/prolog_code.pl +416 -0
- package/lib/swipl/library/prolog_codewalk.pl +1248 -0
- package/lib/swipl/library/prolog_colour.pl +3301 -0
- package/lib/swipl/library/prolog_colour.qlf +0 -0
- package/lib/swipl/library/prolog_config.pl +154 -0
- package/lib/swipl/library/prolog_coverage.pl +1333 -0
- package/lib/swipl/library/prolog_debug.pl +404 -0
- package/lib/swipl/library/prolog_deps.pl +675 -0
- package/lib/swipl/library/prolog_evaluable.pl +234 -0
- package/lib/swipl/library/prolog_format.pl +219 -0
- package/lib/swipl/library/prolog_history.pl +161 -0
- package/lib/swipl/library/prolog_jiti.pl +333 -0
- package/lib/swipl/library/prolog_locale.pl +61 -0
- package/lib/swipl/library/prolog_metainference.pl +307 -0
- package/lib/swipl/library/prolog_pack.pl +3906 -0
- package/lib/swipl/library/prolog_profile.pl +346 -0
- package/lib/swipl/library/prolog_qlfmake.pl +533 -0
- package/lib/swipl/library/prolog_source.pl +1188 -0
- package/lib/swipl/library/prolog_stack.pl +794 -0
- package/lib/swipl/library/prolog_trace.pl +365 -0
- package/lib/swipl/library/prolog_versions.pl +347 -0
- package/lib/swipl/library/prolog_wrap.pl +164 -0
- package/lib/swipl/library/prolog_xref.pl +3090 -0
- package/lib/swipl/library/prolog_xref.qlf +0 -0
- package/lib/swipl/library/pure_input.pl +266 -0
- package/lib/swipl/library/qpforeign.pl +695 -0
- package/lib/swipl/library/qsave.pl +1516 -0
- package/lib/swipl/library/quasi_quotations.pl +300 -0
- package/lib/swipl/library/quintus.pl +437 -0
- package/lib/swipl/library/random.pl +459 -0
- package/lib/swipl/library/rbtrees.pl +1153 -0
- package/lib/swipl/library/readln.pl +256 -0
- package/lib/swipl/library/readutil.pl +304 -0
- package/lib/swipl/library/record.pl +544 -0
- package/lib/swipl/library/rwlocks.pl +172 -0
- package/lib/swipl/library/sandbox.pl +1384 -0
- package/lib/swipl/library/semweb/dc.rdfs +198 -0
- package/lib/swipl/library/semweb/eor.rdfs +95 -0
- package/lib/swipl/library/semweb/owl.owl +287 -0
- package/lib/swipl/library/semweb/rdf_library.ttl +90 -0
- package/lib/swipl/library/semweb/rdfs.rdfs +251 -0
- package/lib/swipl/library/settings.pl +755 -0
- package/lib/swipl/library/shell.pl +462 -0
- package/lib/swipl/library/shlib.pl +670 -0
- package/lib/swipl/library/solution_sequences.pl +439 -0
- package/lib/swipl/library/sort.pl +119 -0
- package/lib/swipl/library/statistics.pl +541 -0
- package/lib/swipl/library/streams.pl +118 -0
- package/lib/swipl/library/strings.pl +469 -0
- package/lib/swipl/library/system.pl +95 -0
- package/lib/swipl/library/tables.pl +381 -0
- package/lib/swipl/library/tableutil.pl +771 -0
- package/lib/swipl/library/tabling.pl +42 -0
- package/lib/swipl/library/terms.pl +457 -0
- package/lib/swipl/library/theme/auto.pl +61 -0
- package/lib/swipl/library/theme/dark.pl +455 -0
- package/lib/swipl/library/theme/light.pl +45 -0
- package/lib/swipl/library/thread.pl +810 -0
- package/lib/swipl/library/thread_pool.pl +508 -0
- package/lib/swipl/library/threadutil.pl +574 -0
- package/lib/swipl/library/tty.pl +316 -0
- package/lib/swipl/library/ugraphs.pl +644 -0
- package/lib/swipl/library/unicode/INDEX.pl +6 -0
- package/lib/swipl/library/unicode/blocks.pl +414 -0
- package/lib/swipl/library/url.pl +1129 -0
- package/lib/swipl/library/utf8.pl +145 -0
- package/lib/swipl/library/varnumbers.pl +221 -0
- package/lib/swipl/library/vm.pl +251 -0
- package/lib/swipl/library/wfs.pl +205 -0
- package/lib/swipl/library/when.pl +263 -0
- package/lib/swipl/library/writef.pl +278 -0
- package/lib/swipl/library/www_browser.pl +251 -0
- package/lib/swipl/library/yall.pl +574 -0
- package/lib/swipl/library/zip.pl +211 -0
- package/lib/swipl/swipl.home +1 -0
- package/lib/vendor/libcrypto.so.3 +0 -0
- package/lib/vendor/libpcre2-8.so.0 +0 -0
- package/lib/vendor/libssl.so.3 +0 -0
- package/lib/vendor/libz.so.1 +0 -0
- package/licenses/OpenSSL-LICENSE.txt +177 -0
- package/licenses/PCRE2-COPYING +5 -0
- package/licenses/README.md +12 -0
- package/licenses/SWI-Prolog-LICENSE +41 -0
- package/licenses/zlib-LICENSE +22 -0
- package/package.json +27 -0
|
@@ -0,0 +1,1248 @@
|
|
|
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) 2012-2025, VU University Amsterdam
|
|
7
|
+
CWI, 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_codewalk,
|
|
38
|
+
[ prolog_walk_code/1, % +Options
|
|
39
|
+
prolog_program_clause/2 % -ClauseRef, +Options
|
|
40
|
+
]).
|
|
41
|
+
:- use_module(library(record),[(record)/1, op(_,_,record)]).
|
|
42
|
+
:- use_module(library(debug),[debug/3,debugging/1,assertion/1]).
|
|
43
|
+
|
|
44
|
+
:- autoload(library(apply),[maplist/2]).
|
|
45
|
+
:- autoload(library(error),[must_be/2]).
|
|
46
|
+
:- autoload(library(listing),[portray_clause/1]).
|
|
47
|
+
:- autoload(library(lists),[member/2,nth1/3,append/3]).
|
|
48
|
+
:- autoload(library(option),[meta_options/3]).
|
|
49
|
+
:- autoload(library(prolog_clause),
|
|
50
|
+
[clause_info/4,initialization_layout/4,clause_name/2]).
|
|
51
|
+
:- autoload(library(prolog_metainference),
|
|
52
|
+
[inferred_meta_predicate/2,infer_meta_predicate/2]).
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
/** <module> Prolog code walker
|
|
56
|
+
|
|
57
|
+
This module walks over the loaded program, searching for callable
|
|
58
|
+
predicates. It started as part of library(prolog_autoload) and has been
|
|
59
|
+
turned into a separate module to facilitate operations that require the
|
|
60
|
+
same reachability analysis, such as finding references to a predicate,
|
|
61
|
+
finding unreachable code, etc.
|
|
62
|
+
|
|
63
|
+
For example, the following determins the call graph of the loaded
|
|
64
|
+
program. By using source(true), The exact location of the call in the
|
|
65
|
+
source file is passed into _Where.
|
|
66
|
+
|
|
67
|
+
==
|
|
68
|
+
:- dynamic
|
|
69
|
+
calls/2.
|
|
70
|
+
|
|
71
|
+
assert_call_graph :-
|
|
72
|
+
retractall(calls(_, _)),
|
|
73
|
+
prolog_walk_code([ trace_reference(_),
|
|
74
|
+
on_trace(assert_edge),
|
|
75
|
+
source(false)
|
|
76
|
+
]),
|
|
77
|
+
predicate_property(calls(_,_), number_of_clauses(N)),
|
|
78
|
+
format('Got ~D edges~n', [N]).
|
|
79
|
+
|
|
80
|
+
assert_edge(Callee, Caller, _Where) :-
|
|
81
|
+
calls(Caller, Callee), !.
|
|
82
|
+
assert_edge(Callee, Caller, _Where) :-
|
|
83
|
+
assertz(calls(Caller, Callee)).
|
|
84
|
+
==
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
:- meta_predicate
|
|
88
|
+
prolog_walk_code(:).
|
|
89
|
+
|
|
90
|
+
:- multifile
|
|
91
|
+
prolog:called_by/4,
|
|
92
|
+
prolog:called_by/2.
|
|
93
|
+
|
|
94
|
+
:- predicate_options(prolog_walk_code/1, 1,
|
|
95
|
+
[ undefined(oneof([ignore,error,trace])),
|
|
96
|
+
autoload(boolean),
|
|
97
|
+
clauses(list),
|
|
98
|
+
module(atom),
|
|
99
|
+
module_class(list(oneof([user,system,library,
|
|
100
|
+
test,development]))),
|
|
101
|
+
source(boolean),
|
|
102
|
+
trace_reference(any),
|
|
103
|
+
trace_condition(callable),
|
|
104
|
+
on_trace(callable),
|
|
105
|
+
on_edge(callable),
|
|
106
|
+
infer_meta_predicates(oneof([false,true,all])),
|
|
107
|
+
walk_meta_predicates(boolean),
|
|
108
|
+
evaluate(boolean),
|
|
109
|
+
verbose(boolean)
|
|
110
|
+
]).
|
|
111
|
+
|
|
112
|
+
:- record
|
|
113
|
+
walk_option(undefined:oneof([ignore,error,trace])=ignore,
|
|
114
|
+
autoload:boolean=true,
|
|
115
|
+
source:boolean=true,
|
|
116
|
+
module:atom, % Only analyse given module
|
|
117
|
+
module_class:list(oneof([user,system,library,
|
|
118
|
+
test,development]))=[user,library],
|
|
119
|
+
infer_meta_predicates:oneof([false,true,all])=true,
|
|
120
|
+
walk_meta_predicates:boolean=true,
|
|
121
|
+
clauses:list, % Walk only these clauses
|
|
122
|
+
trace_reference:any=(-),
|
|
123
|
+
trace_condition:callable, % Call-back condition
|
|
124
|
+
on_edge:callable, % Call-back on trace hits
|
|
125
|
+
on_trace:callable, % Call-back on trace hits
|
|
126
|
+
% private stuff
|
|
127
|
+
clause, % Processed clause
|
|
128
|
+
caller, % Head of the caller
|
|
129
|
+
initialization, % Initialization source
|
|
130
|
+
undecided, % Error to throw error
|
|
131
|
+
evaluate:boolean, % Do partial evaluation
|
|
132
|
+
verbose:boolean=false). % Report progress
|
|
133
|
+
|
|
134
|
+
:- thread_local
|
|
135
|
+
multifile_predicate/3. % Name, Arity, Module
|
|
136
|
+
|
|
137
|
+
%! prolog_walk_code(+Options) is det.
|
|
138
|
+
%
|
|
139
|
+
% Walk over all loaded (user) Prolog code. The following code is
|
|
140
|
+
% processed:
|
|
141
|
+
%
|
|
142
|
+
% 1. The bodies of all clauses in all user and library modules.
|
|
143
|
+
% This steps collects, but does not scan multifile predicates
|
|
144
|
+
% to avoid duplicate work.
|
|
145
|
+
% 2. All multi-file predicates collected.
|
|
146
|
+
% 3. All goals registered with initialization/1
|
|
147
|
+
%
|
|
148
|
+
% Options processed:
|
|
149
|
+
%
|
|
150
|
+
% * undefined(+Action)
|
|
151
|
+
% Action defines what happens if the analysis finds a
|
|
152
|
+
% definitely undefined predicate. One of `ignore` or
|
|
153
|
+
% `error` (default is `ignore`).
|
|
154
|
+
%
|
|
155
|
+
% * autoload(+Boolean)
|
|
156
|
+
% Try to autoload code while walking. This is enabled by default
|
|
157
|
+
% to obtain as much as possible information about goals and find
|
|
158
|
+
% references from autoloaded libraries.
|
|
159
|
+
%
|
|
160
|
+
% * clauses(+ListOfClauseReferences)
|
|
161
|
+
% Only process the given clauses. Can be used to find clauses
|
|
162
|
+
% quickly using source(false) and then process only interesting
|
|
163
|
+
% clauses with source information.
|
|
164
|
+
%
|
|
165
|
+
% * module(+Module)
|
|
166
|
+
% Only process the given module
|
|
167
|
+
%
|
|
168
|
+
% * module_class(+ModuleClassList)
|
|
169
|
+
% Limit processing to modules of the given classes. See
|
|
170
|
+
% module_property/2 for details on module classes. Default
|
|
171
|
+
% is to scan the classes =user= and =library=.
|
|
172
|
+
%
|
|
173
|
+
% * infer_meta_predicates(+BooleanOrAll)
|
|
174
|
+
% Use infer_meta_predicate/2 on predicates with clauses that
|
|
175
|
+
% call known meta-predicates. The analysis is restarted until
|
|
176
|
+
% a fixed point is reached. If =true= (default), analysis is
|
|
177
|
+
% only restarted if the inferred meta-predicate contains a
|
|
178
|
+
% callable argument. If =all=, it will be restarted until no
|
|
179
|
+
% more new meta-predicates can be found.
|
|
180
|
+
%
|
|
181
|
+
% * walk_meta_predicates(Boolean)
|
|
182
|
+
% When `false` (default `true`), do not analyse the arguments
|
|
183
|
+
% of meta predicates. Standard Prolog control structures are
|
|
184
|
+
% always analysed.
|
|
185
|
+
%
|
|
186
|
+
% * trace_reference(Callable)
|
|
187
|
+
% Print all calls to goals that subsume Callable. Goals are
|
|
188
|
+
% represented as Module:Callable (i.e., they are always
|
|
189
|
+
% qualified). See also subsumes_term/2.
|
|
190
|
+
%
|
|
191
|
+
% * trace_condition(:Cond)
|
|
192
|
+
% Additional filter condition applied after `trace_reference`.
|
|
193
|
+
% Called as call(Cond, Callee, Context), where `Context` is a
|
|
194
|
+
% dict containing the following keys:
|
|
195
|
+
%
|
|
196
|
+
% - Context:caller
|
|
197
|
+
% Qualified term representing the caller or the atom
|
|
198
|
+
% '<initialization>'.
|
|
199
|
+
% - Context:module
|
|
200
|
+
% Module being processed
|
|
201
|
+
% - Context:clause
|
|
202
|
+
% If we are processing a normal clause, the clause reference
|
|
203
|
+
% to this clause.
|
|
204
|
+
% - Context:initialization
|
|
205
|
+
% If we are processing an initialization/1 directive, a term
|
|
206
|
+
% `File:Line` representing the location of the declaration.
|
|
207
|
+
%
|
|
208
|
+
% * on_edge(:OnEdge)
|
|
209
|
+
% If a reference to `trace_reference` is found, call
|
|
210
|
+
% call(OnEdge, Callee, Caller, Location), where `Location` is a
|
|
211
|
+
% dict containing a subset of the keys `clause`, `file`,
|
|
212
|
+
% `character_count`, `line_count` and `line_position`. If
|
|
213
|
+
% full position information is available all keys are present.
|
|
214
|
+
% If the clause layout is unknown the only the `clause`, `file`
|
|
215
|
+
% and `line_count` are available and the line is the start line
|
|
216
|
+
% of the clause. For a dynamic clause, only the `clause` is
|
|
217
|
+
% present. If the position is associated to a _directive_,
|
|
218
|
+
% the `clause` is missing. If nothing is known the `Location`
|
|
219
|
+
% is an empty dict.
|
|
220
|
+
%
|
|
221
|
+
% * on_trace(:OnTrace)
|
|
222
|
+
% As `on_edge`, but location is not translated and is one
|
|
223
|
+
% of these:
|
|
224
|
+
%
|
|
225
|
+
% - clause_term_position(+ClauseRef, +TermPos)
|
|
226
|
+
% - clause(+ClauseRef)
|
|
227
|
+
% - file_term_position(+Path, +TermPos)
|
|
228
|
+
% - file(+File, +Line, -1, _)
|
|
229
|
+
% - a variable (unknown)
|
|
230
|
+
%
|
|
231
|
+
% Caller is the qualified head of the calling clause or the
|
|
232
|
+
% atom '<initialization>'.
|
|
233
|
+
%
|
|
234
|
+
% * source(+Boolean)
|
|
235
|
+
% If `false` (default `true`), to not try to obtain detailed
|
|
236
|
+
% source information for printed messages.
|
|
237
|
+
%
|
|
238
|
+
% * verbose(+Boolean)
|
|
239
|
+
% If `true` (default `false`), report derived meta-predicates
|
|
240
|
+
% and iterations.
|
|
241
|
+
%
|
|
242
|
+
% @compat OnTrace was called using Caller-Location in older
|
|
243
|
+
% versions.
|
|
244
|
+
|
|
245
|
+
prolog_walk_code(Options) :-
|
|
246
|
+
meta_options(is_meta, Options, QOptions),
|
|
247
|
+
prolog_walk_code(1, QOptions).
|
|
248
|
+
|
|
249
|
+
prolog_walk_code(Iteration, Options) :-
|
|
250
|
+
statistics(cputime, CPU0),
|
|
251
|
+
make_walk_option(Options, OTerm, _),
|
|
252
|
+
( walk_option_clauses(OTerm, Clauses),
|
|
253
|
+
nonvar(Clauses)
|
|
254
|
+
-> walk_clauses(Clauses, OTerm)
|
|
255
|
+
; forall(( walk_option_module(OTerm, M0),
|
|
256
|
+
copy_term(M0, M),
|
|
257
|
+
current_module(M),
|
|
258
|
+
scan_module(M, OTerm)
|
|
259
|
+
),
|
|
260
|
+
find_walk_from_module(M, OTerm)),
|
|
261
|
+
walk_from_multifile(OTerm),
|
|
262
|
+
walk_from_initialization(OTerm)
|
|
263
|
+
),
|
|
264
|
+
infer_new_meta_predicates(New, OTerm),
|
|
265
|
+
statistics(cputime, CPU1),
|
|
266
|
+
( New \== []
|
|
267
|
+
-> CPU is CPU1-CPU0,
|
|
268
|
+
( walk_option_verbose(OTerm, true)
|
|
269
|
+
-> Level = informational
|
|
270
|
+
; Level = silent
|
|
271
|
+
),
|
|
272
|
+
print_message(Level,
|
|
273
|
+
codewalk(reiterate(New, Iteration, CPU))),
|
|
274
|
+
succ(Iteration, Iteration2),
|
|
275
|
+
prolog_walk_code(Iteration2, Options)
|
|
276
|
+
; true
|
|
277
|
+
).
|
|
278
|
+
|
|
279
|
+
is_meta(on_edge).
|
|
280
|
+
is_meta(on_trace).
|
|
281
|
+
is_meta(trace_condition).
|
|
282
|
+
|
|
283
|
+
%! walk_clauses(+Clauses, +OTerm) is det.
|
|
284
|
+
%
|
|
285
|
+
% Walk the given clauses.
|
|
286
|
+
|
|
287
|
+
walk_clauses(Clauses, OTerm) :-
|
|
288
|
+
must_be(list, Clauses),
|
|
289
|
+
forall(member(ClauseRef, Clauses),
|
|
290
|
+
( user:clause(CHead, Body, ClauseRef),
|
|
291
|
+
( CHead = Module:Head
|
|
292
|
+
-> true
|
|
293
|
+
; Module = user,
|
|
294
|
+
Head = CHead
|
|
295
|
+
),
|
|
296
|
+
walk_option_clause(OTerm, ClauseRef),
|
|
297
|
+
walk_option_caller(OTerm, Module:Head),
|
|
298
|
+
walk_called_by_body(Body, Module, OTerm)
|
|
299
|
+
)).
|
|
300
|
+
|
|
301
|
+
%! scan_module(+Module, +OTerm) is semidet.
|
|
302
|
+
%
|
|
303
|
+
% True if we must scan Module according to OTerm.
|
|
304
|
+
|
|
305
|
+
scan_module(M, OTerm) :-
|
|
306
|
+
walk_option_module(OTerm, M1),
|
|
307
|
+
nonvar(M1),
|
|
308
|
+
!,
|
|
309
|
+
\+ M \= M1.
|
|
310
|
+
scan_module(M, OTerm) :-
|
|
311
|
+
walk_option_module_class(OTerm, Classes),
|
|
312
|
+
module_property(M, class(Class)),
|
|
313
|
+
memberchk(Class, Classes),
|
|
314
|
+
!.
|
|
315
|
+
|
|
316
|
+
%! walk_from_initialization(+OTerm)
|
|
317
|
+
%
|
|
318
|
+
% Find initialization/1,2 directives and process what they are
|
|
319
|
+
% calling. Skip
|
|
320
|
+
%
|
|
321
|
+
% @bug Relies on private '$init_goal'/3 database.
|
|
322
|
+
|
|
323
|
+
walk_from_initialization(OTerm) :-
|
|
324
|
+
walk_option_caller(OTerm, '<initialization>'),
|
|
325
|
+
forall(init_goal_in_scope(Goal, SourceLocation, OTerm),
|
|
326
|
+
( walk_option_initialization(OTerm, SourceLocation),
|
|
327
|
+
walk_from_initialization(Goal, OTerm))).
|
|
328
|
+
|
|
329
|
+
init_goal_in_scope(Goal, SourceLocation, OTerm) :-
|
|
330
|
+
'$init_goal'(_When, Goal, SourceLocation),
|
|
331
|
+
SourceLocation = File:_Line,
|
|
332
|
+
( walk_option_module(OTerm, M),
|
|
333
|
+
nonvar(M)
|
|
334
|
+
-> module_property(M, file(File))
|
|
335
|
+
; walk_option_module_class(OTerm, Classes),
|
|
336
|
+
source_file_property(File, module(MF))
|
|
337
|
+
-> module_property(MF, class(Class)),
|
|
338
|
+
memberchk(Class, Classes),
|
|
339
|
+
walk_option_module(OTerm, MF)
|
|
340
|
+
; true
|
|
341
|
+
).
|
|
342
|
+
|
|
343
|
+
walk_from_initialization(M:Goal, OTerm) :-
|
|
344
|
+
scan_module(M, OTerm),
|
|
345
|
+
!,
|
|
346
|
+
walk_called_by_body(Goal, M, OTerm).
|
|
347
|
+
walk_from_initialization(_, _).
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
%! find_walk_from_module(+Module, +OTerm) is det.
|
|
351
|
+
%
|
|
352
|
+
% Find undefined calls from the bodies of all clauses that belong
|
|
353
|
+
% to Module.
|
|
354
|
+
|
|
355
|
+
find_walk_from_module(M, OTerm) :-
|
|
356
|
+
debug(autoload, 'Analysing module ~q', [M]),
|
|
357
|
+
walk_option_module(OTerm, M),
|
|
358
|
+
forall(predicate_in_module(M, PI),
|
|
359
|
+
walk_called_by_pred(M:PI, OTerm)).
|
|
360
|
+
|
|
361
|
+
walk_called_by_pred(Module:Name/Arity, _) :-
|
|
362
|
+
multifile_predicate(Name, Arity, Module),
|
|
363
|
+
!.
|
|
364
|
+
walk_called_by_pred(Module:Name/Arity, _) :-
|
|
365
|
+
functor(Head, Name, Arity),
|
|
366
|
+
predicate_property(Module:Head, multifile),
|
|
367
|
+
!,
|
|
368
|
+
assertz(multifile_predicate(Name, Arity, Module)).
|
|
369
|
+
walk_called_by_pred(Module:Name/Arity, OTerm) :-
|
|
370
|
+
functor(Head, Name, Arity),
|
|
371
|
+
( no_walk_property(Property),
|
|
372
|
+
predicate_property(Module:Head, Property)
|
|
373
|
+
-> true
|
|
374
|
+
; walk_option_caller(OTerm, Module:Head),
|
|
375
|
+
walk_option_clause(OTerm, ClauseRef),
|
|
376
|
+
forall(catch(clause(Module:Head, Body, ClauseRef), _, fail),
|
|
377
|
+
walk_called_by_body(Body, Module, OTerm))
|
|
378
|
+
).
|
|
379
|
+
|
|
380
|
+
no_walk_property(number_of_rules(0)). % no point walking only facts
|
|
381
|
+
no_walk_property(foreign). % cannot walk foreign code
|
|
382
|
+
|
|
383
|
+
%! walk_from_multifile(+OTerm)
|
|
384
|
+
%
|
|
385
|
+
% Process registered multifile predicates.
|
|
386
|
+
|
|
387
|
+
walk_from_multifile(OTerm) :-
|
|
388
|
+
forall(retract(multifile_predicate(Name, Arity, Module)),
|
|
389
|
+
walk_called_by_multifile(Module:Name/Arity, OTerm)).
|
|
390
|
+
|
|
391
|
+
walk_called_by_multifile(Module:Name/Arity, OTerm) :-
|
|
392
|
+
functor(Head, Name, Arity),
|
|
393
|
+
forall(catch(clause_not_from_development(
|
|
394
|
+
Module:Head, Body, ClauseRef, OTerm),
|
|
395
|
+
_, fail),
|
|
396
|
+
( walk_option_clause(OTerm, ClauseRef),
|
|
397
|
+
walk_option_caller(OTerm, Module:Head),
|
|
398
|
+
walk_called_by_body(Body, Module, OTerm)
|
|
399
|
+
)).
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
%! clause_not_from_development(:Head, -Body, ?Ref, +Options) is nondet.
|
|
403
|
+
%
|
|
404
|
+
% Enumerate clauses for a multifile predicate, but omit those from
|
|
405
|
+
% a module that is specifically meant to support development.
|
|
406
|
+
|
|
407
|
+
clause_not_from_development(Module:Head, Body, Ref, OTerm) :-
|
|
408
|
+
clause(Module:Head, Body, Ref),
|
|
409
|
+
\+ ( clause_property(Ref, file(File)),
|
|
410
|
+
module_property(LoadModule, file(File)),
|
|
411
|
+
\+ scan_module(LoadModule, OTerm)
|
|
412
|
+
).
|
|
413
|
+
|
|
414
|
+
%! walk_called_by_body(+Body, +Module, +OTerm) is det.
|
|
415
|
+
%
|
|
416
|
+
% Check the Body term when executed in the context of Module.
|
|
417
|
+
% Options:
|
|
418
|
+
%
|
|
419
|
+
% - undefined(+Action)
|
|
420
|
+
% One of =ignore=, =error=
|
|
421
|
+
|
|
422
|
+
walk_called_by_body(True, _, _) :-
|
|
423
|
+
True == true,
|
|
424
|
+
!. % quickly deal with facts
|
|
425
|
+
walk_called_by_body(Body, Module, OTerm) :-
|
|
426
|
+
set_undecided_of_walk_option(error, OTerm, OTerm1),
|
|
427
|
+
set_evaluate_of_walk_option(false, OTerm1, OTerm2),
|
|
428
|
+
catch(walk_called(Body, Module, _TermPos, OTerm2),
|
|
429
|
+
missing(Missing),
|
|
430
|
+
walk_called_by_body(Missing, Body, Module, OTerm)),
|
|
431
|
+
!.
|
|
432
|
+
walk_called_by_body(Body, Module, OTerm) :-
|
|
433
|
+
format(user_error, 'Failed to analyse:~n', []),
|
|
434
|
+
portray_clause(('<head>' :- Body)),
|
|
435
|
+
debug_walk(Body, Module, OTerm).
|
|
436
|
+
|
|
437
|
+
% recompile this library after `debug(codewalk(trace))` and re-try
|
|
438
|
+
% for debugging failures.
|
|
439
|
+
:- if(debugging(codewalk(trace))).
|
|
440
|
+
debug_walk(Body, Module, OTerm) :-
|
|
441
|
+
gtrace,
|
|
442
|
+
walk_called_by_body(Body, Module, OTerm).
|
|
443
|
+
:- else.
|
|
444
|
+
debug_walk(_,_,_).
|
|
445
|
+
:- endif.
|
|
446
|
+
|
|
447
|
+
%! walk_called_by_body(+Missing, +Body, +Module, +OTerm)
|
|
448
|
+
%
|
|
449
|
+
% Restart the analysis because the previous analysis provided
|
|
450
|
+
% insufficient information.
|
|
451
|
+
|
|
452
|
+
walk_called_by_body(Missing, Body, _, OTerm) :-
|
|
453
|
+
debugging(codewalk),
|
|
454
|
+
format(user_error, 'Retrying due to ~w (~p)~n', [Missing, OTerm]),
|
|
455
|
+
portray_clause(('<head>' :- Body)), fail.
|
|
456
|
+
walk_called_by_body(undecided_call, Body, Module, OTerm) :-
|
|
457
|
+
catch(forall(walk_called(Body, Module, _TermPos, OTerm),
|
|
458
|
+
true),
|
|
459
|
+
missing(Missing),
|
|
460
|
+
walk_called_by_body(Missing, Body, Module, OTerm)).
|
|
461
|
+
walk_called_by_body(subterm_positions, Body, Module, OTerm) :-
|
|
462
|
+
( ( walk_option_clause(OTerm, ClauseRef), nonvar(ClauseRef),
|
|
463
|
+
clause_info(ClauseRef, _, TermPos, _NameOffset),
|
|
464
|
+
TermPos = term_position(_,_,_,_,[_,BodyPos])
|
|
465
|
+
-> WBody = Body
|
|
466
|
+
; walk_option_initialization(OTerm, SrcLoc),
|
|
467
|
+
ground(SrcLoc), SrcLoc = _File:_Line,
|
|
468
|
+
initialization_layout(SrcLoc, Module:Body, WBody, BodyPos)
|
|
469
|
+
)
|
|
470
|
+
-> catch(forall(walk_called(WBody, Module, BodyPos, OTerm),
|
|
471
|
+
true),
|
|
472
|
+
missing(subterm_positions),
|
|
473
|
+
walk_called_by_body(no_positions, Body, Module, OTerm))
|
|
474
|
+
; set_source_of_walk_option(false, OTerm, OTerm2),
|
|
475
|
+
forall(walk_called(Body, Module, _BodyPos, OTerm2),
|
|
476
|
+
true)
|
|
477
|
+
).
|
|
478
|
+
walk_called_by_body(no_positions, Body, Module, OTerm) :-
|
|
479
|
+
set_source_of_walk_option(false, OTerm, OTerm2),
|
|
480
|
+
forall(walk_called(Body, Module, _NoPos, OTerm2),
|
|
481
|
+
true).
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
%! walk_called(+Goal, +Module, +TermPos, +OTerm) is multi.
|
|
485
|
+
%
|
|
486
|
+
% Perform abstract interpretation of Goal, touching all sub-goals
|
|
487
|
+
% that are directly called or immediately reachable through
|
|
488
|
+
% meta-calls. The actual auto-loading is performed by the
|
|
489
|
+
% predicate_property/2 call for meta-predicates.
|
|
490
|
+
%
|
|
491
|
+
% If Goal is disjunctive, walk_called succeeds with a
|
|
492
|
+
% choice-point. Backtracking analyses the alternative control
|
|
493
|
+
% path(s).
|
|
494
|
+
%
|
|
495
|
+
% Options:
|
|
496
|
+
%
|
|
497
|
+
% * undecided(+Action)
|
|
498
|
+
% How to deal with insifficiently instantiated terms in the
|
|
499
|
+
% call-tree. Values are:
|
|
500
|
+
%
|
|
501
|
+
% - ignore
|
|
502
|
+
% Silently ignore such goals
|
|
503
|
+
% - error
|
|
504
|
+
% Throw =undecided_call=
|
|
505
|
+
%
|
|
506
|
+
% * evaluate(+Boolean)
|
|
507
|
+
% If =true= (default), evaluate some goals. Notably =/2.
|
|
508
|
+
%
|
|
509
|
+
% @tbd Analyse e.g. assert((Head:-Body))?
|
|
510
|
+
|
|
511
|
+
walk_called(Term, Module, parentheses_term_position(_,_,Pos), OTerm) :-
|
|
512
|
+
nonvar(Pos),
|
|
513
|
+
!,
|
|
514
|
+
walk_called(Term, Module, Pos, OTerm).
|
|
515
|
+
walk_called(Var, _, TermPos, OTerm) :-
|
|
516
|
+
var(Var), % Incomplete analysis
|
|
517
|
+
!,
|
|
518
|
+
undecided(Var, TermPos, OTerm).
|
|
519
|
+
walk_called(M:G, _, term_position(_,_,_,_,[MPos,Pos]), OTerm) :-
|
|
520
|
+
!,
|
|
521
|
+
( nonvar(M)
|
|
522
|
+
-> walk_called(G, M, Pos, OTerm)
|
|
523
|
+
; undecided(M, MPos, OTerm)
|
|
524
|
+
).
|
|
525
|
+
walk_called((A,B), M, term_position(_,_,_,_,[PA,PB]), OTerm) :-
|
|
526
|
+
!,
|
|
527
|
+
walk_called(A, M, PA, OTerm),
|
|
528
|
+
walk_called(B, M, PB, OTerm).
|
|
529
|
+
walk_called((A->B), M, term_position(_,_,_,_,[PA,PB]), OTerm) :-
|
|
530
|
+
!,
|
|
531
|
+
walk_called(A, M, PA, OTerm),
|
|
532
|
+
walk_called(B, M, PB, OTerm).
|
|
533
|
+
walk_called((A*->B), M, term_position(_,_,_,_,[PA,PB]), OTerm) :-
|
|
534
|
+
!,
|
|
535
|
+
walk_called(A, M, PA, OTerm),
|
|
536
|
+
walk_called(B, M, PB, OTerm).
|
|
537
|
+
walk_called(\+(A), M, term_position(_,_,_,_,[PA]), OTerm) :-
|
|
538
|
+
!,
|
|
539
|
+
\+ \+ walk_called(A, M, PA, OTerm).
|
|
540
|
+
walk_called((A;B), M, term_position(_,_,_,_,[PA,PB]), OTerm) :-
|
|
541
|
+
!,
|
|
542
|
+
( walk_option_evaluate(OTerm, Eval), Eval == true
|
|
543
|
+
-> Goal = (A;B),
|
|
544
|
+
setof(Goal,
|
|
545
|
+
( walk_called(A, M, PA, OTerm)
|
|
546
|
+
; walk_called(B, M, PB, OTerm)
|
|
547
|
+
),
|
|
548
|
+
Alts0),
|
|
549
|
+
variants(Alts0, Alts),
|
|
550
|
+
member(Goal, Alts)
|
|
551
|
+
; \+ \+ walk_called(A, M, PA, OTerm), % do not propagate bindings
|
|
552
|
+
\+ \+ walk_called(B, M, PB, OTerm)
|
|
553
|
+
).
|
|
554
|
+
walk_called(Goal, Module, TermPos, OTerm) :-
|
|
555
|
+
walk_option_trace_reference(OTerm, To), To \== (-),
|
|
556
|
+
( subsumes_term(To, Module:Goal)
|
|
557
|
+
-> M2 = Module
|
|
558
|
+
; predicate_property(Module:Goal, imported_from(M2)),
|
|
559
|
+
subsumes_term(To, M2:Goal)
|
|
560
|
+
),
|
|
561
|
+
trace_condition(M2:Goal, TermPos, OTerm),
|
|
562
|
+
print_reference(M2:Goal, TermPos, trace, OTerm),
|
|
563
|
+
fail. % Continue search
|
|
564
|
+
walk_called(Goal, Module, _, OTerm) :-
|
|
565
|
+
evaluate(Goal, Module, OTerm),
|
|
566
|
+
!.
|
|
567
|
+
walk_called(autoload_call(_), _, _, _) :-
|
|
568
|
+
!. % Should we continue, but just not report?
|
|
569
|
+
walk_called(Goal, M, TermPos, OTerm) :-
|
|
570
|
+
( ( predicate_property(M:Goal, imported_from(IM))
|
|
571
|
+
-> true
|
|
572
|
+
; IM = M
|
|
573
|
+
),
|
|
574
|
+
prolog:called_by(Goal, IM, M, Called)
|
|
575
|
+
; prolog:called_by(Goal, Called)
|
|
576
|
+
),
|
|
577
|
+
Called \== [],
|
|
578
|
+
!,
|
|
579
|
+
walk_called_by(Called, M, Goal, TermPos, OTerm).
|
|
580
|
+
walk_called(Meta, M, term_position(_,E,_,_,ArgPosList), OTerm) :-
|
|
581
|
+
walk_option_walk_meta_predicates(OTerm, true),
|
|
582
|
+
( walk_option_autoload(OTerm, false)
|
|
583
|
+
-> nonvar(M),
|
|
584
|
+
'$get_predicate_attribute'(M:Meta, defined, 1)
|
|
585
|
+
; true
|
|
586
|
+
),
|
|
587
|
+
( predicate_property(M:Meta, meta_predicate(Head))
|
|
588
|
+
; inferred_meta_predicate(M:Meta, Head)
|
|
589
|
+
),
|
|
590
|
+
!,
|
|
591
|
+
walk_option_clause(OTerm, ClauseRef),
|
|
592
|
+
register_possible_meta_clause(ClauseRef),
|
|
593
|
+
walk_meta_call(1, Head, Meta, M, ArgPosList, E-E, OTerm).
|
|
594
|
+
walk_called(Closure, _, _, _) :-
|
|
595
|
+
blob(Closure, closure),
|
|
596
|
+
!,
|
|
597
|
+
'$closure_predicate'(Closure, Module:Name/Arity),
|
|
598
|
+
functor(Head, Name, Arity),
|
|
599
|
+
'$get_predicate_attribute'(Module:Head, defined, 1).
|
|
600
|
+
walk_called(ClosureCall, _, _, _) :-
|
|
601
|
+
compound(ClosureCall),
|
|
602
|
+
compound_name_arity(ClosureCall, Closure, _),
|
|
603
|
+
blob(Closure, closure),
|
|
604
|
+
!,
|
|
605
|
+
'$closure_predicate'(Closure, Module:Name/Arity),
|
|
606
|
+
functor(Head, Name, Arity),
|
|
607
|
+
'$get_predicate_attribute'(Module:Head, defined, 1).
|
|
608
|
+
walk_called(Goal, Module, _, _) :-
|
|
609
|
+
nonvar(Module),
|
|
610
|
+
'$get_predicate_attribute'(Module:Goal, defined, 1),
|
|
611
|
+
!.
|
|
612
|
+
walk_called(Goal, Module, TermPos, OTerm) :-
|
|
613
|
+
callable(Goal),
|
|
614
|
+
!,
|
|
615
|
+
undefined(Module:Goal, TermPos, OTerm).
|
|
616
|
+
walk_called(Goal, _Module, TermPos, OTerm) :-
|
|
617
|
+
not_callable(Goal, TermPos, OTerm).
|
|
618
|
+
|
|
619
|
+
%! trace_condition(:Callee, +TermPos, +OTerm) is semidet.
|
|
620
|
+
%
|
|
621
|
+
% Call call(Condition, Callee, Dict)
|
|
622
|
+
|
|
623
|
+
trace_condition(Callee, TermPos, OTerm) :-
|
|
624
|
+
walk_option_trace_condition(OTerm, Cond), nonvar(Cond),
|
|
625
|
+
!,
|
|
626
|
+
cond_location_context(OTerm, TermPos, Context0),
|
|
627
|
+
walk_option_caller(OTerm, Caller),
|
|
628
|
+
walk_option_module(OTerm, Module),
|
|
629
|
+
put_dict(#{caller:Caller, module:Module}, Context0, Context),
|
|
630
|
+
call(Cond, Callee, Context).
|
|
631
|
+
trace_condition(_, _, _).
|
|
632
|
+
|
|
633
|
+
cond_location_context(OTerm, _TermPos, Context) :-
|
|
634
|
+
walk_option_clause(OTerm, Clause), nonvar(Clause),
|
|
635
|
+
!,
|
|
636
|
+
Context = #{clause:Clause}.
|
|
637
|
+
cond_location_context(OTerm, _TermPos, Context) :-
|
|
638
|
+
walk_option_initialization(OTerm, Init), nonvar(Init),
|
|
639
|
+
!,
|
|
640
|
+
Context = #{initialization:Init}.
|
|
641
|
+
|
|
642
|
+
%! undecided(+Variable, +TermPos, +OTerm)
|
|
643
|
+
|
|
644
|
+
undecided(Var, TermPos, OTerm) :-
|
|
645
|
+
walk_option_undecided(OTerm, Undecided),
|
|
646
|
+
( var(Undecided)
|
|
647
|
+
-> Action = ignore
|
|
648
|
+
; Action = Undecided
|
|
649
|
+
),
|
|
650
|
+
undecided(Action, Var, TermPos, OTerm).
|
|
651
|
+
|
|
652
|
+
undecided(ignore, _, _, _) :- !.
|
|
653
|
+
undecided(error, _, _, _) :-
|
|
654
|
+
throw(missing(undecided_call)).
|
|
655
|
+
|
|
656
|
+
%! evaluate(Goal, Module, OTerm) is nondet.
|
|
657
|
+
|
|
658
|
+
evaluate(Goal, Module, OTerm) :-
|
|
659
|
+
walk_option_evaluate(OTerm, Evaluate),
|
|
660
|
+
Evaluate \== false,
|
|
661
|
+
evaluate(Goal, Module).
|
|
662
|
+
|
|
663
|
+
evaluate(A=B, _) :-
|
|
664
|
+
unify_with_occurs_check(A, B).
|
|
665
|
+
|
|
666
|
+
%! undefined(:Goal, +TermPos, +OTerm)
|
|
667
|
+
%
|
|
668
|
+
% The analysis trapped a definitely undefined predicate.
|
|
669
|
+
|
|
670
|
+
undefined(_, _, OTerm) :-
|
|
671
|
+
walk_option_undefined(OTerm, ignore),
|
|
672
|
+
!.
|
|
673
|
+
undefined(Goal, _, _) :-
|
|
674
|
+
predicate_property(Goal, autoload(_)),
|
|
675
|
+
!.
|
|
676
|
+
undefined(Goal, TermPos, OTerm) :-
|
|
677
|
+
( walk_option_undefined(OTerm, trace)
|
|
678
|
+
-> Why = trace
|
|
679
|
+
; Why = undefined
|
|
680
|
+
),
|
|
681
|
+
print_reference(Goal, TermPos, Why, OTerm).
|
|
682
|
+
|
|
683
|
+
%! not_callable(+Goal, +TermPos, +OTerm)
|
|
684
|
+
%
|
|
685
|
+
% We found a reference to a non-callable term
|
|
686
|
+
|
|
687
|
+
not_callable(Goal, TermPos, OTerm) :-
|
|
688
|
+
print_reference(Goal, TermPos, not_callable, OTerm).
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
%! print_reference(+Goal, +TermPos, +Why, +OTerm)
|
|
692
|
+
%
|
|
693
|
+
% Print a reference to Goal, found at TermPos.
|
|
694
|
+
%
|
|
695
|
+
% @arg Why is one of `trace` or `undefined`
|
|
696
|
+
|
|
697
|
+
print_reference(Goal, TermPos, Why, OTerm) :-
|
|
698
|
+
walk_option_clause(OTerm, Clause), nonvar(Clause),
|
|
699
|
+
!,
|
|
700
|
+
( compound(TermPos),
|
|
701
|
+
arg(1, TermPos, CharCount),
|
|
702
|
+
integer(CharCount) % test it is valid
|
|
703
|
+
-> From = clause_term_position(Clause, TermPos)
|
|
704
|
+
; walk_option_source(OTerm, false)
|
|
705
|
+
-> From = clause(Clause)
|
|
706
|
+
; From = _,
|
|
707
|
+
throw(missing(subterm_positions))
|
|
708
|
+
),
|
|
709
|
+
print_reference2(Goal, From, Why, OTerm).
|
|
710
|
+
print_reference(Goal, TermPos, Why, OTerm) :-
|
|
711
|
+
walk_option_initialization(OTerm, Init), nonvar(Init),
|
|
712
|
+
Init = File:Line,
|
|
713
|
+
!,
|
|
714
|
+
( compound(TermPos),
|
|
715
|
+
arg(1, TermPos, CharCount),
|
|
716
|
+
integer(CharCount) % test it is valid
|
|
717
|
+
-> From = file_term_position(File, TermPos)
|
|
718
|
+
; walk_option_source(OTerm, false)
|
|
719
|
+
-> From = file(File, Line, -1, _)
|
|
720
|
+
; From = _,
|
|
721
|
+
throw(missing(subterm_positions))
|
|
722
|
+
),
|
|
723
|
+
print_reference2(Goal, From, Why, OTerm).
|
|
724
|
+
print_reference(Goal, _, Why, OTerm) :-
|
|
725
|
+
print_reference2(Goal, _, Why, OTerm).
|
|
726
|
+
|
|
727
|
+
print_reference2(Goal, From, trace, OTerm) :-
|
|
728
|
+
walk_option_on_trace(OTerm, Closure),
|
|
729
|
+
nonvar(Closure),
|
|
730
|
+
walk_option_caller(OTerm, Caller),
|
|
731
|
+
call(Closure, Goal, Caller, From),
|
|
732
|
+
!.
|
|
733
|
+
print_reference2(Goal, From, trace, OTerm) :-
|
|
734
|
+
walk_option_on_edge(OTerm, Closure),
|
|
735
|
+
nonvar(Closure),
|
|
736
|
+
walk_option_caller(OTerm, Caller),
|
|
737
|
+
translate_location(From, Dict),
|
|
738
|
+
call(Closure, Goal, Caller, Dict),
|
|
739
|
+
!.
|
|
740
|
+
print_reference2(Goal, From, Why, _OTerm) :-
|
|
741
|
+
make_message(Why, Goal, From, Message, Level),
|
|
742
|
+
print_message(Level, Message).
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
make_message(undefined, Goal, Context,
|
|
746
|
+
error(existence_error(procedure, PI), Context), error) :-
|
|
747
|
+
goal_pi(Goal, PI).
|
|
748
|
+
make_message(not_callable, Goal, Context,
|
|
749
|
+
error(type_error(callable, Goal), Context), error).
|
|
750
|
+
make_message(trace, Goal, Context,
|
|
751
|
+
trace_call_to(PI, Context), informational) :-
|
|
752
|
+
goal_pi(Goal, PI).
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
goal_pi(Goal, M:Name/Arity) :-
|
|
756
|
+
strip_module(Goal, M, Head),
|
|
757
|
+
callable(Head),
|
|
758
|
+
!,
|
|
759
|
+
functor(Head, Name, Arity).
|
|
760
|
+
goal_pi(Goal, Goal).
|
|
761
|
+
|
|
762
|
+
:- dynamic
|
|
763
|
+
possible_meta_predicate/2.
|
|
764
|
+
|
|
765
|
+
%! register_possible_meta_clause(+ClauseRef) is det.
|
|
766
|
+
%
|
|
767
|
+
% ClausesRef contains as call to a meta-predicate. Remember to
|
|
768
|
+
% analyse this predicate. We only analyse the predicate if it is
|
|
769
|
+
% loaded from a user module. I.e., system and library modules are
|
|
770
|
+
% trusted.
|
|
771
|
+
|
|
772
|
+
register_possible_meta_clause(ClausesRef) :-
|
|
773
|
+
nonvar(ClausesRef),
|
|
774
|
+
clause_property(ClausesRef, predicate(PI)),
|
|
775
|
+
pi_head(PI, Head, Module),
|
|
776
|
+
module_property(Module, class(user)),
|
|
777
|
+
\+ predicate_property(Module:Head, meta_predicate(_)),
|
|
778
|
+
\+ inferred_meta_predicate(Module:Head, _),
|
|
779
|
+
\+ possible_meta_predicate(Head, Module),
|
|
780
|
+
!,
|
|
781
|
+
assertz(possible_meta_predicate(Head, Module)).
|
|
782
|
+
register_possible_meta_clause(_).
|
|
783
|
+
|
|
784
|
+
pi_head(Module:Name/Arity, Head, Module) :-
|
|
785
|
+
!,
|
|
786
|
+
functor(Head, Name, Arity).
|
|
787
|
+
pi_head(_, _, _) :-
|
|
788
|
+
assertion(fail).
|
|
789
|
+
|
|
790
|
+
%! infer_new_meta_predicates(-MetaSpecs, +OTerm) is det.
|
|
791
|
+
|
|
792
|
+
infer_new_meta_predicates([], OTerm) :-
|
|
793
|
+
walk_option_infer_meta_predicates(OTerm, false),
|
|
794
|
+
!.
|
|
795
|
+
infer_new_meta_predicates(MetaSpecs, OTerm) :-
|
|
796
|
+
findall(Module:MetaSpec,
|
|
797
|
+
( retract(possible_meta_predicate(Head, Module)),
|
|
798
|
+
infer_meta_predicate(Module:Head, MetaSpec),
|
|
799
|
+
( walk_option_infer_meta_predicates(OTerm, all)
|
|
800
|
+
-> true
|
|
801
|
+
; calling_metaspec(MetaSpec)
|
|
802
|
+
)
|
|
803
|
+
),
|
|
804
|
+
MetaSpecs).
|
|
805
|
+
|
|
806
|
+
%! calling_metaspec(+Head) is semidet.
|
|
807
|
+
%
|
|
808
|
+
% True if this is a meta-specification that makes a difference to
|
|
809
|
+
% the code walker.
|
|
810
|
+
|
|
811
|
+
calling_metaspec(Head) :-
|
|
812
|
+
arg(_, Head, Arg),
|
|
813
|
+
calling_metaarg(Arg),
|
|
814
|
+
!.
|
|
815
|
+
|
|
816
|
+
calling_metaarg(I) :- integer(I), !.
|
|
817
|
+
calling_metaarg(^).
|
|
818
|
+
calling_metaarg(//).
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
%! walk_meta_call(+Index, +GoalHead, +MetaHead, +Module,
|
|
822
|
+
%! +ArgPosList, +EndPos, +OTerm)
|
|
823
|
+
%
|
|
824
|
+
% Walk a call to a meta-predicate. This walks all meta-arguments
|
|
825
|
+
% labeled with an integer, ^ or //.
|
|
826
|
+
%
|
|
827
|
+
% @arg EndPos reflects the end of the term. This is used if the
|
|
828
|
+
% number of arguments in the compiled form exceeds the
|
|
829
|
+
% number of arguments in the term read.
|
|
830
|
+
|
|
831
|
+
walk_meta_call(I, Head, Meta, M, ArgPosList, EPos, OTerm) :-
|
|
832
|
+
arg(I, Head, AS),
|
|
833
|
+
!,
|
|
834
|
+
( ArgPosList = [ArgPos|ArgPosTail]
|
|
835
|
+
-> true
|
|
836
|
+
; ArgPos = EPos,
|
|
837
|
+
ArgPosTail = []
|
|
838
|
+
),
|
|
839
|
+
( integer(AS)
|
|
840
|
+
-> arg(I, Meta, MA),
|
|
841
|
+
extend(MA, AS, Goal, ArgPos, ArgPosEx, OTerm),
|
|
842
|
+
walk_called(Goal, M, ArgPosEx, OTerm)
|
|
843
|
+
; AS == (^)
|
|
844
|
+
-> arg(I, Meta, MA),
|
|
845
|
+
remove_quantifier(MA, Goal, ArgPos, ArgPosEx, M, MG, OTerm),
|
|
846
|
+
walk_called(Goal, MG, ArgPosEx, OTerm)
|
|
847
|
+
; AS == (//)
|
|
848
|
+
-> arg(I, Meta, DCG),
|
|
849
|
+
walk_dcg_body(DCG, M, ArgPos, OTerm)
|
|
850
|
+
; true
|
|
851
|
+
),
|
|
852
|
+
succ(I, I2),
|
|
853
|
+
walk_meta_call(I2, Head, Meta, M, ArgPosTail, EPos, OTerm).
|
|
854
|
+
walk_meta_call(_, _, _, _, _, _, _).
|
|
855
|
+
|
|
856
|
+
remove_quantifier(Goal, _, TermPos, TermPos, M, M, OTerm) :-
|
|
857
|
+
var(Goal),
|
|
858
|
+
!,
|
|
859
|
+
undecided(Goal, TermPos, OTerm).
|
|
860
|
+
remove_quantifier(_^Goal0, Goal,
|
|
861
|
+
term_position(_,_,_,_,[_,GPos]),
|
|
862
|
+
TermPos, M0, M, OTerm) :-
|
|
863
|
+
!,
|
|
864
|
+
remove_quantifier(Goal0, Goal, GPos, TermPos, M0, M, OTerm).
|
|
865
|
+
remove_quantifier(M1:Goal0, Goal,
|
|
866
|
+
term_position(_,_,_,_,[_,GPos]),
|
|
867
|
+
TermPos, _, M, OTerm) :-
|
|
868
|
+
!,
|
|
869
|
+
remove_quantifier(Goal0, Goal, GPos, TermPos, M1, M, OTerm).
|
|
870
|
+
remove_quantifier(Goal, Goal, TermPos, TermPos, M, M, _).
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
%! walk_called_by(+Called:list, +Module, +Goal, +TermPos, +OTerm)
|
|
874
|
+
%
|
|
875
|
+
% Walk code explicitly mentioned to be called through the hook
|
|
876
|
+
% prolog:called_by/2.
|
|
877
|
+
|
|
878
|
+
walk_called_by([], _, _, _, _).
|
|
879
|
+
walk_called_by([H|T], M, Goal, TermPos, OTerm) :-
|
|
880
|
+
( H = G0+N
|
|
881
|
+
-> subterm_pos(G0, M, Goal, TermPos, G, GPos),
|
|
882
|
+
( extend(G, N, G2, GPos, GPosEx, OTerm)
|
|
883
|
+
-> walk_called(G2, M, GPosEx, OTerm)
|
|
884
|
+
; true
|
|
885
|
+
)
|
|
886
|
+
; subterm_pos(H, M, Goal, TermPos, G, GPos),
|
|
887
|
+
walk_called(G, M, GPos, OTerm)
|
|
888
|
+
),
|
|
889
|
+
walk_called_by(T, M, Goal, TermPos, OTerm).
|
|
890
|
+
|
|
891
|
+
subterm_pos(Sub, _, Term, TermPos, Sub, SubTermPos) :-
|
|
892
|
+
subterm_pos(Sub, Term, TermPos, SubTermPos),
|
|
893
|
+
!.
|
|
894
|
+
subterm_pos(Sub, M, Term, TermPos, G, SubTermPos) :-
|
|
895
|
+
nonvar(Sub),
|
|
896
|
+
Sub = M:H,
|
|
897
|
+
!,
|
|
898
|
+
subterm_pos(H, M, Term, TermPos, G, SubTermPos).
|
|
899
|
+
subterm_pos(Sub, _, _, _, Sub, _).
|
|
900
|
+
|
|
901
|
+
subterm_pos(Sub, Term, TermPos, SubTermPos) :-
|
|
902
|
+
subterm_pos(Sub, Term, same_term, TermPos, SubTermPos),
|
|
903
|
+
!.
|
|
904
|
+
subterm_pos(Sub, Term, TermPos, SubTermPos) :-
|
|
905
|
+
subterm_pos(Sub, Term, ==, TermPos, SubTermPos),
|
|
906
|
+
!.
|
|
907
|
+
subterm_pos(Sub, Term, TermPos, SubTermPos) :-
|
|
908
|
+
subterm_pos(Sub, Term, =@=, TermPos, SubTermPos),
|
|
909
|
+
!.
|
|
910
|
+
subterm_pos(Sub, Term, TermPos, SubTermPos) :-
|
|
911
|
+
subterm_pos(Sub, Term, subsumes_term, TermPos, SubTermPos),
|
|
912
|
+
!.
|
|
913
|
+
|
|
914
|
+
%! walk_dcg_body(+Body, +Module, +TermPos, +OTerm)
|
|
915
|
+
%
|
|
916
|
+
% Walk a DCG body that is meta-called.
|
|
917
|
+
|
|
918
|
+
walk_dcg_body(Var, _Module, TermPos, OTerm) :-
|
|
919
|
+
var(Var),
|
|
920
|
+
!,
|
|
921
|
+
undecided(Var, TermPos, OTerm).
|
|
922
|
+
walk_dcg_body([], _Module, _, _) :- !.
|
|
923
|
+
walk_dcg_body([_|_], _Module, _, _) :- !.
|
|
924
|
+
walk_dcg_body(String, _Module, _, _) :-
|
|
925
|
+
string(String),
|
|
926
|
+
!.
|
|
927
|
+
walk_dcg_body(!, _Module, _, _) :- !.
|
|
928
|
+
walk_dcg_body(M:G, _, term_position(_,_,_,_,[MPos,Pos]), OTerm) :-
|
|
929
|
+
!,
|
|
930
|
+
( nonvar(M)
|
|
931
|
+
-> walk_dcg_body(G, M, Pos, OTerm)
|
|
932
|
+
; undecided(M, MPos, OTerm)
|
|
933
|
+
).
|
|
934
|
+
walk_dcg_body((A,B), M, term_position(_,_,_,_,[PA,PB]), OTerm) :-
|
|
935
|
+
!,
|
|
936
|
+
walk_dcg_body(A, M, PA, OTerm),
|
|
937
|
+
walk_dcg_body(B, M, PB, OTerm).
|
|
938
|
+
walk_dcg_body((A->B), M, term_position(_,_,_,_,[PA,PB]), OTerm) :-
|
|
939
|
+
!,
|
|
940
|
+
walk_dcg_body(A, M, PA, OTerm),
|
|
941
|
+
walk_dcg_body(B, M, PB, OTerm).
|
|
942
|
+
walk_dcg_body((A*->B), M, term_position(_,_,_,_,[PA,PB]), OTerm) :-
|
|
943
|
+
!,
|
|
944
|
+
walk_dcg_body(A, M, PA, OTerm),
|
|
945
|
+
walk_dcg_body(B, M, PB, OTerm).
|
|
946
|
+
walk_dcg_body((A;B), M, term_position(_,_,_,_,[PA,PB]), OTerm) :-
|
|
947
|
+
!,
|
|
948
|
+
( walk_dcg_body(A, M, PA, OTerm)
|
|
949
|
+
; walk_dcg_body(B, M, PB, OTerm)
|
|
950
|
+
).
|
|
951
|
+
walk_dcg_body((A|B), M, term_position(_,_,_,_,[PA,PB]), OTerm) :-
|
|
952
|
+
!,
|
|
953
|
+
( walk_dcg_body(A, M, PA, OTerm)
|
|
954
|
+
; walk_dcg_body(B, M, PB, OTerm)
|
|
955
|
+
).
|
|
956
|
+
walk_dcg_body({G}, M, brace_term_position(_,_,PG), OTerm) :-
|
|
957
|
+
!,
|
|
958
|
+
walk_called(G, M, PG, OTerm).
|
|
959
|
+
walk_dcg_body(G, M, TermPos, OTerm) :-
|
|
960
|
+
extend(G, 2, G2, TermPos, TermPosEx, OTerm),
|
|
961
|
+
walk_called(G2, M, TermPosEx, OTerm).
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
%! subterm_pos(+SubTerm, +Term, :Cmp,
|
|
965
|
+
%! +TermPosition, -SubTermPos) is nondet.
|
|
966
|
+
%
|
|
967
|
+
% True when SubTerm is a sub term of Term, compared using Cmp,
|
|
968
|
+
% TermPosition describes the term layout of Term and SubTermPos
|
|
969
|
+
% describes the term layout of SubTerm. Cmp is typically one of
|
|
970
|
+
% =same_term=, =|==|=, =|=@=|= or =|subsumes_term|=
|
|
971
|
+
|
|
972
|
+
:- meta_predicate
|
|
973
|
+
subterm_pos(+, +, 2, +, -),
|
|
974
|
+
sublist_pos(+, +, +, +, 2, -).
|
|
975
|
+
:- public
|
|
976
|
+
subterm_pos/5. % used in library(check).
|
|
977
|
+
|
|
978
|
+
subterm_pos(_, _, _, Pos, _) :-
|
|
979
|
+
var(Pos), !, fail.
|
|
980
|
+
subterm_pos(Sub, Term, Cmp, Pos, Pos) :-
|
|
981
|
+
call(Cmp, Sub, Term),
|
|
982
|
+
!.
|
|
983
|
+
subterm_pos(Sub, Term, Cmp, term_position(_,_,_,_,ArgPosList), Pos) :-
|
|
984
|
+
is_list(ArgPosList),
|
|
985
|
+
compound(Term),
|
|
986
|
+
nth1(I, ArgPosList, ArgPos),
|
|
987
|
+
arg(I, Term, Arg),
|
|
988
|
+
subterm_pos(Sub, Arg, Cmp, ArgPos, Pos).
|
|
989
|
+
subterm_pos(Sub, Term, Cmp, list_position(_,_,ElemPosList,TailPos), Pos) :-
|
|
990
|
+
sublist_pos(ElemPosList, TailPos, Sub, Term, Cmp, Pos).
|
|
991
|
+
subterm_pos(Sub, {Arg}, Cmp, brace_term_position(_,_,ArgPos), Pos) :-
|
|
992
|
+
subterm_pos(Sub, Arg, Cmp, ArgPos, Pos).
|
|
993
|
+
|
|
994
|
+
sublist_pos([EP|TP], TailPos, Sub, [H|T], Cmp, Pos) :-
|
|
995
|
+
( subterm_pos(Sub, H, Cmp, EP, Pos)
|
|
996
|
+
; sublist_pos(TP, TailPos, Sub, T, Cmp, Pos)
|
|
997
|
+
).
|
|
998
|
+
sublist_pos([], TailPos, Sub, Tail, Cmp, Pos) :-
|
|
999
|
+
TailPos \== none,
|
|
1000
|
+
subterm_pos(Sub, Tail, Cmp, TailPos, Pos).
|
|
1001
|
+
|
|
1002
|
+
%! extend(+Goal, +ExtraArgs, +TermPosIn, -TermPosOut, +OTerm)
|
|
1003
|
+
%
|
|
1004
|
+
% @bug:
|
|
1005
|
+
|
|
1006
|
+
extend(Goal, 0, Goal, TermPos, TermPos, _) :- !.
|
|
1007
|
+
extend(Goal, _, _, TermPos, TermPos, OTerm) :-
|
|
1008
|
+
var(Goal),
|
|
1009
|
+
!,
|
|
1010
|
+
undecided(Goal, TermPos, OTerm).
|
|
1011
|
+
extend(M:Goal, N, M:GoalEx,
|
|
1012
|
+
term_position(F,T,FT,TT,[MPos,GPosIn]),
|
|
1013
|
+
term_position(F,T,FT,TT,[MPos,GPosOut]), OTerm) :-
|
|
1014
|
+
!,
|
|
1015
|
+
( var(M)
|
|
1016
|
+
-> undecided(N, MPos, OTerm)
|
|
1017
|
+
; true
|
|
1018
|
+
),
|
|
1019
|
+
extend(Goal, N, GoalEx, GPosIn, GPosOut, OTerm).
|
|
1020
|
+
extend(Goal, N, GoalEx, TermPosIn, TermPosOut, _) :-
|
|
1021
|
+
callable(Goal),
|
|
1022
|
+
!,
|
|
1023
|
+
Goal =.. List,
|
|
1024
|
+
length(Extra, N),
|
|
1025
|
+
extend_term_pos(TermPosIn, N, TermPosOut),
|
|
1026
|
+
append(List, Extra, ListEx),
|
|
1027
|
+
GoalEx =.. ListEx.
|
|
1028
|
+
extend(Closure, N, M:GoalEx, TermPosIn, TermPosOut, OTerm) :-
|
|
1029
|
+
blob(Closure, closure), % call(Closure, A1, ...)
|
|
1030
|
+
!,
|
|
1031
|
+
'$closure_predicate'(Closure, M:Name/Arity),
|
|
1032
|
+
length(Extra, N),
|
|
1033
|
+
extend_term_pos(TermPosIn, N, TermPosOut),
|
|
1034
|
+
GoalEx =.. [Name|Extra],
|
|
1035
|
+
( N =:= Arity
|
|
1036
|
+
-> true
|
|
1037
|
+
; print_reference(Closure, TermPosIn, closure_arity_mismatch, OTerm)
|
|
1038
|
+
).
|
|
1039
|
+
extend(Goal, _, _, TermPos, _, OTerm) :-
|
|
1040
|
+
print_reference(Goal, TermPos, not_callable, OTerm).
|
|
1041
|
+
|
|
1042
|
+
extend_term_pos(Var, _, _) :-
|
|
1043
|
+
var(Var),
|
|
1044
|
+
!.
|
|
1045
|
+
extend_term_pos(term_position(F,T,FT,TT,ArgPosIn),
|
|
1046
|
+
N,
|
|
1047
|
+
term_position(F,T,FT,TT,ArgPosOut)) :-
|
|
1048
|
+
!,
|
|
1049
|
+
length(Extra, N),
|
|
1050
|
+
maplist(=(0-0), Extra),
|
|
1051
|
+
append(ArgPosIn, Extra, ArgPosOut).
|
|
1052
|
+
extend_term_pos(F-T, N, term_position(F,T,F,T,Extra)) :-
|
|
1053
|
+
length(Extra, N),
|
|
1054
|
+
maplist(=(0-0), Extra).
|
|
1055
|
+
|
|
1056
|
+
|
|
1057
|
+
%! variants(+SortedList, -Variants) is det.
|
|
1058
|
+
|
|
1059
|
+
variants([], []).
|
|
1060
|
+
variants([H|T], List) :-
|
|
1061
|
+
variants(T, H, List).
|
|
1062
|
+
|
|
1063
|
+
variants([], H, [H]).
|
|
1064
|
+
variants([H|T], V, List) :-
|
|
1065
|
+
( H =@= V
|
|
1066
|
+
-> variants(T, V, List)
|
|
1067
|
+
; List = [V|List2],
|
|
1068
|
+
variants(T, H, List2)
|
|
1069
|
+
).
|
|
1070
|
+
|
|
1071
|
+
%! predicate_in_module(+Module, ?PI) is nondet.
|
|
1072
|
+
%
|
|
1073
|
+
% True if PI is a predicate locally defined in Module.
|
|
1074
|
+
|
|
1075
|
+
predicate_in_module(Module, PI) :-
|
|
1076
|
+
current_predicate(Module:PI),
|
|
1077
|
+
PI = Name/Arity,
|
|
1078
|
+
\+ hidden_predicate(Name, Arity),
|
|
1079
|
+
functor(Head, Name, Arity),
|
|
1080
|
+
\+ predicate_property(Module:Head, imported_from(_)).
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
hidden_predicate(Name, _) :-
|
|
1084
|
+
atom(Name), % []/N is not hidden
|
|
1085
|
+
sub_atom(Name, 0, _, _, '$wrap$').
|
|
1086
|
+
|
|
1087
|
+
|
|
1088
|
+
/*******************************
|
|
1089
|
+
* ENUMERATE CLAUSES *
|
|
1090
|
+
*******************************/
|
|
1091
|
+
|
|
1092
|
+
%! prolog_program_clause(-ClauseRef, +Options) is nondet.
|
|
1093
|
+
%
|
|
1094
|
+
% True when ClauseRef is a reference for clause in the program.
|
|
1095
|
+
% Options is a subset of the options processed by
|
|
1096
|
+
% prolog_walk_code/1. The logic for deciding on which clauses to
|
|
1097
|
+
% enumerate is shared with prolog_walk_code/1.
|
|
1098
|
+
%
|
|
1099
|
+
% * module(?Module)
|
|
1100
|
+
% * module_class(+list(Classes))
|
|
1101
|
+
|
|
1102
|
+
prolog_program_clause(ClauseRef, Options) :-
|
|
1103
|
+
make_walk_option(Options, OTerm, _),
|
|
1104
|
+
setup_call_cleanup(
|
|
1105
|
+
true,
|
|
1106
|
+
( current_module(Module),
|
|
1107
|
+
scan_module(Module, OTerm),
|
|
1108
|
+
module_clause(Module, ClauseRef, OTerm)
|
|
1109
|
+
; retract(multifile_predicate(Name, Arity, MM)),
|
|
1110
|
+
multifile_clause(ClauseRef, MM:Name/Arity, OTerm)
|
|
1111
|
+
; initialization_clause(ClauseRef, OTerm)
|
|
1112
|
+
),
|
|
1113
|
+
retractall(multifile_predicate(_,_,_))).
|
|
1114
|
+
|
|
1115
|
+
|
|
1116
|
+
module_clause(Module, ClauseRef, _OTerm) :-
|
|
1117
|
+
predicate_in_module(Module, Name/Arity),
|
|
1118
|
+
\+ multifile_predicate(Name, Arity, Module),
|
|
1119
|
+
functor(Head, Name, Arity),
|
|
1120
|
+
( predicate_property(Module:Head, multifile)
|
|
1121
|
+
-> assertz(multifile_predicate(Name, Arity, Module)),
|
|
1122
|
+
fail
|
|
1123
|
+
; predicate_property(Module:Head, Property),
|
|
1124
|
+
no_enum_property(Property)
|
|
1125
|
+
-> fail
|
|
1126
|
+
; catch(nth_clause(Module:Head, _, ClauseRef), _, fail)
|
|
1127
|
+
).
|
|
1128
|
+
|
|
1129
|
+
no_enum_property(foreign).
|
|
1130
|
+
|
|
1131
|
+
multifile_clause(ClauseRef, M:Name/Arity, OTerm) :-
|
|
1132
|
+
functor(Head, Name, Arity),
|
|
1133
|
+
catch(clauseref_not_from_development(M:Head, ClauseRef, OTerm),
|
|
1134
|
+
_, fail).
|
|
1135
|
+
|
|
1136
|
+
clauseref_not_from_development(Module:Head, Ref, OTerm) :-
|
|
1137
|
+
nth_clause(Module:Head, _N, Ref),
|
|
1138
|
+
\+ ( clause_property(Ref, file(File)),
|
|
1139
|
+
module_property(LoadModule, file(File)),
|
|
1140
|
+
\+ scan_module(LoadModule, OTerm)
|
|
1141
|
+
).
|
|
1142
|
+
|
|
1143
|
+
initialization_clause(ClauseRef, OTerm) :-
|
|
1144
|
+
catch(clause(system:'$init_goal'(_File, M:_Goal, SourceLocation),
|
|
1145
|
+
true, ClauseRef),
|
|
1146
|
+
_, fail),
|
|
1147
|
+
walk_option_initialization(OTerm, SourceLocation),
|
|
1148
|
+
scan_module(M, OTerm).
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
%! translate_location(+Loc, -Dict) is det.
|
|
1152
|
+
|
|
1153
|
+
translate_location(clause_term_position(ClauseRef, TermPos), Dict),
|
|
1154
|
+
clause_property(ClauseRef, file(File)) =>
|
|
1155
|
+
arg(1, TermPos, CharCount),
|
|
1156
|
+
filepos_line(File, CharCount, Line, LinePos),
|
|
1157
|
+
Dict = _{ clause: ClauseRef,
|
|
1158
|
+
file: File,
|
|
1159
|
+
character_count: CharCount,
|
|
1160
|
+
line_count: Line,
|
|
1161
|
+
line_position: LinePos
|
|
1162
|
+
}.
|
|
1163
|
+
translate_location(clause(ClauseRef), Dict),
|
|
1164
|
+
clause_property(ClauseRef, file(File)),
|
|
1165
|
+
clause_property(ClauseRef, line_count(Line)) =>
|
|
1166
|
+
Dict = _{ clause: ClauseRef,
|
|
1167
|
+
file: File,
|
|
1168
|
+
line_count: Line
|
|
1169
|
+
}.
|
|
1170
|
+
translate_location(clause(ClauseRef), Dict) =>
|
|
1171
|
+
Dict = _{ clause: ClauseRef
|
|
1172
|
+
}.
|
|
1173
|
+
translate_location(file_term_position(Path, TermPos), Dict) =>
|
|
1174
|
+
arg(1, TermPos, CharCount),
|
|
1175
|
+
filepos_line(Path, CharCount, Line, LinePos),
|
|
1176
|
+
Dict = _{ file: Path,
|
|
1177
|
+
character_count: CharCount,
|
|
1178
|
+
line_count: Line,
|
|
1179
|
+
line_position: LinePos
|
|
1180
|
+
}.
|
|
1181
|
+
translate_location(file(Path, Line, -1, _), Dict) =>
|
|
1182
|
+
Dict = _{ file: Path,
|
|
1183
|
+
line_count: Line
|
|
1184
|
+
}.
|
|
1185
|
+
translate_location(Var, Dict), var(Var) =>
|
|
1186
|
+
Dict = _{}.
|
|
1187
|
+
|
|
1188
|
+
/*******************************
|
|
1189
|
+
* MESSAGES *
|
|
1190
|
+
*******************************/
|
|
1191
|
+
|
|
1192
|
+
:- multifile
|
|
1193
|
+
prolog:message//1,
|
|
1194
|
+
prolog:message_location//1.
|
|
1195
|
+
|
|
1196
|
+
prolog:message(trace_call_to(PI, Context)) -->
|
|
1197
|
+
[ 'Call to ~q at '-[PI] ],
|
|
1198
|
+
'$messages':swi_location(Context).
|
|
1199
|
+
|
|
1200
|
+
prolog:message_location(clause_term_position(ClauseRef, TermPos)) -->
|
|
1201
|
+
{ clause_property(ClauseRef, file(File)) },
|
|
1202
|
+
message_location_file_term_position(File, TermPos).
|
|
1203
|
+
prolog:message_location(clause(ClauseRef)) -->
|
|
1204
|
+
{ clause_property(ClauseRef, file(File)),
|
|
1205
|
+
clause_property(ClauseRef, line_count(Line))
|
|
1206
|
+
},
|
|
1207
|
+
!,
|
|
1208
|
+
[ url(File:Line), ': ' ].
|
|
1209
|
+
prolog:message_location(clause(ClauseRef)) -->
|
|
1210
|
+
{ clause_name(ClauseRef, Name) },
|
|
1211
|
+
[ '~w: '-[Name] ].
|
|
1212
|
+
prolog:message_location(file_term_position(Path, TermPos)) -->
|
|
1213
|
+
message_location_file_term_position(Path, TermPos).
|
|
1214
|
+
prolog:message(codewalk(reiterate(New, Iteration, CPU))) -->
|
|
1215
|
+
[ 'Found new meta-predicates in iteration ~w (~3f sec)'-
|
|
1216
|
+
[Iteration, CPU], nl ],
|
|
1217
|
+
meta_decls(New),
|
|
1218
|
+
[ 'Restarting analysis ...'-[], nl ].
|
|
1219
|
+
|
|
1220
|
+
meta_decls([]) --> [].
|
|
1221
|
+
meta_decls([H|T]) -->
|
|
1222
|
+
[ ':- meta_predicate ~q.'-[H], nl ],
|
|
1223
|
+
meta_decls(T).
|
|
1224
|
+
|
|
1225
|
+
message_location_file_term_position(File, TermPos) -->
|
|
1226
|
+
{ arg(1, TermPos, CharCount),
|
|
1227
|
+
filepos_line(File, CharCount, Line, LinePos)
|
|
1228
|
+
},
|
|
1229
|
+
[ url(File:Line:LinePos), ': ' ].
|
|
1230
|
+
|
|
1231
|
+
%! filepos_line(+File, +CharPos, -Line, -Column) is det.
|
|
1232
|
+
%
|
|
1233
|
+
% @arg CharPos is 0-based character offset in the file.
|
|
1234
|
+
% @arg Column is the current column, counting tabs as 8 spaces.
|
|
1235
|
+
|
|
1236
|
+
filepos_line(File, CharPos, Line, LinePos) :-
|
|
1237
|
+
setup_call_cleanup(
|
|
1238
|
+
( open(File, read, In),
|
|
1239
|
+
open_null_stream(Out)
|
|
1240
|
+
),
|
|
1241
|
+
( copy_stream_data(In, Out, CharPos),
|
|
1242
|
+
stream_property(In, position(Pos)),
|
|
1243
|
+
stream_position_data(line_count, Pos, Line),
|
|
1244
|
+
stream_position_data(line_position, Pos, LinePos)
|
|
1245
|
+
),
|
|
1246
|
+
( close(Out),
|
|
1247
|
+
close(In)
|
|
1248
|
+
)).
|