blib/lib/Wasm/Wasmtime/Trap.pm

filter: Statementstmt 100% 45 / 45 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod n/a totaltotal 100% 60 / 60 CC 3 SCAR 2.7
CC
3
Cov
100%
__ANON__
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.3
« blib/lib/Wasm/Wasmtime/ExternType.pm ↑ Summary blib/lib/Wasm/Wasmtime/Wat2Wasm.pm »
1 package Wasm::Wasmtime::Trap;
2  
3 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 17 ▶use Wasm::Wasmtime::FFI;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 17 ▶use Wasm::Wasmtime::Store;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 use overload
9 4 ▶ '""' => sub { shift->message . "\n" },
Subroutine __ANON__: called CC=1 SCAR=0.0
10 12 ▶ bool => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
11 17 ▶ fallback => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # ABSTRACT: Wasmtime trap class
14 17 our $VERSION = '0.23'; # VERSION
15  
16  
17 17 $ffi_prefix = 'wasm_trap_';
18 17 $ffi->load_custom_type('::PtrObject' => 'wasm_trap_t' => __PACKAGE__);
19  
20  
21 $ffi->attach( new => [ 'wasm_store_t', 'wasm_byte_vec_t*' ] => 'wasm_trap_t' => sub {
22 5 ▶ my $xsub = shift;
Subroutine __ANON__: called CC=2 SCAR=6.9
23 5 my $class = shift;
24 5 ▶ if(@_ == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 1 4 5
25 {
26 1 my $ptr = shift;
27 1 return bless {
28 ptr => $ptr,
29 }, $class;
30 }
31 else
32 {
33 4 my $store = shift;
34 4 my $message = Wasm::Wasmtime::ByteVec->new($_[0]);
35 4 return $xsub->($store, $message);
36 }
37 17 });
38  
39  
40 $ffi->attach( message => ['wasm_trap_t', 'wasm_byte_vec_t*'] => sub {
41 8 ▶ my($xsub, $self) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
42 8 my $message = Wasm::Wasmtime::ByteVec->new;
43 8 $xsub->($self, $message);
44 8 my $ret = $message->get;
45 8 $ret =~ s/\0$//;
46 8 $message->delete;
47 8 $ret;
48 17 });
49  
50  
51 $ffi->attach( [ wasmtime_trap_exit_status => 'exit_status' ] => ['wasm_trap_t', 'int*'] => 'bool' => sub {
52 4 ▶ my($xsub, $self) = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
53 4 my $status;
54 4 ▶ $xsub->($self, \$status)
Branch: 1 branch
BranchTrueFalseTotal
&$xsub($self, \$status) ? : 2 2 4
55 ? $status
56 : undef;
57 17 });
58  
59 17 _generate_destroy();
60  
61 17 1;
62  
63 __END__
« blib/lib/Wasm/Wasmtime/ExternType.pm ↑ Summary blib/lib/Wasm/Wasmtime/Wat2Wasm.pm »