From: Nicholas Clark Date: Sun, 2 Apr 2006 10:08:04 +0000 (+0000) Subject: Abstract all the accesses to cop_arybase (apart from ByteLoader) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fc15ae8fb67c31ee845fb33ce00b1c24c4c1a908;p=p5sagit%2Fp5-mst-13.2.git Abstract all the accesses to cop_arybase (apart from ByteLoader) p4raw-id: //depot/perl@27671 --- diff --git a/cop.h b/cop.h index 8ce6b3e..da9fd5b 100644 --- a/cop.h +++ b/cop.h @@ -229,6 +229,11 @@ struct cop { # define OutCopFILE(c) CopFILE(c) #endif +/* CopARYBASE is likely to be removed soon. */ +#define CopARYBASE(c) ((c)->cop_arybase) +#define CopARYBASE_get(c) ((c)->cop_arybase + 0) +#define CopARYBASE_set(c, b) STMT_START { (c)->cop_arybase = (b); } STMT_END + /* * Here we have some enormously heavy (or at least ponderous) wizardry. */ diff --git a/ext/B/B.xs b/ext/B/B.xs index 23034c1..d1a3d7a 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -1057,7 +1057,7 @@ LOOP_lastop(o) #define COP_file(o) CopFILE(o) #define COP_filegv(o) CopFILEGV(o) #define COP_cop_seq(o) o->cop_seq -#define COP_arybase(o) o->cop_arybase +#define COP_arybase(o) CopARYBASE_get(o) #define COP_line(o) CopLINE(o) #define COP_warnings(o) o->cop_warnings #define COP_io(o) o->cop_io diff --git a/mg.c b/mg.c index d8f4e0e..91bf38c 100644 --- a/mg.c +++ b/mg.c @@ -963,7 +963,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) case '/': break; case '[': - WITH_THR(sv_setiv(sv, (IV)PL_curcop->cop_arybase)); + WITH_THR(sv_setiv(sv, (IV)CopARYBASE_get(PL_curcop))); break; case '|': if (GvIOp(PL_defoutgv)) @@ -1724,7 +1724,7 @@ Perl_magic_getarylen(pTHX_ SV *sv, const MAGIC *mg) dVAR; const AV * const obj = (AV*)mg->mg_obj; if (obj) { - sv_setiv(sv, AvFILL(obj) + PL_curcop->cop_arybase); + sv_setiv(sv, AvFILL(obj) + CopARYBASE_get(PL_curcop)); } else { SvOK_off(sv); } @@ -1737,7 +1737,7 @@ Perl_magic_setarylen(pTHX_ SV *sv, MAGIC *mg) dVAR; AV * const obj = (AV*)mg->mg_obj; if (obj) { - av_fill(obj, SvIV(sv) - PL_curcop->cop_arybase); + av_fill(obj, SvIV(sv) - CopARYBASE_get(PL_curcop)); } else { if (ckWARN(WARN_MISC)) Perl_warner(aTHX_ packWARN(WARN_MISC), @@ -1780,7 +1780,7 @@ Perl_magic_getpos(pTHX_ SV *sv, MAGIC *mg) I32 i = mg->mg_len; if (DO_UTF8(lsv)) sv_pos_b2u(lsv, &i); - sv_setiv(sv, i + PL_curcop->cop_arybase); + sv_setiv(sv, i + CopARYBASE_get(PL_curcop)); return 0; } } @@ -1817,7 +1817,7 @@ Perl_magic_setpos(pTHX_ SV *sv, MAGIC *mg) } len = SvPOK(lsv) ? SvCUR(lsv) : sv_len(lsv); - pos = SvIV(sv) - PL_curcop->cop_arybase; + pos = SvIV(sv) - CopARYBASE_get(PL_curcop); if (DO_UTF8(lsv)) { ulen = sv_len_utf8(lsv); @@ -2358,7 +2358,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) } break; case '[': - PL_compiling.cop_arybase = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv); + CopARYBASE_set(&PL_compiling, SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv)); break; case '?': #ifdef COMPLEX_STATUS diff --git a/op.c b/op.c index 31b8e8d..130daf9 100644 --- a/op.c +++ b/op.c @@ -1103,12 +1103,13 @@ Perl_mod(pTHX_ OP *o, I32 type) goto nomod; localize = 0; if (PL_eval_start && PL_eval_start->op_type == OP_CONST) { - PL_compiling.cop_arybase = (I32)SvIV(cSVOPx(PL_eval_start)->op_sv); + CopARYBASE_set(&PL_compiling, + (I32)SvIV(cSVOPx(PL_eval_start)->op_sv)); PL_eval_start = 0; } else if (!type) { - SAVEI32(PL_compiling.cop_arybase); - PL_compiling.cop_arybase = 0; + SAVECOPARYBASE(&PL_compiling); + CopARYBASE_set(&PL_compiling, 0); } else if (type == OP_REFGEN) goto nomod; @@ -3906,7 +3907,7 @@ Perl_newASSIGNOP(pTHX_ I32 flags, OP *left, I32 optype, OP *right) else { /* FIXME for MAD */ op_free(o); - o = newSVOP(OP_CONST, 0, newSViv(PL_compiling.cop_arybase)); + o = newSVOP(OP_CONST, 0, newSViv(CopARYBASE_get(&PL_compiling))); o->op_private |= OPpCONST_ARYBASE; } } @@ -3942,7 +3943,7 @@ Perl_newSTATEOP(pTHX_ I32 flags, char *label, OP *o) PL_hints |= HINT_BLOCK_SCOPE; } cop->cop_seq = seq; - cop->cop_arybase = PL_curcop->cop_arybase; + CopARYBASE_set(cop, CopARYBASE_get(PL_curcop)); if (specialWARN(PL_curcop->cop_warnings)) cop->cop_warnings = PL_curcop->cop_warnings ; else @@ -7648,7 +7649,7 @@ Perl_peep(pTHX_ register OP *o) pop->op_next->op_type == OP_AELEM && !(pop->op_next->op_private & (OPpLVAL_INTRO|OPpLVAL_DEFER|OPpDEREF|OPpMAYBE_LVSUB)) && - (i = SvIV(((SVOP*)pop)->op_sv) - PL_curcop->cop_arybase) + (i = SvIV(((SVOP*)pop)->op_sv) - CopARYBASE_get(PL_curcop)) <= 255 && i >= 0) { diff --git a/pp.c b/pp.c index 0a99184..eef2f03 100644 --- a/pp.c +++ b/pp.c @@ -334,7 +334,7 @@ PP(pp_pos) I32 i = mg->mg_len; if (DO_UTF8(sv)) sv_pos_b2u(sv, &i); - PUSHi(i + PL_curcop->cop_arybase); + PUSHi(i + CopARYBASE_get(PL_curcop)); RETURN; } } @@ -2923,7 +2923,7 @@ PP(pp_substr) I32 fail; const I32 lvalue = PL_op->op_flags & OPf_MOD || LVRET; const char *tmps; - const I32 arybase = PL_curcop->cop_arybase; + const I32 arybase = CopARYBASE_get(PL_curcop); SV *repl_sv = NULL; const char *repl = NULL; STRLEN repl_len; @@ -3124,7 +3124,7 @@ PP(pp_index) I32 retval; const char *tmps; const char *tmps2; - const I32 arybase = PL_curcop->cop_arybase; + const I32 arybase = CopARYBASE_get(PL_curcop); bool big_utf8; bool little_utf8; const bool is_index = PL_op->op_type == OP_INDEX; @@ -3673,7 +3673,7 @@ PP(pp_aslice) register const I32 lval = (PL_op->op_flags & OPf_MOD || LVRET); if (SvTYPE(av) == SVt_PVAV) { - const I32 arybase = PL_curcop->cop_arybase; + const I32 arybase = CopARYBASE_get(PL_curcop); if (lval && PL_op->op_private & OPpLVAL_INTRO) { register SV **svp; I32 max = -1; @@ -3926,7 +3926,7 @@ PP(pp_lslice) SV ** const lastlelem = PL_stack_base + POPMARK; SV ** const firstlelem = PL_stack_base + POPMARK + 1; register SV ** const firstrelem = lastlelem + 1; - const I32 arybase = PL_curcop->cop_arybase; + const I32 arybase = CopARYBASE_get(PL_curcop); I32 is_something_there = PL_op->op_flags & OPf_MOD; register const I32 max = lastrelem - lastlelem; @@ -4034,7 +4034,7 @@ PP(pp_splice) if (offset < 0) offset += AvFILLp(ary) + 1; else - offset -= PL_curcop->cop_arybase; + offset -= CopARYBASE_get(PL_curcop); if (offset < 0) DIE(aTHX_ PL_no_aelem, i); if (++MARK < SP) { diff --git a/pp_ctl.c b/pp_ctl.c index 1fcbbac..4b099d4 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -2925,7 +2925,7 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq) PL_eval_root = NULL; PL_error_count = 0; PL_curcop = &PL_compiling; - PL_curcop->cop_arybase = 0; + CopARYBASE_set(PL_curcop, 0); if (saveop && (saveop->op_type != OP_REQUIRE) && (saveop->op_flags & OPf_SPECIAL)) PL_in_eval |= EVAL_KEEPERR; else diff --git a/pp_hot.c b/pp_hot.c index 9edf122..8cb2364 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -2939,7 +2939,7 @@ PP(pp_aelem) if (SvROK(elemsv) && !SvGAMAGIC(elemsv) && ckWARN(WARN_MISC)) Perl_warner(aTHX_ packWARN(WARN_MISC), "Use of reference \"%"SVf"\" as array index", elemsv); if (elem > 0) - elem -= PL_curcop->cop_arybase; + elem -= CopARYBASE_get(PL_curcop); if (SvTYPE(av) != SVt_PVAV) RETPUSHUNDEF; svp = av_fetch(av, elem, lval && !defer); diff --git a/scope.c b/scope.c index b4ecd65..0070f63 100644 --- a/scope.c +++ b/scope.c @@ -981,6 +981,11 @@ Perl_leave_scope(pTHX_ I32 base) ptr = SSPOPPTR; (*SSPOPDPTR)(ptr); break; + case SAVEt_COP_ARYBASE: + ptr = SSPOPPTR; + i = SSPOPINT; + CopARYBASE_set((COP *)ptr, i); + break; default: Perl_croak(aTHX_ "panic: leave_scope inconsistency"); } diff --git a/scope.h b/scope.h index 74ab22b..50fd752 100644 --- a/scope.h +++ b/scope.h @@ -49,6 +49,7 @@ #define SAVEt_BOOL 38 #define SAVEt_SET_SVFLAGS 39 #define SAVEt_SAVESWITCHSTACK 40 +#define SAVEt_COP_ARYBASE 41 #ifndef SCOPE_SAVES_SIGNAL_MASK #define SCOPE_SAVES_SIGNAL_MASK 0 @@ -180,6 +181,15 @@ Closing bracket on a callback. See C and L. PL_curstackinfo->si_stack = (t); \ } STMT_END +#define SAVECOPARYBASE(c) \ + STMT_START { \ + SSCHECK(3); \ + SSPUSHINT(CopARYBASE_get(c)); \ + SSPUSHPTR(c); \ + SSPUSHINT(SAVEt_COP_ARYBASE); \ + } STMT_END + + #ifdef USE_ITHREADS # define SAVECOPSTASH(c) SAVEPPTR(CopSTASHPV(c)) # define SAVECOPSTASH_FREE(c) SAVESHAREDPV(CopSTASHPV(c)) diff --git a/toke.c b/toke.c index c7a9d91..f6e21a2 100644 --- a/toke.c +++ b/toke.c @@ -4555,7 +4555,7 @@ Perl_yylex(pTHX) /* This kludge not intended to be bulletproof. */ if (PL_tokenbuf[1] == '[' && !PL_tokenbuf[2]) { yylval.opval = newSVOP(OP_CONST, 0, - newSViv(PL_compiling.cop_arybase)); + newSViv(CopARYBASE_get(&PL_compiling))); yylval.opval->op_private = OPpCONST_ARYBASE; TERM(THING); }