Reference

Contents

Index

WasmtimeRuntime.WasmExternType
WasmExtern{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
source
WasmtimeRuntime.WasmGlobalType
WasmGlobal(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 global
  • global_type::WasmGlobalType: Type descriptor defining value type and mutability
  • initial_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))
source
WasmtimeRuntime.WasmGlobalTypeType
WasmGlobalType(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)
source
WasmtimeRuntime.WasmInstanceExportType
WasmInstanceExport{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 identifier
  • ptr::Ptr{wasm_exporttype_t}: Native export type handle
  • extern::WasmExtern{E}: Concrete extern object implementation
source
WasmtimeRuntime.WasmInstanceExportMethod
WasmInstanceExport(notowned_extern::Ptr{wasm_extern_t}) -> WasmInstanceExport

Create instance export from existing wasmexternt pointer.

Used when processing exports from instantiated modules.

source
WasmtimeRuntime.WasmInstanceExportMethod
WasmInstanceExport(name, extern::WasmExtern{E}) -> WasmInstanceExport{E}

Create instance export from an extern object.

Associates an export name with a concrete extern implementation.

source
WasmtimeRuntime.WasmModuleExportType
WasmModuleExport{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 identifier
  • ptr::Ptr{wasm_exporttype_t}: Native export type handle
source
WasmtimeRuntime.WasmModuleExportMethod
WasmModuleExport(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.

source
WasmtimeRuntime.WasmTableType
WasmTable

WebAssembly table that holds function references or other reference types. Implements AbstractVector interface for element access.

source
WasmtimeRuntime.WasmTableTypeType
WasmTableType

Represents a WebAssembly table type with size limits and element type. Tables hold function references or other reference types.

source
WasmtimeRuntime.WasmVecType
WasmVec{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])
source
Base.getindexMethod
getindex(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.

source
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.

source
WasmtimeRuntime.wat2wasmMethod
wat2wasm(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.

source