From 843e0ff5601479239791f452bec9865df779839b Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 27 Aug 2026 16:06:57 +0200 Subject: chore: simplify operands, extract more exec_ methods Signed-off-by: Henry --- crates/parser/src/macros.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'crates/parser/src/macros.rs') 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)*); -- cgit v1.3.1