lib/B/Hooks/AtRuntime.xs

filter: Statementstmt 85.2% 52 / 61 Branchbran 57.1% 40 / 70 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 70.2% 92 / 131 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« tlib/t/D.pm ↑ Summary
1 #include <EXTERN.h>
2 #include <perl.h>
3 #include <XSUB.h>
4  
5 #define NEED_caller_cx
6 #define NEED_PL_parser
7 #define DPPP_PL_parser_NO_DUMMY
8 #include "ppport.h"
9  
10 void
11 9 call_after (pTHX_ void *p)
12 {
13 9 dSP;
14 9 SV *cv = (SV*)p;
15  
16 9 PUSHSTACKi(PERLSI_DESTROY);
17 9 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 9 9
18 9 call_sv(cv, G_VOID|G_DISCARD);
19 9 POPSTACK;
20  
21 9 SvREFCNT_dec(cv);
22 9 }
23  
24 0 void show_cx (pTHX_ const char *name, const PERL_CONTEXT *cx)
25 {
26 0 int is_sub = CxTYPE(cx) == CXt_SUB;
27 0 ▶ CV *cxcv = is_sub ? cx->blk_sub.cv : NULL;
Branch: 1 branch
BranchTrueFalseTotal
CV *cxcv = is_sub ? cx->blk_sub.cv : NULL; 0 0 0
28 0 ▶ int is_special = is_sub ? CvSPECIAL(cxcv) : 0;
Branch: 3 branches
BranchTrueFalseTotal
int is_special = is_sub ? CvSPECIAL(cxcv) : 0; 0 0 0
int is_special = is_sub ? CvSPECIAL(cxcv) : 0; 0 0 0
int is_special = is_sub ? CvSPECIAL(cxcv) : 0; 0 0 0
29 0 ▶ const char *cvname = is_sub ? GvNAME(CvGV(cxcv)) : "<none>";
Branch: 1 branch
BranchTrueFalseTotal
const char *cvname = is_sub ? GvNAME(CvGV(cxcv)) : "<none>"; 0 0 0
30  
31 0 ▶ Perl_warn(aTHX_ "%s: sub %s, special %s, name %s\n",
Branch: 2 branches
BranchTrueFalseTotal
Perl_warn(aTHX_ "%s: sub %s, special %s, name %s\n", 0 0 0
Perl_warn(aTHX_ "%s: sub %s, special %s, name %s\n", 0 0 0
32 name,
33 (is_sub ? "yes" : "no"),
34 (is_special ? "yes" : "no"),
35 cvname);
36 0 }
37  
38 MODULE = B::Hooks::AtRuntime PACKAGE = B::Hooks::AtRuntime
39  
40 #ifdef lex_stuff_sv
41  
42 void
43 lex_stuff (s)
44 SV *s
45 CODE:
46 59 ▶ if (!PL_parser)
Branch: 1 branch
BranchTrueFalseTotal
if (!PL_parser) 0 59 59
47 0 Perl_croak(aTHX_ "Not currently compiling anything");
48 59 lex_stuff_sv(s, 0);
49  
50 #endif
51  
52 UV
53 count_BEGINs ()
54 PREINIT:
55 116 ▶ I32 c = 0;
Branch: 1 branch
BranchTrueFalseTotal
I32 c = 0; 116 0 116
56 const PERL_CONTEXT *cx;
57 const PERL_CONTEXT *dbcx;
58 const CV *cxcv;
59 CODE:
60 116 RETVAL = 0;
61  
62 784 ▶ while ((cx = caller_cx(c++, &dbcx))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((cx = caller_cx(c++, &dbcx))) { 668 116 784
63  
64 /*
65 show_cx(aTHX_ "cx", cx);
66 show_cx(aTHX_ "dbcx", dbcx);
67 */
68  
69 668 ▶ if (CxTYPE(dbcx) == CXt_SUB &&
Branch: 1 branch
BranchTrueFalseTotal
if (CxTYPE(dbcx) == CXt_SUB && 449 219 668
70 449 ▶ (cxcv = dbcx->blk_sub.cv) &&
Branch: 1 branch
BranchTrueFalseTotal
(cxcv = dbcx->blk_sub.cv) && 449 0 449
71 449 ▶ CvSPECIAL(cxcv) &&
Branch: 2 branches
BranchTrueFalseTotal
CvSPECIAL(cxcv) && 115 334 449
CvSPECIAL(cxcv) && 115 0 115
72 115 ▶ strEQ(GvNAME(CvGV(cxcv)), "BEGIN")
Branch: 1 branch
BranchTrueFalseTotal
strEQ(GvNAME(CvGV(cxcv)), "BEGIN") 115 0 115
73 )
74 115 RETVAL++;
75 }
76  
77 /*
78 Perl_warn(aTHX_ "count_BEGINS: frames %i, BEGINs %lu\n",
79 c, RETVAL);
80 */
81 OUTPUT:
82 RETVAL
83  
84 bool
85 compiling_string_eval ()
86 PREINIT:
87 113 I32 c = 0;
88 const PERL_CONTEXT *cx;
89 const PERL_CONTEXT *dbcx;
90 const CV *cxcv;
91 CODE:
92 113 RETVAL = 0;
93 422 ▶ while ((cx = caller_cx(c++, &dbcx))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((cx = caller_cx(c++, &dbcx))) { 421 1 422
94 421 ▶ if (CxTYPE(dbcx) == CXt_SUB &&
Branch: 1 branch
BranchTrueFalseTotal
if (CxTYPE(dbcx) == CXt_SUB && 419 2 421
95 419 ▶ (cxcv = dbcx->blk_sub.cv) &&
Branch: 1 branch
BranchTrueFalseTotal
(cxcv = dbcx->blk_sub.cv) && 419 0 419
96 419 ▶ CvSPECIAL(cxcv) &&
Branch: 2 branches
BranchTrueFalseTotal
CvSPECIAL(cxcv) && 112 307 419
CvSPECIAL(cxcv) && 112 0 112
97 112 ▶ strEQ(GvNAME(CvGV(cxcv)), "BEGIN")
Branch: 1 branch
BranchTrueFalseTotal
strEQ(GvNAME(CvGV(cxcv)), "BEGIN") 112 0 112
98 ) {
99 112 cx = caller_cx(c + 1, &dbcx);
100 112 ▶ if (cx && CxREALEVAL(dbcx))
Branch: 2 branches
BranchTrueFalseTotal
if (cx && CxREALEVAL(dbcx)) 112 0 112
if (cx && CxREALEVAL(dbcx)) 2 110 112
101 2 RETVAL = 1;
102 112 break;
103 }
104 }
105 OUTPUT:
106 RETVAL
107  
108 SV *
109 remaining_text ()
110 PREINIT:
111 char *c;
112 CODE:
113 55 RETVAL = &PL_sv_undef;
114 55 ▶ if (PL_parser) {
Branch: 1 branch
BranchTrueFalseTotal
if (PL_parser) { 55 0 55
115 112 ▶ for (c = PL_bufptr; c < PL_bufend; c++) {
Branch: 3 branches
BranchTrueFalseTotal
for (c = PL_bufptr; c < PL_bufend; c++) { 0 55 55
for (c = PL_bufptr; c < PL_bufend; c++) { 0 112 112
for (c = PL_bufptr; c < PL_bufend; c++) { 59 53 112
116 59 ▶ if (isSPACE(*c)) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (isSPACE(*c)) continue; 57 2 59
117 2 ▶ if (*c == '#') break;
Branch: 1 branch
BranchTrueFalseTotal
if (*c == '#') break; 1 1 2
118 /* strictly it might be UTF8, but this is just an error so I
119 * don't care. */
120 1 ▶ RETVAL = newSVpvn(c, PL_bufend - c);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = newSVpvn(c, PL_bufend - c); 0 1 1
121 1 break;
122 }
123 }
124 OUTPUT:
125 RETVAL
126  
127 void
128 run (...)
129 PREINIT:
130 85 dORIGMARK;
131 SV *sv;
132 85 I32 i = 0;
133 CODE:
134 /* This is the magic step... This leaves the scope that
135 * surrounds the call to run(), putting us back in the outer
136 * scope we were called from. This is what makes after_runtime
137 * subs run at the end of the inserted-into scope, rather than
138 * when run() finishes. */
139 85 LEAVE;
140  
141 186 ▶ while (i++ < items) {
Branch: 1 branch
BranchTrueFalseTotal
while (i++ < items) { 101 85 186
142 101 sv = *(MARK + i);
143  
144 101 ▶ if (!SvROK(sv))
Branch: 1 branch
BranchTrueFalseTotal
if (!SvROK(sv)) 0 101 101
145 0 Perl_croak(aTHX_ "Not a reference");
146 101 sv = SvRV(sv);
147  
148 /* We have a ref to a ref; this is after_runtime. */
149 101 ▶ if (SvROK(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv)) { 9 92 101
150 9 sv = SvRV(sv);
151 9 SvREFCNT_inc(sv);
152 9 SAVEDESTRUCTOR_X(call_after, sv);
153 }
154 /* This is at_runtime. */
155 else {
156 92 ▶ PUSHMARK(SP); PUTBACK;
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); PUTBACK; 0 92 92
157 92 call_sv(sv, G_VOID|G_DISCARD);
158 92 MSPAGAIN;
159  
160 }
161 }
162  
163 /* Re-enter the scope level we were supposed to be in, or perl
164 * will get confused. */
165 85 ENTER;
« tlib/t/D.pm ↑ Summary