line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sub::Identify; |
2
|
|
|
|
|
|
|
|
3
|
13
|
|
|
13
|
|
286494
|
use strict; |
|
13
|
|
|
|
|
30
|
|
|
13
|
|
|
|
|
346
|
|
4
|
13
|
|
|
13
|
|
65
|
use Exporter; |
|
13
|
|
|
|
|
22
|
|
|
13
|
|
|
|
|
6984
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
BEGIN { |
7
|
13
|
|
|
13
|
|
28
|
our $VERSION = '0.12'; |
8
|
13
|
|
|
|
|
118
|
our @ISA = ('Exporter'); |
9
|
13
|
|
|
|
|
66
|
our %EXPORT_TAGS = ( |
10
|
|
|
|
|
|
|
all => [ |
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
12
|
|
|
|
|
|
|
sub_name |
13
|
|
|
|
|
|
|
stash_name |
14
|
|
|
|
|
|
|
sub_fullname |
15
|
|
|
|
|
|
|
get_code_info |
16
|
|
|
|
|
|
|
get_code_location |
17
|
|
|
|
|
|
|
is_sub_constant |
18
|
|
|
|
|
|
|
) |
19
|
|
|
|
|
|
|
] |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
13
|
|
|
|
|
30
|
our $IsPurePerl = 1; |
23
|
13
|
100
|
|
|
|
81
|
unless ($ENV{PERL_SUB_IDENTIFY_PP}) { |
24
|
8
|
50
|
|
|
|
14
|
if ( |
25
|
|
|
|
|
|
|
eval { |
26
|
8
|
|
|
|
|
37
|
require XSLoader; |
27
|
8
|
|
|
|
|
4178
|
XSLoader::load(__PACKAGE__, $VERSION); |
28
|
8
|
|
|
|
|
55
|
1; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
) { |
31
|
8
|
|
|
|
|
18
|
$IsPurePerl = 0; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else { |
34
|
0
|
0
|
0
|
|
|
0
|
die $@ if $@ && $@ !~ /object version|loadable object/; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
13
|
100
|
|
|
|
45
|
if ($IsPurePerl) { |
39
|
5
|
|
|
|
|
23
|
require B; |
40
|
|
|
|
|
|
|
*get_code_info = sub ($) { |
41
|
32
|
|
|
32
|
|
53
|
my ($coderef) = @_; |
42
|
32
|
50
|
|
|
|
82
|
ref $coderef or return; |
43
|
32
|
|
|
|
|
103
|
my $cv = B::svref_2object($coderef); |
44
|
32
|
50
|
|
|
|
170
|
$cv->isa('B::CV') or return; |
45
|
|
|
|
|
|
|
# bail out if GV is undefined |
46
|
32
|
50
|
|
|
|
184
|
$cv->GV->isa('B::SPECIAL') and return; |
47
|
|
|
|
|
|
|
|
48
|
32
|
|
|
|
|
330
|
return ($cv->GV->STASH->NAME, $cv->GV->NAME); |
49
|
5
|
|
|
|
|
38
|
}; |
50
|
|
|
|
|
|
|
*get_code_location = sub ($) { |
51
|
4
|
|
|
4
|
|
1524
|
my ($coderef) = @_; |
52
|
4
|
50
|
|
|
|
16
|
ref $coderef or return; |
53
|
4
|
|
|
|
|
28
|
my $cv = B::svref_2object($coderef); |
54
|
4
|
100
|
66
|
|
|
122
|
$cv->isa('B::CV') && $cv->START->isa('B::COP') |
55
|
|
|
|
|
|
|
or return; |
56
|
|
|
|
|
|
|
|
57
|
2
|
|
|
|
|
23
|
return ($cv->START->file, $cv->START->line); |
58
|
5
|
|
|
|
|
37
|
}; |
59
|
|
|
|
|
|
|
} |
60
|
13
|
100
|
66
|
|
|
1016
|
if ($IsPurePerl || $] < 5.016) { |
61
|
5
|
|
|
|
|
20
|
require B; |
62
|
|
|
|
|
|
|
*is_sub_constant = sub ($) { |
63
|
5
|
|
|
5
|
|
234
|
my ($coderef) = @_; |
64
|
5
|
50
|
|
|
|
15
|
ref $coderef or return 0; |
65
|
5
|
|
|
|
|
14
|
my $cv = B::svref_2object($coderef); |
66
|
5
|
50
|
|
|
|
39
|
$cv->isa('B::CV') or return 0; |
67
|
5
|
|
|
|
|
9
|
my $p = prototype $coderef; |
68
|
5
|
100
|
66
|
|
|
27
|
defined $p && $p eq "" or return 0; |
69
|
3
|
|
|
|
|
22
|
return ($cv->CvFLAGS & B::CVf_CONST()) == B::CVf_CONST(); |
70
|
5
|
|
|
|
|
485
|
}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
22
|
|
|
22
|
0
|
108
|
sub stash_name ($) { (get_code_info($_[0]))[0] } |
75
|
28
|
|
|
28
|
0
|
914
|
sub sub_name ($) { (get_code_info($_[0]))[1] } |
76
|
30
|
|
|
30
|
0
|
39303
|
sub sub_fullname ($) { join '::', get_code_info($_[0]) } |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |