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