hax/optree-additions.c.inc

filter: Statementstmt 25.0% 4 / 16 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 18.1% 4 / 22 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« share-infix/include/XSParseInfix.h ↑ Summary lib/XS/Parse/Keyword.xs »
1 /* vi: set ft=c : */
2  
3 #define newAELEMOP(flags, first, key) S_newAELEMOP(aTHX_ flags, first, key)
4 0 static OP *S_newAELEMOP(pTHX_ U32 flags, OP *first, I32 key)
5 {
6 #if HAVE_PERL_VERSION(5,16,0)
7 0 ▶ if(key >= -128 && key < 128 && first->op_type == OP_PADAV) {
Branch: 3 branches
BranchTrueFalseTotal
if(key >= -128 && key < 128 && first->op_type == OP_PADAV) { 0 0 0
if(key >= -128 && key < 128 && first->op_type == OP_PADAV) { 0 0 0
if(key >= -128 && key < 128 && first->op_type == OP_PADAV) { 0 0 0
8 0 OP *o = newOP(OP_AELEMFAST_LEX, flags);
9 0 o->op_private = (I8)key;
10 0 o->op_targ = first->op_targ;
11 0 op_free(first);
12 0 return o;
13 }
14 #endif
15  
16 0 return newBINOP(OP_AELEM, flags, first, newSVOP(OP_CONST, 0, newSViv(key)));
17 }
18  
19 #if HAVE_PERL_VERSION(5, 22, 0)
20 # define HAVE_UNOP_AUX
21 #endif
22  
23 #ifndef HAVE_UNOP_AUX
24 typedef struct UNOP_with_IV {
25 UNOP baseop;
26 IV iv;
27 } UNOP_with_IV;
28  
29 #define newUNOP_with_IV(type, flags, first, iv) S_newUNOP_with_IV(aTHX_ type, flags, first, iv)
30 static OP *S_newUNOP_with_IV(pTHX_ I32 type, I32 flags, OP *first, IV iv)
31 {
32 /* Cargoculted from perl's op.c:Perl_newUNOP()
33 */
34 UNOP_with_IV *op = PerlMemShared_malloc(sizeof(UNOP_with_IV) * 1);
35 NewOp(1101, op, 1, UNOP_with_IV);
36  
37 if(!first)
38 first = newOP(OP_STUB, 0);
39 UNOP *unop = (UNOP *)op;
40 unop->op_type = (OPCODE)type;
41 unop->op_first = first;
42 unop->op_ppaddr = NULL;
43 unop->op_flags = (U8)flags | OPf_KIDS;
44 unop->op_private = (U8)(1 | (flags >> 8));
45  
46 op->iv = iv;
47  
48 return (OP *)op;
49 }
50 #endif
51  
52 #define newMETHOD_REDIR_OP(rclass, methname, flags) S_newMETHOD_REDIR_OP(aTHX_ rclass, methname, flags)
53 0 static OP *S_newMETHOD_REDIR_OP(pTHX_ SV *rclass, SV *methname, I32 flags)
54 {
55 #if HAVE_PERL_VERSION(5, 22, 0)
56 0 OP *op = newMETHOP_named(OP_METHOD_REDIR, flags, methname);
57 # ifdef USE_ITHREADS
58 {
59 /* cargoculted from S_op_relocate_sv() */
60 PADOFFSET ix = pad_alloc(OP_CONST, SVf_READONLY);
61 PAD_SETSV(ix, rclass);
62 cMETHOPx(op)->op_rclass_targ = ix;
63 }
64 # else
65 0 cMETHOPx(op)->op_rclass_sv = rclass;
66 # endif
67 #else
68 OP *op = newUNOP(OP_METHOD, flags,
69 newSVOP(OP_CONST, 0, newSVpvf("%" SVf "::%" SVf, rclass, methname)));
70 #endif
71  
72 0 return op;
73 }
74  
75 /* If `@_` is called "snail", then elements of it can be called "slugs"; i.e.
76 * snails without their container
77 */
78 #define newSLUGOP(idx) S_newSLUGOP(aTHX_ idx)
79 8 static OP *S_newSLUGOP(pTHX_ int idx)
80 {
81 8 OP *op = newGVOP(OP_AELEMFAST, 0, PL_defgv);
82 8 op->op_private = idx;
83 8 return op;
84 }
85  
86 #ifndef newLISTOPn
87 /* newLISTOPn was added in 5.39.3 */
88 # define newLISTOPn(type, flags, ...) S_newLISTOPn(aTHX_ type, flags, __VA_ARGS__)
89 static OP *S_newLISTOPn(pTHX_ OPCODE type, U32 flags, ...)
90 {
91 va_list args;
92 va_start(args, flags);
93  
94 OP *o = newLISTOP(OP_LIST, 0, NULL, NULL);
95  
96 OP *kid;
97 while((kid = va_arg(args, OP *)))
98 o = op_append_elem(OP_LIST, o, kid);
99  
100 va_end(args);
101  
102 return op_convert_list(type, flags, o);
103 }
104 #endif
« share-infix/include/XSParseInfix.h ↑ Summary lib/XS/Parse/Keyword.xs »