line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sub::Called; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: get information about how the subroutine is called |
4
|
|
|
|
|
|
|
|
5
|
12
|
|
|
12
|
|
336977
|
use warnings; |
|
12
|
|
|
|
|
96
|
|
|
12
|
|
|
|
|
404
|
|
6
|
12
|
|
|
12
|
|
59
|
use strict; |
|
12
|
|
|
|
|
26
|
|
|
12
|
|
|
|
|
254
|
|
7
|
|
|
|
|
|
|
|
8
|
12
|
|
|
12
|
|
57
|
use B; |
|
12
|
|
|
|
|
22
|
|
|
12
|
|
|
|
|
438
|
|
9
|
12
|
|
|
12
|
|
56
|
use Exporter; |
|
12
|
|
|
|
|
20
|
|
|
12
|
|
|
|
|
6945
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw(with_ampersand already_called not_called); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub with_ampersand { |
18
|
|
|
|
|
|
|
|
19
|
25
|
|
100
|
25
|
1
|
9769
|
my $sub = (caller(2))[3] || "main"; |
20
|
25
|
|
|
|
|
148
|
my $line = (caller(1))[2]; |
21
|
|
|
|
|
|
|
|
22
|
25
|
|
|
|
|
104
|
my $func = (caller(1))[3]; |
23
|
|
|
|
|
|
|
|
24
|
25
|
|
|
|
|
49
|
my $svref = \&{$sub}; |
|
25
|
|
|
|
|
93
|
|
25
|
25
|
|
|
|
|
113
|
my $obj = B::svref_2object( $svref ); |
26
|
|
|
|
|
|
|
|
27
|
25
|
100
|
|
|
|
124
|
my $op = $sub eq 'main' ? B::main_start() : $obj->START; |
28
|
25
|
|
|
|
|
47
|
my $is_line = 0; |
29
|
25
|
|
|
|
|
35
|
my $retval = 0; |
30
|
25
|
|
|
|
|
36
|
my $is_gv = 0; |
31
|
|
|
|
|
|
|
|
32
|
25
|
|
|
|
|
58
|
my $test = B::main_cv; |
33
|
|
|
|
|
|
|
|
34
|
25
|
|
|
|
|
107
|
for(; $$op; $op = $op->next ){ |
35
|
617
|
|
|
|
|
1523
|
my $name = $op->name; |
36
|
617
|
100
|
|
|
|
1219
|
if( $name eq 'nextstate' ){ |
|
|
100
|
|
|
|
|
|
37
|
116
|
|
|
|
|
252
|
$is_line = ( $op->line == $line ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
elsif( $name eq 'gv' ){ |
40
|
33
|
|
|
|
|
51
|
my $stash = ""; |
41
|
33
|
|
|
|
|
44
|
my $globname = ""; |
42
|
|
|
|
|
|
|
|
43
|
33
|
50
|
|
|
|
274
|
if( B::class( $op ) eq 'PADOP' ){ |
44
|
0
|
|
|
|
|
0
|
my $sv = (( $test->PADLIST->ARRAY)[1]->ARRAY)[ $op->padix ]; |
45
|
0
|
0
|
|
|
|
0
|
if( $sv ){ |
46
|
0
|
|
|
|
|
0
|
my $class = B::class( $sv ); |
47
|
0
|
0
|
|
|
|
0
|
if( $class eq 'GV' ){ |
48
|
0
|
|
|
|
|
0
|
$stash = $sv->STASH->NAME; |
49
|
0
|
|
|
|
|
0
|
$globname = $sv->SAFENAME; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else { |
54
|
33
|
|
|
|
|
149
|
$globname = $op->gv->NAME; |
55
|
33
|
|
|
|
|
248
|
$stash = $op->gv->STASH->NAME; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
33
|
|
|
|
|
92
|
my $check = $stash . '::' . $globname; |
59
|
33
|
100
|
|
|
|
91
|
$is_gv = 1 if $check eq $func; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
617
|
100
|
100
|
|
|
2519
|
next unless $is_line and $is_gv and $name eq 'entersub'; |
|
|
|
100
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
16
|
|
|
|
|
63
|
my $priv = $op->private; |
65
|
|
|
|
|
|
|
|
66
|
16
|
|
|
|
|
30
|
my $key = 8; |
67
|
16
|
100
|
66
|
|
|
69
|
if( ( $key & $priv) == $key and $priv > $key ){ |
68
|
9
|
|
|
|
|
20
|
$retval = 1; |
69
|
|
|
|
|
|
|
} |
70
|
16
|
|
|
|
|
27
|
last; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
25
|
|
|
|
|
113
|
return $retval; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my %called; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub already_called() { |
80
|
2
|
|
|
2
|
1
|
110
|
my ( $package, $filename, $line, $subroutine ) = caller(1); |
81
|
2
|
|
|
|
|
8
|
my $called = $called{$package}{$subroutine}; |
82
|
2
|
|
|
|
|
6
|
$called{$package}{$subroutine} = 1; |
83
|
2
|
|
|
|
|
10
|
return $called; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub not_called() { |
88
|
2
|
|
|
2
|
1
|
97
|
my ( $package, $filename, $line, $subroutine ) = caller(1); |
89
|
2
|
|
|
|
|
7
|
my $called = $called{$package}{$subroutine}; |
90
|
2
|
|
|
|
|
5
|
$called{$package}{$subroutine} = 1; |
91
|
2
|
|
|
|
|
11
|
return not $called; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; # End of Sub::Called |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |