| 1 | package Acme::ComeFrom; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | $Acme::ComeFrom::VERSION = '0.11'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use 5.005; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use vars qw/$CacheEXPR/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Filter::Simple 0.70; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | my $Mark = '__COME_FROM'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | my $count = '0000'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | FILTER_ONLY code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=20 SCAR=32.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | my ( %subs, %labels, @tokens, @counts ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | my $source = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | $_ = $source and return unless $source =~ /comefrom/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition25%1/4
$source =~ /comefrom/ || ($_ = $source) && (return)
$_ = $source and return
MC/DC0%0/2
$source =~ /comefrom/ || ($_ = $source) && (return)
$source =~ /comefrom/
$_ = $source
Truth table33%1/3
A || B
A= $source =~ /comefrom/B= $_ = $source
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | while ( $source =~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | s/\bcomefrom\b(\s*)\(?(&?)?([\w\:]+|[^\;]+)(?:\(\))?\)?/$Mark$count:$1/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 7 | my $token = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 7 | ▶ | push @{ $subs{$token} }, $count++ and next if $2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%3/4
$2 && (push(@{$subs{$token};}, $count++) && (next))
push @{$subs{$token};}, $count++ and next
MC/DC0%0/2
$2 && (push(@{$subs{$token};}, $count++) && (next))
$2
push @{$subs{$token};}, $count++
Truth table33%1/3
A && B
A= $2B= push @{$subs{$token};}, $count++
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 6 | ▶ | push @{ $labels{$token} }, $count++ and next if $token =~ /^[\w\:]+$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%3/4
$token =~ /^[\w\:]+$/ && (push(@{$labels{$token};}, $count++) && (next))
push @{$labels{$token};}, $count++ and next
MC/DC0%0/2
$token =~ /^[\w\:]+$/ && (push(@{$labels{$token};}, $count++) && (next))
$token =~ /^[\w\:]+$/
push @{$labels{$token};}, $count++
Truth table33%1/3
A && B
A= $token =~ /^[\w\:]+$/B= push @{$labels{$token};}, $count++
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | push @tokens, $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | push @counts, $count++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | ▶ | $_ = $source and return unless %subs or %labels or @tokens; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%5/10
%subs || %labels || @tokens || ($_ = $source) && (return)
%subs or %labels or @tokens
%subs or %labels
$_ = $source and return
MC/DC0%0/4
%subs || %labels || @tokens || ($_ = $source) && (return)
%subs
%labels
@tokens
$_ = $source
Truth table40%2/5
A or B or C || D
A= %subsB= %labelsC= @tokensD= $_ = $source
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | my $code = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | ▶ | if (%subs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | require Hook::LexWrap; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | $code .= 'require Hook::LexWrap;'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 3 | ▶ | while ( my ( $k, $v ) = each %subs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | my $chunk = make_chunk($v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | $code .= "Hook::LexWrap::wrap($k, post => sub { $chunk });"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | ▶ | if (@tokens) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 3 | $source =~ s!(\n\s*)([a-zA-Z_]\w+):! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 12 | my $label = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | my $chunk = make_chunk( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 12 | ▶ | [ @counts, exists $labels{$label} ? @{$labels{$label}} : ()], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | $label, \@tokens | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ) unless substr($label, 0, length($Mark)) eq $Mark; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 12 | ▶ | "$1$label:" . ($chunk ? "do {$chunk};" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | !eg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | while ( my ( $k, $v ) = each %labels ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $chunk = make_chunk($v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $source =~ s!\Q$k\E:!$k: do {$chunk};!g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 3 | ▶ | $_ = ( $code ? "CHECK { $code; 1 };" : '' ) . $source; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 7 | ▶ | sub make_chunk { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_chunk: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 7 | my $pkg = '$' . __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 7 | my ( $v, $label, $cond ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 7 | my $chunk = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 7 | foreach my $iter ( 0 .. $#{$v} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 9 | my $fork = ( $iter != $#{$v} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 9 | ▶ | if ( defined $cond->[$iter] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 6 | ▶ | my $forktext = ( $fork ? ' or fork' : '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 6 | $chunk .= " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | if (\$Acme::ComeFrom::CacheEXPR) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | $pkg\::CACHE[$v->[$iter]] = eval q;$cond->[$iter]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | unless exists $pkg\::CACHE[$v->[$iter]]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | goto $Mark$v->[$iter] unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ('$label' ne $pkg\::CACHE[$v->[$iter]])$forktext; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | goto $Mark$v->[$iter] unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | ('$label' ne eval q;$cond->[$iter];)$forktext; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | "; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 3 | ▶ | $chunk .= "goto $Mark$v->[$iter]" . ( $fork ? " unless fork();" : ';' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 7 | $chunk =~ s/\n */ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 7 | return $chunk; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||