line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Language::P::Parser::Lexicals; |
2
|
|
|
|
|
|
|
|
3
|
86
|
|
|
86
|
|
500
|
use strict; |
|
86
|
|
|
|
|
197
|
|
|
86
|
|
|
|
|
3322
|
|
4
|
86
|
|
|
86
|
|
530
|
use warnings; |
|
86
|
|
|
|
|
175
|
|
|
86
|
|
|
|
|
10379
|
|
5
|
86
|
|
|
86
|
|
497
|
use base qw(Class::Accessor::Fast); |
|
86
|
|
|
|
|
240
|
|
|
86
|
|
|
|
|
38470
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors( qw(outer names is_subroutine |
8
|
|
|
|
|
|
|
top_level) ); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
172
|
|
|
172
|
1
|
2353
|
my( $class, $args ) = @_; |
12
|
172
|
|
|
|
|
834
|
my $self = $class->SUPER::new( $args ); |
13
|
|
|
|
|
|
|
|
14
|
172
|
|
50
|
|
|
2806
|
$self->{names} ||= {}; |
15
|
|
|
|
|
|
|
|
16
|
172
|
|
|
|
|
668
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _find_name { |
20
|
500
|
|
|
500
|
|
3570
|
my( $self, $name, $level ) = @_; |
21
|
|
|
|
|
|
|
|
22
|
500
|
100
|
|
|
|
1580
|
return ( $level, $self->names->{$name} ) |
23
|
|
|
|
|
|
|
if exists $self->names->{$name}; |
24
|
478
|
100
|
|
|
|
3805
|
return _find_name( $self->outer, $name, |
25
|
|
|
|
|
|
|
$level + $self->is_subroutine ) if $self->outer; |
26
|
291
|
|
|
|
|
2128
|
return ( 0, undef ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub find_name { |
30
|
313
|
|
|
313
|
0
|
2378
|
my( $self, $name ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
313
|
|
|
|
|
875
|
return _find_name( $self, $name, 0 ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub add_name { |
36
|
21
|
|
|
21
|
0
|
241
|
my( $self, $sigil, $name ) = @_; |
37
|
|
|
|
|
|
|
|
38
|
21
|
|
|
|
|
300
|
$self->add_lexical( Language::P::ParseTree::LexicalDeclaration->new |
39
|
|
|
|
|
|
|
( { name => $name, |
40
|
|
|
|
|
|
|
sigil => $sigil, |
41
|
|
|
|
|
|
|
flags => 0, |
42
|
|
|
|
|
|
|
} ) ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub add_lexical { |
46
|
32
|
|
|
32
|
0
|
129
|
my( $self, $lexical ) = @_; |
47
|
|
|
|
|
|
|
|
48
|
32
|
|
|
|
|
143
|
my $s = $self->names->{$lexical->symbol_name} = $lexical; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |