This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PUSHBLOCK: don't use implicit args
authorDavid Mitchell <davem@iabyn.com>
Sat, 26 Dec 2015 11:39:30 +0000 (11:39 +0000)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 09:19:18 +0000 (09:19 +0000)
Make gimme a parameter of PUSHBLOCK() rather than just assuming that
there's a 'gimme' var in scope.

cop.h
pp_ctl.c
pp_hot.c
pp_sort.c
pp_sys.c

diff --git a/cop.h b/cop.h
index f58e89c..1fa485e 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -961,7 +961,7 @@ struct block {
                    __FILE__, __LINE__));
 
 /* Enter a block. */
-#define PUSHBLOCK(cx,t,sp, saveix)                                      \
+#define PUSHBLOCK(cx, t, gimme, sp, saveix)                             \
         CXINC,                                                          \
         cx = CX_CUR(),                                                 \
        cx->cx_type             = t,                                    \
@@ -1343,8 +1343,8 @@ See L<perlcall/LIGHTWEIGHT CALLBACKS>.
        multicall_oldcatch = CATCH_GET;                                 \
        CATCH_SET(TRUE);                                                \
        PUSHSTACKi(PERLSI_MULTICALL);                                   \
-       PUSHBLOCK(cx, (CXt_SUB|CXp_MULTICALL|flags), PL_stack_sp,       \
-                  PL_savestack_ix);                                    \
+       PUSHBLOCK(cx, (CXt_SUB|CXp_MULTICALL|flags), gimme,             \
+                  PL_stack_sp, PL_savestack_ix);                       \
        PUSHSUB(cx);                                                    \
        SAVEOP();                                                       \
         saveix_floor = PL_savestack_ix;                                 \
