move PL_expect and PL_copline into the PL_parser structure
Dave Mitchell [Fri, 4 May 2007 00:41:51 +0000 (00:41 +0000)]
p4raw-id: //depot/perl@31134

embedvar.h
ext/Devel/PPPort/parts/inc/variables
intrpvar.h
op.c
parser.h
perlapi.h
perly.act
perly.y
sv.c

index da82c87..7f64f8e 100644 (file)
 #define PL_comppad_name_fill   (vTHX->Icomppad_name_fill)
 #define PL_comppad_name_floor  (vTHX->Icomppad_name_floor)
 #define PL_cop_seqmax          (vTHX->Icop_seqmax)
-#define PL_copline             (vTHX->Icopline)
 #define PL_cryptseen           (vTHX->Icryptseen)
 #define PL_cshlen              (vTHX->Icshlen)
 #define PL_cshname             (vTHX->Icshname)
 #define PL_exit_flags          (vTHX->Iexit_flags)
 #define PL_exitlist            (vTHX->Iexitlist)
 #define PL_exitlistlen         (vTHX->Iexitlistlen)
-#define PL_expect              (vTHX->Iexpect)
 #define PL_fdpid               (vTHX->Ifdpid)
 #define PL_filemode            (vTHX->Ifilemode)
 #define PL_forkprocess         (vTHX->Iforkprocess)
 #define PL_Icomppad_name_fill  PL_comppad_name_fill
 #define PL_Icomppad_name_floor PL_comppad_name_floor
 #define PL_Icop_seqmax         PL_cop_seqmax
-#define PL_Icopline            PL_copline
 #define PL_Icryptseen          PL_cryptseen
 #define PL_Icshlen             PL_cshlen
 #define PL_Icshname            PL_cshname
 #define PL_Iexit_flags         PL_exit_flags
 #define PL_Iexitlist           PL_exitlist
 #define PL_Iexitlistlen                PL_exitlistlen
-#define PL_Iexpect             PL_expect
 #define PL_Ifdpid              PL_fdpid
 #define PL_Ifilemode           PL_filemode
 #define PL_Iforkprocess                PL_forkprocess
index e7001ae..8901509 100644 (file)
@@ -93,6 +93,12 @@ __NEED_VAR__ U32 PL_signals = D_PPP_PERL_SIGNALS_INIT;
 /* Replace: 0 */
 #endif
 
+#if { VERSION >= 5.9.5 }
+#  define PL_PARSER_EXISTS
+#  define PL_expect   (PL_parser ? PL_parser->expect : 0)
+#  define PL_copline  (PL_parser ? PL_parser->copline : 0)
+#endif
+
 =xsinit
 
 #define NEED_PL_signals
@@ -211,7 +217,11 @@ other_variables()
                ppp_TESTVAR(PL_dirty);
                ppp_TESTVAR(PL_dowarn);
                ppp_TESTVAR(PL_errgv);
+#ifdef PL_PARSER_EXISTS
+               ppp_TESTVAR(PL_parser); /* just any var that isn't PL_expect */
+#else
                ppp_TESTVAR(PL_expect);
+#endif
                ppp_TESTVAR(PL_laststatval);
                ppp_TESTVAR(PL_no_modify);
                ppp_TESTVAR(PL_perl_destruct_level);
index 25e67bd..543acd0 100644 (file)
@@ -178,7 +178,6 @@ PERLVAR(Ieval_start,        OP *)
 
 /* runtime control stuff */
 PERLVARI(Icurcopdb,    COP *,  NULL)
-PERLVARI(Icopline,     line_t, NOLINE)
 
 /* statics moved here for shared library purposes */
 PERLVARI(Igensym,      I32,    0)      /* next symbol for getsym() to define */
@@ -305,10 +304,11 @@ PERLVAR(Ioldbufptr,       char *)
 PERLVAR(Ioldoldbufptr, char *)
 PERLVAR(Ibufend,       char *)
 
-PERLVARI(Iexpect, U8,  XSTATE)         /* how to interpret ambiguous tokens */
 PERLVAR(Ilex_state,    U8)             /* next token is determined */
 PERLVAR(Ierror_count,  U8)             /* how many errors so far, max 10 */
 PERLVARI(Icv_has_eval, bool, FALSE) /* PL_compcv includes an entereval or similar */
+/* Space for one more U8 here without increasing the structure size */
+
 PERLVAR(Imulti_end,    I32)            /* last line of multi-line string */
 
 PERLVAR(Isubname,      SV *)           /* name of current subroutine */
@@ -537,8 +537,8 @@ PERLVARI(Islab_count, U32, 0)       /* Size of the array */
 
 PERLVARI(Iisarev, HV*, NULL) /* Reverse map of @ISA dependencies */
 
