Wasm::Memory - Interface to WebAssembly Memory
version 0.11
use PeekPoke::FFI qw( peek poke ); use Wasm -api => 0, -wat => q{ (module (memory (export "memory") 3 9) ) } ; # $memory isa Wasm::Memory poke($memory->address + 10, 42); # store the byte 42 at offset # 10 inside the data region my($current, $min, $max) = $memory->limits; printf "size = %x\n", $memory->size; # 30000 printf "current = %d\n", $current; # 3 printf "min = %d\n", $min; # 3 printf "max = %d\n", $max; # 9 $memory->grow(4); # increase data region by 4 pages ($current, $min, $max) = $memory->limits; printf "size = %x\n", $memory->size; # 70000 printf "current = %d\n", $current; # 7 printf "min = %d\n", $min; # 3 printf "max = %d\n", $max; # 9
This class represents a region of memory exported from a WebAssembly module. A Wasm::Memory instance is automatically imported into Perl space for each WebAssembly memory region with the same name.
my $pointer = $memory->address;
Returns an opaque pointer to the start of memory.
my $size = $memory->size;
Returns the size of the memory in bytes.
my($current, $min, $max) = $memory->limits;
Returns the current memory limit, the minimum and maximum. All sizes are in pages.
$memory->grow($count);
Grown the memory region by $count pages.
$count
Graham Ollis <plicease@cpan.org>
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.
To install Wasm, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Wasm
CPAN shell
perl -MCPAN -e shell install Wasm
For more information on module installation, please visit the detailed CPAN module installation guide.