src/try-catch-stack.c

filter: Statementstmt 93.3% 14 / 15 Branchbran 68.7% 11 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 80.6% 25 / 31 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Syntax/Feature/Try.pm ↑ Summary Try.xs »
1 #include "try-catch-constants.h"
2 #include "try-catch-stack.h"
3  
4 #include <perl.h>
5  
6 #define get_sub_context_ix(start_ix) my_get_sub_context_ix(aTHX_ start_ix)
7 1146 STATIC I32 my_get_sub_context_ix(pTHX_ I32 start_ix) {
8 I32 i;
9  
10 1757 ▶ for (i = start_ix; i >= 0; i--) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = start_ix; i >= 0; i--) { 1756 1 1757
11 1756 register const PERL_CONTEXT * const cx = &cxstack[i];
12 1756 ▶ switch (CxTYPE(cx)) {
Branch: 1 branch
BranchTrueFalseTotal
switch (CxTYPE(cx)) { 1145 611 1756
13 1145 case CXt_EVAL:
14 case CXt_SUB:
15 case CXt_FORMAT:
16 1145 return i;
17 }
18 }
19 1 return -1;
20 }
21  
22 #define is_called_internally(cx) \
23 CopSTASH_eq((cx)->blk_oldcop, internal_stash)
24  
25 573 static PERL_CONTEXT* my_get_sub_context(pTHX_ int skip_internals) {
26 I32 i;
27 573 i = get_sub_context_ix(cxstack_ix);
28 573 ▶ if (i < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (i < 0) { 0 573 573
29 0 return NULL;
30 }
31  
32 573 ▶ if (skip_internals && (i >= 0)) {
Branch: 2 branches
BranchTrueFalseTotal
if (skip_internals && (i >= 0)) { 573 0 573
if (skip_internals && (i >= 0)) { 573 0 573
33 // skip internally called
34 573 ▶ while ((i >= 0) && is_called_internally(&cxstack[i])) i--;
Branch: 2 branches
BranchTrueFalseTotal
while ((i >= 0) && is_called_internally(&cxstack[i])) i--; 573 0 573
while ((i >= 0) && is_called_internally(&cxstack[i])) i--; 0 573 573
35  
36 // skip last internal block and find upper sub
37 573 i = get_sub_context_ix(i-1);
38 }
39 573 ▶ return (i >= 0) ? &cxstack[i] : NULL;
Branch: 1 branch
BranchTrueFalseTotal
return (i >= 0) ? &cxstack[i] : NULL; 572 1 573
40 }
« blib/lib/Syntax/Feature/Try.pm ↑ Summary Try.xs »