From 6850e8bc669171c658696655f4f31996d6e934af Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Wed, 31 Jan 2024 00:03:42 +0100 Subject: chore: overall code cleanup Signed-off-by: Henry Gressmann --- crates/parser/src/conversion.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'crates/parser/src/conversion.rs') diff --git a/crates/parser/src/conversion.rs b/crates/parser/src/conversion.rs index 7c10d62..38a2ada 100644 --- a/crates/parser/src/conversion.rs +++ b/crates/parser/src/conversion.rs @@ -131,7 +131,7 @@ pub(crate) fn convert_module_globals<'a, T: IntoIterator Result { +pub(crate) fn convert_module_export(export: wasmparser::Export<'_>) -> Result { let kind = match export.kind { wasmparser::ExternalKind::Func => ExternalKind::Func, wasmparser::ExternalKind::Table => ExternalKind::Table, @@ -146,7 +146,7 @@ pub(crate) fn convert_module_export(export: wasmparser::Export) -> Result, mut validator: FuncValidator, ) -> Result { let locals_reader = func.get_locals_reader()?; @@ -205,18 +205,17 @@ pub(crate) fn convert_memarg(memarg: wasmparser::MemArg) -> MemoryArg { MemoryArg { offset: memarg.offset, align: memarg.align, align_max: memarg.max_align, mem_addr: memarg.memory } } -pub(crate) fn process_const_operators(ops: OperatorsReader) -> Result { +pub(crate) fn process_const_operators(ops: OperatorsReader<'_>) -> Result { let ops = ops.into_iter().collect::>>()?; // In practice, the len can never be something other than 2, // but we'll keep this here since it's part of the spec // Invalid modules will be rejected by the validator anyway (there are also tests for this in the testsuite) assert!(ops.len() >= 2); assert!(matches!(ops[ops.len() - 1], wasmparser::Operator::End)); - process_const_operator(ops[ops.len() - 2].clone()) } -pub fn process_const_operator(op: wasmparser::Operator) -> Result { +pub(crate) fn process_const_operator(op: wasmparser::Operator<'_>) -> Result { match op { wasmparser::Operator::RefNull { ty } => Ok(ConstInstruction::RefNull(convert_valtype(&ty))), wasmparser::Operator::RefFunc { function_index } => Ok(ConstInstruction::RefFunc(function_index)), @@ -229,7 +228,7 @@ pub fn process_const_operator(op: wasmparser::Operator) -> Result( +pub(crate) fn process_operators<'a>( mut offset: usize, ops: impl Iterator, wasmparser::BinaryReaderError>>, mut validator: FuncValidator, @@ -515,7 +514,6 @@ pub fn process_operators<'a>( return Err(crate::ParseError::UnsupportedOperator(format!("Unsupported instruction: {:?}", op))); } }; - instructions.push(res); } @@ -524,6 +522,5 @@ pub fn process_operators<'a>( } validator.finish(offset)?; - Ok(instructions.into_boxed_slice()) } -- cgit v1.3.1