| 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
| Branch | True | False | Total |
| 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
| Branch | True | False | Total |
| 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
| Branch | True | False | Total |
| if (i < 0) { |
0 |
573 |
573 |
|
| 29 |
0 |
| return NULL; |
| 30 |
|
| } |
| 31 |
|
| |
| 32 |
573 |
▶ | if (skip_internals && (i >= 0)) { |
Branch: 2 branches
| Branch | True | False | Total |
| 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
| Branch | True | False | Total |
| 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
| Branch | True | False | Total |
| return (i >= 0) ? &cxstack[i] : NULL; |
572 |
1 |
573 |
|
| 40 |
|
| } |