From 8f33b67404160ce8cf35a22c0d0993112b5abe9c Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Mon, 18 Dec 2023 15:01:30 +0100 Subject: feat: global parsing, improve testsuite Signed-off-by: Henry Gressmann --- crates/parser/src/module.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'crates/parser/src/module.rs') diff --git a/crates/parser/src/module.rs b/crates/parser/src/module.rs index 69bb894..6f823de 100644 --- a/crates/parser/src/module.rs +++ b/crates/parser/src/module.rs @@ -1,7 +1,7 @@ use crate::log::debug; use alloc::{boxed::Box, format, vec::Vec}; use core::fmt::Debug; -use tinywasm_types::{Export, FuncType, Instruction, ValType}; +use tinywasm_types::{Export, FuncType, Global, Instruction, ValType}; use wasmparser::{Payload, Validator}; use crate::{conversion, ParseError, Result}; @@ -21,10 +21,10 @@ pub struct ModuleReader { pub function_section: Vec, pub export_section: Vec, pub code_section: Vec, + pub global_section: Vec, // pub table_section: Option>, // pub memory_section: Option>, - // pub global_section: Option>, // pub element_section: Option>, // pub data_section: Option>, // pub import_section: Option>, @@ -39,9 +39,9 @@ impl Debug for ModuleReader { .field("function_section", &self.function_section) .field("code_section", &self.code_section) .field("export_section", &self.export_section) + .field("global_section", &self.global_section) // .field("table_section", &self.table_section) // .field("memory_section", &self.memory_section) - // .field("global_section", &self.global_section) // .field("element_section", &self.element_section) // .field("data_section", &self.data_section) // .field("import_section", &self.import_section) @@ -84,6 +84,11 @@ impl ModuleReader { validator.function_section(&reader)?; self.function_section = reader.into_iter().map(|f| Ok(f?)).collect::>>()?; } + GlobalSection(reader) => { + debug!("Found global section"); + validator.global_section(&reader)?; + self.global_section = conversion::convert_module_globals(reader)?; + } TableSection(_reader) => { return Err(ParseError::UnsupportedSection("Table section".into())); // debug!("Found table section"); @@ -96,12 +101,7 @@ impl ModuleReader { // validator.memory_section(&reader)?; // self.memory_section = Some(reader); } - GlobalSection(_reader) => { - return Err(ParseError::UnsupportedSection("Global section".into())); - // debug!("Found global section"); - // validator.global_section(&reader)?; - // self.global_section = Some(reader); - } + ElementSection(_reader) => { return Err(ParseError::UnsupportedSection("Element section".into())); // debug!("Found element section"); -- cgit v1.3.1