use B qw(class main_root main_start main_cv svref_2object opnumber cstring
OPf_WANT OPf_WANT_VOID OPf_WANT_SCALAR OPf_WANT_LIST
OPf_KIDS OPf_REF OPf_STACKED OPf_SPECIAL
- OPpLVAL_INTRO OPpENTERSUB_AMPER OPpSLICE OPpCONST_BARE
+ OPpLVAL_INTRO OPpOUR_INTRO OPpENTERSUB_AMPER OPpSLICE OPpCONST_BARE
OPpTRANS_SQUASH OPpTRANS_DELETE OPpTRANS_COMPLEMENT OPpTARGET_MY
- OPpCONST_ARYBASE OPpEXISTS_SUB
- SVf_IOK SVf_NOK SVf_ROK SVf_POK
+ OPpCONST_ARYBASE OPpEXISTS_SUB OPpSORT_NUMERIC OPpSORT_INTEGER
+ OPpSORT_REVERSE
+ SVf_IOK SVf_NOK SVf_ROK SVf_POK SVpad_OUR
CVf_METHOD CVf_LOCKED CVf_LVALUE
PMf_KEEP PMf_GLOBAL PMf_CONTINUE PMf_EVAL PMf_ONCE PMf_SKIPWHITE
PMf_MULTILINE PMf_SINGLELINE PMf_FOLD PMf_EXTENDED);
# 1 statement modifiers
# 0 statement level
+# Also, lineseq may pass a fourth parameter to the pp_ routines:
+# if present, the fourth parameter is passed on by deparse.
+#
+# If present and true, it means that the op exists directly as
+# part of a lineseq. Currently it's only used by scopeop to
+# decide whether its results need to be enclosed in a do {} block.
+
# Nonprinting characters with special meaning:
# \cS - steal parens (see maybe_parens_unop)
# \n - newline and indent
return $use_dec;
}
}
- return "sub $name " . $self->deparse_sub($cv);
+ my $l = '';
+ if ($self->{'linenums'}) {
+ my $line = $gv->LINE;
+ my $file = $gv->FILE;
+ $l = "\n\f#line $line \"$file\"\n";
+ }
+ return "${l}sub $name " . $self->deparse_sub($cv);
}
}
return unless $self->const_sv($constop)->PV eq $module;
$constop = $constop->sibling;
-
$version = $self->const_sv($constop)->int_value;
$constop = $constop->sibling;
return if $constop->name ne "method_named";
# See if there are import arguments
my $args = '';
- my $constop = $entersub->first->sibling; # Skip over pushmark
- return unless $self->const_sv($constop)->PV eq $module;
+ my $svop = $entersub->first->sibling; # Skip over pushmark
+ return unless $self->const_sv($svop)->PV eq $module;
# Pull out the arguments
- for ($constop=$constop->sibling; $constop->name eq "const";
- $constop = $constop->sibling) {
+ for ($svop=$svop->sibling; $svop->name ne "method_named";
+ $svop = $svop->sibling) {
$args .= ", " if length($args);
- $args .= $self->deparse($constop, 6);
+ $args .= $self->deparse($svop, 6);
}
my $use = 'use';
- my $method_named = $constop;
+ my $method_named = $svop;
return if $method_named->name ne "method_named";
my $method_name = $self->const_sv($method_named)->PV;
next if $key eq 'main::'; # avoid infinite recursion
my $class = class($val);
if ($class eq "PV") {
- # Just a prototype
+ # Just a prototype. As an ugly but fairly effective way
+ # to find out if it belongs here is to see if the AUTOLOAD
+ # (if any) for the stash was defined in one of our files.
+ my $A = $stash{"AUTOLOAD"};
+ if (defined ($A) && class($A) eq "GV" && defined($A->CV)
+ && class($A->CV) eq "CV") {
+ my $AF = $A->FILE;
+ next unless $AF eq $0 || exists $self->{'files'}{$AF};
+ }
push @{$self->{'protos_todo'}}, [$pack . $key, $val->PV];
} elsif ($class eq "IV") {
- # Just a name
+ # Just a name. As above.
+ my $A = $stash{"AUTOLOAD"};
+ if (defined ($A) && class($A) eq "GV" && defined($A->CV)
+ && class($A->CV) eq "CV") {
+ my $AF = $A->FILE;
+ next unless $AF eq $0 || exists $self->{'files'}{$AF};
+ }
push @{$self->{'protos_todo'}}, [$pack . $key, undef];
} elsif ($class eq "GV") {
if (class(my $cv = $val->CV) ne "SPECIAL") {
sub deparse {
my $self = shift;
- my($op, $cx) = @_;
+ my($op, $cx, $flags) = @_;
Carp::confess("Null op in deparse") if !defined($op)
|| class($op) eq "NULL";
my $meth = "pp_" . $op->name;
+ if (is_scope($op)) {
+ return $self->$meth($op, $cx, $flags);
+ }
return $self->$meth($op, $cx);
}
my $self = shift;
my $cv = shift;
my $proto = "";
+Carp::confess("NULL in deparse_sub") if !defined($cv) || $cv->isa("B::NULL");
Carp::confess("SPECIAL in deparse_sub") if $cv->isa("B::SPECIAL");
local $self->{'curcop'} = $self->{'curcop'};
if ($cv->FLAGS & SVf_POK) {
local($self->{'curcvlex'});
local(@$self{qw'curstash warnings hints'})
= @$self{qw'curstash warnings hints'};
+ my $body;
if (not null $cv->ROOT) {
- # skip leavesub
- return $proto . "{\n\t" .
- $self->deparse($cv->ROOT->first, 0) . "\n\b}\n";
+ my $lineseq = $cv->ROOT->first;
+ if ($lineseq->name eq "lineseq") {
+ my @ops;
+ for(my$o=$lineseq->first; $$o; $o=$o->sibling) {
+ push @ops, $o;
+ }
+ $body = $self->lineseq(undef, @ops).";";
+ my $scope_en = $self->find_scope_en($lineseq);
+ if (defined $scope_en) {
+ my $subs = join"", $self->seq_subs($scope_en);
+ $body .= ";\n$subs" if length($subs);
+ }
+ }
+ else {
+ $body = $self->deparse($cv->ROOT->first, 0);
+ }
}
- my $sv = $cv->const_sv;
- if ($$sv) {
- # uh-oh. inlinable sub... format it differently
- return $proto . "{ " . const($sv) . " }\n";
- } else { # XSUB? (or just a declaration)
- return "$proto;\n";
+ else {
+ my $sv = $cv->const_sv;
+ if ($$sv) {
+ # uh-oh. inlinable sub... format it differently
+ return $proto . "{ " . const($sv) . " }\n";
+ } else { # XSUB? (or just a declaration)
+ return "$proto;\n";
+ }
}
+ return $proto ."{\n\t$body\n\b}" ."\n";
}
sub deparse_format {
$op = $op->sibling; # skip nextstate
my @exprs;
$kid = $op->first->sibling; # skip pushmark
- push @text, $self->const_sv($kid)->PV;
+ push @text, "\f".$self->const_sv($kid)->PV;
$kid = $kid->sibling;
for (; not null $kid; $kid = $kid->sibling) {
push @exprs, $self->deparse($kid, 0);
}
- push @text, join(", ", @exprs)."\n" if @exprs;
+ push @text, "\f".join(", ", @exprs)."\n" if @exprs;
$op = $op->sibling;
}
- return join("", @text) . ".";
+ return join("", @text) . "\f.";
}
sub is_scope {
my $self = shift;
my($name, $kid, $cx) = @_;
if ($cx > 16 or $self->{'parens'}) {
- return "$name(" . $self->deparse($kid, 1) . ")";
+ $kid = $self->deparse($kid, 1);
+ if ($name eq "umask" && $kid =~ /^\d+$/) {
+ $kid = sprintf("%#o", $kid);
+ }
+ return "$name($kid)";
} else {
$kid = $self->deparse($kid, 16);
+ if ($name eq "umask" && $kid =~ /^\d+$/) {
+ $kid = sprintf("%#o", $kid);
+ }
if (substr($kid, 0, 1) eq "\cS") {
# use kid's parens
return $name . substr($kid, 1);
sub maybe_local {
my $self = shift;
my($op, $cx, $text) = @_;
- if ($op->private & OPpLVAL_INTRO and not $self->{'avoid_local'}{$$op}) {
+ my $our_intro = ($op->name =~ /^(gv|rv2)[ash]v$/) ? OPpOUR_INTRO : 0;
+ if ($op->private & (OPpLVAL_INTRO|$our_intro)
+ and not $self->{'avoid_local'}{$$op}) {
+ my $our_local = ($op->private & OPpLVAL_INTRO) ? "local" : "our";
if (want_scalar($op)) {
- return "local $text";
+ return "$our_local $text";
} else {
- return $self->maybe_parens_func("local", $text, $cx, 16);
+ return $self->maybe_parens_func("$our_local", $text, $cx, 16);
}
} else {
return $text;
return "XXX";
}
+# $root should be the op which represents the root of whatever
+# we're sequencing here. If it's undefined, then we don't append
+# any subroutine declarations to the deparsed ops, otherwise we
+# append appropriate declarations.
sub lineseq {
- my $self = shift;
- my(@ops) = @_;
+ my($self, $root, @ops) = @_;
my($expr, @exprs);
+
+ my $out_cop = $self->{'curcop'};
+ my $out_seq = defined($out_cop) ? $out_cop->cop_seq : undef;
+ my $limit_seq;
+ if (defined $root) {
+ $limit_seq = $out_seq;
+ my $nseq = $self->find_scope_st($root->sibling) if ${$root->sibling};
+ $limit_seq = $nseq if !defined($limit_seq)
+ or defined($nseq) && $nseq < $limit_seq;
+ }
+ $limit_seq = $self->{'limit_seq'}
+ if defined($self->{'limit_seq'})
+ && (!defined($limit_seq) || $self->{'limit_seq'} < $limit_seq);
+ local $self->{'limit_seq'} = $limit_seq;
for (my $i = 0; $i < @ops; $i++) {
$expr = "";
if (is_state $ops[$i]) {
$expr = $self->deparse($ops[$i], 0);
$i++;
- last if $i > $#ops;
+ if ($i > $#ops) {
+ push @exprs, $expr;
+ last;
+ }
}
- if (!is_state $ops[$i] and $ops[$i+1] and !null($ops[$i+1]) and
- $ops[$i+1]->name eq "leaveloop" and $self->{'expand'} < 3)
+ if (!is_state $ops[$i] and (my $ls = $ops[$i+1]) and
+ !null($ops[$i+1]) and $ops[$i+1]->name eq "lineseq")
{
- push @exprs, $expr . $self->for_loop($ops[$i], 0);
- $i++;
- next;
+ if ($ls->first && !null($ls->first) && is_state($ls->first)
+ && (my $sib = $ls->first->sibling)) {
+ if (!null($sib) && $sib->name eq "leaveloop") {
+ push @exprs, $expr . $self->for_loop($ops[$i], 0);
+ $i++;
+ next;
+ }
+ }
}
- $expr .= $self->deparse($ops[$i], 0);
- push @exprs, $expr if length $expr;
+ $expr .= $self->deparse($ops[$i], 0, (@ops != 1));
+ $expr =~ s/;\n?\z//;
+ push @exprs, $expr;
+ }
+ my $body = join(";\n", grep {length} @exprs);
+ my $subs = "";
+ if (defined $root && defined $limit_seq) {
+ $subs = join "\n", $self->seq_subs($limit_seq);
}
- for(@exprs[0..@exprs-1]) { s/;\n\z// }
- return join(";\n", @exprs);
+ return join(";\n", grep {length} $body, $subs);
}
sub scopeop {
- my($real_block, $self, $op, $cx) = @_;
+ my($real_block, $self, $op, $cx, $flags) = @_;
my $kid;
my @kids;
for (; !null($kid); $kid = $kid->sibling) {
push @kids, $kid;
}
- if ($cx > 0) { # inside an expression, (a do {} while for lineseq)
- return "do { " . $self->lineseq(@kids) . " }";
+ if ($flags || $cx > 0) { # inside an expression, (a do {} while for lineseq)
+ return "do {\n\t" . $self->lineseq($op, @kids) . "\n\b}";
} else {
- my $lineseq = $self->lineseq(@kids);
+ my $lineseq = $self->lineseq($op, @kids);
return (length ($lineseq) ? "$lineseq;" : "");
}
}
my ($self, $name) = @_;
$self->populate_curcvlex() if !defined $self->{'curcvlex'};
+ return 0 if !defined($self->{'curcop'});
my $seq = $self->{'curcop'}->cop_seq;
return 0 if !exists $self->{'curcvlex'}{$name};
for my $a (@{$self->{'curcvlex'}{$name}}) {
sub populate_curcvlex {
my $self = shift;
- for (my $cv = $self->{'curcv'}; $$cv; $cv = $cv->OUTSIDE) {
+ for (my $cv = $self->{'curcv'}; class($cv) eq "CV"; $cv = $cv->OUTSIDE) {
my @padlist = $cv->PADLIST->ARRAY;
my @ns = $padlist[0]->ARRAY;
for (my $i=0; $i<@ns; ++$i) {
next if class($ns[$i]) eq "SPECIAL";
+ next if $ns[$i]->FLAGS & SVpad_OUR; # Skip "our" vars
if (class($ns[$i]) eq "PV") {
# Probably that pesky lexical @_
next;
}
}
-# Recurses down the tree, looking for a COP
-sub find_cop {
- my ($self, $op) = @_;
- if ($op->flags & OPf_KIDS) {
- for (my $o=$op->first; $$o; $o=$o->sibling) {
- return $o if is_state($o);
- my $r = $self->find_cop($o);
- return $r if defined $r;
+sub find_scope_st { ((find_scope(@_))[0]); }
+sub find_scope_en { ((find_scope(@_))[1]); }
+
+# Recurses down the tree, looking for pad variable introductions and COPs
+sub find_scope {
+ my ($self, $op, $scope_st, $scope_en) = @_;
+Carp::cluck() if !defined $op;
+ return ($scope_st, $scope_en) unless $op->flags & OPf_KIDS;
+
+ for (my $o=$op->first; $$o; $o=$o->sibling) {
+ if ($o->name =~ /^pad.v$/ && $o->private & OPpLVAL_INTRO) {
+ my $s = int($self->padname_sv($o->targ)->NVX);
+ my $e = $self->padname_sv($o->targ)->IVX;
+ $scope_st = $s if !defined($scope_st) || $s < $scope_st;
+ $scope_en = $e if !defined($scope_en) || $e > $scope_en;
+ }
+ elsif (is_state($o)) {
+ my $c = $o->cop_seq;
+ $scope_st = $c if !defined($scope_st) || $c < $scope_st;
+ $scope_en = $c if !defined($scope_en) || $c > $scope_en;
+ }
+ elsif ($o->flags & OPf_KIDS) {
+ ($scope_st, $scope_en) =
+ $self->find_scope($o, $scope_st, $scope_en)
}
}
- return undef;
+
+ return ($scope_st, $scope_en);
}
# Returns a list of subs which should be inserted before the COP
# If we have nephews, then our sequence number indicates
# the cop_seq of the end of some sort of scope.
if (class($op->sibling) ne "NULL" && $op->sibling->flags & OPf_KIDS
- and my $ncop = $self->find_cop($op->sibling)) {
- $seq = $ncop->cop_seq;
+ and my $nseq = $self->find_scope_st($op->sibling) ) {
+ $seq = $nseq;
}
$seq = $out_seq if defined($out_seq) && $out_seq < $seq;
return $self->seq_subs($seq);
my @text;
#push @text, "# ($seq)\n";
+ return "" if !defined $seq;
while (scalar(@{$self->{'subs_todo'}})
and $seq > $self->{'subs_todo'}[0][0]) {
push @text, $self->next_todo;
my($op, $cx) = @_;
$self->{'curcop'} = $op;
my @text;
- @text = $op->label . ": " if $op->label;
-#push @text, "# ", $op->cop_seq, "\n";
push @text, $self->cop_subs($op);
+ push @text, $op->label . ": " if $op->label;
my $stash = $op->stashpv;
if ($stash ne $self->{'curstash'}) {
push @text, "package $stash;\n";
sub declare_warnings {
my ($from, $to) = @_;
- if ($to eq warnings::bits("all")) {
+ if (($to & WARN_MASK) eq warnings::bits("all")) {
return "use warnings;\n";
}
- elsif ($to eq "\0"x12) {
+ elsif (($to & WARN_MASK) eq "\0"x length($to)) {
return "no warnings;\n";
}
return "BEGIN {\${^WARNING_BITS} = ".cstring($to)."}\n";
sub declare_hints {
my ($from, $to) = @_;
- my $bits = $to;
- return sprintf "BEGIN {\$^H &= ~0xFF; \$^H |= %x}\n", $bits;
+ my $use = $to & ~$from;
+ my $no = $from & ~$to;
+ my $decls = "";
+ for my $pragma (hint_pragmas($use)) {
+ $decls .= "use $pragma;\n";
+ }
+ for my $pragma (hint_pragmas($no)) {
+ $decls .= "no $pragma;\n";
+ }
+ return $decls;
+}
+
+sub hint_pragmas {
+ my ($bits) = @_;
+ my @pragmas;
+ push @pragmas, "integer" if $bits & 0x1;
+ push @pragmas, "strict 'refs'" if $bits & 0x2;
+ push @pragmas, "bytes" if $bits & 0x8;
+ return @pragmas;
}
sub pp_dbstate { pp_nextstate(@_) }
return $name;
}
-sub pp_stub { baseop(@_, "()") }
+sub pp_stub {
+ my $self = shift;
+ my($op, $cx, $name) = @_;
+ if ($cx) {
+ return "()";
+ }
+ else {
+ return "();";
+ }
+}
sub pp_wantarray { baseop(@_, "wantarray") }
sub pp_fork { baseop(@_, "fork") }
sub pp_wait { maybe_targmy(@_, \&baseop, "wait") }
sub SWAP_CHILDREN () { 1 }
sub ASSIGN () { 2 } # has OP= variant
+sub LIST_CONTEXT () { 4 } # Assignment is in list context
my(%left, %right);
($left, $right) = ($right, $left);
}
$left = $self->deparse_binop_left($op, $left, $prec);
+ $left = "($left)" if $flags & LIST_CONTEXT && $left =~ /^\$/;
$right = $self->deparse_binop_right($op, $right, $prec);
return $self->maybe_parens("$left $opname$eq $right", $cx, $prec);
}
sub pp_scmp { binop(@_, "cmp", 14) }
sub pp_sassign { binop(@_, "=", 7, SWAP_CHILDREN) }
-sub pp_aassign { binop(@_, "=", 7, SWAP_CHILDREN) }
+sub pp_aassign { binop(@_, "=", 7, SWAP_CHILDREN | LIST_CONTEXT) }
# `.' is special because concats-of-concats are optimized to save copying
# by making all but the first concat stacked. The effect is as if the
else {
$first = $self->deparse($kid, 6);
}
+ if ($name eq "chmod" && $first =~ /^\d+$/) {
+ $first = sprintf("%#o", $first);
+ }
$first = "+$first" if not $parens and substr($first, 0, 1) eq "(";
push @exprs, $first;
$kid = $kid->sibling;
$indir = $indir->first; # skip rv2gv
if (is_scope($indir)) {
$indir = "{" . $self->deparse($indir, 0) . "}";
+ } elsif ($indir->name eq "const" && $indir->private & OPpCONST_BARE) {
+ $indir = $self->const_sv($indir)->PV;
} else {
$indir = $self->deparse($indir, 24);
}
$indir = $indir . " ";
$kid = $kid->sibling;
}
+ if ($name eq "sort" && $op->private & (OPpSORT_NUMERIC | OPpSORT_INTEGER)) {
+ $indir = ($op->private & OPpSORT_REVERSE) ? '{$b <=> $a} '
+ : '{$a <=> $b} ';
+ }
+ elsif ($name eq "sort" && $op->private & OPpSORT_REVERSE) {
+ $indir = '{$b cmp $a} ';
+ }
for (; !null($kid); $kid = $kid->sibling) {
$expr = $self->deparse($kid, 6);
push @exprs, $expr;
my($expr, @exprs);
my $kid = $op->first->sibling; # skip pushmark
my $lop;
- my $local = "either"; # could be local(...) or my(...)
+ my $local = "either"; # could be local(...), my(...) or our(...)
for ($lop = $kid; !null($lop); $lop = $lop->sibling) {
# This assumes that no other private flags equal 128, and that
# OPs that store things other than flags in their op_private,
# like OP_AELEMFAST, won't be immediate children of a list.
- unless ($lop->private & OPpLVAL_INTRO or $lop->name eq "undef")
+ unless ($lop->private & OPpLVAL_INTRO
+ or $lop->name eq "undef")
{
$local = ""; # or not
last;
}
if ($lop->name =~ /^pad[ash]v$/) { # my()
- ($local = "", last) if $local eq "local";
+ ($local = "", last) if $local eq "local" || $local eq "our";
$local = "my";
+ } elsif ($op->name =~ /^(gv|rv2)[ash]v$/
+ && $op->private & OPpOUR_INTRO) { # our()
+ ($local = "", last) if $local eq "my" || $local eq "local";
+ $local = "our";
} elsif ($lop->name ne "undef") { # local()
- ($local = "", last) if $local eq "my";
+ ($local = "", last) if $local eq "my" || $local eq "our";
$local = "local";
}
}
my $bare = 0;
my $body;
my $cond = undef;
- my $out_seq = $self->{'curcop'}->cop_seq;;
if ($kid->name eq "lineseq") { # bare or infinite loop
if (is_state $kid->last) { # infinite
- $head = "for (;;) "; # shorter than while (1)
+ $head = "while (1) "; # Can't use for(;;) if there's a continue
$cond = "";
} else {
$bare = 1;
# block (or the last in a bare loop).
my $cont_start = $enter->nextop;
my $cont;
- if ($$cont_start != $$op and $ {$cont_start->sibling} != $ {$body->last}) {
+ if ($$cont_start != $$op && ${$cont_start->sibling} != ${$body->last}) {
if ($bare) {
$cont = $body->last;
} else {
for (; $$state != $$cont; $state = $state->sibling) {
push @states, $state;
}
- $body = $self->lineseq(@states);
+ $body = $self->lineseq(undef, @states);
if (defined $cond and not is_scope $cont and $self->{'expand'} < 3) {
$head = "for ($init; $cond; " . $self->deparse($cont, 1) .") ";
$cont = "\cK";
}
} else {
return "" if !defined $body;
+ if (length $init) {
+ $head = "for ($init; $cond;) ";
+ }
$cont = "\cK";
$body = $self->deparse($body, 0);
}
- $body .= "\n";
- # If we have say C<{my $x=2; sub x{$x}}>, the sub must go inside
- # the loop. So we insert any subs which are due here.
- $body .= join"", $self->seq_subs($out_seq);
+ $body =~ s/;?$/;\n/;
return $head . "{\n\t" . $body . "\b}" . $cont;
}
my $self = shift;
my($op, $cx) = @_;
my $init = $self->deparse($op, 1);
- return $self->loop_common($op->sibling, $cx, $init);
+ return $self->loop_common($op->sibling->first->sibling, $cx, $init);
}
sub pp_leavetry {
return $self->maybe_parens($self->deparse($op->first, 20) . " =~ "
. $self->deparse($op->first->sibling, 20),
$cx, 20);
+ } elsif ($op->flags & OPf_SPECIAL && $cx == 0 && !$op->targ) {
+ return "do {\n\t". $self->deparse($op->first, $cx) ."\n\b};";
} else {
return $self->deparse($op->first, $cx);
}
my $self = shift;
my($op, $cx) = @_;
my $gv = $self->gv_or_padgv($op);
- return "\$" . $self->gv_name($gv) . "[" .
+ my $name = $self->gv_name($gv);
+ $name = $self->{'curstash'}."::$name"
+ if $name !~ /::/ && $self->lex_in_scope('@'.$name);
+
+ return "\$" . $name . "[" .
($op->private + $self->{'arybase'}) . "]";
}
$array = $self->padany($array);
} elsif (is_scope($array)) { # ${expr}[0]
$array = "{" . $self->deparse($array, 0) . "}";
+ } elsif ($array->name eq "gv") {
+ $array = $self->gv_name($self->gv_or_padgv($array));
+ if ($array !~ /::/) {
+ my $prefix = ($left eq '[' ? '@' : '%');
+ $array = $self->{curstash}.'::'.$array
+ if $self->lex_in_scope($prefix . $array);
+ }
} elsif (is_scalar $array) { # $x[0], $$x[0], ...
$array = $self->deparse($array, 24);
} else {
# Doesn't matter how many prototypes there are, if
# they haven't happened yet!
my $declared = exists $self->{'subs_declared'}{$kid};
+ if (!$declared && defined($proto)) {
+ # Avoid "too early to check prototype" warning
+ ($amper, $proto) = ('&');
+ }
my $args;
if ($declared and defined $proto and not $amper) {
return "$kid(" . $args . ")";
} elsif (defined $proto and $proto eq "") {
return $kid;
- } elsif (defined $proto and $proto eq "\$") {
+ } elsif (defined $proto and $proto eq "\$" and is_scalar($exprs[0])) {
return $self->maybe_parens_func($kid, $args, $cx, 16);
} elsif (defined($proto) && $proto or $simple) {
return $self->maybe_parens_func($kid, $args, $cx, 5);
# but not character escapes
sub uninterp {
my($str) = @_;
- $str =~ s/(^|\G|[^\\])((?:\\\\)*)([\$\%\@]|\\[uUlLQE])/$1$2\\$3/g;
+ $str =~ s/(^|\G|[^\\])((?:\\\\)*)([\$\@]|\\[uUlLQE])/$1$2\\$3/g;
return $str;
}
# the same, but treat $|, $), $( and $ at the end of the string differently
sub re_uninterp {
my($str) = @_;
- $str =~ s/(^|\G|[^\\])((?:\\\\)*)([\$\%\@](?!\||\)|\$\(|$)|\\[uUlLQE])/$1$2\\$3/g
-;
+ $str =~ s/(^|\G|[^\\])((?:\\\\)*)([\$\@](?!\||\)|\(|$)|\\[uUlLQE])/$1$2\\$3/g;
return $str;
}
my($kid, @exprs, $ary, $expr);
$kid = $op->first;
if ($ {$kid->pmreplroot}) {
- $ary = '@' . $self->gv_name($kid->pmreplroot);
+ $ary = $self->stash_variable('@', $self->gv_name($kid->pmreplroot));
}
for (; !null($kid); $kid = $kid->sibling) {
push @exprs, $self->deparse($kid, 6);