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/module.rs | 66 +++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 47 deletions(-) (limited to 'crates/parser/src/module.rs') diff --git a/crates/parser/src/module.rs b/crates/parser/src/module.rs index f5c01ac..a18d343 100644 --- a/crates/parser/src/module.rs +++ b/crates/parser/src/module.rs @@ -6,58 +6,34 @@ use tinywasm_types::{Data, Element, Export, FuncType, Global, Import, Instructio use wasmparser::{Payload, Validator}; #[derive(Debug, Clone)] -pub struct CodeSection { - pub locals: Box<[ValType]>, - pub body: Box<[Instruction]>, +pub(crate) struct CodeSection { + pub(crate) locals: Box<[ValType]>, + pub(crate) body: Box<[Instruction]>, } #[derive(Default)] -pub struct ModuleReader { - pub version: Option, - pub start_func: Option, - - pub func_types: Vec, - - // map from local function index to type index - pub code_type_addrs: Vec, - - pub exports: Vec, - pub code: Vec, - pub globals: Vec, - pub table_types: Vec, - pub memory_types: Vec, - pub imports: Vec, - pub data: Vec, - pub elements: Vec, - - // pub element_section: Option>, - pub end_reached: bool, -} - -impl Debug for ModuleReader { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { - f.debug_struct("ModuleReader") - .field("version", &self.version) - .field("func_types", &self.func_types) - .field("func_addrs", &self.code_type_addrs) - .field("code", &self.code) - .field("exports", &self.exports) - .field("globals", &self.globals) - .field("table_types", &self.table_types) - .field("memory_types", &self.memory_types) - .field("import_section", &self.imports) - // .field("element_section", &self.element_section) - // .field("data_section", &self.data_section) - .finish() - } +pub(crate) struct ModuleReader { + pub(crate) version: Option, + pub(crate) start_func: Option, + pub(crate) func_types: Vec, + pub(crate) code_type_addrs: Vec, + pub(crate) exports: Vec, + pub(crate) code: Vec, + pub(crate) globals: Vec, + pub(crate) table_types: Vec, + pub(crate) memory_types: Vec, + pub(crate) imports: Vec, + pub(crate) data: Vec, + pub(crate) elements: Vec, + pub(crate) end_reached: bool, } impl ModuleReader { - pub fn new() -> ModuleReader { + pub(crate) fn new() -> ModuleReader { Self::default() } - pub fn process_payload(&mut self, payload: Payload, validator: &mut Validator) -> Result<()> { + pub(crate) fn process_payload(&mut self, payload: Payload<'_>, validator: &mut Validator) -> Result<()> { use wasmparser::Payload::*; match payload { @@ -191,10 +167,6 @@ impl ModuleReader { debug!("Found custom section"); debug!("Skipping custom section: {:?}", _reader.name()); } - // TagSection(tag) => { - // debug!("Found tag section"); - // validator.tag_section(&tag)?; - // } UnknownSection { .. } => return Err(ParseError::UnsupportedSection("Unknown section".into())), section => return Err(ParseError::UnsupportedSection(format!("Unsupported section: {:?}", section))), }; -- cgit v1.3.1