From: Dave Mitchell Date: Sat, 12 May 2007 22:17:40 +0000 (+0000) Subject: move PL_in_my and PL_in_my_stash into the PL_parser struct X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=12bd6ede29d13c215438daf78d15695e487886b0;p=p5sagit%2Fp5-mst-13.2.git move PL_in_my and PL_in_my_stash into the PL_parser struct p4raw-id: //depot/perl@31203 --- diff --git a/embedvar.h b/embedvar.h index ba97800..99f0864 100644 --- a/embedvar.h +++ b/embedvar.h @@ -218,8 +218,6 @@ #define PL_in_clean_all (vTHX->Iin_clean_all) #define PL_in_clean_objs (vTHX->Iin_clean_objs) #define PL_in_load_module (vTHX->Iin_load_module) -#define PL_in_my (vTHX->Iin_my) -#define PL_in_my_stash (vTHX->Iin_my_stash) #define PL_incgv (vTHX->Iincgv) #define PL_initav (vTHX->Iinitav) #define PL_inplace (vTHX->Iinplace) @@ -466,8 +464,6 @@ #define PL_Iin_clean_all PL_in_clean_all #define PL_Iin_clean_objs PL_in_clean_objs #define PL_Iin_load_module PL_in_load_module -#define PL_Iin_my PL_in_my -#define PL_Iin_my_stash PL_in_my_stash #define PL_Iincgv PL_incgv #define PL_Iinitav PL_initav #define PL_Iinplace PL_inplace diff --git a/intrpvar.h b/intrpvar.h index fbbe64f..2bb2f88 100644 --- a/intrpvar.h +++ b/intrpvar.h @@ -189,7 +189,6 @@ PERLVAR(Imess_sv, SV *) PERLVAR(Iors_sv, SV *) /* output record separator $\ */ /* statics moved here for shared library purposes */ PERLVARI(Igensym, I32, 0) /* next symbol for getsym() to define */ -PERLVAR(Iin_my, U16) /* we're compiling a "my" (or "our") declaration */ PERLVARI(Ilaststype, U16, OP_STAT) PERLVARI(Ilaststatval, int, -1) @@ -300,8 +299,6 @@ PERLVAR(Ipadix, I32) /* max used index in current "register" pad */ PERLVAR(Ipadix_floor, I32) /* how low may inner block reset padix */ PERLVAR(Ipad_reset_pending, I32) /* reset pad on next attempted alloc */ -PERLVAR(Iin_my_stash, HV *) /* declared class of this "my" declaration */ - PERLVAR(Ihints, U32) /* pragma-tic compile-time flags */ PERLVAR(Idebug, VOL U32) /* flags given to -D switch */ diff --git a/op.c b/op.c index e679ecb..481bf3e 100644 --- a/op.c +++ b/op.c @@ -352,7 +352,7 @@ Perl_allocmy(pTHX_ const char *const name) { dVAR; PADOFFSET off; - const bool is_our = (PL_in_my == KEY_our); + const bool is_our = (PL_parser->in_my == KEY_our); /* complain about "my $" etc etc */ if (*name && @@ -373,24 +373,25 @@ Perl_allocmy(pTHX_ const char *const name) /* check for duplicate declaration */ pad_check_dup(name, is_our, (PL_curstash ? PL_curstash : PL_defstash)); - if (PL_in_my_stash && *name != '$') { + if (PL_parser->in_my_stash && *name != '$') { yyerror(Perl_form(aTHX_ "Can't declare class for non-scalar %s in \"%s\"", name, - is_our ? "our" : PL_in_my == KEY_state ? "state" : "my")); + is_our ? "our" + : PL_parser->in_my == KEY_state ? "state" : "my")); } /* allocate a spare slot and store the name in that slot */ off = pad_add_name(name, - PL_in_my_stash, + PL_parser->in_my_stash, (is_our /* $_ is always in main::, even with our */ ? (PL_curstash && !strEQ(name,"$_") ? PL_curstash : PL_defstash) : NULL ), 0, /* not fake */ - PL_in_my == KEY_state + PL_parser->in_my == KEY_state ); return off; } @@ -1969,11 +1970,13 @@ S_my_kid(pTHX_ OP *o, OP *attrs, OP **imopsp) if (cUNOPo->op_first->op_type != OP_GV) { /* MJD 20011224 */ yyerror(Perl_form(aTHX_ "Can't declare %s in \"%s\"", OP_DESC(o), - PL_in_my == KEY_our ? "our" : PL_in_my == KEY_state ? "state" : "my")); + PL_parser->in_my == KEY_our + ? "our" + : PL_parser->in_my == KEY_state ? "state" : "my")); } else if (attrs) { GV * const gv = cGVOPx_gv(cUNOPo->op_first); - PL_in_my = FALSE; - PL_in_my_stash = NULL; + PL_parser->in_my = FALSE; + PL_parser->in_my_stash = NULL; apply_attrs(GvSTASH(gv), (type == OP_RV2SV ? GvSV(gv) : type == OP_RV2AV ? (SV*)GvAV(gv) : @@ -1990,14 +1993,16 @@ S_my_kid(pTHX_ OP *o, OP *attrs, OP **imopsp) { yyerror(Perl_form(aTHX_ "Can't declare %s in \"%s\"", OP_DESC(o), - PL_in_my == KEY_our ? "our" : PL_in_my == KEY_state ? "state" : "my")); + PL_parser->in_my == KEY_our + ? "our" + : PL_parser->in_my == KEY_state ? "state" : "my")); return o; } else if (attrs && type != OP_PUSHMARK) { HV *stash; - PL_in_my = FALSE; - PL_in_my_stash = NULL; + PL_parser->in_my = FALSE; + PL_parser->in_my_stash = NULL; /* check for C when deciding package */ stash = PAD_COMPNAME_TYPE(o->op_targ); @@ -2007,7 +2012,7 @@ S_my_kid(pTHX_ OP *o, OP *attrs, OP **imopsp) } o->op_flags |= OPf_MOD; o->op_private |= OPpLVAL_INTRO; - if (PL_in_my == KEY_state) + if (PL_parser->in_my == KEY_state) o->op_private |= OPpPAD_STATE; return o; } @@ -2041,8 +2046,8 @@ Perl_my_attrs(pTHX_ OP *o, OP *attrs) else o = append_list(OP_LIST, (LISTOP*)o, (LISTOP*)rops); } - PL_in_my = FALSE; - PL_in_my_stash = NULL; + PL_parser->in_my = FALSE; + PL_parser->in_my_stash = NULL; return o; } @@ -2287,8 +2292,13 @@ Perl_localize(pTHX_ OP *o, I32 lex) if (sigil && (*s == ';' || *s == '=')) { Perl_warner(aTHX_ packWARN(WARN_PARENTHESIS), "Parentheses missing around \"%s\" list", - lex ? (PL_in_my == KEY_our ? "our" : PL_in_my == KEY_state ? "state" : "my") - : "local"); + lex + ? (PL_parser->in_my == KEY_our + ? "our" + : PL_parser->in_my == KEY_state + ? "state" + : "my") + : "local"); } } } @@ -2296,8 +2306,8 @@ Perl_localize(pTHX_ OP *o, I32 lex) o = my(o); else o = mod(o, OP_NULL); /* a bit kludgey */ - PL_in_my = FALSE; - PL_in_my_stash = NULL; + PL_parser->in_my = FALSE; + PL_parser->in_my_stash = NULL; return o; } diff --git a/pad.c b/pad.c index 1e0217c..51592d0 100644 --- a/pad.c +++ b/pad.c @@ -550,7 +550,7 @@ Perl_pad_check_dup(pTHX_ const char *name, bool is_our, const HV *ourstash) break; /* "our" masking "our" */ Perl_warner(aTHX_ packWARN(WARN_MISC), "\"%s\" variable %s masks earlier declaration in same %s", - (is_our ? "our" : PL_in_my == KEY_my ? "my" : "state"), + (is_our ? "our" : PL_parser->in_my == KEY_my ? "my" : "state"), name, (COP_SEQ_RANGE_HIGH(sv) == PAD_MAX ? "scope" : "statement")); --off; diff --git a/parser.h b/parser.h index affe7be..f481cac 100644 --- a/parser.h +++ b/parser.h @@ -61,7 +61,6 @@ typedef struct yy_parser { bool preambled; SUBLEXINFO sublex_info; SV *linestr; /* current chunk of src text */ - line_t copline; /* current line number */ char *bufptr; char *oldbufptr; char *oldoldbufptr; @@ -69,7 +68,11 @@ typedef struct yy_parser { char *linestart; /* beginning of most recently read line */ char *last_uni; /* position of last named-unary op */ char *last_lop; /* position of last list operator */ + line_t copline; /* current line number */ + U16 in_my; /* we're compiling a "my"/"our" declaration */ U8 lex_state; /* next token is determined */ + /* space for a U8 here */ + HV *in_my_stash; /* declared class of this "my" declaration */ PerlIO *rsfp; /* current source file pointer */ AV *rsfp_filters; /* holds chain of active source filters */ diff --git a/perlapi.h b/perlapi.h index a4600d8..9888ed7 100644 --- a/perlapi.h +++ b/perlapi.h @@ -312,10 +312,6 @@ END_EXTERN_C #define PL_in_clean_objs (*Perl_Iin_clean_objs_ptr(aTHX)) #undef PL_in_load_module #define PL_in_load_module (*Perl_Iin_load_module_ptr(aTHX)) -#undef PL_in_my -#define PL_in_my (*Perl_Iin_my_ptr(aTHX)) -#undef PL_in_my_stash -#define PL_in_my_stash (*Perl_Iin_my_stash_ptr(aTHX)) #undef PL_incgv #define PL_incgv (*Perl_Iincgv_ptr(aTHX)) #undef PL_initav diff --git a/perly.act b/perly.act index 294194b..3cdae59 100644 --- a/perly.act +++ b/perly.act @@ -1535,7 +1535,7 @@ case 2: case 200: #line 1293 "perly.y" - { PL_in_my = 0; (yyval.opval) = my((ps[(1) - (1)].val.opval)); ;} + { PL_parser->in_my = 0; (yyval.opval) = my((ps[(1) - (1)].val.opval)); ;} break; case 201: diff --git a/perly.y b/perly.y index 40836be..33b269a 100644 --- a/perly.y +++ b/perly.y @@ -1290,7 +1290,7 @@ listexprcom: /* NULL */ /* A little bit of trickery to make "for my $foo (@bar)" actually be lexical */ my_scalar: scalar - { PL_in_my = 0; $$ = my($1); } + { PL_parser->in_my = 0; $$ = my($1); } ; amper : '&' indirob diff --git a/sv.c b/sv.c index f2c2147..6f526b2 100644 --- a/sv.c +++ b/sv.c @@ -9579,6 +9579,8 @@ Perl_parser_dup(pTHX_ const yy_parser *proto, CLONE_PARAMS* param) parser->rsfp = fp_dup(proto->rsfp, '<', param); /* rsfp_filters entries have fake IoDIRP() */ parser->rsfp_filters= av_dup_inc(proto->rsfp_filters, param); + parser->in_my = proto->in_my; + parser->in_my_stash = hv_dup(proto->in_my_stash, param); parser->linestr = sv_dup_inc(proto->linestr, param); @@ -11266,8 +11268,6 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, PL_subline = proto_perl->Isubline; PL_subname = sv_dup_inc(proto_perl->Isubname, param); - PL_in_my = proto_perl->Iin_my; - PL_in_my_stash = hv_dup(proto_perl->Iin_my_stash, param); #ifdef FCRYPT PL_cryptseen = proto_perl->Icryptseen; #endif diff --git a/toke.c b/toke.c index efa2e10..46862bf 100644 --- a/toke.c +++ b/toke.c @@ -63,6 +63,8 @@ #define PL_lex_state (PL_parser->lex_state) #define PL_rsfp (PL_parser->rsfp) #define PL_rsfp_filters (PL_parser->rsfp_filters) +#define PL_in_my (PL_parser->in_my) +#define PL_in_my_stash (PL_parser->in_my_stash) #ifdef PERL_MAD # define PL_endwhite (PL_parser->endwhite) diff --git a/utf8.c b/utf8.c index b44057c..e6cbd48 100644 --- a/utf8.c +++ b/utf8.c @@ -1595,9 +1595,6 @@ Perl_swash_init(pTHX_ const char* pkg, const char* name, SV *listsv, I32 minbits PUSHs(sv_2mortal(newSViv(none))); PUTBACK; if (IN_PERL_COMPILETIME) { - /* XXX ought to be handled by lex_start */ - SAVEI16(PL_in_my); - PL_in_my = 0; sv_setpv(tokenbufsv, PL_tokenbuf); } errsv_save = newSVsv(ERRSV);