blib/lib/Wasm/Wasmtime/ExternType.pm

filter: Statementstmt 95.4% 42 / 44 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 10 / 12 Podpod 100% 2 / 2 totaltotal 91.6% 55 / 60 CC 2 SCAR 2.7
CC
2
Cov
93%
__ANON__
2.0
kind
2.0
to_string
2.0
CRAP 1.3
« blib/lib/Wasm/Wasmtime/WasiConfig.pm ↑ Summary blib/lib/Wasm/Wasmtime/Wat2Wasm.pm »
1 package Wasm::Wasmtime::ExternType;
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 Wasm::Wasmtime::FFI;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 26 require Wasm::Wasmtime::FuncType;
9 26 require Wasm::Wasmtime::GlobalType;
10 26 require Wasm::Wasmtime::TableType;
11 26 require Wasm::Wasmtime::MemoryType;
12  
13 # ABSTRACT: Wasmtime extern type class
14 26 our $VERSION = '0.24'; # VERSION
15  
16  
17 0 ▶sub kind { die "internal error" };
Subroutine kind: not called CC=1 SCAR=6.9
Pod documented
18 26 ▶use constant is_functype => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 26 ▶use constant is_globaltype => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 26 ▶use constant is_tabletype => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 26 ▶use constant is_memorytype => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 26 $ffi_prefix = 'wasm_externtype_';
24  
25 26 $ffi->attach( [ kind => '_kind' ] => ['opaque'] => 'uint8' );
26  
27 26 my @cast;
28  
29 sub _cast
30 104 ▶{
Subroutine _cast: called CC=1 SCAR=0.0
31 104 my(undef, $index) = @_;
32 104 my $caller = caller;
33 104 my($name) = map { lc $_ } $caller =~ /::([a-z]+Type)$/i;
34 104 $cast[$index] = $ffi->function( "wasm_externtype_as_$name" => ['opaque'] => "wasm_${name}_t" )->sub_ref;
35 }
36  
37 $ffi->custom_type('wasm_externtype_t' => {
38 native_type => 'opaque',
39 162 ▶ native_to_perl => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
40 162 my $externtype = shift;
41 162 ▶ Carp::croak("externtype error") unless defined $externtype;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $externtype 0 162 162
42 162 my $kind = _kind($externtype);
43 162 $cast[$kind]->($externtype);
44 },
45 26 });
46  
47  
48 sub to_string
49 0 ▶{
Subroutine to_string: not called CC=1 SCAR=6.9
Pod documented
50 0 die "internal error"; # pure virtual ish
51 }
52  
53 26 1;
54  
55 __END__
« blib/lib/Wasm/Wasmtime/WasiConfig.pm ↑ Summary blib/lib/Wasm/Wasmtime/Wat2Wasm.pm »