blib/lib/Zuzu/AST/Visitor/LexicalEnvHints.pm

filter: Statementstmt 99.6% 310 / 311 Branchbran 92.4% 183 / 198 Conditioncond 62.6% 52 / 83 MC/DCmcdc 34.0% 16 / 47 Subroutinesub 100% 16 / 16 Podpod 0.0% 0 / 1 totaltotal 87.9% 577 / 656 CC 158 SCAR 42.6
CC
158
Cov
92%
_visit_node
106.1
_block_can_reuse_current_env
35.8
_visit_block
8.1
CRAP 70.6
« blib/lib/Zuzu/Module/DB.pm ↑ Summary blib/lib/Zuzu/Module/Archive.pm »
1 package Zuzu::AST::Visitor::LexicalEnvHints;
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 753 ▶has '_scope_stack' => ( is => 'rw', default => sub { [ {} ] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
12  
13 753 ▶sub apply {
Subroutine apply: called CC=1 SCAR=0.0
Pod undocumented
14 753 my ( $self, $ast ) = @_;
15  
16 753 $self->_visit_node($ast);
17  
18 753 return $ast;
19 }
20  
21 17288 ▶sub _current_scope { $_[0]->_scope_stack->[-1] }
Subroutine _current_scope: called CC=1 SCAR=0.0
22  
23 11224 ▶sub _push_scope {
Subroutine _push_scope: called CC=2 SCAR=6.9
24 11224 my ( $self, $initial ) = @_;
25  
26 11224 ▶ push @{ $self->_scope_stack }, { %{ $initial // {} } };
Condition100%2/2
$initial // {}
l!l
47106514
MC/DC100%1/1
$initial // {}
$initial
Truth table100%2/2
A
A= $initial
Aresult
11
00
27  
28 11224 return;
29 }
30  
31 11224 ▶sub _pop_scope {
Subroutine _pop_scope: called CC=1 SCAR=0.0
32 11224 my ( $self ) = @_;
33  
34 11224 pop @{ $self->_scope_stack };
35  
36 11224 return;
37 }
38  
39 17288 ▶sub _declare_name {
Subroutine _declare_name: called CC=3 SCAR=12.0
40 17288 my ( $self, $name ) = @_;
41  
42 17288 ▶ return if !defined $name or $name eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $name or $name eq "" 0 17288 17288
Condition33%1/3
not defined $name or $name eq ""
l!l&&r!l&&!r
0017288
MC/DC0%0/2
not defined $name or $name eq ""
not defined $name $name eq ""
Truth table33%1/3
not(A) or B
A= not defined $nameB= $name eq ""
ABresult
1X1
011
000
43 17288 $self->_current_scope->{$name} = 1;
44  
45 17288 return;
46 }
47  
48 44177 ▶sub _lookup_depth {
Subroutine _lookup_depth: called CC=4 SCAR=13.9
49 44177 my ( $self, $name ) = @_;
50  
51 44177 ▶ return undef if !defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 44177 44177
52 44177 my $scopes = $self->_scope_stack;
53 44177 ▶ for ( my $i = $#$scopes; $i >= 0; $i-- ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= 0) 113650 3272 116922
54 113650 ▶ return $#$scopes - $i if exists $scopes->[$i]{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $scopes->[$i]{$name} 40905 72745 113650
55 }
56  
57 3272 return undef;
58 }
59  
60 44177 ▶sub _annotate_var {
Subroutine _annotate_var: called CC=2 SCAR=6.9
61 44177 my ( $self, $node ) = @_;
62  
63 44177 delete $node->{_env_depth};
64 44177 delete $node->{_binding_name};
65 44177 my $depth = $self->_lookup_depth( $node->name );
66 44177 ▶ return if !defined $depth;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $depth 3272 40905 44177
67  
68 40905 $node->{_env_depth} = $depth;
69 40905 $node->{_binding_name} = $node->name;
70  
71 40905 return;
72 }
73  
74 133478 ▶sub _block_can_reuse_current_env {
Subroutine _block_can_reuse_current_env: called CC=34 SCAR=35.8
75 133478 my ( $self, $node, $seen ) = @_;
76  
77 133478 ▶ return 1 if !defined $node;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $node 1205 132273 133478
78 132273 ▶ $seen //= {};
Condition100%2/2
$seen //= {}
l!l
1229429331
MC/DC100%1/1
$seen //= {}
$seen
Truth table100%2/2
A
A= $seen
Aresult
11
00
79  
80 132273 ▶ if ( blessed($node) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($node)) 41537 90736 132273
81 41537 my $addr = refaddr($node);
82 41537 ▶ return 1 if defined $addr and $seen->{$addr}++;
Branch: 1 branch
BranchTrueFalseTotal
if defined $addr and $seen->{$addr}++ 0 41537 41537
Condition33%1/3
defined $addr and $seen->{$addr}++
!ll&&!rl&&r
0415370
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}++
ABresult
0X0
100
111
83  
84 41537 ▶ return 0 if $node->isa('Zuzu::AST::Stmt::Let');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("Zuzu::AST::Stmt::Let") 2262 39275 41537
85 39275 ▶ return 0 if $node->isa('Zuzu::AST::Stmt::LetUnpack');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("Zuzu::AST::Stmt::LetUnpack") 1 39274 39275
86 39274 ▶ return 0 if $node->isa('Zuzu::AST::Stmt::Function');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("Zuzu::AST::Stmt::Function") 3 39271 39274
87 39271 ▶ return 0 if $node->isa('Zuzu::AST::Stmt::Class');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("Zuzu::AST::Stmt::Class") 0 39271 39271
88 39271 ▶ return 0 if $node->isa('Zuzu::AST::Stmt::Trait');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("Zuzu::AST::Stmt::Trait") 0 39271 39271
89 39271 ▶ return 0 if $node->isa('Zuzu::AST::Stmt::Import');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("Zuzu::AST::Stmt::Import") 117 39154 39271
90 39154 ▶ return 0 if $node->isa('Zuzu::AST::Stmt::Catch');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("Zuzu::AST::Stmt::Catch") 22 39132 39154
91 39132 ▶ return 0
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("Zuzu::AST::Stmt::For") and $node->declare_loop_var 214 38918 39132
Condition66%2/3
$node->isa("Zuzu::AST::Stmt::For") and $node->declare_loop_var
!ll&&!rl&&r
389180214
MC/DC50%1/2
$node->isa("Zuzu::AST::Stmt::For") and $node->declare_loop_var
$node->isa("Zuzu::AST::Stmt::For") $node->declare_loop_var
Truth table66%2/3
A and B
A= $node->isa("Zuzu::AST::Stmt::For")B= $node->declare_loop_var
ABresult
0X0
100
111
92 if $node->isa('Zuzu::AST::Stmt::For')
93 and $node->declare_loop_var;
94  
95 38918 ▶ return 0 if $node->isa('Zuzu::AST::Expr::Call');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("Zuzu::AST::Expr::Call") 1440 37478 38918
96 37478 ▶ return 0 if $node->isa('Zuzu::AST::Expr::MemberCall');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("Zuzu::AST::Expr::MemberCall") 2242 35236 37478
97 35236 ▶ return 0 if $node->isa('Zuzu::AST::Expr::DynamicMemberCall');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("Zuzu::AST::Expr::DynamicMemberCall") 5 35231 35236
98 35231 ▶ return 0 if $node->isa('Zuzu::AST::Expr::New');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("Zuzu::AST::Expr::New") 155 35076 35231
99 35076 ▶ return 0 if $node->isa('Zuzu::AST::Expr::Function');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("Zuzu::AST::Expr::Function") 7 35069 35076
100 35069 ▶ return 0 if $node->isa('Zuzu::AST::Expr::Spawn');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("Zuzu::AST::Expr::Spawn") 1 35068 35069
101 35068 ▶ return 0 if $node->isa('Zuzu::AST::Expr::Await');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("Zuzu::AST::Expr::Await") 45 35023 35068
102  
103 35023 for my $value ( values %{ $node } ) {
104 110253 ▶ return 0 if !$self->_block_can_reuse_current_env( $value, $seen );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_block_can_reuse_current_env($value, $seen) 12324 97929 110253
105 }
106  
107 22699 return 1;
108 }
109  
110 90736 ▶ if ( ref($node) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $node eq "ARRAY") 11213 79523 90736
111 11213 my $addr = refaddr($node);
112 11213 ▶ return 1 if defined $addr and $seen->{$addr}++;
Branch: 1 branch
BranchTrueFalseTotal
if defined $addr and $seen->{$addr}++ 0 11213 11213
Condition33%1/3
defined $addr and $seen->{$addr}++
!ll&&!rl&&r
0112130
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}++
ABresult
0X0
100
111
113 11213 for my $value ( @{ $node } ) {
114 13044 ▶ return 0 if !$self->_block_can_reuse_current_env( $value, $seen );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_block_can_reuse_current_env($value, $seen) 7067 5977 13044
115 }
116 4146 return 1;
117 }
118  
119 79523 ▶ if ( ref($node) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $node eq "HASH") 287 79236 79523
120 287 my $addr = refaddr($node);
121 287 ▶ return 1 if defined $addr and $seen->{$addr}++;
Branch: 1 branch
BranchTrueFalseTotal
if defined $addr and $seen->{$addr}++ 0 287 287
Condition33%1/3
defined $addr and $seen->{$addr}++
!ll&&!rl&&r
02870
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}++
ABresult
0X0
100
111
122 287 for my $value ( values %{ $node } ) {
123 850 ▶ return 0 if !$self->_block_can_reuse_current_env( $value, $seen );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_block_can_reuse_current_env($value, $seen) 6 844 850
124 }
125 281 return 1;
126 }
127  
128 79236 return 1;
129 }
130  
131 9331 ▶sub _visit_block {
Subroutine _visit_block: called CC=8 SCAR=20.9
132 9331 my ( $self, $node ) = @_;
133  
134 9331 ▶ return if !defined $node;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $node 0 9331 9331
135 9331 ▶ $node->reuse_current_env( $self->_block_can_reuse_current_env($node) ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$self->_block_can_reuse_current_env($node) ? : 2817 6514 9331
136 9331 ▶ if ( $node->reuse_current_env ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->reuse_current_env) 2817 6514 9331
137 2817 ▶ for my $stmt ( @{ $node->statements // [] } ) {
Condition50%1/2
$node->statements // []
l!l
28170
MC/DC0%0/1
$node->statements // []
$node->statements
Truth table50%1/2
A
A= $node->statements
Aresult
11
00
138 3379 $self->_visit_node($stmt);
139 }
140 2817 return;
141 }
142  
143 6514 $self->_push_scope;
144 6514 ▶ for my $stmt ( @{ $node->statements // [] } ) {
Condition50%1/2
$node->statements // []
l!l
65140
MC/DC0%0/1
$node->statements // []
$node->statements
Truth table50%1/2
A
A= $node->statements
Aresult
11
00
145 18700 $self->_visit_node($stmt);
146 }
147 6514 $self->_pop_scope;
148  
149 6514 return;
150 }
151  
152 3516 ▶sub _declare_function_params {
Subroutine _declare_function_params: called CC=5 SCAR=16.1
153 3516 my ( $self, $node ) = @_;
154  
155 3516 $self->_declare_name('__argc__');
156 3516 ▶ for my $name ( @{ $node->params // [] } ) {
Condition50%1/2
$node->params // []
l!l
35160
MC/DC0%0/1
$node->params // []
$node->params
Truth table50%1/2
A
A= $node->params
Aresult
11
00
157 4997 $self->_declare_name($name);
158 }
159 3516 ▶ $self->_declare_name( $node->vararg )
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->vararg 62 3454 3516
160 if defined $node->vararg;
161 3516 ▶ $self->_declare_name( $node->named_vararg )
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->named_vararg 115 3401 3516
162 if defined $node->named_vararg;
163  
164 3516 return;
165 }
166  
167 3557 ▶sub _visit_function_like {
Subroutine _visit_function_like: called CC=6 SCAR=17.9
168 3557 my ( $self, $node ) = @_;
169  
170 3557 ▶ return if $node->can('is_predeclared') and $node->is_predeclared;
Branch: 1 branch
BranchTrueFalseTotal
if $node->can("is_predeclared") and $node->is_predeclared 41 3516 3557
Condition100%3/3
$node->can("is_predeclared") and $node->is_predeclared
!ll&&!rl&&r
458305841
MC/DC100%2/2
$node->can("is_predeclared") and $node->is_predeclared
$node->can("is_predeclared") $node->is_predeclared
Truth table100%3/3
A and B
A= $node->can("is_predeclared")B= $node->is_predeclared
ABresult
0X0
100
111
171  
172 3516 my %initial;
173 3516 ▶ if ( $node->isa('Zuzu::AST::Stmt::Method') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::Method")) 1588 1928 3516
174 1588 $initial{self} = 1;
175 1588 ▶ $initial{super} = 1
Branch: 1 branch
BranchTrueFalseTotal
if not defined $node->uses_super or $node->uses_super 33 1555 1588
Condition100%3/3
not defined $node->uses_super or $node->uses_super
l!l&&r!l&&!r
5281555
MC/DC100%2/2
not defined $node->uses_super or $node->uses_super
not defined $node->uses_super $node->uses_super
Truth table100%3/3
not(A) or B
A= not defined $node->uses_superB= $node->uses_super
ABresult
1X1
011
000
176 if !defined $node->uses_super or $node->uses_super;
177 }
178  
179 3516 $self->_push_scope( \%initial );
180 3516 $self->_declare_function_params($node);
181 3516 $self->_visit_block( $node->body );
182 3516 $self->_pop_scope;
183  
184 3516 return;
185 }
186  
187 134979 ▶sub _visit_node {
Subroutine _visit_node: called CC=102 SCAR=46.6
188 134979 my ( $self, $node ) = @_;
189  
190 134979 ▶ return if !defined $node;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $node 112 134867 134979
191 134867 ▶ return if !blessed($node);
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($node) 0 134867 134867
192  
193 134867 ▶ if ( $node->isa('Zuzu::AST::Program') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Program")) 753 134114 134867
194 753 ▶ for my $stmt ( @{ $node->statements // [] } ) {
Condition50%1/2
$node->statements // []
l!l
7530
MC/DC0%0/1
$node->statements // []
$node->statements
Truth table50%1/2
A
A= $node->statements
Aresult
11
00
195 3910 $self->_visit_node($stmt);
196 }
197 753 return;
198 }
199  
200 134114 ▶ if ( $node->isa('Zuzu::AST::Block') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Block")) 274 133840 134114
201 274 $self->_visit_block($node);
202 274 return;
203 }
204  
205 133840 ▶ if ( $node->isa('Zuzu::AST::Expr::Var') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::Var")) 44177 89663 133840
206 44177 $self->_annotate_var($node);
207 44177 return;
208 }
209  
210 89663 ▶ if ( $node->isa('Zuzu::AST::Stmt::Let') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::Let")) 5728 83935 89663
211 5728 ▶ $self->_visit_node( $node->init ) if defined $node->init;
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->init 5677 51 5728
212 5728 $self->_declare_name( $node->name );
213 5728 return;
214 }
215  
216 83935 ▶ if ( $node->isa('Zuzu::AST::Stmt::LetUnpack') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::LetUnpack")) 18 83917 83935
217 18 ▶ for my $binding ( @{ $node->bindings // [] } ) {
Condition50%1/2
$node->bindings // []
l!l
180
MC/DC0%0/1
$node->bindings // []
$node->bindings
Truth table50%1/2
A
A= $node->bindings
Aresult
11
00
218 27 $self->_visit_node( $binding->{key_expr} );
219 $self->_visit_node( $binding->{default_expr} )
220 27 ▶ if $binding->{has_default};
Branch: 1 branch
BranchTrueFalseTotal
if $binding->{"has_default"} 4 23 27
221 }
222 18 ▶ $self->_visit_node( $node->init ) if defined $node->init;
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->init 18 0 18
223 18 ▶ for my $binding ( @{ $node->bindings // [] } ) {
Condition50%1/2
$node->bindings // []
l!l
180
MC/DC0%0/1
$node->bindings // []
$node->bindings
Truth table50%1/2
A
A= $node->bindings
Aresult
11
00
224 27 $self->_declare_name( $binding->{name} );
225 }
226 18 return;
227 }
228  
229 83917 ▶ if ( $node->isa('Zuzu::AST::Stmt::Assign') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::Assign")) 2196 81721 83917
230 2196 $self->_visit_node( $node->target );
231 2196 ▶ $self->_visit_node( $node->expr ) if defined $node->expr;
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->expr 2188 8 2196
232 2196 ▶ $self->_visit_node( $node->match_expr ) if defined $node->match_expr;
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->match_expr 8 2188 2196
233 2196 ▶ $self->_visit_node( $node->replace_expr ) if defined $node->replace_expr;
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->replace_expr 8 2188 2196
234 2196 return;
235 }
236  
237 81721 ▶ if ( $node->isa('Zuzu::AST::Stmt::Expr') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::Expr")) 4072 77649 81721
238 4072 $self->_visit_node( $node->expr );
239 4072 return;
240 }
241  
242 77649 ▶ if ( $node->isa('Zuzu::AST::Stmt::Return') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::Return")) 5320 72329 77649
243 5320 ▶ $self->_visit_node( $node->expr ) if $node->can('expr');
Branch: 1 branch
BranchTrueFalseTotal
if $node->can("expr") 5320 0 5320
244 5320 return;
245 }
246  
247 72329 ▶ if ( $node->isa('Zuzu::AST::Stmt::If') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::If")) 3860 68469 72329
248 3860 $self->_visit_node( $node->cond );
249 3860 $self->_visit_block( $node->then_block );
250 3860 ▶ $self->_visit_node( $node->else_branch ) if defined $node->else_branch;
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->else_branch 597 3263 3860
251 3860 return;
252 }
253  
254 68469 ▶ if ( $node->isa('Zuzu::AST::Stmt::PostfixIf') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::PostfixIf")) 1205 67264 68469
255 1205 $self->_visit_node( $node->cond );
256 1205 $self->_visit_node( $node->statement );
257 1205 return;
258 }
259  
260 67264 ▶ if ( $node->isa('Zuzu::AST::Stmt::While') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::While")) 496 66768 67264
261 496 $self->_visit_node( $node->cond );
262 496 $self->_visit_block( $node->body );
263 496 return;
264 }
265  
266 66768 ▶ if ( $node->isa('Zuzu::AST::Stmt::For') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::For")) 740 66028 66768
267 740 $self->_visit_node( $node->collection );
268 740 ▶ if ( $node->declare_loop_var ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->declare_loop_var) { } 738 2 740
269 738 $self->_push_scope( { $node->var => 1 } );
270 738 $self->_visit_block( $node->body );
271 738 $self->_pop_scope;
272 }
273 else {
274 2 $self->_visit_block( $node->body );
275 }
276 740 ▶ $self->_visit_block( $node->else_block ) if defined $node->else_block;
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->else_block 15 725 740
277 740 return;
278 }
279  
280 66028 ▶ if ( $node->isa('Zuzu::AST::Stmt::Function') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::Function")) 1502 64526 66028
281 1502 $self->_declare_name( $node->name );
282 1502 $self->_visit_function_like($node);
283 1502 return;
284 }
285  
286 64526 ▶ if ( $node->isa('Zuzu::AST::Expr::Function') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::Function")) 458 64068 64526
287 458 $self->_visit_function_like($node);
288 458 return;
289 }
290  
291 64068 ▶ if ( $node->isa('Zuzu::AST::Stmt::Method') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::Method")) 1597 62471 64068
292 1597 $self->_visit_function_like($node);
293 1597 return;
294 }
295  
296 62471 ▶ if ( $node->isa('Zuzu::AST::Stmt::Class') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::Class")) 302 62169 62471
297 302 ▶ $self->_visit_node( $node->parent ) if defined $node->parent;
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->parent 133 169 302
298 302 ▶ for my $trait_ref ( @{ $node->traits // [] } ) {
Condition50%1/2
$node->traits // []
l!l
3020
MC/DC0%0/1
$node->traits // []
$node->traits
Truth table50%1/2
A
A= $node->traits
Aresult
11
00
299 20 $self->_visit_node($trait_ref);
300 }
301 302 ▶ for my $field ( @{ $node->fields // [] } ) {
Condition50%1/2
$node->fields // []
l!l
3020
MC/DC0%0/1
$node->fields // []
$node->fields
Truth table50%1/2
A
A= $node->fields
Aresult
11
00
302 468 ▶ $self->_visit_node( $field->{init} ) if defined $field->{init};
Branch: 1 branch
BranchTrueFalseTotal
if defined $field->{"init"} 376 92 468
303 }
304 302 $self->_declare_name( $node->name );
305 302 $self->_push_scope( { self => 1 } );
306 302 ▶ for my $klass ( @{ $node->classes // [] } ) {
Condition50%1/2
$node->classes // []
l!l
3020
MC/DC0%0/1
$node->classes // []
$node->classes
Truth table50%1/2
A
A= $node->classes
Aresult
11
00
307 0 $self->_visit_node($klass);
308 }
309 302 ▶ for my $method ( @{ $node->methods // [] } ) {
Condition50%1/2
$node->methods // []
l!l
3020
MC/DC0%0/1
$node->methods // []
$node->methods
Truth table50%1/2
A
A= $node->methods
Aresult
11
00
310 1492 $self->_visit_node($method);
311 }
312 302 ▶ for my $method ( @{ $node->static_methods // [] } ) {
Condition50%1/2
$node->static_methods // []
l!l
3020
MC/DC0%0/1
$node->static_methods // []
$node->static_methods
Truth table50%1/2
A
A= $node->static_methods
Aresult
11
00
313 73 $self->_visit_node($method);
314 }
315 302 $self->_pop_scope;
316 302 return;
317 }
318  
319 62169 ▶ if ( $node->isa('Zuzu::AST::Stmt::Trait') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::Trait")) 14 62155 62169
320 14 $self->_declare_name( $node->name );
321 14 ▶ for my $method ( @{ $node->methods // [] } ) {
Condition50%1/2
$node->methods // []
l!l
140
MC/DC0%0/1
$node->methods // []
$node->methods
Truth table50%1/2
A
A= $node->methods
Aresult
11
00
322 32 $self->_visit_node($method);
323 }
324 14 return;
325 }
326  
327 62155 ▶ if ( $node->isa('Zuzu::AST::Stmt::Try') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::Try")) 152 62003 62155
328 152 $self->_visit_block( $node->block );
329 152 ▶ for my $catch ( @{ $node->catches // [] } ) {
Condition50%1/2
$node->catches // []
l!l
1520
MC/DC0%0/1
$node->catches // []
$node->catches
Truth table50%1/2
A
A= $node->catches
Aresult
11
00
330 154 $self->_visit_node($catch);
331 }
332 152 return;
333 }
334  
335 62003 ▶ if ( $node->isa('Zuzu::AST::Stmt::Catch') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::Catch")) 154 61849 62003
336 154 $self->_visit_node( $node->type_expr );
337 154 $self->_push_scope( { $node->name => 1 } );
338 154 $self->_visit_block( $node->block );
339 154 $self->_pop_scope;
340 154 return;
341 }
342  
343 61849 ▶ if ( $node->isa('Zuzu::AST::Stmt::Import') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Stmt::Import")) 693 61156 61849
344 693 ▶ $self->_visit_node( $node->condition_expr )
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->condition_expr 3 690 693
345 if defined $node->condition_expr;
346 693 ▶ for my $item ( @{ $node->items // [] } ) {
Condition50%1/2
$node->items // []
l!l
6930
MC/DC0%0/1
$node->items // []
$node->items
Truth table50%1/2
A
A= $node->items
Aresult
11
00
347 1217 ▶ next if $item->{star};
Branch: 1 branch
BranchTrueFalseTotal
if $item->{"star"} 192 1025 1217
348 1025 $self->_declare_name( $item->{alias} );
349 }
350 693 return;
351 }
352  
353 61156 ▶ if ( $node->isa('Zuzu::AST::Expr::Call') or $node->isa('Zuzu::AST::Expr::MemberCall') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::Call") or $node->isa("Zuzu::AST::Expr::MemberCall")) 14762 46394 61156
Condition100%3/3
$node->isa("Zuzu::AST::Expr::Call") or $node->isa("Zuzu::AST::Expr::MemberCall")
l!l&&r!l&&!r
6686807646394
MC/DC100%2/2
$node->isa("Zuzu::AST::Expr::Call") or $node->isa("Zuzu::AST::Expr::MemberCall")
$node->isa("Zuzu::AST::Expr::Call") $node->isa("Zuzu::AST::Expr::MemberCall")
Truth table100%3/3
A or B
A= $node->isa("Zuzu::AST::Expr::Call")B= $node->isa("Zuzu::AST::Expr::MemberCall")
ABresult
1X1
011
000
354 14762 ▶ $self->_visit_node( $node->callee ) if $node->can('callee');
Branch: 1 branch
BranchTrueFalseTotal
if $node->can("callee") 6686 8076 14762
355 14762 ▶ $self->_visit_node( $node->object ) if $node->can('object');
Branch: 1 branch
BranchTrueFalseTotal
if $node->can("object") 8076 6686 14762
356 14762 ▶ for my $arg ( @{ $node->args // [] } ) {
Condition50%1/2
$node->args // []
l!l
147620
MC/DC0%0/1
$node->args // []
$node->args
Truth table50%1/2
A
A= $node->args
Aresult
11
00
357 21113 ▶ $self->_visit_node( $arg->[0] ) if ref($arg) eq 'ARRAY' and $arg->[2];
Branch: 1 branch
BranchTrueFalseTotal
if ref $arg eq "ARRAY" and $arg->[2] 5 21108 21113
Condition100%3/3
ref $arg eq "ARRAY" and $arg->[2]
!ll&&!rl&&r
161209475
MC/DC100%2/2
ref $arg eq "ARRAY" and $arg->[2]
ref $arg eq "ARRAY" $arg->[2]
Truth table100%3/3
A and B
A= ref $arg eq "ARRAY"B= $arg->[2]
ABresult
0X0
100
111
358 21113 ▶ $self->_visit_node( ref($arg) eq 'ARRAY' ? $arg->[1] : $arg );
Branch: 1 branch
BranchTrueFalseTotal
ref $arg eq 'ARRAY' ? : 20952 161 21113
359 }
360 14762 return;
361 }
362  
363 46394 ▶ if ( $node->isa('Zuzu::AST::Expr::DynamicMemberCall') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::DynamicMemberCall")) 11 46383 46394
364 11 $self->_visit_node( $node->object );
365 11 $self->_visit_node( $node->method_expr );
366 11 ▶ for my $arg ( @{ $node->args // [] } ) {
Condition50%1/2
$node->args // []
l!l
110
MC/DC0%0/1
$node->args // []
$node->args
Truth table50%1/2
A
A= $node->args
Aresult
11
00
367 7 ▶ $self->_visit_node( $arg->[0] ) if ref($arg) eq 'ARRAY' and $arg->[2];
Branch: 1 branch
BranchTrueFalseTotal
if ref $arg eq "ARRAY" and $arg->[2] 0 7 7
Condition33%1/3
ref $arg eq "ARRAY" and $arg->[2]
!ll&&!rl&&r
070
MC/DC0%0/2
ref $arg eq "ARRAY" and $arg->[2]
ref $arg eq "ARRAY" $arg->[2]
Truth table33%1/3
A and B
A= ref $arg eq "ARRAY"B= $arg->[2]
ABresult
0X0
100
111
368 7 ▶ $self->_visit_node( ref($arg) eq 'ARRAY' ? $arg->[1] : $arg );
Branch: 1 branch
BranchTrueFalseTotal
ref $arg eq 'ARRAY' ? : 7 0 7
369 }
370 11 return;
371 }
372  
373 46383 ▶ if ( $node->isa('Zuzu::AST::Expr::Spread') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::Spread")) 19 46364 46383
374 19 $self->_visit_node( $node->expr );
375 19 return;
376 }
377  
378 46364 ▶ if ( $node->isa('Zuzu::AST::Expr::Binary') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::Binary")) 11111 35253 46364
379 11111 $self->_visit_node( $node->left );
380 11111 $self->_visit_node( $node->right );
381 11111 return;
382 }
383  
384 35253 ▶ if ( $node->isa('Zuzu::AST::Expr::Unary') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::Unary")) 1798 33455 35253
385 1798 $self->_visit_node( $node->expr );
386 1798 return;
387 }
388  
389 33455 ▶ if ( $node->isa('Zuzu::AST::Expr::Await') or $node->isa('Zuzu::AST::Expr::Spawn') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::Await") or $node->isa("Zuzu::AST::Expr::Spawn")) 124 33331 33455
Condition100%3/3
$node->isa("Zuzu::AST::Expr::Await") or $node->isa("Zuzu::AST::Expr::Spawn")
l!l&&r!l&&!r
1071733331
MC/DC100%2/2
$node->isa("Zuzu::AST::Expr::Await") or $node->isa("Zuzu::AST::Expr::Spawn")
$node->isa("Zuzu::AST::Expr::Await") $node->isa("Zuzu::AST::Expr::Spawn")
Truth table100%3/3
A or B
A= $node->isa("Zuzu::AST::Expr::Await")B= $node->isa("Zuzu::AST::Expr::Spawn")
ABresult
1X1
011
000
390 124 $self->_visit_block( $node->block );
391 124 return;
392 }
393  
394 33331 ▶ if ( $node->isa('Zuzu::AST::Expr::Ternary') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::Ternary")) 596 32735 33331
395 596 $self->_visit_node( $node->cond );
396 596 ▶ $self->_visit_node( $node->if_true ) if defined $node->if_true;
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->if_true 573 23 596
397 596 $self->_visit_node( $node->if_false );
398 596 return;
399 }
400  
401 32735 ▶ if ( $node->isa('Zuzu::AST::Expr::Index') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::Index")) 1105 31630 32735
402 1105 $self->_visit_node( $node->array );
403 1105 $self->_visit_node( $node->index );
404 1105 return;
405 }
406  
407 31630 ▶ if ( $node->isa('Zuzu::AST::Expr::DictGet') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::DictGet")) 2433 29197 31630
408 2433 $self->_visit_node( $node->dict );
409 2433 $self->_visit_node( $node->key );
410 2433 return;
411 }
412  
413 29197 ▶ if ( $node->isa('Zuzu::AST::Expr::Slice') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::Slice")) 23 29174 29197
414 23 $self->_visit_node( $node->collection );
415 23 ▶ $self->_visit_node( $node->start ) if defined $node->start;
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->start 23 0 23
416 23 ▶ $self->_visit_node( $node->length ) if defined $node->length;
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->length 15 8 23
417 23 return;
418 }
419  
420 29174 ▶ if ( $node->isa('Zuzu::AST::Expr::IncDec') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::IncDec")) 690 28484 29174
421 690 $self->_visit_node( $node->target );
422 690 return;
423 }
424  
425 28484 ▶ if ( $node->isa('Zuzu::AST::Expr::Array') or $node->isa('Zuzu::AST::Expr::Set') or $node->isa('Zuzu::AST::Expr::Bag') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::Array") or $node->isa("Zuzu::AST::Expr::Set") or $node->isa("Zuzu::AST::Expr::Bag")) 1228 27256 28484
Condition100%6/6
$node->isa("Zuzu::AST::Expr::Array") or $node->isa("Zuzu::AST::Expr::Set") or $node->isa("Zuzu::AST::Expr::Bag")
l!l&&r!l&&!r
11903827256
$node->isa("Zuzu::AST::Expr::Array") or $node->isa("Zuzu::AST::Expr::Set")
l!l&&r!l&&!r
11335727294
MC/DC100%3/3
$node->isa("Zuzu::AST::Expr::Array") or $node->isa("Zuzu::AST::Expr::Set") or $node->isa("Zuzu::AST::Expr::Bag")
$node->isa("Zuzu::AST::Expr::Array") $node->isa("Zuzu::AST::Expr::Set") $node->isa("Zuzu::AST::Expr::Bag")
Truth table100%4/4
A or B or C
A= $node->isa("Zuzu::AST::Expr::Array")B= $node->isa("Zuzu::AST::Expr::Set")C= $node->isa("Zuzu::AST::Expr::Bag")
ABCresult
1XX1
01X1
0011
0000
426 1228 ▶ for my $item ( @{ $node->items // [] } ) {
Condition50%1/2
$node->items // []
l!l
12280
MC/DC0%0/1
$node->items // []
$node->items
Truth table50%1/2
A
A= $node->items
Aresult
11
00
427 1723 $self->_visit_node($item);
428 }
429 1228 return;
430 }
431  
432 27256 ▶ if ( $node->isa('Zuzu::AST::Expr::Range') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::Range")) 10 27246 27256
433 10 $self->_visit_node( $node->start );
434 10 $self->_visit_node( $node->end );
435 10 return;
436 }
437  
438 27246 ▶ if ( $node->isa('Zuzu::AST::Expr::Dict') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::Dict")) 801 26445 27246
439 801 ▶ for my $pair ( @{ $node->pairs // [] } ) {
Condition50%1/2
$node->pairs // []
l!l
8010
MC/DC0%0/1
$node->pairs // []
$node->pairs
Truth table50%1/2
A
A= $node->pairs
Aresult
11
00
440 2231 ▶ next if ref($pair) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $pair ne "ARRAY" 0 2231 2231
441 2231 $self->_visit_node( $pair->[0] );
442 2231 $self->_visit_node( $pair->[1] );
443 }
444 801 return;
445 }
446  
447 26445 ▶ if ( $node->isa('Zuzu::AST::Expr::New') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->isa("Zuzu::AST::Expr::New")) 755 25690 26445
448 755 $self->_visit_node( $node->class_expr );
449 755 ▶ for my $trait_ref ( @{ $node->traits // [] } ) {
Condition50%1/2
$node->traits // []
l!l
7550
MC/DC0%0/1
$node->traits // []
$node->traits
Truth table50%1/2
A
A= $node->traits
Aresult
11
00
450 3 $self->_visit_node( $trait_ref );
451 }
452 755 ▶ for my $pair ( @{ $node->args // [] } ) {
Condition50%1/2
$node->args // []
l!l
7550
MC/DC0%0/1
$node->args // []
$node->args
Truth table50%1/2
A
A= $node->args
Aresult
11
00
453 1676 $self->_visit_node( $pair->[1] );
454 }
455 755 return;
456 }
457  
458 25690 return;
459 }
460  
461 78 1;
462  
463 =pod
464  
465 =head1 COPYRIGHT AND LICENCE
466  
467 B<< Zuzu::AST::Visitor::LexicalEnvHints >> is copyright Toby Inkster.
468  
469 It is free software; you may redistribute it and/or modify it under
470 the terms of either the Artistic License 1.0 or the GNU General Public
471 License version 2.
472  
473 =cut
« blib/lib/Zuzu/Module/DB.pm ↑ Summary blib/lib/Zuzu/Module/Archive.pm »