| 1 | 1 | ▶ | use 5.008003; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | no warnings qw( void once uninitialized ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | package Sub::HandlesVia::Toolkit::SubAccessorSmall; | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | our $VERSION = '1.001002'; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Sub::HandlesVia::Toolkit; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | our @ISA = 'Sub::HandlesVia::Toolkit'; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | $ISA[0]->VERSION( '0.025' ); | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | bless { @_ } => $class; | |||||||||||||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | sub _attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_attr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | shift->{attr}; | |||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | sub _handles_map { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handles_map: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | shift->{handles_map}; | |||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | sub clean_spec { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_spec: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | my ( $self, $target, $attr, $spec ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | if ( 'ARRAY' eq ref $spec->{handles} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | my %tmp = @{ $spec->{handles} }; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | $spec->{handles} = \%tmp; | |||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | return $self->SUPER::clean_spec( $target, $attr, $spec ); | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | sub code_generator_for_attribute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
code_generator_for_attribute: called CC=4 SCAR=19.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | my ( $self, $target, $attr ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | my $realattr = $self->_attr; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | my $handles_map = $self->_handles_map; | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | my $captures = ( $realattr->{inline_environment} ||= {} ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$realattr->{"inline_environment"} ||= {}
MC/DC0%0/1
$realattr->{"inline_environment"} ||= {}
$realattr->{"inline_environment"}
Truth table50%1/2
A
A= $realattr->{"inline_environment"}
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | my $slot = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $gen = shift; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | delete local $realattr->{chain}; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $realattr->inline_access($gen->generate_self); | |||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | my ( $get, $set, $get_is_lvalue ); | |||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | if ( $realattr->has_simple_reader ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 3 | ▶ | $get = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 3 | my $gen = shift; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | return $realattr->inline_access($gen->generate_self); | |||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | $get_is_lvalue = !!1; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | $get = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $gen = shift; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | return $realattr->inline_reader( $gen->generate_self ); | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | ▶ | if ( $realattr->has_simple_writer ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $set = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | my ( $gen, $val ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | delete local $realattr->{chain}; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | return sprintf('(%s)', $realattr->inline_access_w($gen->generate_self, $val) ); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | $set = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my ( $gen, $val ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | delete local $realattr->{chain}; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | return $realattr->inline_writer( $gen->generate_self, $val ); | |||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | require Sub::HandlesVia::CodeGenerator; | |||||||||||||||||||||||||||||||||||||||||
| 82 | return 'Sub::HandlesVia::CodeGenerator'->new( | ||||||||||||||||||||||||||||||||||||||||||
| 83 | toolkit => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | target => $target, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | attribute => $attr, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | env => $captures, | ||||||||||||||||||||||||||||||||||||||||||
| 87 | isa => $realattr->{isa}, | ||||||||||||||||||||||||||||||||||||||||||
| 88 | coerce => $realattr->{coerce}, | ||||||||||||||||||||||||||||||||||||||||||
| 89 | generator_for_get => $get, | ||||||||||||||||||||||||||||||||||||||||||
| 90 | generator_for_set => $set, | ||||||||||||||||||||||||||||||||||||||||||
| 91 | generator_for_slot => $slot, | ||||||||||||||||||||||||||||||||||||||||||
| 92 | get_is_lvalue => $get_is_lvalue, | ||||||||||||||||||||||||||||||||||||||||||
| 93 | set_checks_isa => !!1, | ||||||||||||||||||||||||||||||||||||||||||
| 94 | set_strictly => !!0, | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | ▶ | method_installer => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | my ( $method_name, $coderef ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | my $real_destination = $handles_map->{$method_name}; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | $realattr->install_coderef( $real_destination, $coderef ); | |||||||||||||||||||||||||||||||||||||||||
| 99 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | generator_for_default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | my ( $gen, $handler ) = @_ or die; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | if ( $handler and not $realattr->{builder} and not exists $realattr->{default} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$handler and not $realattr->{"builder"} and not exists $realattr->{"default"}
$handler and not $realattr->{"builder"}
MC/DC0%0/3
$handler and not $realattr->{"builder"} and not exists $realattr->{"default"}
$handler
not $realattr->{"builder"}
not exists $realattr->{"default"}
Truth table0%0/4
A and not(B) and not(C)
A= $handlerB= not $realattr->{"builder"}C= not exists $realattr->{"default"}
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | return $handler->default_for_reset->(); | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | return $realattr->inline_default($gen->generate_self, '$default'); | |||||||||||||||||||||||||||||||||||||||||
| 106 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||