line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Language::P::ParseTree::Visitor; |
2
|
|
|
|
|
|
|
|
3
|
88
|
|
|
88
|
|
665
|
use strict; |
|
88
|
|
|
|
|
403
|
|
|
88
|
|
|
|
|
3052
|
|
4
|
88
|
|
|
88
|
|
610
|
use warnings; |
|
88
|
|
|
|
|
224
|
|
|
88
|
|
|
|
|
2459
|
|
5
|
88
|
|
|
88
|
|
595
|
use base qw(Class::Accessor::Fast); |
|
88
|
|
|
|
|
327
|
|
|
88
|
|
|
|
|
14595
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
208
|
|
|
208
|
1
|
3505
|
my( $class, $args ) = @_; |
9
|
208
|
|
|
|
|
1611
|
my $self = $class->SUPER::new( $args ); |
10
|
|
|
|
|
|
|
|
11
|
208
|
|
|
|
|
2407
|
return $self; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _superclasses { |
15
|
85
|
|
|
85
|
|
133
|
my( $class ) = @_; |
16
|
|
|
|
|
|
|
|
17
|
88
|
|
|
88
|
|
513
|
no strict 'refs'; |
|
88
|
|
|
|
|
209
|
|
|
88
|
|
|
|
|
33293
|
|
18
|
85
|
|
|
|
|
122
|
return @{$class . '::ISA'}; |
|
85
|
|
|
|
|
676
|
|
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _find_method { |
22
|
3490
|
|
|
3490
|
|
4700
|
my( $self, $map, $class ) = @_; |
23
|
3490
|
|
|
|
|
6086
|
my $method = $map->{$class}; |
24
|
3490
|
100
|
|
|
|
10541
|
return $method if $method; |
25
|
|
|
|
|
|
|
|
26
|
25
|
|
|
|
|
93
|
my @bases = _superclasses( $class ); |
27
|
25
|
|
100
|
|
|
635
|
while( !$method && @bases ) { |
28
|
60
|
|
|
|
|
106
|
my $base = shift @bases; |
29
|
60
|
|
|
|
|
126
|
$method = $map->{$base}; |
30
|
60
|
|
|
|
|
172
|
push @bases, _superclasses( $base ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
25
|
100
|
66
|
|
|
178
|
if( !$method && $map->{DEFAULT} ) { |
34
|
13
|
|
|
|
|
40
|
$method = $map->{$class} = $map->{DEFAULT} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
25
|
50
|
|
|
|
107
|
Carp::confess "No method for '$class'" unless $method; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# use the map as a cache to speed-up lookup |
40
|
25
|
|
|
|
|
90
|
return $map->{$class} = $method; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub visit { |
44
|
1903
|
|
|
1903
|
0
|
9323
|
my( $self, $tree, @args ) = @_; |
45
|
1903
|
|
|
|
|
5025
|
my $method = _find_method( $self, $self->method_map, ref( $tree ) ); |
46
|
|
|
|
|
|
|
|
47
|
1903
|
|
|
|
|
6898
|
return $self->$method( $tree, @args ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub visit_map { |
51
|
1587
|
|
|
1587
|
0
|
2941
|
my( $self, $map, $tree, @args ) = @_; |
52
|
1587
|
|
|
|
|
4419
|
my $method = _find_method( $self, $map, ref( $tree ) ); |
53
|
|
|
|
|
|
|
|
54
|
1587
|
|
|
|
|
6713
|
return $self->$method( $tree, @args ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |