blib/lib/Wasm/Wasmtime/Linker.pm

filter: Statementstmt 96.9% 94 / 97 Branchbran 63.6% 14 / 22 Conditioncond 33.3% 5 / 15 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 21 / 21 Podpod 100% 1 / 1 totaltotal 83.3% 135 / 162 CC 17 SCAR 14.6
CC
17
Cov
84%
__ANON__
12.5
__ANON__
4.1
__ANON__
3.2
CRAP 4.3
« blib/lib/Wasm/Wasmtime/ImportType.pm ↑ Summary blib/lib/Wasm/Wasmtime/TableType.pm »
1 package Wasm::Wasmtime::Linker;
2  
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use Wasm::Wasmtime::FFI;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 9 ▶use Wasm::Wasmtime::Store;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 9 ▶use Wasm::Wasmtime::Extern;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 9 ▶use Wasm::Wasmtime::Instance;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 9 ▶use Wasm::Wasmtime::WasiInstance;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 9 ▶use Wasm::Wasmtime::Func;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 9 ▶use Wasm::Wasmtime::Trap;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 9 ▶use Ref::Util qw( is_blessed_ref );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 9 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 # ABSTRACT: Wasmtime linker class
17 9 our $VERSION = '0.23'; # VERSION
18  
19  
20 9 $ffi_prefix = 'wasmtime_linker_';
21 9 $ffi->load_custom_type('::PtrObject' => 'wasmtime_linker_t' => __PACKAGE__);
22  
23  
24 $ffi->attach( new => ['wasm_store_t'] => 'wasmtime_linker_t' => sub {
25 7 ▶ my($xsub, $class, $store) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
26 7 my $self = $xsub->($store);
27 7 $self->{store} = $store;
28 7 $self;
29 9 });
30  
31  
32 $ffi->attach( allow_shadowing => [ 'wasmtime_linker_t', 'bool' ] => sub {
33 7 ▶ my($xsub, $self, $value) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
34 7 $xsub->($self, $value);
35 7 $self;
36 9 });
37  
38  
39 $ffi->attach( define => ['wasmtime_linker_t', 'wasm_byte_vec_t*', 'wasm_byte_vec_t*', 'opaque'] => 'wasmtime_error_t' => sub {
40 5 ▶ my $xsub = shift;
Subroutine __ANON__: called CC=8 SCAR=25.3
41 5 my $self = shift;
42 5 my $module = Wasm::Wasmtime::ByteVec->new(shift);
43 5 my $name = Wasm::Wasmtime::ByteVec->new(shift);
44 5 my $extern = shift;
45  
46 # Fix this sillyness when/if ::Extern becomes a base class for extern classes
47 5 ▶ if(is_blessed_ref($extern) && ( $extern->isa('Wasm::Wasmtime::Extern')
Branch: 1 branch
BranchTrueFalseTotal
if (is_blessed_ref($extern) and $extern->isa('Wasm::Wasmtime::Extern') || $extern->isa('Wasm::Wasmtime::Func') || $extern->isa('Wasm::Wasmtime::Memory') || $extern->isa('Wasm::Wasmtime::Global') || $extern->isa('Wasm::Wasmtime::Table')) { } 5 0 5
Condition33%5/15
is_blessed_ref($extern) and $extern->isa("Wasm::Wasmtime::Extern") || $extern->isa("Wasm::Wasmtime::Func") || $extern->isa("Wasm::Wasmtime::Memory") || $extern->isa("Wasm::Wasmtime::Global") || $extern->isa("Wasm::Wasmtime::Table")
!ll&&!rl&&r
005
$extern->isa("Wasm::Wasmtime::Extern") or $extern->isa("Wasm::Wasmtime::Func") or $extern->isa("Wasm::Wasmtime::Memory") or $extern->isa("Wasm::Wasmtime::Global") or $extern->isa("Wasm::Wasmtime::Table")
l!l&&r!l&&!r
500
$extern->isa("Wasm::Wasmtime::Extern") or $extern->isa("Wasm::Wasmtime::Func") or $extern->isa("Wasm::Wasmtime::Memory") or $extern->isa("Wasm::Wasmtime::Global")
l!l&&r!l&&!r
500
$extern->isa("Wasm::Wasmtime::Extern") or $extern->isa("Wasm::Wasmtime::Func") or $extern->isa("Wasm::Wasmtime::Memory")
l!l&&r!l&&!r
500
$extern->isa("Wasm::Wasmtime::Extern") or $extern->isa("Wasm::Wasmtime::Func")
l!l&&r!l&&!r
500
MC/DC0%0/6
is_blessed_ref($extern) and $extern->isa("Wasm::Wasmtime::Extern") || $extern->isa("Wasm::Wasmtime::Func") || $extern->isa("Wasm::Wasmtime::Memory") || $extern->isa("Wasm::Wasmtime::Global") || $extern->isa("Wasm::Wasmtime::Table")
is_blessed_ref($extern) $extern->isa("Wasm::Wasmtime::Extern") $extern->isa("Wasm::Wasmtime::Func") $extern->isa("Wasm::Wasmtime::Memory") $extern->isa("Wasm::Wasmtime::Global") $extern->isa("Wasm::Wasmtime::Table")
Truth table14%1/7
A and B or C or D or E or F
A= is_blessed_ref($extern)B= $extern->isa("Wasm::Wasmtime::Extern")C= $extern->isa("Wasm::Wasmtime::Func")D= $extern->isa("Wasm::Wasmtime::Memory")E= $extern->isa("Wasm::Wasmtime::Global")F= $extern->isa("Wasm::Wasmtime::Table")
ABCDEFresult
0XXXXX0
1000000
11XXXX1
101XXX1
1001XX1
10001X1
1000011
48 || $extern->isa('Wasm::Wasmtime::Func')
49 || $extern->isa('Wasm::Wasmtime::Memory')
50 || $extern->isa('Wasm::Wasmtime::Global')
51 || $extern->isa('Wasm::Wasmtime::Table')))
52 {
53 5 my $error = $xsub->($self, $module, $name, $extern->{ptr});
54 5 ▶ Carp::croak($error->message) if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 1 4 5
55 4 return $self;
56 }
57 else
58 {
59 0 Carp::croak("not an extern: $extern");
60 }
61 9 });
62  
63  
64 $ffi->attach( define_wasi => ['wasmtime_linker_t', 'wasi_instance_t'] => 'wasmtime_error_t' => sub {
65 4 ▶ my($xsub, $self, $wasi) = @_;
Subroutine __ANON__: called CC=2 SCAR=7.0
66 4 my $error = $xsub->($self, $wasi);
67 4 ▶ Carp::croak($error->message) if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 4 4
68 4 $self;
69 9 });
70  
71  
72 $ffi->attach( define_instance => ['wasmtime_linker_t', 'wasm_byte_vec_t*', 'wasm_instance_t'] => 'wasmtime_error_t' => sub {
73 20 ▶ my($xsub, $self, $name, $instance) = @_;
Subroutine __ANON__: called CC=2 SCAR=7.0
74 20 my $vname = Wasm::Wasmtime::ByteVec->new($name);
75 20 my $error = $xsub->($self, $vname, $instance);
76 20 ▶ Carp::croak($error->message) if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 20 20
77 20 $self;
78 9 });
79  
80  
81 $ffi->attach( instantiate => ['wasmtime_linker_t','wasm_module_t','opaque*','opaque*'] => 'wasmtime_error_t' => sub {
82 21 ▶ my($xsub, $self, $module) = @_;
Subroutine __ANON__: called CC=4 SCAR=14.2
83 21 my $trap;
84 my $ptr;
85 21 my $error = $xsub->($self, $module, \$ptr, \$trap);
86 21 ▶ Carp::croak($error->message) if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 21 21
87 21 ▶ if($trap)
Branch: 2 branches
BranchTrueFalseTotal
if ($trap) { } 1 20 21
elsif ($ptr) { } 20 0 20
88 {
89 1 $trap = Wasm::Wasmtime::Trap->new($trap);
90 1 die $trap;
91 }
92 elsif($ptr)
93 {
94 20 return Wasm::Wasmtime::Instance->new(
95 $module, $self->store, $ptr,
96 );
97 }
98 else
99 {
100 0 Carp::croak("unknown instantiate error");
101 }
102 9 });
103  
104  
105 $ffi->attach( get_one_by_name => ['wasmtime_linker_t','wasm_byte_vec_t*','wasm_byte_vec_t*','opaque*'] => 'wasmtime_error_t' => sub {
106 2 ▶ my($xsub, $self, $module, $name) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.0
107 2 my $vmodule = Wasm::Wasmtime::ByteVec->new($module);
108 2 my $vname = Wasm::Wasmtime::ByteVec->new($name);
109 2 my $ptr;
110 2 ▶ if(my $error = $xsub->($self, $vmodule, $vname, \$ptr))
Branch: 1 branch
BranchTrueFalseTotal
if (my $error = &$xsub($self, $vmodule, $vname, \$ptr)) { } 1 1 2
111 {
112 1 Carp::croak($error->message);
113 }
114 else
115 {
116 1 ▶ $ptr
Branch: 1 branch
BranchTrueFalseTotal
$ptr ? : 1 0 1
117 ? $ffi->cast('opaque','wasm_extern_t',$ptr)
118 : undef;
119 }
120 9 });
121  
122  
123 $ffi->attach( get_default => ['wasmtime_linker_t','wasm_byte_vec_t*','opaque*'] => 'wasmtime_error_t' => sub {
124 1 ▶ my($xsub, $self, $name) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.8
125 1 my $vname = Wasm::Wasmtime::ByteVec->new($name);
126 1 my $ptr;
127 1 ▶ if(my $error = $xsub->($self, $vname, \$ptr))
Branch: 1 branch
BranchTrueFalseTotal
if (my $error = &$xsub($self, $vname, \$ptr)) { } 0 1 1
128 {
129 0 Carp::croak($error->message);
130 }
131 else
132 {
133 1 ▶ return $ptr ? Wasm::Wasmtime::Func->new($ptr, $self) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$ptr ? : 1 0 1
134 }
135 9 });
136  
137  
138 46 ▶sub store { shift->{store} }
Subroutine store: called CC=1 SCAR=0.0
Pod documented
139  
140 9 _generate_destroy();
141  
142 9 1;
143  
144 __END__
« blib/lib/Wasm/Wasmtime/ImportType.pm ↑ Summary blib/lib/Wasm/Wasmtime/TableType.pm »