blib/lib/Wasm/Wasmtime/Extern.pm

filter: Statementstmt 94.6% 53 / 56 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 87.5% 14 / 16 Podpod 100% 5 / 5 totaltotal 90.2% 74 / 82 CC 4 SCAR 4.4
CC
4
Cov
92%
from_extern
3.2
kind
2.0
store
2.0
CRAP 1.6
« blib/lib/Wasm/Wasmtime/ValType.pm ↑ Summary blib/lib/Wasm/Wasmtime/WasiConfig.pm »
1 package Wasm::Wasmtime::Extern;
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 FFI::C::Util qw( c_to_perl );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 16 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 16 ▶use Wasm::Wasmtime::FFI;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 16 require Wasm::Wasmtime::Func;
11 16 require Wasm::Wasmtime::Global;
12 16 require Wasm::Wasmtime::Table;
13 16 require Wasm::Wasmtime::Memory;
14  
15 # ABSTRACT: Wasmtime extern class
16 16 our $VERSION = '0.24'; # VERSION
17  
18  
19 16 ▶use constant is_func => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 16 ▶use constant is_global => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 16 ▶use constant is_table => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 16 ▶use constant is_memory => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 0 ▶sub kind { die "internal error" }
Subroutine kind: not called CC=1 SCAR=6.9
Pod documented
25  
26 16 my %CLASS_FOR_KIND = (
27 func => 'Wasm::Wasmtime::Func',
28 global => 'Wasm::Wasmtime::Global',
29 table => 'Wasm::Wasmtime::Table',
30 memory => 'Wasm::Wasmtime::Memory',
31 );
32  
33 16 my %DATA_CLASS = (
34 func => 'Wasm::Wasmtime::FuncData',
35 global => 'Wasm::Wasmtime::GlobalData',
36 table => 'Wasm::Wasmtime::TableData',
37 memory => 'Wasm::Wasmtime::MemoryData',
38 );
39  
40  
41 sub from_extern
42 109 ▶{
Subroutine from_extern: called CC=3 SCAR=11.6
Pod documented
43 109 my(undef, $extern, $store, $owner) = @_;
44 109 my $kind = $Wasm::Wasmtime::FFI::EXTERN_KIND{$extern->kind};
45 109 ▶ my $class = $CLASS_FOR_KIND{$kind || ''}
Branch: 1 branch
BranchTrueFalseTotal
my $class = $CLASS_FOR_KIND{$kind or ""} or Carp::croak("unsupported extern kind: @{[$extern->kind];}") 109 0 109
Condition50%1/2
$kind || ''
l!l
1090
MC/DC0%0/1
$kind || ''
$kind
Truth table50%1/2
A
A= $kind
Aresult
11
00
46 0 or Carp::croak("unsupported extern kind: @{[ $extern->kind ]}");
47 109 my $data_class = $DATA_CLASS{$kind};
48 109 my $data = $data_class->new( c_to_perl($extern->of->$kind) );
49 109 bless { data => $data, store => $store, owner => $owner }, $class;
50 }
51  
52  
53 0 ▶sub store { shift->{store} }
Subroutine store: not called CC=1 SCAR=6.9
Pod documented
54  
55  
56 127 ▶sub context { shift->{store}->context }
Subroutine context: called CC=1 SCAR=0.0
Pod documented
57  
58 # _fill_extern($dst) writes this object's handle into an existing
59 # Wasm::Wasmtime::ExternData (wasmtime_extern_t).
60 sub _fill_extern
61 10 ▶{
Subroutine _fill_extern: called CC=2 SCAR=6.9
62 10 my($self, $extern) = @_;
63 10 my $kind = $self->kind;
64 10 $extern->kind($Wasm::Wasmtime::FFI::EXTERN_KIND_NUM{$kind});
65 10 my $slot = $extern->of->$kind;
66 10 my $src = c_to_perl($self->{data});
67 10 $slot->$_($src->{$_}) for keys %$src;
68 10 $extern;
69 }
70  
71  
72 sub to_extern
73 5 ▶{
Subroutine to_extern: called CC=1 SCAR=0.0
Pod documented
74 5 my($self) = @_;
75 5 $self->_fill_extern(Wasm::Wasmtime::ExternData->new);
76 }
77  
78 16 1;
79  
80 __END__
« blib/lib/Wasm/Wasmtime/ValType.pm ↑ Summary blib/lib/Wasm/Wasmtime/WasiConfig.pm »