NAME

Wasm::Wasmtime::Instance - Wasmtime instance class

VERSION

version 0.24

SYNOPSIS

use Wasm::Wasmtime;

my $store = Wasm::Wasmtime::Store->new;
my $module = Wasm::Wasmtime::Module->new($store->engine, wat => '(module)');
my $instance = Wasm::Wasmtime::Instance->new($module, $store, []);

DESCRIPTION

WARNING: WebAssembly and Wasmtime are a moving target and the interface for these modules is under active development. Use with caution.

This class represents an instance of a WebAssembly module Wasm::Wasmtime::Module.

CONSTRUCTOR

new

my $instance = Wasm::Wasmtime::Instance->new(
  $module,    # Wasm::Wasmtime::Module
  $store      # Wasm::Wasmtime::Store
);
my $instance = Wasm::Wasmtime::Instance->new(
  $module,    # Wasm::Wasmtime::Module
  $store,     # Wasm::Wasmtime::Store
  \@imports,  # array reference of Wasm::Wasmtime::Extern (or shortcuts)
);

Create a new instance. @imports should match the imports specified by $module. Shortcuts: a plain code reference for a function import, a scalar reference or undef for a memory import.

METHODS

module

my $module = $instance->module;

Returns the Wasm::Wasmtime::Module for this instance.

store

my $store = $instance->store;

Returns the Wasm::Wasmtime::Store for this instance.

context

my $context = $instance->context;

Returns the wasmtime_context_t pointer for this instance's store (internal use).

exports

my $exports = $instance->exports;

Returns the Wasm::Wasmtime::Instance::Exports object for this instance.

SEE ALSO

Wasm
Wasm::Wasmtime

AUTHOR

Graham Ollis <plicease@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2020-2026 by Graham Ollis.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.