From: David Mitchell Date: Tue, 8 Jul 2014 15:44:53 +0000 (+0100) Subject: [Merge] add support for ops to link to parent X-Git-Tag: v5.21.2~60 X-Git-Url: https://perl5.git.perl.org/perl5.git/commitdiff_plain/586d4abb8e2f0a3c98c8c47e0b5d51925848d8b8 [Merge] add support for ops to link to parent This series of commits provides experimental support for ops in the optree to be able to locate their parent op, if any. First, it adds a new general-purpose function, op_sibling_splice(), which allows for general manipulation of an op_sibling chain by analogy with the perl splice() function. op.c has then been heavily refactored to use this function rather than manipulating ops directly. Then the boolean field op_lastsib has been added to OPs. Within the core, this is set on the last op in an op_sibling chain (so it is synonymous with op_sibling being null). By default, its value is set but not used. In addition, a new build define has been added (not yet enabled by default), -DPERL_OP_PARENT, that forces the core to use op_lastsib to detect the last op in a sibling chain, rather than op_sibling being NULL. This frees up the last op_sibling pointer in the chain, which rather than being set to NULL, is now set to point back to the parent of the sibling chain (if any). Then add a C-level op_parent() function and B parent() method; under default builds they just return NULL, under PERL_OP_PARENT they return the parent of the current op. Collectively this provides a facility not previously available from B:: nor C, of being able to follow an op tree up as well as down. Also, some assertions are added to finalize_op() that check the consistency of the optree; in particular that op_last points to the last sibling. Under -DPERL_OP_PARENT, more checks are enabled. --- 586d4abb8e2f0a3c98c8c47e0b5d51925848d8b8