diff options
author | David Mitchell <davem@iabyn.com> | 2014-06-10 13:54:13 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2014-07-08 16:40:03 +0100 |
commit | 1ed44841e79d19d36361c250aecabc75154c999c (patch) | |
tree | fe39d432a2af6a50d6817d6747dd70fcfb3b21f4 /pp_ctl.c | |
parent | 26443f8e448912975ced96860e4f51a9e1fbbaca (diff) | |
download | perl-1ed44841e79d19d36361c250aecabc75154c999c.tar.gz |
wrap op_sibling field access in OP_SIBLING* macros
Remove (almost all) direct access to the op_sibling field of OP structs,
and use these three new macros instead:
OP_SIBLING(o);
OP_HAS_SIBLING(o);
OP_SIBLING_set(o, new_value);
OP_HAS_SIBLING is intended to be a slightly more efficient version of
OP_SIBLING when only boolean context is needed.
For now these three macros are just defined in the obvious way:
#define OP_SIBLING(o) (0 + (o)->op_sibling)
#define OP_HAS_SIBLING(o) (cBOOL((o)->op_sibling))
#define OP_SIBLING_set(o, sib) ((o)->op_sibling = (sib))
but abstracting them out will allow us shortly to make the last pointer in
an op_sibling chain point back to the parent rather than being null, with
a new flag indicating whether this is the last op.
Perl_ck_fun() still has a couple of direct uses of op_sibling, since it
takes the field's address, which is not covered by these macros.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -1811,7 +1811,7 @@ PP(pp_caller) PUSHTARG; } mPUSHs(newSVpv(OutCopFILE(cx->blk_oldcop), 0)); - lcop = closest_cop(cx->blk_oldcop, cx->blk_oldcop->op_sibling, + lcop = closest_cop(cx->blk_oldcop, OP_SIBLING(cx->blk_oldcop), cx->blk_sub.retop, TRUE); if (!lcop) lcop = cx->blk_oldcop; @@ -2701,7 +2701,7 @@ S_dofindlabel(pTHX_ OP *o, const char *label, STRLEN len, U32 flags, OP **opstac if (o->op_flags & OPf_KIDS) { OP *kid; /* First try all the kids at this level, since that's likeliest. */ - for (kid = cUNOPo->op_first; kid; kid = kid->op_sibling) { + for (kid = cUNOPo->op_first; kid; kid = OP_SIBLING(kid)) { if (kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE) { STRLEN kid_label_len; U32 kid_label_flags; @@ -2721,7 +2721,7 @@ S_dofindlabel(pTHX_ OP *o, const char *label, STRLEN len, U32 flags, OP **opstac return kid; } } - for (kid = cUNOPo->op_first; kid; kid = kid->op_sibling) { + for (kid = cUNOPo->op_first; kid; kid = OP_SIBLING(kid)) { if (kid == PL_lastgotoprobe) continue; if (kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE) { @@ -3007,13 +3007,13 @@ PP(pp_goto) /* also pp_dump */ case CXt_LOOP_PLAIN: case CXt_GIVEN: case CXt_WHEN: - gotoprobe = cx->blk_oldcop->op_sibling; + gotoprobe = OP_SIBLING(cx->blk_oldcop); break; case CXt_SUBST: continue; case CXt_BLOCK: if (ix) { - gotoprobe = cx->blk_oldcop->op_sibling; + gotoprobe = OP_SIBLING(cx->blk_oldcop); in_block = TRUE; } else gotoprobe = PL_main_root; @@ -3039,10 +3039,10 @@ PP(pp_goto) /* also pp_dump */ enterops, enterops + GOTO_DEPTH); if (retop) break; - if (gotoprobe->op_sibling && - gotoprobe->op_sibling->op_type == OP_UNSTACK && - gotoprobe->op_sibling->op_sibling) { - retop = dofindlabel(gotoprobe->op_sibling->op_sibling, + if (OP_HAS_SIBLING(gotoprobe) && + OP_SIBLING(gotoprobe)->op_type == OP_UNSTACK && + OP_HAS_SIBLING(OP_SIBLING(gotoprobe))) { + retop = dofindlabel(OP_SIBLING(OP_SIBLING(gotoprobe)), label, label_len, label_flags, enterops, enterops + GOTO_DEPTH); if (retop) |