summaryrefslogtreecommitdiff
path: root/op.h
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-04-17 23:59:46 +0100
committerDavid Mitchell <davem@iabyn.com>2015-04-19 18:42:01 +0100
commit5e24af7dc1ab912b3a8f822d37f232e8ef19779d (patch)
tree67026101c1105c52e3d9e1a8c19c9a1acd4e5de3 /op.h
parent1fafe688be3ff13b81d5e18b2a8766dd719ee8eb (diff)
downloadperl-5e24af7dc1ab912b3a8f822d37f232e8ef19779d.tar.gz
add Op(MORE|LAST|MAYBE)SIB_set; rm OpSIBLING_set
the OpSIBLING_set() macro just set the op_sibling/op_sibparent field, and didn't update op_moresib. Remove this macro, and replace it with the three macros OpMORESIB_set OpLASTSIB_set OpMAYBESIB_set which also set op_moresib appropriately. These were suggested by Zefram. Then in the remaining areas in op.c where low-level op_sibling/op_moresib tweaking is done, use the new macros instead (so if nothing else, they get used and tested.)
Diffstat (limited to 'op.h')
-rw-r--r--op.h33
1 files changed, 28 insertions, 5 deletions
diff --git a/op.h b/op.h
index 5aeb9c58ad..ed3e9a128e 100644
--- a/op.h
+++ b/op.h
@@ -938,11 +938,23 @@ the NULL pointer check.
=for apidoc Am|bool|OpHAS_SIBLING|OP *o
Returns true if o has a sibling
-=for apidoc Am|bool|OpSIBLING|OP *o
+=for apidoc Am|OP*|OpSIBLING|OP *o
Returns the sibling of o, or NULL if there is no sibling
-=for apidoc Am|bool|OpSIBLING_set|OP *o|OP *sib
-Sets the sibling of o to sib
+=for apidoc Am|void|OpMORESIB_set|OP *o|OP *sib
+Sets the sibling of o to the non-zero value sib. See also C<OpLASTSIB_set>
+and C<OpMAYBESIB_set>. For a higher-level interface, see
+C<op_sibling_splice>.
+
+=for apidoc Am|void|OpLASTSIB_set|OP *o|OP *parent
+Marks o as having no further siblings. On C<PERL_OP_PARENT> builds, marks
+o as having the specified parent. See also C<OpMORESIB_set> and
+C<OpMAYBESIB_set>. For a higher-level interface, see
+C<op_sibling_splice>.
+
+=for apidoc Am|void|OpMAYBESIB_set|OP *o|OP *sib|OP *parent
+Conditionally does C<OpMORESIB_set> or C<OpLASTSIB_set> depending on whether
+sib is non-null. For a higher-level interface, see C<op_sibling_splice>.
=cut
*/
@@ -980,16 +992,27 @@ Sets the sibling of o to sib
#define OP_TYPE_ISNT_AND_WASNT(o, type) \
( (o) && OP_TYPE_ISNT_AND_WASNT_NN(o, type) )
+
#ifdef PERL_OP_PARENT
# define OpHAS_SIBLING(o) (cBOOL((o)->op_moresib))
# define OpSIBLING(o) (0 + (o)->op_moresib ? (o)->op_sibparent : NULL)
-# define OpSIBLING_set(o, sib) ((o)->op_sibparent = (sib))
+# define OpMORESIB_set(o, sib) ((o)->op_moresib = 1, (o)->op_sibparent = (sib))
+# define OpLASTSIB_set(o, parent) \
+ ((o)->op_moresib = 0, (o)->op_sibparent = (parent))
+# define OpMAYBESIB_set(o, sib, parent) \
+ ((o)->op_sibparent = ((o)->op_moresib = cBOOL(sib)) ? (sib) : (parent))
#else
# define OpHAS_SIBLING(o) (cBOOL((o)->op_sibling))
# define OpSIBLING(o) (0 + (o)->op_sibling)
-# define OpSIBLING_set(o, sib) ((o)->op_sibling = (sib))
+# define OpMORESIB_set(o, sib) ((o)->op_moresib = 1, (o)->op_sibling = (sib))
+# define OpLASTSIB_set(o, parent) \
+ ((o)->op_moresib = 0, (o)->op_sibling = NULL)
+# define OpMAYBESIB_set(o, sib, parent) \
+ ((o)->op_moresib = cBOOL(sib), (o)->op_sibling = (sib))
#endif
+
#if !defined(PERL_CORE) && !defined(PERL_EXT)
+/* for backwards compatibility only */
# define OP_SIBLING(o) OpSIBLING(o)
#endif