| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Devel::Callsite; |
|
2
|
2
|
|
|
2
|
|
48490
|
use 5.005; |
|
|
2
|
|
|
|
|
11
|
|
|
3
|
2
|
|
|
2
|
|
8
|
use vars qw($VERSION); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
93
|
|
|
4
|
2
|
|
|
2
|
|
8
|
use XSLoader; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
30
|
|
|
5
|
2
|
|
|
2
|
|
6
|
use base qw(Exporter); |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
366
|
|
|
6
|
|
|
|
|
|
|
$VERSION = '1.0.1'; |
|
7
|
|
|
|
|
|
|
if ($] >= 5.026) { |
|
8
|
|
|
|
|
|
|
@EXPORT = qw/callsite context addr_to_op caller_nextop/; |
|
9
|
|
|
|
|
|
|
} else { |
|
10
|
|
|
|
|
|
|
@EXPORT = qw/callsite context/; |
|
11
|
|
|
|
|
|
|
} |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
XSLoader::load __PACKAGE__; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
BEGIN { |
|
16
|
2
|
50
|
|
2
|
|
240
|
if ($] >= 5.026) { |
|
|
0
|
|
|
|
|
0
|
|
|
17
|
|
|
|
|
|
|
sub caller_nextop { |
|
18
|
1
|
50
|
|
1
|
1
|
5460
|
my $level = ($#_ ? shift : 0) + 1; |
|
19
|
1
|
|
|
|
|
8
|
return addr_to_op(callsite($level)); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Demo code |
|
25
|
|
|
|
|
|
|
unless (caller) { |
|
26
|
|
|
|
|
|
|
my $site = sub { return callsite() }; |
|
27
|
|
|
|
|
|
|
printf "OP location: 0x%x\n", $site->(); # prints caller OP location |
|
28
|
|
|
|
|
|
|
printf "OP location: 0x%x\n", $site->(); # prints a different OP location |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
if ($] >= 5.026) { |
|
31
|
|
|
|
|
|
|
my $get_op = sub { return caller_nextop() }; |
|
32
|
|
|
|
|
|
|
printf "OP is: %s\n", $get_op->(); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# prints the interpreter context, an unsigned number |
|
35
|
|
|
|
|
|
|
print "Expression context is: ", context(), "\n"; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
|
40
|
|
|
|
|
|
|
__END__ |