index 1f4786f..f573968 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2014,7 +2014,7 @@ PP(pp_dbstate)
        }
        else {
             U8 hasargs = 0;
-           PUSHBLOCK(cx, CXt_SUB, SP, PL_savestack_ix);
+           PUSHBLOCK(cx, CXt_SUB, gimme, SP, PL_savestack_ix);
            PUSHSUB_DB(cx);
            cx->blk_sub.retop = PL_op->op_next;
 
@@ -2039,7 +2039,7 @@ PP(pp_enter)
     PERL_CONTEXT *cx;
     I32 gimme = GIMME_V;
 
-    PUSHBLOCK(cx, CXt_BLOCK, SP, PL_savestack_ix);
+    PUSHBLOCK(cx, CXt_BLOCK, gimme, SP, PL_savestack_ix);
     PUSHBASICBLK(cx);
 
     RETURN;
@@ -2139,7 +2139,7 @@ PP(pp_enteriter)
     /* OPpITER_DEF (implicit $_) should only occur with a GV iter var */
     assert((cxflags & CXp_FOR_GV) || !(PL_op->op_private & OPpITER_DEF));
 
-    PUSHBLOCK(cx, cxflags, MARK, PL_savestack_ix);
+    PUSHBLOCK(cx, cxflags, gimme, MARK, PL_savestack_ix);
     PUSHLOOP_FOR(cx, itervarp, itersave);
 
     if (PL_op->op_flags & OPf_STACKED) {
@@ -2214,7 +2214,7 @@ PP(pp_enterloop)
     PERL_CONTEXT *cx;
     const I32 gimme = GIMME_V;
 
-    PUSHBLOCK(cx, CXt_LOOP_PLAIN, SP, PL_savestack_ix);
+    PUSHBLOCK(cx, CXt_LOOP_PLAIN, gimme, SP, PL_savestack_ix);
     PUSHLOOP_PLAIN(cx);
 
     RETURN;
@@ -4043,7 +4043,7 @@ PP(pp_require)
     }
 
     /* switch to eval mode */
-    PUSHBLOCK(cx, CXt_EVAL, SP, old_savestack_ix);
+    PUSHBLOCK(cx, CXt_EVAL, gimme, SP, old_savestack_ix);
     PUSHEVAL(cx, name);
     cx->blk_eval.retop = PL_op->op_next;
 
@@ -4158,7 +4158,7 @@ PP(pp_entereval)
      * to do the dirty work for us */
     runcv = find_runcv(&seq);
 
-    PUSHBLOCK(cx, (CXt_EVAL|CXp_REAL), SP, old_savestack_ix);
+    PUSHBLOCK(cx, (CXt_EVAL|CXp_REAL), gimme, SP, old_savestack_ix);
     PUSHEVAL(cx, 0);
     cx->blk_eval.retop = PL_op->op_next;
 
@@ -4289,7 +4289,7 @@ Perl_create_eval_scope(pTHX_ U32 flags)
     PERL_CONTEXT *cx;
     const I32 gimme = GIMME_V;
        
-    PUSHBLOCK(cx, (CXt_EVAL|CXp_TRYBLOCK), PL_stack_sp, PL_savestack_ix);
+    PUSHBLOCK(cx, (CXt_EVAL|CXp_TRYBLOCK), gimme, PL_stack_sp, PL_savestack_ix);
     PUSHEVAL(cx, 0);
 
     PL_in_eval = EVAL_INEVAL;
@@ -4349,7 +4349,7 @@ PP(pp_entergiven)
     assert(!PL_op->op_targ); /* used to be set for lexical $_ */
     GvSV(PL_defgv) = SvREFCNT_inc(newsv);
 
-    PUSHBLOCK(cx, CXt_GIVEN, SP, PL_savestack_ix);
+    PUSHBLOCK(cx, CXt_GIVEN, gimme, SP, PL_savestack_ix);
     PUSHGIVEN(cx, origsv);
 
     RETURN;
@@ -4929,7 +4929,7 @@ PP(pp_enterwhen)
     if ((0 == (PL_op->op_flags & OPf_SPECIAL)) && !SvTRUEx(POPs))
        RETURNOP(cLOGOP->op_other->op_next);
 
-    PUSHBLOCK(cx, CXt_WHEN, SP, PL_savestack_ix);
+    PUSHBLOCK(cx, CXt_WHEN, gimme, SP, PL_savestack_ix);
     PUSHWHEN(cx);
 
     RETURN;
index 127e562..647e398 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3852,7 +3852,7 @@ PP(pp_entersub)
         }
 
         gimme = GIMME_V;
-       PUSHBLOCK(cx, CXt_SUB, MARK, old_savestack_ix);
+       PUSHBLOCK(cx, CXt_SUB, gimme, MARK, old_savestack_ix);
         hasargs = cBOOL(PL_op->op_flags & OPf_STACKED);
        PUSHSUB(cx);
        cx->blk_sub.retop = PL_op->op_next;
index 65609da..e910662 100644 (file)
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1668,7 +1668,7 @@ PP(pp_sort)
            }
 
             gimme = G_SCALAR;
-           PUSHBLOCK(cx, CXt_NULL, PL_stack_base, old_savestack_ix);
+           PUSHBLOCK(cx, CXt_NULL, gimme, PL_stack_base, old_savestack_ix);
            if (!(flags & OPf_SPECIAL)) {
                cx->cx_type = CXt_SUB|CXp_MULTICALL;
                PUSHSUB(cx);
index 74fede7..901cfe5 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1389,7 +1389,7 @@ S_doform(pTHX_ CV *cv, GV *gv, OP *retop)
     if (CvCLONE(cv))
        cv = MUTABLE_CV(sv_2mortal(MUTABLE_SV(cv_clone(cv))));
 
-    PUSHBLOCK(cx, CXt_FORMAT, PL_stack_sp, PL_savestack_ix);
+    PUSHBLOCK(cx, CXt_FORMAT, gimme, PL_stack_sp, PL_savestack_ix);
     PUSHFORMAT(cx, retop);
     if (CvDEPTH(cv) >= 2)
        pad_push(CvPADLIST(cv), CvDEPTH(cv));