summaryrefslogtreecommitdiff
path: root/crates/types/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/types/src')
-rw-r--r--crates/types/src/instructions.rs6
-rw-r--r--crates/types/src/lib.rs12
-rw-r--r--crates/types/src/value.rs6
3 files changed, 15 insertions, 9 deletions
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<FuncAddr>),
RefExtern(Option<ExternAddr>),
+ 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.