blob: 3580e9d6483c9f5b796abcbc9349303d3d61d7c5 (
plain)
use alloc::sync::Arc;
use tinywasm_types::*;
use crate::func::HostFunction;
/// A WebAssembly Function Instance
///
/// See <https://webassembly.github.io/spec/core/exec/runtime.html#function-instances>
#[derive(Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub(crate) struct FunctionInstance {
pub(crate) type_addr: TypeAddr,
pub(crate) gc: FunctionGcMetadata,
pub(crate) kind: FunctionKind,
}
#[derive(Clone, Copy)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub(crate) struct FunctionGcMetadata {
pub(crate) params: bool,
pub(crate) results: bool,
}
#[derive(Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub(crate) enum FunctionKind {
/// A host function
Host(HostFunction),
/// A pointer to a WebAssembly function
Wasm(WasmFunctionInstance),
}
#[derive(Clone)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub(crate) struct WasmFunctionInstance {
pub(crate) func: Arc<WasmFunction>,
pub(crate) owner: ModuleInstanceId,
}
|