blib/lib/Wasm/Wasmtime/Memory.pm

filter: Statementstmt 96.8% 62 / 64 Branchbran 62.5% 5 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 17 / 17 Podpod n/a totaltotal 90.4% 85 / 94 CC 6 SCAR 7.5
CC
6
Cov
91%
__ANON__
5.5
__ANON__
2.1
BEGIN
1.0
CRAP 2.1
« blib/lib/Wasm/Wasmtime/FuncType.pm ↑ Summary blib/lib/Wasm/Wasmtime/Caller.pm »
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_blessed_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 Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 16 ▶use constant is_memory => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 16 ▶use constant kind => 'memory';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # ABSTRACT: Wasmtime memory class
16 16 our $VERSION = '0.24'; # VERSION
17  
18  
19 16 $ffi_prefix = 'wasmtime_memory_';
20  
21  
22 5 ▶$ffi->attach( [ wasmtime_memory_new => 'new' ] => ['opaque', 'wasm_memorytype_t', 'wasmtime_memory_t'] => 'wasmtime_error_t' => sub {
Subroutine __ANON__: called CC=5 SCAR=17.1
23 5 my $xsub = shift;
24 5 my $class = shift;
25 5 my($store, $memorytype) = @_;
26 5 ▶ Carp::croak("Wasm::Wasmtime::Memory->new requires a Wasm::Wasmtime::Store")
Branch: 1 branch
BranchTrueFalseTotal
unless is_blessed_ref($store) and $store->isa("Wasm::Wasmtime::Store") 0 5 5
Condition33%1/3
is_blessed_ref($store) and $store->isa("Wasm::Wasmtime::Store")
!ll&&!rl&&r
005
MC/DC0%0/2
is_blessed_ref($store) and $store->isa("Wasm::Wasmtime::Store")
is_blessed_ref($store) $store->isa("Wasm::Wasmtime::Store")
Truth table33%1/3
A and B
A= is_blessed_ref($store)B= $store->isa("Wasm::Wasmtime::Store")
ABresult
0X0
100
111
27 unless is_blessed_ref($store) && $store->isa('Wasm::Wasmtime::Store');
28 5 ▶ $memorytype = Wasm::Wasmtime::MemoryType->new($memorytype)
Branch: 1 branch
BranchTrueFalseTotal
if is_plain_arrayref($memorytype) 2 3 5
29 if is_plain_arrayref $memorytype;
30 5 my $data = Wasm::Wasmtime::MemoryData->new;
31 5 ▶ if(my $error = $xsub->($store->context, $memorytype, $data))
Branch: 1 branch
BranchTrueFalseTotal
if (my $error = &$xsub($store->context, $memorytype, $data)) 0 5 5
32 {
33 0 Carp::croak($error->message);
34 }
35 5 bless { data => $data, store => $store }, $class;
36 16 });
37  
38  
39 6 ▶$ffi->attach( [ wasmtime_memory_type => 'type' ] => ['opaque', 'wasmtime_memory_t'] => 'wasm_memorytype_t' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
40 6 my($xsub, $self) = @_;
41 6 $xsub->($self->context, $self->{data});
42 16 });
43  
44  
45 2 ▶$ffi->attach( [ wasmtime_memory_data => 'data' ] => ['opaque', 'wasmtime_memory_t'] => 'opaque' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
46 2 my($xsub, $self) = @_;
47 2 $xsub->($self->context, $self->{data});
48 16 });
49  
50  
51 2 ▶$ffi->attach( [ wasmtime_memory_data_size => 'data_size' ] => ['opaque', 'wasmtime_memory_t'] => 'size_t' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
52 2 my($xsub, $self) = @_;
53 2 $xsub->($self->context, $self->{data});
54 16 });
55  
56  
57 5 ▶$ffi->attach( [ wasmtime_memory_size => 'size' ] => ['opaque', 'wasmtime_memory_t'] => 'uint64' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
58 5 my($xsub, $self) = @_;
59 5 $xsub->($self->context, $self->{data});
60 16 });
61  
62  
63 2 ▶$ffi->attach( [ wasmtime_memory_grow => 'grow' ] => ['opaque', 'wasmtime_memory_t', 'uint64', 'uint64*'] => 'wasmtime_error_t' => sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
64 2 my($xsub, $self, $delta) = @_;
65 2 my $prev = 0;
66 2 my $error = $xsub->($self->context, $self->{data}, $delta, \$prev);
67 2 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 2 2
68 {
69 # match the old boolean-ish behaviour
70 0 return !!0;
71 }
72 2 return !!1;
73 16 });
74  
75 16 1;
76  
77 __END__
« blib/lib/Wasm/Wasmtime/FuncType.pm ↑ Summary blib/lib/Wasm/Wasmtime/Caller.pm »