From 666c7f59301acc9fcef10ac2da5beb464e57d665 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 10 Aug 2026 15:22:56 +0200 Subject: chore: simplify runtime and clean up tests Signed-off-by: Henry --- crates/parser/src/module.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'crates/parser/src/module.rs') diff --git a/crates/parser/src/module.rs b/crates/parser/src/module.rs index bbe2cf8..3d38ad6 100644 --- a/crates/parser/src/module.rs +++ b/crates/parser/src/module.rs @@ -64,6 +64,7 @@ pub(crate) struct ModuleReader<'a> { pub(crate) end_reached: bool, imported_func_count: usize, imported_memory_count: u32, + global_types: Vec, #[cfg(parallel_parser)] pending_functions: Option>>, @@ -148,7 +149,7 @@ impl<'a> ModuleReader<'a> { if let Some(validator) = validator.as_mut() { validator.global_section(&reader)?; } - self.globals = convert_module_globals(reader)?; + self.globals = convert_module_globals(reader, &mut self.global_types)?; } Payload::TableSection(reader) => { check_section("table", !self.tables.is_empty())?; @@ -168,7 +169,7 @@ impl<'a> ModuleReader<'a> { let init = match table.init { wasmparser::TableInit::RefNull => None, wasmparser::TableInit::Expr(expr) => { - Some(process_const_operators(expr.get_operators_reader())?) + Some(process_const_operators(expr.get_operators_reader(), &self.global_types)?) } }; tables.push(TableDefinition { ty, init }); @@ -209,8 +210,10 @@ impl<'a> ModuleReader<'a> { if let Some(validator) = validator.as_mut() { validator.element_section(&reader)?; } - self.elements = - reader.into_iter().map(|element| convert_module_element(element?)).collect::>()?; + self.elements = reader + .into_iter() + .map(|element| convert_module_element(element?, &self.global_types)) + .collect::>()?; } Payload::DataSection(reader) => { check_section("data", !self.data.is_empty())?; @@ -218,7 +221,10 @@ impl<'a> ModuleReader<'a> { if let Some(validator) = validator.as_mut() { validator.data_section(&reader)?; } - self.data = reader.into_iter().map(|data| convert_module_data(data?)).collect::>()?; + self.data = reader + .into_iter() + .map(|data| convert_module_data(data?, &self.global_types)) + .collect::>()?; } Payload::DataCountSection { count, range } => { debug!("Found data count section"); @@ -270,6 +276,7 @@ impl<'a> ModuleReader<'a> { self.imported_func_count += 1; } ImportKind::Memory(_) => self.imported_memory_count += 1, + ImportKind::Global(ty) => self.global_types.push(ty.ty), ImportKind::Tag(tag) => { let ty = self.types.get(tag.type_idx).and_then(SubType::as_func).ok_or_else(|| { ParseError::Other(format!( -- cgit v1.3.1