This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add op_lastsib and -DPERL_OP_PARENT
authorDavid Mitchell <davem@iabyn.com>
Fri, 27 Jun 2014 10:52:44 +0000 (11:52 +0100)
committerDavid Mitchell <davem@iabyn.com>
Tue, 8 Jul 2014 15:40:03 +0000 (16:40 +0100)
commit29e61fd971cd4373e17cf1dd6e954ddea5171299
tree98cedf27877b50dba8ab0a7c7e781bd4a21275f3
parentc4b209751862a812e3cb3d6951c4f9411b0ca0af
add op_lastsib and -DPERL_OP_PARENT

Add the boolean field op_lastsib 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, add a new build define (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).

This commit also adds 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.
14 files changed:
dump.c
embed.fnc
embed.h
ext/B/B.pm
ext/B/B.xs
ext/B/t/b.t
ext/Devel-Peek/Peek.xs
ext/Devel-Peek/t/Peek.t
ext/XS-APItest/APItest.xs
op.c
op.h
pod/perlguts.pod
pp_ctl.c
proto.h