This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove deprecated literal control char variable names
[perl5.git] / pp_ctl.c
index 8a259d4..99ff59a 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -965,7 +965,7 @@ PP(pp_grepstart)
 PP(pp_mapwhile)
 {
     dSP;
-    const I32 gimme = GIMME_V;
+    const U8 gimme = GIMME_V;
     I32 items = (SP - PL_stack_base) - TOPMARK; /* how many new items */
     I32 count;
     I32 shift;
@@ -1332,14 +1332,14 @@ S_dopoptolabel(pTHX_ const char *label, STRLEN len, U32 flags)
 
 
 
-I32
+U8
 Perl_dowantarray(pTHX)
 {
-    const I32 gimme = block_gimme();
+    const U8 gimme = block_gimme();
     return (gimme == G_VOID) ? G_SCALAR : gimme;
 }
 
-I32
+U8
 Perl_block_gimme(pTHX)
 {
     const I32 cxix = dopoptosub(cxstack_ix);
@@ -1541,13 +1541,13 @@ Perl_dounwind(pTHX_ I32 cxix)
        case CXt_LOOP_LAZYSV:
        case CXt_LOOP_LIST:
        case CXt_LOOP_ARY:
-           CX_POPLOOP(cx);
+           cx_poploop(cx);
            break;
        case CXt_WHEN:
-           CX_POPWHEN(cx);
+           cx_popwhen(cx);
            break;
        case CXt_GIVEN:
-           CX_POPGIVEN(cx);
+           cx_popgiven(cx);
            break;
        case CXt_BLOCK:
        case CXt_NULL:
@@ -1674,7 +1674,7 @@ Perl_die_unwind(pTHX_ SV *msv)
             SV *namesv = NULL;
            PERL_CONTEXT *cx;
            SV **oldsp;
-            I32 gimme;
+            U8 gimme;
            JMPENV *restartjmpenv;
            OP *restartop;
 
@@ -1800,7 +1800,7 @@ PP(pp_caller)
     dSP;
     const PERL_CONTEXT *cx;
     const PERL_CONTEXT *dbcx;
-    I32 gimme = GIMME_V;
+    U8 gimme = GIMME_V;
     const HEK *stash_hek;
     I32 count = 0;
     bool has_arg = MAXARG && TOPs;
@@ -1870,7 +1870,7 @@ PP(pp_caller)
        PUSHs(newSVpvs_flags("(eval)", SVs_TEMP));
        mPUSHi(0);
     }
-    gimme = (I32)cx->blk_gimme;
+    gimme = cx->blk_gimme;
     if (gimme == G_VOID)
        PUSHs(&PL_sv_undef);
     else
@@ -1984,7 +1984,7 @@ PP(pp_dbstate)
     {
        dSP;
        PERL_CONTEXT *cx;
-       const I32 gimme = G_ARRAY;
+       const U8 gimme = G_ARRAY;
        GV * const gv = PL_DBgv;
        CV * cv = NULL;
 
@@ -2035,25 +2035,25 @@ PP(pp_dbstate)
 
 PP(pp_enter)
 {
-    dSP;
-    I32 gimme = GIMME_V;
+    U8 gimme = GIMME_V;
 
-    (void)cx_pushblock(CXt_BLOCK, gimme, SP, PL_savestack_ix);
-
-    RETURN;
+    (void)cx_pushblock(CXt_BLOCK, gimme, PL_stack_sp, PL_savestack_ix);
+    return NORMAL;
 }
 
+
 PP(pp_leave)
 {
     PERL_CONTEXT *cx;
     SV **oldsp;
-    I32 gimme;
+    U8 gimme;
 
     cx = CX_CUR();
     assert(CxTYPE(cx) == CXt_BLOCK);
 
     if (PL_op->op_flags & OPf_SPECIAL)
-       cx->blk_oldpm = PL_curpm; /* fake block should preserve $1 et al */
+        /* fake block should preserve $1 et al; e.g.  /(...)/ while ...; */
+       cx->blk_oldpm = PL_curpm;
 
     oldsp = PL_stack_base + cx->blk_oldsp;
     gimme = cx->blk_gimme;
@@ -2097,7 +2097,7 @@ PP(pp_enteriter)
 {
     dSP; dMARK;
     PERL_CONTEXT *cx;
-    const I32 gimme = GIMME_V;
+    const U8 gimme = GIMME_V;
     void *itervarp; /* GV or pad slot of the iteration variable */
     SV   *itersave; /* the old var in the iterator var slot */
     U8 cxflags = 0;
@@ -2142,7 +2142,7 @@ PP(pp_enteriter)
      * freeing or undoing, in case we die in the meantime. And vice-versa.
      */
     cx = cx_pushblock(cxflags, gimme, MARK, PL_savestack_ix);
-    CX_PUSHLOOP_FOR(cx, itervarp, itersave);
+    cx_pushloop_for(cx, itervarp, itersave);
 
     if (PL_op->op_flags & OPf_STACKED) {
         /* OPf_STACKED implies either a single array: for(@), with a
@@ -2212,20 +2212,19 @@ PP(pp_enteriter)
 
 PP(pp_enterloop)
 {
-    dSP;
     PERL_CONTEXT *cx;
-    const I32 gimme = GIMME_V;
+    const U8 gimme = GIMME_V;
 
-    cx = cx_pushblock(CXt_LOOP_PLAIN, gimme, SP, PL_savestack_ix);
-    CX_PUSHLOOP_PLAIN(cx);
-
-    RETURN;
+    cx = cx_pushblock(CXt_LOOP_PLAIN, gimme, PL_stack_sp, PL_savestack_ix);
+    cx_pushloop_plain(cx);
+    return NORMAL;
 }
 
+
 PP(pp_leaveloop)
 {
     PERL_CONTEXT *cx;
-    I32 gimme;
+    U8 gimme;
     SV **oldsp;
     SV **mark;
 
@@ -2244,7 +2243,7 @@ PP(pp_leaveloop)
                                 PL_op->op_private & OPpLVALUE ? 3 : 1);
 
     CX_LEAVE_SCOPE(cx);
-    CX_POPLOOP(cx);    /* Stack values are safe: release loop vars ... */
+    cx_poploop(cx);    /* Stack values are safe: release loop vars ... */
     cx_popblock(cx);
     CX_POP(cx);
 
@@ -2258,11 +2257,13 @@ PP(pp_leaveloop)
  *
  * Any changes made to this function may need to be copied to pp_leavesub
  * and vice-versa.
+ *
+ * also tail-called by pp_return
  */
 
 PP(pp_leavesublv)
 {
-    I32 gimme;
+    U8 gimme;
     PERL_CONTEXT *cx;
     SV **oldsp;
     OP *retop;
@@ -2399,20 +2400,18 @@ PP(pp_return)
         }
 
         /* There are contexts that need popping. Doing this may free the
-         * return value(s), so preserve them first, e.g. popping the plain
+         * return value(s), so preserve them first: e.g. popping the plain
          * loop here would free $x:
          *     sub f {  { my $x = 1; return $x } }
          * We may also need to shift the args down; for example,
          *    for (1,2) { return 3,4 }
-         * leaves 1,2,3,4 on the stack. Both these actions can be done by
-         * leave_adjust_stacks().  By calling it with and lvalue "pass
-         * all" action, we just bump the ref count and mortalise the args
-         * that need it, do a FREETMPS.  The "scan the args and maybe copy
-         * them" process will be repeated by whoever we tail-call (e.g.
-         * pp_leaveeval), where any copying etc will be done. That is to
-         * say, in this code path two scans of the args will be done; the
-         * first just shifts and preserves; the second is the "real" arg
-         * processing, based on the type of return.
+         * leaves 1,2,3,4 on the stack. Both these actions will be done by
+         * leave_adjust_stacks(), along with freeing any temps. Note that
+         * whoever we tail-call (e.g. pp_leaveeval) will also call
+         * leave_adjust_stacks(); however, the second call is likely to
+         * just see a bunch of SvTEMPs with a ref count of 1, and so just
+         * pass them through, rather than copying them again. So this
+         * isn't as inefficient as it sounds.
          */
         cx = &cxstack[cxix];
         PUTBACK;
@@ -2533,7 +2532,7 @@ PP(pp_last)
 
     /* Stack values are safe: */
     CX_LEAVE_SCOPE(cx);
-    CX_POPLOOP(cx);    /* release loop vars ... */
+    cx_poploop(cx);    /* release loop vars ... */
     cx_popblock(cx);
     nextop = cx->blk_loop.my_op->op_lastop->op_next;
     CX_POP(cx);
@@ -3260,7 +3259,7 @@ S_try_yyparse(pTHX_ int gramtype)
  */
 
 STATIC bool
-S_doeval_compile(pTHX_ int gimme, CV* outside, U32 seq, HV *hh)
+S_doeval_compile(pTHX_ U8 gimme, CV* outside, U32 seq, HV *hh)
 {
     dSP;
     OP * const saveop = PL_op;
@@ -3600,7 +3599,7 @@ PP(pp_require)
 #endif
     const char *tryname = NULL;
     SV *namesv = NULL;
-    const I32 gimme = GIMME_V;
+    const U8 gimme = GIMME_V;
     int filter_has_file = 0;
     PerlIO *tryrsfp = NULL;
     SV *filter_cache = NULL;
@@ -3722,7 +3721,7 @@ PP(pp_require)
        }
     }
 
-    LOADING_FILE_PROBE(unixname);
+    PERL_DTRACE_PROBE_FILE_LOADING(unixname);
 
     /* prepare to compile file */
 
@@ -4058,7 +4057,7 @@ PP(pp_require)
     else
        op = PL_op->op_next;
 
-    LOADED_FILE_PROBE(unixname);
+    PERL_DTRACE_PROBE_FILE_LOADED(unixname);
 
     return op;
 }
@@ -4080,7 +4079,7 @@ PP(pp_entereval)
     dSP;
     PERL_CONTEXT *cx;
     SV *sv;
-    const I32 gimme = GIMME_V;
+    const U8 gimme = GIMME_V;
     const U32 was = PL_breakable_sub_gen;
     char tbuf[TYPE_DIGITS(long) + 12];
     bool saved_delete = FALSE;
@@ -4203,10 +4202,13 @@ PP(pp_entereval)
     }
 }
 
+
+/* also tail-called by pp_return */
+
 PP(pp_leaveeval)
 {
     SV **oldsp;
-    I32 gimme;
+    U8 gimme;
     PERL_CONTEXT *cx;
     OP *retop;
     SV *namesv = NULL;
@@ -4287,7 +4289,7 @@ void
 Perl_create_eval_scope(pTHX_ OP *retop, U32 flags)
 {
     PERL_CONTEXT *cx;
-    const I32 gimme = GIMME_V;
+    const U8 gimme = GIMME_V;
        
     cx = cx_pushblock((CXt_EVAL|CXp_TRYBLOCK), gimme,
                     PL_stack_sp, PL_savestack_ix);
@@ -4309,10 +4311,13 @@ PP(pp_entertry)
     return DOCATCH(PL_op->op_next);
 }
 
+
+/* also tail-called by pp_return */
+
 PP(pp_leavetry)
 {
     SV **oldsp;
-    I32 gimme;
+    U8 gimme;
     PERL_CONTEXT *cx;
     OP *retop;
 
@@ -4341,7 +4346,7 @@ PP(pp_entergiven)
 {
     dSP;
     PERL_CONTEXT *cx;
-    const I32 gimme = GIMME_V;
+    const U8 gimme = GIMME_V;
     SV *origsv = DEFSV;
     SV *newsv = POPs;
     
@@ -4349,7 +4354,7 @@ PP(pp_entergiven)
     GvSV(PL_defgv) = SvREFCNT_inc(newsv);
 
     cx = cx_pushblock(CXt_GIVEN, gimme, SP, PL_savestack_ix);
-    CX_PUSHGIVEN(cx, origsv);
+    cx_pushgiven(cx, origsv);
 
     RETURN;
 }
@@ -4357,7 +4362,7 @@ PP(pp_entergiven)
 PP(pp_leavegiven)
 {
     PERL_CONTEXT *cx;
-    I32 gimme;
+    U8 gimme;
     SV **oldsp;
     PERL_UNUSED_CONTEXT;
 
@@ -4372,7 +4377,7 @@ PP(pp_leavegiven)
         leave_adjust_stacks(oldsp, oldsp, gimme, 1);
 
     CX_LEAVE_SCOPE(cx);
-    CX_POPGIVEN(cx);
+    cx_popgiven(cx);
     cx_popblock(cx);
     CX_POP(cx);
 
@@ -4917,7 +4922,7 @@ PP(pp_enterwhen)
 {
     dSP;
     PERL_CONTEXT *cx;
-    const I32 gimme = GIMME_V;
+    const U8 gimme = GIMME_V;
 
     /* This is essentially an optimization: if the match
        fails, we don't want to push a context and then
@@ -4925,11 +4930,11 @@ PP(pp_enterwhen)
        to the op that follows the leavewhen.
        RETURNOP calls PUTBACK which restores the stack pointer after the POPs.
     */
-    if ((0 == (PL_op->op_flags & OPf_SPECIAL)) && !SvTRUEx(POPs))
+    if (!(PL_op->op_flags & OPf_SPECIAL) && !SvTRUEx(POPs))
        RETURNOP(cLOGOP->op_other->op_next);
 
     cx = cx_pushblock(CXt_WHEN, gimme, SP, PL_savestack_ix);
-    CX_PUSHWHEN(cx);
+    cx_pushwhen(cx);
 
     RETURN;
 }
@@ -4938,7 +4943,7 @@ PP(pp_leavewhen)
 {
     I32 cxix;
     PERL_CONTEXT *cx;
-    I32 gimme;
+    U8 gimme;
     SV **oldsp;
 
     cx = CX_CUR();
@@ -4995,7 +5000,7 @@ PP(pp_continue)
     assert(CxTYPE(cx) == CXt_WHEN);
     PL_stack_sp = PL_stack_base + cx->blk_oldsp;
     CX_LEAVE_SCOPE(cx);
-    CX_POPWHEN(cx);
+    cx_popwhen(cx);
     cx_popblock(cx);
     nextop = cx->blk_givwhen.leave_op->op_next;
     CX_POP(cx);