-/* If you are adding a U16, see the comment above on where there are 2 bytes
-   of gap which currently will be structure padding.  */
+/* If you are adding a U8 or U16, see the 'Space' comments above on where
+ * there are gaps which currently will be structure padding.  */
 
 /* Within a stable branch, new variables must be added to the very end, before
  * this comment, for binary compatibility (the offsets of the old members must
diff --git a/op.c b/op.c
index 8ee0fa5..1c793e3 100644 (file)
--- a/op.c
+++ b/op.c
@@ -782,8 +782,8 @@ S_scalarboolean(pTHX_ OP *o)
        if (ckWARN(WARN_SYNTAX)) {
            const line_t oldline = CopLINE(PL_curcop);
 
-           if (PL_copline != NOLINE)
-               CopLINE_set(PL_curcop, PL_copline);
+           if (PL_parser && PL_parser->copline != NOLINE)
+               CopLINE_set(PL_curcop, PL_parser->copline);
            Perl_warner(aTHX_ packWARN(WARN_SYNTAX), "Found = in conditional, should be ==");
            CopLINE_set(PL_curcop, oldline);
        }
@@ -1818,7 +1818,6 @@ S_apply_attrs(pTHX_ HV *stash, SV *target, OP *attrs, bool for_my)
 
     /* fake up C<use attributes $pkg,$rv,@attrs> */
     ENTER;             /* need to protect against side-effects of 'use' */
-    SAVEI8(PL_expect);
     stashsv = stash ? newSVhek(HvNAME_HEK(stash)) : &PL_sv_no;
 
 #define ATTRSMODULE "attributes"
@@ -3653,8 +3652,8 @@ Perl_package(pTHX_ OP *o)
     sv_setsv(PL_curstname, sv);
 
     PL_hints |= HINT_BLOCK_SCOPE;
-    PL_copline = NOLINE;
-    PL_expect = XSTATE;
+    PL_parser->copline = NOLINE;
+    PL_parser->expect = XSTATE;
 
 #ifndef PERL_MAD
     op_free(o);
@@ -3778,8 +3777,8 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *idop, OP *arg)
      */
 
     PL_hints |= HINT_BLOCK_SCOPE;
-    PL_copline = NOLINE;
-    PL_expect = XSTATE;
+    PL_parser->copline = NOLINE;
+    PL_parser->expect = XSTATE;
     PL_cop_seqmax++; /* Purely for B::*'s benefit */
 
 #ifdef PERL_MAD
@@ -3857,17 +3856,19 @@ Perl_vload_module(pTHX_ U32 flags, SV *name, SV *ver, va_list *args)
            sv = va_arg(*args, SV*);
        }
     }
-    {
-       const line_t ocopline = PL_copline;
-       COP * const ocurcop = PL_curcop;
-       const U8 oexpect = PL_expect;
 
-       utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(FALSE, 0),
-               veop, modname, imop);
-       PL_expect = oexpect;
-       PL_copline = ocopline;
-       PL_curcop = ocurcop;
-    }
+    /* utilize() fakes up a BEGIN { require ..; import ... }, so make sure
+     * that it has a PL_parser to play with while doing that, and also
+     * that it doesn't mess with any existing parser, by creating a tmp
+     * new parser with lex_start(). This won't actually be used for much,
+     * since pp_require() will create another parser for the real work. */
+
+    ENTER;
+    SAVEVPTR(PL_curcop);
+    lex_start(NULL);
+    utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(FALSE, 0),
+           veop, modname, imop);
+    LEAVE;
 }
 
 OP *
@@ -4176,11 +4177,12 @@ Perl_newSTATEOP(pTHX_ I32 flags, char *label, OP *o)
        HINTS_REFCNT_UNLOCK;
     }
 
-    if (PL_copline == NOLINE)
+    if (PL_parser && PL_parser->copline == NOLINE)
         CopLINE_set(cop, CopLINE(PL_curcop));
     else {
-       CopLINE_set(cop, PL_copline);
-        PL_copline = NOLINE;
+       CopLINE_set(cop, PL_parser->copline);
+       if (PL_parser)
+           PL_parser->copline = NOLINE;
     }
 #ifdef USE_ITHREADS
     CopFILE_set(cop, CopFILE(PL_curcop));      /* XXX share in a pvtable? */
