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