summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2017-12-05 21:24:19 +0000
committerZefram <zefram@fysh.org>2017-12-05 21:24:19 +0000
commit16ea2c1905a8b12a3ddd72561c74de0063cbcc40 (patch)
tree25c1924d4d36685e57b580211a3cfb711c390a26 /lib
parent40b0df696c4f45c9e0e43ec2121b53bc06a586db (diff)
downloadperl-16ea2c1905a8b12a3ddd72561c74de0063cbcc40.tar.gz
merge leavegiven op type into leaveloop
The leaveloop op type can already do the whole job, with leavegiven being a near duplicate of it. Replace all uses of leavegiven with leaveloop.
Diffstat (limited to 'lib')
-rw-r--r--lib/B/Deparse.pm22
-rw-r--r--lib/B/Op_private.pm1
2 files changed, 11 insertions, 12 deletions
diff --git a/lib/B/Deparse.pm b/lib/B/Deparse.pm
index 02ea4bc5f0..fe8abbf4e1 100644
--- a/lib/B/Deparse.pm
+++ b/lib/B/Deparse.pm
@@ -2539,23 +2539,16 @@ sub pp_lock { unop(@_, "lock") }
sub pp_continue { unop(@_, "continue"); }
-sub givwhen {
- my $self = shift;
- my($op, $cx, $givwhen) = @_;
-
+sub pp_leavewhen {
+ my($self, $op, $cx) = @_;
+ my $when = $self->keyword("when");
my $enterop = $op->first;
my $cond = $enterop->first;
my $cond_str = $self->deparse($cond, 1);
my $block = $self->deparse($cond->sibling, 0);
-
- return "$givwhen ($cond_str) {\n".
- "\t$block\n".
- "\b}\cK";
+ return "$when ($cond_str) {\n\t$block\n\b}\cK";
}
-sub pp_leavegiven { givwhen(@_, $_[0]->keyword("given")); }
-sub pp_leavewhen { givwhen(@_, $_[0]->keyword("when")); }
-
sub pp_exists {
my $self = shift;
my($op, $cx) = @_;
@@ -3792,6 +3785,13 @@ sub loop_common {
$bare = 1;
}
$body = $kid;
+ } elsif ($enter->name eq "entergiven") { # given
+ my $given = $self->keyword("given");
+ my $enterop = $op->first;
+ my $topic = $enterop->first;
+ my $topic_str = $self->deparse($topic, 1);
+ my $block = $self->deparse($topic->sibling, 0);
+ return "$given ($topic_str) {\n\t$block\n\b}\cK";
} elsif ($enter->name eq "enteriter") { # foreach
my $ary = $enter->first->sibling; # first was pushmark
my $var = $ary->sibling;
diff --git a/lib/B/Op_private.pm b/lib/B/Op_private.pm
index 5df382a329..4718a25031 100644
--- a/lib/B/Op_private.pm
+++ b/lib/B/Op_private.pm
@@ -405,7 +405,6 @@ $bits{lc}{0} = $bf[0];
$bits{lcfirst}{0} = $bf[0];
@{$bits{le}}{1,0} = ($bf[1], $bf[1]);
$bits{leaveeval}{0} = $bf[0];
-$bits{leavegiven}{0} = $bf[0];
@{$bits{leaveloop}}{1,0} = ($bf[1], $bf[1]);
$bits{leavesub}{0} = $bf[0];
$bits{leavesublv}{0} = $bf[0];