Access cx->blk_sub.hasargs via a pair of macros (as it's about to
Nicholas Clark [Fri, 1 Sep 2006 15:05:10 +0000 (15:05 +0000)]
move)

p4raw-id: //depot/perl@28772

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

diff --git a/cop.h b/cop.h
index 5bc36bd..c248eed 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -278,10 +278,13 @@ struct block_sub {
  * Note that the refcnt of the cv is incremented twice;  The CX one is
  * decremented by LEAVESUB, the other by LEAVE. */
 
+#define CX_SUB_HASARGS_SET(cx, v)      ((cx)->blk_sub.hasargs = (v))
+#define CX_SUB_HASARGS_GET(cx)         ((cx)->blk_sub.hasargs + 0)
+
 #define PUSHSUB_BASE(cx)                                               \
        cx->blk_sub.cv = cv;                                            \
        cx->blk_sub.olddepth = CvDEPTH(cv);                             \
-       cx->blk_sub.hasargs = hasargs;                                  \
+       CX_SUB_HASARGS_SET(cx, hasargs);                                \
        cx->blk_sub.retop = NULL;                                       \
        if (!CvDEPTH(cv)) {                                             \
            SvREFCNT_inc_simple_void_NN(cv);                            \
@@ -305,7 +308,7 @@ struct block_sub {
        cx->blk_sub.cv = cv;                                            \
        cx->blk_sub.gv = gv;                                            \
        cx->blk_sub.retop = NULL;                                       \
-       cx->blk_sub.hasargs = 0;                                        \
+       CX_SUB_HASARGS_SET(cx, 0);                                      \
        cx->blk_sub.dfoutgv = PL_defoutgv;                              \
        SvREFCNT_inc_void(cx->blk_sub.dfoutgv)
 
@@ -326,7 +329,7 @@ struct block_sub {
 
 #define POPSUB(cx,sv)                                                  \
     STMT_START {                                                       \
-       if (cx->blk_sub.hasargs) {                                      \
+       if (CX_SUB_HASARGS_GET(cx)) {                                   \
            POP_SAVEARRAY();                                            \
            /* abandon @_ if it got reified */                          \
            if (AvREAL(cx->blk_sub.argarray)) {                         \
index acc7d57..5efbdc5 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1641,11 +1641,11 @@ PP(pp_caller)
            SV * const sv = newSV(0);
            gv_efullname3(sv, cvgv, NULL);
            PUSHs(sv_2mortal(sv));
-           PUSHs(sv_2mortal(newSViv((I32)cx->blk_sub.hasargs)));
+           PUSHs(sv_2mortal(newSViv((I32)CX_SUB_HASARGS_GET(cx))));
        }
        else {
            PUSHs(sv_2mortal(newSVpvs("(unknown)")));
-           PUSHs(sv_2mortal(newSViv((I32)cx->blk_sub.hasargs)));
+           PUSHs(sv_2mortal(newSViv((I32)CX_SUB_HASARGS_GET(cx))));
        }
     }
     else {
@@ -1678,7 +1678,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 && CX_SUB_HASARGS_GET(cx)
        && CopSTASH_eq(PL_curcop, PL_debstash))
     {
        AV * const ary = cx->blk_sub.argarray;
@@ -2348,7 +2348,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 && CX_SUB_HASARGS_GET(cx)) {
                /* put @_ back onto stack */
                AV* av = cx->blk_sub.argarray;
 
@@ -2410,7 +2410,7 @@ PP(pp_goto)
                    PL_in_eval = cx->blk_eval.old_in_eval;
                    PL_eval_root = cx->blk_eval.old_eval_root;
                    cx->cx_type = CXt_SUB;
-                   cx->blk_sub.hasargs = 0;
+                   CX_SUB_HASARGS_SET(cx, 0);
                }
                cx->blk_sub.cv = cv;
                cx->blk_sub.olddepth = CvDEPTH(cv);
@@ -2425,7 +2425,7 @@ PP(pp_goto)
                }
                SAVECOMPPAD();
                PAD_SET_CUR_NOSAVE(padlist, CvDEPTH(cv));
-               if (cx->blk_sub.hasargs)
+               if (CX_SUB_HASARGS_GET(cx))
                {
                    AV* const av = (AV*)PAD_SVl(0);
 
diff --git a/scope.c b/scope.c
index a2a0f3a..9bb2b57 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -1033,7 +1033,7 @@ Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
        PerlIO_printf(Perl_debug_log, "BLK_SUB.DFOUTGV = 0x%"UVxf"\n",
                PTR2UV(cx->blk_sub.dfoutgv));
        PerlIO_printf(Perl_debug_log, "BLK_SUB.HASARGS = %d\n",
-               (int)cx->blk_sub.hasargs);
+               (int)CX_SUB_HASARGS_GET(cx));
        PerlIO_printf(Perl_debug_log, "BLK_SUB.RETOP = 0x%"UVxf"\n",
                PTR2UV(cx->blk_sub.retop));
        break;
@@ -1043,7 +1043,7 @@ 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);
+               (int)CX_SUB_HASARGS_GET(cx));
        PerlIO_printf(Perl_debug_log, "BLK_SUB.LVAL = %d\n",
                (int)cx->blk_sub.lval);
        PerlIO_printf(Perl_debug_log, "BLK_SUB.RETOP = 0x%"UVxf"\n",
diff --git a/sv.c b/sv.c
index 32939d2..56d292e 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -10286,12 +10286,12 @@ Perl_cx_dup(pTHX_ PERL_CONTEXT *cxs, I32 ix, I32 max, CLONE_PARAMS* param)
                ncx->blk_sub.cv         = (cx->blk_sub.olddepth == 0
                                           ? cv_dup_inc(cx->blk_sub.cv, param)
                                           : cv_dup(cx->blk_sub.cv,param));
-               ncx->blk_sub.argarray   = (cx->blk_sub.hasargs
+               ncx->blk_sub.argarray   = (CX_SUB_HASARGS_GET(cx)
                                           ? av_dup_inc(cx->blk_sub.argarray, param)
                                           : NULL);
                ncx->blk_sub.savearray  = av_dup_inc(cx->blk_sub.savearray, param);
                ncx->blk_sub.olddepth   = cx->blk_sub.olddepth;
-               ncx->blk_sub.hasargs    = cx->blk_sub.hasargs;
+               CX_SUB_HASARGS_SET(ncx, CX_SUB_HASARGS_GET(cx));
                ncx->blk_sub.lval       = cx->blk_sub.lval;
                ncx->blk_sub.retop      = cx->blk_sub.retop;
                ncx->blk_sub.oldcomppad = (PAD*)ptr_table_fetch(PL_ptr_table,
@@ -10327,7 +10327,7 @@ Perl_cx_dup(pTHX_ PERL_CONTEXT *cxs, I32 ix, I32 max, CLONE_PARAMS* param)
                ncx->blk_sub.cv         = cv_dup(cx->blk_sub.cv, param);
                ncx->blk_sub.gv         = gv_dup(cx->blk_sub.gv, param);
                ncx->blk_sub.dfoutgv    = gv_dup_inc(cx->blk_sub.dfoutgv, param);
-               ncx->blk_sub.hasargs    = cx->blk_sub.hasargs;
+               CX_SUB_HASARGS_SET(ncx, CX_SUB_HASARGS_GET(cx));
                ncx->blk_sub.retop      = cx->blk_sub.retop;
                break;
            case CXt_BLOCK: