From 957b62bf1d6205409bac94a4ced790dfb8007e3d Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 15 Jul 2026 16:23:02 +0200 Subject: fix: 64 bit table addressing Signed-off-by: Henry --- crates/types/src/lib.rs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'crates/types/src') diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index e918e46..fcac23c 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -499,22 +499,34 @@ impl Default for GlobalType { } } -#[derive(Clone, PartialEq, Eq)] +#[derive(Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "debug", derive(Debug))] #[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))] pub struct TableType { + arch: MemoryArch, pub element_type: WasmType, - pub size_initial: u32, - pub size_max: Option, + pub size_initial: u64, + pub size_max: Option, } impl TableType { - pub fn empty() -> Self { - Self { element_type: WasmType::RefFunc, size_initial: 0, size_max: None } + pub const fn empty() -> Self { + Self::new(WasmType::RefFunc, 0, None) + } + + /// Create a table with 32-bit indices. + pub const fn new(element_type: WasmType, size_initial: u64, size_max: Option) -> Self { + Self { arch: MemoryArch::I32, element_type, size_initial, size_max } } - pub fn new(element_type: WasmType, size_initial: u32, size_max: Option) -> Self { - Self { element_type, size_initial, size_max } + /// Create a table with 64-bit indices. + pub const fn new64(element_type: WasmType, size_initial: u64, size_max: Option) -> Self { + Self { arch: MemoryArch::I64, element_type, size_initial, size_max } + } + + #[inline] + pub const fn arch(&self) -> MemoryArch { + self.arch } } -- cgit v1.3.1