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