summaryrefslogtreecommitdiff
path: root/crates/types
diff options
context:
space:
mode:
Diffstat (limited to 'crates/types')
-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