From c2499d9fb0f90d8c332d89e12207c88c025e91c1 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 12 Apr 2026 15:29:20 +0200 Subject: fix: fix remaining issues with extended-const Signed-off-by: Henry --- crates/types/src/instructions.rs | 6 ++++++ crates/types/src/lib.rs | 12 ++++++------ crates/types/src/value.rs | 6 +++--- 3 files changed, 15 insertions(+), 9 deletions(-) (limited to 'crates/types') diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs index 8b12811..8c0680e 100644 --- a/crates/types/src/instructions.rs +++ b/crates/types/src/instructions.rs @@ -40,6 +40,12 @@ pub enum ConstInstruction { GlobalGet(GlobalAddr), RefFunc(Option), RefExtern(Option), + I32Add, + I32Sub, + I32Mul, + I64Add, + I64Sub, + I64Mul, } /// A WebAssembly Instruction diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index 29a29e5..737c04e 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -325,7 +325,7 @@ pub struct Export { #[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))] pub struct Global { pub ty: GlobalType, - pub init: ConstInstruction, + pub init: Box<[ConstInstruction]>, } #[derive(Clone, Copy, PartialEq, Eq)] @@ -458,7 +458,7 @@ pub struct Data { #[cfg_attr(feature = "debug", derive(Debug))] #[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))] pub enum DataKind { - Active { mem: MemAddr, offset: ConstInstruction }, + Active { mem: MemAddr, offset: Box<[ConstInstruction]> }, Passive, } @@ -472,19 +472,19 @@ pub struct Element { pub ty: ValType, } -#[derive(Clone, Copy, PartialEq)] +#[derive(Clone, PartialEq)] #[cfg_attr(feature = "debug", derive(Debug))] #[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))] pub enum ElementKind { Passive, - Active { table: TableAddr, offset: ConstInstruction }, + Active { table: TableAddr, offset: Box<[ConstInstruction]> }, Declared, } -#[derive(Clone, Copy, PartialEq)] +#[derive(Clone, PartialEq)] #[cfg_attr(feature = "debug", derive(Debug))] #[cfg_attr(feature = "archive", derive(serde::Serialize, serde::Deserialize))] pub enum ElementItem { Func(FuncAddr), - Expr(ConstInstruction), + Expr(Box<[ConstInstruction]>), } diff --git a/crates/types/src/value.rs b/crates/types/src/value.rs index 8cc7f1b..f468be5 100644 --- a/crates/types/src/value.rs +++ b/crates/types/src/value.rs @@ -128,8 +128,8 @@ impl ExternRef { impl WasmValue { #[doc(hidden)] #[inline] - pub const fn const_instr(&self) -> ConstInstruction { - match self { + pub fn const_instr(&self) -> alloc::boxed::Box<[ConstInstruction]> { + alloc::boxed::Box::new([match self { Self::I32(i) => ConstInstruction::I32Const(*i), Self::I64(i) => ConstInstruction::I64Const(*i), Self::F32(i) => ConstInstruction::F32Const(*i), @@ -137,7 +137,7 @@ impl WasmValue { Self::V128(i) => ConstInstruction::V128Const(*i), Self::RefFunc(i) => ConstInstruction::RefFunc(i.addr()), Self::RefExtern(i) => ConstInstruction::RefExtern(i.addr()), - } + }]) } /// Get the default value for a given type. -- cgit v1.3.1