The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Wasm::Wasmtime::Instance - Wasmtime instance class

VERSION

version 0.11

SYNOPSIS

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

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
 );
 my $instance = Wasm::Wasmtime::Instance->new(
   $module,    # Wasm::Wasmtime::Module
   \@imports,  # array reference of Wasm::Wasmtime::Extern
 );

Create a new instance of the instance class. @imports should match the imports specified by $module. You can use a few shortcuts when specifying imports:

code reference

For a function import, you can provide a plan Perl subroutine, since we can determine the function signature from the $module.

scalar reference

For a memory import, a memory object will be created and the referred scalar will be set to it.

undef

For a memory import, a memory object will be created. You won't be able to access it from Perl space, but at least it won't die.

METHODS

module

 my $module = $instance->module;

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

exports

 my $exports = $instance->exports;

Returns the Wasm:Wasmtime::Instance::Exports object for this instance. This can be used to query and call exports from the instance.

SEE ALSO

Wasm
Wasm::Wasmtime

AUTHOR

Graham Ollis <plicease@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2020 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.