From 54c1b75f9a7bd80e45aa0356cf2cae30a646f383 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Sat, 6 Jan 2024 15:03:41 +0100 Subject: feat: imports Signed-off-by: Henry Gressmann --- crates/types/src/lib.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'crates/types') diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index 4895418..1213515 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -91,6 +91,15 @@ pub enum WasmValue { } impl WasmValue { + pub fn const_instr(&self) -> ConstInstruction { + match self { + Self::I32(i) => ConstInstruction::I32Const(*i), + Self::I64(i) => ConstInstruction::I64Const(*i), + Self::F32(i) => ConstInstruction::F32Const(*i), + Self::F64(i) => ConstInstruction::F64Const(*i), + } + } + /// Get the default value for a given type. pub fn default_for(ty: ValType) -> Self { match ty { @@ -227,7 +236,7 @@ impl WasmValue { } /// Type of a WebAssembly value. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ValType { /// A 32-bit integer. I32, @@ -340,7 +349,7 @@ pub struct Global { pub init: ConstInstruction, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct GlobalType { pub mutable: bool, pub ty: ValType, -- cgit v1.3.1