| 1 | package Perl::ToPerl6::Transformer::Variables::ReplaceNegativeIndex; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 17 | ▶ | use 5.006001; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 17 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 17 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 17 | ▶ | use Readonly; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 17 | ▶ | use Perl::ToPerl6::Utils qw{ :severities }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 17 | ▶ | use Perl::ToPerl6::Utils::PPI qw{ is_ppi_token_word }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 17 | ▶ | use base 'Perl::ToPerl6::Transformer'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 17 | Readonly::Scalar my $DESC => q{Negative array indexes now need [*-1] notation}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 17 | Readonly::Scalar my $EXPL => q{Negative array indexes now need [*-1] notation}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # That way we don't have to deal with the integer conversions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 31 | ▶ | sub run_before { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_before: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 31 | return 'BasicTypes::Integers::RewriteBinaryNumbers', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 'BasicTypes::Integers::RewriteOctalNumbers', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 'BasicTypes::Integers::RewriteHexNumbers' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 38 | ▶ | sub supported_parameters { return () } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 28 | ▶ | sub default_necessity { return $NECESSITY_HIGHEST } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_necessity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 24 | ▶ | sub default_themes { return qw( core ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_themes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # Don't test the subscript type because the [-N] may be after a {}. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 5 | ▶ | sub applies_to { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 78 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 78 | ▶ | $_[1]->isa('PPI::Token::Symbol') and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
$_[1]->isa('PPI::Token::Symbol') && $_[1]->snext_sibling && ($_[1]->snext_sibling->isa('PPI::Structure::Subscript') || $_[1]->snext_sibling->isa('PPI::Token::Operator'))
$_[1]->isa("PPI::Token::Symbol") and $_[1]->snext_sibling
$_[1]->snext_sibling->isa("PPI::Structure::Subscript") or $_[1]->snext_sibling->isa("PPI::Token::Operator")
MC/DC75%3/4
$_[1]->isa('PPI::Token::Symbol') && $_[1]->snext_sibling && ($_[1]->snext_sibling->isa('PPI::Structure::Subscript') || $_[1]->snext_sibling->isa('PPI::Token::Operator'))
$_[1]->isa("PPI::Token::Symbol")
$_[1]->snext_sibling
$_[1]->snext_sibling->isa("PPI::Structure::Subscript")
$_[1]->snext_sibling->isa("PPI::Token::Operator")
Truth table80%4/5
A and B && C or D
A= $_[1]->isa("PPI::Token::Symbol")B= $_[1]->snext_siblingC= $_[1]->snext_sibling->isa("PPI::Structure::Subscript")D= $_[1]->snext_sibling->isa("PPI::Token::Operator")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | $_[1]->snext_sibling and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ( $_[1]->snext_sibling->isa('PPI::Structure::Subscript') or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | $_[1]->snext_sibling->isa('PPI::Token::Operator') ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 5 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | sub transform { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
transform: called CC=7 SCAR=28.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | my ($self, $elem, $doc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | my $head = $elem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | ▶ | while ( $head = $head->snext_sibling ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 5 | ▶ | next unless $head->isa('PPI::Structure::Subscript') and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$head->isa("PPI::Structure::Subscript") and $head->start eq "["
MC/DC0%0/2
$head->isa("PPI::Structure::Subscript") and $head->start eq "["
$head->isa("PPI::Structure::Subscript")
$head->start eq "["
Truth table33%1/3
A and B
A= $head->isa("PPI::Structure::Subscript")B= $head->start eq "["
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | $head->start eq '['; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ( $head->schild(0)->isa('PPI::Statement::Expression') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if ( $head->schild(0)->schild(0)->isa('PPI::Token::Number') and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$head->schild(0)->schild(0)->isa("PPI::Token::Number") and $head->schild(0)->schild(0)->content =~ /^ [-] /x
MC/DC0%0/2
$head->schild(0)->schild(0)->isa("PPI::Token::Number") and $head->schild(0)->schild(0)->content =~ /^ [-] /x
$head->schild(0)->schild(0)->isa("PPI::Token::Number")
$head->schild(0)->schild(0)->content =~ /^ [-] /x
Truth table0%0/3
A and B
A= $head->schild(0)->schild(0)->isa("PPI::Token::Number")B= $head->schild(0)->schild(0)->content =~ /^ [-] /x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | $head->schild(0)->schild(0)->content =~ /^ [-] /x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # Don't use the operator '*' lest it get confused. This way | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # the code is still syntactically correct. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $head->schild(0)->schild(0)->insert_before( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | PPI::Token::Word->new('*') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | return $self->transformation( $DESC, $EXPL, $elem ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 17 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||