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 /op.h | |
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 'op.h')
-rw-r--r-- | op.h | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -1016,6 +1016,15 @@ is also available as well as C<OP_TYPE_IS_OR_WAS_NN> and C<OP_TYPE_ISNT_AND_WASNT_NN> which elide the NULL pointer check. +=for apidoc Am|bool|OP_HAS_SIBLING|OP *o +Returns true if o has a sibling + +=for apidoc Am|bool|OP_SIBLING|OP *o +Returns the sibling of o, or NULL if there is no sibling + +=for apidoc Am|bool|OP_SIBLING_set|OP *o|OP *sib +Sets the sibling of o to sib + =cut */ @@ -1052,6 +1061,10 @@ the NULL pointer check. #define OP_TYPE_ISNT_AND_WASNT(o, type) \ ( (o) && OP_TYPE_ISNT_AND_WASNT_NN(o, type) ) +#define OP_HAS_SIBLING(o) (cBOOL((o)->op_sibling)) +#define OP_SIBLING(o) (0 + (o)->op_sibling) +#define OP_SIBLING_set(o, sib) ((o)->op_sibling = (sib)) + #define newATTRSUB(f, o, p, a, b) Perl_newATTRSUB_x(aTHX_ f, o, p, a, b, FALSE) #define newSUB(f, o, p, b) newATTRSUB((f), (o), (p), NULL, (b)) |