NAME

Wasm::Wasmtime::Global - Wasmtime global class

VERSION

version 0.23

SYNOPSIS

use Wasm::Wasmtime;

my $store = Wasm::Wasmtime::Store->new;
my $global = Wasm::Wasmtime::Global->new(
  $store,
  Wasm::Wasmtime::GlobalType->new('i32','var'),
  42,
);

print $global->get, "\n";  # 42
$global->set(99);
print $global->get, "\n";  # 99

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 global object.

CONSTRUCTOR

new

my $global = Wasm::Wasmtime::Global->new(
  $store,      # Wasm::Wasmtime::Store
  $globaltype, # Wasm::Wasmtime::GlobalType
);

Creates a new global object.

METHODS

type

my $globaltype = $global->type;

Returns the Wasm::Wasmtime::GlobalType object for this global object.

get

my $value = $global->get;

Gets the global value.

set

my $global->set($value);

Sets the global to the given value.

tie

my $ref = $global->tie;

Returns a reference to a tied scalar that can be used to get/set the global.

SEE ALSO

Wasm
Wasm::Wasmtime

AUTHOR

Graham Ollis <plicease@cpan.org>

COPYRIGHT AND LICENSE

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