diff options
author | Vincent Pit <vince@profvince.com> | 2009-11-15 01:16:44 +0100 |
---|---|---|
committer | Vincent Pit <vince@profvince.com> | 2009-11-15 01:23:17 +0100 |
commit | 689e417f571b6d714ad62b19aa8883b3b04f59ed (patch) | |
tree | e7f676b0287acbb8e79b8b45a3314c6253ddd032 /dist | |
parent | 4192a60ab85c903bbbe3c8cb5b7e2afc0b34760c (diff) | |
download | perl-689e417f571b6d714ad62b19aa8883b3b04f59ed.tar.gz |
Teach B::Deparse about in-place reverse
And bump the $VERSION.
Diffstat (limited to 'dist')
-rw-r--r-- | dist/B-Deparse/Deparse.pm | 6 | ||||
-rw-r--r-- | dist/B-Deparse/t/deparse.t | 14 |
2 files changed, 18 insertions, 2 deletions
diff --git a/dist/B-Deparse/Deparse.pm b/dist/B-Deparse/Deparse.pm index fbfee981d7..93e250fd56 100644 --- a/dist/B-Deparse/Deparse.pm +++ b/dist/B-Deparse/Deparse.pm @@ -16,13 +16,14 @@ use B qw(class main_root main_start main_cv svref_2object opnumber perlstring OPpTRANS_SQUASH OPpTRANS_DELETE OPpTRANS_COMPLEMENT OPpTARGET_MY OPpCONST_ARYBASE OPpEXISTS_SUB OPpSORT_NUMERIC OPpSORT_INTEGER OPpSORT_REVERSE OPpSORT_INPLACE OPpSORT_DESCEND OPpITER_REVERSED + OPpREVERSE_INPLACE SVf_IOK SVf_NOK SVf_ROK SVf_POK SVpad_OUR SVf_FAKE SVs_RMG SVs_SMG CVf_METHOD CVf_LVALUE PMf_KEEP PMf_GLOBAL PMf_CONTINUE PMf_EVAL PMf_ONCE PMf_MULTILINE PMf_SINGLELINE PMf_FOLD PMf_EXTENDED), ($] < 5.009 ? 'PMf_SKIPWHITE' : 'RXf_SKIPWHITE'), ($] < 5.011 ? 'CVf_LOCKED' : ()); -$VERSION = 0.92; +$VERSION = 0.93; use strict; use vars qw/$AUTOLOAD/; use warnings (); @@ -2308,6 +2309,9 @@ sub listop { for (; !null($kid); $kid = $kid->sibling) { push @exprs, $self->deparse($kid, 6); } + if ($name eq "reverse" && ($op->private & OPpREVERSE_INPLACE)) { + return "$exprs[0] = $name" . ($parens ? "($exprs[0])" : " $exprs[0]"); + } if ($parens) { return "$name(" . join(", ", @exprs) . ")"; } else { diff --git a/dist/B-Deparse/t/deparse.t b/dist/B-Deparse/t/deparse.t index 12879fc5cb..191324a7c3 100644 --- a/dist/B-Deparse/t/deparse.t +++ b/dist/B-Deparse/t/deparse.t @@ -17,7 +17,7 @@ BEGIN { require feature; feature->import(':5.10'); } -use Test::More tests => 81; +use Test::More tests => 83; use Config (); use B::Deparse; @@ -603,3 +603,15 @@ my $pi = 4; my $pi : = 4; >>>> my $pi = 4; +#### +our @a; +my @b; +@a = sort @a; +@b = sort @b; +(); +#### +our @a; +my @b; +@a = reverse @a; +@b = reverse @b; +(); |