[Jifty-commit] r3616 - in B: B
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sat Jul 7 16:22:47 EDT 2007
Author: clkao
Date: Sat Jul 7 16:22:47 2007
New Revision: 3616
Modified:
B/B/Deparse.pm
B/t/deparse.t
Log:
anonlist and anonhash.
Modified: B/B/Deparse.pm
==============================================================================
--- B/B/Deparse.pm (original)
+++ B/B/Deparse.pm Sat Jul 7 16:22:47 2007
@@ -1699,15 +1699,13 @@
if ($kid->name eq "null") {
$kid = $kid->first;
if ($kid->name eq "anonlist" || $kid->name eq "anonhash") {
- my($pre, $post) = @{{"anonlist" => ["[","]"],
- "anonhash" => ["{","}"]}->{$kid->name}};
- my($expr, @exprs);
+ my @exprs;
+ my $method = "e_".$kid->name;
$kid = $kid->first->sibling; # skip pushmark
for (; !null($kid); $kid = $kid->sibling) {
- $expr = $self->deparse($kid, 6);
- push @exprs, $expr;
+ push @exprs, $kid;
}
- return $pre . join(", ", @exprs) . $post;
+ return $self->$method({ exprs => \@exprs });
} elsif (!null($kid->sibling) and
$kid->sibling->name eq "anoncode") {
return $self->e_anoncode({ code => $self->padval($kid->sibling->targ) });
@@ -1737,6 +1735,16 @@
return "sub " . $text;
}
+sub e_anonlist {
+ my ($self, $info) = @_;
+ return '[' . join(", ", map { $self->deparse($_, 6) } @{$info->{exprs}}) . ']';
+}
+
+sub e_anonhash {
+ my ($self, $info) = @_;
+ return '{' . join(", ", map { $self->deparse($_, 6) } @{$info->{exprs}}) . '}';
+}
+
sub pp_srefgen { pp_refgen(@_) }
sub pp_readline {
Modified: B/t/deparse.t
==============================================================================
--- B/t/deparse.t (original)
+++ B/t/deparse.t Sat Jul 7 16:22:47 2007
@@ -21,7 +21,7 @@
use warnings;
use strict;
-use Test::More tests => 42;
+use Test::More tests => 43;
use B::Deparse;
my $deparse = B::Deparse->new();
@@ -307,3 +307,6 @@
####
# 36
'Foo'->bar;
+####
+# 37
+foo('bar', [{'baz', 'fnord'}]);
More information about the Jifty-commit
mailing list