File Coverage

OnlyCoreDependencies.xs
Criterion Covered Total %
statement 22 61 36.0
branch 16 70 22.8
condition n/a
subroutine n/a
pod n/a
total 38 131 29.0


line stmt bran cond sub pod time code
1             #include
2             #include
3             #include
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 0           call_after (pTHX_ void *p)
12             {
13 0           dSP;
14 0           SV *cv = (SV*)p;
15              
16 0           PUSHSTACKi(PERLSI_DESTROY);
17 0 0         PUSHMARK(SP);
18 0           call_sv(cv, G_VOID|G_DISCARD);
19 0           POPSTACK;
20              
21 0           SvREFCNT_dec(cv);
22 0           }
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 0         CV *cxcv = is_sub ? cx->blk_sub.cv : NULL;
28 0 0         int is_special = is_sub ? CvSPECIAL(cxcv) : 0;
    0          
    0          
29 0 0         const char *cvname = is_sub ? GvNAME(CvGV(cxcv)) : "";
30              
31 0 0         Perl_warn(aTHX_ "%s: sub %s, special %s, name %s\n",
    0          
32             name,
33             (is_sub ? "yes" : "no"),
34             (is_special ? "yes" : "no"),
35             cvname);
36 0           }
37              
38             MODULE = B::Hooks::AtRuntime::OnlyCoreDependencies PACKAGE = B::Hooks::AtRuntime::OnlyCoreDependencies
39              
40             #ifdef lex_stuff_sv
41              
42             void
43             lex_stuff (s)
44             SV *s
45             CODE:
46 13 50         if (!PL_parser)
47 0           Perl_croak(aTHX_ "Not currently compiling anything");
48 13           lex_stuff_sv(s, 0);
49              
50             #endif
51              
52             UV
53             count_BEGINs ()
54             PREINIT:
55 16 50         I32 c = 0;
56             const PERL_CONTEXT *cx;
57             const PERL_CONTEXT *dbcx;
58             const CV *cxcv;
59             CODE:
60 16           RETVAL = 0;
61              
62 86 100         while ((cx = caller_cx(c++, &dbcx))) {
63              
64             /*
65             show_cx(aTHX_ "cx", cx);
66             show_cx(aTHX_ "dbcx", dbcx);
67             */
68              
69 70 100         if (CxTYPE(dbcx) == CXt_SUB &&
70 52 50         (cxcv = dbcx->blk_sub.cv) &&
71 52 100         CvSPECIAL(cxcv) &&
    50          
72 17 50         strEQ(GvNAME(CvGV(cxcv)), "BEGIN")
73             )
74 17           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 0           I32 c = 0;
88             const PERL_CONTEXT *cx;
89             const PERL_CONTEXT *dbcx;
90             const CV *cxcv;
91             CODE:
92 0           RETVAL = 0;
93 0 0         while ((cx = caller_cx(c++, &dbcx))) {
94 0 0         if (CxTYPE(dbcx) == CXt_SUB &&
95 0 0         (cxcv = dbcx->blk_sub.cv) &&
96 0 0         CvSPECIAL(cxcv) &&
    0          
97 0 0         strEQ(GvNAME(CvGV(cxcv)), "BEGIN")
98             ) {
99 0           cx = caller_cx(c + 1, &dbcx);
100 0 0         if (cx && CxREALEVAL(dbcx))
    0          
101 0           RETVAL = 1;
102 0           break;
103             }
104             }
105             OUTPUT:
106             RETVAL
107              
108             SV *
109             remaining_text ()
110             PREINIT:
111             char *c;
112             CODE:
113 0           RETVAL = &PL_sv_undef;
114 0 0         if (PL_parser) {
115 0 0         for (c = PL_bufptr; c < PL_bufend; c++) {
    0          
    0          
116 0 0         if (isSPACE(*c)) continue;
117 0 0         if (*c == '#') break;
118             /* strictly it might be UTF8, but this is just an error so I
119             * don't care. */
120 0 0         RETVAL = newSVpvn(c, PL_bufend - c);
121 0           break;
122             }
123             }
124             OUTPUT:
125             RETVAL
126              
127             void
128             run (...)
129             PREINIT:
130 21           dORIGMARK;
131             SV *sv;
132 21           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 21           LEAVE;
140              
141 45 100         while (i++ < items) {
142 24           sv = *(MARK + i);
143              
144 24 50         if (!SvROK(sv))
145 0           Perl_croak(aTHX_ "Not a reference");
146 24           sv = SvRV(sv);
147              
148             /* We have a ref to a ref; this is after_runtime. */
149 24 50         if (SvROK(sv)) {
150 0           sv = SvRV(sv);
151 0           SvREFCNT_inc(sv);
152 0           SAVEDESTRUCTOR_X(call_after, sv);
153             }
154             /* This is at_runtime. */
155             else {
156 24 50         PUSHMARK(SP); PUTBACK;
157 24           call_sv(sv, G_VOID|G_DISCARD);
158 24           MSPAGAIN;
159              
160             }
161             }
162              
163             /* Re-enter the scope level we were supposed to be in, or perl
164             * will get confused. */
165 21           ENTER;