blib/lib/Wasm/Wasmtime/FuncType.pm

filter: Statementstmt 96.7% 60 / 62 Branchbran 87.5% 7 / 8 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 13 / 13 Podpod 100% 1 / 1 totaltotal 90.4% 85 / 94 CC 7 SCAR 8.8
CC
7
Cov
92%
to_string
5.0
__ANON__
3.2
BEGIN
1.0
CRAP 2.4
« blib/lib/Wasm/Wasmtime/MemoryType.pm ↑ Summary blib/lib/Wasm/Wasmtime/Memory.pm »
1 package Wasm::Wasmtime::FuncType;
2  
3 26 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 26 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 26 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 26 ▶use base qw( Wasm::Wasmtime::ExternType );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 26 ▶use Ref::Util qw( is_arrayref );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 26 ▶use Wasm::Wasmtime::FFI;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 26 ▶use Wasm::Wasmtime::ValType;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 26 ▶use constant is_functype => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 26 ▶use constant kind => 'functype';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # ABSTRACT: Wasmtime function type class
14 26 our $VERSION = '0.24'; # VERSION
15  
16  
17 26 $ffi_prefix = 'wasm_functype_';
18 26 $ffi->load_custom_type('::PtrObject' => 'wasm_functype_t' => __PACKAGE__);
19  
20  
21 10 ▶$ffi->attach( new => ['wasm_valtype_vec_t*', 'wasm_valtype_vec_t*'] => 'wasm_functype_t' => sub {
Subroutine __ANON__: called CC=3 SCAR=11.6
22 10 my $xsub = shift;
23 10 my $class = shift;
24 10 ▶ if(is_arrayref $_[0] && is_arrayref $_[1])
Branch: 1 branch
BranchTrueFalseTotal
if (is_arrayref($_[0]) and is_arrayref($_[1])) { } 10 0 10
Condition33%1/3
is_arrayref($_[0]) and is_arrayref($_[1])
!ll&&!rl&&r
0010
MC/DC0%0/2
is_arrayref($_[0]) and is_arrayref($_[1])
is_arrayref($_[0]) is_arrayref($_[1])
Truth table33%1/3
A and B
A= is_arrayref($_[0])B= is_arrayref($_[1])
ABresult
0X0
100
111
25 {
26 # try not to think too much about all of the maps here
27 20 my($params, $results) = map { my $rec = Wasm::Wasmtime::ValTypeVec->new; $rec->set($_) }
28 10 map { [map { delete $_->{ptr} } map { Wasm::Wasmtime::ValType->new($_) } @$_] } @_;
29 10 my $self = $xsub->($params, $results);
30 10 return $self;
31 }
32 else
33 {
34 0 my($ptr, $owner) = @_;
35 0 bless {
36 ptr => $ptr,
37 owner => $owner,
38 }, $class;
39 }
40 26 });
41  
42  
43 78 ▶$ffi->attach( params => ['wasm_functype_t'] => 'wasm_valtype_vec_t*' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
44 78 my($xsub, $self) = @_;
45 78 $xsub->($self)->to_list;
46 26 });
47  
48  
49 76 ▶$ffi->attach( results => ['wasm_functype_t'] => 'wasm_valtype_vec_t*' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
50 76 my($xsub, $self) = @_;
51 76 $xsub->($self)->to_list;
52 26 });
53  
54  
55 sub to_string
56 5 ▶{
Subroutine to_string: called CC=5 SCAR=16.1
Pod documented
57 5 my($self) = @_;
58 5 my @params = map { $_->to_string } $self->params;
59 5 my @results = map { $_->to_string } $self->results;
60  
61 5 my $string = '';
62 5 ▶ $string .= "(param @params)" if @params;
Branch: 1 branch
BranchTrueFalseTotal
if @params 4 1 5
63 5 ▶ $string .= ' ' if $string && @results;
Branch: 1 branch
BranchTrueFalseTotal
if $string and @results 4 1 5
Condition66%2/3
$string and @results
!ll&&!rl&&r
104
MC/DC50%1/2
$string and @results
$string @results
Truth table66%2/3
A and B
A= $stringB= @results
ABresult
0X0
100
111
64 5 ▶ $string .= "(result @results)" if @results;
Branch: 1 branch
BranchTrueFalseTotal
if @results 4 1 5
65 5 $string;
66 }
67  
68 26 __PACKAGE__->_cast(0);
69 26 _generate_destroy();
70  
71 26 1;
72  
73 __END__
« blib/lib/Wasm/Wasmtime/MemoryType.pm ↑ Summary blib/lib/Wasm/Wasmtime/Memory.pm »