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 /ext/Devel-Peek | |
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 'ext/Devel-Peek')
-rw-r--r-- | ext/Devel-Peek/Peek.pm | 2 | ||||
-rw-r--r-- | ext/Devel-Peek/Peek.xs | 17 |
2 files changed, 10 insertions, 9 deletions
diff --git a/ext/Devel-Peek/Peek.pm b/ext/Devel-Peek/Peek.pm index d0ed3943b6..c17401b66d 100644 --- a/ext/Devel-Peek/Peek.pm +++ b/ext/Devel-Peek/Peek.pm @@ -3,7 +3,7 @@ package Devel::Peek; -$VERSION = '1.17'; +$VERSION = '1.18'; $XS_VERSION = $VERSION; $VERSION = eval $VERSION; diff --git a/ext/Devel-Peek/Peek.xs b/ext/Devel-Peek/Peek.xs index 0d8b833267..cb3d0ba553 100644 --- a/ext/Devel-Peek/Peek.xs +++ b/ext/Devel-Peek/Peek.xs @@ -360,12 +360,13 @@ S_ck_dump(pTHX_ OP *entersubop, GV *namegv, SV *cv) newSVpvn_flags("$;$", 3, SVs_TEMP)); aop = cUNOPx(entersubop)->op_first; - if (!aop->op_sibling) + if (!OP_HAS_SIBLING(aop)) aop = cUNOPx(aop)->op_first; prev = aop; - aop = aop->op_sibling; + aop = OP_SIBLING(aop); first = aop; - prev->op_sibling = first->op_sibling; + OP_SIBLING_set(prev, OP_SIBLING(first)); + if (first->op_type == OP_RV2AV || first->op_type == OP_PADAV || first->op_type == OP_RV2HV || @@ -374,7 +375,7 @@ S_ck_dump(pTHX_ OP *entersubop, GV *namegv, SV *cv) first->op_flags |= OPf_REF; else first->op_flags &= ~OPf_MOD; - aop = aop->op_sibling; + aop = OP_SIBLING(aop); if (!aop) { /* It doesn’t really matter what we return here, as this only occurs after yyerror. */ @@ -384,12 +385,12 @@ S_ck_dump(pTHX_ OP *entersubop, GV *namegv, SV *cv) /* aop now points to the second arg if there is one, the cvop otherwise */ - if (aop->op_sibling) { - prev->op_sibling = aop->op_sibling; + if (OP_HAS_SIBLING(aop)) { + OP_SIBLING_set(prev, OP_SIBLING(aop)); second = aop; - second->op_sibling = NULL; + OP_SIBLING_set(second, NULL); } - first->op_sibling = second; + OP_SIBLING_set(first, second); op_free(entersubop); |