diff options
| author | Henry Gressmann <mail@henrygressmann.de> | 2023-12-01 14:06:05 +0100 |
|---|---|---|
| committer | Henry Gressmann <mail@henrygressmann.de> | 2023-12-01 14:06:05 +0100 |
| commit | b9b517375c1f8c50c0096ef61d2395decf071914 (patch) | |
| tree | c524ed3cd702a2c7b261e8bdfac59887b1ca5c4e | |
| parent | 871398ff821255debdbd9452e46ca55a05e8cb92 (diff) | |
chore: move TinyWasmModule to types
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
| -rw-r--r-- | Cargo.lock | 66 | ||||
| -rw-r--r-- | crates/parser/src/lib.rs | 18 | ||||
| -rw-r--r-- | crates/types/Cargo.toml | 2 | ||||
| -rw-r--r-- | crates/types/src/lib.rs | 15 |
4 files changed, 81 insertions, 20 deletions
@@ -36,7 +36,7 @@ dependencies = [ "argh_shared", "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -219,6 +219,26 @@ dependencies = [ ] [[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] name = "quote" version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -228,12 +248,40 @@ dependencies = [ ] [[package]] +name = "rkyv" +version = "0.7.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58" +dependencies = [ + "ptr_meta", + "rkyv_derive", + "seahash", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2e06b915b5c230a17d7a736d1e2e63ee753c256a8614ef3f5147b13a4f5541d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] name = "rustc-demangle" version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] name = "serde" version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -250,7 +298,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -270,6 +318,17 @@ checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" @@ -323,6 +382,7 @@ dependencies = [ name = "tinywasm-types" version = "0.0.0" dependencies = [ + "rkyv", "tracing", ] @@ -345,7 +405,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs index 39bb1c6..d2b6d9c 100644 --- a/crates/parser/src/lib.rs +++ b/crates/parser/src/lib.rs @@ -9,10 +9,9 @@ extern crate std; mod conversion; mod error; mod module; -use alloc::boxed::Box; pub use error::*; use module::ModuleReader; -use tinywasm_types::{Export, FuncType, Function}; +use tinywasm_types::TinyWasmModule; pub struct Parser {} @@ -45,21 +44,6 @@ impl Parser { } } -pub struct TinyWasmModule { - pub version: Option<u16>, - pub start_func: Option<u32>, - - pub types: Option<Box<[FuncType]>>, - pub funcs: Option<Box<[Function]>>, - pub exports: Option<Box<[Export]>>, - // pub tables: Option<TableType>, - // pub memories: Option<MemoryType>, - // pub globals: Option<GlobalType>, - // pub elements: Option<ElementSectionReader<'a>>, - // pub imports: Option<ImportSectionReader<'a>>, - // pub data_segments: Option<DataSectionReader<'a>>, -} - impl TryFrom<ModuleReader<'_>> for TinyWasmModule { type Error = ParseError; diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml index 83263a6..fa2fc6e 100644 --- a/crates/types/Cargo.toml +++ b/crates/types/Cargo.toml @@ -5,7 +5,9 @@ edition="2021" [dependencies] tracing={version="0.1.38", default-features=false} # logging +rkyv={version="0.7", optional=true, default-features=false} [features] default=["std"] std=[] +serialize=["dep:rkyv"] diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index e68efe7..e793b26 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -3,6 +3,21 @@ extern crate alloc; mod instructions; pub use instructions::*; +pub struct TinyWasmModule { + pub version: Option<u16>, + pub start_func: Option<u32>, + + pub types: Option<Box<[FuncType]>>, + pub funcs: Option<Box<[Function]>>, + pub exports: Option<Box<[Export]>>, + // pub tables: Option<TableType>, + // pub memories: Option<MemoryType>, + // pub globals: Option<GlobalType>, + // pub elements: Option<ElementSectionReader<'a>>, + // pub imports: Option<ImportSectionReader<'a>>, + // pub data_segments: Option<DataSectionReader<'a>>, +} + /// A WebAssembly value. /// See https://webassembly.github.io/spec/core/syntax/types.html#value-types #[derive(Debug, Clone, PartialEq)] |
