summaryrefslogtreecommitdiff
path: root/crates/parser/src
diff options
context:
space:
mode:
authorHenry Gressmann <mail@henrygressmann.de>2024-01-29 20:39:31 +0100
committerHenry Gressmann <mail@henrygressmann.de>2024-01-29 20:39:31 +0100
commitf8651619e576ac97209b72660144568b54eb965c (patch)
tree6bbf232f2b7444d02ef6cb2192759f628ce2ab8f /crates/parser/src
parent4c9385df1bcc0098c7e1db7a2f7c7e3dbeb00c8b (diff)
feat: pre-processed wasm
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'crates/parser/src')
-rw-r--r--crates/parser/src/lib.rs22
1 files changed, 8 insertions, 14 deletions
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs
index edcd280..c608232 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -25,7 +25,7 @@ mod module;
use alloc::{string::ToString, vec::Vec};
pub use error::*;
use module::ModuleReader;
-use tinywasm_types::WasmFunction;
+use tinywasm_types::{TypedWasmFunction, WasmFunction};
use wasmparser::Validator;
pub use tinywasm_types::TinyWasmModule;
@@ -116,19 +116,13 @@ impl TryFrom<ModuleReader> for TinyWasmModule {
.code
.into_iter()
.zip(code_type_addrs)
- .map(|(f, ty_idx)| {
- (
- ty_idx,
- WasmFunction {
- instructions: f.body,
- locals: f.locals,
- ty: reader
- .func_types
- .get(ty_idx as usize)
- .expect("No func type for func, this is a bug")
- .clone(),
- },
- )
+ .map(|(f, ty_idx)| TypedWasmFunction {
+ type_addr: ty_idx,
+ wasm_function: WasmFunction {
+ instructions: f.body,
+ locals: f.locals,
+ ty: reader.func_types.get(ty_idx as usize).expect("No func type for func, this is a bug").clone(),
+ },
})
.collect::<Vec<_>>();