=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
*/
#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