blib/lib/Wasm/Wasmtime/Store.pm

filter: Statementstmt 84.4% 49 / 58 Branchbran 30.0% 3 / 10 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 85.7% 12 / 14 Podpod 100% 2 / 2 totaltotal 73.4% 69 / 94 CC 8 SCAR 10.3
CC
8
Cov
74%
__ANON__
6.0
__ANON__
6.0
__ANON__
4.5
CRAP 2.8
« blib/lib/Wasm/Hook.pm ↑ Summary blib/lib/Wasm/Wasmtime/ExportType.pm »
1 package Wasm::Wasmtime::Store;
2  
3 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 24 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 24 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 24 ▶use Wasm::Wasmtime::FFI;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 24 ▶use Wasm::Wasmtime::Engine;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 24 ▶use Ref::Util qw( is_blessed_ref );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 24 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # ABSTRACT: Wasmtime store class
12 24 our $VERSION = '0.24'; # VERSION
13  
14  
15 24 $ffi_prefix = 'wasm_store_';
16 24 $ffi->load_custom_type('::PtrObject' => 'wasm_store_t' => __PACKAGE__);
17  
18  
19 37 ▶$ffi->attach( [ wasmtime_store_new => 'new' ] => ['wasm_engine_t', 'opaque', 'opaque'] => 'opaque' => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
20 37 my($xsub, $class, $engine) = @_;
21 37 ▶ $engine ||= Wasm::Wasmtime::Engine->new;
Condition66%2/3
$engine ||= "Wasm::Wasmtime::Engine"->new
l!l&&r!l&&!r
17200
MC/DC0%0/2
$engine ||= "Wasm::Wasmtime::Engine"->new
$engine "Wasm::Wasmtime::Engine"->new
Truth table66%2/3
A ||= B
A= $engineB= "Wasm::Wasmtime::Engine"->new
ABresult
1X1
011
000
22 37 my $ptr = $xsub->($engine, undef, undef);
23 37 my $self = bless {
24 ptr => $ptr,
25 engine => $engine,
26 }, $class;
27 37 $self->{context} = _context($ptr);
28 37 $self;
29 24 });
30  
31 24 $ffi->attach( [ wasmtime_store_context => '_context' ] => ['opaque'] => 'opaque' );
32  
33  
34 368 ▶sub context { shift->{context} }
Subroutine context: called CC=1 SCAR=0.0
Pod documented
35  
36  
37 57 ▶sub engine { shift->{engine} }
Subroutine engine: called CC=1 SCAR=0.0
Pod documented
38  
39  
40 1 ▶$ffi->attach( [ wasmtime_context_gc => 'gc' ] => ['opaque'] => 'wasmtime_error_t' => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
41 1 my($xsub, $self) = @_;
42 1 my $error = $xsub->($self->{context});
43 1 ▶ Carp::croak($error->message) if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 1 1
44 1 return;
45 24 });
46  
47  
48 0 ▶$ffi->attach( [ wasmtime_context_set_fuel => 'set_fuel' ] => ['opaque','uint64'] => 'wasmtime_error_t' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
49 0 my($xsub, $self, $fuel) = @_;
50 0 my $error = $xsub->($self->{context}, $fuel);
51 0 ▶ Carp::croak($error->message) if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 0 0
52 0 $self;
53 24 });
54  
55 0 ▶$ffi->attach( [ wasmtime_context_get_fuel => 'get_fuel' ] => ['opaque','uint64*'] => 'wasmtime_error_t' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
56 0 my($xsub, $self) = @_;
57 0 my $fuel = 0;
58 0 my $error = $xsub->($self->{context}, \$fuel);
59 0 ▶ Carp::croak($error->message) if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 0 0
60 0 $fuel;
61 24 });
62  
63  
64 4 ▶$ffi->attach( [ wasmtime_context_set_wasi => 'set_wasi' ] => ['opaque','opaque'] => 'wasmtime_error_t' => sub {
Subroutine __ANON__: called CC=4 SCAR=15.0
65 4 my($xsub, $self, $wasi_config) = @_;
66 4 ▶ Carp::croak("not a Wasm::Wasmtime::WasiConfig")
Branch: 1 branch
BranchTrueFalseTotal
unless is_blessed_ref($wasi_config) and $wasi_config->isa("Wasm::Wasmtime::WasiConfig") 0 4 4
Condition33%1/3
is_blessed_ref($wasi_config) and $wasi_config->isa("Wasm::Wasmtime::WasiConfig")
!ll&&!rl&&r
004
MC/DC0%0/2
is_blessed_ref($wasi_config) and $wasi_config->isa("Wasm::Wasmtime::WasiConfig")
is_blessed_ref($wasi_config) $wasi_config->isa("Wasm::Wasmtime::WasiConfig")
Truth table33%1/3
A and B
A= is_blessed_ref($wasi_config)B= $wasi_config->isa("Wasm::Wasmtime::WasiConfig")
ABresult
0X0
100
111
67 unless is_blessed_ref($wasi_config) && $wasi_config->isa('Wasm::Wasmtime::WasiConfig');
68 4 my $ptr = delete $wasi_config->{ptr};
69 4 my $error = $xsub->($self->{context}, $ptr);
70 4 ▶ Carp::croak($error->message) if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 4 4
71 4 $self;
72 24 });
73  
74 24 _generate_destroy('wasmtime_store_delete');
75  
76 24 1;
77  
78 __END__
« blib/lib/Wasm/Hook.pm ↑ Summary blib/lib/Wasm/Wasmtime/ExportType.pm »