| 1 | package Zuzu::AST::Visitor::SuperHints; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 78 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 78 | our $VERSION = '0.007002'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 78 | ▶ | use Scalar::Util qw( blessed refaddr ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 78 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 752 | ▶ | sub apply { | ||||||||||||||||||||||||||
|
Subroutine
apply: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | 752 | my ( $self, $ast ) = @_; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 752 | $self->_visit_node($ast); | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 752 | return $ast; | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 279099 | ▶ | sub _node_references_super { | ||||||||||||||||||||||||||
|
Subroutine
_node_references_super: called CC=20 SCAR=30.8
| |||||||||||||||||||||||||||||
| 20 | 279099 | my ( $self, $node, $seen ) = @_; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 279099 | ▶ | return 0 if !defined $node; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 258526 | ▶ | $seen //= {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$seen //= {}
MC/DC100%1/1
$seen //= {}
$seen
Truth table100%2/2
A
A= $seen
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 258526 | ▶ | if ( blessed($node) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 54155 | my $addr = refaddr($node); | |||||||||||||||||||||||||||
| 27 | 54155 | ▶ | return 0 if defined $addr and $seen->{$addr}++; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $addr and $seen->{$addr}++
MC/DC0%0/2
defined $addr and $seen->{$addr}++
defined $addr
$seen->{$addr}++
Truth table33%1/3
A and B
A= defined $addrB= $seen->{$addr}++
| |||||||||||||||||||||||||||||
| 28 | 54155 | ▶ | return 1 | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$node->isa("Zuzu::AST::Expr::Var") and $node->name eq "super"
MC/DC100%2/2
$node->isa("Zuzu::AST::Expr::Var") and $node->name eq "super"
$node->isa("Zuzu::AST::Expr::Var")
$node->name eq "super"
Truth table100%3/3
A and B
A= $node->isa("Zuzu::AST::Expr::Var")B= $node->name eq "super"
| |||||||||||||||||||||||||||||
| 29 | if $node->isa('Zuzu::AST::Expr::Var') | ||||||||||||||||||||||||||||
| 30 | and $node->name eq 'super'; | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 54127 | for my $value ( values %{ $node } ) { | |||||||||||||||||||||||||||
| 33 | 229764 | ▶ | return 1 if $self->_node_references_super( $value, $seen ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 53998 | return 0; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 204371 | ▶ | if ( ref($node) eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 27676 | my $addr = refaddr($node); | |||||||||||||||||||||||||||
| 41 | 27676 | ▶ | return 0 if defined $addr and $seen->{$addr}++; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $addr and $seen->{$addr}++
MC/DC0%0/2
defined $addr and $seen->{$addr}++
defined $addr
$seen->{$addr}++
Truth table33%1/3
A and B
A= defined $addrB= $seen->{$addr}++
| |||||||||||||||||||||||||||||
| 42 | 27676 | for my $value ( @{ $node } ) { | |||||||||||||||||||||||||||
| 43 | 45636 | ▶ | return 1 if $self->_node_references_super( $value, $seen ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | 27647 | return 0; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 176695 | ▶ | if ( ref($node) eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 5114 | my $addr = refaddr($node); | |||||||||||||||||||||||||||
| 50 | 5114 | ▶ | return 0 if defined $addr and $seen->{$addr}++; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $addr and $seen->{$addr}++
MC/DC0%0/2
defined $addr and $seen->{$addr}++
defined $addr
$seen->{$addr}++
Truth table33%1/3
A and B
A= defined $addrB= $seen->{$addr}++
| |||||||||||||||||||||||||||||
| 51 | 5114 | for my $value ( values %{ $node } ) { | |||||||||||||||||||||||||||
| 52 | 2107 | ▶ | return 1 if $self->_node_references_super( $value, $seen ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | 5114 | return 0; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 171581 | return 0; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 772483 | ▶ | sub _visit_node { | ||||||||||||||||||||||||||
|
Subroutine
_visit_node: called CC=17 SCAR=29.0
| |||||||||||||||||||||||||||||
| 61 | 772483 | my ( $self, $node, $seen ) = @_; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 772483 | ▶ | return if !defined $node; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 723402 | ▶ | $seen //= {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$seen //= {}
MC/DC100%1/1
$seen //= {}
$seen
Truth table100%2/2
A
A= $seen
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 723402 | ▶ | if ( blessed($node) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 151086 | my $addr = refaddr($node); | |||||||||||||||||||||||||||
| 68 | 151086 | ▶ | return if defined $addr and $seen->{$addr}++; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $addr and $seen->{$addr}++
MC/DC0%0/2
defined $addr and $seen->{$addr}++
defined $addr
$seen->{$addr}++
Truth table33%1/3
A and B
A= defined $addrB= $seen->{$addr}++
| |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 151086 | ▶ | if ( $node->isa('Zuzu::AST::Stmt::Method') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 1592 | ▶ | $node->uses_super( $self->_node_references_super($node) ? 1 : 0 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 151086 | for my $value ( values %{ $node } ) { | |||||||||||||||||||||||||||
| 75 | 624022 | $self->_visit_node( $value, $seen ); | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | 151086 | return; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 572316 | ▶ | if ( ref($node) eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 76161 | my $addr = refaddr($node); | |||||||||||||||||||||||||||
| 82 | 76161 | ▶ | return if defined $addr and $seen->{$addr}++; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $addr and $seen->{$addr}++
MC/DC0%0/2
defined $addr and $seen->{$addr}++
defined $addr
$seen->{$addr}++
Truth table33%1/3
A and B
A= defined $addrB= $seen->{$addr}++
| |||||||||||||||||||||||||||||
| 83 | 76161 | for my $value ( @{ $node } ) { | |||||||||||||||||||||||||||
| 84 | 135137 | $self->_visit_node( $value, $seen ); | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | 76161 | return; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 496155 | ▶ | if ( ref($node) eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 13077 | my $addr = refaddr($node); | |||||||||||||||||||||||||||
| 91 | 13077 | ▶ | return if defined $addr and $seen->{$addr}++; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $addr and $seen->{$addr}++
MC/DC0%0/2
defined $addr and $seen->{$addr}++
defined $addr
$seen->{$addr}++
Truth table33%1/3
A and B
A= defined $addrB= $seen->{$addr}++
| |||||||||||||||||||||||||||||
| 92 | 13077 | for my $value ( values %{ $node } ) { | |||||||||||||||||||||||||||
| 93 | 12572 | $self->_visit_node( $value, $seen ); | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | 13077 | return; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 483078 | return; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 78 | 1; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =pod | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | =head1 COPYRIGHT AND LICENCE | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | B<< Zuzu::AST::Visitor::SuperHints >> is copyright Toby Inkster. | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | It is free software; you may redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 110 | the terms of either the Artistic License 1.0 or the GNU General Public | ||||||||||||||||||||||||||||
| 111 | License version 2. | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =cut | ||||||||||||||||||||||||||||