From: Dave Mitchell Date: Fri, 20 Feb 2004 15:34:27 +0000 (+0000) Subject: add Deparse/Concise support for inplace sort (change 22349) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2b6e98cb0bc81ffc31a6d3baf33465260376f405;p=p5sagit%2Fp5-mst-13.2.git add Deparse/Concise support for inplace sort (change 22349) p4raw-id: //depot/perl@22350 --- diff --git a/ext/B/B/Concise.pm b/ext/B/B/Concise.pm index 2b8a612..5c5fd5d 100644 --- a/ext/B/B/Concise.pm +++ b/ext/B/B/Concise.pm @@ -416,7 +416,7 @@ $priv{"exists"}{64} = "SUB"; $priv{$_}{64} = "LOCALE" for ("sort", "prtf", "sprintf", "slt", "sle", "seq", "sne", "sgt", "sge", "scmp", "lc", "uc", "lcfirst", "ucfirst"); -@{$priv{"sort"}}{1,2,4} = ("NUM", "INT", "REV"); +@{$priv{"sort"}}{1,2,4,8} = ("NUM", "INT", "REV", "INPLACE"); $priv{"threadsv"}{64} = "SVREFd"; @{$priv{$_}}{16,32,64,128} = ("INBIN","INCR","OUTBIN","OUTCR") for ("open", "backtick"); diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm index 21a3379..65f314d 100644 --- a/ext/B/B/Deparse.pm +++ b/ext/B/B/Deparse.pm @@ -14,7 +14,7 @@ use B qw(class main_root main_start main_cv svref_2object opnumber perlstring OPpLVAL_INTRO OPpOUR_INTRO OPpENTERSUB_AMPER OPpSLICE OPpCONST_BARE OPpTRANS_SQUASH OPpTRANS_DELETE OPpTRANS_COMPLEMENT OPpTARGET_MY OPpCONST_ARYBASE OPpEXISTS_SUB OPpSORT_NUMERIC OPpSORT_INTEGER - OPpSORT_REVERSE + OPpSORT_REVERSE OPpSORT_INPLACE SVf_IOK SVf_NOK SVf_ROK SVf_POK SVpad_OUR SVf_FAKE SVs_RMG SVs_SMG CVf_METHOD CVf_LOCKED CVf_LVALUE CVf_ASSERTION PMf_KEEP PMf_GLOBAL PMf_CONTINUE PMf_EVAL PMf_ONCE PMf_SKIPWHITE @@ -2311,6 +2311,10 @@ sub indirop { $expr = $self->deparse($kid, 6); push @exprs, $expr; } + if ($name eq "sort" && ($op->private & OPpSORT_INPLACE)) { + return "$exprs[0] = sort $indir $exprs[0]"; + } + my $args = $indir . join(", ", @exprs); if ($indir ne "" and $name eq "sort") { # We don't want to say "sort(f 1, 2, 3)", since perl -w will