| 1 | package Wasm::Wasmtime::Memory; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 16 | ▶ | use 5.008004; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use base qw( Wasm::Wasmtime::Extern ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 16 | ▶ | use Ref::Util qw( is_ref is_plain_arrayref ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 16 | ▶ | use Wasm::Wasmtime::FFI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 16 | ▶ | use Wasm::Wasmtime::Store; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 16 | ▶ | use Wasm::Wasmtime::MemoryType; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 16 | ▶ | use constant is_memory => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 16 | ▶ | use constant kind => 'memory'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # ABSTRACT: Wasmtime memory class | ||||||||||||||||||||||||||||
| 15 | 16 | our $VERSION = '0.23'; # VERSION | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 16 | $ffi_prefix = 'wasm_memory_'; | |||||||||||||||||||||||||||
| 19 | 16 | $ffi->load_custom_type('::PtrObject' => 'wasm_memory_t' => __PACKAGE__); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | $ffi->attach( new => ['wasm_store_t', 'wasm_memorytype_t'] => 'wasm_memory_t' => sub { | ||||||||||||||||||||||||||||
| 23 | 5 | ▶ | my $xsub = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||
| 24 | 5 | my $class = shift; | |||||||||||||||||||||||||||
| 25 | 5 | ▶ | if(is_ref $_[0]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | { | ||||||||||||||||||||||||||||
| 27 | 5 | my($store, $memorytype) = @_; | |||||||||||||||||||||||||||
| 28 | 5 | ▶ | $memorytype = Wasm::Wasmtime::MemoryType->new($memorytype) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | if is_plain_arrayref $memorytype; | ||||||||||||||||||||||||||||
| 30 | 5 | return $xsub->($store, $memorytype); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | else | ||||||||||||||||||||||||||||
| 33 | { | ||||||||||||||||||||||||||||
| 34 | 0 | my($ptr, $owner) = @_; | |||||||||||||||||||||||||||
| 35 | 0 | return bless { | |||||||||||||||||||||||||||
| 36 | ptr => $ptr, | ||||||||||||||||||||||||||||
| 37 | owner => $owner, | ||||||||||||||||||||||||||||
| 38 | }, $class; | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | 16 | }); | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | $ffi->attach( type => ['wasm_memory_t'] => 'wasm_memorytype_t' => sub { | ||||||||||||||||||||||||||||
| 44 | 6 | ▶ | my($xsub, $self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||
| 45 | 6 | my $type = $xsub->($self); | |||||||||||||||||||||||||||
| 46 | 6 | ▶ | $type->{owner} = $self->{owner} || $self if $type; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{'owner'} || $self
MC/DC0%0/2
$self->{'owner'} || $self
$self->{'owner'}
$self
Truth table66%2/3
A || B
A= $self->{'owner'}B= $self
| |||||||||||||||||||||||||||||
| 47 | 6 | $type; | |||||||||||||||||||||||||||
| 48 | 16 | }); | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | $ffi->attach( data => ['wasm_memory_t'] => 'opaque' => sub { | ||||||||||||||||||||||||||||
| 52 | 2 | ▶ | my($xsub, $self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 53 | 2 | $xsub->($self); | |||||||||||||||||||||||||||
| 54 | 16 | }); | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | $ffi->attach( data_size => ['wasm_memory_t'] => 'size_t' => sub { | ||||||||||||||||||||||||||||
| 58 | 2 | ▶ | my($xsub, $self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 59 | 2 | $xsub->($self); | |||||||||||||||||||||||||||
| 60 | 16 | }); | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | $ffi->attach( size => ['wasm_memory_t'] => 'uint32' => sub { | ||||||||||||||||||||||||||||
| 64 | 5 | ▶ | my($xsub, $self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 65 | 5 | $xsub->($self); | |||||||||||||||||||||||||||
| 66 | 16 | }); | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | $ffi->attach( grow => ['wasm_memory_t', 'uint32'] => 'bool' => sub { | ||||||||||||||||||||||||||||
| 70 | 2 | ▶ | my($xsub, $self, $delta) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 71 | 2 | $xsub->($self, $delta); | |||||||||||||||||||||||||||
| 72 | 16 | }); | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 16 | __PACKAGE__->_cast(3); | |||||||||||||||||||||||||||
| 75 | 16 | _generate_destroy(); | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 16 | 1; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | __END__ | ||||||||||||||||||||||||||||