diff options
| author | Henry <mail@henrygressmann.de> | 2026-05-02 21:14:02 +0200 |
|---|---|---|
| committer | Henry <mail@henrygressmann.de> | 2026-05-02 21:19:54 +0200 |
| commit | ba1cf56464f8e5c3c7bcc2dc75f10aad2cd56e6b (patch) | |
| tree | dd0bef203b31c494f48e72c1169f2f50ae7b6d21 | |
| parent | d3c6b705a3b1035adda66a92131e9ddf59fb46ab (diff) | |
chore: add more tests, fix issues with import types, cleanup doom example
Signed-off-by: Henry <mail@henrygressmann.de>
26 files changed, 467 insertions, 1739 deletions
diff --git a/.cargo/config.toml b/.cargo/config.toml index 122d4ae..ed20d09 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -6,6 +6,7 @@ test-wasm-3="test --package tinywasm --test test-wasm-3 --release" test-wast="test --package tinywasm --test test-wast" test-wasm-custom="test --package tinywasm --test test-wasm-custom --release" cli="run -p tinywasm-cli --bin tinywasm --release --" +doom="run --manifest-path ./examples/doom/Cargo.toml --release --" [target.x86_64-unknown-linux-gnu] rustflags=["-C", "target-cpu=x86-64-v3"] @@ -1,12 +1,9 @@ /target notes.md -examples/rust/out/* -examples/rust/target -examples/rust/Cargo.lock -examples/doom/out/* -!examples/doom/out/.gitkeep +examples/*/out/* +examples/*/target +examples/*/Cargo.lock examples/doom/upstream/ -examples/doom/out/runtime/ *.wad *.WAD examples/wast/* @@ -3,35 +3,6 @@ version = 4 [[package]] -name = "ab_glyph" -version = "0.2.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01c0457472c38ea5bd1c3b5ada5e368271cb550be7a4ca4a0b4634e9913f6cc2" -dependencies = [ - "ab_glyph_rasterizer", - "owned_ttf_parser", -] - -[[package]] -name = "ab_glyph_rasterizer" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" - -[[package]] -name = "ahash" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" -dependencies = [ - "cfg-if", - "getrandom 0.3.4", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] name = "aho-corasick" version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -50,31 +21,6 @@ dependencies = [ ] [[package]] -name = "android-activity" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2a1bb052857d5dd49572219344a7332b31b76405648eabac5bc68978251bcd" -dependencies = [ - "android-properties", - "bitflags 2.11.1", - "cc", - "jni", - "libc", - "log", - "ndk", - "ndk-context", - "ndk-sys", - "num_enum", - "thiserror 2.0.18", -] - -[[package]] -name = "android-properties" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" - -[[package]] name = "anes" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -116,7 +62,7 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys 0.61.2", + "windows-sys", ] [[package]] @@ -127,7 +73,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.61.2", + "windows-sys", ] [[package]] @@ -137,24 +83,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" [[package]] -name = "arrayref" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" - -[[package]] -name = "arrayvec" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" - -[[package]] -name = "as-raw-xcb-connection" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" - -[[package]] name = "assert_cmd" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -170,12 +98,6 @@ dependencies = [ ] [[package]] -name = "atomic-waker" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" - -[[package]] name = "autocfg" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -183,26 +105,11 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" [[package]] -name = "block2" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" -dependencies = [ - "objc2 0.5.2", -] - -[[package]] name = "bstr" version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -220,58 +127,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" [[package]] -name = "bytemuck" -version = "1.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8efb64bd706a16a1bdde310ae86b351e4d21550d98d056f22f8a7f7a2183fec" -dependencies = [ - "bytemuck_derive", -] - -[[package]] -name = "bytemuck_derive" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "bytes" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" - -[[package]] -name = "calloop" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" -dependencies = [ - "bitflags 2.11.1", - "log", - "polling", - "rustix 0.38.44", - "slab", - "thiserror 1.0.69", -] - -[[package]] -name = "calloop-wayland-source" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a66a987056935f7efce4ab5668920b5d0dac4a7c99991a67395f13702ddd20" -dependencies = [ - "calloop", - "rustix 0.38.44", - "wayland-backend", - "wayland-client", -] - -[[package]] name = "cast" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -284,8 +139,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d16d90359e986641506914ba71350897565610e87ce0ad9e6f28569db3dd5c6d" dependencies = [ "find-msvc-tools", - "jobserver", - "libc", "shlex", ] @@ -296,12 +149,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] -name = "cfg_aliases" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" - -[[package]] name = "ciborium" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -383,7 +230,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1" dependencies = [ - "thiserror 2.0.18", + "thiserror", ] [[package]] @@ -393,65 +240,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" [[package]] -name = "combine" -version = "4.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" -dependencies = [ - "bytes", - "memchr", -] - -[[package]] -name = "concurrent-queue" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" - -[[package]] -name = "core-graphics" -version = "0.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-graphics-types", - "foreign-types", - "libc", -] - -[[package]] -name = "core-graphics-types" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "libc", -] - -[[package]] name = "criterion" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -517,110 +305,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" [[package]] -name = "ctor" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83cf0d42651b16c6dfe68685716d18480d18a9c39c62d76e8cf3eb6ed5d8bcbf" -dependencies = [ - "dtor", -] - -[[package]] -name = "cursor-icon" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" - -[[package]] name = "difflib" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" [[package]] -name = "dispatch" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" - -[[package]] -name = "dispatch2" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" -dependencies = [ - "bitflags 2.11.1", - "objc2 0.6.4", -] - -[[package]] -name = "dlib" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a" -dependencies = [ - "libloading", -] - -[[package]] -name = "downcast-rs" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" - -[[package]] -name = "dpi" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76" - -[[package]] -name = "drm" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80bc8c5c6c2941f70a55c15f8d9f00f9710ebda3ffda98075f996a0e6c92756f" -dependencies = [ - "bitflags 2.11.1", - "bytemuck", - "drm-ffi", - "drm-fourcc", - "libc", - "rustix 0.38.44", -] - -[[package]] -name = "drm-ffi" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51a91c9b32ac4e8105dec255e849e0d66e27d7c34d184364fb93e469db08f690" -dependencies = [ - "drm-sys", - "rustix 1.1.4", -] - -[[package]] -name = "drm-fourcc" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aafbcdb8afc29c1a7ee5fbe53b5d62f4565b35a042a662ca9fecd0b54dae6f4" - -[[package]] -name = "drm-sys" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc8e1361066d91f5ffccff060a3c3be9c3ecde15be2959c1937595f7a82a9f8" -dependencies = [ - "libc", - "linux-raw-sys 0.9.4", -] - -[[package]] -name = "dtor" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edf234dd1594d6dd434a8fb8cada51ddbbc593e40e4a01556a0b31c62da2775b" - -[[package]] name = "either" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -664,7 +354,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys", ] [[package]] @@ -705,79 +395,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" [[package]] -name = "foreign-types" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" -dependencies = [ - "foreign-types-macros", - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-macros" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "foreign-types-shared" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" - -[[package]] -name = "futures-core" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" - -[[package]] -name = "futures-task" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" - -[[package]] -name = "futures-util" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" -dependencies = [ - "futures-core", - "futures-task", - "pin-project-lite", - "slab", -] - -[[package]] -name = "gethostname" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" -dependencies = [ - "rustix 1.1.4", - "windows-link", -] - -[[package]] -name = "getrandom" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" -dependencies = [ - "cfg-if", - "libc", - "r-efi 5.3.0", - "wasip2", -] - -[[package]] name = "getrandom" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -785,7 +402,7 @@ checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" dependencies = [ "cfg-if", "libc", - "r-efi 6.0.0", + "r-efi", "wasip2", "wasip3", ] @@ -885,7 +502,7 @@ checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" dependencies = [ "hermit-abi", "libc", - "windows-sys 0.61.2", + "windows-sys", ] [[package]] @@ -910,86 +527,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] -name = "jni" -version = "0.22.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498" -dependencies = [ - "cfg-if", - "combine", - "jni-macros", - "jni-sys 0.4.1", - "log", - "simd_cesu8", - "thiserror 2.0.18", - "walkdir", - "windows-link", -] - -[[package]] -name = "jni-macros" -version = "0.22.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3" -dependencies = [ - "proc-macro2", - "quote", - "rustc_version", - "simd_cesu8", - "syn", -] - -[[package]] -name = "jni-sys" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258" -dependencies = [ - "jni-sys 0.4.1", -] - -[[package]] -name = "jni-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" -dependencies = [ - "jni-sys-macros", -] - -[[package]] -name = "jni-sys-macros" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "jobserver" -version = "0.1.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" -dependencies = [ - "getrandom 0.3.4", - "libc", -] - -[[package]] -name = "js-sys" -version = "0.3.97" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1840c94c045fbcf8ba2812c95db44499f7c64910a912551aaaa541decebcacf" -dependencies = [ - "cfg-if", - "futures-util", - "once_cell", - "wasm-bindgen", -] - -[[package]] name = "leb128fmt" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1002,46 +539,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" [[package]] -name = "libloading" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" -dependencies = [ - "cfg-if", - "windows-link", -] - -[[package]] name = "libm" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] -name = "libredox" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e02f3bb43d335493c96bf3fd3a321600bf6bd07ed34bc64118e9293bdffea46c" -dependencies = [ - "bitflags 2.11.1", - "libc", - "plain", - "redox_syscall 0.7.4", -] - -[[package]] -name = "linux-raw-sys" -version = "0.4.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" - -[[package]] -name = "linux-raw-sys" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" - -[[package]] name = "linux-raw-sys" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1060,45 +563,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] -name = "memmap2" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "714098028fe011992e1c3962653c96b2d578c4b4bce9036e15ff220319b1e0e3" -dependencies = [ - "libc", -] - -[[package]] -name = "ndk" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" -dependencies = [ - "bitflags 2.11.1", - "jni-sys 0.3.1", - "log", - "ndk-sys", - "num_enum", - "raw-window-handle", - "thiserror 1.0.69", -] - -[[package]] -name = "ndk-context" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" - -[[package]] -name = "ndk-sys" -version = "0.6.0+11769913" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873" -dependencies = [ - "jni-sys 0.3.1", -] - -[[package]] name = "normalize-line-endings" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1114,298 +578,6 @@ dependencies = [ ] [[package]] -name = "num_enum" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26" -dependencies = [ - "num_enum_derive", - "rustversion", -] - -[[package]] -name = "num_enum_derive" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "objc-sys" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" - -[[package]] -name = "objc2" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" -dependencies = [ - "objc-sys", - "objc2-encode", -] - -[[package]] -name = "objc2" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a12a8ed07aefc768292f076dc3ac8c48f3781c8f2d5851dd3d98950e8c5a89f" -dependencies = [ - "objc2-encode", -] - -[[package]] -name = "objc2-app-kit" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" -dependencies = [ - "bitflags 2.11.1", - "block2", - "libc", - "objc2 0.5.2", - "objc2-core-data", - "objc2-core-image", - "objc2-foundation 0.2.2", - "objc2-quartz-core 0.2.2", -] - -[[package]] -name = "objc2-cloud-kit" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" -dependencies = [ - "bitflags 2.11.1", - "block2", - "objc2 0.5.2", - "objc2-core-location", - "objc2-foundation 0.2.2", -] - -[[package]] -name = "objc2-contacts" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889" -dependencies = [ - "block2", - "objc2 0.5.2", - "objc2-foundation 0.2.2", -] - -[[package]] -name = "objc2-core-data" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" -dependencies = [ - "bitflags 2.11.1", - "block2", - "objc2 0.5.2", - "objc2-foundation 0.2.2", -] - -[[package]] -name = "objc2-core-foundation" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" -dependencies = [ - "bitflags 2.11.1", - "dispatch2", - "objc2 0.6.4", -] - -[[package]] -name = "objc2-core-graphics" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" -dependencies = [ - "bitflags 2.11.1", - "dispatch2", - "objc2 0.6.4", - "objc2-core-foundation", - "objc2-io-surface", -] - -[[package]] -name = "objc2-core-image" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" -dependencies = [ - "block2", - "objc2 0.5.2", - "objc2-foundation 0.2.2", - "objc2-metal", -] - -[[package]] -name = "objc2-core-location" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781" -dependencies = [ - "block2", - "objc2 0.5.2", - "objc2-contacts", - "objc2-foundation 0.2.2", -] - -[[package]] -name = "objc2-encode" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" - -[[package]] -name = "objc2-foundation" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" -dependencies = [ - "bitflags 2.11.1", - "block2", - "dispatch", - "libc", - "objc2 0.5.2", -] - -[[package]] -name = "objc2-foundation" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" -dependencies = [ - "bitflags 2.11.1", - "objc2 0.6.4", - "objc2-core-foundation", -] - -[[package]] -name = "objc2-io-surface" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" -dependencies = [ - "bitflags 2.11.1", - "objc2 0.6.4", - "objc2-core-foundation", -] - -[[package]] -name = "objc2-link-presentation" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398" -dependencies = [ - "block2", - "objc2 0.5.2", - "objc2-app-kit", - "objc2-foundation 0.2.2", -] - -[[package]] -name = "objc2-metal" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" -dependencies = [ - "bitflags 2.11.1", - "block2", - "objc2 0.5.2", - "objc2-foundation 0.2.2", -] - -[[package]] -name = "objc2-quartz-core" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" -dependencies = [ - "bitflags 2.11.1", - "block2", - "objc2 0.5.2", - "objc2-foundation 0.2.2", - "objc2-metal", -] - -[[package]] -name = "objc2-quartz-core" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" -dependencies = [ - "bitflags 2.11.1", - "objc2 0.6.4", - "objc2-core-foundation", - "objc2-foundation 0.3.2", -] - -[[package]] -name = "objc2-symbols" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc" -dependencies = [ - "objc2 0.5.2", - "objc2-foundation 0.2.2", -] - -[[package]] -name = "objc2-ui-kit" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" -dependencies = [ - "bitflags 2.11.1", - "block2", - "objc2 0.5.2", - "objc2-cloud-kit", - "objc2-core-data", - "objc2-core-image", - "objc2-core-location", - "objc2-foundation 0.2.2", - "objc2-link-presentation", - "objc2-quartz-core 0.2.2", - "objc2-symbols", - "objc2-uniform-type-identifiers", - "objc2-user-notifications", -] - -[[package]] -name = "objc2-uniform-type-identifiers" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe" -dependencies = [ - "block2", - "objc2 0.5.2", - "objc2-foundation 0.2.2", -] - -[[package]] -name = "objc2-user-notifications" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" -dependencies = [ - "bitflags 2.11.1", - "block2", - "objc2 0.5.2", - "objc2-core-location", - "objc2-foundation 0.2.2", -] - -[[package]] name = "once_cell" version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1424,25 +596,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" [[package]] -name = "orbclient" -version = "0.3.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a570f6bca41d29acb2139229a7c873ec99bc9a313bd10804081d89bfac8ff329" -dependencies = [ - "libc", - "libredox", -] - -[[package]] -name = "owned_ttf_parser" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36820e9051aca1014ddc75770aab4d68bc1e9e632f0f5627c4086bc216fb583b" -dependencies = [ - "ttf-parser", -] - -[[package]] name = "owo-colors" version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1459,64 +612,6 @@ dependencies = [ ] [[package]] -name = "percent-encoding" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" - -[[package]] -name = "pin-project" -version = "1.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1749c7ed4bcaf4c3d0a3efc28538844fb29bcdd7d2b67b2be7e20ba861ff517" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b20ed30f105399776b9c883e68e536ef602a16ae6f596d2c473591d6ad64c6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" - -[[package]] -name = "pkg-config" -version = "0.3.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" - -[[package]] -name = "plain" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" - -[[package]] -name = "polling" -version = "3.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" -dependencies = [ - "cfg-if", - "concurrent-queue", - "hermit-abi", - "pin-project-lite", - "rustix 1.1.4", - "windows-sys 0.61.2", -] - -[[package]] name = "postcard" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1579,15 +674,6 @@ dependencies = [ ] [[package]] -name = "proc-macro-crate" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" -dependencies = [ - "toml_edit", -] - -[[package]] name = "proc-macro2" version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1597,15 +683,6 @@ dependencies = [ ] [[package]] -name = "quick-xml" -version = "0.39.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "958f21e8e7ceb5a1aa7fa87fab28e7c75976e0bfe7e23ff069e0a260f894067d" -dependencies = [ - "memchr", -] - -[[package]] name = "quote" version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1616,23 +693,11 @@ dependencies = [ [[package]] name = "r-efi" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" - -[[package]] -name = "r-efi" version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] -name = "raw-window-handle" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" - -[[package]] name = "rayon" version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1653,33 +718,6 @@ dependencies = [ ] [[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_syscall" -version = "0.5.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" -dependencies = [ - "bitflags 2.11.1", -] - -[[package]] -name = "redox_syscall" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f450ad9c3b1da563fb6948a8e0fb0fb9269711c9c73d9ea1de5058c79c8d643a" -dependencies = [ - "bitflags 2.11.1", -] - -[[package]] name = "regex" version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1709,47 +747,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" [[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - -[[package]] -name = "rustix" -version = "0.38.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" -dependencies = [ - "bitflags 2.11.1", - "errno", - "libc", - "linux-raw-sys 0.4.15", - "windows-sys 0.59.0", -] - -[[package]] name = "rustix" version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags 2.11.1", + "bitflags", "errno", "libc", - "linux-raw-sys 0.12.1", - "windows-sys 0.61.2", + "linux-raw-sys", + "windows-sys", ] [[package]] -name = "rustversion" -version = "1.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" - -[[package]] name = "same-file" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1759,25 +769,6 @@ dependencies = [ ] [[package]] -name = "scoped-tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" - -[[package]] -name = "sctk-adwaita" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6277f0217056f77f1d8f49f2950ac6c278c0d607c45f5ee99328d792ede24ec" -dependencies = [ - "ab_glyph", - "log", - "memmap2", - "smithay-client-toolkit", - "tiny-skia", -] - -[[package]] name = "semver" version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1833,106 +824,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] -name = "simd_cesu8" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94f90157bb87cddf702797c5dadfa0be7d266cdf49e22da2fcaa32eff75b2c33" -dependencies = [ - "rustc_version", - "simdutf8", -] - -[[package]] -name = "simdutf8" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" - -[[package]] -name = "slab" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" - -[[package]] -name = "smallvec" -version = "1.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" - -[[package]] -name = "smithay-client-toolkit" -version = "0.19.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" -dependencies = [ - "bitflags 2.11.1", - "calloop", - "calloop-wayland-source", - "cursor-icon", - "libc", - "log", - "memmap2", - "rustix 0.38.44", - "thiserror 1.0.69", - "wayland-backend", - "wayland-client", - "wayland-csd-frame", - "wayland-cursor", - "wayland-protocols", - "wayland-protocols-wlr", - "wayland-scanner", - "xkeysym", -] - -[[package]] -name = "smol_str" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead" -dependencies = [ - "serde", -] - -[[package]] -name = "softbuffer" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aac18da81ebbf05109ab275b157c22a653bb3c12cf884450179942f81bcbf6c3" -dependencies = [ - "as-raw-xcb-connection", - "bytemuck", - "drm", - "fastrand", - "js-sys", - "memmap2", - "ndk", - "objc2 0.6.4", - "objc2-core-foundation", - "objc2-core-graphics", - "objc2-foundation 0.3.2", - "objc2-quartz-core 0.3.2", - "raw-window-handle", - "redox_syscall 0.5.18", - "rustix 1.1.4", - "tiny-xlib", - "tracing", - "wasm-bindgen", - "wayland-backend", - "wayland-client", - "wayland-sys", - "web-sys", - "windows-sys 0.61.2", - "x11rb", -] - -[[package]] -name = "strict-num" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" - -[[package]] name = "strsim" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1956,10 +847,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.4.2", + "getrandom", "once_cell", - "rustix 1.1.4", - "windows-sys 0.61.2", + "rustix", + "windows-sys", ] [[package]] @@ -1979,31 +870,11 @@ checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" [[package]] name = "thiserror" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" -dependencies = [ - "thiserror-impl 1.0.69", -] - -[[package]] -name = "thiserror" version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" dependencies = [ - "thiserror-impl 2.0.18", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "thiserror-impl", ] [[package]] @@ -2018,44 +889,6 @@ dependencies = [ ] [[package]] -name = "tiny-skia" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" -dependencies = [ - "arrayref", - "arrayvec", - "bytemuck", - "cfg-if", - "log", - "tiny-skia-path", -] - -[[package]] -name = "tiny-skia-path" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" -dependencies = [ - "arrayref", - "bytemuck", - "strict-num", -] - -[[package]] -name = "tiny-xlib" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a90a0ca3ee6a69f2ad28fd11621a4c3f03b371f366be500b64df260c4ffbafb4" -dependencies = [ - "as-raw-xcb-connection", - "ctor", - "libloading", - "pkg-config", - "tracing", -] - -[[package]] name = "tinytemplate" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2103,18 +936,6 @@ dependencies = [ ] [[package]] -name = "tinywasm-doom" -version = "0.0.0" -dependencies = [ - "eyre", - "log", - "pretty_env_logger", - "softbuffer", - "tinywasm", - "winit", -] - -[[package]] name = "tinywasm-parser" version = "0.9.0-alpha.0" dependencies = [ @@ -2143,70 +964,12 @@ dependencies = [ ] [[package]] -name = "toml_datetime" -version = "1.1.1+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" -dependencies = [ - "serde_core", -] - -[[package]] -name = "toml_edit" -version = "0.25.11+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b59c4d22ed448339746c59b905d24568fcbb3ab65a500494f7b8c3e97739f2b" -dependencies = [ - "indexmap", - "toml_datetime", - "toml_parser", - "winnow", -] - -[[package]] -name = "toml_parser" -version = "1.1.2+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2abe9b86193656635d2411dc43050282ca48aa31c2451210f4202550afb7526" -dependencies = [ - "winnow", -] - -[[package]] -name = "tracing" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" -dependencies = [ - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" - -[[package]] -name = "ttf-parser" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" - -[[package]] name = "unicode-ident" version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] -name = "unicode-segmentation" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c" - -[[package]] name = "unicode-width" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2225,12 +988,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] name = "wait-timeout" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2268,61 +1025,6 @@ dependencies = [ ] [[package]] -name = "wasm-bindgen" -version = "0.2.120" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df52b6d9b87e0c74c9edfa1eb2d9bf85e5d63515474513aa50fa181b3c4f5db1" -dependencies = [ - "cfg-if", - "once_cell", - "rustversion", - "wasm-bindgen-macro", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af934872acec734c2d80e6617bbb5ff4f12b052dd8e6332b0817bce889516084" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.120" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b1041f495fb322e64aca85f5756b2172e35cd459376e67f2a6c9dffcedb103" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.120" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dcd0ff20416988a18ac686d4d4d0f6aae9ebf08a389ff5d29012b05af2a1b41" -dependencies = [ - "bumpalo", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.120" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49757b3c82ebf16c57d69365a142940b384176c24df52a087fb748e2085359ea" -dependencies = [ - "unicode-ident", -] - -[[package]] name = "wasm-encoder" version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2370,7 +1072,7 @@ version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" dependencies = [ - "bitflags 2.11.1", + "bitflags", "hashbrown 0.15.5", "indexmap", "semver", @@ -2382,7 +1084,7 @@ version = "0.248.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa4439c5eee9df71ee0c6efb37f63b1fcb1fec38f85f5142c54e7ed05d33091a" dependencies = [ - "bitflags 2.11.1", + "bitflags", "indexmap", "semver", ] @@ -2410,135 +1112,6 @@ dependencies = [ ] [[package]] -name = "wayland-backend" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2857dd20b54e916ec7253b3d6b4d5c4d7d4ca2c33c2e11c6c76a99bd8744755d" -dependencies = [ - "cc", - "downcast-rs", - "rustix 1.1.4", - "scoped-tls", - "smallvec", - "wayland-sys", -] - -[[package]] -name = "wayland-client" -version = "0.31.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c7c96bb74690c3189b5c9cb4ca1627062bb23693a4fad9d8c3de958260144" -dependencies = [ - "bitflags 2.11.1", - "rustix 1.1.4", - "wayland-backend", - "wayland-scanner", -] - -[[package]] -name = "wayland-csd-frame" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" -dependencies = [ - "bitflags 2.11.1", - "cursor-icon", - "wayland-backend", -] - -[[package]] -name = "wayland-cursor" -version = "0.31.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a52d18780be9b1314328a3de5f930b73d2200112e3849ca6cb11822793fb34d" -dependencies = [ - "rustix 1.1.4", - "wayland-client", - "xcursor", -] - -[[package]] -name = "wayland-protocols" -version = "0.32.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "563a85523cade2429938e790815fd7319062103b9f4a2dc806e9b53b95982d8f" -dependencies = [ - "bitflags 2.11.1", - "wayland-backend", - "wayland-client", - "wayland-scanner", -] - -[[package]] -name = "wayland-protocols-plasma" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b6d8cf1eb2c1c31ed1f5643c88a6e53538129d4af80030c8cabd1f9fa884d91" -dependencies = [ - "bitflags 2.11.1", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-scanner", -] - -[[package]] -name = "wayland-protocols-wlr" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb04e52f7836d7c7976c78ca0250d61e33873c34156a2a1fc9474828ec268234" -dependencies = [ - "bitflags 2.11.1", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-scanner", -] - -[[package]] -name = "wayland-scanner" -version = "0.31.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c324a910fd86ebdc364a3e61ec1f11737d3b1d6c273c0239ee8ff4bc0d24b4a" -dependencies = [ - "proc-macro2", - "quick-xml", - "quote", -] - -[[package]] -name = "wayland-sys" -version = "0.31.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be" -dependencies = [ - "dlib", - "log", - "once_cell", - "pkg-config", -] - -[[package]] -name = "web-sys" -version = "0.3.97" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eadbac71025cd7b0834f20d1fe8472e8495821b4e9801eb0a60bd1f19827602" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "web-time" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2560,7 +1133,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys", ] [[package]] @@ -2577,24 +1150,6 @@ checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-sys" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-sys" version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" @@ -2603,131 +1158,6 @@ dependencies = [ ] [[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "winit" -version = "0.30.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6755fa58a9f8350bd1e472d4c3fcc25f824ec358933bba33306d0b63df5978d" -dependencies = [ - "ahash", - "android-activity", - "atomic-waker", - "bitflags 2.11.1", - "block2", - "bytemuck", - "calloop", - "cfg_aliases", - "concurrent-queue", - "core-foundation", - "core-graphics", - "cursor-icon", - "dpi", - "js-sys", - "libc", - "memmap2", - "ndk", - "objc2 0.5.2", - "objc2-app-kit", - "objc2-foundation 0.2.2", - "objc2-ui-kit", - "orbclient", - "percent-encoding", - "pin-project", - "raw-window-handle", - "redox_syscall 0.4.1", - "rustix 0.38.44", - "sctk-adwaita", - "smithay-client-toolkit", - "smol_str", - "tracing", - "unicode-segmentation", - "wasm-bindgen", - "wasm-bindgen-futures", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-protocols-plasma", - "web-sys", - "web-time", - "windows-sys 0.52.0", - "x11-dl", - "x11rb", - "xkbcommon-dl", -] - -[[package]] -name = "winnow" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ee1708bef14716a11bae175f579062d4554d95be2c6829f518df847b7b3fdd0" -dependencies = [ - "memchr", -] - -[[package]] name = "wit-bindgen" version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2791,7 +1221,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" dependencies = [ "anyhow", - "bitflags 2.11.1", + "bitflags", "indexmap", "log", "serde", @@ -2822,63 +1252,6 @@ dependencies = [ ] [[package]] -name = "x11-dl" -version = "2.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" -dependencies = [ - "libc", - "once_cell", - "pkg-config", -] - -[[package]] -name = "x11rb" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414" -dependencies = [ - "as-raw-xcb-connection", - "gethostname", - "libc", - "libloading", - "once_cell", - "rustix 1.1.4", - "x11rb-protocol", -] - -[[package]] -name = "x11rb-protocol" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd" - -[[package]] -name = "xcursor" -version = "0.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec9e4a500ca8864c5b47b8b482a73d62e4237670e5b5f1d6b9e3cae50f28f2b" - -[[package]] -name = "xkbcommon-dl" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" -dependencies = [ - "bitflags 2.11.1", - "dlib", - "log", - "once_cell", - "xkeysym", -] - -[[package]] -name = "xkeysym" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" - -[[package]] name = "zerocopy" version = "0.8.48" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1,5 +1,5 @@ [workspace] -members=["crates/*", "examples/doom"] +members=["crates/*"] default-members=[".", "crates/tinywasm", "crates/types", "crates/parser"] resolver="2" diff --git a/crates/parser/src/conversion.rs b/crates/parser/src/conversion.rs index 487f992..8a12daa 100644 --- a/crates/parser/src/conversion.rs +++ b/crates/parser/src/conversion.rs @@ -3,7 +3,7 @@ use alloc::sync::Arc; use crate::{Result, module::FunctionCode, visit::process_operators_and_validate}; use alloc::{boxed::Box, format, string::ToString, vec::Vec}; use tinywasm_types::*; -use wasmparser::{FuncValidator, FuncValidatorAllocations, OperatorsReader, ValidatorResources}; +use wasmparser::{CompositeInnerType, FuncValidator, FuncValidatorAllocations, OperatorsReader, ValidatorResources}; pub(crate) fn convert_module_elements<'a, T: IntoIterator<Item = wasmparser::Result<wasmparser::Element<'a>>>>( elements: T, @@ -39,7 +39,7 @@ pub(crate) fn convert_module_element(element: wasmparser::Element<'_>) -> Result .collect::<Result<Vec<_>>>()? .into_boxed_slice(); - Ok(tinywasm_types::Element { kind, items, ty: convert_reftype(ty), range: element.range }) + Ok(tinywasm_types::Element { kind, items, ty: convert_reftype(ty)?, range: element.range }) } } } @@ -74,7 +74,7 @@ pub(crate) fn convert_module_import(import: wasmparser::Import<'_>) -> Result<Im let kind = match import.ty { wasmparser::TypeRef::Func(ty) => ImportKind::Function(ty), wasmparser::TypeRef::Table(ty) => ImportKind::Table(TableType { - element_type: convert_reftype(ty.element_type), + element_type: convert_reftype(ty.element_type)?, size_initial: ty.initial.try_into().map_err(|_| { crate::ParseError::UnsupportedOperator(format!("Table size initial is too large: {}", ty.initial)) })?, @@ -87,7 +87,7 @@ pub(crate) fn convert_module_import(import: wasmparser::Import<'_>) -> Result<Im }), wasmparser::TypeRef::Memory(ty) => ImportKind::Memory(convert_module_memory(ty)), wasmparser::TypeRef::Global(ty) => { - ImportKind::Global(GlobalType::new(convert_valtype(&ty.content_type), ty.mutable)) + ImportKind::Global(GlobalType::new(convert_valtype(&ty.content_type)?, ty.mutable)) } wasmparser::TypeRef::Tag(ty) => { return Err(crate::ParseError::UnsupportedOperator(format!("Unsupported import kind: {ty:?}"))); @@ -129,7 +129,7 @@ pub(crate) fn convert_module_table(table: wasmparser::Table<'_>) -> Result<Table let size_max = table.ty.maximum.map(|max| max.try_into()).transpose(); let size_max = size_max.map_err(|e| crate::ParseError::UnsupportedOperator(format!("Table size max is too large: {e}")))?; - Ok(TableType { element_type: convert_reftype(table.ty.element_type), size_initial, size_max }) + Ok(TableType { element_type: convert_reftype(table.ty.element_type)?, size_initial, size_max }) } pub(crate) fn convert_module_globals( @@ -139,7 +139,7 @@ pub(crate) fn convert_module_globals( .into_iter() .map(|global| { let global = global?; - let ty = convert_valtype(&global.ty.content_type); + let ty = convert_valtype(&global.ty.content_type)?; let ops = global.init_expr.get_operators_reader(); Ok(Global { init: process_const_operators(ops)?, ty: GlobalType::new(ty, global.ty.mutable) }) }) @@ -211,27 +211,37 @@ pub(crate) fn convert_module_type(ty: wasmparser::RecGroup) -> Result<Arc<FuncTy )); } - let ty = types.next().unwrap().unwrap_func(); + let ty = types.next().unwrap(); + let CompositeInnerType::Func(ty) = &ty.composite_type.inner else { + return Err(crate::ParseError::UnsupportedOperator(format!( + "Unsupported non-function type in type section: {}", + ty.composite_type + ))); + }; let params: Vec<_> = ty.params().iter().map(convert_valtype).collect(); - let results: Vec<_> = ty.results().iter().map(convert_valtype).collect(); + let params = params.into_iter().collect::<Result<Vec<_>>>()?; + let results = ty.results().iter().map(convert_valtype).collect::<Result<Vec<_>>>()?; Ok(FuncType::new(¶ms, &results).into()) } -pub(crate) fn convert_reftype(reftype: wasmparser::RefType) -> WasmType { +pub(crate) fn convert_reftype(reftype: wasmparser::RefType) -> Result<WasmType> { match reftype { - _ if reftype.is_func_ref() => WasmType::RefFunc, - _ if reftype.is_extern_ref() => WasmType::RefExtern, - _ => unimplemented!("Unsupported reference type: {:?}, {:?}", reftype, reftype.heap_type()), + _ if reftype.is_func_ref() => Ok(WasmType::RefFunc), + _ if reftype.is_extern_ref() => Ok(WasmType::RefExtern), + _ => Err(crate::ParseError::UnsupportedOperator(format!( + "Unsupported reference type: {reftype:?}, {:?}", + reftype.heap_type() + ))), } } -pub(crate) fn convert_valtype(valtype: &wasmparser::ValType) -> WasmType { +pub(crate) fn convert_valtype(valtype: &wasmparser::ValType) -> Result<WasmType> { match valtype { - wasmparser::ValType::I32 => WasmType::I32, - wasmparser::ValType::I64 => WasmType::I64, - wasmparser::ValType::F32 => WasmType::F32, - wasmparser::ValType::F64 => WasmType::F64, - wasmparser::ValType::V128 => WasmType::V128, + wasmparser::ValType::I32 => Ok(WasmType::I32), + wasmparser::ValType::I64 => Ok(WasmType::I64), + wasmparser::ValType::F32 => Ok(WasmType::F32), + wasmparser::ValType::F64 => Ok(WasmType::F64), + wasmparser::ValType::V128 => Ok(WasmType::V128), wasmparser::ValType::Ref(r) => convert_reftype(*r), } } @@ -247,10 +257,14 @@ pub(crate) fn process_const_operators(ops: OperatorsReader<'_>) -> Result<Box<[C let mut out = Vec::with_capacity(ops.len().saturating_sub(1)); for op in ops.iter().take(ops.len() - 1) { let instr = match op { - wasmparser::Operator::RefNull { hty } => match convert_heaptype(*hty) { + wasmparser::Operator::RefNull { hty } => match convert_heaptype(*hty)? { WasmType::RefFunc => ConstInstruction::RefFunc(None), WasmType::RefExtern => ConstInstruction::RefExtern(None), - _ => unimplemented!("Unsupported heap type: {:?}", hty), + other => { + return Err(crate::ParseError::UnsupportedOperator(format!( + "Unsupported ref.null heap type lowered to {other:?}" + ))); + } }, wasmparser::Operator::RefFunc { function_index } => ConstInstruction::RefFunc(Some(*function_index)), wasmparser::Operator::I32Const { value } => ConstInstruction::I32Const(*value), @@ -277,12 +291,14 @@ pub(crate) fn process_const_operators(ops: OperatorsReader<'_>) -> Result<Box<[C Ok(out.into_boxed_slice()) } -pub(crate) fn convert_heaptype(heap: wasmparser::HeapType) -> WasmType { +pub(crate) fn convert_heaptype(heap: wasmparser::HeapType) -> Result<WasmType> { match heap { - wasmparser::HeapType::Abstract { shared: false, ty: wasmparser::AbstractHeapType::Func } => WasmType::RefFunc, + wasmparser::HeapType::Abstract { shared: false, ty: wasmparser::AbstractHeapType::Func } => { + Ok(WasmType::RefFunc) + } wasmparser::HeapType::Abstract { shared: false, ty: wasmparser::AbstractHeapType::Extern } => { - WasmType::RefExtern + Ok(WasmType::RefExtern) } - _ => unimplemented!("Unsupported heap type: {:?}", heap), + _ => Err(crate::ParseError::UnsupportedOperator(format!("Unsupported heap type: {heap:?}"))), } } diff --git a/crates/parser/src/error.rs b/crates/parser/src/error.rs index 22edd39..7b5dc34 100644 --- a/crates/parser/src/error.rs +++ b/crates/parser/src/error.rs @@ -2,7 +2,7 @@ use alloc::string::{String, ToString}; use core::fmt::{Debug, Display}; use wasmparser::Encoding; -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq)] /// Errors that can occur when parsing a WebAssembly module pub enum ParseError { /// An invalid type was encountered diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs index c4f6ff7..c6ae326 100644 --- a/crates/parser/src/lib.rs +++ b/crates/parser/src/lib.rs @@ -283,7 +283,25 @@ impl Parser { continue; } - if eof || reader.end_reached { + if reader.end_reached { + if !buffer.is_empty() { + return Err(ParseError::Other("trailing bytes after end of module".into())); + } + + if !eof { + let read_bytes = Self::read_more(&mut stream, &mut buffer, 1)?; + eof = read_bytes == 0; + + if !eof { + return Err(ParseError::Other("trailing bytes after end of module".into())); + } + } + + reader.process_pending_functions(&self.options)?; + return reader.into_module(&self.options); + } + + if eof { reader.process_pending_functions(&self.options)?; return reader.into_module(&self.options); } diff --git a/crates/parser/src/module.rs b/crates/parser/src/module.rs index 02a3297..5f5e5e2 100644 --- a/crates/parser/src/module.rs +++ b/crates/parser/src/module.rs @@ -377,6 +377,15 @@ impl<'a> ModuleReader<'a> { }; let mut funcs = Vec::with_capacity(self.code.len()); + let mut func_type_idxs = self + .imports + .iter() + .filter_map(|import| match import.kind { + ImportKind::Function(type_idx) => Some(type_idx), + _ => None, + }) + .collect::<Vec<_>>(); + func_type_idxs.extend(self.code_type_addrs.iter().copied()); for (code, ty_idx) in self.code.into_iter().zip(self.code_type_addrs) { let ty = self.func_types.get(ty_idx as usize).expect("No func type for func, this is a bug").clone(); @@ -402,6 +411,7 @@ impl<'a> ModuleReader<'a> { Ok(ModuleInner { funcs: funcs.into(), func_types: self.func_types.into(), + func_type_idxs: func_type_idxs.into(), globals: self.globals.into(), table_types: self.table_types.into(), imports: self.imports.into(), diff --git a/crates/parser/src/visit.rs b/crates/parser/src/visit.rs index f8d5cfd..62db307 100644 --- a/crates/parser/src/visit.rs +++ b/crates/parser/src/visit.rs @@ -417,7 +417,12 @@ impl<'a, R: WasmModuleResources> wasmparser::VisitOperator<'a> for FunctionBuild // Reference Types fn visit_ref_null(&mut self, ty: wasmparser::HeapType) -> Self::Output { - self.instructions.push(Instruction::RefNull(convert_heaptype(ty))); + match convert_heaptype(ty) { + Ok(ty) => self.instructions.push(Instruction::RefNull(ty)), + Err(err) => { + self.error.get_or_insert(err); + } + }; } fn visit_typed_select_multi(&mut self, tys: Vec<wasmparser::ValType>) -> Self::Output { diff --git a/crates/tinywasm/src/error.rs b/crates/tinywasm/src/error.rs index 0d1f368..adac5a7 100644 --- a/crates/tinywasm/src/error.rs +++ b/crates/tinywasm/src/error.rs @@ -36,9 +36,6 @@ pub enum Error { /// An invalid label type was encountered InvalidLabelType, - /// The store is not the one that the module instance was instantiated in - InvalidStore, - #[cfg(feature = "std")] /// An I/O error occurred Io(crate::std::io::Error), @@ -51,9 +48,27 @@ pub enum Error { Twasm(TwasmError), } +impl PartialEq for Error { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (Self::Trap(a), Self::Trap(b)) => a == b, + (Self::Linker(a), Self::Linker(b)) => a == b, + (Self::UnsupportedFeature(a), Self::UnsupportedFeature(b)) => a == b, + (Self::Other(a), Self::Other(b)) => a == b, + #[cfg(feature = "std")] + (Self::Io(a), Self::Io(b)) => a.kind() == b.kind(), + #[cfg(feature = "parser")] + (Self::Parser(a), Self::Parser(b)) => a == b, + (Self::Twasm(a), Self::Twasm(b)) => a == b, + _ => false, + } + } +} + /// Errors that can occur when linking a WebAssembly module #[non_exhaustive] #[cfg_attr(feature = "debug", derive(Debug))] +#[derive(PartialEq, Eq)] pub enum LinkingError { /// An unknown import was encountered UnknownImport { @@ -120,6 +135,9 @@ pub enum Trap { /// Invalid Integer Conversion InvalidConversionToInt, + /// The store is not the one that the module instance was instantiated in + InvalidStore, + /// Integer Overflow IntegerOverflow, @@ -173,11 +191,18 @@ impl Trap { Self::UninitializedElement { .. } => "uninitialized element", Self::IndirectCallTypeMismatch { .. } => "indirect call type mismatch", Self::HostFunction(_) => "host function trap", + Self::InvalidStore => "invalid store", Self::Other(message) => message, } } } +impl PartialEq for Trap { + fn eq(&self, other: &Self) -> bool { + self.message() == other.message() + } +} + impl LinkingError { /// Get the message of the linking error pub fn message(&self) -> &'static str { @@ -199,6 +224,7 @@ impl From<TwasmError> for Error { Self::Twasm(value) } } + impl From<Trap> for Error { fn from(value: Trap) -> Self { Self::Trap(value) @@ -226,7 +252,6 @@ impl Display for Error { } #[cfg(not(feature = "debug"))] Self::InvalidHostFnReturn { .. } => write!(f, "invalid host function return"), - Self::InvalidStore => write!(f, "invalid store"), } } } @@ -264,6 +289,7 @@ impl Display for Trap { Self::UninitializedElement { index } => { write!(f, "uninitialized element: index={index}") } + Self::InvalidStore => write!(f, "invalid store"), #[cfg(feature = "debug")] Self::IndirectCallTypeMismatch { expected, actual } => { write!(f, "indirect call type mismatch: expected={expected:?}, actual={actual:?}") diff --git a/crates/tinywasm/src/instance.rs b/crates/tinywasm/src/instance.rs index 8ef572d..e5a2d88 100644 --- a/crates/tinywasm/src/instance.rs +++ b/crates/tinywasm/src/instance.rs @@ -6,7 +6,7 @@ use alloc::{format, rc::Rc}; use tinywasm_types::*; use crate::func::{FromWasmValueTuple, IntoWasmValueTuple, WasmTypesFromTuple}; -use crate::{Error, Function, FunctionTyped, Global, Imports, Memory, Result, Store, Table}; +use crate::{Error, Function, FunctionTyped, Global, Imports, Memory, Result, Store, Table, Trap}; /// A typed view over an exported extern value. pub enum ExternItem { @@ -34,6 +34,7 @@ struct ModuleInstanceInner { store_id: usize, idx: ModuleInstanceAddr, types: Arc<[Arc<FuncType>]>, + func_type_idxs: Arc<[u32]>, func_addrs: Box<[FuncAddr]>, table_addrs: Box<[TableAddr]>, mem_addrs: Box<[MemAddr]>, @@ -50,12 +51,25 @@ impl ModuleInstance { self.0.idx } + /// Type indices come from the module type section and are used by indirect calls. #[inline] - pub(crate) fn func_ty(&self, addr: FuncAddr) -> &Arc<FuncType> { - match self.0.types.get(addr as usize) { + pub(crate) fn func_type_by_type_index(&self, type_idx: u32) -> &Arc<FuncType> { + match self.0.types.get(type_idx as usize) { Some(ty) => ty, None => { cold_path(); + unreachable!("invalid type index: {type_idx}") + } + } + } + + /// Function indices need their own lookup because they are not type-section indices. + #[inline] + pub(crate) fn func_type_idx(&self, addr: FuncAddr) -> u32 { + match self.0.func_type_idxs.get(addr as usize) { + Some(idx) => *idx, + None => { + cold_path(); unreachable!("invalid function address: {addr}") } } @@ -66,7 +80,7 @@ impl ModuleInstance { &self.0.func_addrs } - // resolve a function address to the global store address + /// resolve a function address to the global store address #[inline] pub(crate) fn resolve_func_addr(&self, addr: FuncAddr) -> FuncAddr { match self.0.func_addrs.get(addr as usize) { @@ -78,7 +92,7 @@ impl ModuleInstance { } } - // resolve a table address to the global store address + /// resolve a table address to the global store address #[inline] pub(crate) fn resolve_table_addr(&self, addr: TableAddr) -> TableAddr { match self.0.table_addrs.get(addr as usize) { @@ -90,7 +104,7 @@ impl ModuleInstance { } } - // resolve a memory address to the global store address + /// resolve a memory address to the global store address #[inline] pub(crate) fn resolve_mem_addr(&self, addr: MemAddr) -> MemAddr { match self.0.mem_addrs.get(addr as usize) { @@ -102,7 +116,7 @@ impl ModuleInstance { } } - // resolve a data address to the global store address + /// resolve a data address to the global store address #[inline] pub(crate) fn resolve_data_addr(&self, addr: DataAddr) -> DataAddr { match self.0.data_addrs.get(addr as usize) { @@ -114,7 +128,7 @@ impl ModuleInstance { } } - // resolve an element address to the global store address + /// resolve an element address to the global store address #[inline] pub(crate) fn resolve_elem_addr(&self, addr: ElemAddr) -> ElemAddr { match self.0.elem_addrs.get(addr as usize) { @@ -126,7 +140,7 @@ impl ModuleInstance { } } - // resolve a global address to the global store address + /// resolve a global address to the global store address #[inline] pub(crate) fn resolve_global_addr(&self, addr: GlobalAddr) -> GlobalAddr { match self.0.global_addrs.get(addr as usize) { @@ -142,7 +156,7 @@ impl ModuleInstance { pub(crate) fn validate_store(&self, store: &Store) -> Result<()> { if self.0.store_id != store.id() { cold_path(); - return Err(Error::InvalidStore); + return Err(Trap::InvalidStore.into()); } Ok(()) } @@ -167,7 +181,6 @@ impl ModuleInstance { pub fn instantiate_no_start(store: &mut Store, module: &Module, imports: Option<Imports>) -> Result<Self> { let idx = store.next_module_instance_idx(); let mut addrs = imports.unwrap_or_default().link(store, module)?; - addrs.funcs.extend(store.init_funcs(&module.funcs, idx)); addrs.tables.extend(store.init_tables(&module.table_types)); match module.local_memory_allocation { @@ -186,6 +199,7 @@ impl ModuleInstance { store_id: store.id(), idx, types: module.func_types.clone(), + func_type_idxs: module.func_type_idxs.clone(), func_addrs: addrs.funcs.into_boxed_slice(), table_addrs: addrs.tables.into_boxed_slice(), mem_addrs: addrs.memories.into_boxed_slice(), @@ -230,7 +244,7 @@ impl ModuleInstance { item: crate::StoreItem::new(self.0.store_id, func_addr), module_addr: self.id(), addr: func_addr, - ty: self.func_ty(export.index).clone(), + ty: self.func_type_by_type_index(self.func_type_idx(export.index)).clone(), }) } ExternalKind::Table => { @@ -281,7 +295,7 @@ impl ModuleInstance { item: crate::StoreItem::new(self.0.store_id, addr), module_addr: self.id(), addr, - ty: self.func_ty(export.index).clone(), + ty: self.func_type_by_type_index(self.func_type_idx(export.index)).clone(), })) } ExternVal::Memory(addr) => Ok(ExternItem::Memory(Memory::from_store_addr(self.0.store_id, addr))), @@ -461,19 +475,24 @@ impl ModuleInstance { pub fn start_func(&self, store: &Store) -> Result<Option<Function>> { self.validate_store(store)?; - let func_index = match self.0.func_start { + let func_addr = match self.0.func_start { Some(func_index) => func_index, None => { - // alternatively, check for a _start function in the exports + // Alternatively, check for a _start function in the exports. let Some(ExternVal::Func(func_addr)) = self.export_addr("_start") else { return Ok(None); }; - func_addr + return Ok(Some(Function { + item: crate::StoreItem::new(self.0.store_id, func_addr), + module_addr: self.id(), + addr: func_addr, + ty: store.state.get_func(func_addr).ty().clone(), + })); } }; - let func_addr = self.resolve_func_addr(func_index); + let func_addr = self.resolve_func_addr(func_addr); Ok(Some(Function { item: crate::StoreItem::new(self.0.store_id, func_addr), module_addr: self.id(), diff --git a/crates/tinywasm/src/interpreter/executor.rs b/crates/tinywasm/src/interpreter/executor.rs index 4d862d6..4c941c8 100644 --- a/crates/tinywasm/src/interpreter/executor.rs +++ b/crates/tinywasm/src/interpreter/executor.rs @@ -1046,7 +1046,7 @@ impl<'store, const BUDGETED: bool> Executor<'store, BUDGETED> { return Err(Trap::UninitializedElement { index: table_idx as usize }); }; - let call_ty = self.module.func_ty(type_addr); + let call_ty = self.module.func_type_by_type_index(type_addr); match self.store.state.get_func(func_ref) { crate::FunctionInstance::Wasm(wasm_func) => { if wasm_func.ty() != call_ty { diff --git a/crates/tinywasm/src/reference.rs b/crates/tinywasm/src/reference.rs index 5f8d46f..8f02317 100644 --- a/crates/tinywasm/src/reference.rs +++ b/crates/tinywasm/src/reference.rs @@ -7,8 +7,7 @@ use alloc::{ffi::CString, format}; use crate::store::{GlobalInstance, TableElement, TableInstance}; use crate::{Error, MemoryInstance, Result, Store, Trap}; use tinywasm_types::{ - Addr, ExternRef, FuncRef, GlobalAddr, GlobalType, MemAddr, MemoryArch, MemoryType, TableAddr, TableType, WasmType, - WasmValue, + Addr, ExternRef, FuncRef, GlobalAddr, GlobalType, MemAddr, MemoryType, TableAddr, TableType, WasmType, WasmValue, }; #[derive(Clone, Copy, PartialEq, Eq, Hash)] @@ -27,7 +26,7 @@ impl StoreItem { #[inline] pub(crate) fn validate_store(&self, store: &Store) -> Result<(), Trap> { if self.store_id != store.id() { - return Err(Trap::Other("invalid store")); + return Err(Trap::InvalidStore); } Ok(()) } @@ -146,9 +145,6 @@ impl Memory { /// Create a new memory in the given store. pub fn new(store: &mut Store, ty: MemoryType) -> Result<Self> { - if let MemoryArch::I64 = ty.arch() { - return Err(Error::UnsupportedFeature("64-bit memories")); - } let addr = store.state.memories.len() as MemAddr; store.state.memories.push(MemoryInstance::new(ty, &store.engine.config().memory_backend)?); Ok(Self::from_store_addr(store.id(), addr)) @@ -399,7 +395,8 @@ impl Table { /// Grow the table and return the previous size. pub fn grow(&self, store: &mut Store, delta: i32, init: WasmValue) -> Result<usize> { - let table = self.instance_mut(store)?; + self.0.validate_store(store)?; + let table = store.state.get_table_mut(self.0.addr); let old_size = table.size() as usize; let init = table_value_to_element(table.kind.element_type, init)?; table.grow(delta, init)?; @@ -415,6 +412,10 @@ impl Global { /// Create a new global in the given store. pub fn new(store: &mut Store, ty: GlobalType, value: WasmValue) -> Result<Self> { + if WasmType::from(value) != ty.ty { + cold_path(); + return Err(Error::Other("invalid global value type".to_string())); + } let addr = store.state.globals.len() as GlobalAddr; store.state.globals.push(GlobalInstance::new(ty, value.into())); Ok(Self::from_store_addr(store.id(), addr)) diff --git a/crates/tinywasm/src/store/memory/mod.rs b/crates/tinywasm/src/store/memory/mod.rs index 50ad520..2e58939 100644 --- a/crates/tinywasm/src/store/memory/mod.rs +++ b/crates/tinywasm/src/store/memory/mod.rs @@ -103,8 +103,8 @@ pub trait LinearMemory { let mut offset = 0; while offset < len { let chunk_len = min(len - offset, 1024); - let chunk = vec![0; chunk_len]; - self.read_exact(src + offset, &mut chunk.clone())?; + let mut chunk = vec![0; chunk_len]; + self.read_exact(src + offset, &mut chunk)?; self.write_all(dst + offset, &chunk)?; offset += chunk_len; } @@ -114,8 +114,8 @@ pub trait LinearMemory { while offset > 0 { let chunk_len = min(offset, 1024); offset -= chunk_len; - let chunk = vec![0; chunk_len]; - self.read_exact(src + offset, &mut chunk.clone())?; + let mut chunk = vec![0; chunk_len]; + self.read_exact(src + offset, &mut chunk)?; self.write_all(dst + offset, &chunk)?; } } diff --git a/crates/tinywasm/src/store/mod.rs b/crates/tinywasm/src/store/mod.rs index 2b8ba73..a4d26e3 100644 --- a/crates/tinywasm/src/store/mod.rs +++ b/crates/tinywasm/src/store/mod.rs @@ -249,7 +249,7 @@ impl State { } /// Get the global at the actual index in the store - pub(crate) fn get_global_val(&self, addr: MemAddr) -> TinyWasmValue { + pub(crate) fn get_global_val(&self, addr: GlobalAddr) -> TinyWasmValue { match self.globals.get(addr as usize) { Some(global) => global.value.get(), None => { @@ -260,7 +260,7 @@ impl State { } /// Set the global at the actual index in the store - pub(crate) fn set_global_val(&mut self, addr: MemAddr, value: TinyWasmValue) { + pub(crate) fn set_global_val(&mut self, addr: GlobalAddr, value: TinyWasmValue) { match self.globals.get_mut(addr as usize) { Some(global) => global.value.set(value), None => { @@ -288,13 +288,13 @@ impl Store { /// Get the global at the actual index in the store #[doc(hidden)] - pub fn get_global_val(&self, addr: MemAddr) -> TinyWasmValue { + pub fn get_global_val(&self, addr: GlobalAddr) -> TinyWasmValue { self.state.get_global_val(addr) } /// Set the global at the actual index in the store #[doc(hidden)] - pub fn set_global_val(&mut self, addr: MemAddr, value: TinyWasmValue) { + pub fn set_global_val(&mut self, addr: GlobalAddr, value: TinyWasmValue) { self.state.set_global_val(addr, value); } } diff --git a/crates/tinywasm/tests/import_linking.rs b/crates/tinywasm/tests/import_linking.rs index 712148e..e7948fa 100644 --- a/crates/tinywasm/tests/import_linking.rs +++ b/crates/tinywasm/tests/import_linking.rs @@ -1,5 +1,5 @@ use eyre::Result; -use tinywasm::{Error, Imports, Module, ModuleInstance, Store}; +use tinywasm::{Error, Imports, Module, ModuleInstance, Store, Trap}; const WASM_ADD: &str = r#" (module @@ -52,6 +52,6 @@ fn link_module_rejects_cross_store_instance() -> Result<()> { imports.link_module("adder", add_instance)?; let err = ModuleInstance::instantiate(&mut target_store, &import_module, Some(imports)).unwrap_err(); - assert!(matches!(err, Error::InvalidStore)); + assert_eq!(err, Error::from(Trap::InvalidStore)); Ok(()) } diff --git a/crates/tinywasm/tests/internal_refs.rs b/crates/tinywasm/tests/internal_refs.rs index 9e96d4c..2382597 100644 --- a/crates/tinywasm/tests/internal_refs.rs +++ b/crates/tinywasm/tests/internal_refs.rs @@ -94,3 +94,100 @@ fn extern_item_lookup_returns_expected_kinds() -> Result<()> { Ok(()) } + +#[test] +fn extern_item_and_exports_use_actual_function_type() -> Result<()> { + let wasm = wat::parse_str( + r#" + (module + (type $local_ty (func)) + (type $import_ty (func (param i64))) + (import "host" "imported" (func (type $import_ty))) + (func (export "f") (type $local_ty) + nop) + ) + "#, + )?; + + let module = tinywasm::parse_bytes(&wasm)?; + let mut store = Store::default(); + let mut imports = tinywasm::Imports::new(); + imports.define( + "host", + "imported", + tinywasm::HostFunction::from(&mut store, |_ctx: tinywasm::FuncContext<'_>, _arg: i64| Ok(())), + ); + let instance = ModuleInstance::instantiate(&mut store, &module, Some(imports))?; + + let ExternItem::Func(func) = instance.extern_item("f")? else { panic!("expected function export") }; + assert_eq!(func.call(&mut store, &[])?, vec![]); + + let (_, ExternItem::Func(func)) = instance.exports().find(|(name, _)| *name == "f").expect("export f not found") + else { + panic!("expected function export") + }; + assert_eq!(func.call(&mut store, &[])?, vec![]); + + Ok(()) +} + +#[test] +fn export_func_type_index_mismatch_fixture_would_break_old_lookup() -> Result<()> { + let wasm = wat::parse_str( + r#" + (module + (type $local_ty (func)) + (type $import_ty (func (param i64))) + (import "spectest" "print_i64" (func (type $import_ty))) + (func (export "f") (type $local_ty) + nop) + ) + "#, + )?; + let module = tinywasm::parse_bytes(&wasm)?; + + let export = module.exports.iter().find(|export| export.name.as_ref() == "f").expect("export f not found"); + let old_lookup_ty = module.func_types.get(export.index as usize).expect("old lookup type missing"); + + assert_eq!(old_lookup_ty.params(), &[tinywasm::types::WasmType::I64]); + assert_eq!(module.funcs[0].ty.params(), &[]); + assert_ne!(old_lookup_ty.params(), module.funcs[0].ty.params()); + + let mut store = Store::default(); + let mut imports = tinywasm::Imports::new(); + imports.define( + "spectest", + "print_i64", + tinywasm::HostFunction::from(&mut store, |_ctx: tinywasm::FuncContext<'_>, _arg: i64| Ok(())), + ); + let instance = ModuleInstance::instantiate(&mut store, &module, Some(imports))?; + + let ExternItem::Func(func) = instance.extern_item("f")? else { panic!("expected function export") }; + assert_eq!(func.call(&mut store, &[])?, vec![]); + + Ok(()) +} + +#[test] +fn start_prefers_exported_start_without_re_resolving_store_addr() -> Result<()> { + let wasm = wat::parse_str( + r#" + (module + (global (export "g") (mut i32) (i32.const 0)) + (func (export "_start") + i32.const 1 + global.set 0) + ) + "#, + )?; + + let module = tinywasm::parse_bytes(&wasm)?; + let mut store = Store::default(); + let _unused = tinywasm::HostFunction::from(&mut store, |_ctx: tinywasm::FuncContext<'_>, (): ()| Ok(())); + let instance = ModuleInstance::instantiate_no_start(&mut store, &module, None)?; + + instance.start(&mut store)?; + assert_eq!(instance.global_get(&store, "g")?, WasmValue::I32(1)); + + Ok(()) +} diff --git a/crates/tinywasm/tests/module_descriptors.rs b/crates/tinywasm/tests/module_descriptors.rs index 3804df8..d7fabfa 100644 --- a/crates/tinywasm/tests/module_descriptors.rs +++ b/crates/tinywasm/tests/module_descriptors.rs @@ -89,3 +89,66 @@ fn module_descriptors_resolve_imported_and_local_export_types() -> Result<()> { Ok(()) } + +#[test] +fn module_descriptors_resolve_imported_and_local_table_and_memory_exports() -> Result<()> { + let wasm = wat::parse_str( + r#" + (module + (import "host" "itable" (table 2 4 funcref)) + (import "host" "imemory" (memory 1 3)) + (table $ltable 5 7 funcref) + (memory $lmemory 2 6) + (export "itable_export" (table 0)) + (export "imemory_export" (memory 0)) + (export "ltable_export" (table 1)) + (export "lmemory_export" (memory 1)) + ) + "#, + )?; + + let module = tinywasm::parse_bytes(&wasm)?; + let exports: Vec<_> = module.exports().collect(); + + let itable_export = exports.iter().find(|export| export.name == "itable_export").expect("itable export not found"); + match itable_export.ty { + ExportType::Table(ty) => { + assert_eq!(ty.element_type, WasmType::RefFunc); + assert_eq!(ty.size_initial, 2); + assert_eq!(ty.size_max, Some(4)); + } + _ => panic!("itable export should resolve to imported table type"), + } + + let imemory_export = + exports.iter().find(|export| export.name == "imemory_export").expect("imemory export not found"); + match imemory_export.ty { + ExportType::Memory(ty) => { + assert_eq!(ty.page_count_initial(), 1); + assert_eq!(ty.page_count_max(), 3); + } + _ => panic!("imemory export should resolve to imported memory type"), + } + + let ltable_export = exports.iter().find(|export| export.name == "ltable_export").expect("ltable export not found"); + match ltable_export.ty { + ExportType::Table(ty) => { + assert_eq!(ty.element_type, WasmType::RefFunc); + assert_eq!(ty.size_initial, 5); + assert_eq!(ty.size_max, Some(7)); + } + _ => panic!("ltable export should resolve to local table type"), + } + + let lmemory_export = + exports.iter().find(|export| export.name == "lmemory_export").expect("lmemory export not found"); + match lmemory_export.ty { + ExportType::Memory(ty) => { + assert_eq!(ty.page_count_initial(), 2); + assert_eq!(ty.page_count_max(), 6); + } + _ => panic!("lmemory export should resolve to local memory type"), + } + + Ok(()) +} diff --git a/crates/tinywasm/tests/store_ownership.rs b/crates/tinywasm/tests/store_ownership.rs index acf8e42..61cc88c 100644 --- a/crates/tinywasm/tests/store_ownership.rs +++ b/crates/tinywasm/tests/store_ownership.rs @@ -38,7 +38,51 @@ fn memory_access_rejects_wrong_store() -> Result<()> { let memory = instance.memory("memory")?; let other_store = Store::default(); let err = memory.len(&other_store).unwrap_err(); - assert!(err.to_string().contains("invalid store")); + assert_eq!(err, tinywasm::Error::Trap(tinywasm::Trap::InvalidStore)); + + Ok(()) +} + +#[test] +fn global_access_rejects_wrong_store() -> Result<()> { + let wasm = wat::parse_str( + r#" + (module + (global (export "g") (mut i32) (i32.const 1)) + ) + "#, + )?; + let module = tinywasm::parse_bytes(&wasm)?; + + let mut owner_store = Store::default(); + let instance = ModuleInstance::instantiate(&mut owner_store, &module, None)?; + let global = instance.global("g")?; + + let other_store = Store::default(); + let err = global.get(&other_store).unwrap_err(); + assert_eq!(err, tinywasm::Error::Trap(tinywasm::Trap::InvalidStore)); + + Ok(()) +} + +#[test] +fn table_grow_rejects_wrong_store_with_invalid_store_error() -> Result<()> { + let wasm = wat::parse_str( + r#" + (module + (table (export "t") 1 funcref) + ) + "#, + )?; + let module = tinywasm::parse_bytes(&wasm)?; + + let mut owner_store = Store::default(); + let instance = ModuleInstance::instantiate(&mut owner_store, &module, None)?; + let table = instance.table("t")?; + + let mut other_store = Store::default(); + let err = table.grow(&mut other_store, 1, tinywasm::types::FuncRef::null().into()).unwrap_err(); + assert_eq!(err, tinywasm::Error::Trap(tinywasm::Trap::InvalidStore)); Ok(()) } diff --git a/crates/types/src/archive.rs b/crates/types/src/archive.rs index 2636230..92bb87a 100644 --- a/crates/types/src/archive.rs +++ b/crates/types/src/archive.rs @@ -23,7 +23,7 @@ fn validate_magic(wasm: &[u8]) -> Result<usize, TwasmError> { Ok(TWASM_MAGIC.len()) } -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq)] pub enum TwasmError { InvalidMagic, InvalidVersion, diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index b65e4b7..8057518 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -101,6 +101,9 @@ pub struct ModuleInner { /// Corresponds to the `type` section of the original WebAssembly module. pub func_types: Arc<[Arc<FuncType>]>, + /// Function index to type index mapping in module index space, including imports. + pub func_type_idxs: Arc<[u32]>, + /// Exported items of the WebAssembly module. /// /// Corresponds to the `export` section of the original WebAssembly module. @@ -161,6 +164,22 @@ impl Module { /// /// The returned data mirrors the module's export section and preserves order. pub fn exports(&self) -> impl Iterator<Item = ModuleExport<'_>> { + fn imported_count(module: &ModuleInner, kind: ExternalKind) -> usize { + module + .imports + .iter() + .filter(|import| { + matches!( + (kind, &import.kind), + (ExternalKind::Func, ImportKind::Function(_)) + | (ExternalKind::Table, ImportKind::Table(_)) + | (ExternalKind::Memory, ImportKind::Memory(_)) + | (ExternalKind::Global, ImportKind::Global(_)) + ) + }) + .count() + } + fn imported_func_type(module: &ModuleInner, function_index: usize) -> Option<&FuncType> { let mut seen = 0usize; for import in module.imports.iter() { @@ -174,6 +193,32 @@ impl Module { None } + fn imported_table_type(module: &ModuleInner, table_index: usize) -> Option<&TableType> { + let mut seen = 0usize; + for import in module.imports.iter() { + if let ImportKind::Table(table_ty) = &import.kind { + if seen == table_index { + return Some(table_ty); + } + seen += 1; + } + } + None + } + + fn imported_memory_type(module: &ModuleInner, memory_index: usize) -> Option<&MemoryType> { + let mut seen = 0usize; + for import in module.imports.iter() { + if let ImportKind::Memory(memory_ty) = &import.kind { + if seen == memory_index { + return Some(memory_ty); + } + seen += 1; + } + } + None + } + fn imported_global_type(module: &Module, global_index: usize) -> Option<&GlobalType> { let mut seen = 0usize; for import in module.imports.iter() { @@ -188,12 +233,10 @@ impl Module { } self.0.exports.iter().filter_map(move |export| { - let imports = self.0.imports.iter(); let idx = export.index as usize; let ty = match export.kind { ExternalKind::Func => { - let imported_funcs = - imports.filter(|import| matches!(import.kind, ImportKind::Function(_))).count(); + let imported_funcs = imported_count(&self.0, ExternalKind::Func); if idx < imported_funcs { ExportType::Func(imported_func_type(&self.0, idx)?) } else { @@ -201,11 +244,26 @@ impl Module { ExportType::Func(&self.0.funcs.get(local_idx)?.ty) } } - ExternalKind::Table => ExportType::Table(self.0.table_types.get(idx)?), - ExternalKind::Memory => ExportType::Memory(self.0.memory_types.get(idx)?), + ExternalKind::Table => { + let imported_tables = imported_count(&self.0, ExternalKind::Table); + if idx < imported_tables { + ExportType::Table(imported_table_type(&self.0, idx)?) + } else { + let local_idx = idx - imported_tables; + ExportType::Table(self.0.table_types.get(local_idx)?) + } + } + ExternalKind::Memory => { + let imported_memories = imported_count(&self.0, ExternalKind::Memory); + if idx < imported_memories { + ExportType::Memory(imported_memory_type(&self.0, idx)?) + } else { + let local_idx = idx - imported_memories; + ExportType::Memory(self.0.memory_types.get(local_idx)?) + } + } ExternalKind::Global => { - let imported_globals = - imports.filter(|import| matches!(import.kind, ImportKind::Global(_))).count(); + let imported_globals = imported_count(&self.0, ExternalKind::Global); if idx < imported_globals { ExportType::Global(imported_global_type(self, idx)?) } else { diff --git a/crates/types/src/value.rs b/crates/types/src/value.rs index 20c822e..c57edc0 100644 --- a/crates/types/src/value.rs +++ b/crates/types/src/value.rs @@ -341,8 +341,7 @@ impl From<WasmValue> for WasmType { } /// Type of a WebAssembly value. -#[derive(Clone, Copy, PartialEq, Eq)] -#[cfg_attr(feature = "debug", derive(Debug))] +#[derive(Clone, Copy, PartialEq, Eq, Debug)] #[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))] pub enum WasmType { /// A 32-bit integer. diff --git a/examples/doom/Cargo.toml b/examples/doom/Cargo.toml index c1d0af4..62710de 100644 --- a/examples/doom/Cargo.toml +++ b/examples/doom/Cargo.toml @@ -1,13 +1,15 @@ +# treat this as an independent package +[workspace] + [package] name="tinywasm-doom" publish=false -edition.workspace=true -rust-version.workspace=true +edition="2024" [dependencies] -eyre.workspace=true -pretty_env_logger.workspace=true -tinywasm={workspace=true, features=[ +eyre="0.6" +pretty_env_logger="0.5" +tinywasm={features=[ "std", "parser", "log", @@ -15,7 +17,7 @@ tinywasm={workspace=true, features=[ "canonicalize-nans", "debug", "parallel-parser", -]} -log.workspace=true +], path="../../crates/tinywasm"} +log="0.4" softbuffer="0.4" winit="0.30" diff --git a/examples/doom/README.md b/examples/doom/README.md index f3bc60e..7438563 100644 --- a/examples/doom/README.md +++ b/examples/doom/README.md @@ -10,10 +10,12 @@ This example builds a WebAssembly guest from [`PureDOOM`](https://github.com/Dai ## Running the example +From the root of the repository, run: + ```sh # download & build `PureDOOM` ./examples/doom/build.sh # start doom with the WAD you want to use -cargo run -p tinywasm-doom --release -- /path/to/DOOM1.WAD +cargo doom /path/to/doom.wad ``` diff --git a/examples/doom/out/.gitkeep b/examples/doom/out/.gitkeep deleted file mode 100644 index e69de29..0000000 --- a/examples/doom/out/.gitkeep +++ /dev/null diff --git a/examples/rust/Cargo.toml b/examples/rust/Cargo.toml index 73aa815..97f9674 100644 --- a/examples/rust/Cargo.toml +++ b/examples/rust/Cargo.toml @@ -1,12 +1,9 @@ -cargo-features=["per-package-target"] - # treat this as an independent package [workspace] [package] publish=false name="rust-wasm-examples" -forced-target="wasm32-unknown-unknown" edition="2021" [dependencies] |
