line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Xslate::AST::Walker; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1260
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
48
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
7
|
|
|
|
|
|
|
use Class::Accessor::Lite ( |
8
|
1
|
|
|
|
|
13
|
new => 1, |
9
|
|
|
|
|
|
|
ro => [qw(nodes)], |
10
|
1
|
|
|
1
|
|
1402
|
); |
|
1
|
|
|
|
|
1418
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub search_descendants { |
13
|
1
|
|
|
1
|
0
|
113876
|
my ($self, $predicate) = @_; |
14
|
1
|
|
|
|
|
4
|
return [ map { @{$self->_recursive_search($_, $predicate)} } @{$self->nodes} ]; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
4
|
|
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _recursive_search { |
18
|
6
|
|
|
6
|
|
7
|
my ($self, $node, $predicate) = @_; |
19
|
6
|
|
|
|
|
8
|
my @matched; |
20
|
6
|
100
|
|
|
|
13
|
push @matched, $node if $predicate->($node); |
21
|
6
|
|
|
|
|
37
|
my @matched_descendants = map { @{$self->_recursive_search($_, $predicate)} } @{$node->child_symbols}; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
14
|
|
22
|
6
|
|
|
|
|
11
|
push @matched, @matched_descendants; |
23
|
6
|
|
|
|
|
18
|
return \@matched; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
package |
27
|
|
|
|
|
|
|
Text::Xslate::Symbol; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
1
|
|
244
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
30
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
212
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub child_symbols { |
33
|
6
|
|
|
6
|
0
|
7
|
my ($self) = @_; |
34
|
|
|
|
|
|
|
return [ |
35
|
3
|
|
|
|
|
15
|
grep { $_->isa(ref($self)) } |
|
6
|
|
|
|
|
10
|
|
36
|
6
|
|
|
|
|
8
|
@{$self->child_nodes} |
37
|
|
|
|
|
|
|
]; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub child_nodes { |
41
|
6
|
|
|
6
|
0
|
9
|
my ($self) = @_; |
42
|
|
|
|
|
|
|
return [ |
43
|
18
|
|
|
|
|
39
|
grep { defined($_) } |
|
18
|
|
|
|
|
51
|
|
44
|
6
|
|
|
|
|
8
|
map { @{_ensure_array_ref($self->$_)} } |
|
18
|
|
|
|
|
17
|
|
45
|
|
|
|
|
|
|
qw(first second third) |
46
|
|
|
|
|
|
|
]; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _ensure_array_ref { |
50
|
18
|
|
|
18
|
|
17
|
my ($maybe_arrayref) = @_; |
51
|
18
|
100
|
|
|
|
60
|
return ref($maybe_arrayref) eq 'ARRAY' ? $maybe_arrayref : [$maybe_arrayref]; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
__END__ |