summaryrefslogtreecommitdiff
path: root/crates/types
diff options
context:
space:
mode:
authorHenry Gressmann <mail@henrygressmann.de>2024-01-20 19:26:44 +0100
committerHenry Gressmann <mail@henrygressmann.de>2024-01-20 19:26:44 +0100
commit7b456a58f70c0a1dbaf289d285b14a6b139495f7 (patch)
treefcdd1e9b3e6f2c3d066cb1f8791bd7796d2c982d /crates/types
parent032d2cdd590c1cdd30490384742a90dc0c759176 (diff)
feat: typed host funcs
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'crates/types')
-rw-r--r--crates/types/src/lib.rs34
1 files changed, 3 insertions, 31 deletions
diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs
index 5b290ca..069f134 100644
--- a/crates/types/src/lib.rs
+++ b/crates/types/src/lib.rs
@@ -28,7 +28,7 @@ extern crate alloc;
mod instructions;
use core::{fmt::Debug, ops::Range};
-use alloc::boxed::Box;
+use alloc::{boxed::Box, sync::Arc, vec::Vec};
pub use instructions::*;
/// A TinyWasm WebAssembly Module
@@ -45,7 +45,7 @@ pub struct TinyWasmModule {
pub start_func: Option<FuncAddr>,
/// The functions of the WebAssembly module.
- pub funcs: Box<[Function]>,
+ pub funcs: Box<[WasmFunction]>,
/// The types of the WebAssembly module.
pub func_types: Box<[FuncType]>,
@@ -169,12 +169,6 @@ impl From<f64> for WasmValue {
}
}
-// impl From<i128> for WasmValue {
-// fn from(i: i128) -> Self {
-// Self::V128(i)
-// }
-// }
-
impl TryFrom<WasmValue> for i32 {
type Error = ();
@@ -339,35 +333,13 @@ impl FuncType {
}
}
-// A WebAssembly Function
-#[derive(Debug, Clone)]
-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 ty_addr: TypeAddr,
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
#[derive(Debug, Clone)]
pub struct Export {