This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Merge the refactoring of toke.c's S_force_word.
[perl5.git] / pp.h
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           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 return 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.
101
102 =for apidoc Amn|char*|POPpx
103 Pops a string off the stack.  Identical to POPp.  There are two names for
104 historical reasons.
105
106 =for apidoc Amn|char*|POPpbytex
107 Pops a string off the stack which must consist of bytes i.e. characters < 256.
108
109 =for apidoc Amn|NV|POPn
110 Pops a double off the stack.
111
112 =for apidoc Amn|IV|POPi
113 Pops an integer off the stack.
114
115 =for apidoc Amn|long|POPl
116 Pops a long off the stack.
117
118 =cut
119 */
120
121 #define PUTBACK         PL_stack_sp = sp
122 #define RETURN          return (PUTBACK, NORMAL)
123 #define RETURNOP(o)     return (PUTBACK, o)
124 #define RETURNX(x)      return (x, PUTBACK, NORMAL)
125
126 #define POPs            (*sp--)
127 #define POPp            POPpx
128 #define POPpx           (SvPVx_nolen(POPs))
129 #define POPpconstx      (SvPVx_nolen_const(POPs))
130 #define POPpbytex       (SvPVbytex_nolen(POPs))
131 #define POPn            (SvNVx(POPs))
132 #define POPi            ((IV)SvIVx(POPs))
133 #define POPu            ((UV)SvUVx(POPs))
134 #define POPl            ((long)SvIVx(POPs))
135 #define POPul           ((unsigned long)SvIVx(POPs))
136 #ifdef HAS_QUAD
137 #define POPq            ((Quad_t)SvIVx(POPs))
138 #define POPuq           ((Uquad_t)SvUVx(POPs))
139 #endif
140
141 #define TOPs            (*sp)
142 #define TOPm1s          (*(sp-1))
143 #define TOPp1s          (*(sp+1))
144 #define TOPp            TOPpx
145 #define TOPpx           (SvPV_nolen(TOPs))
146 #define TOPn            (SvNV(TOPs))
147 #define TOPi            ((IV)SvIV(TOPs))
148 #define TOPu            ((UV)SvUV(TOPs))
149 #define TOPl            ((long)SvIV(TOPs))
150 #define TOPul           ((unsigned long)SvUV(TOPs))
151 #ifdef HAS_QUAD
152 #define TOPq            ((Quad_t)SvIV(TOPs))
153 #define TOPuq           ((Uquad_t)SvUV(TOPs))
154 #endif
155
156 /* Go to some pains in the rare event that we must extend the stack. */
157
158 /*
159 =for apidoc Am|void|EXTEND|SP|int nitems
160 Used to extend the argument stack for an XSUB's return values. Once
161 used, guarantees that there is room for at least C<nitems> to be pushed
162 onto the stack.
163
164 =for apidoc Am|void|PUSHs|SV* sv
165 Push an SV onto the stack.  The stack must have room for this element.
166 Does not handle 'set' magic.  Does not use C<TARG>.  See also C<PUSHmortal>,
167 C<XPUSHs> and C<XPUSHmortal>.
168
169 =for apidoc Am|void|PUSHp|char* str|STRLEN len
170 Push a string onto the stack.  The stack must have room for this element.
171 The C<len> indicates the length of the string.  Handles 'set' magic.  Uses
172 C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to declare it.  Do not
173 call multiple C<TARG>-oriented macros to return lists from XSUB's - see
174 C<mPUSHp> instead.  See also C<XPUSHp> and C<mXPUSHp>.
175
176 =for apidoc Am|void|PUSHn|NV nv
177 Push a double onto the stack.  The stack must have room for this element.
178 Handles 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
179 called to declare it.  Do not call multiple C<TARG>-oriented macros to
180 return lists from XSUB's - see C<mPUSHn> instead.  See also C<XPUSHn> and
181 C<mXPUSHn>.
182
183 =for apidoc Am|void|PUSHi|IV iv
184 Push an integer onto the stack.  The stack must have room for this element.
185 Handles 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
186 called to declare it.  Do not call multiple C<TARG>-oriented macros to 
187 return lists from XSUB's - see C<mPUSHi> instead.  See also C<XPUSHi> and
188 C<mXPUSHi>.
189
190 =for apidoc Am|void|PUSHu|UV uv
191 Push an unsigned integer onto the stack.  The stack must have room for this
192 element.  Handles 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG>
193 should be called to declare it.  Do not call multiple C<TARG>-oriented
194 macros to return lists from XSUB's - see C<mPUSHu> instead.  See also
195 C<XPUSHu> and C<mXPUSHu>.
196
197 =for apidoc Am|void|XPUSHs|SV* sv
198 Push an SV onto the stack, extending the stack if necessary.  Does not
199 handle 'set' magic.  Does not use C<TARG>.  See also C<XPUSHmortal>,
200 C<PUSHs> and C<PUSHmortal>.
201
202 =for apidoc Am|void|XPUSHp|char* str|STRLEN len
203 Push a string onto the stack, extending the stack if necessary.  The C<len>
204 indicates the length of the string.  Handles 'set' magic.  Uses C<TARG>, so
205 C<dTARGET> or C<dXSTARG> should be called to declare it.  Do not call
206 multiple C<TARG>-oriented macros to return lists from XSUB's - see
207 C<mXPUSHp> instead.  See also C<PUSHp> and C<mPUSHp>.
208
209 =for apidoc Am|void|XPUSHn|NV nv
210 Push a double onto the stack, extending the stack if necessary.  Handles
211 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to
212 declare it.  Do not call multiple C<TARG>-oriented macros to return lists
213 from XSUB's - see C<mXPUSHn> instead.  See also C<PUSHn> and C<mPUSHn>.
214
215 =for apidoc Am|void|XPUSHi|IV iv
216 Push an integer onto the stack, extending the stack if necessary.  Handles
217 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to
218 declare it.  Do not call multiple C<TARG>-oriented macros to return lists
219 from XSUB's - see C<mXPUSHi> instead.  See also C<PUSHi> and C<mPUSHi>.
220
221 =for apidoc Am|void|XPUSHu|UV uv
222 Push an unsigned integer onto the stack, extending the stack if necessary.
223 Handles 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
224 called to declare it.  Do not call multiple C<TARG>-oriented macros to
225 return lists from XSUB's - see C<mXPUSHu> instead.  See also C<PUSHu> and
226 C<mPUSHu>.
227
228 =for apidoc Am|void|mPUSHs|SV* sv
229 Push an SV onto the stack and mortalizes the SV.  The stack must have room
230 for this element.  Does not use C<TARG>.  See also C<PUSHs> and C<mXPUSHs>.
231
232 =for apidoc Am|void|PUSHmortal
233 Push a new mortal SV onto the stack.  The stack must have room for this
234 element.  Does not use C<TARG>.  See also C<PUSHs>, C<XPUSHmortal> and C<XPUSHs>.
235
236 =for apidoc Am|void|mPUSHp|char* str|STRLEN len
237 Push a string onto the stack.  The stack must have room for this element.
238 The C<len> indicates the length of the string.  Does not use C<TARG>.
239 See also C<PUSHp>, C<mXPUSHp> and C<XPUSHp>.
240
241 =for apidoc Am|void|mPUSHn|NV nv
242 Push a double onto the stack.  The stack must have room for this element.
243 Does not use C<TARG>.  See also C<PUSHn>, C<mXPUSHn> and C<XPUSHn>.
244
245 =for apidoc Am|void|mPUSHi|IV iv
246 Push an integer onto the stack.  The stack must have room for this element.
247 Does not use C<TARG>.  See also C<PUSHi>, C<mXPUSHi> and C<XPUSHi>.
248
249 =for apidoc Am|void|mPUSHu|UV uv
250 Push an unsigned integer onto the stack.  The stack must have room for this
251 element.  Does not use C<TARG>.  See also C<PUSHu>, C<mXPUSHu> and C<XPUSHu>.
252
253 =for apidoc Am|void|mXPUSHs|SV* sv
254 Push an SV onto the stack, extending the stack if necessary and mortalizes
255 the SV.  Does not use C<TARG>.  See also C<XPUSHs> and C<mPUSHs>.
256
257 =for apidoc Am|void|XPUSHmortal
258 Push a new mortal SV onto the stack, extending the stack if necessary.
259 Does not use C<TARG>.  See also C<XPUSHs>, C<PUSHmortal> and C<PUSHs>.
260
261 =for apidoc Am|void|mXPUSHp|char* str|STRLEN len
262 Push a string onto the stack, extending the stack if necessary.  The C<len>
263 indicates the length of the string.  Does not use C<TARG>.  See also C<XPUSHp>,
264 C<mPUSHp> and C<PUSHp>.
265
266 =for apidoc Am|void|mXPUSHn|NV nv
267 Push a double onto the stack, extending the stack if necessary.
268 Does not use C<TARG>.  See also C<XPUSHn>, C<mPUSHn> and C<PUSHn>.
269
270 =for apidoc Am|void|mXPUSHi|IV iv
271 Push an integer onto the stack, extending the stack if necessary.
272 Does not use C<TARG>.  See also C<XPUSHi>, C<mPUSHi> and C<PUSHi>.
273
274 =for apidoc Am|void|mXPUSHu|UV uv
275 Push an unsigned integer onto the stack, extending the stack if necessary.
276 Does not use C<TARG>.  See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
277
278 =cut
279 */
280
281 #define EXTEND(p,n)    (void)(UNLIKELY(PL_stack_max - p < (int)(n)) &&         \
282                             (sp = stack_grow(sp,p, (int) (n))))
283
284 /* Same thing, but update mark register too. */
285 #define MEXTEND(p,n)   STMT_START {if (UNLIKELY(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)       (EXTEND(sp,1), *++sp = (s))
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 dPOPnv_nomg     NV value = (sp--, SvNV_nomg(TOPp1s))
332 #define dTOPiv          IV value = TOPi
333 #define dPOPiv          IV value = POPi
334 #define dTOPuv          UV value = TOPu
335 #define dPOPuv          UV value = POPu
336 #ifdef HAS_QUAD
337 #define dTOPqv          Quad_t value = TOPu
338 #define dPOPqv          Quad_t value = POPu
339 #define dTOPuqv         Uquad_t value = TOPuq
340 #define dPOPuqv         Uquad_t value = POPuq
341 #endif
342
343 #define dPOPXssrl(X)    SV *right = POPs; SV *left = CAT2(X,s)
344 #define dPOPXnnrl(X)    NV right = POPn; NV left = CAT2(X,n)
345 #define dPOPXiirl(X)    IV right = POPi; IV left = CAT2(X,i)
346
347 #define USE_LEFT(sv) \
348         (SvOK(sv) || !(PL_op->op_flags & OPf_STACKED))
349 #define dPOPXiirl_ul_nomg(X) \
350     IV right = (sp--, SvIV_nomg(TOPp1s));               \
351     SV *leftsv = CAT2(X,s);                             \
352     IV left = USE_LEFT(leftsv) ? SvIV_nomg(leftsv) : 0
353
354 #define dPOPPOPssrl     dPOPXssrl(POP)
355 #define dPOPPOPnnrl     dPOPXnnrl(POP)
356 #define dPOPPOPiirl     dPOPXiirl(POP)
357
358 #define dPOPTOPssrl     dPOPXssrl(TOP)
359 #define dPOPTOPnnrl     dPOPXnnrl(TOP)
360 #define dPOPTOPnnrl_nomg \
361     NV right = SvNV_nomg(TOPs); NV left = (sp--, SvNV_nomg(TOPs))
362 #define dPOPTOPiirl     dPOPXiirl(TOP)
363 #define dPOPTOPiirl_ul_nomg dPOPXiirl_ul_nomg(TOP)
364 #define dPOPTOPiirl_nomg \
365     IV right = SvIV_nomg(TOPs); IV left = (sp--, SvIV_nomg(TOPs))
366
367 #define RETPUSHYES      RETURNX(PUSHs(&PL_sv_yes))
368 #define RETPUSHNO       RETURNX(PUSHs(&PL_sv_no))
369 #define RETPUSHUNDEF    RETURNX(PUSHs(&PL_sv_undef))
370
371 #define RETSETYES       RETURNX(SETs(&PL_sv_yes))
372 #define RETSETNO        RETURNX(SETs(&PL_sv_no))
373 #define RETSETUNDEF     RETURNX(SETs(&PL_sv_undef))
374
375 #define ARGTARG         PL_op->op_targ
376
377     /* See OPpTARGET_MY: */
378 #define MAXARG          (PL_op->op_private & 15)
379
380 #define SWITCHSTACK(f,t) \
381     STMT_START {                                                        \
382         AvFILLp(f) = sp - PL_stack_base;                                \
383         PL_stack_base = AvARRAY(t);                                     \
384         PL_stack_max = PL_stack_base + AvMAX(t);                        \
385         sp = PL_stack_sp = PL_stack_base + AvFILLp(t);                  \
386         PL_curstack = t;                                                \
387     } STMT_END
388
389 #define EXTEND_MORTAL(n) \
390     STMT_START {                                                        \
391         if (UNLIKELY(PL_tmps_ix + (n) >= PL_tmps_max))                  \
392             tmps_grow(n);                                               \
393     } STMT_END
394
395 #define AMGf_noright    1
396 #define AMGf_noleft     2
397 #define AMGf_assign     4
398 #define AMGf_unary      8
399 #define AMGf_numeric    0x10    /* for Perl_try_amagic_bin */
400 #define AMGf_set        0x20    /* for Perl_try_amagic_bin */
401 #define AMGf_want_list  0x40
402
403
404 /* do SvGETMAGIC on the stack args before checking for overload */
405
406 #define tryAMAGICun_MG(method, flags) STMT_START { \
407         if ( (SvFLAGS(TOPs) & (SVf_ROK|SVs_GMG)) \
408                 && Perl_try_amagic_un(aTHX_ method, flags)) \
409             return NORMAL; \
410     } STMT_END
411 #define tryAMAGICbin_MG(method, flags) STMT_START { \
412         if ( ((SvFLAGS(TOPm1s)|SvFLAGS(TOPs)) & (SVf_ROK|SVs_GMG)) \
413                 && Perl_try_amagic_bin(aTHX_ method, flags)) \
414             return NORMAL; \
415     } STMT_END
416
417 #define AMG_CALLunary(sv,meth) \
418     amagic_call(sv,&PL_sv_undef, meth, AMGf_noright | AMGf_unary)
419
420 /* No longer used in core. Use AMG_CALLunary instead */
421 #define AMG_CALLun(sv,meth) AMG_CALLunary(sv, CAT2(meth,_amg))
422
423 #define tryAMAGICunTARGETlist(meth, jump)                       \
424     STMT_START {                                                \
425         dSP;                                                    \
426         SV *tmpsv;                                              \
427         SV *arg= *sp;                                           \
428         int gimme = GIMME_V;                                    \
429         if (SvAMAGIC(arg) &&                                    \
430             (tmpsv = amagic_call(arg, &PL_sv_undef, meth,       \
431                                  AMGf_want_list | AMGf_noright  \
432                                 |AMGf_unary))) {                \
433             SPAGAIN;                                            \
434             if (gimme == G_VOID) {                              \
435                 (void)POPs; /* XXX ??? */                       \
436             }                                                   \
437             else if (gimme == G_ARRAY) {                        \
438                 int i;                                          \
439                 I32 len;                                        \
440                 assert(SvTYPE(tmpsv) == SVt_PVAV);              \
441                 len = av_len((AV *)tmpsv) + 1;                  \
442                 (void)POPs; /* get rid of the arg */            \
443                 EXTEND(sp, len);                                \
444                 for (i = 0; i < len; ++i)                       \
445                     PUSHs(av_shift((AV *)tmpsv));               \
446             }                                                   \
447             else { /* AMGf_want_scalar */                       \
448                 dATARGET; /* just use the arg's location */     \
449                 sv_setsv(TARG, tmpsv);                          \
450                 if (opASSIGN)                                   \
451                     sp--;                                       \
452                 SETTARG;                                        \
453             }                                                   \
454             PUTBACK;                                            \
455             if (jump) {                                         \
456                 OP *jump_o = NORMAL->op_next;                   \
457                 while (jump_o->op_type == OP_NULL)              \
458                     jump_o = jump_o->op_next;                   \
459                 assert(jump_o->op_type == OP_ENTERSUB);         \
460                 PL_markstack_ptr--;                             \
461                 return jump_o->op_next;                         \
462             }                                                   \
463             return NORMAL;                                      \
464         }                                                       \
465     } STMT_END
466
467 /* This is no longer used anywhere in the core. You might wish to consider
468    calling amagic_deref_call() directly, as it has a cleaner interface.  */
469 #define tryAMAGICunDEREF(meth)                                          \
470     STMT_START {                                                        \
471         sv = amagic_deref_call(*sp, CAT2(meth,_amg));                   \
472         SPAGAIN;                                                        \
473     } STMT_END
474
475
476 #define opASSIGN (PL_op->op_flags & OPf_STACKED)
477 #define SETsv(sv)       STMT_START {                                    \
478                 if (opASSIGN || (SvFLAGS(TARG) & SVs_PADMY))            \
479                    { sv_setsv(TARG, (sv)); SETTARG; }                   \
480                 else SETs(sv); } STMT_END
481
482 #define SETsvUN(sv)     STMT_START {                                    \
483                 if (SvFLAGS(TARG) & SVs_PADMY)          \
484                    { sv_setsv(TARG, (sv)); SETTARG; }                   \
485                 else SETs(sv); } STMT_END
486
487 /*
488 =for apidoc mU||LVRET
489 True if this op will be the return value of an lvalue subroutine
490
491 =cut */
492 #define LVRET ((PL_op->op_private & OPpMAYBE_LVSUB) && is_lvalue_sub())
493
494 #define SvCANEXISTDELETE(sv) \
495  (!SvRMAGICAL(sv)            \
496   || !(mg = mg_find((const SV *) sv, PERL_MAGIC_tied))           \
497   || (   (stash = SvSTASH(SvRV(SvTIED_obj(MUTABLE_SV(sv), mg)))) \
498       && gv_fetchmethod_autoload(stash, "EXISTS", TRUE)          \
499       && gv_fetchmethod_autoload(stash, "DELETE", TRUE)          \
500      )                       \
501   )
502
503 #ifdef PERL_CORE
504
505 /* These are just for Perl_tied_method(), which is not part of the public API.
506    Use 0x04 rather than the next available bit, to help the compiler if the
507    architecture can generate more efficient instructions.  */
508 #  define TIED_METHOD_MORTALIZE_NOT_NEEDED      0x04
509 #  define TIED_METHOD_ARGUMENTS_ON_STACK        0x08
510 #  define TIED_METHOD_SAY                       0x10
511
512 /* Used in various places that need to dereference a glob or globref */
513 #  define MAYBE_DEREF_GV_flags(sv,phlags)                          \
514     (                                                               \
515         (void)(phlags & SV_GMAGIC && (SvGETMAGIC(sv),0)),            \
516         isGV_with_GP(sv)                                              \
517           ? (GV *)(sv)                                                \
518           : SvROK(sv) && SvTYPE(SvRV(sv)) <= SVt_PVLV &&               \
519             (SvGETMAGIC(SvRV(sv)), isGV_with_GP(SvRV(sv)))              \
520              ? (GV *)SvRV(sv)                                            \
521              : NULL                                                       \
522     )
523 #  define MAYBE_DEREF_GV(sv)      MAYBE_DEREF_GV_flags(sv,SV_GMAGIC)
524 #  define MAYBE_DEREF_GV_nomg(sv) MAYBE_DEREF_GV_flags(sv,0)
525
526 #  define FIND_RUNCV_padid_eq   1
527 #  define FIND_RUNCV_level_eq   2
528
529 #endif
530
531 /*
532  * Local variables:
533  * c-indentation-style: bsd
534  * c-basic-offset: 4
535  * indent-tabs-mode: nil
536  * End:
537  *
538  * ex: set ts=8 sts=4 sw=4 et:
539  */