blib/lib/Wasm/Wasmtime/Module/Exports.pm

filter: Statementstmt 95.9% 47 / 49 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 78.5% 11 / 14 Podpod 0.0% 0 / 2 totaltotal 85.1% 63 / 74 CC 6 SCAR 5.5
CC
6
Cov
93%
new
3.0
can
2.0
AUTOLOAD
2.0
CRAP 1.7
« blib/lib/Wasm/Wasmtime/Module/Imports.pm ↑ Summary blib/lib/Wasm/Wasmtime/Instance/Exports.pm »
1 package Wasm::Wasmtime::Module::Exports;
2  
3 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 22 ▶use 5.008004;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 22 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 22 ▶use Hash::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 use overload
9 22 ▶ '%{}' => sub {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
10 4 my $self = shift;
11 4 my $module = $$self;
12 4 $module->{exports};
13 },
14 57 ▶ '@{}' => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
15 57 my $self = shift;
16 57 my $module = $$self;
17 57 my @exports = $module->_exports;
18 57 Internals::SvREADONLY @exports, 1;
19 57 Internals::SvREADONLY $exports[$_], 1 for 0..$#exports;
20 57 \@exports;
21 },
22 0 ▶ bool => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 22 fallback => 1;
24  
25 # ABSTRACT: Wasmtime module exports class
26 22 our $VERSION = '0.24'; # VERSION
27  
28  
29 sub new
30 57 ▶{
Subroutine new: called CC=3 SCAR=11.0
Pod undocumented
31 57 my($class, $module) = @_;
32  
33 57 ▶ $module->{exports} ||= do {
Condition66%2/3
$module->{"exports"} ||= do { my(@exports) = $module->_exports; my %exports; foreach my $export (@exports) { $exports{$export->name} = $export->type; } ; &Hash::Util::lock_hash(\%exports); \%exports }
l!l&&r!l&&!r
19380
MC/DC0%0/2
$module->{"exports"} ||= do { my(@exports) = $module->_exports; my %exports; foreach my $export (@exports) { $exports{$export->name} = $export->type; } ; &Hash::Util::lock_hash(\%exports); \%exports }
$module->{"exports"} do { my(@exports) = $module->_exports; my %exports; foreach my $export (@exports) { $exports{$export->name} = $export->type; } ; &Hash::Util::lock_hash(\%exports); \%exports }
Truth table66%2/3
A ||= B
A= $module->{"exports"}B= do { my(@exports) = $module->_exports; my %exports; foreach my $export (@exports) { $exports{$export->name} = $export->type; } ; &Hash::Util::lock_hash(\%exports); \%exports }
ABresult
1X1
011
000
34 38 my @exports = $module->_exports;
35 38 my %exports;
36 38 foreach my $export (@exports)
37 {
38 71 $exports{$export->name} = $export->type;
39 }
40 38 Hash::Util::lock_hash(%exports);
41 38 \%exports;
42 };
43  
44 57 bless \$module, $class;
45 }
46  
47 sub can
48 10 ▶{
Subroutine can: called CC=2 SCAR=7.0
Pod undocumented
49 10 my($self, $name) = @_;
50 10 my $module = $$self;
51 exists $module->{exports}->{$name}
52 0 ▶ ? sub { $self->$name }
Subroutine __ANON__: not called CC=1 SCAR=6.9
53 10 ▶ : $self->SUPER::can($name);
Branch: 1 branch
BranchTrueFalseTotal
exists $module->{'exports'}{$name} ? : 7 3 10
54 }
55  
56 sub AUTOLOAD
57 7 ▶{
Subroutine AUTOLOAD: called CC=2 SCAR=7.0
58 7 our $AUTOLOAD;
59 7 my $self = shift;
60  
61 7 my $name = $AUTOLOAD;
62 7 $name=~ s/^.*:://;
63  
64 7 my $module = $$self;
65 7 ▶ Carp::croak("no export $name") unless exists $module->{exports}->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $module->{"exports"}{$name} 0 7 7
66 7 $module->{exports}->{$name};
67 }
68  
69 sub DESTROY
70 0 ▶{
Subroutine DESTROY: not called CC=1 SCAR=0.0
71 # needed because of AUTOLOAD
72 }
73  
74  
75 22 1;
76  
77 __END__
« blib/lib/Wasm/Wasmtime/Module/Imports.pm ↑ Summary blib/lib/Wasm/Wasmtime/Instance/Exports.pm »