diff options
| author | Henry Gressmann <mail@henrygressmann.de> | 2024-01-06 15:03:41 +0100 |
|---|---|---|
| committer | Henry Gressmann <mail@henrygressmann.de> | 2024-01-06 15:03:41 +0100 |
| commit | 54c1b75f9a7bd80e45aa0356cf2cae30a646f383 (patch) | |
| tree | 89993cee8c9e52a2f7346eb089702d709b83c55f /crates/types/src | |
| parent | 64606e091757deb5c3e4dbd5c4ef2c9eead6d891 (diff) | |
feat: imports
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'crates/types/src')
| -rw-r--r-- | crates/types/src/lib.rs | 13 |
1 files changed, 11 insertions, 2 deletions
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, |
