blib/lib/Wasm/Wasmtime/Global.pm

filter: Statementstmt 97.0% 65 / 67 Branchbran 50.0% 1 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 16 / 16 Podpod 100% 1 / 1 totaltotal 93.4% 85 / 91 CC 3 SCAR 2.1
CC
3
Cov
94%
__ANON__
2.1
__ANON__
2.0
BEGIN
1.0
CRAP 1.2
« blib/lib/Wasm/Wasmtime/WasiConfig.pm ↑ Summary blib/lib/Wasm/Wasmtime/Extern.pm »
1 package Wasm::Wasmtime::Global;
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_ref );
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::GlobalType;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 16 ▶use constant is_global => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 16 ▶use constant kind => 'global';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # ABSTRACT: Wasmtime global class
15 16 our $VERSION = '0.23'; # VERSION
16  
17  
18 16 $ffi_prefix = 'wasm_global_';
19 16 $ffi->load_custom_type('::PtrObject' => 'wasm_global_t' => __PACKAGE__);
20  
21  
22 $ffi->attach( new => ['wasm_store_t', 'wasm_globaltype_t', 'wasm_val_t'] => 'wasm_global_t' => sub {
23 2 ▶ my $xsub = shift;
Subroutine __ANON__: called CC=2 SCAR=7.2
24 2 my $class = shift;
25 2 ▶ if(is_ref $_[0])
Branch: 1 branch
BranchTrueFalseTotal
if (is_ref($_[0])) { } 2 0 2
26 {
27 2 my($store, $globaltype, $value) = @_;
28 2 $value = Wasm::Wasmtime::Val->new({
29 kind => $globaltype->content->kind_num,
30 of => { $globaltype->content->kind => $value },
31 });
32 2 my $self = $xsub->($store, $globaltype, $value);
33 2 $self->{store} = $store;
34 2 return $self;
35 }
36 else
37 {
38 0 my($ptr, $owner) = @_;
39 0 bless {
40 ptr => $ptr,
41 owner => $owner,
42 }, $class;
43 }
44 16 });
45  
46  
47 $ffi->attach( type => ['wasm_global_t'] => 'wasm_globaltype_t' => sub {
48 6 ▶ my($xsub, $self) = @_;
Subroutine __ANON__: called CC=2 SCAR=7.0
49 6 my $type = $xsub->($self);
50 6 ▶ $type->{owner} = $self->{owner} || $self;
Condition66%2/3
$self->{'owner'} || $self
l!l&&r!l&&!r
150
MC/DC0%0/2
$self->{'owner'} || $self
$self->{'owner'} $self
Truth table66%2/3
A || B
A= $self->{'owner'}B= $self
ABresult
1X1
011
000
51 6 $type;
52 16 });
53  
54  
55 $ffi->attach( get => ['wasm_global_t', 'wasm_val_t'] => sub {
56 11 ▶ my($xsub, $self) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
57 11 my $value = Wasm::Wasmtime::Val->new;
58 11 $xsub->($self, $value);
59 11 $value->to_perl;
60 16 });
61  
62  
63 $ffi->attach( set => ['wasm_global_t','wasm_val_t'] => sub {
64 2 ▶ my($xsub, $self, $value) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
65 2 $value = Wasm::Wasmtime::Val->new({
66 kind => $self->type->content->kind_num,
67 of => { $self->type->content->kind => $value },
68 });
69 2 $xsub->($self, $value);
70 16 });
71  
72  
73 sub tie
74 {
75 4 ▶ my $self = shift;
Subroutine tie: called CC=1 SCAR=0.0
Pod documented
76 4 my $ref;
77 4 tie $ref, __PACKAGE__, $self;
78 4 \$ref;
79 }
80  
81 4 ▶sub TIESCALAR { $_[1] }
Subroutine TIESCALAR: called CC=1 SCAR=0.0
82 16 *FETCH = \&get;
83 16 *STORE = \&set;
84  
85 16 __PACKAGE__->_cast(1);
86 16 _generate_destroy();
87  
88 16 1;
89  
90 __END__
« blib/lib/Wasm/Wasmtime/WasiConfig.pm ↑ Summary blib/lib/Wasm/Wasmtime/Extern.pm »