The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Wasm::Wasmer::Global - WebAssembly global

SYNOPSIS

    my $store = Wasm::Wasmer::Store->new();

    my $life = $store->create_i32_const(42);

DESCRIPTION

This class represents WebAssembly global imports & exports.

This class subclasses Wasm::Wasmer::Extern.

METHODS

$val = OBJ->get()

Retrieves the global’s current value.

$obj = OBJ->set( $NEW_VALUE )

Sets the global’s value. If called on a constant/non-mutable global this throws.

$mut = OBJ->mutability()

Returns a number that represents the object’s mutability state. The constants Wasm::Wasmer::WASM_VAR and Wasm::Wasmer::WASM_CONST indicate mutability and non-mutability, respectively.

(You can currently treat $mut as a boolean, and that will probably never bite you. But that’s not 100% certain.)