blib/lib/Devel/Callsite.pm

filter: Statementstmt 66.6% 20 / 30 Branchbran 40.0% 4 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod 100% 1 / 1 totaltotal 63.2% 31 / 49 CC 3 SCAR 5.0
CC
3
Cov
60%
BEGIN
2.1
caller_nextop
2.1
__ANON__
2.0
CRAP 1.6
↑ Summary Callsite.xs »
1 package Devel::Callsite;
2 2 ▶use 5.005;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use XSLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 $VERSION = '1.0.1';
7 2 ▶if ($] >= 5.026) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= 5.026) { } 2 0 2
8 2 @EXPORT = qw/callsite context addr_to_op caller_nextop/;
9 } else {
10 0 @EXPORT = qw/callsite context/;
11 }
12  
13 2 XSLoader::load __PACKAGE__;
14  
15 2 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.6
16 2 ▶ if ($] >= 5.026) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= "5.026") 2 0 2
17 1 ▶ sub caller_nextop {
Subroutine caller_nextop: called CC=2 SCAR=7.2
Pod documented
18 1 ▶ my $level = ($#_ ? shift : 0) + 1;
Branch: 1 branch
BranchTrueFalseTotal
$#_ ? : 1 0 1
19 1 return addr_to_op(callsite($level));
20 }
21 }
22 }
23  
24 # Demo code
25 2 ▶unless (caller) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller) 0 2 2
26 0 ▶ my $site = sub { return callsite() };
Subroutine __ANON__: not called CC=1 SCAR=6.9
27 0 printf "OP location: 0x%x\n", $site->(); # prints caller OP location
28 0 printf "OP location: 0x%x\n", $site->(); # prints a different OP location
29  
30 0 ▶ if ($] >= 5.026) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= "5.026") 0 0 0
31 0 ▶ my $get_op = sub { return caller_nextop() };
Subroutine __ANON__: not called CC=1 SCAR=6.9
32 0 printf "OP is: %s\n", $get_op->();
33  
34 # prints the interpreter context, an unsigned number
35 0 print "Expression context is: ", context(), "\n";
36 }
37 }
38  
39 2 1;
40 __END__
↑ Summary Callsite.xs »