| 1 | package Perl6::Gather; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Perl6::Export; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 0 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.5
Subroutine
BEGIN: called CC=2 SCAR=9.7
Subroutine
BEGIN: called CC=1 SCAR=1.5
Subroutine
_import_16ca23858bb28246dfa2fcc876a8131f: called CC=1 SCAR=1.5
Subroutine
import: called CC=8 SCAR=29.1
Branch: 3 branches
Condition9%1/11
$EXPORT_TAGS{"MANDATORY"} ||= []
not ref $_ and /^[:\$&%\@]?(\w+)$/ and exists $EXPORT{$1} || exists $EXPORT_TAGS{$1}
not ref $_ and /^[:\$&%\@]?(\w+)$/
exists $EXPORT{$1} or exists $EXPORT_TAGS{$1}
MC/DC0%0/1
$EXPORT_TAGS{"MANDATORY"} ||= []
$EXPORT_TAGS{"MANDATORY"}
MC/DC0%0/4
not ref $_ and /^[:\$&%\@]?(\w+)$/ and exists $EXPORT{$1} || exists $EXPORT_TAGS{$1}
not ref $_
/^[:\$&%\@]?(\w+)$/
exists $EXPORT{$1}
exists $EXPORT_TAGS{$1}
Truth table50%1/2
A
A= $EXPORT_TAGS{"MANDATORY"}
Truth table0%0/5
not(A) and B and C or D
A= not ref $_B= /^[:\$&%\@]?(\w+)$/C= exists $EXPORT{$1}D= exists $EXPORT_TAGS{$1}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | our $VERSION = '0.42'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | my %gatherers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | sub gather(&) is export(:DEFAULT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=2 SCAR=6.9
Subroutine
gather: called CC=7 SCAR=21.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | croak "Useless use of 'gather' in void context" unless defined wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | my ($code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | local @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | push @{$gatherers{$caller}}, bless \@_, 'Perl6::Gather::MagicArrayRef'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | die $@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | if !eval{ &$code } && $@ && !UNIVERSAL::isa($@, Perl6::Gather::Break); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not eval {
do {
&$code
}
} and $@ and not UNIVERSAL::isa($@, "Perl6::Gather::Break")
not eval {
do {
&$code
}
} and $@
MC/DC0%0/3
not eval {
do {
&$code
}
} and $@ and not UNIVERSAL::isa($@, "Perl6::Gather::Break")
not eval {
do {
&$code
}
}
$@
not UNIVERSAL::isa($@, "Perl6::Gather::Break")
Truth table25%1/4
not(A) and B and not(C)
A= not eval {
do {
&$code
}
}B= $@C= not UNIVERSAL::isa($@, "Perl6::Gather::Break")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | return @{pop @{$gatherers{$caller}}} if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | return pop @{$gatherers{$caller}} if defined wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | sub gathered() is export(:DEFAULT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=2 SCAR=6.9
Subroutine
gathered: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 4 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | ▶ | croak "Call to gathered not inside a gather" unless @{$gatherers{$caller}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | return $gatherers{$caller}[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | sub take(@) is export(:DEFAULT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=2 SCAR=6.9
Subroutine
take: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 33 | ▶ | @_ = $_ unless @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 33 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 33 | ▶ | croak "Call to take not inside a gather block" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
(caller 3)[3] || ''
MC/DC100%1/1
(caller 3)[3] || ''
(caller 3)[3]
Truth table100%2/2
A
A= (caller 3)[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | unless ((caller 3)[3]||"") eq 'Perl6::Gather::gather'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 32 | push @{$gatherers{$caller}[-1]}, @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 32 | return 0+@_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | my $breaker = bless [], 'Perl6::Gather::Break'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | sub break() is export(:DEFAULT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=2 SCAR=6.9
Subroutine
break: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | die $breaker; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | package Perl6::Gather::MagicArrayRef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | use overload | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | ▶ | 'bool' => sub { @{$_[0]} > 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.5
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | '0+' => sub { @{$_[0]} + 0 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | '""' => sub { join "", @{$_[0]} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | '~' => sub { join "", @{$_[0]} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | fallback => 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||