@@ -4326,7 +4328,7 @@ S_new_logop(pTHX_ I32 type, I32 flags, OP** firstp, OP** otherp)
        }
        if (warnop) {
            const line_t oldline = CopLINE(PL_curcop);
-           CopLINE_set(PL_curcop, PL_copline);
+           CopLINE_set(PL_curcop, PL_parser->copline);
            Perl_warner(aTHX_ packWARN(WARN_MISC),
                 "Value of %s%s can be \"0\"; test with defined()",
                 PL_op_desc[warnop],
@@ -4595,7 +4597,7 @@ whileline, OP *expr, OP *block, OP *cont, I32 has_my)
     redo = LINKLIST(listop);
 
     if (expr) {
-       PL_copline = (line_t)whileline;
+       PL_parser->copline = (line_t)whileline;
        scalar(listop);
        o = new_logop(OP_AND, 0, &expr, &listop);
        if (o == expr && o->op_type == OP_CONST && !SvTRUE(cSVOPo->op_sv)) {
@@ -4754,7 +4756,7 @@ Perl_newFOROP(pTHX_ I32 flags, char *label, line_t forline, OP *sv, OP *expr, OP
     wop = newWHILEOP(flags, 1, loop, forline, newOP(OP_ITER, 0), block, cont, 0);
     if (madsv)
        op_getmad(madsv, (OP*)loop, 'v');
-    PL_copline = forline;
+    PL_parser->copline = forline;
     return newSTATEOP(0, label, wop);
 }
 
@@ -5318,8 +5320,8 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
                        && (!const_sv || sv_cmp(cv_const_sv(cv), const_sv))))
                {
                    const line_t oldline = CopLINE(PL_curcop);
-                   if (PL_copline != NOLINE)
-                       CopLINE_set(PL_curcop, PL_copline);
+                   if (PL_parser && PL_parser->copline != NOLINE)
+                       CopLINE_set(PL_curcop, PL_parser->copline);
                    Perl_warner(aTHX_ packWARN(WARN_REDEFINE),
                        CvCONST(cv) ? "Constant subroutine %s redefined"
                                    : "Subroutine %s redefined", name);
@@ -5539,7 +5541,8 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
     }
 
   done:
-    PL_copline = NOLINE;
+    if (PL_parser)
+       PL_parser->copline = NOLINE;
     LEAVE_SCOPE(floor);
     return cv;
 }
@@ -5635,7 +5638,7 @@ Perl_newCONSTSUB(pTHX_ HV *stash, const char *name, SV *sv)
     ENTER;
 
     SAVECOPLINE(PL_curcop);
-    CopLINE_set(PL_curcop, PL_copline);
+    CopLINE_set(PL_curcop, PL_parser ? PL_parser->copline : NOLINE);
 
     SAVEHINTS();
     PL_hints &= ~HINT_BLOCK_SCOPE;
