This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In struct block_sub and block_format, access the members hasargs and
authorNicholas Clark <nick@ccl4.org>
Sun, 20 Jan 2008 21:50:31 +0000 (21:50 +0000)
committerNicholas Clark <nick@ccl4.org>
Sun, 20 Jan 2008 21:50:31 +0000 (21:50 +0000)
lval via macros CxHASARGS() and CxLVAL(), which will allow the storage
location to be changed.

p4raw-id: //depot/perl@33017

cop.h
pp_ctl.c
pp_hot.c
scope.c
sv.c

diff --git a/cop.h b/cop.h
index 209ee2a..c03dfdc 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -364,7 +364,7 @@ struct block_format {
                CopFILE((COP*)CvSTART((CV*)cx->blk_sub.cv)),            \
                CopLINE((COP*)CvSTART((CV*)cx->blk_sub.cv)));           \
                                                                        \
-       if (cx->blk_sub.hasargs) {                                      \
+       if (CxHASARGS(cx)) {                                            \
            POP_SAVEARRAY();                                            \
            /* abandon @_ if it got reified */                          \
            if (AvREAL(cx->blk_sub.argarray)) {                         \
@@ -488,6 +488,8 @@ struct block_loop {
            cx->blk_loop.itersave = NULL;
 #endif
 #define CxLABEL(c)     (0 + (c)->blk_oldcop->cop_label)
+#define CxHASARGS(c)   (0 + (c)->blk_sub.hasargs)
+#define CxLVAL(c)      (0 + (c)->blk_sub.lval)
 
 #ifdef USE_ITHREADS
 #  define PUSHLOOP_OP_NEXT             /* No need to do anything.  */
index d1b0877..2d3648b 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1308,8 +1308,8 @@ Perl_is_lvalue_sub(pTHX)
     const I32 cxix = dopoptosub(cxstack_ix);
     assert(cxix >= 0);  /* We should only be called from inside subs */
 
-    if (cxstack[cxix].blk_sub.lval && CvLVALUE(cxstack[cxix].blk_sub.cv))
-       return cxstack[cxix].blk_sub.lval;
+    if (CxLVAL(cxstack + cxix) && CvLVALUE(cxstack[cxix].blk_sub.cv))
+       return CxLVAL(cxstack + cxix);
     else
        return 0;
 }
@@ -1654,11 +1654,11 @@ PP(pp_caller)
            SV * const sv = newSV(0);
            gv_efullname3(sv, cvgv, NULL);
            mPUSHs(sv);
-           mPUSHi((I32)cx->blk_sub.hasargs);
+           mPUSHi((I32)CxHASARGS(cx));
        }
        else {
            PUSHs(newSVpvs_flags("(unknown)", SVs_TEMP));
-           mPUSHi((I32)cx->blk_sub.hasargs);
+           mPUSHi((I32)CxHASARGS(cx));
        }
     }
     else {
@@ -1691,7 +1691,7 @@ PP(pp_caller)
        PUSHs(&PL_sv_undef);
        PUSHs(&PL_sv_undef);
     }
-    if (CxTYPE(cx) == CXt_SUB && cx->blk_sub.hasargs
+    if (CxTYPE(cx) == CXt_SUB && CxHASARGS(cx)
        && CopSTASH_eq(PL_curcop, PL_debstash))
     {
        AV * const ary = cx->blk_sub.argarray;
@@ -2378,7 +2378,7 @@ PP(pp_goto)
            }
            else if (CxMULTICALL(cx))
                DIE(aTHX_ "Can't goto subroutine from a sort sub (or similar callback)");
-           if (CxTYPE(cx) == CXt_SUB && cx->blk_sub.hasargs) {
+           if (CxTYPE(cx) == CXt_SUB && CxHASARGS(cx)) {
                /* put @_ back onto stack */
                AV* av = cx->blk_sub.argarray;
 
@@ -2455,7 +2455,7 @@ PP(pp_goto)
                }
                SAVECOMPPAD();
                PAD_SET_CUR_NOSAVE(padlist, CvDEPTH(cv));
-               if (cx->blk_sub.hasargs)
+               if (CxHASARGS(cx))
                {
                    AV* const av = (AV*)PAD_SVl(0);
 
index ad9e0ea..95a757d 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2505,7 +2505,7 @@ PP(pp_leavesublv)
 
     TAINT_NOT;
 
-    if (cx->blk_sub.lval & OPpENTERSUB_INARGS) {
+    if (CxLVAL(cx) & OPpENTERSUB_INARGS) {
        /* We are an argument to a function or grep().
         * This kind of lvalueness was legal before lvalue
         * subroutines too, so be backward compatible:
@@ -2532,7 +2532,7 @@ PP(pp_leavesublv)
            }
        }
     }
-    else if (cx->blk_sub.lval) {     /* Leave it as it is if we can. */
+    else if (CxLVAL(cx)) {     /* Leave it as it is if we can. */
        /* Here we go for robustness, not for speed, so we change all
         * the refcounts so the caller gets a live guy. Cannot set
         * TEMP, so sv_2mortal is out of question. */
diff --git a/scope.c b/scope.c
index b5925f7..c2722f9 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -1053,7 +1053,7 @@ Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
        PerlIO_printf(Perl_debug_log, "BLK_FORMAT.DFOUTGV = 0x%"UVxf"\n",
                PTR2UV(cx->blk_format.dfoutgv));
        PerlIO_printf(Perl_debug_log, "BLK_FORMAT.HASARGS = %d\n",
-               (int)cx->blk_format.hasargs);
+                     (int)CxHASARGS(cx));
        PerlIO_printf(Perl_debug_log, "BLK_FORMAT.RETOP = 0x%"UVxf"\n",
                PTR2UV(cx->blk_format.retop));
        break;
@@ -1063,9 +1063,8 @@ Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
        PerlIO_printf(Perl_debug_log, "BLK_SUB.OLDDEPTH = %ld\n",
                (long)cx->blk_sub.olddepth);
        PerlIO_printf(Perl_debug_log, "BLK_SUB.HASARGS = %d\n",
-               (int)cx->blk_sub.hasargs);
-       PerlIO_printf(Perl_debug_log, "BLK_SUB.LVAL = %d\n",
-               (int)cx->blk_sub.lval);
+               (int)CxHASARGS(cx));
+       PerlIO_printf(Perl_debug_log, "BLK_SUB.LVAL = %d\n", (int)CxLVAL(cx));
        PerlIO_printf(Perl_debug_log, "BLK_SUB.RETOP = 0x%"UVxf"\n",
                PTR2UV(cx->blk_sub.retop));
        break;
diff --git a/sv.c b/sv.c
index 3ae7b75..0618a8a 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -10528,7 +10528,7 @@ Perl_cx_dup(pTHX_ PERL_CONTEXT *cxs, I32 ix, I32 max, CLONE_PARAMS* param)
                ncx->blk_sub.cv         = (ncx->blk_sub.olddepth == 0
                                           ? cv_dup_inc(ncx->blk_sub.cv, param)
                                           : cv_dup(ncx->blk_sub.cv,param));
-               ncx->blk_sub.argarray   = (ncx->blk_sub.hasargs
+               ncx->blk_sub.argarray   = (CxHASARGS(ncx)
                                           ? av_dup_inc(ncx->blk_sub.argarray,
                                                        param)
                                           : NULL);