diff options
| author | Henry <mail@henrygressmann.de> | 2026-08-27 16:06:57 +0200 |
|---|---|---|
| committer | Henry <mail@henrygressmann.de> | 2026-08-27 16:06:57 +0200 |
| commit | 843e0ff5601479239791f452bec9865df779839b (patch) | |
| tree | 622e042f6f6cacec2a72c70f22816e8296997e41 /crates/parser/src/macros.rs | |
| parent | a8f42e481e9cc56834c39f073236c25cb533efc6 (diff) | |
chore: simplify operands, extract more exec_ methods
Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'crates/parser/src/macros.rs')
| -rw-r--r-- | crates/parser/src/macros.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/crates/parser/src/macros.rs b/crates/parser/src/macros.rs index 5e675e6..f807c0f 100644 --- a/crates/parser/src/macros.rs +++ b/crates/parser/src/macros.rs @@ -72,7 +72,10 @@ pub(crate) mod visit { ) => { fn $visit(&mut self, memarg: wasmparser::MemArg $(, $lane: $ty)?) -> Self::Output { let address = self.metadata.memory_size(memarg.memory)?; - let memory_arg_idx = self.push_operand(MemoryArg::new(memarg.offset, memarg.memory))?; + self.mark_memory(memarg.memory); + let memory_arg_idx = self.push_operand128(tinywasm_types::Operand128::< + tinywasm_types::MemoryOperand, + >::new(memarg.offset, memarg.memory))?; lowering_ops!(@emit self address(address) [$($input),*] => [$($output),*] lowering_ops!(@memory_instruction $instr memory_arg_idx $(, $lane)?)) } @@ -87,7 +90,17 @@ pub(crate) mod visit { lowering_ops!(@resolved global_size $inputs => $outputs $($operator)*); }; (@memory_index $inputs:tt => $outputs:tt $($operator:tt)*) => { - lowering_ops!(@resolved memory_size $inputs => $outputs $($operator)*); + lowering_ops!(@memory_index_impl $inputs => $outputs $($operator)*); + }; + (@memory_index_impl [$($input:ident),*] => [$($output:ident),*] + $visit:ident($index:ident: $ty:ty) => $instr:ident + ) => { + fn $visit(&mut self, $index: $ty) -> Self::Output { + let address = self.metadata.memory_size($index)?; + self.mark_memory($index); + lowering_ops!(@emit self address(address) [$($input),*] => [$($output),*] + Instruction::$instr($index).into()) + } }; (@table $inputs:tt => $outputs:tt $($operator:tt)*) => { lowering_ops!(@resolved table_size $inputs => $outputs $($operator)*); |
