Generate.xs

filter: Statementstmt 38.3% 210 / 548 Branchbran 29.7% 117 / 394 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 34.7% 327 / 942 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/B/Generate.pm ↑ Summary
1 /* -*- mode:C tab-width:4 -*- */
2 #define PERL_NO_GET_CONTEXT
3 #include "EXTERN.h"
4 #include "perl.h"
5 #include "perlapi.h"
6 #include "XSUB.h"
7  
8  
9 #ifdef PERL_OBJECT
10 # undef PL_op_name
11 # undef PL_opargs
12 # undef PL_op_desc
13 # define PL_op_name (get_op_names())
14 # define PL_opargs (get_opargs())
15 # define PL_op_desc (get_op_descs())
16 #endif
17  
18 /* CPAN #28912: MSWin32 and AIX as only platforms do not export PERL_CORE functions,
19 such as Perl_pad_alloc, Perl_cv_clone, fold_constants,
20 so disable this feature. cygwin gcc-3 --export-all-symbols was non-strict, gcc-4 is.
21 POSIX with export PERL_DL_NONLAZY=1 also fails. This is checked in Makefile.PL
22 but cannot be solved for clients adding it.
23 TODO: Add the patchlevel here when it is fixed in CORE.
24 */
25 #if !defined (DISABLE_PERL_CORE_EXPORTED) && \
26 (defined(WIN32) || \
27 defined(_MSC_VER) || defined(__MINGW32_VERSION) || \
28 (defined(__CYGWIN__) && (__GNUC__ > 3)) || defined(AIX))
29 # define DISABLE_PERL_CORE_EXPORTED
30 #endif
31  
32 #ifdef DISABLE_PERL_CORE_EXPORTED
33 # undef HAVE_PAD_ALLOC
34 # undef HAVE_CV_CLONE
35 # undef HAVE_FOLD_CONSTANTS
36 #endif
37  
38 #ifdef PERL_CUSTOM_OPS
39 # define CHECK_CUSTOM_OPS \
40 if (typenum == OP_CUSTOM) \
41 o->op_ppaddr = custom_op_ppaddr(SvPV_nolen(type));
42 #else
43 # define CHECK_CUSTOM_OPS
44 #endif
45  
46 #ifndef PadARRAY
47 #undef HAVE_PADNAMELIST
48 # if PERL_VERSION < 8 || (PERL_VERSION == 8 && !PERL_SUBVERSION)
49 typedef AV PADLIST;
50 typedef AV PAD;
51 # endif
52 # define PadlistARRAY(pl) ((PAD **)AvARRAY(pl))
53 # define PadlistNAMES(pl) (*PadlistARRAY(pl))
54 # define PadARRAY AvARRAY
55 # define PadnamelistMAX AvFILLp
56 # define PadnamelistARRAY AvARRAY
57 #else
58 #define HAVE_PADNAMELIST
59 #endif
60  
61 #ifndef SvIS_FREED
62 # define SvIS_FREED(sv) ((sv)->sv_flags == SVTYPEMASK)
63 #endif
64 #ifndef OpSIBLING
65 # ifdef PERL_OP_PARENT
66 # define OpSIBLING(o) (0 + (o)->op_moresib ? (o)->op_sibparent : NULL)
67 # define OpSIBLING_set(o, v) ((o)->op_moresib ? (o)->op_sibparent = (v) : NULL)
68 # else
69 # define OpSIBLING(o) (o)->op_sibling
70 # define OpSIBLING_set(o, v) (o)->op_sibling = (v)
71 # endif
72 #else
73 # ifndef OpSIBLING_set
74 # define OpSIBLING_set(o, v) OpMORESIB_set((o), (v))
75 # endif
76 #endif
77  
78 static const char* const svclassnames[] = {
79 "B::NULL",
80 #if PERL_VERSION >= 9 && PERL_VERSION < 19
81 "B::BIND",
82 #endif
83 "B::IV",
84 "B::NV",
85 #if PERL_VERSION <= 10
86 "B::RV",
87 #endif
88 "B::PV",
89 #if PERL_VERSION >= 19
90 "B::INVLIST",
91 #endif
92 "B::PVIV",
93 "B::PVNV",
94 "B::PVMG",
95 #if PERL_VERSION <= 8
96 "B::BM",
97 #endif
98 #if PERL_VERSION >= 11
99 "B::REGEXP",
100 #endif
101 #if PERL_VERSION >= 9
102 "B::GV",
103 #endif
104 "B::PVLV",
105 "B::AV",
106 "B::HV",
107 "B::CV",
108 #if PERL_VERSION <= 8
109 "B::GV",
110 #endif
111 "B::FM",
112 "B::IO",
113 };
114  
115 typedef enum {
116 OPc_NULL, /* 0 */
117 OPc_BASEOP, /* 1 */
118 OPc_UNOP, /* 2 */
119 OPc_BINOP, /* 3 */
120 OPc_LOGOP, /* 4 */
121 OPc_LISTOP, /* 5 */
122 OPc_PMOP, /* 6 */
123 OPc_SVOP, /* 7 */
124 OPc_PADOP, /* 8 */
125 OPc_PVOP, /* 9 */
126 OPc_CVOP, /* 10 */
127 OPc_LOOP, /* 11 */
128 OPc_COP, /* 12 */
129 OPc_METHOP, /* 13 */
130 OPc_UNOP_AUX /* 14 */
131 } opclass;
132  
133 static char *opclassnames[] = {
134 "B::NULL",
135 "B::OP",
136 "B::UNOP",
137 "B::BINOP",
138 "B::LOGOP",
139 "B::LISTOP",
140 "B::PMOP",
141 "B::SVOP",
142 "B::PADOP",
143 "B::PVOP",
144 "B::CVOP",
145 "B::LOOP",
146 "B::COP",
147 "B::METHOP",
148 "B::UNOP_AUX"
149 };
150  
151 static int walkoptree_debug = 0; /* Flag for walkoptree debug hook */
152  
153 static SV *specialsv_list[7]; /* 0-6 */
154  
155 AV * tmp_comppad;
156 #ifdef HAVE_PADNAMELIST
157 PADNAMELIST * tmp_comppad_name;
158 #else
159 AV * tmp_comppad_name;
160 #endif
161 I32 tmp_padix, tmp_reset_pending;
162 OP * tmp_op;
163  
164 CV * my_curr_cv = NULL;
165  
166 SV** my_current_pad;
167 SV** tmp_pad;
168  
169 HV* root_cache;
170  
171 #define GEN_PAD { set_active_sub(find_cv_by_root((OP*)o));tmp_pad = PL_curpad;PL_curpad = my_current_pad;}
172 #define GEN_PAD_CV(cv) { set_active_sub(cv);tmp_pad = PL_curpad;PL_curpad = my_current_pad;}
173 #define OLD_PAD (PL_curpad = tmp_pad)
174  
175 #define SAVE_VARS \
176 { \
177 tmp_comppad = PL_comppad; \
178 tmp_comppad_name = PL_comppad_name; \
179 tmp_padix = PL_padix; \
180 tmp_reset_pending = PL_pad_reset_pending; \
181 tmp_pad = PL_curpad; \
182 tmp_op = PL_op; \
183 if ( my_curr_cv) { \
184 PL_comppad = PadlistARRAY(CvPADLIST(my_curr_cv))[1]; \
185 PL_comppad_name = PadlistNAMES(CvPADLIST(my_curr_cv)); \
186 PL_padix = PadnamelistMAX(PL_comppad_name); \
187 PL_pad_reset_pending = 0; \
188 } \
189 PL_curpad = AvARRAY(PL_comppad); \
190 }
191  
192 #define RESTORE_VARS \
193 { \
194 PL_op = tmp_op; \
195 PL_comppad = tmp_comppad; \
196 PL_curpad = tmp_pad; \
197 PL_padix = tmp_padix; \
198 PL_comppad_name = tmp_comppad_name; \
199 PL_pad_reset_pending = tmp_reset_pending; \
200 }
201  
202 void
203 0 set_active_sub(SV *sv)
204 {
205 dTHX;
206 PADLIST* padlist;
207 PAD** svp;
208 /* sv_dump(SvRV(sv)); */
209 0 padlist = CvPADLIST(SvRV(sv));
210 0 ▶ if (!padlist) {
Branch: 1 branch
BranchTrueFalseTotal
if (!padlist) { 0 0 0
211 dTHX; /* XXX coverage 0 */
212 0 sv_dump(sv);
213 0 sv_dump((SV*)SvRV(sv));
214 0 croak("set_active_sub: !CvPADLIST(SvRV(sv))");
215 }
216 0 svp = PadlistARRAY(padlist);
217 0 my_current_pad = PadARRAY(svp[1]); /* => GEN_PAD */
218 0 }
219  
220 static SV *
221 3 find_cv_by_root(OP* o) {
222 dTHX;
223 3 OP* root = o;
224 SV* key;
225 HE* cached;
226  
227 3 ▶ if (PL_compcv && SvTYPE(PL_compcv) == SVt_PVCV && !PL_eval_root) {
Branch: 3 branches
BranchTrueFalseTotal
if (PL_compcv && SvTYPE(PL_compcv) == SVt_PVCV && !PL_eval_root) { 0 3 3
if (PL_compcv && SvTYPE(PL_compcv) == SVt_PVCV && !PL_eval_root) { 0 0 0
if (PL_compcv && SvTYPE(PL_compcv) == SVt_PVCV && !PL_eval_root) { 0 0 0
228 /* XXX coverage 0 */
229 0 ▶ if (SvROK(PL_compcv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(PL_compcv)) { 0 0 0
230 0 sv_dump(SvRV(PL_compcv));
231 0 croak("find_cv_by_root: SvROK(PL_compcv)");
232 }
233 0 return newRV((SV*)PL_compcv);
234 }
235  
236 3 ▶ if (!root_cache)
Branch: 1 branch
BranchTrueFalseTotal
if (!root_cache) 2 1 3
237 2 root_cache = newHV();
238  
239 130 ▶ while(root->op_next)
Branch: 1 branch
BranchTrueFalseTotal
while(root->op_next) 127 3 130
240 127 root = root->op_next;
241  
242 3 key = newSViv(PTR2IV(root));
243  
244 3 cached = hv_fetch_ent(root_cache, key, 0, 0);
245 3 ▶ if (cached) {
Branch: 1 branch
BranchTrueFalseTotal
if (cached) { 1 2 3
246 1 SvREFCNT_dec(key);
247 1 return HeVAL(cached);
248 }
249  
250 2 ▶ if (PL_main_root == root) {
Branch: 1 branch
BranchTrueFalseTotal
if (PL_main_root == root) { 1 1 2
251 /* Special case, this is the main root */
252 1 cached = hv_store_ent(root_cache, key, newRV((SV*)PL_main_cv), 0);
253 1 ▶ } else if (PL_eval_root == root && PL_compcv) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (PL_eval_root == root && PL_compcv) { 0 1 1
} else if (PL_eval_root == root && PL_compcv) { 0 0 0
254 0 SV* tmpcv = (SV*)NEWSV(1104,0); /* XXX coverage 0 */
255 0 sv_upgrade((SV *)tmpcv, SVt_PVCV);
256 0 CvPADLIST(tmpcv) = CvPADLIST(PL_compcv);
257 0 SvREFCNT_inc(CvPADLIST(tmpcv));
258 0 CvROOT(tmpcv) = root;
259 OP_REFCNT_LOCK;
260 0 ▶ OpREFCNT_inc(root);
Branch: 1 branch
BranchTrueFalseTotal
OpREFCNT_inc(root); 0 0 0
261 OP_REFCNT_UNLOCK;
262 0 cached = hv_store_ent(root_cache, key, newRV((SV*)tmpcv), 0);
263 } else {
264 /* Need to walk the symbol table, yay */
265 1 CV* cv = 0;
266 SV* sva;
267 SV* sv;
268 register SV* svend;
269  
270 97 ▶ for (sva = PL_sv_arenaroot; sva; sva = (SV*)SvANY(sva)) {
Branch: 1 branch
BranchTrueFalseTotal
for (sva = PL_sv_arenaroot; sva; sva = (SV*)SvANY(sva)) { 97 0 97
271 97 svend = &sva[SvREFCNT(sva)];
272 16421 ▶ for (sv = sva + 1; sv < svend; ++sv) {
Branch: 1 branch
BranchTrueFalseTotal
for (sv = sva + 1; sv < svend; ++sv) { 16325 96 16421
273 16325 ▶ if (!SvIS_FREED(sv) && SvREFCNT(sv)) {
Branch: 2 branches
BranchTrueFalseTotal
if (!SvIS_FREED(sv) && SvREFCNT(sv)) { 16108 217 16325
if (!SvIS_FREED(sv) && SvREFCNT(sv)) { 16108 0 16108
274 16108 ▶ if (SvTYPE(sv) == SVt_PVCV &&
Branch: 1 branch
BranchTrueFalseTotal
if (SvTYPE(sv) == SVt_PVCV && 1668 14440 16108
275 1668 ▶ CvROOT(sv) == root
Branch: 1 branch
BranchTrueFalseTotal
CvROOT(sv) == root 1 1667 1668
276 ) {
277 1 cv = (CV*) sv;
278 1 goto out;
279 16107 ▶ } else if ( SvTYPE(sv) == SVt_PVGV &&
Branch: 1 branch
BranchTrueFalseTotal
} else if ( SvTYPE(sv) == SVt_PVGV && 916 15191 16107
280 #if PERL_VERSION >= 10
281 916 ▶ isGV_with_GP(sv) &&
Branch: 3 branches
BranchTrueFalseTotal
isGV_with_GP(sv) && 916 0 916
isGV_with_GP(sv) && 0 916 916
isGV_with_GP(sv) && 0 0 0
282 #endif
283 916 ▶ GvGP(sv) &&
Branch: 1 branch
BranchTrueFalseTotal
GvGP(sv) && 916 0 916
284 916 ▶ GvCV(sv) && !SvVALID(sv) && !CvXSUB(GvCV(sv)) &&
Branch: 7 branches
BranchTrueFalseTotal
GvCV(sv) && !SvVALID(sv) && !CvXSUB(GvCV(sv)) && 685 231 916
GvCV(sv) && !SvVALID(sv) && !CvXSUB(GvCV(sv)) && 0 685 685
GvCV(sv) && !SvVALID(sv) && !CvXSUB(GvCV(sv)) && 0 0 0
GvCV(sv) && !SvVALID(sv) && !CvXSUB(GvCV(sv)) && 0 0 0
GvCV(sv) && !SvVALID(sv) && !CvXSUB(GvCV(sv)) && 0 0 0
GvCV(sv) && !SvVALID(sv) && !CvXSUB(GvCV(sv)) && 0 0 0
GvCV(sv) && !SvVALID(sv) && !CvXSUB(GvCV(sv)) && 0 685 685
285 0 ▶ CvROOT(GvCV(sv)) == root)
Branch: 1 branch
BranchTrueFalseTotal
CvROOT(GvCV(sv)) == root) 0 0 0
286 {
287 0 cv = (CV*) GvCV(sv); /* XXX coverage 0 */
288 0 goto out;
289 }
290 }
291 }
292 }
293  
294 0 ▶ if (!cv) {
Branch: 1 branch
BranchTrueFalseTotal
if (!cv) { 0 0 0
295 0 croak("find_cv_by_root: couldn't find the root cv\n"); /* XXX coverage 0 */
296 }
297 0 out:
298 1 cached = hv_store_ent(root_cache, key, newRV((SV*)cv), 0);
299 }
300  
301 2 SvREFCNT_dec(key);
302 2 return (SV*) HeVAL(cached);
303 }
304  
305  
306 static SV *
307 390 make_sv_object(pTHX_ SV *arg, SV *sv)
308 {
309 390 char *type = 0;
310 IV iv;
311  
312 3120 ▶ for (iv = 0; iv < sizeof(specialsv_list)/sizeof(SV*); iv++) {
Branch: 1 branch
BranchTrueFalseTotal
for (iv = 0; iv < sizeof(specialsv_list)/sizeof(SV*); iv++) { 2730 390 3120
313 2730 ▶ if (sv == specialsv_list[iv]) {
Branch: 1 branch
BranchTrueFalseTotal
if (sv == specialsv_list[iv]) { 0 2730 2730
314 0 type = "B::SPECIAL"; /* XXX coverage 0 */
315 0 break;
316 }
317 }
318 390 ▶ if (!type) {
Branch: 1 branch
BranchTrueFalseTotal
if (!type) { 390 0 390
319 390 type = (char*)svclassnames[SvTYPE(sv)];
320 390 iv = PTR2IV(sv);
321 }
322 390 sv_setiv(newSVrv(arg, type), iv);
323 390 return arg;
324 }
325  
326  
327 /*
328 #define PERL_CUSTOM_OPS
329 now defined by Makefile.PL, if building for 5.8.x
330 */
331 static I32
332 6 op_name_to_num(SV * name)
333 {
334 dTHX;
335 char const *s;
336 6 char *wanted = SvPV_nolen(name);
337 6 int i =0;
338 6 int topop = OP_max;
339  
340 #ifdef PERL_CUSTOM_OPS
341 6 topop--;
342 #endif
343  
344 6 ▶ if (SvIOK(name) && SvIV(name) >= 0 && SvIV(name) < topop)
Branch: 3 branches
BranchTrueFalseTotal
if (SvIOK(name) && SvIV(name) >= 0 && SvIV(name) < topop) 0 6 6
if (SvIOK(name) && SvIV(name) >= 0 && SvIV(name) < topop) 0 0 0
if (SvIOK(name) && SvIV(name) >= 0 && SvIV(name) < topop) 0 0 0
345 0 return SvIV(name); /* XXX coverage 0 */
346  
347 730 ▶ for (s = PL_op_name[i]; s; s = PL_op_name[++i]) {
Branch: 1 branch
BranchTrueFalseTotal
for (s = PL_op_name[i]; s; s = PL_op_name[++i]) { 730 0 730
348 730 ▶ if (strEQ(s, wanted))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(s, wanted)) 6 724 730
349 6 return i;
350 }
351 #ifdef PERL_CUSTOM_OPS
352 0 ▶ if (PL_custom_op_names) {
Branch: 1 branch
BranchTrueFalseTotal
if (PL_custom_op_names) { 0 0 0
353 HE* ent;
354 SV* value;
355  
356 /* This is sort of a hv_exists, backwards - since custom-ops
357 are stored using their pp-addr as key, we must scan the
358 values */
359 0 (void)hv_iterinit(PL_custom_op_names);
360 0 ▶ while ((ent = hv_iternext(PL_custom_op_names))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((ent = hv_iternext(PL_custom_op_names))) { 0 0 0
361 0 ▶ if (strEQ(SvPV_nolen(hv_iterval(PL_custom_op_names,ent)),wanted))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(SvPV_nolen(hv_iterval(PL_custom_op_names,ent)),wanted)) 0 0 0
362 0 return OP_CUSTOM;
363 }
364 }
365 #endif
366  
367 0 croak("No such op \"%s\"", SvPV_nolen(name)); /* XXX coverage 0 */
368  
369 return -1;
370 }
371  
372 #ifdef PERL_CUSTOM_OPS
373 static void*
374 0 custom_op_ppaddr(char *name)
375 {
376 dTHX;
377 HE *ent;
378 SV *value;
379 0 ▶ if (!PL_custom_op_names)
Branch: 1 branch
BranchTrueFalseTotal
if (!PL_custom_op_names) 0 0 0
380 0 return 0;
381  
382 /* This is sort of a hv_fetch, backwards */
383 0 (void)hv_iterinit(PL_custom_op_names);
384 0 ▶ while ((ent = hv_iternext(PL_custom_op_names))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((ent = hv_iternext(PL_custom_op_names))) { 0 0 0
385 0 ▶ if (strEQ(SvPV_nolen(hv_iterval(PL_custom_op_names,ent)),name))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(SvPV_nolen(hv_iterval(PL_custom_op_names,ent)),name)) 0 0 0
386 0 return INT2PTR(void*,SvIV(hv_iterkeysv(ent)));
387 }
388  
389 0 return 0;
390 }
391 #endif
392  
393 static opclass
394 18279 cc_opclass(pTHX_ const OP *o)
395 {
396 18279 bool custom = 0;
397  
398 18279 ▶ if (!o)
Branch: 1 branch
BranchTrueFalseTotal
if (!o) 691 17588 18279
399 691 return OPc_NULL;
400  
401 17588 ▶ if (o->op_type == 0)
Branch: 1 branch
BranchTrueFalseTotal
if (o->op_type == 0) 449 17139 17588
402 449 ▶ return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP;
Branch: 1 branch
BranchTrueFalseTotal
return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP; 390 59 449
403  
404 17139 ▶ if (o->op_type == OP_SASSIGN)
Branch: 1 branch
BranchTrueFalseTotal
if (o->op_type == OP_SASSIGN) 20 17119 17139
405 20 ▶ return ((o->op_private & OPpASSIGN_BACKWARDS) ? OPc_UNOP : OPc_BINOP);
Branch: 1 branch
BranchTrueFalseTotal
return ((o->op_private & OPpASSIGN_BACKWARDS) ? OPc_UNOP : OPc_BINOP); 0 20 20
406  
407 17119 ▶ if (o->op_type == OP_AELEMFAST) {
Branch: 1 branch
BranchTrueFalseTotal
if (o->op_type == OP_AELEMFAST) { 77 17042 17119
408 77 ▶ if (o->op_flags & OPf_SPECIAL)
Branch: 1 branch
BranchTrueFalseTotal
if (o->op_flags & OPf_SPECIAL) 0 77 77
409 0 return OPc_BASEOP;
410 else
411 #ifdef USE_ITHREADS
412 return OPc_PADOP;
413 #else
414 77 return OPc_SVOP;
415 #endif
416 }
417
418 #ifdef USE_ITHREADS
419 if (o->op_type == OP_GV || o->op_type == OP_GVSV
420 || o->op_type == OP_RCATLINE)
421 return OPc_PADOP;
422 #endif
423  
424 #ifdef PERL_CUSTOM_OPS
425 17042 ▶ if (o->op_type == OP_CUSTOM)
Branch: 1 branch
BranchTrueFalseTotal
if (o->op_type == OP_CUSTOM) 0 17042 17042
426 0 custom = 1;
427 #endif
428  
429 17042 switch (PL_opargs[o->op_type] & OA_CLASS_MASK) {
430 2036 case OA_BASEOP:
431 2036 return OPc_BASEOP;
432  
433 4516 case OA_UNOP:
434 4516 return OPc_UNOP;
435  
436 277 case OA_BINOP:
437 277 return OPc_BINOP;
438  
439 769 case OA_LOGOP:
440 769 return OPc_LOGOP;
441  
442 4134 case OA_LISTOP:
443 4134 return OPc_LISTOP;
444  
445 30 case OA_PMOP:
446 30 return OPc_PMOP;
447  
448 701 case OA_SVOP:
449 701 return OPc_SVOP;
450  
451 0 case OA_PADOP:
452 0 return OPc_PADOP;
453  
454 0 case OA_PVOP_OR_SVOP:
455 /*
456 * Character translations (tr///) are usually a PVOP, keeping a
457 * pointer to a table of shorts used to look up translations.
458 * Under utf8, however, a simple table isn't practical; instead,
459 * the OP is an SVOP (or, under threads, a PADOP),
460 * and the SV is a reference to a swash
461 * (i.e., an RV pointing to an HV).
462 */
463 0 return (!custom &&
464 0 ▶ (o->op_private & (OPpTRANS_TO_UTF|OPpTRANS_FROM_UTF))
Branch: 1 branch
BranchTrueFalseTotal
(o->op_private & (OPpTRANS_TO_UTF|OPpTRANS_FROM_UTF)) 0 0 0
465 )
466 #if defined(USE_ITHREADS) \
467 && (PERL_VERSION > 8 || (PERL_VERSION == 8 && PERL_SUBVERSION >= 9))
468 ? OPc_PADOP : OPc_PVOP;
469 #else
470 0 ▶ ? OPc_SVOP : OPc_PVOP;
Branch: 1 branch
BranchTrueFalseTotal
? OPc_SVOP : OPc_PVOP; 0 0 0
471 #endif
472  
473 9 case OA_LOOP:
474 9 return OPc_LOOP;
475  
476 4141 case OA_COP:
477 4141 return OPc_COP;
478  
479 #if PERL_VERSION >= 22
480 325 case OA_METHOP:
481 325 return OPc_METHOP;
482  
483 28 case OA_UNOP_AUX:
484 28 return OPc_UNOP_AUX;
485 #endif
486  
487 76 case OA_BASEOP_OR_UNOP:
488 /*
489 * UNI(OP_foo) in toke.c returns token UNI or FUNC1 depending on
490 * whether parens were seen. perly.y uses OPf_SPECIAL to
491 * signal whether a BASEOP had empty parens or none.
492 * Some other UNOPs are created later, though, so the best
493 * test is OPf_KIDS, which is set in newUNOP.
494 */
495 76 ▶ return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP;
Branch: 1 branch
BranchTrueFalseTotal
return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP; 62 14 76
496  
497 0 case OA_FILESTATOP:
498 /*
499 * The file stat OPs are created via UNI(OP_foo) in toke.c but use
500 * the OPf_REF flag to distinguish between OP types instead of the
501 * usual OPf_SPECIAL flag. As usual, if OPf_KIDS is set, then we
502 * return OPc_UNOP so that walkoptree can find our children. If
503 * OPf_KIDS is not set then we check OPf_REF. Without OPf_REF set
504 * (no argument to the operator) it's an OP; with OPf_REF set it's
505 * an SVOP (and op_sv is the GV for the filehandle argument).
506 */
507 0 ▶ return ((o->op_flags & OPf_KIDS) ? OPc_UNOP :
Branch: 1 branch
BranchTrueFalseTotal
return ((o->op_flags & OPf_KIDS) ? OPc_UNOP : 0 0 0
508 #ifdef USE_ITHREADS
509 (o->op_flags & OPf_REF) ? OPc_PADOP : OPc_BASEOP);
510 #else
511 0 ▶ (o->op_flags & OPf_REF) ? OPc_SVOP : OPc_BASEOP);
Branch: 1 branch
BranchTrueFalseTotal
(o->op_flags & OPf_REF) ? OPc_SVOP : OPc_BASEOP); 0 0 0
512 #endif
513 0 case OA_LOOPEXOP:
514 /*
515 * next, last, redo, dump and goto use OPf_SPECIAL to indicate that a
516 * label was omitted (in which case it's a BASEOP) or else a term was
517 * seen. In this last case, all except goto are definitely PVOP but
518 * goto is either a PVOP (with an ordinary constant label), an UNOP
519 * with OPf_STACKED (with a non-constant non-sub) or an UNOP for
520 * OP_REFGEN (with goto &sub) in which case OPf_STACKED also seems to
521 * get set.
522 */
523 0 ▶ if (o->op_flags & OPf_STACKED)
Branch: 1 branch
BranchTrueFalseTotal
if (o->op_flags & OPf_STACKED) 0 0 0
524 0 return OPc_UNOP;
525 0 ▶ else if (o->op_flags & OPf_SPECIAL)
Branch: 1 branch
BranchTrueFalseTotal
else if (o->op_flags & OPf_SPECIAL) 0 0 0
526 0 return OPc_BASEOP;
527 else
528 0 return OPc_PVOP;
529 }
530 0 ▶ warn("can't determine class of operator %s, assuming BASEOP\n",
Branch: 1 branch
BranchTrueFalseTotal
warn("can't determine class of operator %s, assuming BASEOP\n", 0 0 0
531 OP_NAME(o));
532 0 return OPc_BASEOP;
533 }
534  
535 static char *
536 18279 cc_opclassname(pTHX_ OP *o)
537 {
538 18279 return opclassnames[cc_opclass(aTHX_ o)];
539 }
540  
541 static OP *
542 8 SVtoO(SV* sv)
543 {
544 dTHX;
545 8 ▶ if (SvROK(sv)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv)) { 8 0 8
546 8 IV tmp = SvIV((SV*)SvRV(sv));
547 8 return INT2PTR(OP*,tmp);
548 }
549 else {
550 0 return 0;
551 }
552 croak("Argument is not a reference");
553 return 0; /* Not reached */
554 }
555  
556 /* svop_new */
557  
558 0 SV *__svop_new(pTHX_ SV *class, SV *type, I32 flags, SV *sv)
559 {
560 OP *o;
561 SV *result;
562 SV **sparepad;
563 OP *saveop;
564 I32 typenum;
565  
566 0 ▶ SAVE_VARS;
Branch: 1 branch
BranchTrueFalseTotal
SAVE_VARS; 0 0 0
567 0 sparepad = PL_curpad;
568 0 PL_curpad = AvARRAY(PL_comppad);
569 0 saveop = PL_op;
570 0 typenum = op_name_to_num(type); /* XXX More classes here! */
571 0 ▶ if (typenum == OP_GVSV) {
Branch: 1 branch
BranchTrueFalseTotal
if (typenum == OP_GVSV) { 0 0 0
572 0 ▶ if (*(SvPV_nolen(sv)) == '$')
Branch: 1 branch
BranchTrueFalseTotal
if (*(SvPV_nolen(sv)) == '$') 0 0 0
573 0 sv = (SV*)gv_fetchpv(SvPVX(sv)+1, TRUE, SVt_PV);
574 else
575 0 croak("First character to GVSV was not dollar");
576 } else {
577 0 ▶ if (SvTYPE(sv) != SVt_PVCV) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvTYPE(sv) != SVt_PVCV) { 0 0 0
578 0 sv = newSVsv(sv); /* copy it unless it's cv */
579 }
580 }
581 0 o = newSVOP(typenum, flags, SvREFCNT_inc(sv));
582 0 ▶ CHECK_CUSTOM_OPS
Branch: 1 branch
BranchTrueFalseTotal
CHECK_CUSTOM_OPS 0 0 0
583 0 RESTORE_VARS;
584 0 result = sv_newmortal();
585 0 sv_setiv(newSVrv(result, "B::SVOP"), PTR2IV(o));
586 0 return result;
587 }
588  
589 /* Pre-5.7 compatibility */
590 #ifndef op_clear
591 void op_clear(OP* o) {
592 /* Fake it, I'm bored */
593 croak("This operation requires a newer version of Perl");
594 }
595 #endif
596 #ifndef op_null
597 # define op_null croak("This operation requires a newer version of Perl");
598 #endif
599  
600 #ifndef PM_GETRE
601 # define PM_GETRE(o) ((o)->op_pmregexp)
602 #endif
603  
604 typedef OP *B__OP;
605 typedef UNOP *B__UNOP;
606 typedef BINOP *B__BINOP;
607 typedef LOGOP *B__LOGOP;
608 typedef LISTOP *B__LISTOP;
609 typedef PMOP *B__PMOP;
610 typedef SVOP *B__SVOP;
611 typedef PADOP *B__PADOP;
612 typedef PVOP *B__PVOP;
613 typedef LOOP *B__LOOP;
614 typedef COP *B__COP;
615 #if PERL_VERSION >= 22
616 typedef METHOP *B__METHOP;
617 typedef UNOP_AUX *B__UNOP_AUX;
618 typedef UNOP_AUX_item *B__UNOP_AUX_item;
619 #endif
620  
621 typedef SV *B__SV;
622 typedef SV *B__IV;
623 typedef SV *B__PV;
624 typedef SV *B__NV;
625 typedef SV *B__PVMG;
626 typedef SV *B__PVLV;
627 typedef SV *B__BM;
628 typedef SV *B__RV;
629 typedef AV *B__AV;
630 typedef HV *B__HV;
631 typedef CV *B__CV;
632 typedef GV *B__GV;
633 typedef IO *B__IO;
634  
635 typedef MAGIC *B__MAGIC;
636  
637 MODULE = B::Generate PACKAGE = B PREFIX = B_
638  
639 # XXX coverage 0
640 void
641 B_fudge()
642 CODE:
643 0 ▶ SSCHECK(2);
Branch: 1 branch
BranchTrueFalseTotal
SSCHECK(2); 0 0 0
644 0 SSPUSHPTR((SV*)PL_comppad);
645 0 SSPUSHINT(SAVEt_COMPPAD);
646  
647 # coverage ok
648 B::OP
649 B_main_root(...)
650 PROTOTYPE: ;$
651 CODE:
652 5 ▶ if (items > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 0) 0 5 5
653 0 PL_main_root = SVtoO(ST(0));
654 5 RETVAL = PL_main_root;
655 OUTPUT:
656 RETVAL
657  
658 # coverage ok
659 B::OP
660 B_main_start(...)
661 PROTOTYPE: ;$
662 CODE:
663 6 ▶ if (items > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 0) 0 6 6
664 0 PL_main_start = SVtoO(ST(0));
665 6 RETVAL = PL_main_start;
666 OUTPUT:
667 RETVAL
668  
669 # XXX coverage 0
670 SV *
671 B_cv_pad(...)
672 CV * old_cv = NO_INIT
673 PROTOTYPE: ;$
674 CODE:
675 0 old_cv = my_curr_cv;
676 0 ▶ if (items > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (items > 0) { 0 0 0
677 0 ▶ if (SvROK(ST(0))) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(ST(0))) { 0 0 0
678 IV tmp;
679 0 ▶ if (!sv_derived_from(ST(0), "B::CV"))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(ST(0), "B::CV")) 0 0 0
680 0 croak("Reference is not a B::CV object");
681 0 tmp = SvIV((SV*)SvRV(ST(0)));
682 0 my_curr_cv = INT2PTR(CV*,tmp);
683 } else {
684 0 my_curr_cv = NULL;
685 }
686 }
687  
688 0 ▶ if ( old_cv ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( old_cv ) { 0 0 0
689 0 ST(0) = sv_newmortal();
690 0 sv_setiv(newSVrv(ST(0), "B::CV"), PTR2IV(old_cv));
691 } else {
692 0 ST(0) = &PL_sv_undef;
693 }
694  
695 #define OP_desc(o) (char* const)PL_op_desc[o->op_type]
696  
697 MODULE = B::Generate PACKAGE = B::OP PREFIX = OP_
698  
699 # coverage: basic.t
700 B::CV
701 OP_find_cv(o)
702 B::OP o
703 CODE:
704 3 RETVAL = (CV*)SvRV(find_cv_by_root((OP*)o));
705 OUTPUT:
706 RETVAL
707  
708 # coverage ok
709 B::OP
710 OP_next(o, ...)
711 B::OP o
712 CODE:
713 2015 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 6 2009 2015
714 6 o->op_next = SVtoO(ST(1));
715 2015 RETVAL = o->op_next;
716 OUTPUT:
717 RETVAL
718  
719 # coverage ok
720 B::OP
721 OP_sibling(o, ...)
722 B::OP o
723 CODE:
724 1792 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 2 1790 1792
725 2 OpSIBLING_set(o, SVtoO(ST(1)));
726 1792 ▶ RETVAL = OpSIBLING(o);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = OpSIBLING(o); 1165 627 1792
727 OUTPUT:
728 RETVAL
729  
730 #ifdef PERL_OP_PARENT
731  
732 # XXX coverage 0
733 B::OP
734 OP_sibparent(o, ...)
735 B::OP o
736 CODE:
737 0 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 0 0 0
738 0 OpLASTSIB_set(o, SVtoO(ST(1)));
739 0 RETVAL = o->op_sibparent;
740 OUTPUT:
741 RETVAL
742  
743 #endif
744  
745 # XXX coverage 0
746 IV
747 OP_ppaddr(o, ...)
748 B::OP o
749 CODE:
750 0 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 0 0 0
751 0 o->op_ppaddr = INT2PTR(void*,SvIV(ST(1)));
752 0 ▶ RETVAL = PTR2IV((void*)(o->op_ppaddr));
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = PTR2IV((void*)(o->op_ppaddr)); 0 0 0
753 OUTPUT:
754 RETVAL
755  
756 # XXX coverage 0
757 char *
758 OP_desc(o)
759 B::OP o
760  
761 # XXX coverage 50%
762 PADOFFSET
763 OP_targ(o, ...)
764 B::OP o
765 CODE:
766 840 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 1 839 840
767 1 o->op_targ = (PADOFFSET)SvIV(ST(1));
768  
769 /* begin highly experimental */ /* XXX coverage 0 */
770 840 ▶ if (items > 1 && (SvIV(ST(1)) > 1000 || SvIV(ST(1)) & 0x80000000)) {
Branch: 3 branches
BranchTrueFalseTotal
if (items > 1 && (SvIV(ST(1)) > 1000 || SvIV(ST(1)) & 0x80000000)) { 1 839 840
if (items > 1 && (SvIV(ST(1)) > 1000 || SvIV(ST(1)) & 0x80000000)) { 1 0 1
if (items > 1 && (SvIV(ST(1)) > 1000 || SvIV(ST(1)) & 0x80000000)) { 0 1 1
771 0 PADLIST *padlist = INT2PTR(PADLIST*,SvIV(ST(1)));
772  
773 0 I32 old_padix = PL_padix;
774 0 I32 old_comppad_name_fill = PL_comppad_name_fill;
775 0 I32 old_min_intro_pending = PL_min_intro_pending;
776 0 I32 old_max_intro_pending = PL_max_intro_pending;
777 /* int old_cv_has_eval = PL_cv_has_eval; */
778 0 I32 old_pad_reset_pending = PL_pad_reset_pending;
779 0 SV **old_curpad = PL_curpad;
780 0 AV *old_comppad = PL_comppad;
781 #ifdef HAVE_PADNAMELIST
782 0 PADNAMELIST *old_comppad_name = PL_comppad_name;
783 #else
784 AV *old_comppad_name = PL_comppad_name;
785 #endif
786 /* PTR2UV */
787  
788 0 PL_comppad_name = PadlistNAMES(padlist);
789 0 PL_comppad = PadlistARRAY(padlist)[1];
790 0 PL_curpad = AvARRAY(PL_comppad);
791  
792 0 PL_padix = PadnamelistMAX(PL_comppad_name);
793 0 PL_pad_reset_pending = 0;
794 /* <medwards> PL_comppad_name_fill appears irrelevant as long as you
795 stick to pad_alloc, pad_swipe, pad_free.
796 * PL_comppad_name_fill = 0;
797 * PL_min_intro_pending = 0;
798 * PL_cv_has_eval = 0;
799 */
800 #ifdef HAVE_PAD_ALLOC
801 0 o->op_targ = Perl_pad_alloc(aTHX_ 0, SVs_PADTMP);
802 #else
803 /* CPAN #28912: MSWin32 does not export Perl_pad_alloc.
804 Rewrite from Perl_pad_alloc for PADTMP:
805 Scan the pad from PL_padix upwards for a slot which
806 has no name and no active value. */
807 {
808 SV *sv;
809 # if PERL_VERSION > 18
810 PADNAME * const * const names = PadnamelistARRAY(PL_comppad_name);
811 const SSize_t names_fill = PadnamelistMAX(PL_comppad_name);
812 for (;;) {
813 PADNAME *pn;
814 if (++PL_padix <= names_fill &&
815 (pn = names[PL_padix]) && PadnamePV(pn))
816 continue;
817 sv = *av_fetch(PL_comppad, PL_padix, TRUE);
818 if (!(SvFLAGS(sv) & SVs_PADTMP))
819 break;
820 }
821 # else
822 SV * const * const names = PadnamelistARRAY(PL_comppad_name);
823 const SSize_t names_fill = PadnamelistMAX(PL_comppad_name);
824 for (;;) {
825 if (++PL_padix <= names_fill &&
826 (sv = names[PL_padix]) && sv != &PL_sv_undef)
827 continue;
828 sv = *av_fetch(PL_comppad, PL_padix, TRUE);
829 if (!(SvFLAGS(sv) & (SVs_PADTMP | SVs_PADMY)) &&
830 !IS_PADGV(sv) && !IS_PADCONST(sv))
831 break;
832 }
833 # endif
834 o->op_targ = PL_padix;
835 SvFLAGS(sv) |= SVs_PADTMP;
836 }
837 #endif
838 0 PL_padix = old_padix;
839 0 PL_comppad_name_fill = old_comppad_name_fill;
840 0 PL_min_intro_pending = old_min_intro_pending;
841 0 PL_max_intro_pending = old_max_intro_pending;
842 /* PL_cv_has_eval = old_cv_has_eval; */
843 0 PL_pad_reset_pending = old_pad_reset_pending;
844 0 PL_curpad = old_curpad;
845 0 PL_comppad = old_comppad;
846 0 PL_comppad_name = old_comppad_name;
847 }
848 /* end highly experimental */
849  
850 840 ▶ RETVAL = o->op_targ;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = o->op_targ; 756 84 840
851 OUTPUT:
852 RETVAL
853  
854 # coverage 50%
855 U16
856 OP_type(o, ...)
857 B::OP o
858 CODE:
859 105 ▶ if (items > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) { 0 105 105
860 0 o->op_type = (U16)SvIV(ST(1)); /* XXX coverage 0 */
861 0 o->op_ppaddr = PL_ppaddr[o->op_type];
862 }
863 105 ▶ RETVAL = o->op_type;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = o->op_type; 87 18 105
864 OUTPUT:
865 RETVAL
866  
867 #if PERL_VERSION < 10
868  
869 U16
870 OP_seq(o, ...)
871 B::OP o
872 CODE:
873 if (items > 1)
874 o->op_seq = (U16)SvIV(ST(1));
875 RETVAL = o->op_seq;
876 OUTPUT:
877 RETVAL
878  
879 #endif
880  
881 # coverage ok
882 U8
883 OP_flags(o, ...)
884 B::OP o
885 CODE:
886 1299 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 0 1299 1299
887 0 o->op_flags = (U8)SvIV(ST(1));
888 1299 ▶ RETVAL = o->op_flags;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = o->op_flags; 1204 95 1299
889 OUTPUT:
890 RETVAL
891  
892 # coverage ok
893 U8
894 OP_private(o, ...)
895 B::OP o
896 CODE:
897 900 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 0 900 900
898 0 o->op_private = (U8)SvIV(ST(1));
899 900 ▶ RETVAL = o->op_private;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = o->op_private; 818 82 900
900 OUTPUT:
901 RETVAL
902  
903 # XXX coverage 0
904 void
905 OP_dump(o)
906 B::OP o
907 CODE:
908 0 op_dump(o);
909  
910 # XXX coverage 0
911 void
912 OP_clean(o)
913 B::OP o
914 CODE:
915 0 ▶ if (o == PL_main_root)
Branch: 1 branch
BranchTrueFalseTotal
if (o == PL_main_root) 0 0 0
916 0 o->op_next = Nullop;
917  
918 # XXX coverage 0
919 void
920 OP_new(class, type, flags)
921 SV * class
922 SV * type
923 I32 flags
924 OP *o = NO_INIT
925 I32 typenum = NO_INIT
926 CODE:
927 0 ▶ SAVE_VARS;
Branch: 1 branch
BranchTrueFalseTotal
SAVE_VARS; 0 0 0
928 0 typenum = op_name_to_num(type);
929 0 o = newOP(typenum, flags);
930 0 ▶ CHECK_CUSTOM_OPS
Branch: 1 branch
BranchTrueFalseTotal
CHECK_CUSTOM_OPS 0 0 0
931 0 RESTORE_VARS;
932 0 ST(0) = sv_newmortal();
933 0 sv_setiv(newSVrv(ST(0), "B::OP"), PTR2IV(o));
934  
935 # XXX coverage 0
936 void
937 OP_newstate(class, flags, label, oldo)
938 SV * class
939 I32 flags
940 char * label
941 B::OP oldo
942 OP *o = NO_INIT
943 CODE:
944 0 ▶ SAVE_VARS;
Branch: 1 branch
BranchTrueFalseTotal
SAVE_VARS; 0 0 0
945 0 o = newSTATEOP(flags, label, oldo);
946 0 RESTORE_VARS;
947 0 ST(0) = sv_newmortal();
948 0 sv_setiv(newSVrv(ST(0), "B::LISTOP"), PTR2IV(o));
949  
950 # XXX coverage 0
951 B::OP
952 OP_mutate(o, type)
953 B::OP o
954 SV* type
955 I32 rtype = NO_INIT
956 CODE:
957 0 rtype = op_name_to_num(type);
958 0 o->op_ppaddr = PL_ppaddr[rtype];
959 0 o->op_type = rtype;
960 OUTPUT:
961 o
962  
963 # Introduced with change 34924, git change b7783a124ff
964 # This works now only on non-MSWin32/AIX platforms and without PERL_DL_NONLAZY=1,
965 # checked by DISABLE_PERL_CORE_EXPORTED
966 # If you use such a platform, you have to fold the constants by yourself.
967  
968 #if defined(HAVE_FOLD_CONSTANTS) && (PERL_VERSION >= 11)
969 # define Perl_fold_constants S_fold_constants
970 #endif
971  
972 # XXX coverage 0, added with 0.07
973 B::OP
974 OP_convert(o, type, flags)
975 B::OP o
976 I32 flags
977 I32 type
978 CODE:
979 0 ▶ if (!o || o->op_type != OP_LIST)
Branch: 2 branches
BranchTrueFalseTotal
if (!o || o->op_type != OP_LIST) 0 0 0
if (!o || o->op_type != OP_LIST) 0 0 0
980 0 o = newLISTOP(OP_LIST, 0, o, Nullop);
981 else
982 0 o->op_flags &= ~OPf_WANT;
983  
984 0 ▶ if (!(PL_opargs[type] & OA_MARK) && o->op_type != OP_NULL) {
Branch: 2 branches
BranchTrueFalseTotal
if (!(PL_opargs[type] & OA_MARK) && o->op_type != OP_NULL) { 0 0 0
if (!(PL_opargs[type] & OA_MARK) && o->op_type != OP_NULL) { 0 0 0
985 0 op_clear(o);
986 0 o->op_targ = o->op_type;
987 }
988  
989 0 o->op_type = type;
990 0 o->op_ppaddr = PL_ppaddr[type];
991 0 o->op_flags |= flags;
992  
993 0 o = PL_check[type](aTHX_ (OP*)o);
994 #ifdef HAVE_FOLD_CONSTANTS
995 if (o->op_type == type) {
996 COP *cop = PL_curcop;
997 PL_curcop = &PL_compiling;
998 o = Perl_fold_constants(aTHX_ o);
999 PL_curcop = cop;
1000 }
1001 #endif
1002  
1003 OUTPUT:
1004 o
1005  
1006 MODULE = B::Generate PACKAGE = B::UNOP PREFIX = UNOP_
1007  
1008 # coverage 50%
1009 B::OP
1010 UNOP_first(o, ...)
1011 B::UNOP o
1012 CODE:
1013 10303 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 0 10303 10303
1014 0 o->op_first = SVtoO(ST(1)); /* XXX coverage 0 */
1015 10303 RETVAL = o->op_first;
1016 OUTPUT:
1017 RETVAL
1018  
1019 # XXX coverage 0
1020 void
1021 UNOP_new(class, type, flags, sv_first)
1022 SV * class
1023 SV * type
1024 I32 flags
1025 SV * sv_first
1026 OP *first = NO_INIT
1027 OP *o = NO_INIT
1028 I32 typenum = NO_INIT
1029 CODE:
1030 2 I32 padflag = 0;
1031 2 ▶ if (SvROK(sv_first)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv_first)) { 2 0 2
1032 2 ▶ if (!sv_derived_from(sv_first, "B::OP"))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(sv_first, "B::OP")) 0 2 2
1033 0 croak("Reference 'first' was not a B::OP object");
1034 else {
1035 2 IV tmp = SvIV((SV*)SvRV(sv_first));
1036 2 first = INT2PTR(OP*, tmp);
1037 }
1038 0 ▶ } else if (SvTRUE(sv_first))
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvTRUE(sv_first)) 0 0 0
1039 0 croak("'first' argument to B::UNOP->new should be a B::OP object or a false value");
1040 else
1041 0 first = Nullop;
1042 {
1043  
1044 2 ▶ SAVE_VARS;
Branch: 1 branch
BranchTrueFalseTotal
SAVE_VARS; 0 2 2
1045 2 typenum = op_name_to_num(type);
1046 {
1047 2 COP *cop = PL_curcop;
1048 2 PL_curcop = &PL_compiling;
1049 2 o = newUNOP(typenum, flags, first);
1050 2 PL_curcop = cop;
1051 }
1052 2 ▶ CHECK_CUSTOM_OPS
Branch: 1 branch
BranchTrueFalseTotal
CHECK_CUSTOM_OPS 0 2 2
1053 2 RESTORE_VARS;
1054 }
1055 2 ST(0) = sv_newmortal();
1056 2 sv_setiv(newSVrv(ST(0), "B::UNOP"), PTR2IV(o));
1057  
1058 MODULE = B::Generate PACKAGE = B::BINOP PREFIX = BINOP_
1059  
1060 # XXX coverage 0
1061 void
1062 BINOP_null(o)
1063 B::BINOP o
1064 CODE:
1065 0 op_null((OP*)o);
1066  
1067 # coverage 50%
1068 B::OP
1069 BINOP_last(o,...)
1070 B::BINOP o
1071 CODE:
1072 144 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 0 144 144
1073 0 o->op_last = SVtoO(ST(1)); /* XXX coverage 0 */
1074 144 RETVAL = o->op_last;
1075 OUTPUT:
1076 RETVAL
1077  
1078 # coverage 50%
1079 void
1080 BINOP_new(class, type, flags, sv_first, sv_last)
1081 SV * class
1082 SV * type
1083 I32 flags
1084 SV * sv_first
1085 SV * sv_last
1086 OP *first = NO_INIT
1087 OP *last = NO_INIT
1088 OP *o = NO_INIT
1089 CODE:
1090 2 ▶ if (SvROK(sv_first)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv_first)) { 1 1 2
1091 1 ▶ if (!sv_derived_from(sv_first, "B::OP"))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(sv_first, "B::OP")) 0 1 1
1092 0 croak("Reference 'first' was not a B::OP object");
1093 else {
1094 1 IV tmp = SvIV((SV*)SvRV(sv_first));
1095 1 first = INT2PTR(OP*, tmp);
1096 }
1097 1 ▶ } else if (SvTRUE(sv_first))
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvTRUE(sv_first)) 0 1 1
1098 0 croak("'first' argument to B::UNOP->new should be a B::OP object or a false value");
1099 else
1100 1 first = Nullop;
1101  
1102 2 ▶ if (SvROK(sv_last)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv_last)) { 1 1 2
1103 1 ▶ if (!sv_derived_from(sv_last, "B::OP"))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(sv_last, "B::OP")) 0 1 1
1104 0 croak("Reference 'last' was not a B::OP object");
1105 else {
1106 1 IV tmp = SvIV((SV*)SvRV(sv_last));
1107 1 last = INT2PTR(OP*, tmp);
1108 }
1109 1 ▶ } else if (SvTRUE(sv_last))
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvTRUE(sv_last)) 0 1 1
1110 0 croak("'last' argument to B::BINOP->new should be a B::OP object or a false value");
1111 else
1112 1 last = Nullop;
1113  
1114 {
1115 2 I32 typenum = op_name_to_num(type);
1116  
1117 2 ▶ SAVE_VARS;
Branch: 1 branch
BranchTrueFalseTotal
SAVE_VARS; 0 2 2
1118  
1119 2 ▶ if (typenum == OP_SASSIGN || typenum == OP_AASSIGN)
Branch: 2 branches
BranchTrueFalseTotal
if (typenum == OP_SASSIGN || typenum == OP_AASSIGN) 2 0 2
if (typenum == OP_SASSIGN || typenum == OP_AASSIGN) 0 2 2
1120 0 o = newASSIGNOP(flags, first, 0, last);
1121 else {
1122 2 COP *cop = PL_curcop;
1123 2 PL_curcop = &PL_compiling;
1124 2 o = newBINOP(typenum, flags, first, last);
1125 2 PL_curcop = cop;
1126 2 ▶ CHECK_CUSTOM_OPS
Branch: 1 branch
BranchTrueFalseTotal
CHECK_CUSTOM_OPS 0 2 2
1127 }
1128  
1129 2 RESTORE_VARS;
1130 }
1131 2 ST(0) = sv_newmortal();
1132 2 sv_setiv(newSVrv(ST(0), "B::BINOP"), PTR2IV(o));
1133  
1134 MODULE = B::Generate PACKAGE = B::LISTOP PREFIX = LISTOP_
1135  
1136 # coverage scope.t
1137 void
1138 LISTOP_new(class, type, flags, sv_first, sv_last)
1139 SV * class
1140 SV * type
1141 I32 flags
1142 SV * sv_first
1143 SV * sv_last
1144 OP *first = NO_INIT
1145 OP *last = NO_INIT
1146 OP *o = NO_INIT
1147 CODE:
1148 1 ▶ if (SvROK(sv_first)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv_first)) { 1 0 1
1149 1 ▶ if (!sv_derived_from(sv_first, "B::OP"))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(sv_first, "B::OP")) 0 1 1
1150 0 croak("Reference 'first' was not a B::OP object");
1151 else {
1152 1 IV tmp = SvIV((SV*)SvRV(sv_first));
1153 1 first = INT2PTR(OP*, tmp);
1154 }
1155 0 ▶ } else if (SvTRUE(sv_first))
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvTRUE(sv_first)) 0 0 0
1156 0 croak("'first' argument to B::UNOP->new should be a B::OP object or a false value");
1157 else
1158 0 first = Nullop;
1159  
1160 1 ▶ if (SvROK(sv_last)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv_last)) { 0 1 1
1161 0 ▶ if (!sv_derived_from(sv_last, "B::OP"))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(sv_last, "B::OP")) 0 0 0
1162 0 croak("Reference 'last' was not a B::OP object");
1163 else {
1164 0 IV tmp = SvIV((SV*)SvRV(sv_last));
1165 0 last = INT2PTR(OP*, tmp);
1166 }
1167 1 ▶ } else if (SvTRUE(sv_last))
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvTRUE(sv_last)) 0 1 1
1168 0 croak("'last' argument to B::BINOP->new should be a B::OP object or a false value");
1169 else
1170 1 last = Nullop;
1171  
1172 {
1173 1 I32 typenum = op_name_to_num(type);
1174  
1175 1 ▶ SAVE_VARS;
Branch: 1 branch
BranchTrueFalseTotal
SAVE_VARS; 0 1 1
1176 1 o = newLISTOP(typenum, flags, first, last);
1177 1 ▶ CHECK_CUSTOM_OPS
Branch: 1 branch
BranchTrueFalseTotal
CHECK_CUSTOM_OPS 0 1 1
1178 1 RESTORE_VARS;
1179 }
1180 1 ST(0) = sv_newmortal();
1181 1 sv_setiv(newSVrv(ST(0), "B::LISTOP"), PTR2IV(o));
1182  
1183 MODULE = B::Generate PACKAGE = B::LOGOP PREFIX = LOGOP_
1184  
1185 # XXX coverage 0
1186 void
1187 LOGOP_new(class, type, flags, sv_first, sv_last)
1188 SV * class
1189 SV * type
1190 I32 flags
1191 SV * sv_first
1192 SV * sv_last
1193 OP *first = NO_INIT
1194 OP *last = NO_INIT
1195 OP *o = NO_INIT
1196 CODE:
1197 0 ▶ if (SvROK(sv_first)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv_first)) { 0 0 0
1198 0 ▶ if (!sv_derived_from(sv_first, "B::OP"))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(sv_first, "B::OP")) 0 0 0
1199 0 croak("Reference 'first' was not a B::OP object");
1200 else {
1201 0 IV tmp = SvIV((SV*)SvRV(sv_first));
1202 0 first = INT2PTR(OP*, tmp);
1203 }
1204 0 ▶ } else if (SvTRUE(sv_first))
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvTRUE(sv_first)) 0 0 0
1205 0 croak("'first' argument to B::UNOP->new should be a B::OP object or a false value");
1206 else
1207 0 first = Nullop;
1208  
1209 0 ▶ if (SvROK(sv_last)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv_last)) { 0 0 0
1210 0 ▶ if (!sv_derived_from(sv_last, "B::OP"))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(sv_last, "B::OP")) 0 0 0
1211 0 croak("Reference 'last' was not a B::OP object");
1212 else {
1213 0 IV tmp = SvIV((SV*)SvRV(sv_last));
1214 0 last = INT2PTR(OP*, tmp);
1215 }
1216 0 ▶ } else if (SvTRUE(sv_last))
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvTRUE(sv_last)) 0 0 0
1217 0 croak("'last' argument to B::BINOP->new should be a B::OP object or a false value");
1218 else
1219 0 last = Nullop;
1220  
1221 {
1222 0 I32 typenum = op_name_to_num(type);
1223 0 ▶ SAVE_VARS;
Branch: 1 branch
BranchTrueFalseTotal
SAVE_VARS; 0 0 0
1224 0 o = newLOGOP(typenum, flags, first, last);
1225 0 ▶ CHECK_CUSTOM_OPS
Branch: 1 branch
BranchTrueFalseTotal
CHECK_CUSTOM_OPS 0 0 0
1226 0 RESTORE_VARS;
1227 }
1228 0 ST(0) = sv_newmortal();
1229 0 sv_setiv(newSVrv(ST(0), "B::LOGOP"), PTR2IV(o));
1230  
1231 # XXX coverage 0
1232 void
1233 LOGOP_newcond(class, flags, sv_first, sv_last, sv_else)
1234 SV * class
1235 I32 flags
1236 SV * sv_first
1237 SV * sv_last
1238 SV * sv_else
1239 OP *first = NO_INIT
1240 OP *last = NO_INIT
1241 OP *elseo = NO_INIT
1242 OP *o = NO_INIT
1243 CODE:
1244 0 ▶ if (SvROK(sv_first)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv_first)) { 0 0 0
1245 0 ▶ if (!sv_derived_from(sv_first, "B::OP"))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(sv_first, "B::OP")) 0 0 0
1246 0 croak("Reference 'first' was not a B::OP object");
1247 else {
1248 0 IV tmp = SvIV((SV*)SvRV(sv_first));
1249 0 first = INT2PTR(OP*, tmp);
1250 }
1251 0 ▶ } else if (SvTRUE(sv_first))
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvTRUE(sv_first)) 0 0 0
1252 0 croak("'first' argument to B::UNOP->new should be a B::OP object or a false value");
1253 else
1254 0 first = Nullop;
1255  
1256 0 ▶ if (SvROK(sv_last)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv_last)) { 0 0 0
1257 0 ▶ if (!sv_derived_from(sv_last, "B::OP"))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(sv_last, "B::OP")) 0 0 0
1258 0 croak("Reference 'last' was not a B::OP object");
1259 else {
1260 0 IV tmp = SvIV((SV*)SvRV(sv_last));
1261 0 last = INT2PTR(OP*, tmp);
1262 }
1263 0 ▶ } else if (SvTRUE(sv_last))
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvTRUE(sv_last)) 0 0 0
1264 0 croak("'last' argument to B::BINOP->new should be a B::OP object or a false value");
1265 else
1266 0 last = Nullop;
1267  
1268 0 ▶ if (SvROK(sv_else)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv_else)) { 0 0 0
1269 0 ▶ if (!sv_derived_from(sv_else, "B::OP"))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(sv_else, "B::OP")) 0 0 0
1270 0 croak("Reference 'else' was not a B::OP object");
1271 else {
1272 0 IV tmp = SvIV((SV*)SvRV(sv_else));
1273 0 elseo = INT2PTR(OP*, tmp);
1274 }
1275 0 ▶ } else if (SvTRUE(sv_else))
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvTRUE(sv_else)) 0 0 0
1276 0 croak("'last' argument to B::BINOP->new should be a B::OP object or a false value");
1277 else
1278 0 elseo = Nullop;
1279  
1280 {
1281 0 ▶ SAVE_VARS;
Branch: 1 branch
BranchTrueFalseTotal
SAVE_VARS; 0 0 0
1282 0 o = newCONDOP(flags, first, last, elseo);
1283 0 RESTORE_VARS;
1284 }
1285 0 ST(0) = sv_newmortal();
1286 0 sv_setiv(newSVrv(ST(0), "B::LOGOP"), PTR2IV(o));
1287  
1288 # coverage 50%
1289 B::OP
1290 LOGOP_other(o,...)
1291 B::LOGOP o
1292 CODE:
1293 0 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 0 0 0
1294 0 o->op_other = SVtoO(ST(1));
1295 0 RETVAL = o->op_other;
1296 OUTPUT:
1297 RETVAL
1298  
1299 #if PERL_VERSION < 10
1300  
1301 #define PMOP_pmreplroot(o) o->op_pmreplroot
1302 #define PMOP_pmnext(o) o->op_pmnext
1303 #define PMOP_pmpermflags(o) o->op_pmpermflags
1304  
1305 #endif
1306  
1307 #define PMOP_pmregexp(o) o->op_pmregexp
1308 #define PMOP_pmflags(o) o->op_pmflags
1309  
1310 MODULE = B::Generate PACKAGE = B::PMOP PREFIX = PMOP_
1311  
1312 #if PERL_VERSION < 10
1313  
1314 void
1315 PMOP_pmreplroot(o)
1316 B::PMOP o
1317 OP * root = NO_INIT
1318 CODE:
1319 ST(0) = sv_newmortal();
1320 root = o->op_pmreplroot;
1321 /* OP_PUSHRE stores an SV* instead of an OP* in op_pmreplroot */
1322 if (o->op_type == OP_PUSHRE) {
1323 sv_setiv(newSVrv(ST(0), root ?
1324 svclassnames[SvTYPE((SV*)root)] : "B::SV"),
1325 PTR2IV(root));
1326 }
1327 else {
1328 sv_setiv(newSVrv(ST(0), cc_opclassname(aTHX_ root)), PTR2IV(root));
1329 }
1330  
1331 B::OP
1332 PMOP_pmreplstart(o, ...)
1333 B::PMOP o
1334 CODE:
1335 if (items > 1)
1336 o->op_pmreplstart = SVtoO(ST(1));
1337 RETVAL = o->op_pmreplstart;
1338 OUTPUT:
1339 RETVAL
1340  
1341 B::PMOP
1342 PMOP_pmnext(o, ...)
1343 B::PMOP o
1344 CODE:
1345 if (items > 1)
1346 o->op_pmnext = (PMOP*)SVtoO(ST(1));
1347 RETVAL = o->op_pmnext;
1348 OUTPUT:
1349 RETVAL
1350  
1351 U16
1352 PMOP_pmpermflags(o)
1353 B::PMOP o
1354  
1355 #endif
1356  
1357 U16
1358 PMOP_pmflags(o)
1359 B::PMOP o
1360  
1361 #if PERL_VERSION < 11
1362  
1363 void
1364 PMOP_precomp(o)
1365 B::PMOP o
1366 REGEXP * rx = NO_INIT
1367 CODE:
1368 ST(0) = sv_newmortal();
1369 rx = PM_GETRE(o);
1370 if (rx)
1371 sv_setpvn(ST(0), rx->precomp, rx->prelen);
1372  
1373 #endif
1374  
1375 #define SVOP_sv(o) (cSVOPo_sv)
1376 #define SVOP_gv(o) ((GV*)cSVOPo_sv)
1377  
1378 MODULE = B::Generate PACKAGE = B::SVOP PREFIX = SVOP_
1379  
1380 # coverage 50%
1381 # SVOP::sv(o, sv, cvref)
1382 # not-threaded ignore optional 2nd cvref arg.
1383 # threaded only allow my variables, not TMP nor OUR.
1384 # XXX [CPAN #70398] B::SVOP->sv broken by B::Generate.
1385 # bad sideeffect polluting Concise.
1386 B::SV
1387 SVOP_sv(o, ...)
1388 B::SVOP o
1389 PREINIT:
1390 SV *sv;
1391 CODE:
1392 164 ▶ if (items > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) { 3 161 164
1393 #ifdef USE_ITHREADS
1394 if (items > 2) {
1395 if (!(SvROK(ST(2)) && SvTYPE(SvRV(ST(2))) == SVt_PVCV))
1396 croak("2nd arg is not a cvref");
1397 GEN_PAD_CV(ST(2));
1398 } else {
1399 GEN_PAD;
1400 }
1401 #endif
1402 3 sv = newSVsv(ST(1));
1403 #ifdef USE_ITHREADS
1404 if ( cSVOPx(o)->op_sv ) {
1405 cSVOPx(o)->op_sv = sv; /* XXX coverage 0 */
1406 }
1407 else {
1408 /* assert(SvTYPE(sv) & SVs_PADMY); */
1409 PAD_SVl(o->op_targ) = sv;
1410 }
1411 #else
1412 3 cSVOPx(o)->op_sv = sv;
1413 #endif
1414 #ifdef USE_ITHREADS
1415 OLD_PAD;
1416 #endif
1417 }
1418 /* [CPAN #70398] cSVOPo_sv => cSVOPx(o)->op_sv */
1419 164 RETVAL = cSVOPx(o)->op_sv;
1420 OUTPUT:
1421 RETVAL
1422  
1423 # XXX coverage 0
1424 B::GV
1425 SVOP_gv(o)
1426 B::SVOP o
1427  
1428 # coverage 50% const.t
1429 # uses the additional args type, flags, sv from the embedding function
1430 #define NEW_SVOP(_newOPgen, B_class) \
1431 { \
1432 OP *o; \
1433 SV* param; \
1434 I32 typenum; \
1435 SAVE_VARS; \
1436 typenum = op_name_to_num(type); /* XXX More classes here! */ \
1437 if (typenum == OP_GVSV) { \
1438 if (*(SvPV_nolen(sv)) == '$') \
1439 param = (SV*)gv_fetchpv(SvPVX(sv)+1, TRUE, SVt_PV); \
1440 else \
1441 croak("First character to GVSV was not dollar"); \
1442 } else \
1443 param = newSVsv(sv); \
1444 o = _newOPgen(typenum, flags, param); \
1445 CHECK_CUSTOM_OPS \
1446 RESTORE_VARS; \
1447 ST(0) = sv_newmortal(); \
1448 sv_setiv(newSVrv(ST(0), B_class), PTR2IV(o)); \
1449 }
1450  
1451  
1452 # XXX coverage 0
1453 SV*
1454 SVOP_new_svrv(class, type, flags, sv)
1455 SV * class
1456 SV * type
1457 I32 flags
1458 SV * sv
1459 CODE:
1460 0 ST(0) = __svop_new(aTHX_ class, type, flags, SvRV(sv));
1461  
1462  
1463 # coverage 100% const.t
1464 # class: ignored. B::SVOP forced
1465 # Note: This is the NEW_SVOP macro expanded for debugging
1466 OP*
1467 SVOP_new(class, type, flags, sv)
1468 SV * class
1469 SV * type
1470 I32 flags
1471 SV * sv
1472 CODE:
1473 OP *o;
1474 SV* param;
1475 I32 typenum;
1476 1 ▶ SAVE_VARS;
Branch: 1 branch
BranchTrueFalseTotal
SAVE_VARS; 0 1 1
1477 1 typenum = op_name_to_num(type); /* XXX More classes here! */
1478 1 ▶ if (typenum == OP_GVSV) {
Branch: 1 branch
BranchTrueFalseTotal
if (typenum == OP_GVSV) { 0 1 1
1479 0 ▶ if (*(SvPV_nolen(sv)) == '$')
Branch: 1 branch
BranchTrueFalseTotal
if (*(SvPV_nolen(sv)) == '$') 0 0 0
1480 0 param = (SV*)gv_fetchpv(SvPVX(sv)+1, TRUE, SVt_PV);
1481 else
1482 0 croak("First character to GVSV was not dollar");
1483 } else
1484 1 param = newSVsv(sv);
1485 1 o = newSVOP(typenum, flags, param);
1486 1 ▶ CHECK_CUSTOM_OPS
Branch: 1 branch
BranchTrueFalseTotal
CHECK_CUSTOM_OPS 0 1 1
1487 1 RESTORE_VARS;
1488 1 ST(0) = sv_newmortal();
1489 1 sv_setiv(newSVrv(ST(0), "B::SVOP"), PTR2IV(o));
1490  
1491  
1492 #define PADOP_padix(o) o->op_padix
1493 #define PADOP_sv(o) (o->op_padix ? PL_curpad[o->op_padix] : Nullsv)
1494 #define PADOP_gv(o) ((o->op_padix \
1495 && SvTYPE(PL_curpad[o->op_padix]) == SVt_PVGV) \
1496 ? (GV*)PL_curpad[o->op_padix] : Nullgv)
1497  
1498 MODULE = B::Generate PACKAGE = B::GVOP PREFIX = GVOP_
1499  
1500 # XXX coverage 0
1501 SV *
1502 GVOP_new(class, type, flags, sv)
1503 SV * class
1504 SV * type
1505 I32 flags
1506 SV * sv
1507 CODE:
1508 #ifdef USE_ITHREADS
1509 NEW_SVOP(newPADOP, "B::PADOP");
1510 #else
1511 0 ▶ NEW_SVOP(newSVOP, "B::SVOP");
Branch: 4 branches
BranchTrueFalseTotal
NEW_SVOP(newSVOP, "B::SVOP"); 0 0 0
NEW_SVOP(newSVOP, "B::SVOP"); 0 0 0
NEW_SVOP(newSVOP, "B::SVOP"); 0 0 0
NEW_SVOP(newSVOP, "B::SVOP"); 0 0 0
1512 #endif
1513  
1514 MODULE = B::Generate PACKAGE = B::PADOP PREFIX = PADOP_
1515  
1516 PADOFFSET
1517 PADOP_padix(o, ...)
1518 B::PADOP o
1519 CODE:
1520 0 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 0 0 0
1521 0 o->op_padix = (PADOFFSET)SvIV(ST(1));
1522 0 ▶ RETVAL = o->op_padix;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = o->op_padix; 0 0 0
1523 OUTPUT:
1524 RETVAL
1525  
1526 B::SV
1527 PADOP_sv(o, ...)
1528 B::PADOP o
1529  
1530 B::GV
1531 PADOP_gv(o)
1532 B::PADOP o
1533  
1534 MODULE = B::Generate PACKAGE = B::PVOP PREFIX = PVOP_
1535  
1536 void
1537 PVOP_pv(o)
1538 B::PVOP o
1539 CODE:
1540 /*
1541 * OP_TRANS uses op_pv to point to a table of 256 shorts
1542 * whereas other PVOPs point to a null terminated string.
1543 */
1544 0 ▶ ST(0) = sv_2mortal(newSVpv(o->op_pv, (o->op_type == OP_TRANS) ?
Branch: 1 branch
BranchTrueFalseTotal
ST(0) = sv_2mortal(newSVpv(o->op_pv, (o->op_type == OP_TRANS) ? 0 0 0
1545 256 * sizeof(short) : 0));
1546  
1547 MODULE = B::Generate PACKAGE = B::LOOP PREFIX = LOOP_
1548  
1549 B::OP
1550 LOOP_redoop(o, ...)
1551 B::LOOP o
1552 CODE:
1553 0 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 0 0 0
1554 0 o->op_redoop = SVtoO(ST(1));
1555 0 RETVAL = o->op_redoop;
1556 OUTPUT:
1557 RETVAL
1558  
1559 B::OP
1560 LOOP_nextop(o, ...)
1561 B::LOOP o
1562 CODE:
1563 0 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 0 0 0
1564 0 o->op_nextop = SVtoO(ST(1));
1565 0 RETVAL = o->op_nextop;
1566 OUTPUT:
1567 RETVAL
1568  
1569 B::OP
1570 LOOP_lastop(o, ...)
1571 B::LOOP o
1572 CODE:
1573 0 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 0 0 0
1574 0 o->op_lastop = SVtoO(ST(1));
1575 0 RETVAL = o->op_lastop;
1576 OUTPUT:
1577 RETVAL
1578  
1579 #if PERL_VERSION < 11
1580 #define COP_label(o) o->cop_label
1581 #endif
1582 #define COP_stashpv(o) CopSTASHPV(o)
1583 #define COP_stash(o) CopSTASH(o)
1584 #define COP_file(o) CopFILE(o)
1585 #define COP_cop_seq(o) o->cop_seq
1586 #if PERL_VERSION < 10
1587 #define COP_arybase(o) o->cop_arybase
1588 #endif
1589 #define COP_line(o) CopLINE(o)
1590 #define COP_warnings(o) (SV*)o->cop_warnings
1591  
1592 MODULE = B::Generate PACKAGE = B::COP PREFIX = COP_
1593  
1594  
1595 #if PERL_VERSION < 11
1596  
1597 char *
1598 COP_label(o)
1599 B::COP o
1600  
1601 #endif
1602  
1603 char *
1604 COP_stashpv(o)
1605 B::COP o
1606  
1607 B::HV
1608 COP_stash(o)
1609 B::COP o
1610  
1611 char *
1612 COP_file(o)
1613 B::COP o
1614  
1615 U32
1616 COP_cop_seq(o)
1617 B::COP o
1618  
1619 #if PERL_VERSION < 10
1620  
1621 I32
1622 COP_arybase(o)
1623 B::COP o
1624  
1625 #endif
1626  
1627 U16
1628 COP_line(o)
1629 B::COP o
1630  
1631 =pod
1632  
1633 /*
1634 Disable this wrong B::COP->warnings [CPAN #70396]
1635 Use the orginal B version instead.
1636  
1637 TODO: This throws a warning that cop_warnings is (STRLEN*)
1638 while I am casting to (SV*). The typedef converts special
1639 values of (STRLEN*) into SV objects. Hope the initial pointer
1640 casting isn't a problem.
1641  
1642 New code for 5.11 is loosely based upon patch 27786 changes to
1643 B.xs, but avoids calling the static function added there.
1644 XXX: maybe de-static that function
1645 */
1646  
1647 #if PERL_VERSION < 11
1648  
1649 B::SV
1650 COP_warnings(o)
1651 B::COP o
1652  
1653 #else
1654  
1655 void
1656 COP_warnings(o)
1657 B::COP o
1658  
1659 #endif
1660  
1661 =cut
1662  
1663 =pod
1664  
1665 /*
1666  
1667 another go: with blead@33056, get another arg2 mismatch to newSVpv
1668 in this code. Turns out that COP_warnings(o) returns void now.
1669 So I hope to comment out this XS, and get B's version instead.
1670  
1671 B::SV
1672 COP_warnings(o)
1673 B::COP o
1674 CODE:
1675 RETVAL = newSVpv(o->cop_warnings, 0);
1676  
1677 #endif
1678  
1679 */
1680  
1681 =cut
1682  
1683 #ifndef CopLABEL_alloc
1684 #define CopLABEL_alloc(str) ((str)?savepv(str):NULL)
1685 #endif
1686  
1687 # XXX coverage 70%
1688 B::COP
1689 COP_new(class, flags, name, sv_first)
1690 SV * class
1691 char * name
1692 I32 flags
1693 SV * sv_first
1694 OP *first = NO_INIT
1695 OP *o = NO_INIT
1696 CODE:
1697  
1698 0 ▶ if (SvROK(sv_first)) { /* # XXX coverage o */
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv_first)) { /* # XXX coverage o */ 0 0 0
1699 0 ▶ if (!sv_derived_from(sv_first, "B::OP"))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(sv_first, "B::OP")) 0 0 0
1700 0 croak("Reference 'first' was not a B::OP object");
1701 else {
1702 0 IV tmp = SvIV((SV*)SvRV(sv_first));
1703 0 first = INT2PTR(OP*, tmp);
1704 }
1705 0 ▶ } else if (SvTRUE(sv_first))
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvTRUE(sv_first)) 0 0 0
1706 0 croak("'first' argument to B::COP->new should be a B::OP object or a false value");
1707 else
1708 0 first = Nullop;
1709  
1710 {
1711 #if PERL_VERSION >= 10
1712 0 yy_parser* saveparser = PL_parser, dummyparser;
1713 0 ▶ if ( PL_parser == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if ( PL_parser == NULL) { 0 0 0
1714 0 PL_parser = &dummyparser;
1715 0 PL_parser-> copline = NOLINE;
1716 }
1717 #endif
1718 0 ▶ SAVE_VARS;
Branch: 1 branch
BranchTrueFalseTotal
SAVE_VARS; 0 0 0
1719 0 ▶ o = newSTATEOP(flags, CopLABEL_alloc(name), first);
Branch: 1 branch
BranchTrueFalseTotal
o = newSTATEOP(flags, CopLABEL_alloc(name), first); 0 0 0
1720 0 RESTORE_VARS;
1721 #if PERL_VERSION >= 10
1722 0 PL_parser = saveparser;
1723 #endif
1724 }
1725 0 ST(0) = sv_newmortal();
1726 0 sv_setiv(newSVrv(ST(0), "B::COP"), PTR2IV(o));
1727  
1728 #if PERL_VERSION >= 22
1729  
1730 MODULE = B::Generate PACKAGE = B::UNOP_AUX PREFIX = UNOP_AUX_
1731  
1732 # TODO: support list of [type, value] pairs
1733 # coverage
1734 B::UNOP_AUX_item
1735 UNOP_AUX_aux(o, ...)
1736 B::UNOP_AUX o
1737 CODE:
1738 0 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 0 0 0
1739 0 o->op_aux = (UNOP_AUX_item*)SVtoO(ST(1));
1740 0 RETVAL = o->op_aux;
1741 OUTPUT:
1742 RETVAL
1743  
1744 # XXX coverage 0
1745 void
1746 UNOP_AUX_new(class, type, flags, sv_first, sv_aux)
1747 SV * class
1748 SV * type
1749 I32 flags
1750 SV * sv_first
1751 SV * sv_aux
1752 OP *first = NO_INIT
1753 UNOP_AUX_item *aux = NO_INIT
1754 OP *o = NO_INIT
1755 I32 typenum = NO_INIT
1756 CODE:
1757 0 I32 padflag = 0;
1758 0 ▶ if (SvROK(sv_first)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv_first)) { 0 0 0
1759 0 ▶ if (!sv_derived_from(sv_first, "B::OP"))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(sv_first, "B::OP")) 0 0 0
1760 0 croak("Reference 'first' was not a B::OP object");
1761 else {
1762 0 IV tmp = SvIV((SV*)SvRV(sv_first));
1763 0 first = INT2PTR(OP*, tmp);
1764 }
1765 0 ▶ } else if (SvTRUE(sv_first))
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvTRUE(sv_first)) 0 0 0
1766 0 croak("'first' argument to B::UNOP_AUX->new should be a B::OP object or a false value");
1767 else
1768 0 first = Nullop;
1769  
1770 0 ▶ if (SvROK(sv_aux)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(sv_aux)) { 0 0 0
1771 0 ▶ if (!sv_derived_from(sv_first, "B::PV"))
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(sv_first, "B::PV")) 0 0 0
1772 0 croak("Reference 'first' was not a B::PV object");
1773 else {
1774 0 IV tmp = SvIV((SV*)SvRV(sv_aux));
1775 0 aux = INT2PTR(UNOP_AUX_item*, tmp);
1776 }
1777 0 ▶ } else if (SvTRUE(sv_aux))
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvTRUE(sv_aux)) 0 0 0
1778 0 croak("'aux' argument to B::UNOP_AUX->new should be a B::PV object or a false value");
1779 else
1780 0 aux = NULL;
1781 {
1782  
1783 0 ▶ SAVE_VARS;
Branch: 1 branch
BranchTrueFalseTotal
SAVE_VARS; 0 0 0
1784 0 typenum = op_name_to_num(type);
1785 {
1786 0 COP *cop = PL_curcop;
1787 0 PL_curcop = &PL_compiling;
1788 0 o = newUNOP_AUX(typenum, flags, first, aux);
1789 0 PL_curcop = cop;
1790 }
1791 0 ▶ CHECK_CUSTOM_OPS
Branch: 1 branch
BranchTrueFalseTotal
CHECK_CUSTOM_OPS 0 0 0
1792 0 RESTORE_VARS;
1793 }
1794 0 ST(0) = sv_newmortal();
1795 0 sv_setiv(newSVrv(ST(0), "B::UNOP_AUX"), PTR2IV(o));
1796  
1797 MODULE = B::Generate PACKAGE = B::METHOP PREFIX = METHOP_
1798  
1799 # coverage
1800 B::HV
1801 METHOP_rclass(o, ...)
1802 B::METHOP o
1803 SV *sv = NO_INIT
1804 CODE:
1805 0 ▶ if (items > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) { 0 0 0
1806 #ifdef USE_ITHREADS
1807 int i;
1808 #endif
1809 0 sv = (SV*)SVtoO(ST(1));
1810 0 ▶ if (sv &&
Branch: 1 branch
BranchTrueFalseTotal
if (sv && 0 0 0
1811 0 ▶ (SvTYPE(sv) != SVt_PVHV
Branch: 1 branch
BranchTrueFalseTotal
(SvTYPE(sv) != SVt_PVHV 0 0 0
1812 0 ▶ || !HvNAME(sv)))
Branch: 7 branches
BranchTrueFalseTotal
|| !HvNAME(sv))) 0 0 0
|| !HvNAME(sv))) 0 0 0
|| !HvNAME(sv))) 0 0 0
|| !HvNAME(sv))) 0 0 0
|| !HvNAME(sv))) 0 0 0
|| !HvNAME(sv))) 0 0 0
|| !HvNAME(sv))) 0 0 0
1813 0 croak("rclass argument is not a stash");
1814 #ifdef USE_ITHREADS
1815 for (i=0;i<PL_generation;i++) {
1816 if (PL_curpad[i] == sv) {
1817 o->op_rclass_targ = i;
1818 break;
1819 }
1820 }
1821 #else
1822 0 o->op_rclass_sv = sv;
1823 #endif
1824 }
1825 #ifdef USE_ITHREADS
1826 RETVAL = (HV*)PL_curpad[o->op_rclass_targ];
1827 #else
1828 0 RETVAL = (HV*)o->op_rclass_sv;
1829 #endif
1830 OUTPUT:
1831 RETVAL
1832  
1833 B::SV
1834 METHOP_meth_sv(o, ...)
1835 B::METHOP o
1836 CODE:
1837 170 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 0 170 170
1838 0 o->op_u.op_meth_sv = (SV*)SVtoO(ST(1));
1839 170 RETVAL = o->op_u.op_meth_sv;
1840 OUTPUT:
1841 RETVAL
1842  
1843 # XXX coverage 0
1844 void
1845 METHOP_new(class, type, flags, op_first)
1846 SV * class
1847 SV * type
1848 I32 flags
1849 SV * op_first
1850 OP *first = NO_INIT
1851 OP *o = NO_INIT
1852 I32 typenum = NO_INIT
1853 CODE:
1854 0 I32 padflag = 0;
1855 0 ▶ if (SvROK(op_first)) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(op_first)) { 0 0 0
1856 0 ▶ if (!sv_derived_from(op_first, "B::OP")) {
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_derived_from(op_first, "B::OP")) { 0 0 0
1857 0 ▶ if (sv_derived_from(op_first, "B::PV")) {
Branch: 1 branch
BranchTrueFalseTotal
if (sv_derived_from(op_first, "B::PV")) { 0 0 0
1858 0 IV tmp = SvIV(SvRV(op_first));
1859 0 first = INT2PTR(OP*, tmp);
1860 }
1861 0 else croak("Reference 'first' was not a B::OP or B::PV object");
1862 }
1863 else {
1864 0 IV tmp = SvIV(SvRV(op_first));
1865 0 first = INT2PTR(OP*, tmp);
1866 }
1867 0 ▶ } else if (SvTRUE(op_first))
Branch: 1 branch
BranchTrueFalseTotal
} else if (SvTRUE(op_first)) 0 0 0
1868 0 croak("'first' argument to B::METHOP->new should be a B::OP or B::PV object or a false value");
1869 else
1870 0 first = Nullop;
1871 {
1872  
1873 0 ▶ SAVE_VARS;
Branch: 1 branch
BranchTrueFalseTotal
SAVE_VARS; 0 0 0
1874 0 typenum = op_name_to_num(type);
1875 {
1876 0 COP *cop = PL_curcop;
1877 0 PL_curcop = &PL_compiling;
1878 0 o = newMETHOP(typenum, flags, first);
1879 0 PL_curcop = cop;
1880 }
1881 0 ▶ CHECK_CUSTOM_OPS
Branch: 1 branch
BranchTrueFalseTotal
CHECK_CUSTOM_OPS 0 0 0
1882 0 RESTORE_VARS;
1883 }
1884 0 ST(0) = sv_newmortal();
1885 0 sv_setiv(newSVrv(ST(0), "B::METHOP"), PTR2IV(o));
1886  
1887 #endif
1888  
1889 MODULE = B::Generate PACKAGE = B::SV PREFIX = Sv
1890  
1891 # coverage ok
1892 SV*
1893 Svsv(sv)
1894 B::SV sv
1895 CODE:
1896 3 RETVAL = newSVsv(sv);
1897 OUTPUT:
1898 RETVAL
1899  
1900 # XXX coverage 0
1901 void*
1902 Svdump(sv)
1903 B::SV sv
1904 CODE:
1905 0 sv_dump(sv);
1906  
1907 # XXX coverage 0
1908 U32
1909 SvFLAGS(sv, ...)
1910 B::SV sv
1911 CODE:
1912 68383 ▶ if (items > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) 0 68383 68383
1913 0 sv->sv_flags = SvIV(ST(1));
1914 68383 ▶ RETVAL = SvFLAGS(sv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = SvFLAGS(sv); 68282 101 68383
1915 OUTPUT:
1916 RETVAL
1917  
1918 MODULE = B::Generate PACKAGE = B::CV PREFIX = CV_
1919  
1920 # XXX coverage 0
1921 B::OP
1922 CV_ROOT(cv)
1923 B::CV cv
1924 CODE:
1925 4014 ▶ if (cv == PL_main_cv) {
Branch: 1 branch
BranchTrueFalseTotal
if (cv == PL_main_cv) { 7 4007 4014
1926 7 RETVAL = PL_main_root;
1927 } else {
1928 4007 ▶ RETVAL = CvISXSUB(cv) ? NULL : CvROOT(cv);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = CvISXSUB(cv) ? NULL : CvROOT(cv); 4007 0 4007
1929 }
1930 OUTPUT:
1931 RETVAL
1932  
1933 # XXX coverage 0
1934 B::CV
1935 CV_newsub_simple(class, name, block)
1936 SV* class
1937 SV* name
1938 B::OP block
1939 CV* mycv = NO_INIT
1940 OP* o = NO_INIT
1941  
1942 CODE:
1943 0 o = newSVOP(OP_CONST, 0, SvREFCNT_inc(name));
1944 0 mycv = newSUB(start_subparse(FALSE, 0), o, Nullop, block);
1945 /*op_free(o); */
1946 0 RETVAL = mycv;
1947 OUTPUT:
1948 RETVAL
1949  
1950 #ifdef HAVE_CV_CLONE
1951 # define PERL_CORE
1952 # include "embed.h"
1953  
1954 # XXX coverage t/new_cv.t
1955 B::CV
1956 CV_NEW_with_start(cv, root, start)
1957 B::CV cv
1958 B::OP root
1959 B::OP start
1960 PREINIT:
1961 CV *new;
1962 CODE:
1963 2 new = Perl_cv_clone(aTHX_ cv);
1964 2 CvROOT(new) = root;
1965 2 CvSTART(new) = start;
1966 2 CvDEPTH(new) = 0;
1967 #if PERL_VERSION > 9
1968 2 CvPADLIST(new) = CvPADLIST(cv);
1969 #endif
1970 2 SvREFCNT_inc(new);
1971 2 RETVAL = new;
1972 OUTPUT:
1973 RETVAL
1974  
1975 #undef PERL_CORE
1976 #endif
1977  
1978 MODULE = B::Generate PACKAGE = B::PV PREFIX = Sv
1979  
1980 # XXX coverage 0
1981 void
1982 SvPV(sv,...)
1983 B::PV sv
1984 CODE:
1985 {
1986 203 ▶ if (items > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) { 1 202 203
1987 2 sv_setpv(sv, SvPV_nolen(ST(1)));
1988 }
1989 203 ST(0) = sv_newmortal();
1990 203 ▶ if ( SvPOK(sv) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ( SvPOK(sv) ) { 203 0 203
1991 203 sv_setpvn(ST(0), SvPVX(sv), SvCUR(sv));
1992 203 SvFLAGS(ST(0)) |= SvUTF8(sv);
1993 }
1994 else {
1995 /* XXX for backward compatibility, but should fail */
1996 /* croak( "argument is not SvPOK" ); */
1997 0 sv_setpvn(ST(0), NULL, 0);
1998 }
1999 }
2000  
2001 BOOT:
2002 11 specialsv_list[0] = Nullsv;
2003 11 specialsv_list[1] = &PL_sv_undef;
2004 11 specialsv_list[2] = &PL_sv_yes;
2005 11 specialsv_list[3] = &PL_sv_no;
2006 /* These are supposed to be (STRLEN*) so I cheat. */
2007 11 specialsv_list[4] = (SV*)pWARN_ALL;
2008 11 specialsv_list[5] = (SV*)pWARN_NONE;
2009 11 specialsv_list[6] = (SV*)pWARN_STD;
« blib/lib/B/Generate.pm ↑ Summary