diff options
author | Dave Mitchell <davem@fdisolutions.com> | 2007-05-04 00:41:51 +0000 |
---|---|---|
committer | Dave Mitchell <davem@fdisolutions.com> | 2007-05-04 00:41:51 +0000 |
commit | 53a7735b62aee14640bc8ca619b4267f07d686b9 (patch) | |
tree | eb7cf7f4d631f6b83cd24d9c98ce0cc2821df29f /op.c | |
parent | d932daed4961bf485d739adcee3fa2136d8ca8ca (diff) | |
download | perl-53a7735b62aee14640bc8ca619b4267f07d686b9.tar.gz |
move PL_expect and PL_copline into the PL_parser structure
p4raw-id: //depot/perl@31134
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 68 |
1 files changed, 36 insertions, 32 deletions
@@ -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; |