From 1a97fa744e9f3536b437e484270de327c3b278fc Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Mon, 15 Jan 2024 23:28:40 +0100 Subject: feat: element instantiation Signed-off-by: Henry Gressmann --- crates/types/src/instructions.rs | 11 ++++++++++- crates/types/src/lib.rs | 8 +++++--- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'crates/types') diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs index 01c5b6e..c90f3df 100644 --- a/crates/types/src/instructions.rs +++ b/crates/types/src/instructions.rs @@ -1,4 +1,4 @@ -use crate::MemAddr; +use crate::{ElemAddr, MemAddr}; use super::{FuncAddr, GlobalAddr, LabelAddr, LocalAddr, TableAddr, TypeAddr, ValType}; @@ -257,4 +257,13 @@ pub enum Instruction { I64TruncSatF32U, I64TruncSatF64S, I64TruncSatF64U, + + // Table Instructions + TableInit(TableAddr, ElemAddr), + TableGet(TableAddr), + TableSet(TableAddr), + TableCopy { from: TableAddr, to: TableAddr }, + TableGrow(TableAddr), + TableSize(TableAddr), + TableFill(TableAddr), } diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index 4ea7b55..2e4fe4f 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -88,8 +88,8 @@ pub enum WasmValue { F64(f64), // Vec types // V128(i128), - // RefExtern(ExternAddr), // RefHost(FuncAddr), + RefExtern(ExternAddr), RefNull(ValType), } @@ -102,7 +102,7 @@ impl WasmValue { Self::F64(i) => ConstInstruction::F64Const(*i), Self::RefNull(ty) => ConstInstruction::RefNull(*ty), // Self::RefExtern(addr) => ConstInstruction::RefExtern(*addr), - // _ => unimplemented!("const_instr for {:?}", self), + _ => unimplemented!("no const_instr for {:?}", self), } } @@ -224,6 +224,7 @@ impl Debug for WasmValue { WasmValue::F32(i) => write!(f, "f32({})", i), WasmValue::F64(i) => write!(f, "f64({})", i), WasmValue::RefNull(ty) => write!(f, "ref.null({:?})", ty), + WasmValue::RefExtern(addr) => write!(f, "ref.extern({})", addr), // WasmValue::V128(i) => write!(f, "v128({})", i), } } @@ -238,6 +239,7 @@ impl WasmValue { Self::F32(_) => ValType::F32, Self::F64(_) => ValType::F64, Self::RefNull(ty) => *ty, + Self::RefExtern(_) => ValType::ExternRef, // Self::V128(_) => ValType::V128, } } @@ -293,7 +295,7 @@ pub type FuncAddr = Addr; pub type TableAddr = Addr; pub type MemAddr = Addr; pub type GlobalAddr = Addr; -pub type ElmAddr = Addr; +pub type ElemAddr = Addr; pub type DataAddr = Addr; pub type ExternAddr = Addr; // additional internal addresses -- cgit v1.3.1