From e05c34d1ee8d5e1f8490ceaa376d1e5e982267a5 Mon Sep 17 00:00:00 2001 From: notoria Date: Wed, 1 Jul 2020 10:06:20 +0200 Subject: [PATCH 1/4] Revert "build.rs recursively delves into directories during library bake stage, correct misnamed file at machine/mod.rs:455 (#617)" This reverts commit c1b577f2c7a148b13c1692ab8ac741aa57b0ac43. --- Cargo.lock | 448 +++------------------------------------------ build.rs | 32 +--- src/machine/mod.rs | 2 +- 3 files changed, 38 insertions(+), 444 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 41c90cbd..086a638e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,12 +27,6 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" -[[package]] -name = "autocfg" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" - [[package]] name = "autocfg" version = "1.0.0" @@ -51,21 +45,6 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" -[[package]] -name = "bit-set" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" -dependencies = [ - "bit-vec", -] - -[[package]] -name = "bit-vec" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0dc55f2d8a1a85650ac47858bb001b4c0dd73d79e3c455a842925e68d29cd3" - [[package]] name = "bitflags" version = "1.2.1" @@ -204,7 +183,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ - "autocfg 1.0.0", + "autocfg", "cfg-if", "lazy_static", ] @@ -302,12 +281,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -324,16 +297,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -[[package]] -name = "futf" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c9c1ce3fa9336301af935ab852c437817d14cd33690446569392e65170aac3b" -dependencies = [ - "mac", - "new_debug_unreachable", -] - [[package]] name = "generic-array" version = "0.12.3" @@ -371,9 +334,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34a97a52fdee1870a34fa6e4b77570cba531b27d1838874fef4429a791a3d657" dependencies = [ "proc-macro-hack", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.18", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -397,27 +360,13 @@ dependencies = [ "winapi 0.3.8", ] -[[package]] -name = "html5ever" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce65ac8028cf5a287a7dbf6c4e0a6cf2dcf022ed5b167a81bae66ebf599a8b7" -dependencies = [ - "log", - "mac", - "markup5ever", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - [[package]] name = "indexmap" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" dependencies = [ - "autocfg 1.0.0", + "autocfg", ] [[package]] @@ -429,12 +378,6 @@ dependencies = [ "libc", ] -[[package]] -name = "itoa" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" - [[package]] name = "js-sys" version = "0.3.39" @@ -514,29 +457,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "mac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" - -[[package]] -name = "markup5ever" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1af46a727284117e09780d05038b1ce6fc9c76cc6df183c3dae5a8955a25e21" -dependencies = [ - "log", - "phf", - "phf_codegen", - "serde", - "serde_derive", - "serde_json", - "string_cache", - "string_cache_codegen", - "tendril", -] - [[package]] name = "match_cfg" version = "0.1.0" @@ -615,12 +535,6 @@ dependencies = [ "winapi 0.3.8", ] -[[package]] -name = "new_debug_unreachable" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" - [[package]] name = "nix" version = "0.15.0" @@ -659,7 +573,7 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" dependencies = [ - "autocfg 1.0.0", + "autocfg", "num-integer", "num-traits 0.2.11", ] @@ -670,7 +584,7 @@ version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" dependencies = [ - "autocfg 1.0.0", + "autocfg", "num-traits 0.2.11", ] @@ -680,7 +594,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" dependencies = [ - "autocfg 1.0.0", + "autocfg", "num-bigint", "num-integer", "num-traits 0.2.11", @@ -714,7 +628,7 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" dependencies = [ - "autocfg 1.0.0", + "autocfg", ] [[package]] @@ -764,7 +678,7 @@ version = "0.9.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de" dependencies = [ - "autocfg 1.0.0", + "autocfg", "cc", "libc", "openssl-src", @@ -806,44 +720,6 @@ dependencies = [ "winapi 0.3.8", ] -[[package]] -name = "phf" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18" -dependencies = [ - "phf_shared", -] - -[[package]] -name = "phf_codegen" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" -dependencies = [ - "phf_generator", - "phf_shared", -] - -[[package]] -name = "phf_generator" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" -dependencies = [ - "phf_shared", - "rand 0.6.5", -] - -[[package]] -name = "phf_shared" -version = "0.7.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" -dependencies = [ - "siphasher", -] - [[package]] name = "pkg-config" version = "0.3.17" @@ -856,34 +732,19 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" -[[package]] -name = "precomputed-hash" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" - [[package]] name = "proc-macro-hack" version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d659fe7c6d27f25e9d80a1a094c223f5246f6a6596453e09d7229bf42750b63" -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - [[package]] name = "proc-macro2" version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" dependencies = [ - "unicode-xid 0.2.0", + "unicode-xid", ] [[package]] @@ -899,41 +760,13 @@ dependencies = [ "unicode_reader", ] -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - [[package]] name = "quote" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" dependencies = [ - "proc-macro2 1.0.10", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.7", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi 0.3.8", + "proc-macro2", ] [[package]] @@ -944,19 +777,9 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ "getrandom", "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc 0.2.0", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.3.1", + "rand_chacha", + "rand_core", + "rand_hc", ] [[package]] @@ -966,24 +789,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core 0.5.1", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.5.1" @@ -993,84 +801,13 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rand_hc" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.8", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.8", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", + "rand_core", ] [[package]] @@ -1131,15 +868,6 @@ dependencies = [ "opaque-debug", ] -[[package]] -name = "roxmltree" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5001f134077069d87f77c8b9452b690df2445f7a43f1c7ca4a1af8dd505789d" -dependencies = [ - "xmlparser", -] - [[package]] name = "rug" version = "1.8.0" @@ -1238,10 +966,8 @@ dependencies = [ "ref_thread_local", "ring", "ripemd160", - "roxmltree", "rug", "rustyline", - "select", "sha3", "unicode_reader", ] @@ -1269,16 +995,6 @@ dependencies = [ "libc", ] -[[package]] -name = "select" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac645958c62108d11f90f8d34e4dc2799c838fc995ed4c2075867a2a8d5be76b" -dependencies = [ - "bit-set", - "html5ever", -] - [[package]] name = "semver" version = "0.9.0" @@ -1294,34 +1010,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -[[package]] -name = "serde" -version = "1.0.114" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3" - -[[package]] -name = "serde_derive" -version = "1.0.113" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93c5eaa17d0954cb481cdcfffe9d84fcfa7a1a9f2349271e678677be4c26ae31" -dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.18", -] - -[[package]] -name = "serde_json" -version = "1.0.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec2c5d7e739bc07a3e73381a39d61fdb5f671c60c1df26a130690665803d8226" -dependencies = [ - "itoa", - "ryu", - "serde", -] - [[package]] name = "sha3" version = "0.8.2" @@ -1356,12 +1044,6 @@ dependencies = [ "libc", ] -[[package]] -name = "siphasher" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" - [[package]] name = "slab" version = "0.4.2" @@ -1395,66 +1077,21 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f3eb36b47e512f8f1c9e3d10c2c1965bc992bd9cdb024fa581e2194501c83d3" -[[package]] -name = "string_cache" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89c058a82f9fd69b1becf8c274f412281038877c553182f1d02eb027045a2d67" -dependencies = [ - "lazy_static", - "new_debug_unreachable", - "phf_shared", - "precomputed-hash", - "serde", - "string_cache_codegen", - "string_cache_shared", -] - -[[package]] -name = "string_cache_codegen" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f45ed1b65bf9a4bf2f7b7dc59212d1926e9eaf00fa998988e420fd124467c6" -dependencies = [ - "phf_generator", - "phf_shared", - "proc-macro2 1.0.10", - "quote 1.0.3", - "string_cache_shared", -] - -[[package]] -name = "string_cache_shared" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc" - [[package]] name = "subtle" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", -] - [[package]] name = "syn" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "410a7488c0a728c7ceb4ad59b9567eb4053d02e8cc7f5c0e0eeeb39518369213" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "unicode-xid 0.2.0", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] @@ -1465,23 +1102,12 @@ checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" dependencies = [ "cfg-if", "libc", - "rand 0.7.3", + "rand", "redox_syscall", "remove_dir_all", "winapi 0.3.8", ] -[[package]] -name = "tendril" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707feda9f2582d5d680d733e38755547a3e8fb471e7ba11452ecfd9ce93a5d3b" -dependencies = [ - "futf", - "mac", - "utf-8", -] - [[package]] name = "time" version = "0.1.43" @@ -1510,12 +1136,6 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - [[package]] name = "unicode-xid" version = "0.2.0" @@ -1547,12 +1167,6 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" -[[package]] -name = "utf-8" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" - [[package]] name = "utf8parse" version = "0.2.0" @@ -1596,9 +1210,9 @@ dependencies = [ "bumpalo", "lazy_static", "log", - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.18", + "proc-macro2", + "quote", + "syn", "wasm-bindgen-shared", ] @@ -1608,7 +1222,7 @@ version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cd85aa2c579e8892442954685f0d801f9129de24fa2136b2c6a539c76b65776" dependencies = [ - "quote 1.0.3", + "quote", "wasm-bindgen-macro-support", ] @@ -1618,9 +1232,9 @@ version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "syn 1.0.18", + "proc-macro2", + "quote", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1684,9 +1298,3 @@ dependencies = [ "winapi 0.2.8", "winapi-build", ] - -[[package]] -name = "xmlparser" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52613e655f6f11f63c0fe7d1c3b5ef69e44d96df9b65dab296b441ed0e1125f5" diff --git a/build.rs b/build.rs index 4cc5930b..b8a5d224 100644 --- a/build.rs +++ b/build.rs @@ -3,7 +3,7 @@ extern crate indexmap; use crate::indexmap::IndexSet; use std::env; -use std::fs::{File, copy, create_dir_all, read_dir}; +use std::fs::{File, copy, read_dir}; use std::io::Write; use std::path::Path; @@ -15,44 +15,30 @@ fn main() let mut libraries = File::create(&dest_path).unwrap(); let mut library_index = IndexSet::new(); - let mut paths: Vec<_> = read_dir("./src/lib").unwrap() - .map(|e| e.unwrap().path()).collect(); + let paths = read_dir("./src/lib").unwrap(); - while let Some(item) = paths.pop() { - if item.is_file() { - let file_name = item.strip_prefix(".").unwrap(); + for item in paths { + let item = item.unwrap().path(); + if let Some(file_name) = item.file_name() { if let Some(ext) = item.extension() { if ext == "pl" { let file_stem = item.file_stem().unwrap(); let file_str = file_stem.to_string_lossy().to_uppercase(); let dest = Path::new(&out_dir).join(file_name); - let dir_name = dest.parent().unwrap(); - - if !dir_name.exists() { - create_dir_all(dir_name).unwrap(); - } match copy(&item, dest) { - Ok(_) => { - } - Err(e) => { - panic!("die: {:?}", e) - } + Ok(_) => {}, + Err(e) => panic!("die: {:?}", e) }; - let include_line = format!("static {}: &str = include_str!({:?});\n", - file_str, file_name); //file_stem.to_string_lossy()); + let include_line = format!("static {}: &str = include_str!(\"{}.pl\");\n", + file_str, file_stem.to_string_lossy()); libraries.write_all(include_line.as_bytes()).unwrap(); library_index.insert(file_stem.to_string_lossy().to_string()); } } - } else if item.is_dir() { - for entry in read_dir(item).unwrap() { - let path = entry.unwrap().path(); - paths.push(path); - } } } diff --git a/src/machine/mod.rs b/src/machine/mod.rs index 6b8496ca..ea454547 100644 --- a/src/machine/mod.rs +++ b/src/machine/mod.rs @@ -452,7 +452,7 @@ impl Machine { Stream::from(CHARSIO), true, ListingSource::from_file_and_path( - clause_name!("charsio"), + clause_name!("si"), lib_path.clone(), ) ); From 1eb42654e07a0d9c83b505fc092a2721a698f39a Mon Sep 17 00:00:00 2001 From: notoria Date: Wed, 1 Jul 2020 10:07:26 +0200 Subject: [PATCH 2/4] Revert "allow paths in use_module(library(..)) (#604)" This reverts commit cfd15f4e027b4df216e723bbd35facac28a09a1c. --- src/machine/compile.rs | 54 ++++++++++++-------------------- src/machine/mod.rs | 68 +++++++++++++++-------------------------- src/machine/toplevel.rs | 43 ++++++++------------------ src/toplevel.pl | 10 ++---- 4 files changed, 59 insertions(+), 116 deletions(-) diff --git a/src/machine/compile.rs b/src/machine/compile.rs index 32ed3ee3..517c4a94 100644 --- a/src/machine/compile.rs +++ b/src/machine/compile.rs @@ -600,44 +600,30 @@ fn load_library( name: ClauseName, suppress_warnings: bool, ) -> Result { - let mut lib_path = current_dir(); + match LIBRARIES.borrow().get(name.as_str()) { + Some(code) => { + let mut lib_path = current_dir(); - lib_path.pop(); - lib_path.push("lib"); + lib_path.pop(); + lib_path.push("lib"); - let (stream, listing_src) = - match LIBRARIES.borrow().get(name.as_str()) { - Some(code) => { - let listing_src = ListingSource::from_file_and_path(name, lib_path); - (Stream::from(*code), listing_src) - } - None => { - // assume that name is a path. - lib_path.push(name.as_str()); - lib_path.set_extension("pl"); + let listing_src = ListingSource::from_file_and_path(name, lib_path); - let file = - match File::open(&lib_path) { - Ok(file) => { - file - } - Err(_) => { - let err = ExistenceError::ModuleSource(ModuleSource::Library(name)); - return Err(SessionError::ExistenceError(err)); - } - }; + load_module( + wam, + Stream::from(*code), + suppress_warnings, + &listing_src, + ) + } + None => { + let err = ExistenceError::ModuleSource(ModuleSource::Library( + name.clone() + )); - let listing_src = ListingSource::from_file_and_path(name.clone(), lib_path); - (Stream::from_file_as_input(name, file), listing_src) - } - }; - - load_module( - wam, - stream, - suppress_warnings, - &listing_src, - ) + Err(SessionError::ExistenceError(err)) + } + } } impl ListingCompiler { diff --git a/src/machine/mod.rs b/src/machine/mod.rs index ea454547..cf44a693 100644 --- a/src/machine/mod.rs +++ b/src/machine/mod.rs @@ -666,27 +666,21 @@ impl Machine { Ok(exports) } - fn use_module(&mut self, to_src: impl Fn(ClauseName) -> ModuleSource) + fn use_module(&mut self, to_src: ToSource) + where ToSource: Fn(ClauseName) -> ModuleSource { // the term expander will overwrite the cached query, so save it here. let cached_query = mem::replace(&mut self.code_repo.cached_query, vec![]); let module_spec = self.machine_st[temp_v!(1)].clone(); - let (name, is_path) = { + let name = { let addr = self.machine_st.store(self.machine_st.deref(module_spec)); match self.machine_st.heap.index_addr(&addr).as_ref() { HeapCellValue::Atom(name, _) => - (name.clone(), name.as_str().contains('/')), + name.clone(), HeapCellValue::Addr(Addr::Char(c)) => - (clause_name!(c.to_string(), self.indices.atom_tbl), false), - HeapCellValue::Addr(addr @ Addr::PStrLocation(..)) => { - let mut heap_pstr_iter = self.machine_st.heap_pstr_iter(*addr); - let filename = heap_pstr_iter.to_string(); - let is_path = filename.contains('/'); - - (clause_name!(filename, self.indices.atom_tbl), is_path) - } + clause_name!(c.to_string(), self.indices.atom_tbl), _ => unreachable!(), } @@ -694,18 +688,14 @@ impl Machine { let load_result = match to_src(name) { ModuleSource::Library(name) => - if is_path { - load_library(self, name, false) - } else { - if let Some(module) = self.indices.take_module(name.clone()) { - self.indices.remove_module(clause_name!("user"), &module); - self.indices.modules.insert(name.clone(), module); + if let Some(module) = self.indices.take_module(name.clone()) { + self.indices.remove_module(clause_name!("user"), &module); + self.indices.modules.insert(name.clone(), module); - Ok(name) - } else { - load_library(self, name, false) - } - } + Ok(name) + } else { + load_library(self, name, false) + }, ModuleSource::File(name) => load_module_from_file(self, PathBuf::from(name.as_str()), false) }; @@ -727,27 +717,21 @@ impl Machine { } } - fn use_qualified_module(&mut self, to_src: impl Fn(ClauseName) -> ModuleSource) + fn use_qualified_module(&mut self, to_src: ToSource) + where ToSource: Fn(ClauseName) -> ModuleSource { // the term expander will overwrite the cached query, so save it here. let cached_query = mem::replace(&mut self.code_repo.cached_query, vec![]); let module_spec = self.machine_st[temp_v!(1)].clone(); - let (name, is_path) = { + let name = { let addr = self.machine_st.store(self.machine_st.deref(module_spec)); match self.machine_st.heap.index_addr(&addr).as_ref() { HeapCellValue::Atom(name, _) => - (name.clone(), name.as_str().contains('/')), + name.clone(), HeapCellValue::Addr(Addr::Char(c)) => - (clause_name!(c.to_string(), self.indices.atom_tbl), false), - HeapCellValue::Addr(addr @ Addr::PStrLocation(..)) => { - let mut heap_pstr_iter = self.machine_st.heap_pstr_iter(*addr); - let filename = heap_pstr_iter.to_string(); - let is_path = filename.contains('/'); - - (clause_name!(filename, self.indices.atom_tbl), is_path) - } + clause_name!(c.to_string(), self.indices.atom_tbl), _ => unreachable!(), } @@ -763,18 +747,14 @@ impl Machine { let load_result = match to_src(name) { ModuleSource::Library(name) => - if is_path { - load_library(self, name, false) - } else { - if let Some(module) = self.indices.take_module(name.clone()) { - self.indices.remove_module(clause_name!("user"), &module); - self.indices.modules.insert(name.clone(), module); + if let Some(module) = self.indices.take_module(name.clone()) { + self.indices.remove_module(clause_name!("user"), &module); + self.indices.modules.insert(name.clone(), module); - Ok(name) - } else { - load_library(self, name, false) - } - }, + Ok(name) + } else { + load_library(self, name, false) + }, ModuleSource::File(name) => load_module_from_file(self, PathBuf::from(name.as_str()), false) }; diff --git a/src/machine/toplevel.rs b/src/machine/toplevel.rs index 2e553cea..9937fffe 100644 --- a/src/machine/toplevel.rs +++ b/src/machine/toplevel.rs @@ -340,39 +340,16 @@ fn setup_module_decl( } } -fn read_library_path(term: Term, atom_tbl: TabledData) -> Option { - match term { - Term::Constant(_, Constant::Atom(atom, _)) => { - Some(atom.defrock_brackets()) - } - _ => { - let mut atoms = vec![]; - - for term in unfold_by_str(term, "/") { - match term { - Term::Constant(_, Constant::Atom(atom, _)) => { - atoms.push(atom.as_str().to_owned()); - } - _ => { - return None; - } - } - } - - Some(clause_name!(atoms.join("/"), atom_tbl)) - } - } -} - -fn setup_use_module_decl( - mut terms: Vec>, - atom_tbl: TabledData, -) -> Result { +fn setup_use_module_decl(mut terms: Vec>) -> Result { match *terms.pop().unwrap() { Term::Clause(_, ref name, ref mut terms, None) if name.as_str() == "library" && terms.len() == 1 => { - read_library_path(*terms.pop().unwrap(), atom_tbl) + terms + .pop() + .unwrap() + .to_constant() + .and_then(|c| c.to_atom()) .map(|c| ModuleSource::Library(c)) .ok_or(ParserError::InvalidUseModuleDecl) } @@ -419,7 +396,11 @@ fn setup_qualified_import( Term::Clause(_, ref name, ref mut terms, None) if name.as_str() == "library" && terms.len() == 1 => { - read_library_path(*terms.pop().unwrap(), atom_tbl.clone()) + terms + .pop() + .unwrap() + .to_constant() + .and_then(|c| c.to_atom()) .map(|c| ModuleSource::Library(c)) .ok_or(ParserError::InvalidUseModuleDecl) } @@ -704,7 +685,7 @@ fn setup_declaration<'a, 'b, 'c>( } } ("use_module", 1) => { - Ok(Declaration::UseModule(setup_use_module_decl(terms, indices.atom_tbl())?)) + Ok(Declaration::UseModule(setup_use_module_decl(terms)?)) } ("use_module", 2) => { let (name, exports) = setup_qualified_import(terms, indices.atom_tbl())?; diff --git a/src/toplevel.pl b/src/toplevel.pl index 23e7decd..f07b30d4 100644 --- a/src/toplevel.pl +++ b/src/toplevel.pl @@ -387,11 +387,8 @@ consult(Item) :- use_module(Module) :- ( nonvar(Module) -> - ( Module = library(Filename) -> - write_term_to_chars(Filename, [], FilenameString), - '$use_module'(FilenameString) - ; atom(Module) -> - '$use_module_from_file'(Module) + ( Module = library(Filename) -> '$use_module'(Filename) + ; atom(Module) -> '$use_module_from_file'(Module) ; throw(error(invalid_module_specifier, use_module/1)) ) ; throw(error(instantiation_error, use_module/1)) @@ -402,8 +399,7 @@ use_module(Module, QualifiedExports) :- ( list_si(QualifiedExports) -> maplist('$module_export'(use_module/2), QualifiedExports) -> ( Module = library(Filename) -> - write_term_to_chars(Filename, [], FilenameString), - '$use_qualified_module'(FilenameString, QualifiedExports) + '$use_qualified_module'(Filename, QualifiedExports) ; atom(Module) -> '$use_qualified_module_from_file'(Module, QualifiedExports) ; throw(error(invalid_module_specifier, use_module/2)) From 83268f5ff6ede831cd7bf7d897d1701c1a7cc642 Mon Sep 17 00:00:00 2001 From: notoria Date: Wed, 1 Jul 2020 10:22:17 +0200 Subject: [PATCH 3/4] Allowing paths in use_module(library(..)) (#604) In a module, the path is restricted in being an atom. --- Cargo.lock | 448 ++++++++++++++++++++++-- build.rs | 89 +++-- src/lib/tabling.pl | 12 +- src/lib/tabling/batched_worklist.pl | 4 +- src/lib/tabling/table_data_structure.pl | 6 +- src/lib/tabling/table_link_manager.pl | 2 +- src/machine/compile.rs | 7 +- src/machine/mod.rs | 127 +++---- src/toplevel.pl | 10 +- 9 files changed, 528 insertions(+), 177 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 086a638e..41c90cbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,6 +27,12 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" +[[package]] +name = "autocfg" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" + [[package]] name = "autocfg" version = "1.0.0" @@ -45,6 +51,21 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" +[[package]] +name = "bit-set" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0dc55f2d8a1a85650ac47858bb001b4c0dd73d79e3c455a842925e68d29cd3" + [[package]] name = "bitflags" version = "1.2.1" @@ -183,7 +204,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ - "autocfg", + "autocfg 1.0.0", "cfg-if", "lazy_static", ] @@ -281,6 +302,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -297,6 +324,16 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +[[package]] +name = "futf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c9c1ce3fa9336301af935ab852c437817d14cd33690446569392e65170aac3b" +dependencies = [ + "mac", + "new_debug_unreachable", +] + [[package]] name = "generic-array" version = "0.12.3" @@ -334,9 +371,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34a97a52fdee1870a34fa6e4b77570cba531b27d1838874fef4429a791a3d657" dependencies = [ "proc-macro-hack", - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.10", + "quote 1.0.3", + "syn 1.0.18", ] [[package]] @@ -360,13 +397,27 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "html5ever" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce65ac8028cf5a287a7dbf6c4e0a6cf2dcf022ed5b167a81bae66ebf599a8b7" +dependencies = [ + "log", + "mac", + "markup5ever", + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + [[package]] name = "indexmap" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" dependencies = [ - "autocfg", + "autocfg 1.0.0", ] [[package]] @@ -378,6 +429,12 @@ dependencies = [ "libc", ] +[[package]] +name = "itoa" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" + [[package]] name = "js-sys" version = "0.3.39" @@ -457,6 +514,29 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "mac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" + +[[package]] +name = "markup5ever" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1af46a727284117e09780d05038b1ce6fc9c76cc6df183c3dae5a8955a25e21" +dependencies = [ + "log", + "phf", + "phf_codegen", + "serde", + "serde_derive", + "serde_json", + "string_cache", + "string_cache_codegen", + "tendril", +] + [[package]] name = "match_cfg" version = "0.1.0" @@ -535,6 +615,12 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "new_debug_unreachable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" + [[package]] name = "nix" version = "0.15.0" @@ -573,7 +659,7 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" dependencies = [ - "autocfg", + "autocfg 1.0.0", "num-integer", "num-traits 0.2.11", ] @@ -584,7 +670,7 @@ version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" dependencies = [ - "autocfg", + "autocfg 1.0.0", "num-traits 0.2.11", ] @@ -594,7 +680,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" dependencies = [ - "autocfg", + "autocfg 1.0.0", "num-bigint", "num-integer", "num-traits 0.2.11", @@ -628,7 +714,7 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" dependencies = [ - "autocfg", + "autocfg 1.0.0", ] [[package]] @@ -678,7 +764,7 @@ version = "0.9.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de" dependencies = [ - "autocfg", + "autocfg 1.0.0", "cc", "libc", "openssl-src", @@ -720,6 +806,44 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "phf" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3da44b85f8e8dfaec21adae67f95d93244b2ecf6ad2a692320598dcc8e6dd18" +dependencies = [ + "phf_shared", +] + +[[package]] +name = "phf_codegen" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" +dependencies = [ + "phf_generator", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" +dependencies = [ + "phf_shared", + "rand 0.6.5", +] + +[[package]] +name = "phf_shared" +version = "0.7.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" +dependencies = [ + "siphasher", +] + [[package]] name = "pkg-config" version = "0.3.17" @@ -732,19 +856,34 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + [[package]] name = "proc-macro-hack" version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d659fe7c6d27f25e9d80a1a094c223f5246f6a6596453e09d7229bf42750b63" +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid 0.1.0", +] + [[package]] name = "proc-macro2" version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" dependencies = [ - "unicode-xid", + "unicode-xid 0.2.0", ] [[package]] @@ -760,13 +899,41 @@ dependencies = [ "unicode_reader", ] +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2 0.4.30", +] + [[package]] name = "quote" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.10", +] + +[[package]] +name = "rand" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +dependencies = [ + "autocfg 0.1.7", + "libc", + "rand_chacha 0.1.1", + "rand_core 0.4.2", + "rand_hc 0.1.0", + "rand_isaac", + "rand_jitter", + "rand_os", + "rand_pcg", + "rand_xorshift", + "winapi 0.3.8", ] [[package]] @@ -777,9 +944,19 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ "getrandom", "libc", - "rand_chacha", - "rand_core", - "rand_hc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + +[[package]] +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +dependencies = [ + "autocfg 0.1.7", + "rand_core 0.3.1", ] [[package]] @@ -789,9 +966,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.5.1", ] +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + [[package]] name = "rand_core" version = "0.5.1" @@ -801,13 +993,84 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +dependencies = [ + "rand_core 0.3.1", +] + [[package]] name = "rand_hc" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rand_jitter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" +dependencies = [ + "libc", + "rand_core 0.4.2", + "winapi 0.3.8", +] + +[[package]] +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.4.2", + "rdrand", + "winapi 0.3.8", +] + +[[package]] +name = "rand_pcg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +dependencies = [ + "autocfg 0.1.7", + "rand_core 0.4.2", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", ] [[package]] @@ -868,6 +1131,15 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "roxmltree" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5001f134077069d87f77c8b9452b690df2445f7a43f1c7ca4a1af8dd505789d" +dependencies = [ + "xmlparser", +] + [[package]] name = "rug" version = "1.8.0" @@ -966,8 +1238,10 @@ dependencies = [ "ref_thread_local", "ring", "ripemd160", + "roxmltree", "rug", "rustyline", + "select", "sha3", "unicode_reader", ] @@ -995,6 +1269,16 @@ dependencies = [ "libc", ] +[[package]] +name = "select" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac645958c62108d11f90f8d34e4dc2799c838fc995ed4c2075867a2a8d5be76b" +dependencies = [ + "bit-set", + "html5ever", +] + [[package]] name = "semver" version = "0.9.0" @@ -1010,6 +1294,34 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "serde" +version = "1.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3" + +[[package]] +name = "serde_derive" +version = "1.0.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93c5eaa17d0954cb481cdcfffe9d84fcfa7a1a9f2349271e678677be4c26ae31" +dependencies = [ + "proc-macro2 1.0.10", + "quote 1.0.3", + "syn 1.0.18", +] + +[[package]] +name = "serde_json" +version = "1.0.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec2c5d7e739bc07a3e73381a39d61fdb5f671c60c1df26a130690665803d8226" +dependencies = [ + "itoa", + "ryu", + "serde", +] + [[package]] name = "sha3" version = "0.8.2" @@ -1044,6 +1356,12 @@ dependencies = [ "libc", ] +[[package]] +name = "siphasher" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" + [[package]] name = "slab" version = "0.4.2" @@ -1077,21 +1395,66 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f3eb36b47e512f8f1c9e3d10c2c1965bc992bd9cdb024fa581e2194501c83d3" +[[package]] +name = "string_cache" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89c058a82f9fd69b1becf8c274f412281038877c553182f1d02eb027045a2d67" +dependencies = [ + "lazy_static", + "new_debug_unreachable", + "phf_shared", + "precomputed-hash", + "serde", + "string_cache_codegen", + "string_cache_shared", +] + +[[package]] +name = "string_cache_codegen" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f45ed1b65bf9a4bf2f7b7dc59212d1926e9eaf00fa998988e420fd124467c6" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2 1.0.10", + "quote 1.0.3", + "string_cache_shared", +] + +[[package]] +name = "string_cache_shared" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc" + [[package]] name = "subtle" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "unicode-xid 0.1.0", +] + [[package]] name = "syn" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "410a7488c0a728c7ceb4ad59b9567eb4053d02e8cc7f5c0e0eeeb39518369213" dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", + "proc-macro2 1.0.10", + "quote 1.0.3", + "unicode-xid 0.2.0", ] [[package]] @@ -1102,12 +1465,23 @@ checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" dependencies = [ "cfg-if", "libc", - "rand", + "rand 0.7.3", "redox_syscall", "remove_dir_all", "winapi 0.3.8", ] +[[package]] +name = "tendril" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707feda9f2582d5d680d733e38755547a3e8fb471e7ba11452ecfd9ce93a5d3b" +dependencies = [ + "futf", + "mac", + "utf-8", +] + [[package]] name = "time" version = "0.1.43" @@ -1136,6 +1510,12 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + [[package]] name = "unicode-xid" version = "0.2.0" @@ -1167,6 +1547,12 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "utf-8" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" + [[package]] name = "utf8parse" version = "0.2.0" @@ -1210,9 +1596,9 @@ dependencies = [ "bumpalo", "lazy_static", "log", - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.10", + "quote 1.0.3", + "syn 1.0.18", "wasm-bindgen-shared", ] @@ -1222,7 +1608,7 @@ version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cd85aa2c579e8892442954685f0d801f9129de24fa2136b2c6a539c76b65776" dependencies = [ - "quote", + "quote 1.0.3", "wasm-bindgen-macro-support", ] @@ -1232,9 +1618,9 @@ version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 1.0.10", + "quote 1.0.3", + "syn 1.0.18", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1298,3 +1684,9 @@ dependencies = [ "winapi 0.2.8", "winapi-build", ] + +[[package]] +name = "xmlparser" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52613e655f6f11f63c0fe7d1c3b5ef69e44d96df9b65dab296b441ed0e1125f5" diff --git a/build.rs b/build.rs index b8a5d224..a9ec444e 100644 --- a/build.rs +++ b/build.rs @@ -1,60 +1,55 @@ extern crate indexmap; -use crate::indexmap::IndexSet; - use std::env; -use std::fs::{File, copy, read_dir}; +use std::fs; +use std::fs::File; use std::io::Write; use std::path::Path; -fn main() -{ +fn find_prolog_files(libraries: &mut File, prefix: &str, current_dir: &Path) { + let entries = match current_dir.read_dir() { + Ok(entries) => entries, + Err(_) => return, + }; + for entry in entries.filter_map(Result::ok).map(|e| e.path()) { + if entry.is_dir() { + if let Some(file_name) = entry.file_name() { + let new_prefix = + prefix.to_owned() + file_name.to_str().unwrap() + "/"; + find_prolog_files(libraries, &new_prefix, &entry); + } + } else if entry.is_file() { + let ext = std::ffi::OsStr::new("pl"); + if entry.extension() == Some(ext) { + let contain = + String::from_utf8(fs::read(&entry).unwrap()).unwrap(); + let name = entry.file_stem().unwrap().to_str().unwrap(); + let line = format!( + " m.insert(\"{}\",\n{:?});\n", + prefix.to_owned() + name, + contain + ); + + libraries.write_all(line.as_bytes()).unwrap(); + } + } + } +} + +fn main() { let out_dir = env::var("OUT_DIR").unwrap(); let dest_path = Path::new(&out_dir).join("libraries.rs"); let mut libraries = File::create(&dest_path).unwrap(); - let mut library_index = IndexSet::new(); + let lib_path = Path::new("src/lib"); - let paths = read_dir("./src/lib").unwrap(); - - for item in paths { - let item = item.unwrap().path(); - - if let Some(file_name) = item.file_name() { - if let Some(ext) = item.extension() { - if ext == "pl" { - let file_stem = item.file_stem().unwrap(); - let file_str = file_stem.to_string_lossy().to_uppercase(); - let dest = Path::new(&out_dir).join(file_name); - - match copy(&item, dest) { - Ok(_) => {}, - Err(e) => panic!("die: {:?}", e) - }; - - let include_line = format!("static {}: &str = include_str!(\"{}.pl\");\n", - file_str, file_stem.to_string_lossy()); - - libraries.write_all(include_line.as_bytes()).unwrap(); - library_index.insert(file_stem.to_string_lossy().to_string()); - } - } - } - } - - libraries.write_all(b"\nref_thread_local! { + libraries + .write_all( + b"ref_thread_local! { pub static managed LIBRARIES: IndexMap<&'static str, &'static str> = { - let mut m = IndexMap::new();\n").unwrap(); - - for item in library_index { - let line = format!("\n m.insert(\"{}\", {});", item, item.to_uppercase()); - libraries.write_all(line.as_bytes()).unwrap(); - } - - libraries.write_all(b"\n\n m\n }; -}\n").unwrap(); - - libraries.write_all(b"\npub static PROJECT_DIR: &'static str = \"").unwrap(); - libraries.write_all(env::var("CARGO_MANIFEST_DIR").unwrap().as_bytes()).unwrap(); - libraries.write_all(b"\";\n").unwrap(); + let mut m = IndexMap::new();\n", + ) + .unwrap(); + find_prolog_files(&mut libraries, "", &lib_path); + libraries.write_all(b"\n m\n };\n}\n").unwrap(); } diff --git a/src/lib/tabling.pl b/src/lib/tabling.pl index 8f2b79d2..dfe4c429 100644 --- a/src/lib/tabling.pl +++ b/src/lib/tabling.pl @@ -8,12 +8,12 @@ op(1150, fx, table) ]). -:- use_module('tabling/double_linked_list'). -:- use_module('tabling/table_data_structure'). -:- use_module('tabling/batched_worklist'). -:- use_module('tabling/wrapper'). -:- use_module('tabling/global_worklist'). -:- use_module('tabling/table_link_manager'). +:- use_module(library('tabling/double_linked_list')). +:- use_module(library('tabling/table_data_structure')). +:- use_module(library('tabling/batched_worklist')). +:- use_module(library('tabling/wrapper')). +:- use_module(library('tabling/global_worklist')). +:- use_module(library('tabling/table_link_manager')). :- use_module(library(cont)). :- use_module(library(lists)). diff --git a/src/lib/tabling/batched_worklist.pl b/src/lib/tabling/batched_worklist.pl index 36a67c16..7cef4f13 100644 --- a/src/lib/tabling/batched_worklist.pl +++ b/src/lib/tabling/batched_worklist.pl @@ -45,8 +45,8 @@ wkl_worklist_work_done/1 % +WorkList ]). -:- use_module(global_worklist). -:- use_module(double_linked_list). +:- use_module(library('tabling/global_worklist')). +:- use_module(library('tabling/double_linked_list')). :- use_module(library(atts)). :- use_module(library(lists)). diff --git a/src/lib/tabling/table_data_structure.pl b/src/lib/tabling/table_data_structure.pl index b4fc6121..107a7a00 100644 --- a/src/lib/tabling/table_data_structure.pl +++ b/src/lib/tabling/table_data_structure.pl @@ -15,8 +15,8 @@ get_nb_identifiers/3 % +Table, -NbWorklistID, -NbAnswerTreeID ]). -:- use_module(table_link_manager). -:- use_module(trie). +:- use_module(library('tabling/table_link_manager')). +:- use_module(library('tabling/trie')). /* Part of SWI-Prolog @@ -53,7 +53,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -:- use_module(batched_worklist). +:- use_module(library('tabling/batched_worklist')). :- use_module(library(atts)). :- use_module(library(gensym)). diff --git a/src/lib/tabling/table_link_manager.pl b/src/lib/tabling/table_link_manager.pl index c688d0cd..1195680c 100644 --- a/src/lib/tabling/table_link_manager.pl +++ b/src/lib/tabling/table_link_manager.pl @@ -47,7 +47,7 @@ :- use_module(library(iso_ext)). :- use_module(library(terms)). -:- use_module(trie). +:- use_module(library('tabling/trie')). :- attribute trie_table_link/1. diff --git a/src/machine/compile.rs b/src/machine/compile.rs index 517c4a94..36544eba 100644 --- a/src/machine/compile.rs +++ b/src/machine/compile.rs @@ -602,12 +602,7 @@ fn load_library( ) -> Result { match LIBRARIES.borrow().get(name.as_str()) { Some(code) => { - let mut lib_path = current_dir(); - - lib_path.pop(); - lib_path.push("lib"); - - let listing_src = ListingSource::from_file_and_path(name, lib_path); + let listing_src = ListingSource::User; load_module( wam, diff --git a/src/machine/mod.rs b/src/machine/mod.rs index cf44a693..365b201e 100644 --- a/src/machine/mod.rs +++ b/src/machine/mod.rs @@ -212,17 +212,6 @@ impl SubModuleUser for IndexStore { } } -#[inline] -fn current_dir() -> std::path::PathBuf { - let mut path_buf = std::path::PathBuf::from(PROJECT_DIR); - - // file!() always produces a path relative to PROJECT_DIR. - path_buf = path_buf.join(std::path::PathBuf::from(file!())); - - path_buf.pop(); - path_buf -} - include!(concat!(env!("OUT_DIR"), "/libraries.rs")); static TOPLEVEL: &str = include_str!("../toplevel.pl"); @@ -230,12 +219,7 @@ static TOPLEVEL: &str = include_str!("../toplevel.pl"); impl Machine { fn compile_special_forms(&mut self) { - let current_dir = current_dir(); - - let verify_attrs_src = ListingSource::from_file_and_path( - clause_name!("attributed_variables.pl"), - current_dir.clone(), - ); + let verify_attrs_src = ListingSource::User; match compile_special_form( self, @@ -250,10 +234,7 @@ impl Machine { panic!("Machine::compile_special_forms() failed at VERIFY_ATTRS"), } - let project_attrs_src = ListingSource::from_file_and_path( - clause_name!("project_attributes.pl"), - current_dir, - ); + let project_attrs_src = ListingSource::User; match compile_special_form( self, @@ -273,13 +254,7 @@ impl Machine { { self.toplevel_idx = self.code_repo.code.len(); - let mut current_dir = current_dir(); - current_dir.pop(); - - let top_lvl_src = ListingSource::from_file_and_path( - clause_name!("toplevel.pl"), - current_dir, - ); + let top_lvl_src = ListingSource::User; compile_user_module( self, @@ -371,6 +346,8 @@ impl Machine { pub fn new(current_input_stream: Stream, current_output_stream: Stream) -> Self { + use crate::ref_thread_local::RefThreadLocal; + let mut wam = Machine { machine_st: MachineState::new(), inner_heap: Heap::new(), @@ -383,78 +360,59 @@ impl Machine { }; let atom_tbl = wam.indices.atom_tbl.clone(); - let mut lib_path = current_dir(); - - lib_path.pop(); - lib_path.push("lib"); wam.indices.add_term_and_goal_expansion_indices(); compile_listing( &mut wam, - Stream::from(BUILTINS), + Stream::from(LIBRARIES.borrow()["builtins"]), default_index_store!(atom_tbl.clone()), true, - ListingSource::from_file_and_path( - clause_name!("builtins.pl"), - lib_path.clone(), - ), + ListingSource::User, ); wam.compile_special_forms(); - compile_user_module(&mut wam, - Stream::from(ERROR), - true, - ListingSource::from_file_and_path( - clause_name!("error"), - lib_path.clone(), - ) + compile_user_module( + &mut wam, + Stream::from(LIBRARIES.borrow()["error"]), + true, + ListingSource::User, ); - compile_user_module(&mut wam, - Stream::from(PAIRS), - true, - ListingSource::from_file_and_path( - clause_name!("pairs"), - lib_path.clone(), - ) + compile_user_module( + &mut wam, + Stream::from(LIBRARIES.borrow()["pairs"]), + true, + ListingSource::User, ); - compile_user_module(&mut wam, - Stream::from(LISTS), - true, - ListingSource::from_file_and_path( - clause_name!("lists"), - lib_path.clone(), - ), + compile_user_module( + &mut wam, + Stream::from(LIBRARIES.borrow()["lists"]), + true, + ListingSource::User, ); - compile_user_module(&mut wam, - Stream::from(ISO_EXT), - true, - ListingSource::from_file_and_path( - clause_name!("iso_ext"), - lib_path.clone(), - ) + compile_user_module( + &mut wam, + Stream::from(LIBRARIES.borrow()["iso_ext"]), + true, + ListingSource::User, ); - compile_user_module(&mut wam, - Stream::from(SI), - true, - ListingSource::from_file_and_path( - clause_name!("si"), - lib_path.clone(), - ) + compile_user_module( + &mut wam, + Stream::from(LIBRARIES.borrow()["si"]), + true, + ListingSource::User, ); - compile_user_module(&mut wam, - Stream::from(CHARSIO), - true, - ListingSource::from_file_and_path( - clause_name!("si"), - lib_path.clone(), - ) + compile_user_module( + &mut wam, + Stream::from(LIBRARIES.borrow()["charsio"]), + true, + ListingSource::User, ); if wam.compile_top_level().is_err() { @@ -681,8 +639,15 @@ impl Machine { name.clone(), HeapCellValue::Addr(Addr::Char(c)) => clause_name!(c.to_string(), self.indices.atom_tbl), - _ => - unreachable!(), + HeapCellValue::Addr(addr @ Addr::PStrLocation(..)) => { + let mut heap_pstr_iter = + self.machine_st.heap_pstr_iter(*addr); + clause_name!( + heap_pstr_iter.to_string(), + self.indices.atom_tbl + ) + } + _ => unreachable!(), } }; diff --git a/src/toplevel.pl b/src/toplevel.pl index f07b30d4..23e7decd 100644 --- a/src/toplevel.pl +++ b/src/toplevel.pl @@ -387,8 +387,11 @@ consult(Item) :- use_module(Module) :- ( nonvar(Module) -> - ( Module = library(Filename) -> '$use_module'(Filename) - ; atom(Module) -> '$use_module_from_file'(Module) + ( Module = library(Filename) -> + write_term_to_chars(Filename, [], FilenameString), + '$use_module'(FilenameString) + ; atom(Module) -> + '$use_module_from_file'(Module) ; throw(error(invalid_module_specifier, use_module/1)) ) ; throw(error(instantiation_error, use_module/1)) @@ -399,7 +402,8 @@ use_module(Module, QualifiedExports) :- ( list_si(QualifiedExports) -> maplist('$module_export'(use_module/2), QualifiedExports) -> ( Module = library(Filename) -> - '$use_qualified_module'(Filename, QualifiedExports) + write_term_to_chars(Filename, [], FilenameString), + '$use_qualified_module'(FilenameString, QualifiedExports) ; atom(Module) -> '$use_qualified_module_from_file'(Module, QualifiedExports) ; throw(error(invalid_module_specifier, use_module/2)) From bf13700a9531b3991e047c44e5e06c12bd57c13c Mon Sep 17 00:00:00 2001 From: notoria Date: Wed, 1 Jul 2020 13:14:12 +0200 Subject: [PATCH 4/4] Enhanced the implementation The restriction has been removed by using read_library_path from cfd15f4e027b4df216e723bbd35facac28a09a1c. --- src/lib/tabling.pl | 12 ++++---- src/lib/tabling/batched_worklist.pl | 4 +-- src/lib/tabling/table_data_structure.pl | 6 ++-- src/lib/tabling/table_link_manager.pl | 2 +- src/machine/toplevel.rs | 41 +++++++++++++++++-------- 5 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/lib/tabling.pl b/src/lib/tabling.pl index dfe4c429..703da8e3 100644 --- a/src/lib/tabling.pl +++ b/src/lib/tabling.pl @@ -8,12 +8,12 @@ op(1150, fx, table) ]). -:- use_module(library('tabling/double_linked_list')). -:- use_module(library('tabling/table_data_structure')). -:- use_module(library('tabling/batched_worklist')). -:- use_module(library('tabling/wrapper')). -:- use_module(library('tabling/global_worklist')). -:- use_module(library('tabling/table_link_manager')). +:- use_module(library(tabling/double_linked_list)). +:- use_module(library(tabling/table_data_structure)). +:- use_module(library(tabling/batched_worklist)). +:- use_module(library(tabling/wrapper)). +:- use_module(library(tabling/global_worklist)). +:- use_module(library(tabling/table_link_manager)). :- use_module(library(cont)). :- use_module(library(lists)). diff --git a/src/lib/tabling/batched_worklist.pl b/src/lib/tabling/batched_worklist.pl index 7cef4f13..f39f8422 100644 --- a/src/lib/tabling/batched_worklist.pl +++ b/src/lib/tabling/batched_worklist.pl @@ -45,8 +45,8 @@ wkl_worklist_work_done/1 % +WorkList ]). -:- use_module(library('tabling/global_worklist')). -:- use_module(library('tabling/double_linked_list')). +:- use_module(library(tabling/global_worklist)). +:- use_module(library(tabling/double_linked_list)). :- use_module(library(atts)). :- use_module(library(lists)). diff --git a/src/lib/tabling/table_data_structure.pl b/src/lib/tabling/table_data_structure.pl index 107a7a00..0ce989da 100644 --- a/src/lib/tabling/table_data_structure.pl +++ b/src/lib/tabling/table_data_structure.pl @@ -15,8 +15,8 @@ get_nb_identifiers/3 % +Table, -NbWorklistID, -NbAnswerTreeID ]). -:- use_module(library('tabling/table_link_manager')). -:- use_module(library('tabling/trie')). +:- use_module(library(tabling/table_link_manager)). +:- use_module(library(tabling/trie)). /* Part of SWI-Prolog @@ -53,7 +53,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -:- use_module(library('tabling/batched_worklist')). +:- use_module(library(tabling/batched_worklist)). :- use_module(library(atts)). :- use_module(library(gensym)). diff --git a/src/lib/tabling/table_link_manager.pl b/src/lib/tabling/table_link_manager.pl index 1195680c..ec88f105 100644 --- a/src/lib/tabling/table_link_manager.pl +++ b/src/lib/tabling/table_link_manager.pl @@ -47,7 +47,7 @@ :- use_module(library(iso_ext)). :- use_module(library(terms)). -:- use_module(library('tabling/trie')). +:- use_module(library(tabling/trie)). :- attribute trie_table_link/1. diff --git a/src/machine/toplevel.rs b/src/machine/toplevel.rs index 9937fffe..eaa17691 100644 --- a/src/machine/toplevel.rs +++ b/src/machine/toplevel.rs @@ -340,16 +340,37 @@ fn setup_module_decl( } } -fn setup_use_module_decl(mut terms: Vec>) -> Result { +fn read_library_path( + term: Term, + atom_tbl: TabledData, +) -> Option { + match term { + Term::Constant(_, Constant::Atom(atom, _)) => { + Some(atom.defrock_brackets()) + } + _ => { + let mut atoms = vec![]; + + for term in unfold_by_str(term, "/") { + match term { + Term::Constant(_, Constant::Atom(atom, _)) => { + atoms.push(atom.as_str().to_owned()); + } + _ => return None, + } + } + + Some(clause_name!(atoms.join("/"), atom_tbl)) + } + } +} + +fn setup_use_module_decl(mut terms: Vec>, atom_tbl: TabledData) -> Result { match *terms.pop().unwrap() { Term::Clause(_, ref name, ref mut terms, None) if name.as_str() == "library" && terms.len() == 1 => { - terms - .pop() - .unwrap() - .to_constant() - .and_then(|c| c.to_atom()) + read_library_path(*terms.pop().unwrap(), atom_tbl) .map(|c| ModuleSource::Library(c)) .ok_or(ParserError::InvalidUseModuleDecl) } @@ -396,11 +417,7 @@ fn setup_qualified_import( Term::Clause(_, ref name, ref mut terms, None) if name.as_str() == "library" && terms.len() == 1 => { - terms - .pop() - .unwrap() - .to_constant() - .and_then(|c| c.to_atom()) + read_library_path(*terms.pop().unwrap(), atom_tbl.clone()) .map(|c| ModuleSource::Library(c)) .ok_or(ParserError::InvalidUseModuleDecl) } @@ -685,7 +702,7 @@ fn setup_declaration<'a, 'b, 'c>( } } ("use_module", 1) => { - Ok(Declaration::UseModule(setup_use_module_decl(terms)?)) + Ok(Declaration::UseModule(setup_use_module_decl(terms, indices.atom_tbl())?)) } ("use_module", 2) => { let (name, exports) = setup_qualified_import(terms, indices.atom_tbl())?;