summaryrefslogtreecommitdiff
path: root/crates/types/src
diff options
context:
space:
mode:
authorHenry Gressmann <mail@henrygressmann.de>2024-01-20 17:53:59 +0100
committerHenry Gressmann <mail@henrygressmann.de>2024-01-20 17:53:59 +0100
commit032d2cdd590c1cdd30490384742a90dc0c759176 (patch)
tree8143f664e815a3f50abd30d1da8c16baba738b91 /crates/types/src
parentbe396125fe5a3643a91caa35a228ec0390ae1d5f (diff)
chore: progress towards host functions
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'crates/types/src')
-rw-r--r--crates/types/src/lib.rs27
1 files changed, 24 insertions, 3 deletions
diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs
index 1eef0a5..5b290ca 100644
--- a/crates/types/src/lib.rs
+++ b/crates/types/src/lib.rs
@@ -339,12 +339,33 @@ impl FuncType {
}
}
-/// A WebAssembly Function
+// A WebAssembly Function
#[derive(Debug, Clone)]
-pub struct Function {
+pub enum Function {
+ WasmFunction(WasmFunction),
+ HostFunction(HostFunction),
+}
+
+impl Function {
+ pub fn ty(&self) -> TypeAddr {
+ match self {
+ Self::WasmFunction(f) => f.ty,
+ Self::HostFunction(f) => f.ty,
+ }
+ }
+}
+
+#[derive(Debug, Clone)]
+pub struct WasmFunction {
pub ty: TypeAddr,
- pub locals: Box<[ValType]>,
pub instructions: Box<[Instruction]>,
+ pub locals: Box<[ValType]>,
+}
+
+#[derive(Debug, Clone)]
+pub struct HostFunction {
+ pub ty: TypeAddr,
+ pub func: fn(&mut [WasmValue]) -> Result<(), ()>,
}
/// A WebAssembly Module Export