NAME
Wasm::Wasmtime::Module - Wasmtime module class
VERSION
version 0.03
SYNOPSIS
use Wasm::Wasmtime;
my $module = Wasm::Wasmtime::Module->new( wat => '(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 a WebAssembly module.
CONSTRUCTOR
new
my $module = Wasm::Wasmtime::Module->new(
$store, # Wasm::Wasmtime::Store
wat => $wat, # WebAssembly Text
);
my $module = Wasm::Wasmtime::Module->new(
$store, # Wasm::Wasmtime::Store
wasm => $wasm, # WebAssembly binary
);
my $module = Wasm::Wasmtime::Module->new(
$store, # Wasm::Wasmtime::Store
file => $path, # Filename containing WebAssembly binary (.wasm) or WebAssembly Text (.wat)
);
my $module = Wasm::Wasmtime::Module->new(
wat => $wat, # WebAssembly Text
);
my $module = Wasm::Wasmtime::Module->new(
wasm => $wasm, # WebAssembly binary
);
my $module = Wasm::Wasmtime::Module->new(
file => $path, # Filename containing WebAssembly binary (.wasm) or WebAssembly Text (.wat)
);
Create a new WebAssembly module object. You must provide either WebAssembly Text (WAT), WebAssembly binary (Wasm), or a filename of a file that contains WebAssembly binary (Wasm). If the optional Wasm::Wasmtime::Store object is not provided one will be created for you.
METHODS
validate
my($ok, $mssage) = Wasm::Wasmtime::Module->validate(
$store, # Wasm::Wasmtime::Store
wat => $wat, # WebAssembly Text
);
my($ok, $mssage) = Wasm::Wasmtime::Module->validate(
$store, # Wasm::Wasmtime::Store
wasm => $wasm, # WebAssembly binary
);
my($ok, $mssage) = Wasm::Wasmtime::Module->validate(
$store, # Wasm::Wasmtime::Store
file => $path, # Filename containing WebAssembly binary (.wasm)
);
my($ok, $mssage) = Wasm::Wasmtime::Module->validate(
wat => $wat, # WebAssembly Text
);
my($ok, $mssage) = Wasm::Wasmtime::Module->validate(
wasm => $wasm, # WebAssembly binary
);
my($ok, $mssage) = Wasm::Wasmtime::Module->validate(
file => $path, # Filename containing WebAssembly binary (.wasm)
);
Takes the same arguments as new
, but validates the module without creating a module object. Returns $ok
, which is true if the WebAssembly is valid, and false otherwise. For invalid WebAssembly $message
may contain a useful diagnostic for why it was invalid.
exports
my @exporttypes = $module->exports;
Returns a list of Wasm::Wasmtime::ExportType objects for the objects exported by the WebAssembly module.
imports
my @importtypes = $module->imports;
Returns a list of Wasm::Wasmtime::ImportType objects for the objects imported by the WebAssembly module.
store
my $store = $module->store;
Returns the Wasm::Wasmtime::Store object used by this module.
get_export
my $exporttype = $module->get_export($name);
Returns the Wasm::Wasmtime::ExportType with the given $name
as exported by the WebAssembly module. If no such export exists, then undef
is returned.
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.