From: Vincent Pit Date: Sun, 15 Nov 2009 00:16:44 +0000 (+0100) Subject: Teach B::Deparse about in-place reverse X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=689e417f571b6d714ad62b19aa8883b3b04f59ed;p=p5sagit%2Fp5-mst-13.2.git Teach B::Deparse about in-place reverse And bump the $VERSION. --- diff --git a/dist/B-Deparse/Deparse.pm b/dist/B-Deparse/Deparse.pm index fbfee98..93e250f 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 12879fc..191324a 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; +(); diff --git a/ext/B/t/concise-xs.t b/ext/B/t/concise-xs.t index d900113..8e51b88 100644 --- a/ext/B/t/concise-xs.t +++ b/ext/B/t/concise-xs.t @@ -161,10 +161,10 @@ my $testpkgs = { OPpENTERSUB_AMPER OPpEXISTS_SUB OPpITER_REVERSED OPpLVAL_INTRO OPpOUR_INTRO OPpSLICE OPpSORT_DESCEND OPpSORT_INPLACE OPpSORT_INTEGER OPpSORT_NUMERIC - OPpSORT_REVERSE OPpTARGET_MY OPpTRANS_COMPLEMENT - OPpTRANS_DELETE OPpTRANS_SQUASH PMf_CONTINUE - PMf_EVAL PMf_EXTENDED PMf_FOLD PMf_GLOBAL PMf_KEEP - PMf_MULTILINE PMf_ONCE PMf_SINGLELINE + OPpSORT_REVERSE OPpREVERSE_INPLACE OPpTARGET_MY + OPpTRANS_COMPLEMENT OPpTRANS_DELETE OPpTRANS_SQUASH + PMf_CONTINUE PMf_EVAL PMf_EXTENDED PMf_FOLD PMf_GLOBAL + PMf_KEEP PMf_MULTILINE PMf_ONCE PMf_SINGLELINE POSTFIX SVf_FAKE SVf_IOK SVf_NOK SVf_POK SVf_ROK SVpad_OUR SVs_RMG SVs_SMG SWAP_CHILDREN OPpPAD_STATE /, $] > 5.009 ? ('RXf_SKIPWHITE') : ('PMf_SKIPWHITE'),