Permalink
Browse files

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.
  • Loading branch information...
Zefram
Zefram committed Dec 5, 2017
1 parent 40b0df6 commit 16ea2c1905a8b12a3ddd72561c74de0063cbcc40
Showing with 193 additions and 230 deletions.
  1. +1 −1 ext/Opcode/Opcode.pm
  2. +11 −11 lib/B/Deparse.pm
  3. +0 −1 lib/B/Op_private.pm
  4. +1 −2 op.c
  5. +1 −8 opcode.h
  6. +178 −179 opnames.h
  7. +1 −26 pp_ctl.c
  8. +0 −1 pp_proto.h
  9. +0 −1 regen/opcodes
View
@@ -426,7 +426,7 @@ These are a hotchpotch of opcodes still waiting to be considered
entertry leavetry -- can be used to 'hide' fatal errors
entergiven leavegiven
entergiven
enterwhen leavewhen
continue
smartmatch
View
@@ -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;
View
@@ -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];
View
3 op.c
@@ -2210,7 +2210,6 @@ Perl_scalarvoid(pTHX_ OP *arg)
case OP_LEAVETRY:
case OP_LEAVELOOP:
case OP_LINESEQ:
case OP_LEAVEGIVEN:
case OP_LEAVEWHEN:
kids:
for (kid = cLISTOPo->op_first; kid; kid = OpSIBLING(kid))
@@ -8776,7 +8775,7 @@ Perl_newGIVENOP(pTHX_ OP *cond, OP *block, PADOFFSET defsv_off)
OpLASTSIB_set(block, enterop);
enterop->op_flags = OPf_KIDS;
leaveop = newUNOP(OP_LEAVEGIVEN, 0, enterop);
leaveop = newBINOP(OP_LEAVELOOP, 0, enterop, newOP(OP_NULL, 0));
leaveop->op_next = LINKLIST(cond);
cond->op_next = enterop;
enterop = CHECKOP(OP_ENTERGIVEN, enterop);
View
@@ -364,7 +364,6 @@ EXTCONST char* const PL_op_name[] = {
"method_redir",
"method_redir_super",
"entergiven",
"leavegiven",
"enterwhen",
"leavewhen",
"continue",
@@ -768,7 +767,6 @@ EXTCONST char* const PL_op_desc[] = {
"redirect method with known name",
"redirect super method with known name",
"given()",
"leave given block",
"when()",
"leave when block",
"continue",
@@ -1184,7 +1182,6 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */
Perl_pp_method_redir,
Perl_pp_method_redir_super,
Perl_pp_entergiven,
Perl_pp_leavegiven,
Perl_pp_enterwhen,
Perl_pp_leavewhen,
Perl_pp_continue,
@@ -1596,7 +1593,6 @@ EXT Perl_check_t PL_check[] /* or perlvars.h */
Perl_ck_null, /* method_redir */
Perl_ck_null, /* method_redir_super */
Perl_ck_null, /* entergiven */
Perl_ck_null, /* leavegiven */
Perl_ck_null, /* enterwhen */
Perl_ck_null, /* leavewhen */
Perl_ck_null, /* continue */
@@ -2004,7 +2000,6 @@ EXTCONST U32 PL_opargs[] = {
0x00000e40, /* method_redir */
0x00000e40, /* method_redir_super */
0x00000940, /* entergiven */
0x00000100, /* leavegiven */
0x00000340, /* enterwhen */
0x00000100, /* leavewhen */
0x00000000, /* continue */
@@ -2667,7 +2662,6 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = {
0, /* method_redir */
0, /* method_redir_super */
-1, /* entergiven */
0, /* leavegiven */
0, /* enterwhen */
0, /* leavewhen */
-1, /* continue */
@@ -2863,7 +2857,7 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = {
*/
EXTCONST U16 PL_op_private_bitdefs[] = {
0x0003, /* scalar, prototype, refgen, srefgen, readline, regcmaybe, regcreset, regcomp, substcont, chop, schop, defined, undef, study, preinc, i_preinc, predec, i_predec, postinc, i_postinc, postdec, i_postdec, negate, i_negate, not, complement, ucfirst, lcfirst, uc, lc, quotemeta, aeach, avalues, each, pop, shift, grepstart, mapstart, mapwhile, range, and, or, dor, andassign, orassign, dorassign, argcheck, argdefelem, method, method_named, method_super, method_redir, method_redir_super, leavegiven, enterwhen, leavewhen, untie, tied, dbmclose, getsockname, getpeername, lstat, stat, readlink, readdir, telldir, rewinddir, closedir, localtime, alarm, require, dofile, entertry, ghbyname, gnbyname, gpbyname, shostent, snetent, sprotoent, sservent, gpwnam, gpwuid, ggrnam, ggrgid, lock, once, fc, anonconst */
0x0003, /* scalar, prototype, refgen, srefgen, readline, regcmaybe, regcreset, regcomp, substcont, chop, schop, defined, undef, study, preinc, i_preinc, predec, i_predec, postinc, i_postinc, postdec, i_postdec, negate, i_negate, not, complement, ucfirst, lcfirst, uc, lc, quotemeta, aeach, avalues, each, pop, shift, grepstart, mapstart, mapwhile, range, and, or, dor, andassign, orassign, dorassign, argcheck, argdefelem, method, method_named, method_super, method_redir, method_redir_super, enterwhen, leavewhen, untie, tied, dbmclose, getsockname, getpeername, lstat, stat, readlink, readdir, telldir, rewinddir, closedir, localtime, alarm, require, dofile, entertry, ghbyname, gnbyname, gpbyname, shostent, snetent, sprotoent, sservent, gpwnam, gpwuid, ggrnam, ggrgid, lock, once, fc, anonconst */
0x2ebc, 0x3fb9, /* pushmark */
0x00bd, /* wantarray, runcv */
0x0578, 0x1930, 0x406c, 0x3b28, 0x3305, /* const */
@@ -3158,7 +3152,6 @@ EXTCONST U8 PL_op_private_valid[] = {
/* METHOD_REDIR */ (OPpARG1_MASK),
/* METHOD_REDIR_SUPER */ (OPpARG1_MASK),
/* ENTERGIVEN */ (0),
/* LEAVEGIVEN */ (OPpARG1_MASK),
/* ENTERWHEN */ (OPpARG1_MASK),
/* LEAVEWHEN */ (OPpARG1_MASK),
/* CONTINUE */ (0),
Oops, something went wrong.

0 comments on commit 16ea2c1

Please sign in to comment.