summaryrefslogtreecommitdiff
path: root/crates/types
diff options
context:
space:
mode:
authorHenry Gressmann <mail@henrygressmann.de>2024-01-15 23:28:40 +0100
committerHenry Gressmann <mail@henrygressmann.de>2024-01-15 23:28:40 +0100
commit1a97fa744e9f3536b437e484270de327c3b278fc (patch)
tree40b44c77e15f17198841d1c483f0a3a2e66de560 /crates/types
parent9c82f366fc1e0ae8088660abe51d3708d42132f8 (diff)
feat: element instantiation
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'crates/types')
-rw-r--r--crates/types/src/instructions.rs11
-rw-r--r--crates/types/src/lib.rs8
2 files changed, 15 insertions, 4 deletions
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