This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
use PERL_UNUSED_VAR rather than PERL_UNUSED_DECL
[perl5.git] / pp.h
diff --git a/pp.h b/pp.h
index 93aeb91..377d489 100644 (file)
--- a/pp.h
+++ b/pp.h
@@ -67,7 +67,7 @@ Refetch the stack pointer.  Used after a callback.  See L<perlcall>.
 
 #define dSP            SV **sp = PL_stack_sp
 #define djSP           dSP
-#define dMARK          register SV **mark = PL_stack_base + POPMARK
+#define dMARK          SV **mark = PL_stack_base + POPMARK
 #define dORIGMARK      const I32 origmark = (I32)(mark - PL_stack_base)
 #define ORIGMARK       (PL_stack_base + origmark)
 
@@ -97,10 +97,11 @@ See C<PUSHMARK> and L<perlcall> for other uses.
 Pops an SV off the stack.
 
 =for apidoc Amn|char*|POPp
-Pops a string off the stack. Deprecated. New code should use POPpx.
+Pops a string off the stack.
 
 =for apidoc Amn|char*|POPpx
-Pops a string off the stack.
+Pops a string off the stack.  Identical to POPp.  There are two names for
+historical reasons.
 
 =for apidoc Amn|char*|POPpbytex
 Pops a string off the stack which must consist of bytes i.e. characters < 256.
@@ -123,7 +124,7 @@ Pops a long off the stack.
 #define RETURNX(x)     return (x, PUTBACK, NORMAL)
 
 #define POPs           (*sp--)
-#define POPp           (SvPVx(POPs, PL_na))            /* deprecated */
+#define POPp           POPpx
 #define POPpx          (SvPVx_nolen(POPs))
 #define POPpconstx     (SvPVx_nolen_const(POPs))
 #define POPpbytex      (SvPVbytex_nolen(POPs))
@@ -140,7 +141,7 @@ Pops a long off the stack.
 #define TOPs           (*sp)
 #define TOPm1s         (*(sp-1))
 #define TOPp1s         (*(sp+1))
-#define TOPp           (SvPV(TOPs, PL_na))             /* deprecated */
+#define TOPp           TOPpx
 #define TOPpx          (SvPV_nolen(TOPs))
 #define TOPn           (SvNV(TOPs))
 #define TOPi           ((IV)SvIV(TOPs))
@@ -397,6 +398,7 @@ Does not use C<TARG>.  See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
 #define AMGf_unary     8
 #define AMGf_numeric   0x10    /* for Perl_try_amagic_bin */
 #define AMGf_set       0x20    /* for Perl_try_amagic_bin */
+#define AMGf_want_list 0x40
 
 
 /* do SvGETMAGIC on the stack args before checking for overload */
@@ -418,21 +420,37 @@ Does not use C<TARG>.  See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
 /* No longer used in core. Use AMG_CALLunary instead */
 #define AMG_CALLun(sv,meth) AMG_CALLunary(sv, CAT2(meth,_amg))
 
-#define tryAMAGICunTARGET(meth, shift, jump)                   \
+#define tryAMAGICunTARGETlist(meth, jump)                      \
     STMT_START {                                               \
-       dATARGET;                                               \
        dSP;                                                    \
        SV *tmpsv;                                              \
-       SV *arg= sp[shift];                                     \
+       SV *arg= *sp;                                           \
+        int gimme = GIMME_V;                                    \
        if (SvAMAGIC(arg) &&                                    \
            (tmpsv = amagic_call(arg, &PL_sv_undef, meth,       \
-                                AMGf_noright | AMGf_unary))) { \
+                                AMGf_want_list | AMGf_noright  \
+                               |AMGf_unary))) {                \
            SPAGAIN;                                            \
-           sp += shift;                                        \
-           sv_setsv(TARG, tmpsv);                              \
-           if (opASSIGN)                                       \
-               sp--;                                           \
-           SETTARG;                                            \
+            if (gimme == G_VOID) {                              \
+                (void)POPs; /* XXX ??? */                       \
+            }                                                   \
+            else if (gimme == G_ARRAY) {                       \
+                int i;                                          \
+                I32 len;                                        \
+                assert(SvTYPE(tmpsv) == SVt_PVAV);              \
+                len = av_len((AV *)tmpsv) + 1;                  \
+                (void)POPs; /* get rid of the arg */            \
+                EXTEND(sp, len);                                \
+                for (i = 0; i < len; ++i)                       \
+                    PUSHs(av_shift((AV *)tmpsv));               \
+            }                                                   \
+            else { /* AMGf_want_scalar */                       \
+                dATARGET; /* just use the arg's location */     \
+                sv_setsv(TARG, tmpsv);                          \
+                if (opASSIGN)                                   \
+                    sp--;                                       \
+                SETTARG;                                        \
+            }                                                   \
            PUTBACK;                                            \
            if (jump) {                                         \
                OP *jump_o = NORMAL->op_next;                   \
@@ -505,6 +523,9 @@ True if this op will be the return value of an lvalue subroutine
 #  define MAYBE_DEREF_GV(sv)      MAYBE_DEREF_GV_flags(sv,SV_GMAGIC)
 #  define MAYBE_DEREF_GV_nomg(sv) MAYBE_DEREF_GV_flags(sv,0)
 
+#  define FIND_RUNCV_padid_eq  1
+#  define FIND_RUNCV_level_eq  2
+
 #endif
 
 /*