@@ -5748,8 +5751,8 @@ Perl_newXS(pTHX_ const char *name, XSUBADDR_t subaddr, const char *filename)
                        const char *redefined_name = HvNAME_get(stash);
                        if ( strEQ(redefined_name,"autouse") ) {
                            const line_t oldline = CopLINE(PL_curcop);
-                           if (PL_copline != NOLINE)
-                               CopLINE_set(PL_curcop, PL_copline);
+                           if (PL_parser && PL_parser->copline != NOLINE)
+                               CopLINE_set(PL_curcop, PL_parser->copline);
                            Perl_warner(aTHX_ packWARN(WARN_REDEFINE),
                                        CvCONST(cv) ? "Constant subroutine %s redefined"
                                                    : "Subroutine %s redefined"
@@ -5815,8 +5818,8 @@ Perl_newFORM(pTHX_ I32 floor, OP *o, OP *block)
     if ((cv = GvFORM(gv))) {
        if (ckWARN(WARN_REDEFINE)) {
            const line_t oldline = CopLINE(PL_curcop);
-           if (PL_copline != NOLINE)
-               CopLINE_set(PL_curcop, PL_copline);
+           if (PL_parser && PL_parser->copline != NOLINE)
+               CopLINE_set(PL_curcop, PL_parser->copline);
            Perl_warner(aTHX_ packWARN(WARN_REDEFINE),
                        o ? "Format %"SVf" redefined"
                        : "Format STDOUT redefined", SVfARG(cSVOPo->op_sv));
@@ -5843,7 +5846,8 @@ Perl_newFORM(pTHX_ I32 floor, OP *o, OP *block)
 #else
     op_free(o);
 #endif
-    PL_copline = NOLINE;
+    if (PL_parser)
+       PL_parser->copline = NOLINE;
     LEAVE_SCOPE(floor);
 #ifdef PERL_MAD
     return pegop;
index f0a1710..847e50a 100644 (file)
--- a/parser.h
+++ b/parser.h
@@ -45,6 +45,7 @@ typedef struct yy_parser {
     U8         lex_defer;      /* state after determined token */
     bool       lex_dojoin;     /* doing an array interpolation */
     U8         lex_expect;     /* expect after determined token */
+    U8         expect;         /* how to interpret ambiguous tokens */
     I32                lex_formbrack;  /* bracket count at outer format level */
     OP         *lex_inpat;     /* in pattern $) and $| are special */
     OP         *lex_op;        /* extra info to pass back on op */
@@ -59,6 +60,7 @@ typedef struct yy_parser {
     bool       preambled;
     SUBLEXINFO sublex_info;
     SV         *linestr;       /* current chunk of src text */
+    line_t     copline;        /* current line number */
 
 #ifdef PERL_MAD
     SV         *endwhite;
index d09fc33..8070abb 100644 (file)
--- a/perlapi.h
+++ b/perlapi.h
@@ -218,8 +218,6 @@ END_EXTERN_C
 #define PL_comppad_name_floor  (*Perl_Icomppad_name_floor_ptr(aTHX))
 #undef  PL_cop_seqmax
 #define PL_cop_seqmax          (*Perl_Icop_seqmax_ptr(aTHX))
-#undef  PL_copline
-#define PL_copline             (*Perl_Icopline_ptr(aTHX))
 #undef  PL_cryptseen
 #define PL_cryptseen           (*Perl_Icryptseen_ptr(aTHX))
 #undef  PL_cshlen
@@ -288,8 +286,6 @@ END_EXTERN_C
 #define PL_exitlist            (*Perl_Iexitlist_ptr(aTHX))
 #undef  PL_exitlistlen
 #define PL_exitlistlen         (*Perl_Iexitlistlen_ptr(aTHX))
-#undef  PL_expect
-#define PL_expect              (*Perl_Iexpect_ptr(aTHX))
 #undef  PL_fdpid
 #define PL_fdpid               (*Perl_Ifdpid_ptr(aTHX))
 #undef  PL_filemode
index 159ebf6..ca93fb8 100644 (file)
--- a/perly.act
+++ b/perly.act
@@ -5,8 +5,8 @@ case 2:
 
   case 3:
 #line 142 "perly.y"
-    { if (PL_copline > (line_t)IVAL((ps[(1) - (4)].val.i_tkval)))
-                             PL_copline = (line_t)IVAL((ps[(1) - (4)].val.i_tkval));
+    { if (PL_parser->copline > (line_t)IVAL((ps[(1) - (4)].val.i_tkval)))
+                             PL_parser->copline = (line_t)IVAL((ps[(1) - (4)].val.i_tkval));
                          (yyval.opval) = block_end((ps[(2) - (4)].val.ival), (ps[(3) - (4)].val.opval));
                          TOKEN_GETMAD((ps[(1) - (4)].val.i_tkval),(yyval.opval),'{');
                          TOKEN_GETMAD((ps[(4) - (4)].val.i_tkval),(yyval.opval),'}');
@@ -26,14 +26,14 @@ case 2:
   case 6:
 #line 159 "perly.y"
     {
-                   PL_expect = XSTATE; (yyval.ival) = block_start(TRUE);
+                   PL_parser->expect = XSTATE; (yyval.ival) = block_start(TRUE);
                ;}
     break;
 
   case 7:
 #line 166 "perly.y"
-    { if (PL_copline > (line_t)IVAL((ps[(1) - (4)].val.i_tkval)))
-                             PL_copline = (line_t)IVAL((ps[(1) - (4)].val.i_tkval));
+    { if (PL_parser->copline > (line_t)IVAL((ps[(1) - (4)].val.i_tkval)))
+                             PL_parser->copline = (line_t)IVAL((ps[(1) - (4)].val.i_tkval));
                          (yyval.opval) = block_end((ps[(2) - (4)].val.ival), (ps[(3) - (4)].val.opval));
                          TOKEN_GETMAD((ps[(1) - (4)].val.i_tkval),(yyval.opval),'{');
                          TOKEN_GETMAD((ps[(4) - (4)].val.i_tkval),(yyval.opval),'}');
@@ -102,11 +102,11 @@ case 2:
                              (yyval.opval) = IF_MAD(
                                        newOP(OP_NULL, 0),
                                        Nullop);
-                              PL_copline = NOLINE;
+                              PL_parser->copline = NOLINE;
                              TOKEN_FREE((ps[(1) - (2)].val.p_tkval));
                              TOKEN_GETMAD((ps[(2) - (2)].val.i_tkval),(yyval.opval),';');
                          }
-                         PL_expect = XSTATE;
+                         PL_parser->expect = XSTATE;
                        ;}
     break;
 
@@ -114,7 +114,7 @@ case 2:
 #line 226 "perly.y"
     {
                          (yyval.opval) = newSTATEOP(0, PVAL((ps[(1) - (3)].val.p_tkval)), (ps[(2) - (3)].val.opval));
-                         PL_expect = XSTATE;
+                         PL_parser->expect = XSTATE;
                          DO_MAD(
                              /* sideff might already have a nexstate */
                              OP* op = ((LISTOP*)(yyval.opval))->op_first;
@@ -189,7 +189,7 @@ case 2:
 
   case 28:
 #line 279 "perly.y"
-    { PL_copline = (line_t)IVAL((ps[(1) - (6)].val.i_tkval));
+    { PL_parser->copline = (line_t)IVAL((ps[(1) - (6)].val.i_tkval));
                            (yyval.opval) = newCONDOP(0, (ps[(3) - (6)].val.opval), scope((ps[(5) - (6)].val.opval)), (ps[(6) - (6)].val.opval));
                            PL_hints |= HINT_BLOCK_SCOPE;
                          TOKEN_GETMAD((ps[(1) - (6)].val.i_tkval),(yyval.opval),'I');
@@ -200,7 +200,7 @@ case 2:
 
   case 29:
 #line 290 "perly.y"
-    { PL_copline = (line_t)IVAL((ps[(1) - (7)].val.i_tkval));
+    { PL_parser->copline = (line_t)IVAL((ps[(1) - (7)].val.i_tkval));
                            (yyval.opval) = block_end((ps[(3) - (7)].val.ival),
                                   newCONDOP(0, (ps[(4) - (7)].val.opval), scope((ps[(6) - (7)].val.opval)), (ps[(7) - (7)].val.opval)));
                          TOKEN_GETMAD((ps[(1) - (7)].val.i_tkval),(yyval.opval),'I');
@@ -211,7 +211,7 @@ case 2:
 
   case 30:
 #line 298 "perly.y"
-    { PL_copline = (line_t)IVAL((ps[(1) - (7)].val.i_tkval));
+    { PL_parser->copline = (line_t)IVAL((ps[(1) - (7)].val.i_tkval));
                            (yyval.opval) = block_end((ps[(3) - (7)].val.ival),
                                   newCONDOP(0, (ps[(4) - (7)].val.opval), scope((ps[(6) - (7)].val.opval)), (ps[(7) - (7)].val.opval)));
                          TOKEN_GETMAD((ps[(1) - (7)].val.i_tkval),(yyval.opval),'I');
@@ -246,7 +246,7 @@ case 2:
   case 35:
 #line 326 "perly.y"
     { OP *innerop;
-                         PL_copline = (line_t)(ps[(2) - (9)].val.i_tkval);
+                         PL_parser->copline = (line_t)(ps[(2) - (9)].val.i_tkval);
                            (yyval.opval) = block_end((ps[(4) - (9)].val.ival),
                                   newSTATEOP(0, PVAL((ps[(1) - (9)].val.p_tkval)),
                                     innerop = newWHILEOP(0, 1, (LOOP*)Nullop,
@@ -261,7 +261,7 @@ case 2:
   case 36:
 #line 339 "perly.y"
     { OP *innerop;
-                         PL_copline = (line_t)(ps[(2) - (9)].val.i_tkval);
+                         PL_parser->copline = (line_t)(ps[(2) - (9)].val.i_tkval);
                            (yyval.opval) = block_end((ps[(4) - (9)].val.ival),
                                   newSTATEOP(0, PVAL((ps[(1) - (9)].val.p_tkval)),
                                     innerop = newWHILEOP(0, 1, (LOOP*)Nullop,
@@ -316,7 +316,7 @@ case 2:
   case 40:
 #line 384 "perly.y"
     { OP *forop;
-                         PL_copline = (line_t)IVAL((ps[(2) - (12)].val.i_tkval));
+                         PL_parser->copline = (line_t)IVAL((ps[(2) - (12)].val.i_tkval));
                          forop = newSTATEOP(0, PVAL((ps[(1) - (12)].val.p_tkval)),
                                            newWHILEOP(0, 1, (LOOP*)Nullop,
                                                IVAL((ps[(2) - (12)].val.i_tkval)), scalar((ps[(7) - (12)].val.opval)),
@@ -356,7 +356,7 @@ case 2:
 
   case 42:
 #line 422 "perly.y"
-    { PL_copline = (line_t) (ps[(2) - (8)].val.i_tkval);
+    { PL_parser->copline = (line_t) (ps[(2) - (8)].val.i_tkval);
                            (yyval.opval) = block_end((ps[(4) - (8)].val.ival),
                                newSTATEOP(0, PVAL((ps[(1) - (8)].val.p_tkval)),
                                    newGIVENOP((ps[(6) - (8)].val.opval), scope((ps[(8) - (8)].val.opval)),
@@ -594,7 +594,7 @@ case 2:
                                    newOP(OP_NULL,0),
                                    Nullop
                                );
-                         PL_expect = XSTATE;
+                         PL_parser->expect = XSTATE;
                          TOKEN_GETMAD((ps[(1) - (1)].val.i_tkval),(yyval.opval),';');
                        ;}
     break;
@@ -772,7 +772,7 @@ case 2:
   case 101:
 #line 769 "perly.y"
     { (yyval.opval) = newBINOP(OP_GELEM, 0, (ps[(1) - (5)].val.opval), scalar((ps[(3) - (5)].val.opval)));
-                           PL_expect = XOPERATOR;
+                           PL_parser->expect = XOPERATOR;
                          TOKEN_GETMAD((ps[(2) - (5)].val.i_tkval),(yyval.opval),'{');
                          TOKEN_GETMAD((ps[(4) - (5)].val.i_tkval),(yyval.opval),';');
                          TOKEN_GETMAD((ps[(5) - (5)].val.i_tkval),(yyval.opval),'}');
@@ -811,7 +811,7 @@ case 2:
   case 105:
 #line 796 "perly.y"
     { (yyval.opval) = newBINOP(OP_HELEM, 0, oopsHV((ps[(1) - (5)].val.opval)), jmaybe((ps[(3) - (5)].val.opval)));
-                           PL_expect = XOPERATOR;
+                           PL_parser->expect = XOPERATOR;
                          TOKEN_GETMAD((ps[(2) - (5)].val.i_tkval),(yyval.opval),'{');
                          TOKEN_GETMAD((ps[(4) - (5)].val.i_tkval),(yyval.opval),';');
                          TOKEN_GETMAD((ps[(5) - (5)].val.i_tkval),(yyval.opval),'}');
@@ -823,7 +823,7 @@ case 2:
     { (yyval.opval) = newBINOP(OP_HELEM, 0,
                                        ref(newHVREF((ps[(1) - (6)].val.opval)),OP_RV2HV),
                                        jmaybe((ps[(4) - (6)].val.opval)));
-                           PL_expect = XOPERATOR;
+                           PL_parser->expect = XOPERATOR;
                          TOKEN_GETMAD((ps[(2) - (6)].val.i_tkval),(yyval.opval),'a');
                          TOKEN_GETMAD((ps[(3) - (6)].val.i_tkval),(yyval.opval),'{');
                          TOKEN_GETMAD((ps[(5) - (6)].val.i_tkval),(yyval.opval),';');
@@ -836,7 +836,7 @@ case 2:
     { (yyval.opval) = newBINOP(OP_HELEM, 0,
                                        ref(newHVREF((ps[(1) - (5)].val.opval)),OP_RV2HV),
                                        jmaybe((ps[(3) - (5)].val.opval)));
-                           PL_expect = XOPERATOR;
+                           PL_parser->expect = XOPERATOR;
                          TOKEN_GETMAD((ps[(2) - (5)].val.i_tkval),(yyval.opval),'{');
                          TOKEN_GETMAD((ps[(4) - (5)].val.i_tkval),(yyval.opval),';');
                          TOKEN_GETMAD((ps[(5) - (5)].val.i_tkval),(yyval.opval),'}');
@@ -1281,7 +1281,7 @@ case 2:
                                    newLISTOP(OP_HSLICE, 0,
                                        list((ps[(3) - (5)].val.opval)),
                                        ref(oopsHV((ps[(1) - (5)].val.opval)), OP_HSLICE)));
-                           PL_expect = XOPERATOR;
+                           PL_parser->expect = XOPERATOR;
                          TOKEN_GETMAD((ps[(2) - (5)].val.i_tkval),(yyval.opval),'{');
                          TOKEN_GETMAD((ps[(4) - (5)].val.i_tkval),(yyval.opval),';');
                          TOKEN_GETMAD((ps[(5) - (5)].val.i_tkval),(yyval.opval),'}');
diff --git a/perly.y b/perly.y
index 5abfa5a..0a857c7 100644 (file)
--- a/perly.y
+++ b/perly.y
@@ -139,8 +139,8 @@ prog        :       progstart
 
 /* An ordinary block */
 block  :       '{' remember lineseq '}'
-                       { if (PL_copline > (line_t)IVAL($1))
-                             PL_copline = (line_t)IVAL($1);
+                       { if (PL_parser->copline > (line_t)IVAL($1))
+                             PL_parser->copline = (line_t)IVAL($1);
                          $$ = block_end($2, $3);
                          TOKEN_GETMAD($1,$$,'{');
                          TOKEN_GETMAD($4,$$,'}');
@@ -157,14 +157,14 @@ mydefsv:  /* NULL */      /* lexicalize $_ */
 
 progstart:
                {
-                   PL_expect = XSTATE; $$ = block_start(TRUE);
+                   PL_parser->expect = XSTATE; $$ = block_start(TRUE);
                }
        ;
 
 
 mblock :       '{' mremember lineseq '}'
-                       { if (PL_copline > (line_t)IVAL($1))
-                             PL_copline = (line_t)IVAL($1);
+                       { if (PL_parser->copline > (line_t)IVAL($1))
+                             PL_parser->copline = (line_t)IVAL($1);
                          $$ = block_end($2, $3);
                          TOKEN_GETMAD($1,$$,'{');
                          TOKEN_GETMAD($4,$$,'}');
@@ -216,16 +216,16 @@ line      :       label cond
                              $$ = IF_MAD(
                                        newOP(OP_NULL, 0),
                                        Nullop);
-                              PL_copline = NOLINE;
+                              PL_parser->copline = NOLINE;
                              TOKEN_FREE($1);
                              TOKEN_GETMAD($2,$$,';');
                          }
-                         PL_expect = XSTATE;
+                         PL_parser->expect = XSTATE;
                        }
        |       label sideff ';'
                        {
                          $$ = newSTATEOP(0, PVAL($1), $2);
-                         PL_expect = XSTATE;
+                         PL_parser->expect = XSTATE;
                          DO_MAD(
                              /* sideff might already have a nexstate */
                              OP* op = ((LISTOP*)$$)->op_first;
@@ -276,7 +276,7 @@ else        :       /* NULL */
                          TOKEN_GETMAD($1,$$,'o');
                        }
        |       ELSIF '(' mexpr ')' mblock else
-                       { PL_copline = (line_t)IVAL($1);
+                       { PL_parser->copline = (line_t)IVAL($1);
                            $$ = newCONDOP(0, $3, scope($5), $6);
                            PL_hints |= HINT_BLOCK_SCOPE;
                          TOKEN_GETMAD($1,$$,'I');
@@ -287,7 +287,7 @@ else        :       /* NULL */
 
 /* Real conditional expressions */
 cond   :       IF '(' remember mexpr ')' mblock else
-                       { PL_copline = (line_t)IVAL($1);
+                       { PL_parser->copline = (line_t)IVAL($1);
                            $$ = block_end($3,
                                   newCONDOP(0, $4, scope($6), $7));
                          TOKEN_GETMAD($1,$$,'I');
@@ -295,7 +295,7 @@ cond        :       IF '(' remember mexpr ')' mblock else
                          TOKEN_GETMAD($5,$$,')');
                        }
        |       UNLESS '(' remember miexpr ')' mblock else
-                       { PL_copline = (line_t)IVAL($1);
+                       { PL_parser->copline = (line_t)IVAL($1);
                            $$ = block_end($3,
                                   newCONDOP(0, $4, scope($6), $7));
                          TOKEN_GETMAD($1,$$,'I');
@@ -324,7 +324,7 @@ cont        :       /* NULL */
 /* Loops: while, until, for, and a bare block */
 loop   :       label WHILE '(' remember texpr ')' mintro mblock cont
                        { OP *innerop;
-                         PL_copline = (line_t)$2;
+                         PL_parser->copline = (line_t)$2;
                            $$ = block_end($4,
                                   newSTATEOP(0, PVAL($1),
                                     innerop = newWHILEOP(0, 1, (LOOP*)Nullop,
@@ -337,7 +337,7 @@ loop        :       label WHILE '(' remember texpr ')' mintro mblock cont
 
        |       label UNTIL '(' remember iexpr ')' mintro mblock cont
                        { OP *innerop;
-                         PL_copline = (line_t)$2;
+                         PL_parser->copline = (line_t)$2;
                            $$ = block_end($4,
                                   newSTATEOP(0, PVAL($1),
                                     innerop = newWHILEOP(0, 1, (LOOP*)Nullop,
@@ -382,7 +382,7 @@ loop        :       label WHILE '(' remember texpr ')' mintro mblock cont
                    mblock
                        /* basically fake up an initialize-while lineseq */
                        { OP *forop;
-                         PL_copline = (line_t)IVAL($2);
+                         PL_parser->copline = (line_t)IVAL($2);
                          forop = newSTATEOP(0, PVAL($1),
                                            newWHILEOP(0, 1, (LOOP*)Nullop,
                                                IVAL($2), scalar($7),
@@ -419,7 +419,7 @@ loop        :       label WHILE '(' remember texpr ')' mintro mblock cont
 
 /* Switch blocks */
 switch :       label GIVEN '(' remember mydefsv mexpr ')' mblock
-                       { PL_copline = (line_t) $2;
+                       { PL_parser->copline = (line_t) $2;
                            $$ = block_end($4,
                                newSTATEOP(0, PVAL($1),
                                    newGIVENOP($6, scope($8),
@@ -621,7 +621,7 @@ subbody     :       block   { $$ = $1; }
                                    newOP(OP_NULL,0),
                                    Nullop
                                );
-                         PL_expect = XSTATE;
+                         PL_parser->expect = XSTATE;
                          TOKEN_GETMAD($1,$$,';');
                        }
        ;
@@ -767,7 +767,7 @@ subscripted:    star '{' expr ';' '}'        /* *main::{something} */
                         /* In this and all the hash accessors, ';' is
                          * provided by the tokeniser */
                        { $$ = newBINOP(OP_GELEM, 0, $1, scalar($3));
-                           PL_expect = XOPERATOR;
+                           PL_parser->expect = XOPERATOR;
                          TOKEN_GETMAD($2,$$,'{');
                          TOKEN_GETMAD($4,$$,';');
                          TOKEN_GETMAD($5,$$,'}');
@@ -794,7 +794,7 @@ subscripted:    star '{' expr ';' '}'        /* *main::{something} */
                        }
        |       scalar '{' expr ';' '}'    /* $foo->{bar();} */
                        { $$ = newBINOP(OP_HELEM, 0, oopsHV($1), jmaybe($3));
-                           PL_expect = XOPERATOR;
+                           PL_parser->expect = XOPERATOR;
                          TOKEN_GETMAD($2,$$,'{');
                          TOKEN_GETMAD($4,$$,';');
                          TOKEN_GETMAD($5,$$,'}');
@@ -803,7 +803,7 @@ subscripted:    star '{' expr ';' '}'        /* *main::{something} */
                        { $$ = newBINOP(OP_HELEM, 0,
                                        ref(newHVREF($1),OP_RV2HV),
                                        jmaybe($4));
-                           PL_expect = XOPERATOR;
+                           PL_parser->expect = XOPERATOR;
                          TOKEN_GETMAD($2,$$,'a');
                          TOKEN_GETMAD($3,$$,'{');
                          TOKEN_GETMAD($5,$$,';');
@@ -813,7 +813,7 @@ subscripted:    star '{' expr ';' '}'        /* *main::{something} */
                        { $$ = newBINOP(OP_HELEM, 0,
                                        ref(newHVREF($1),OP_RV2HV),
                                        jmaybe($3));
-                           PL_expect = XOPERATOR;
+                           PL_parser->expect = XOPERATOR;
                          TOKEN_GETMAD($2,$$,'{');
                          TOKEN_GETMAD($4,$$,';');
                          TOKEN_GETMAD($5,$$,'}');
@@ -1121,7 +1121,7 @@ term      :       termbinop
                                    newLISTOP(OP_HSLICE, 0,
                                        list($3),
                                        ref(oopsHV($1), OP_HSLICE)));
-                           PL_expect = XOPERATOR;
+                           PL_parser->expect = XOPERATOR;
                          TOKEN_GETMAD($2,$$,'{');
                          TOKEN_GETMAD($4,$$,';');
                          TOKEN_GETMAD($5,$$,'}');
diff --git a/sv.c b/sv.c
index 0de5bb1..d989731 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -246,8 +246,8 @@ S_new_SV(pTHX)
     SvREFCNT(sv) = 1;
     SvFLAGS(sv) = 0;
     sv->sv_debug_optype = PL_op ? PL_op->op_type : 0;
-    sv->sv_debug_line = (U16) ((PL_copline == NOLINE) ?
-        (PL_curcop ? CopLINE(PL_curcop) : 0) : PL_copline);
+    sv->sv_debug_line = (U16) ((PL_parser && PL_parser->copline == NOLINE) ?
+        (PL_curcop ? CopLINE(PL_curcop) : 0) : PL_parser->copline);
     sv->sv_debug_inpad = 0;
     sv->sv_debug_cloned = 0;
     sv->sv_debug_file = PL_curcop ? savepv(CopFILE(PL_curcop)): NULL;
@@ -9572,6 +9572,9 @@ Perl_parser_dup(pTHX_ const yy_parser *proto, CLONE_PARAMS* param)
     parser->preambled  = proto->preambled;
     parser->sublex_info        = proto->sublex_info; /* XXX not quite right */
     parser->linestr    = sv_dup_inc(proto->linestr, param);
+    parser->expect     = proto->expect;
+    parser->copline    = proto->copline;
+
 
 #ifdef PERL_MAD
     parser->endwhite   = proto->endwhite;
@@ -11137,7 +11140,6 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
 
     /* runtime control stuff */
     PL_curcopdb                = (COP*)any_dup(proto_perl->Icurcopdb, proto_perl);
-    PL_copline         = proto_perl->Icopline;
 
     PL_filemode                = proto_perl->Ifilemode;
     PL_lastfd          = proto_perl->Ilastfd;
@@ -11253,8 +11255,6 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
        PL_last_lop             = SvPVX(PL_parser->linestr) + (i < 0 ? 0 : i);
     }
 
-    PL_expect          = proto_perl->Iexpect;
-
     PL_multi_end       = proto_perl->Imulti_end;
 
     PL_error_count     = proto_perl->Ierror_count;