diff --git a/crates/wasmparser/src/readers/core/operators.rs b/crates/wasmparser/src/readers/core/operators.rs index 24c209f88b..94a4422030 100644 --- a/crates/wasmparser/src/readers/core/operators.rs +++ b/crates/wasmparser/src/readers/core/operators.rs @@ -326,3 +326,21 @@ pub trait VisitOperator<'a> { for_each_operator!(define_visit_operator); } + +macro_rules! define_visit_operator_delegate { + ($(@$proposal:ident $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident)*) => { + $( + fn $visit(&mut self $($(,$arg: $argty)*)?) -> Self::Output { + V::$visit(*self, $($($arg),*)?) + } + )* + } +} + +impl<'a, 'b, V: VisitOperator<'a>> VisitOperator<'a> for &'b mut V { + type Output = V::Output; + fn visit_operator(&mut self, op: &Operator<'a>) -> Self::Output { + V::visit_operator(*self, op) + } + for_each_operator!(define_visit_operator_delegate); +}