From 375f9aa32b117a42c7a9c7f29d3c592b81d966be Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Tue, 19 Dec 2023 14:37:51 +0100 Subject: feat: parse memory and table sections Signed-off-by: Henry Gressmann --- crates/types/src/lib.rs | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'crates/types') diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index ddc8ce4..387a878 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -48,13 +48,19 @@ pub struct TinyWasmModule { pub funcs: Box<[Function]>, /// The types of the WebAssembly module. - pub types: Box<[FuncType]>, + pub func_types: Box<[FuncType]>, /// The exports of the WebAssembly module. pub exports: Box<[Export]>, + + /// The tables of the WebAssembly module. pub globals: Box<[Global]>, - // pub tables: Option, - // pub memories: Option, + + /// The tables of the WebAssembly module. + pub table_types: Box<[TableType]>, + + /// The memories of the WebAssembly module. + pub memory_types: Box<[MemoryType]>, // pub elements: Option>, // pub imports: Option>, // pub data_segments: Option>, @@ -300,3 +306,26 @@ pub struct Global { pub ty: ValType, pub init: ConstInstruction, } + +#[derive(Debug, Clone)] +pub struct TableType { + pub element_type: ValType, + pub size_initial: u32, + pub size_max: Option, +} + +#[derive(Debug, Clone)] + +/// Represents a memory's type. +#[derive(Copy, PartialEq, Eq, Hash)] +pub struct MemoryType { + pub arch: MemoryArch, + pub page_count_initial: u64, + pub page_count_max: Option, +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum MemoryArch { + I32, + I64, +} -- cgit v1.3.1