blib/lib/Wasm/Wasmtime/WasiInstance.pm

filter: Statementstmt 92.3% 36 / 39 Branchbran 50.0% 3 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 86.2% 50 / 58 CC 5 SCAR 11.0
CC
5
Cov
85%
__ANON__
5.8
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« blib/lib/Wasm/Wasmtime/Func.pm ↑ Summary blib/lib/Wasm/Hook.pm »
1 package Wasm::Wasmtime::WasiInstance;
2  
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 10 ▶use Wasm::Wasmtime::FFI;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 10 ▶use Wasm::Wasmtime::Store;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use Wasm::Wasmtime::Trap;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use Wasm::Wasmtime::WasiConfig;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # ABSTRACT: WASI instance class
12 10 our $VERSION = '0.23'; # VERSION
13  
14  
15 10 $ffi_prefix = 'wasi_instance_';
16 10 $ffi->load_custom_type('::PtrObject' => 'wasi_instance_t' => __PACKAGE__);
17  
18  
19 $ffi->attach( new => ['wasm_store_t', 'string', 'wasi_config_t', 'opaque*'] => 'wasi_instance_t' => sub {
20 6 ▶ my $xsub = shift;
Subroutine __ANON__: called CC=5 SCAR=17.6
21 6 my $class = shift;
22 6 my $store = shift;
23 6 my $name = shift;
24 6 ▶ my $config = defined $_[0] && ref($_[0]) eq 'Wasm::Wasmtime::WasiConfig' ? shift : Wasm::Wasmtime::WasiConfig->new;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] && ref $_[0] eq 'Wasm::Wasmtime::WasiConfig' ? : 4 2 6
Condition66%2/3
defined $_[0] and ref $_[0] eq "Wasm::Wasmtime::WasiConfig"
!ll&&!rl&&r
204
MC/DC50%1/2
defined $_[0] and ref $_[0] eq "Wasm::Wasmtime::WasiConfig"
defined $_[0] ref $_[0] eq "Wasm::Wasmtime::WasiConfig"
Truth table66%2/3
A and B
A= defined $_[0]B= ref $_[0] eq "Wasm::Wasmtime::WasiConfig"
ABresult
0X0
100
111
25 6 my $trap;
26 6 my $instance = $xsub->($store, $name, $config, \$trap);
27 6 delete $config->{ptr};
28 6 ▶ unless($instance)
Branch: 1 branch
BranchTrueFalseTotal
unless ($instance) 0 6 6
29 {
30 0 ▶ if($trap)
Branch: 1 branch
BranchTrueFalseTotal
if ($trap) 0 0 0
31 {
32 0 die Wasm::Wasmtime::Trap->new($trap);
33 }
34 0 Carp::croak("failed to create wasi instance");
35 }
36 6 $instance;
37 10 });
38  
39 # TODO: bind_import
40  
41 10 _generate_destroy();
42  
43 10 1;
44  
45 __END__
« blib/lib/Wasm/Wasmtime/Func.pm ↑ Summary blib/lib/Wasm/Hook.pm »