1 /* pp.h 2 * 3 * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 4 * 2002, 2003, 2004, 2005, 2006, 2007, 2008 by Larry Wall and others 5 * 6 * You may distribute under the terms of either the GNU General Public 7 * License or the Artistic License, as specified in the README file. 8 * 9 */ 10 11 #define PP(s) OP * Perl_##s(pTHX) 12 13 /* 14 =head1 Stack Manipulation Macros 15 16 =for apidoc AmU||SP 17 Stack pointer. This is usually handled by C<xsubpp>. See C<dSP> and 18 C<SPAGAIN>. 19 20 =for apidoc AmU||MARK 21 Stack marker variable for the XSUB. See C<dMARK>. 22 23 =for apidoc Am|void|PUSHMARK|SP 24 Opening bracket for arguments on a callback. See C<PUTBACK> and 25 L<perlcall>. 26 27 =for apidoc Ams||dSP 28 Declares a local copy of perl's stack pointer for the XSUB, available via 29 the C<SP> macro. See C<SP>. 30 31 =for apidoc ms||djSP 32 33 Declare Just C<SP>. This is actually identical to C<dSP>, and declares 34 a local copy of perl's stack pointer, available via the C<SP> macro. 35 See C<SP>. (Available for backward source code compatibility with the 36 old (Perl 5.005) thread model.) 37 38 =for apidoc Ams||dMARK 39 Declare a stack marker variable, C<mark>, for the XSUB. See C<MARK> and 40 C<dORIGMARK>. 41 42 =for apidoc Ams||dORIGMARK 43 Saves the original stack mark for the XSUB. See C<ORIGMARK>. 44 45 =for apidoc AmU||ORIGMARK 46 The original stack mark for the XSUB. See C<dORIGMARK>. 47 48 =for apidoc Ams||SPAGAIN 49 Refetch the stack pointer. Used after a callback. See L<perlcall>. 50 51 =cut */ 52 53 #undef SP /* Solaris 2.7 i386 has this in /usr/include/sys/reg.h */ 54 #define SP sp 55 #define MARK mark 56 #define TARG targ 57 58 #define PUSHMARK(p) \ 59 STMT_START { \ 60 if (++PL_markstack_ptr == PL_markstack_max) \ 61 markstack_grow(); \ 62 *PL_markstack_ptr = (I32)((p) - PL_stack_base);\ 63 } STMT_END 64 65 #define TOPMARK (*PL_markstack_ptr) 66 #define POPMARK (*PL_markstack_ptr--) 67 68 #define dSP SV **sp = PL_stack_sp 69 #define djSP dSP 70 #define dMARK register SV **mark = PL_stack_base + POPMARK 71 #define dORIGMARK const I32 origmark = (I32)(mark - PL_stack_base) 72 #define ORIGMARK (PL_stack_base + origmark) 73 74 #define SPAGAIN sp = PL_stack_sp 75 #define MSPAGAIN STMT_START { sp = PL_stack_sp; mark = ORIGMARK; } STMT_END 76 77 #define GETTARGETSTACKED targ = (PL_op->op_flags & OPf_STACKED ? POPs : PAD_SV(PL_op->op_targ)) 78 #define dTARGETSTACKED SV * GETTARGETSTACKED 79 80 #define GETTARGET targ = PAD_SV(PL_op->op_targ) 81 #define dTARGET SV * GETTARGET 82 83 #define GETATARGET targ = (PL_op->op_flags & OPf_STACKED ? sp[-1] : PAD_SV(PL_op->op_targ)) 84 #define dATARGET SV * GETATARGET 85 86 #define dTARG SV *targ 87 88 #define NORMAL PL_op->op_next 89 #define DIE Perl_die 90 91 /* 92 =for apidoc Ams||PUTBACK 93 Closing bracket for XSUB arguments. This is usually handled by C<xsubpp>. 94 See C<PUSHMARK> and L<perlcall> for other uses. 95 96 =for apidoc Amn|SV*|POPs 97 Pops an SV off the stack. 98 99 =for apidoc Amn|char*|POPp 100 Pops a string off the stack. Deprecated. New code should use POPpx. 101 102 =for apidoc Amn|char*|POPpx 103 Pops a string off the stack. 104 105 =for apidoc Amn|char*|POPpbytex 106 Pops a string off the stack which must consist of bytes i.e. characters < 256. 107 108 =for apidoc Amn|NV|POPn 109 Pops a double off the stack. 110 111 =for apidoc Amn|IV|POPi 112 Pops an integer off the stack. 113 114 =for apidoc Amn|long|POPl 115 Pops a long off the stack. 116 117 =cut 118 */ 119 120 #define PUTBACK PL_stack_sp = sp 121 #define RETURN return (PUTBACK, NORMAL) 122 #define RETURNOP(o) return (PUTBACK, o) 123 #define RETURNX(x) return (x, PUTBACK, NORMAL) 124 125 #define POPs (*sp--) 126 #define POPp (SvPVx(POPs, PL_na)) /* deprecated */ 127 #define POPpx (SvPVx_nolen(POPs)) 128 #define POPpconstx (SvPVx_nolen_const(POPs)) 129 #define POPpbytex (SvPVbytex_nolen(POPs)) 130 #define POPn (SvNVx(POPs)) 131 #define POPi ((IV)SvIVx(POPs)) 132 #define POPu ((UV)SvUVx(POPs)) 133 #define POPl ((long)SvIVx(POPs)) 134 #define POPul ((unsigned long)SvIVx(POPs)) 135 #ifdef HAS_QUAD 136 #define POPq ((Quad_t)SvIVx(POPs)) 137 #define POPuq ((Uquad_t)SvUVx(POPs)) 138 #endif 139 140 #define TOPs (*sp) 141 #define TOPm1s (*(sp-1)) 142 #define TOPp1s (*(sp+1)) 143 #define TOPp (SvPV(TOPs, PL_na)) /* deprecated */ 144 #define TOPpx (SvPV_nolen(TOPs)) 145 #define TOPn (SvNV(TOPs)) 146 #define TOPi ((IV)SvIV(TOPs)) 147 #define TOPu ((UV)SvUV(TOPs)) 148 #define TOPl ((long)SvIV(TOPs)) 149 #define TOPul ((unsigned long)SvUV(TOPs)) 150 #ifdef HAS_QUAD 151 #define TOPq ((Quad_t)SvIV(TOPs)) 152 #define TOPuq ((Uquad_t)SvUV(TOPs)) 153 #endif 154 155 /* Go to some pains in the rare event that we must extend the stack. */ 156 157 /* 158 =for apidoc Am|void|EXTEND|SP|int nitems 159 Used to extend the argument stack for an XSUB's return values. Once 160 used, guarantees that there is room for at least C<nitems> to be pushed 161 onto the stack. 162 163 =for apidoc Am|void|PUSHs|SV* sv 164 Push an SV onto the stack. The stack must have room for this element. 165 Does not handle 'set' magic. Does not use C<TARG>. See also C<PUSHmortal>, 166 C<XPUSHs> and C<XPUSHmortal>. 167 168 =for apidoc Am|void|PUSHp|char* str|STRLEN len 169 Push a string onto the stack. The stack must have room for this element. 170 The C<len> indicates the length of the string. Handles 'set' magic. Uses 171 C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to declare it. Do not 172 call multiple C<TARG>-oriented macros to return lists from XSUB's - see 173 C<mPUSHp> instead. See also C<XPUSHp> and C<mXPUSHp>. 174 175 =for apidoc Am|void|PUSHn|NV nv 176 Push a double onto the stack. The stack must have room for this element. 177 Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be 178 called to declare it. Do not call multiple C<TARG>-oriented macros to 179 return lists from XSUB's - see C<mPUSHn> instead. See also C<XPUSHn> and 180 C<mXPUSHn>. 181 182 =for apidoc Am|void|PUSHi|IV iv 183 Push an integer onto the stack. The stack must have room for this element. 184 Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be 185 called to declare it. Do not call multiple C<TARG>-oriented macros to 186 return lists from XSUB's - see C<mPUSHi> instead. See also C<XPUSHi> and 187 C<mXPUSHi>. 188 189 =for apidoc Am|void|PUSHu|UV uv 190 Push an unsigned integer onto the stack. The stack must have room for this 191 element. Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> 192 should be called to declare it. Do not call multiple C<TARG>-oriented 193 macros to return lists from XSUB's - see C<mPUSHu> instead. See also 194 C<XPUSHu> and C<mXPUSHu>. 195 196 =for apidoc Am|void|XPUSHs|SV* sv 197 Push an SV onto the stack, extending the stack if necessary. Does not 198 handle 'set' magic. Does not use C<TARG>. See also C<XPUSHmortal>, 199 C<PUSHs> and C<PUSHmortal>. 200 201 =for apidoc Am|void|XPUSHp|char* str|STRLEN len 202 Push a string onto the stack, extending the stack if necessary. The C<len> 203 indicates the length of the string. Handles 'set' magic. Uses C<TARG>, so 204 C<dTARGET> or C<dXSTARG> should be called to declare it. Do not call 205 multiple C<TARG>-oriented macros to return lists from XSUB's - see 206 C<mXPUSHp> instead. See also C<PUSHp> and C<mPUSHp>. 207 208 =for apidoc Am|void|XPUSHn|NV nv 209 Push a double onto the stack, extending the stack if necessary. Handles 210 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to 211 declare it. Do not call multiple C<TARG>-oriented macros to return lists 212 from XSUB's - see C<mXPUSHn> instead. See also C<PUSHn> and C<mPUSHn>. 213 214 =for apidoc Am|void|XPUSHi|IV iv 215 Push an integer onto the stack, extending the stack if necessary. Handles 216 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to 217 declare it. Do not call multiple C<TARG>-oriented macros to return lists 218 from XSUB's - see C<mXPUSHi> instead. See also C<PUSHi> and C<mPUSHi>. 219 220 =for apidoc Am|void|XPUSHu|UV uv 221 Push an unsigned integer onto the stack, extending the stack if necessary. 222 Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be 223 called to declare it. Do not call multiple C<TARG>-oriented macros to 224 return lists from XSUB's - see C<mXPUSHu> instead. See also C<PUSHu> and 225 C<mPUSHu>. 226 227 =for apidoc Am|void|mPUSHs|SV* sv 228 Push an SV onto the stack and mortalizes the SV. The stack must have room 229 for this element. Does not use C<TARG>. See also C<PUSHs> and C<mXPUSHs>. 230 231 =for apidoc Am|void|PUSHmortal 232 Push a new mortal SV onto the stack. The stack must have room for this 233 element. Does not use C<TARG>. See also C<PUSHs>, C<XPUSHmortal> and C<XPUSHs>. 234 235 =for apidoc Am|void|mPUSHp|char* str|STRLEN len 236 Push a string onto the stack. The stack must have room for this element. 237 The C<len> indicates the length of the string. Does not use C<TARG>. 238 See also C<PUSHp>, C<mXPUSHp> and C<XPUSHp>. 239 240 =for apidoc Am|void|mPUSHn|NV nv 241 Push a double onto the stack. The stack must have room for this element. 242 Does not use C<TARG>. See also C<PUSHn>, C<mXPUSHn> and C<XPUSHn>. 243 244 =for apidoc Am|void|mPUSHi|IV iv 245 Push an integer onto the stack. The stack must have room for this element. 246 Does not use C<TARG>. See also C<PUSHi>, C<mXPUSHi> and C<XPUSHi>. 247 248 =for apidoc Am|void|mPUSHu|UV uv 249 Push an unsigned integer onto the stack. The stack must have room for this 250 element. Does not use C<TARG>. See also C<PUSHu>, C<mXPUSHu> and C<XPUSHu>. 251 252 =for apidoc Am|void|mXPUSHs|SV* sv 253 Push an SV onto the stack, extending the stack if necessary and mortalizes 254 the SV. Does not use C<TARG>. See also C<XPUSHs> and C<mPUSHs>. 255 256 =for apidoc Am|void|XPUSHmortal 257 Push a new mortal SV onto the stack, extending the stack if necessary. 258 Does not use C<TARG>. See also C<XPUSHs>, C<PUSHmortal> and C<PUSHs>. 259 260 =for apidoc Am|void|mXPUSHp|char* str|STRLEN len 261 Push a string onto the stack, extending the stack if necessary. The C<len> 262 indicates the length of the string. Does not use C<TARG>. See also C<XPUSHp>, 263 C<mPUSHp> and C<PUSHp>. 264 265 =for apidoc Am|void|mXPUSHn|NV nv 266 Push a double onto the stack, extending the stack if necessary. 267 Does not use C<TARG>. See also C<XPUSHn>, C<mPUSHn> and C<PUSHn>. 268 269 =for apidoc Am|void|mXPUSHi|IV iv 270 Push an integer onto the stack, extending the stack if necessary. 271 Does not use C<TARG>. See also C<XPUSHi>, C<mPUSHi> and C<PUSHi>. 272 273 =for apidoc Am|void|mXPUSHu|UV uv 274 Push an unsigned integer onto the stack, extending the stack if necessary. 275 Does not use C<TARG>. See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>. 276 277 =cut 278 */ 279 280 #define EXTEND(p,n) STMT_START { if (PL_stack_max - p < (int)(n)) { \ 281 sp = stack_grow(sp,p, (int) (n)); \ 282 } } STMT_END 283 284 /* Same thing, but update mark register too. */ 285 #define MEXTEND(p,n) STMT_START {if (PL_stack_max - p < (int)(n)) { \ 286 const int markoff = mark - PL_stack_base; \ 287 sp = stack_grow(sp,p,(int) (n)); \ 288 mark = PL_stack_base + markoff; \ 289 } } STMT_END 290 291 #define PUSHs(s) (*++sp = (s)) 292 #define PUSHTARG STMT_START { SvSETMAGIC(TARG); PUSHs(TARG); } STMT_END 293 #define PUSHp(p,l) STMT_START { sv_setpvn(TARG, (p), (l)); PUSHTARG; } STMT_END 294 #define PUSHn(n) STMT_START { sv_setnv(TARG, (NV)(n)); PUSHTARG; } STMT_END 295 #define PUSHi(i) STMT_START { sv_setiv(TARG, (IV)(i)); PUSHTARG; } STMT_END 296 #define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END 297 298 #define XPUSHs(s) STMT_START { EXTEND(sp,1); (*++sp = (s)); } STMT_END 299 #define XPUSHTARG STMT_START { SvSETMAGIC(TARG); XPUSHs(TARG); } STMT_END 300 #define XPUSHp(p,l) STMT_START { sv_setpvn(TARG, (p), (l)); XPUSHTARG; } STMT_END 301 #define XPUSHn(n) STMT_START { sv_setnv(TARG, (NV)(n)); XPUSHTARG; } STMT_END 302 #define XPUSHi(i) STMT_START { sv_setiv(TARG, (IV)(i)); XPUSHTARG; } STMT_END 303 #define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END 304 #define XPUSHundef STMT_START { SvOK_off(TARG); XPUSHs(TARG); } STMT_END 305 306 #define mPUSHs(s) PUSHs(sv_2mortal(s)) 307 #define PUSHmortal PUSHs(sv_newmortal()) 308 #define mPUSHp(p,l) PUSHs(newSVpvn_flags((p), (l), SVs_TEMP)) 309 #define mPUSHn(n) sv_setnv(PUSHmortal, (NV)(n)) 310 #define mPUSHi(i) sv_setiv(PUSHmortal, (IV)(i)) 311 #define mPUSHu(u) sv_setuv(PUSHmortal, (UV)(u)) 312 313 #define mXPUSHs(s) XPUSHs(sv_2mortal(s)) 314 #define XPUSHmortal XPUSHs(sv_newmortal()) 315 #define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); mPUSHp((p), (l)); } STMT_END 316 #define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END 317 #define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END 318 #define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END 319 320 #define SETs(s) (*sp = s) 321 #define SETTARG STMT_START { SvSETMAGIC(TARG); SETs(TARG); } STMT_END 322 #define SETp(p,l) STMT_START { sv_setpvn(TARG, (p), (l)); SETTARG; } STMT_END 323 #define SETn(n) STMT_START { sv_setnv(TARG, (NV)(n)); SETTARG; } STMT_END 324 #define SETi(i) STMT_START { sv_setiv(TARG, (IV)(i)); SETTARG; } STMT_END 325 #define SETu(u) STMT_START { sv_setuv(TARG, (UV)(u)); SETTARG; } STMT_END 326 327 #define dTOPss SV *sv = TOPs 328 #define dPOPss SV *sv = POPs 329 #define dTOPnv NV value = TOPn 330 #define dPOPnv NV value = POPn 331 #define dTOPiv IV value = TOPi 332 #define dPOPiv IV value = POPi 333 #define dTOPuv UV value = TOPu 334 #define dPOPuv UV value = POPu 335 #ifdef HAS_QUAD 336 #define dTOPqv Quad_t value = TOPu 337 #define dPOPqv Quad_t value = POPu 338 #define dTOPuqv Uquad_t value = TOPuq 339 #define dPOPuqv Uquad_t value = POPuq 340 #endif 341 342 #define dPOPXssrl(X) SV *right = POPs; SV *left = CAT2(X,s) 343 #define dPOPXnnrl(X) NV right = POPn; NV left = CAT2(X,n) 344 #define dPOPXiirl(X) IV right = POPi; IV left = CAT2(X,i) 345 346 #define USE_LEFT(sv) \ 347 (SvOK(sv) || SvGMAGICAL(sv) || !(PL_op->op_flags & OPf_STACKED)) 348 #define dPOPXnnrl_ul(X) \ 349 NV right = POPn; \ 350 SV *leftsv = CAT2(X,s); \ 351 NV left = USE_LEFT(leftsv) ? SvNV(leftsv) : 0.0 352 #define dPOPXiirl_ul(X) \ 353 IV right = POPi; \ 354 SV *leftsv = CAT2(X,s); \ 355 IV left = USE_LEFT(leftsv) ? SvIV(leftsv) : 0 356 357 #define dPOPPOPssrl dPOPXssrl(POP) 358 #define dPOPPOPnnrl dPOPXnnrl(POP) 359 #define dPOPPOPnnrl_ul dPOPXnnrl_ul(POP) 360 #define dPOPPOPiirl dPOPXiirl(POP) 361 #define dPOPPOPiirl_ul dPOPXiirl_ul(POP) 362 363 #define dPOPTOPssrl dPOPXssrl(TOP) 364 #define dPOPTOPnnrl dPOPXnnrl(TOP) 365 #define dPOPTOPnnrl_ul dPOPXnnrl_ul(TOP) 366 #define dPOPTOPiirl dPOPXiirl(TOP) 367 #define dPOPTOPiirl_ul dPOPXiirl_ul(TOP) 368 369 #define RETPUSHYES RETURNX(PUSHs(&PL_sv_yes)) 370 #define RETPUSHNO RETURNX(PUSHs(&PL_sv_no)) 371 #define RETPUSHUNDEF RETURNX(PUSHs(&PL_sv_undef)) 372 373 #define RETSETYES RETURNX(SETs(&PL_sv_yes)) 374 #define RETSETNO RETURNX(SETs(&PL_sv_no)) 375 #define RETSETUNDEF RETURNX(SETs(&PL_sv_undef)) 376 377 #define ARGTARG PL_op->op_targ 378 379 /* See OPpTARGET_MY: */ 380 #define MAXARG (PL_op->op_private & 15) 381 382 #define SWITCHSTACK(f,t) \ 383 STMT_START { \ 384 AvFILLp(f) = sp - PL_stack_base; \ 385 PL_stack_base = AvARRAY(t); \ 386 PL_stack_max = PL_stack_base + AvMAX(t); \ 387 sp = PL_stack_sp = PL_stack_base + AvFILLp(t); \ 388 PL_curstack = t; \ 389 } STMT_END 390 391 #define EXTEND_MORTAL(n) \ 392 STMT_START { \ 393 if (PL_tmps_ix + (n) >= PL_tmps_max) \ 394 tmps_grow(n); \ 395 } STMT_END 396 397 #define AMGf_noright 1 398 #define AMGf_noleft 2 399 #define AMGf_assign 4 400 #define AMGf_unary 8 401 402 #define tryAMAGICbinW_var(meth_enum,assign,set) STMT_START { \ 403 SV* const left = *(sp-1); \ 404 SV* const right = *(sp); \ 405 if ((SvAMAGIC(left)||SvAMAGIC(right))) {\ 406 SV * const tmpsv = amagic_call(left, \ 407 right, \ 408 (meth_enum), \ 409 (assign)? AMGf_assign: 0); \ 410 if (tmpsv) { \ 411 SPAGAIN; \ 412 (void)POPs; set(tmpsv); RETURN; } \ 413 } \ 414 } STMT_END 415 416 #define tryAMAGICbinW(meth,assign,set) \ 417 tryAMAGICbinW_var(CAT2(meth,_amg),assign,set) 418 419 #define tryAMAGICbin_var(meth_enum,assign) \ 420 tryAMAGICbinW_var(meth_enum,assign,SETsv) 421 #define tryAMAGICbin(meth,assign) \ 422 tryAMAGICbin_var(CAT2(meth,_amg),assign) 423 424 #define tryAMAGICbinSET(meth,assign) tryAMAGICbinW(meth,assign,SETs) 425 426 #define tryAMAGICbinSET_var(meth_enum,assign) \ 427 tryAMAGICbinW_var(meth_enum,assign,SETs) 428 429 #define AMG_CALLun_var(sv,meth_enum) amagic_call(sv,&PL_sv_undef, \ 430 meth_enum,AMGf_noright | AMGf_unary) 431 #define AMG_CALLun(sv,meth) AMG_CALLun_var(sv,CAT2(meth,_amg)) 432 433 #define AMG_CALLbinL(left,right,meth) \ 434 amagic_call(left,right,CAT2(meth,_amg),AMGf_noright) 435 436 #define tryAMAGICunW_var(meth_enum,set,shift,ret) STMT_START { \ 437 SV* tmpsv; \ 438 SV* arg= sp[shift]; \ 439 if(0) goto am_again; /* shut up unused warning */ \ 440 am_again: \ 441 if ((SvAMAGIC(arg))&&\ 442 (tmpsv=AMG_CALLun_var(arg,(meth_enum)))) {\ 443 SPAGAIN; if (shift) sp += shift; \ 444 set(tmpsv); ret; } \ 445 } STMT_END 446 #define tryAMAGICunW(meth,set,shift,ret) \ 447 tryAMAGICunW_var(CAT2(meth,_amg),set,shift,ret) 448 449 #define FORCE_SETs(sv) STMT_START { sv_setsv(TARG, (sv)); SETTARG; } STMT_END 450 451 #define tryAMAGICun_var(meth_enum) tryAMAGICunW_var(meth_enum,SETsvUN,0,RETURN) 452 #define tryAMAGICun(meth) tryAMAGICun_var(CAT2(meth,_amg)) 453 #define tryAMAGICunSET(meth) tryAMAGICunW(meth,SETs,0,RETURN) 454 #define tryAMAGICunTARGET(meth, shift) \ 455 STMT_START { dSP; sp--; /* get TARGET from below PL_stack_sp */ \ 456 { dTARGETSTACKED; \ 457 { dSP; tryAMAGICunW(meth,FORCE_SETs,shift,RETURN);}}} STMT_END 458 459 #define setAGAIN(ref) \ 460 STMT_START { \ 461 sv = ref; \ 462 if (!SvROK(ref)) \ 463 Perl_croak(aTHX_ "Overloaded dereference did not return a reference"); \ 464 if (ref != arg && SvRV(ref) != SvRV(arg)) { \ 465 arg = ref; \ 466 goto am_again; \ 467 } \ 468 } STMT_END 469 470 #define tryAMAGICunDEREF(meth) tryAMAGICunW(meth,setAGAIN,0,(void)0) 471 #define tryAMAGICunDEREF_var(meth_enum) \ 472 tryAMAGICunW_var(meth_enum,setAGAIN,0,(void)0) 473 474 #define tryAMAGICftest(chr) \ 475 STMT_START { \ 476 assert(chr != '?'); \ 477 if ((PL_op->op_flags & OPf_KIDS) \ 478 && SvAMAGIC(TOPs)) { \ 479 const char tmpchr = (chr); \ 480 SV * const tmpsv = amagic_call(TOPs, \ 481 newSVpvn_flags(&tmpchr, 1, SVs_TEMP), \ 482 ftest_amg, AMGf_unary); \ 483 \ 484 if (tmpsv) { \ 485 const OP *next = PL_op->op_next; \ 486 \ 487 SPAGAIN; \ 488 \ 489 if (next->op_type >= OP_FTRREAD && \ 490 next->op_type <= OP_FTBINARY && \ 491 next->op_private & OPpFT_STACKED \ 492 ) { \ 493 if (SvTRUE(tmpsv)) \ 494 /* leave the object alone */ \ 495 RETURN; \ 496 } \ 497 \ 498 SETs(tmpsv); \ 499 RETURN; \ 500 } \ 501 } \ 502 } STMT_END 503 504 505 #define opASSIGN (PL_op->op_flags & OPf_STACKED) 506 #define SETsv(sv) STMT_START { \ 507 if (opASSIGN || (SvFLAGS(TARG) & SVs_PADMY)) \ 508 { sv_setsv(TARG, (sv)); SETTARG; } \ 509 else SETs(sv); } STMT_END 510 511 #define SETsvUN(sv) STMT_START { \ 512 if (SvFLAGS(TARG) & SVs_PADMY) \ 513 { sv_setsv(TARG, (sv)); SETTARG; } \ 514 else SETs(sv); } STMT_END 515 516 /* newSVsv does not behave as advertised, so we copy missing 517 * information by hand */ 518 519 /* SV* ref causes confusion with the member variable 520 changed SV* ref to SV* tmpRef */ 521 #define RvDEEPCP(rv) STMT_START { SV* tmpRef=SvRV(rv); SV* rv_copy; \ 522 if (SvREFCNT(tmpRef)>1 && (rv_copy = AMG_CALLun(rv,copy))) { \ 523 SvRV_set(rv, rv_copy); \ 524 SvREFCNT_dec(tmpRef); \ 525 } } STMT_END 526 527 /* 528 =for apidoc mU||LVRET 529 True if this op will be the return value of an lvalue subroutine 530 531 =cut */ 532 #define LVRET ((PL_op->op_private & OPpMAYBE_LVSUB) && is_lvalue_sub()) 533 534 #define SvCANEXISTDELETE(sv) \ 535 (!SvRMAGICAL(sv) \ 536 || ((mg = mg_find((const SV *) sv, PERL_MAGIC_tied)) \ 537 && (stash = SvSTASH(SvRV(SvTIED_obj(MUTABLE_SV(sv), mg)))) \ 538 && gv_fetchmethod_autoload(stash, "EXISTS", TRUE) \ 539 && gv_fetchmethod_autoload(stash, "DELETE", TRUE) \ 540 ) \ 541 ) 542 543 /* 544 * Local variables: 545 * c-indentation-style: bsd 546 * c-basic-offset: 4 547 * indent-tabs-mode: t 548 * End: 549 * 550 * ex: set ts=8 sts=4 sw=4 noet: 551 */ 552