Reference
Contents
Index
WasmtimeRuntime.WasmExtern
WasmtimeRuntime.WasmExternObjectType
WasmtimeRuntime.WasmGlobal
WasmtimeRuntime.WasmGlobalType
WasmtimeRuntime.WasmInstanceExport
WasmtimeRuntime.WasmInstanceExport
WasmtimeRuntime.WasmInstanceExport
WasmtimeRuntime.WasmModuleExport
WasmtimeRuntime.WasmModuleExport
WasmtimeRuntime.WasmModuleExport
WasmtimeRuntime.WasmModuleExport
WasmtimeRuntime.WasmModuleExport
WasmtimeRuntime.WasmModuleExport
WasmtimeRuntime.WasmTable
WasmtimeRuntime.WasmTableType
WasmtimeRuntime.WasmTableType
WasmtimeRuntime.WasmVec
Base.getindex
WasmtimeRuntime._get_export_name!
WasmtimeRuntime.exporttype
WasmtimeRuntime.name
WasmtimeRuntime.name
WasmtimeRuntime.wat2wasm
WasmtimeRuntime.WasmExternObjectType
— TypeWasmExternObjectType
Union type for all WebAssembly extern objects that can be wrapped by WasmExtern
. Includes functions, globals, tables, and memories.
WasmtimeRuntime.WasmExtern
— TypeWasmExtern{E<:WasmExternObjectType} <: AbstractWasmExtern
A wrapper for WebAssembly extern objects that provides a unified interface for functions, globals, tables, and memories. This struct converts specific extern objects into the generic wasm_extern_t
representation used by the Wasmtime C API. Important! The original object is finalized when creating the WasmExtern
wrapper, as ownership transfers to the wrapper. This means the original object should not be used after creating the WasmExtern
.
Type Parameters
E
: The specific extern object type (WasmFunc, WasmGlobal, WasmTable, or WasmMemory)
Fields
ptr::Ptr{LibWasmtime.wasm_extern_t}
: Pointer to the underlying C extern object
Constructor
WasmExtern(obj::WasmExternObjectType)
Creates a WasmExtern
wrapper around a specific extern object. The original object is finalized during construction as ownership transfers to the wrapper.
Examples
# Create extern wrappers for different object types
engine = WasmEngine()
store = WasmStore(engine)
# Memory extern
memory = WasmMemory(store, (1 => 10))
memory_extern = WasmExtern(memory)
# Global extern (when implemented)
# global_type = WasmGlobalType(WasmValType(Int32), false)
# global = WasmGlobal(store, global_type, WasmValue(Int32(42)))
# global_extern = WasmExtern(global)
Notes
- The original object is finalized when creating the extern wrapper
- Each extern type uses its corresponding
_as_extern
C API function - The resulting extern can be used in import/export operations
WasmtimeRuntime.WasmGlobal
— TypeWasmGlobal(store::WasmStore, global_type::WasmGlobalType, initial_value::WasmValue) -> WasmGlobal
WebAssembly global variable that can hold a single value of a specific type.
Global variables can be either mutable or immutable as defined by their type. They maintain their value throughout the lifetime of a WebAssembly instance.
Arguments
store::WasmStore
: The store that owns this globalglobal_type::WasmGlobalType
: Type descriptor defining value type and mutabilityinitial_value::WasmValue
: Initial value for the global variable
Examples
engine = WasmEngine()
store = WasmStore(engine)
# Create a mutable Int32 global
valtype = WasmValType(Int32)
global_type = WasmGlobalType(valtype, true) # mutable
global_var = WasmGlobal(store, global_type, WasmValue(Int32(42)))
# Create an immutable Float64 global
valtype = WasmValType(Float64)
global_type = WasmGlobalType(valtype, false) # immutable
global_var = WasmGlobal(store, global_type, WasmValue(3.14159))
WasmtimeRuntime.WasmGlobalType
— TypeWasmGlobalType(valtype::WasmValtype, mutability::Bool) -> WasmGlobalType
WebAssembly global type descriptor that defines the type and mutability of a global variable.
Arguments
valtype::WasmValtype
: The value type (Int32, Int64, Float32, Float64)mutability::Bool
: true for mutable globals, false for immutable globals
Examples
# Create a mutable Int32 global type
valtype = WasmValType(Int32)
global_type = WasmGlobalType(valtype, true)
# Create an immutable Float64 global type
valtype = WasmValType(Float64)
global_type = WasmGlobalType(valtype, false)
WasmtimeRuntime.WasmInstanceExport
— TypeWasmInstanceExport{E<:WasmExternObjectType} <: AbstractWasmExport
Instance-level export with concrete implementation.
Represents an actual exported object from an instantiated WebAssembly module. Contains both the export metadata and the concrete extern object.
Fields
name::AbstractString
: Export identifierptr::Ptr{wasm_exporttype_t}
: Native export type handleextern::WasmExtern{E}
: Concrete extern object implementation
WasmtimeRuntime.WasmInstanceExport
— MethodWasmInstanceExport(notowned_extern::Ptr{wasm_extern_t}) -> WasmInstanceExport
Create instance export from existing wasmexternt pointer.
Used when processing exports from instantiated modules.
WasmtimeRuntime.WasmInstanceExport
— MethodWasmInstanceExport(name, extern::WasmExtern{E}) -> WasmInstanceExport{E}
Create instance export from an extern object.
Associates an export name with a concrete extern implementation.
WasmtimeRuntime.WasmModuleExport
— TypeWasmModuleExport{E<:WasmExternObjectType} <: AbstractWasmExport
Module-level export declaration with type information.
Represents an export specification from a WebAssembly module before instantiation. Contains export name and type signature but no actual implementation.
Fields
name::String
: Export identifierptr::Ptr{wasm_exporttype_t}
: Native export type handle
WasmtimeRuntime.WasmModuleExport
— MethodWasmModuleExport(name, export_type::WasmFuncType) -> WasmModuleExport{WasmFunc}
Create function export declaration.
WasmtimeRuntime.WasmModuleExport
— MethodWasmModuleExport(name, export_type::WasmGlobalType) -> WasmModuleExport{WasmGlobal}
Create global export declaration.
WasmtimeRuntime.WasmModuleExport
— MethodWasmModuleExport(name, export_type::WasmMemoryType) -> WasmModuleExport{WasmMemory}
Create memory export declaration.
WasmtimeRuntime.WasmModuleExport
— MethodWasmModuleExport(name, export_type::WasmTableType) -> WasmModuleExport{WasmTable}
Create table export declaration.
WasmtimeRuntime.WasmModuleExport
— MethodWasmModuleExport(exporttype_ptr::Ptr{wasm_exporttype_t}) -> WasmModuleExport
Create export from existing wasmexporttypet pointer.
Automatically determines export type and extracts name from the pointer. Used when processing module exports discovered through introspection.
WasmtimeRuntime.WasmTable
— TypeWasmTable
WebAssembly table that holds function references or other reference types. Implements AbstractVector interface for element access.
WasmtimeRuntime.WasmTableType
— TypeWasmTableType
Represents a WebAssembly table type with size limits and element type. Tables hold function references or other reference types.
WasmtimeRuntime.WasmTableType
— MethodWasmTableType(table::WasmTable)
Extract the table type from an existing table.
WasmtimeRuntime.WasmVec
— TypeWasmVec{T,S} <: AbstractVector{S}
Generic wrapper around wasm_XXX_vec_t
types that implements AbstractVector interface.
Examples
extern_vec = WasmVec{wasm_extern_vec_t, Ptr{wasm_extern_t}}()
wasm_vec = WasmVec([ptr1, ptr2, ptr3])
Base.getindex
— Methodgetindex(table::WasmTable, index::Int)
Get a reference from the table at the given index (1-based indexing). Returns nothing
if the slot is empty, or a reference pointer if occupied.
WasmtimeRuntime._get_export_name!
— Method_get_export_name!(exporttype_ptr::Ptr{wasm_exporttype_t}) -> String
Extract export name from a wasmexporttypet pointer.
Handles memory management by deleting the returned name vector after extraction.
WasmtimeRuntime.exporttype
— Methodexporttype(::WasmModuleExport{E}) -> Type{E}
Get the Julia type corresponding to this export's extern type.
WasmtimeRuntime.name
— Methodname(export::WasmInstanceExport) -> String
Get export name.
WasmtimeRuntime.name
— Methodname(export::WasmModuleExport) -> String
Get export name.
WasmtimeRuntime.wat2wasm
— Methodwat2wasm(wat::AbstractString) -> WasmByteVec
Converts a WebAssembly Text format (WAT) string to its corresponding WebAssembly binary format (WASM). Takes a WAT string as input and returns a WasmByteVec
containing the compiled WASM bytes.