sub new {
my $class = shift;
$class = ref($class) || $class || __PACKAGE__;
+
my ($deparse, $level) = _parse_args(@_);
+
my $self = bless $class->SUPER::new(@$deparse), $class;
+
$self->{brd_level} = $level;
+
return $self;
}
}
sub compile {
- my $bd = B::Deparse->new();
my @args = @_;
+
+ my $bd = B::Deparse->new();
my ($deparse, $level) = _parse_args(@args);
+
my $compiler = $bd->coderef2text(B::Deparse::compile(@$deparse));
$compiler =~ s/
['"]? B::Deparse ['"]? \s* -> \s* (new) \s* \( ([^\)]*) \)
/B::RecDeparse->$1(deparse => [ $2 ], level => $level)/gx;
$compiler = eval 'sub ' . $compiler;
die if $@;
+
return $compiler;
}
sub init {
my $self = shift;
+
$self->{brd_cur} = 0;
$self->{brd_sub} = 0;
+
$self->SUPER::init(@_);
}
if (FOOL_SINGLE_DELIM) {
my $oldsd = *B::Deparse::single_delim{CODE};
+
no warnings 'redefine';
*B::Deparse::single_delim = sub {
my $body = $_[2];
+
if ((caller 1)[0] eq __PACKAGE__ and $body =~ s/^$key//) {
return $body;
} else {
sub pp_entersub {
my $self = shift;
+
my $body = do {
local $self->{brd_sub} = 1;
$self->SUPER::pp_entersub(@_);
};
+
$body =~ s/^&\s*(\w)/$1/ if $self->_recurse;
+
return $body;
}
sub pp_refgen {
my $self = shift;
+
return do {
local $self->{brd_sub} = 0;
$self->SUPER::pp_refgen(@_);
sub pp_gv {
my $self = shift;
+
my $body;
if ($self->{brd_sub} <= 0 || !$self->_recurse) {
$body = $self->SUPER::pp_gv(@_);
} else {
my $gv = $self->gv_or_padgv($_[0]);
+
$body = do {
local @{$self}{qw/brd_sub brd_cur/} = (0, $self->{brd_cur} + 1);
'sub ' . $self->indent($self->deparse_sub($gv->CV));
};
+
if (FOOL_SINGLE_DELIM) {
$body = $key . $body;
} else {
$body .= '->';
}
}
+
return $body;
}