line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PLS::Parser::Element::Subroutine; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
66
|
use strict; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
290
|
|
4
|
11
|
|
|
11
|
|
44
|
use warnings; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
235
|
|
5
|
|
|
|
|
|
|
|
6
|
11
|
|
|
11
|
|
45
|
use parent 'PLS::Parser::Element'; |
|
11
|
|
|
|
|
85
|
|
|
11
|
|
|
|
|
78
|
|
7
|
|
|
|
|
|
|
|
8
|
11
|
|
|
11
|
|
601
|
use List::Util qw(any); |
|
11
|
|
|
|
|
14
|
|
|
11
|
|
|
|
|
3621
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
PLS::Parser::Element::Subroutine |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Subclass of L<PLS::Parser::Element> representing a subroutine declaration. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub location_info |
21
|
|
|
|
|
|
|
{ |
22
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my $info = $self->SUPER::location_info; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my $signature = $self->signature; |
27
|
0
|
0
|
|
|
|
|
$info->{signature} = $signature if (ref $signature eq 'HASH'); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
return $info; |
30
|
|
|
|
|
|
|
} ## end sub location_info |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub signature |
33
|
|
|
|
|
|
|
{ |
34
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $block = $self->element->block; |
37
|
0
|
0
|
|
|
|
|
return unless (ref $block eq 'PPI::Structure::Block'); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# only looking at first variable statement, for performance sake. |
40
|
0
|
|
|
|
|
|
foreach my $child ($block->children) |
41
|
|
|
|
|
|
|
{ |
42
|
0
|
0
|
|
|
|
|
next unless $child->isa('PPI::Statement::Variable'); |
43
|
0
|
0
|
|
|
|
|
return unless $child->type eq 'my'; |
44
|
|
|
|
|
|
|
return |
45
|
0
|
0
|
|
0
|
|
|
unless any { $_->isa('PPI::Token::Magic') and $_->content eq '@_' } |
46
|
0
|
0
|
|
|
|
|
$child->children; |
47
|
0
|
0
|
|
|
|
|
return unless (scalar $child->variables); |
48
|
0
|
|
|
|
|
|
return {label => $child->content, parameters => [map { {label => $_} } $child->variables]}; |
|
0
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
} ## end foreach my $child ($block->...) |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return; |
52
|
|
|
|
|
|
|
} ## end sub signature |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub name |
55
|
|
|
|
|
|
|
{ |
56
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return $self->element->name; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub length |
62
|
|
|
|
|
|
|
{ |
63
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
return $self->SUPER::length() + length('sub '); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |