From: Nicholas Clark Date: Thu, 23 Feb 2006 23:45:39 +0000 (+0000) Subject: Replace direct flags tests & manipulations for SVpad_TYPED and X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=00b1698f76403476df2006ff536ab00ffc650220;p=p5sagit%2Fp5-mst-13.2.git Replace direct flags tests & manipulations for SVpad_TYPED and SVpad_OUR with macros SvPAD_TYPED(), SvPAD_OUR() etc, to abstract away the flags bits acutally used to store this information. p4raw-id: //depot/perl@27294 --- diff --git a/XSUB.h b/XSUB.h index 9d4aae6..9f881a2 100644 --- a/XSUB.h +++ b/XSUB.h @@ -150,7 +150,7 @@ is a lexical $_ in scope. #define dUNDERBAR I32 padoff_du = find_rundefsvoffset() #define UNDERBAR ((padoff_du == NOT_IN_PAD \ - || PAD_COMPNAME_FLAGS(padoff_du) & SVpad_OUR) \ + || PAD_COMPNAME_FLAGS_isOUR(padoff_du)) \ ? DEFSV : PAD_SVl(padoff_du)) /* Simple macros to put new mortal values onto the stack. */ diff --git a/dump.c b/dump.c index 880bbae..b63ad5c 100644 --- a/dump.c +++ b/dump.c @@ -1176,7 +1176,8 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo if (GvUNIQUE(sv)) sv_catpv(d, "UNIQUE,"); if (GvASSUMECV(sv)) sv_catpv(d, "ASSUMECV,"); if (GvIN_PAD(sv)) sv_catpv(d, "IN_PAD,"); - if (flags & SVpad_OUR) sv_catpv(d, "OUR,"); + if (SvPAD_OUR(sv)) sv_catpv(d, "OUR,"); + if (SvPAD_TYPED(sv)) sv_catpv(d, "TYPED,"); if (GvIMPORTED(sv)) { sv_catpv(d, "IMPORT"); if (GvIMPORTED(sv) == GVf_IMPORTED) @@ -1200,8 +1201,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo if (SvVALID(sv)) sv_catpv(d, "VALID,"); break; case SVt_PVMG: - if (flags & SVpad_TYPED) - sv_catpv(d, "TYPED,"); + if (SvPAD_TYPED(sv)) sv_catpv(d, "TYPED,"); break; case SVt_PVAV: break; diff --git a/op.c b/op.c index 591ffa7..62b0ca2 100644 --- a/op.c +++ b/op.c @@ -1933,7 +1933,7 @@ S_newDEFSVOP(pTHX) { dVAR; const I32 offset = pad_findmy("$_"); - if (offset == NOT_IN_PAD || PAD_COMPNAME_FLAGS(offset) & SVpad_OUR) { + if (offset == NOT_IN_PAD || PAD_COMPNAME_FLAGS_isOUR(offset)) { return newSVREF(newGVOP(OP_GV, 0, PL_defgv)); } else { @@ -3976,7 +3976,7 @@ Perl_newFOROP(pTHX_ I32 flags, char *label, line_t forline, OP *sv, OP *expr, OP } else { const I32 offset = pad_findmy("$_"); - if (offset == NOT_IN_PAD || PAD_COMPNAME_FLAGS(offset) & SVpad_OUR) { + if (offset == NOT_IN_PAD || PAD_COMPNAME_FLAGS_isOUR(offset)) { sv = newGVOP(OP_GV, 0, PL_defgv); } else { @@ -5895,7 +5895,7 @@ Perl_ck_grep(pTHX_ OP *o) gwop->op_other = LINKLIST(kid); kid->op_next = (OP*)gwop; offset = pad_findmy("$_"); - if (offset == NOT_IN_PAD || PAD_COMPNAME_FLAGS(offset) & SVpad_OUR) { + if (offset == NOT_IN_PAD || PAD_COMPNAME_FLAGS_isOUR(offset)) { o->op_private = gwop->op_private = 0; gwop->op_targ = pad_alloc(type, SVs_PADTMP); } @@ -6089,7 +6089,7 @@ Perl_ck_match(pTHX_ OP *o) dVAR; if (o->op_type != OP_QR && PL_compcv) { const I32 offset = pad_findmy("$_"); - if (offset != NOT_IN_PAD && !(PAD_COMPNAME_FLAGS(offset) & SVpad_OUR)) { + if (offset != NOT_IN_PAD && !(PAD_COMPNAME_FLAGS_isOUR(offset))) { o->op_targ = offset; o->op_private |= OPpTARGET_MY; } @@ -7112,7 +7112,7 @@ Perl_peep(pTHX_ register OP *o) if (rop->op_type != OP_RV2HV || rop->op_first->op_type != OP_PADSV) break; lexname = *av_fetch(PL_comppad_name, rop->op_first->op_targ, TRUE); - if (!(SvFLAGS(lexname) & SVpad_TYPED)) + if (!SvPAD_TYPED(lexname)) break; fields = (GV**)hv_fetchs(SvSTASH(lexname), "FIELDS", FALSE); if (!fields || !GvHV(*fields)) @@ -7161,7 +7161,7 @@ Perl_peep(pTHX_ register OP *o) } lexname = *av_fetch(PL_comppad_name, rop->op_targ, TRUE); - if (!(SvFLAGS(lexname) & SVpad_TYPED)) + if (!SvPAD_TYPED(lexname)) break; fields = (GV**)hv_fetchs(SvSTASH(lexname), "FIELDS", FALSE); if (!fields || !GvHV(*fields)) diff --git a/pad.c b/pad.c index 75f0838..880902d 100644 --- a/pad.c +++ b/pad.c @@ -342,11 +342,11 @@ Perl_pad_add_name(pTHX_ const char *name, HV* typestash, HV* ourstash, bool fake sv_setpv(namesv, name); if (typestash) { - SvFLAGS(namesv) |= SVpad_TYPED; + SvPAD_TYPED_on(namesv); SvSTASH_set(namesv, (HV*)SvREFCNT_inc((SV*) typestash)); } if (ourstash) { - SvFLAGS(namesv) |= SVpad_OUR; + SvPAD_OUR_on(namesv); GvSTASH(namesv) = ourstash; Perl_sv_add_backref(aTHX_ (SV*)ourstash, namesv); } @@ -530,7 +530,7 @@ Perl_pad_check_dup(pTHX_ const char *name, bool is_our, const HV *ourstash) && (SvIVX(sv) == PAD_MAX || SvIVX(sv) == 0) && strEQ(name, SvPVX_const(sv))) { - if (is_our && (SvFLAGS(sv) & SVpad_OUR)) + if (is_our && (SvPAD_OUR(sv))) break; /* "our" masking "our" */ Perl_warner(aTHX_ packWARN(WARN_MISC), "\"%s\" variable %s masks earlier declaration in same %s", @@ -549,7 +549,7 @@ Perl_pad_check_dup(pTHX_ const char *name, bool is_our, const HV *ourstash) && sv != &PL_sv_undef && !SvFAKE(sv) && (SvIVX(sv) == PAD_MAX || SvIVX(sv) == 0) - && ((SvFLAGS(sv) & SVpad_OUR) && GvSTASH(sv) == ourstash) + && ((SvPAD_OUR(sv)) && GvSTASH(sv) == ourstash) && strEQ(name, SvPVX_const(sv))) { Perl_warner(aTHX_ packWARN(WARN_MISC), @@ -601,7 +601,7 @@ Perl_pad_findmy(pTHX_ const char *name) const SV * const namesv = name_svp[offset]; if (namesv && namesv != &PL_sv_undef && !SvFAKE(namesv) - && (SvFLAGS(namesv) & SVpad_OUR) + && (SvPAD_OUR(namesv)) && strEQ(SvPVX_const(namesv), name) && U_32(SvNVX(namesv)) == PAD_MAX /* min */ ) @@ -735,7 +735,7 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn, if (out_capture) { /* our ? */ - if ((SvFLAGS(*out_name_sv) & SVpad_OUR)) { + if (SvPAD_OUR(*out_name_sv)) { *out_capture = NULL; return offset; } @@ -836,9 +836,9 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn, new_offset = pad_add_name( SvPVX_const(*out_name_sv), - (SvFLAGS(*out_name_sv) & SVpad_TYPED) + SvPAD_TYPED(*out_name_sv) ? SvSTASH(*out_name_sv) : NULL, - (SvFLAGS(*out_name_sv) & SVpad_OUR) + SvPAD_OUR(*out_name_sv) ? GvSTASH(*out_name_sv) : NULL, 1 /* fake */ ); @@ -847,7 +847,7 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn, SvIV_set(new_namesv, *out_flags); SvNV_set(new_namesv, (NV)0); - if (SvFLAGS(new_namesv) & SVpad_OUR) { + if (SvPAD_OUR(new_namesv)) { /*EMPTY*/; /* do nothing */ } else if (CvLATE(cv)) { @@ -1649,7 +1649,7 @@ Perl_pad_compname_type(pTHX_ const PADOFFSET po) { dVAR; SV* const * const av = av_fetch(PL_comppad_name, po, FALSE); - if ( SvFLAGS(*av) & SVpad_TYPED ) { + if ( SvPAD_TYPED(*av) ) { return SvSTASH(*av); } return NULL; diff --git a/pad.h b/pad.h index 62d4fb1..e56022f 100644 --- a/pad.h +++ b/pad.h @@ -219,6 +219,7 @@ ling pad (lvalue) to C. Note that C is hijacked for this purpos */ #define PAD_COMPNAME_FLAGS(po) SvFLAGS(*av_fetch(PL_comppad_name, (po), FALSE)) +#define PAD_COMPNAME_FLAGS_isOUR(po) (PAD_COMPNAME_FLAGS(po) & SVpad_OUR) #define PAD_COMPNAME_PV(po) SvPV_nolen(*av_fetch(PL_comppad_name, (po), FALSE)) #define PAD_COMPNAME_TYPE(po) pad_compname_type(po) diff --git a/pp.c b/pp.c index 1438f8d..d63f039 100644 --- a/pp.c +++ b/pp.c @@ -4263,7 +4263,8 @@ PP(pp_reverse) sv_setsv(TARG, (SP > MARK) ? *SP : (padoff_du = find_rundefsvoffset(), - (padoff_du == NOT_IN_PAD || PAD_COMPNAME_FLAGS(padoff_du) & SVpad_OUR) + (padoff_du == NOT_IN_PAD + || PAD_COMPNAME_FLAGS_isOUR(padoff_du)) ? DEFSV : PAD_SVl(padoff_du))); up = SvPV_force(TARG, len); if (len > 1) { diff --git a/sv.c b/sv.c index fd567ec..1dc7283 100644 --- a/sv.c +++ b/sv.c @@ -1240,7 +1240,7 @@ Perl_sv_upgrade(pTHX_ register SV *sv, U32 new_type) /* This flag bit is used to mean other things in other scalar types. Given that it only has meaning inside the pad, it shouldn't be set on anything that can get upgraded. */ - assert((SvFLAGS(sv) & SVpad_TYPED) == 0); + assert(!SvPAD_TYPED(sv)); break; default: if (old_type_details->cant_upgrade) @@ -5042,7 +5042,7 @@ Perl_sv_clear(pTHX_ register SV *sv) if (type >= SVt_PVMG) { if (SvMAGIC(sv)) mg_free(sv); - if (type == SVt_PVMG && SvFLAGS(sv) & SVpad_TYPED) + if (type == SVt_PVMG && SvPAD_TYPED(sv)) SvREFCNT_dec(SvSTASH(sv)); } switch (type) { diff --git a/sv.h b/sv.h index 93a0d00..8f31c21 100644 --- a/sv.h +++ b/sv.h @@ -928,6 +928,14 @@ in gv.h: */ #define SvREPADTMP_off(sv) (SvFLAGS(sv) &= ~SVf_FAKE) #endif +#define SvPAD_TYPED(sv) (SvFLAGS(sv) & SVpad_TYPED) +#define SvPAD_TYPED_on(sv) (SvFLAGS(sv) |= SVpad_TYPED) +#define SvPAD_TYPED_off(sv) (SvFLAGS(sv) &= ~SVpad_TYPED) + +#define SvPAD_OUR(sv) (SvFLAGS(sv) & SVpad_OUR) +#define SvPAD_OUR_on(sv) (SvFLAGS(sv) |= SVpad_OUR) +#define SvPAD_OUR_off(sv) (SvFLAGS(sv) &= ~SVpad_OUR) + #ifdef PERL_DEBUG_COW #define SvRV(sv) (0 + (sv)->sv_u.svu_rv) #else diff --git a/toke.c b/toke.c index 1981c75..44eae03 100644 --- a/toke.c +++ b/toke.c @@ -5751,7 +5751,7 @@ S_pending_ident(pTHX) tmp = pad_findmy(PL_tokenbuf); if (tmp != NOT_IN_PAD) { /* might be an "our" variable" */ - if (PAD_COMPNAME_FLAGS(tmp) & SVpad_OUR) { + if (PAD_COMPNAME_FLAGS_isOUR(tmp)) { /* build ops for a bareword */ HV * const stash = PAD_COMPNAME_OURSTASH(tmp); HEK * const stashname = HvNAME_HEK(stash); @@ -10037,7 +10037,7 @@ S_scan_inputsymbol(pTHX_ char *start) add symbol table ops */ if ((tmp = pad_findmy(d)) != NOT_IN_PAD) { - if (PAD_COMPNAME_FLAGS(tmp) & SVpad_OUR) { + if (PAD_COMPNAME_FLAGS_isOUR(tmp)) { HV * const stash = PAD_COMPNAME_OURSTASH(tmp); HEK * const stashname = HvNAME_HEK(stash); SV * const sym = sv_2mortal(newSVhek(stashname));