| 1 | package Attribute::Method; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use Attribute::Handlers; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use B::Deparse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 5 | our $VERSION = sprintf "%d.%02d", q$Revision: 1.4 $ =~ /(\d+)/g; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 6 | my $dp = Attribute::Method::_Deparse->new('-l'); | |||||||||||||||||||||||||||
| 11 | 6 | my $dppack; | |||||||||||||||||||||||||||
| 12 | 5 | my %sigil2ref = ( | |||||||||||||||||||||||||||
| 13 | '$' => \undef, | ||||||||||||||||||||||||||||
| 14 | '@' => [], | ||||||||||||||||||||||||||||
| 15 | '%' => {}, | ||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 3 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 19 | 3 | my ( $class, @vars ) = @_; | |||||||||||||||||||||||||||
| 20 | 3 | my $pkg = caller(); | |||||||||||||||||||||||||||
| 21 | 3 | push @vars, '$self'; | |||||||||||||||||||||||||||
| 22 | 3 | for my $var (@vars) { | |||||||||||||||||||||||||||
| 23 | 5 | my $sigil = substr( $var, 0, 1, '' ); | |||||||||||||||||||||||||||
| 24 | 5 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 5 | *{ $pkg . '::' . $var } = $sigil2ref{$sigil}; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 4 | ▶ | sub UNIVERSAL::Method : ATTR(RAWDATA) { | ||||||||||||||||||||||||||
|
Subroutine
Method: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | 4 | my ( $pkg, $sym, $ref, undef, $args ) = @_; | |||||||||||||||||||||||||||
| 31 | 4 | $dppack = $pkg; | |||||||||||||||||||||||||||
| 32 | 4 | my $src = $dp->coderef2text($ref); | |||||||||||||||||||||||||||
| 33 | 4 | ▶ | if ($args) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 1 | $src =~ s/\{/{\nmy \$self = shift; my ($args) = \@_;\n/; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | else { | ||||||||||||||||||||||||||||
| 37 | 3 | $src =~ s/\{/{\nmy \$self = shift;\n/; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | 5 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 40 | 4 | my $sub_name = *{$sym}{NAME}; | |||||||||||||||||||||||||||
| 41 | 4 | ▶ | eval qq{ package $pkg; sub $sub_name $src }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 42 | 5 | ▶ | } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | package | ||||||||||||||||||||||||||||
| 45 | Attribute::Method::_Deparse; | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 5 | ▶ | BEGIN { our @ISA = 'B::Deparse' } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 9 | ▶ | sub maybe_qualify { | ||||||||||||||||||||||||||
|
Subroutine
maybe_qualify: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 50 | 9 | my $ret = SUPER::maybe_qualify{@_}; | |||||||||||||||||||||||||||
| 51 | 8 | my ($pack,$name) = $ret =~ /(.*)::(.+)/; | |||||||||||||||||||||||||||
| 52 | 7 | ▶ | length $pack && $pack eq $dppack and return $name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
length $pack and $pack eq $dppack
MC/DC50%1/2
length $pack and $pack eq $dppack
length $pack
$pack eq $dppack
Truth table66%2/3
A and B
A= length $packB= $pack eq $dppack
| |||||||||||||||||||||||||||||
| 53 | 2 | $ret; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 5 | "Rosebud"; # for MARCEL's sake, not 1 -- dankogai | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | __END__ | ||||||||||||||||||||||||||||