| 1 |
|
| #include "EXTERN.h" |
| 2 |
|
| #include "perl.h" |
| 3 |
|
| #include "XSUB.h" |
| 4 |
|
| #include "BUtils1.h" |
| 5 |
|
| #define NEED_sv_2pv_flags |
| 6 |
|
| #include "ppport.h" |
| 7 |
|
| |
| 8 |
|
| /* After 5.10, the CxLVAL macro was added. */ |
| 9 |
|
| #ifndef CxLVAL |
| 10 |
|
| # define CxLVAL(cx) cx->blk_sub.lval |
| 11 |
|
| #endif |
| 12 |
|
| |
| 13 |
|
| #define MY_CXT_KEY "B::Utils1::_guts" XS_VERSION |
| 14 |
|
| |
| 15 |
|
| typedef struct { |
| 16 |
|
| int x_walkoptree_debug; /* Flag for walkoptree debug hook */ |
| 17 |
|
| SV * x_specialsv_list[7]; |
| 18 |
|
| } my_cxt_t; |
| 19 |
|
| |
| 20 |
|
| START_MY_CXT |
| 21 |
|
| |
| 22 |
|
| /* Stolen from B.xs */ |
| 23 |
|
| |
| 24 |
|
| /* XXX: This really need to be properly exported by the B module, |
| 25 |
|
| possibly with custom .h retrieved by some extutil module for |
| 26 |
|
| building, and we shall be able to simply reuse the public symbol |
| 27 |
|
| from loaded module in run time. |
| 28 |
|
| |
| 29 |
|
| Beware of name clashes with CORE when loading the .so into the global namespace. |
| 30 |
|
| It fails with strict linkers, HP-UX, OpenBSD and probably on darwin without -flat-namespace. |
| 31 |
|
| "Can't make loaded symbols global on this platform while loading blib/arch/auto/B/Utils/Utils.sl |
| 32 |
|
| at /opt/perl_32/lib/5.8.8/PA-RISC1.1-thread-multi/DynaLoader.pm line 230." |
| 33 |
|
| */ |
| 34 |
|
| |
| 35 |
|
| #ifdef PERL_OBJECT |
| 36 |
|
| #undef PL_op_name |
| 37 |
|
| #undef PL_opargs |
| 38 |
|
| #undef PL_op_desc |
| 39 |
|
| #define PL_op_name (get_op_names()) |
| 40 |
|
| #define PL_opargs (get_opargs()) |
| 41 |
|
| #define PL_op_desc (get_op_descs()) |
| 42 |
|
| #endif |
| 43 |
|
| |
| 44 |
|
| /* duplicated from B.xs. */ |
| 45 |
|
| static char *BUtils1_svclassnames[] = { |
| 46 |
|
| "B::NULL", |
| 47 |
|
| #if PERL_VERSION < 19 |
| 48 |
|
| "B::BIND", |
| 49 |
|
| #endif |
| 50 |
|
| "B::IV", |
| 51 |
|
| "B::NV", |
| 52 |
|
| #if PERL_VERSION <= 10 |
| 53 |
|
| "B::RV", |
| 54 |
|
| #endif |
| 55 |
|
| "B::PV", |
| 56 |
|
| #if PERL_VERSION >= 19 |
| 57 |
|
| "B::INVLIST", |
| 58 |
|
| #endif |
| 59 |
|
| "B::PVIV", |
| 60 |
|
| "B::PVNV", |
| 61 |
|
| "B::PVMG", |
| 62 |
|
| #if PERL_VERSION >= 11 |
| 63 |
|
| "B::REGEXP", |
| 64 |
|
| #endif |
| 65 |
|
| "B::PVLV", |
| 66 |
|
| "B::AV", |
| 67 |
|
| "B::HV", |
| 68 |
|
| "B::CV", |
| 69 |
|
| "B::FM", |
| 70 |
|
| "B::IO", |
| 71 |
|
| }; |
| 72 |
|
| |
| 73 |
|
| typedef enum { |
| 74 |
|
| OPc_NULL, /* 0 */ |
| 75 |
|
| OPc_BASEOP, /* 1 */ |
| 76 |
|
| OPc_UNOP, /* 2 */ |
| 77 |
|
| OPc_BINOP, /* 3 */ |
| 78 |
|
| OPc_LOGOP, /* 4 */ |
| 79 |
|
| OPc_LISTOP, /* 5 */ |
| 80 |
|
| OPc_PMOP, /* 6 */ |
| 81 |
|
| OPc_SVOP, /* 7 */ |
| 82 |
|
| OPc_PADOP, /* 8 */ |
| 83 |
|
| OPc_PVOP, /* 9 */ |
| 84 |
|
| OPc_LOOP, /* 10 */ |
| 85 |
|
| OPc_COP, /* 11 */ |
| 86 |
|
| OPc_METHOP, /* 12 */ |
| 87 |
|
| OPc_UNOP_AUX /* 13 */ |
| 88 |
|
| } BUtils1_opclass; |
| 89 |
|
| |
| 90 |
|
| static char *BUtils1_opclassnames[] = { |
| 91 |
|
| "B::NULL", |
| 92 |
|
| "B::OP", |
| 93 |
|
| "B::UNOP", |
| 94 |
|
| "B::BINOP", |
| 95 |
|
| "B::LOGOP", |
| 96 |
|
| "B::LISTOP", |
| 97 |
|
| "B::PMOP", |
| 98 |
|
| "B::SVOP", |
| 99 |
|
| "B::PADOP", |
| 100 |
|
| "B::PVOP", |
| 101 |
|
| "B::LOOP", |
| 102 |
|
| "B::COP", |
| 103 |
|
| "B::METHOP", |
| 104 |
|
| "B::UNOP_AUX" |
| 105 |
|
| }; |
| 106 |
|
| |
| 107 |
|
| static BUtils1_opclass |
| 108 |
0 |
| BUtils1_cc_opclass(pTHX_ const OP *o) |
| 109 |
|
| { |
| 110 |
0 |
▶ | if (!o) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!o) |
0 |
0 |
0 |
|
| 111 |
0 |
| return OPc_NULL; |
| 112 |
|
| |
| 113 |
0 |
▶ | if (o->op_type == 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (o->op_type == 0) |
0 |
0 |
0 |
|
| 114 |
0 |
▶ | return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP; |
Branch: 1 branch
| Branch | True | False | Total |
| return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP; |
0 |
0 |
0 |
|
| 115 |
|
| |
| 116 |
0 |
▶ | if (o->op_type == OP_SASSIGN) |
Branch: 1 branch
| Branch | True | False | Total |
| if (o->op_type == OP_SASSIGN) |
0 |
0 |
0 |
|
| 117 |
0 |
▶ | return ((o->op_private & OPpASSIGN_BACKWARDS) ? OPc_UNOP : OPc_BINOP); |
Branch: 1 branch
| Branch | True | False | Total |
| return ((o->op_private & OPpASSIGN_BACKWARDS) ? OPc_UNOP : OPc_BINOP); |
0 |
0 |
0 |
|
| 118 |
|
| |
| 119 |
|
| #ifdef USE_ITHREADS |
| 120 |
|
| if (o->op_type == OP_GV || o->op_type == OP_GVSV || |
| 121 |
|
| o->op_type == OP_AELEMFAST || o->op_type == OP_RCATLINE) |
| 122 |
|
| return OPc_PADOP; |
| 123 |
|
| #endif |
| 124 |
|
| |
| 125 |
0 |
| switch (PL_opargs[o->op_type] & OA_CLASS_MASK) { |
| 126 |
0 |
| case OA_BASEOP: |
| 127 |
0 |
| return OPc_BASEOP; |
| 128 |
|
| |
| 129 |
0 |
| case OA_UNOP: |
| 130 |
0 |
| return OPc_UNOP; |
| 131 |
|
| |
| 132 |
0 |
| case OA_BINOP: |
| 133 |
0 |
| return OPc_BINOP; |
| 134 |
|
| |
| 135 |
0 |
| case OA_LOGOP: |
| 136 |
0 |
| return OPc_LOGOP; |
| 137 |
|
| |
| 138 |
0 |
| case OA_LISTOP: |
| 139 |
0 |
| return OPc_LISTOP; |
| 140 |
|
| |
| 141 |
0 |
| case OA_PMOP: |
| 142 |
0 |
| return OPc_PMOP; |
| 143 |
|
| |
| 144 |
0 |
| case OA_SVOP: |
| 145 |
0 |
| return OPc_SVOP; |
| 146 |
|
| |
| 147 |
0 |
| case OA_PADOP: |
| 148 |
0 |
| return OPc_PADOP; |
| 149 |
|
| |
| 150 |
0 |
| case OA_PVOP_OR_SVOP: |
| 151 |
|
| /* |
| 152 |
|
| * Character translations (tr///) are usually a PVOP, keeping a |
| 153 |
|
| * pointer to a table of shorts used to look up translations. |
| 154 |
|
| * Under utf8, however, a simple table isn't practical; instead, |
| 155 |
|
| * the OP is an SVOP, and the SV is a reference to a swash |
| 156 |
|
| * (i.e., an RV pointing to an HV). |
| 157 |
|
| */ |
| 158 |
0 |
| return (o->op_private & (OPpTRANS_TO_UTF|OPpTRANS_FROM_UTF)) |
| 159 |
0 |
▶ | ? OPc_SVOP : OPc_PVOP; |
Branch: 1 branch
| Branch | True | False | Total |
| ? OPc_SVOP : OPc_PVOP; |
0 |
0 |
0 |
|
| 160 |
|
| |
| 161 |
0 |
| case OA_LOOP: |
| 162 |
0 |
| return OPc_LOOP; |
| 163 |
|
| |
| 164 |
0 |
| case OA_COP: |
| 165 |
0 |
| return OPc_COP; |
| 166 |
|
| |
| 167 |
0 |
| case OA_BASEOP_OR_UNOP: |
| 168 |
|
| /* |
| 169 |
|
| * UNI(OP_foo) in toke.c returns token UNI or FUNC1 depending on |
| 170 |
|
| * whether parens were seen. perly.y uses OPf_SPECIAL to |
| 171 |
|
| * signal whether a BASEOP had empty parens or none. |
| 172 |
|
| * Some other UNOPs are created later, though, so the best |
| 173 |
|
| * test is OPf_KIDS, which is set in newUNOP. |
| 174 |
|
| */ |
| 175 |
0 |
▶ | return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP; |
Branch: 1 branch
| Branch | True | False | Total |
| return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP; |
0 |
0 |
0 |
|
| 176 |
|
| |
| 177 |
0 |
| case OA_FILESTATOP: |
| 178 |
|
| /* |
| 179 |
|
| * The file stat OPs are created via UNI(OP_foo) in toke.c but use |
| 180 |
|
| * the OPf_REF flag to distinguish between OP types instead of the |
| 181 |
|
| * usual OPf_SPECIAL flag. As usual, if OPf_KIDS is set, then we |
| 182 |
|
| * return OPc_UNOP so that walkoptree can find our children. If |
| 183 |
|
| * OPf_KIDS is not set then we check OPf_REF. Without OPf_REF set |
| 184 |
|
| * (no argument to the operator) it's an OP; with OPf_REF set it's |
| 185 |
|
| * an SVOP (and op_sv is the GV for the filehandle argument). |
| 186 |
|
| */ |
| 187 |
0 |
▶ | return ((o->op_flags & OPf_KIDS) ? OPc_UNOP : |
Branch: 1 branch
| Branch | True | False | Total |
| return ((o->op_flags & OPf_KIDS) ? OPc_UNOP : |
0 |
0 |
0 |
|
| 188 |
|
| #ifdef USE_ITHREADS |
| 189 |
|
| (o->op_flags & OPf_REF) ? OPc_PADOP : OPc_BASEOP); |
| 190 |
|
| #else |
| 191 |
0 |
▶ | (o->op_flags & OPf_REF) ? OPc_SVOP : OPc_BASEOP); |
Branch: 1 branch
| Branch | True | False | Total |
| (o->op_flags & OPf_REF) ? OPc_SVOP : OPc_BASEOP); |
0 |
0 |
0 |
|
| 192 |
|
| #endif |
| 193 |
0 |
| case OA_LOOPEXOP: |
| 194 |
|
| /* |
| 195 |
|
| * next, last, redo, dump and goto use OPf_SPECIAL to indicate that a |
| 196 |
|
| * label was omitted (in which case it's a BASEOP) or else a term was |
| 197 |
|
| * seen. In this last case, all except goto are definitely PVOP but |
| 198 |
|
| * goto is either a PVOP (with an ordinary constant label), an UNOP |
| 199 |
|
| * with OPf_STACKED (with a non-constant non-sub) or an UNOP for |
| 200 |
|
| * OP_REFGEN (with goto &sub) in which case OPf_STACKED also seems to |
| 201 |
|
| * get set. |
| 202 |
|
| */ |
| 203 |
0 |
▶ | if (o->op_flags & OPf_STACKED) |
Branch: 1 branch
| Branch | True | False | Total |
| if (o->op_flags & OPf_STACKED) |
0 |
0 |
0 |
|
| 204 |
0 |
| return OPc_UNOP; |
| 205 |
0 |
▶ | else if (o->op_flags & OPf_SPECIAL) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (o->op_flags & OPf_SPECIAL) |
0 |
0 |
0 |
|
| 206 |
0 |
| return OPc_BASEOP; |
| 207 |
|
| else |
| 208 |
0 |
| return OPc_PVOP; |
| 209 |
|
| } |
| 210 |
0 |
| warn("can't determine class of operator %s, assuming BASEOP\n", |
| 211 |
|
| PL_op_name[o->op_type]); |
| 212 |
0 |
| return OPc_BASEOP; |
| 213 |
|
| } |
| 214 |
|
| |
| 215 |
|
| char * |
| 216 |
0 |
| BUtils1_cc_opclassname(pTHX_ const OP *o) |
| 217 |
|
| { |
| 218 |
0 |
| return BUtils1_opclassnames[BUtils1_cc_opclass(aTHX_ o)]; |
| 219 |
|
| } |
| 220 |
|
| |
| 221 |
|
| I32 |
| 222 |
0 |
| BUtils1_op_name_to_num(SV *name) |
| 223 |
|
| { |
| 224 |
|
| dTHX; |
| 225 |
|
| char const *s; |
| 226 |
0 |
| char *wanted = SvPV_nolen(name); |
| 227 |
0 |
| int i =0; |
| 228 |
0 |
| int topop = OP_max; |
| 229 |
|
| |
| 230 |
|
| #ifdef PERL_CUSTOM_OPS |
| 231 |
|
| topop--; |
| 232 |
|
| #endif |
| 233 |
|
| |
| 234 |
0 |
▶ | if (SvIOK(name) && SvIV(name) >= 0 && SvIV(name) < topop) |
Branch: 3 branches
| Branch | True | False | Total |
| if (SvIOK(name) && SvIV(name) >= 0 && SvIV(name) < topop) |
0 |
0 |
0 |
| if (SvIOK(name) && SvIV(name) >= 0 && SvIV(name) < topop) |
0 |
0 |
0 |
| if (SvIOK(name) && SvIV(name) >= 0 && SvIV(name) < topop) |
0 |
0 |
0 |
|
| 235 |
0 |
| return SvIV(name); |
| 236 |
|
| |
| 237 |
0 |
▶ | for (s = PL_op_name[i]; s; s = PL_op_name[++i]) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (s = PL_op_name[i]; s; s = PL_op_name[++i]) { |
0 |
0 |
0 |
|
| 238 |
0 |
▶ | if (strEQ(s, wanted)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (strEQ(s, wanted)) |
0 |
0 |
0 |
|
| 239 |
0 |
| return i; |
| 240 |
|
| } |
| 241 |
|
| #ifdef PERL_CUSTOM_OPS |
| 242 |
|
| if (PL_custom_op_names) { |
| 243 |
|
| HE* ent; |
| 244 |
|
| SV* value; |
| 245 |
|
| /* This is sort of a hv_exists, backwards */ |
| 246 |
|
| (void)hv_iterinit(PL_custom_op_names); |
| 247 |
|
| while ((ent = hv_iternext(PL_custom_op_names))) { |
| 248 |
|
| if (strEQ(SvPV_nolen(hv_iterval(PL_custom_op_names,ent)),wanted)) |
| 249 |
|
| return OP_CUSTOM; |
| 250 |
|
| } |
| 251 |
|
| } |
| 252 |
|
| #endif |
| 253 |
|
| |
| 254 |
0 |
| croak("No such op \"%s\"", SvPV_nolen(name)); |
| 255 |
|
| |
| 256 |
|
| return -1; |
| 257 |
|
| } |
| 258 |
|
| |
| 259 |
|
| SV * |
| 260 |
0 |
| BUtils1_make_sv_object(pTHX_ SV *arg, SV *sv) |
| 261 |
|
| { |
| 262 |
0 |
| char *type = 0; |
| 263 |
|
| IV iv; |
| 264 |
|
| dMY_CXT; |
| 265 |
|
| |
| 266 |
0 |
▶ | if (!type) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!type) { |
0 |
0 |
0 |
|
| 267 |
0 |
| type = BUtils1_svclassnames[SvTYPE(sv)]; |
| 268 |
0 |
| iv = PTR2IV(sv); |
| 269 |
|
| } |
| 270 |
0 |
| sv_setiv(newSVrv(arg, type), iv); |
| 271 |
0 |
| return arg; |
| 272 |
|
| } |
| 273 |
|
| |
| 274 |
|
| /* Stolen from pp_ctl.c (with modifications) */ |
| 275 |
|
| |
| 276 |
|
| static I32 |
| 277 |
0 |
| BUtils1_dopoptosub_at(pTHX_ PERL_CONTEXT *cxstk, I32 startingblock) |
| 278 |
|
| { |
| 279 |
|
| dTHR; |
| 280 |
|
| I32 i; |
| 281 |
|
| PERL_CONTEXT *cx; |
| 282 |
0 |
▶ | for (i = startingblock; i >= 0; i--) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = startingblock; i >= 0; i--) { |
0 |
0 |
0 |
|
| 283 |
0 |
| cx = &cxstk[i]; |
| 284 |
0 |
▶ | switch (CxTYPE(cx)) { |
Branch: 1 branch
| Branch | True | False | Total |
| switch (CxTYPE(cx)) { |
0 |
0 |
0 |
|
| 285 |
0 |
| default: |
| 286 |
0 |
| continue; |
| 287 |
|
| /*case CXt_EVAL:*/ |
| 288 |
0 |
| case CXt_SUB: |
| 289 |
|
| /* In Perl 5.005, formats just used CXt_SUB */ |
| 290 |
|
| #ifdef CXt_FORMAT |
| 291 |
|
| case CXt_FORMAT: |
| 292 |
|
| #endif |
| 293 |
|
| DEBUG_l( Perl_deb(aTHX_ "(Found sub #%ld)\n", (long)i)); |
| 294 |
0 |
| return i; |
| 295 |
|
| } |
| 296 |
|
| } |
| 297 |
0 |
| return i; |
| 298 |
|
| } |
| 299 |
|
| |
| 300 |
|
| static I32 |
| 301 |
0 |
| BUtils1_dopoptosub(pTHX_ I32 startingblock) |
| 302 |
|
| { |
| 303 |
|
| dTHR; |
| 304 |
0 |
| return BUtils1_dopoptosub_at(aTHX_ cxstack, startingblock); |
| 305 |
|
| } |
| 306 |
|
| |
| 307 |
|
| /* This function is based on the code of pp_caller */ |
| 308 |
|
| PERL_CONTEXT* |
| 309 |
0 |
| BUtils1_op_upcontext(pTHX_ I32 count, COP **cop_p, PERL_CONTEXT **ccstack_p, |
| 310 |
|
| I32 *cxix_from_p, I32 *cxix_to_p) |
| 311 |
|
| { |
| 312 |
0 |
| PERL_SI *top_si = PL_curstackinfo; |
| 313 |
0 |
| I32 cxix = BUtils1_dopoptosub(aTHX_ cxstack_ix); |
| 314 |
0 |
| PERL_CONTEXT *ccstack = cxstack; |
| 315 |
|
| |
| 316 |
0 |
▶ | if (cxix_from_p) *cxix_from_p = cxstack_ix+1; |
Branch: 1 branch
| Branch | True | False | Total |
| if (cxix_from_p) *cxix_from_p = cxstack_ix+1; |
0 |
0 |
0 |
|
| 317 |
0 |
▶ | if (cxix_to_p) *cxix_to_p = cxix; |
Branch: 1 branch
| Branch | True | False | Total |
| if (cxix_to_p) *cxix_to_p = cxix; |
0 |
0 |
0 |
|
| 318 |
|
| for (;;) { |
| 319 |
|
| /* we may be in a higher stacklevel, so dig down deeper */ |
| 320 |
0 |
▶ | while (cxix < 0 && top_si->si_type != PERLSI_MAIN) { |
Branch: 2 branches
| Branch | True | False | Total |
| while (cxix < 0 && top_si->si_type != PERLSI_MAIN) { |
0 |
0 |
0 |
| while (cxix < 0 && top_si->si_type != PERLSI_MAIN) { |
0 |
0 |
0 |
|
| 321 |
0 |
| top_si = top_si->si_prev; |
| 322 |
0 |
| ccstack = top_si->si_cxstack; |
| 323 |
0 |
| cxix = BUtils1_dopoptosub_at(aTHX_ ccstack, top_si->si_cxix); |
| 324 |
0 |
▶ | if (cxix_to_p && cxix_from_p) *cxix_from_p = *cxix_to_p; |
Branch: 2 branches
| Branch | True | False | Total |
| if (cxix_to_p && cxix_from_p) *cxix_from_p = *cxix_to_p; |
0 |
0 |
0 |
| if (cxix_to_p && cxix_from_p) *cxix_from_p = *cxix_to_p; |
0 |
0 |
0 |
|
| 325 |
0 |
▶ | if (cxix_to_p) *cxix_to_p = cxix; |
Branch: 1 branch
| Branch | True | False | Total |
| if (cxix_to_p) *cxix_to_p = cxix; |
0 |
0 |
0 |
|
| 326 |
|
| } |
| 327 |
0 |
▶ | if (cxix < 0 && count == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (cxix < 0 && count == 0) { |
0 |
0 |
0 |
| if (cxix < 0 && count == 0) { |
0 |
0 |
0 |
|
| 328 |
0 |
▶ | if (ccstack_p) *ccstack_p = ccstack; |
Branch: 1 branch
| Branch | True | False | Total |
| if (ccstack_p) *ccstack_p = ccstack; |
0 |
0 |
0 |
|
| 329 |
0 |
| return (PERL_CONTEXT *)0; |
| 330 |
|
| } |
| 331 |
0 |
▶ | else if (cxix < 0) |
Branch: 1 branch
| Branch | True | False | Total |
| else if (cxix < 0) |
0 |
0 |
0 |
|
| 332 |
0 |
| return (PERL_CONTEXT *)-1; |
| 333 |
0 |
▶ | if (PL_DBsub && cxix >= 0 && |
Branch: 2 branches
| Branch | True | False | Total |
| if (PL_DBsub && cxix >= 0 && |
0 |
0 |
0 |
| if (PL_DBsub && cxix >= 0 && |
0 |
0 |
0 |
|
| 334 |
0 |
▶ | ccstack[cxix].blk_sub.cv == GvCV(PL_DBsub)) |
Branch: 1 branch
| Branch | True | False | Total |
| ccstack[cxix].blk_sub.cv == GvCV(PL_DBsub)) |
0 |
0 |
0 |
|
| 335 |
0 |
| count++; |
| 336 |
0 |
▶ | if (!count--) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!count--) |
0 |
0 |
0 |
|
| 337 |
0 |
| break; |
| 338 |
|
| |
| 339 |
0 |
▶ | if (cop_p) *cop_p = ccstack[cxix].blk_oldcop; |
Branch: 1 branch
| Branch | True | False | Total |
| if (cop_p) *cop_p = ccstack[cxix].blk_oldcop; |
0 |
0 |
0 |
|
| 340 |
0 |
| cxix = BUtils1_dopoptosub_at(aTHX_ ccstack, cxix - 1); |
| 341 |
0 |
▶ | if (cxix_to_p && cxix_from_p) *cxix_from_p = *cxix_to_p; |
Branch: 2 branches
| Branch | True | False | Total |
| if (cxix_to_p && cxix_from_p) *cxix_from_p = *cxix_to_p; |
0 |
0 |
0 |
| if (cxix_to_p && cxix_from_p) *cxix_from_p = *cxix_to_p; |
0 |
0 |
0 |
|
| 342 |
0 |
▶ | if (cxix_to_p) *cxix_to_p = cxix; |
Branch: 1 branch
| Branch | True | False | Total |
| if (cxix_to_p) *cxix_to_p = cxix; |
0 |
0 |
0 |
|
| 343 |
|
| } |
| 344 |
0 |
▶ | if (ccstack_p) *ccstack_p = ccstack; |
Branch: 1 branch
| Branch | True | False | Total |
| if (ccstack_p) *ccstack_p = ccstack; |
0 |
0 |
0 |
|
| 345 |
0 |
| return &ccstack[cxix]; |
| 346 |
|
| } |
| 347 |
|
| |
| 348 |
|
| /* The most popular error message */ |
| 349 |
|
| #define TOO_FAR \ |
| 350 |
|
| croak("want: Called from outside a subroutine") |
| 351 |
|
| |
| 352 |
|
| /* Between 5.9.1 and 5.9.2 the retstack was removed, and the |
| 353 |
|
| return op is now stored on the cxstack. */ |
| 354 |
|
| #define HAS_RETSTACK (\ |
| 355 |
|
| PERL_REVISION < 5 || \ |
| 356 |
|
| (PERL_REVISION == 5 && PERL_VERSION < 9) || \ |
| 357 |
|
| (PERL_REVISION == 5 && PERL_VERSION == 9 && PERL_SUBVERSION < 2) \ |
| 358 |
|
| ) |
| 359 |
|
| |
| 360 |
|
| OP* |
| 361 |
0 |
| BUtils1_find_return_op(pTHX_ I32 uplevel) |
| 362 |
|
| { |
| 363 |
0 |
| PERL_CONTEXT *cx = BUtils1_op_upcontext(aTHX_ uplevel, 0, 0, 0, 0); |
| 364 |
0 |
▶ | if (!cx) TOO_FAR; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!cx) TOO_FAR; |
0 |
0 |
0 |
|
| 365 |
|
| #if HAS_RETSTACK |
| 366 |
|
| return PL_retstack[cx->blk_oldretsp - 1]; |
| 367 |
|
| #else |
| 368 |
0 |
| return cx->blk_sub.retop; |
| 369 |
|
| #endif |
| 370 |
|
| } |
| 371 |
|
| |
| 372 |
|
| OP* |
| 373 |
0 |
| BUtils1_find_oldcop(pTHX_ I32 uplevel) |
| 374 |
|
| { |
| 375 |
0 |
| PERL_CONTEXT *cx = BUtils1_op_upcontext(aTHX_ uplevel, 0, 0, 0, 0); |
| 376 |
0 |
▶ | if (!cx) TOO_FAR; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!cx) TOO_FAR; |
0 |
0 |
0 |
|
| 377 |
0 |
| return (OP*) cx->blk_oldcop; |
| 378 |
|
| } |
| 379 |
|
| |
| 380 |
|
| MODULE = B::Utils1::OP PACKAGE = B::Utils1::OP PREFIX = BUtils1_OP_ |
| 381 |
|
| PROTOTYPES: DISABLE |
| 382 |
|
| |
| 383 |
|
| B::OP |
| 384 |
|
| parent_op(I32 uplevel) |
| 385 |
|
| CODE: |
| 386 |
0 |
| RETVAL = BUtils1_find_oldcop(aTHX_ uplevel); |
| 387 |
|
| OUTPUT: |
| 388 |
|
| RETVAL |
| 389 |
|
| |
| 390 |
|
| B::OP |
| 391 |
|
| return_op(I32 uplevel) |
| 392 |
|
| CODE: |
| 393 |
0 |
| RETVAL = BUtils1_find_return_op(aTHX_ uplevel); |
| 394 |
|
| OUTPUT: |
| 395 |
|
| RETVAL |
| 396 |
|
| |
| 397 |
|
| MODULE = B::Utils1 PACKAGE = B::Utils1 |
| 398 |
|
| PROTOTYPES: DISABLE |
| 399 |
|
| |