given(): remove support for lexical $_

There is dead code that used to allow

    my $_;
    ...
    given ($foo) {
        # lexical $_ aliased to $foo here
    }

Now that lexical $_ has been removed, remove the code.  I've left the
signatures of the newFOO() functions unchanged; they just expect a target
of 0 to always be passed now.
This commit is contained in:
David Mitchell 2015-10-02 17:19:22 +01:00
parent 9ff1a054e5
commit 5d051ee036
6 changed files with 524 additions and 517 deletions

11
op.c
View File

@ -7452,9 +7452,10 @@ S_newGIVWHENOP(pTHX_ OP *cond, OP *block,
OP *o;
PERL_ARGS_ASSERT_NEWGIVWHENOP;
PERL_UNUSED_ARG(entertarg); /* used to indicate targ of lexical $_ */
enterop = S_alloc_LOGOP(aTHX_ enter_opcode, block, NULL);
enterop->op_targ = ((entertarg == NOT_IN_PAD) ? 0 : entertarg);
enterop->op_targ = 0;
enterop->op_private = 0;
o = newUNOP(leave_opcode, 0, (OP *) enterop);
@ -7573,8 +7574,7 @@ Constructs, checks, and returns an op tree expressing a C<given> block.
C<cond> supplies the expression that will be locally assigned to a lexical
variable, and C<block> supplies the body of the C<given> construct; they
are consumed by this function and become part of the constructed op tree.
C<defsv_off> is the pad offset of the scalar lexical variable that will
be affected. If it is 0, the global C<$_> will be used.
C<defsv_off> must be zero (it used to identity the pad slot of lexical $_).
=cut
*/
@ -7583,11 +7583,14 @@ OP *
Perl_newGIVENOP(pTHX_ OP *cond, OP *block, PADOFFSET defsv_off)
{
PERL_ARGS_ASSERT_NEWGIVENOP;
PERL_UNUSED_ARG(defsv_off);
assert(!defsv_off);
return newGIVWHENOP(
ref_array_or_hash(cond),
block,
OP_ENTERGIVEN, OP_LEAVEGIVEN,
defsv_off);
0);
}
/*

847
perly.act

File diff suppressed because it is too large Load Diff

64
perly.h
View File

@ -5,27 +5,24 @@
*/
#ifdef PERL_CORE
/* A Bison parser, made by GNU Bison 2.3. */
/* A Bison parser, made by GNU Bison 2.7. */
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@ -36,10 +33,18 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
@ -128,6 +133,7 @@
ARROW = 337
};
#endif
/* Tokens. */
#define GRAMPROG 258
#define GRAMEXPR 259
@ -211,8 +217,6 @@
#define ARROW 337
#ifdef PERL_IN_TOKE_C
static bool
S_is_opval_token(int type) {
@ -239,23 +243,39 @@ S_is_opval_token(int type) {
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 2058 of yacc.c */
I32 ival; /* __DEFAULT__ (marker for regen_perly.pl;
must always be 1st union member) */
char *pval;
OP *opval;
GV *gvval;
}
/* Line 1529 of yacc.c. */
YYSTYPE;
/* Line 2058 of yacc.c */
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
/* Generated from:
* e2ef3626c25dd92c66987e4c2f707e7f194c2bd5df74da27c51df206d9809412 perly.y
* a0bc910627eeeffe8245b9a63dd97238e2e6b27b544be36b37d078cf6aba699b perly.y
* d1d4df7b8e30ac9dede664af9179e6e5e7ddc7f2ad9c4eff9e2e5b32c9e16a6e regen_perly.pl
* ex: set ro: */

View File

@ -196,33 +196,33 @@ static const yytype_uint16 yyrline[] =
0, 115, 115, 114, 125, 124, 134, 133, 146, 145,
158, 157, 170, 169, 181, 189, 197, 201, 209, 215,
216, 226, 227, 236, 240, 244, 248, 255, 257, 268,
267, 301, 300, 339, 347, 346, 355, 361, 367, 378,
380, 382, 389, 397, 399, 396, 416, 421, 428, 427,
442, 450, 456, 463, 462, 477, 481, 489, 507, 508,
513, 515, 517, 519, 521, 523, 525, 528, 534, 535,
540, 551, 552, 558, 564, 565, 570, 573, 577, 582,
586, 590, 594, 595, 599, 605, 610, 615, 616, 621,
622, 627, 628, 630, 635, 637, 643, 642, 661, 662,
666, 668, 670, 672, 676, 678, 683, 687, 691, 695,
701, 706, 712, 718, 720, 723, 722, 733, 734, 738,
742, 745, 750, 755, 758, 762, 766, 769, 774, 778,
781, 783, 785, 790, 792, 794, 799, 801, 803, 805,
807, 809, 811, 813, 815, 817, 819, 824, 826, 829,
831, 833, 836, 839, 850, 853, 860, 862, 864, 866,
868, 871, 885, 887, 891, 892, 893, 894, 895, 897,
899, 901, 903, 905, 907, 909, 911, 913, 915, 917,
919, 921, 931, 941, 951, 961, 963, 965, 968, 973,
977, 979, 981, 983, 986, 988, 991, 993, 995, 997,
999, 1001, 1003, 1005, 1007, 1010, 1012, 1014, 1016, 1018,
1020, 1024, 1027, 1026, 1039, 1040, 1041, 1046, 1050, 1052,
1057, 1059, 1062, 1064, 1066, 1071, 1073, 1078, 1079, 1084,
1085, 1091, 1095, 1096, 1097, 1100, 1101, 1104, 1108, 1112,
1118, 1124, 1126, 1130, 1134, 1135, 1139, 1140, 1144, 1145,
1150, 1152, 1154, 1157
267, 301, 300, 339, 347, 346, 355, 361, 367, 372,
374, 376, 383, 391, 393, 390, 410, 415, 422, 421,
436, 444, 450, 457, 456, 471, 475, 483, 501, 502,
507, 509, 511, 513, 515, 517, 519, 522, 528, 529,
534, 545, 546, 552, 558, 559, 564, 567, 571, 576,
580, 584, 588, 589, 593, 599, 604, 609, 610, 615,
616, 621, 622, 624, 629, 631, 637, 636, 655, 656,
660, 662, 664, 666, 670, 672, 677, 681, 685, 689,
695, 700, 706, 712, 714, 717, 716, 727, 728, 732,
736, 739, 744, 749, 752, 756, 760, 763, 768, 772,
775, 777, 779, 784, 786, 788, 793, 795, 797, 799,
801, 803, 805, 807, 809, 811, 813, 818, 820, 823,
825, 827, 830, 833, 844, 847, 854, 856, 858, 860,
862, 865, 879, 881, 885, 886, 887, 888, 889, 891,
893, 895, 897, 899, 901, 903, 905, 907, 909, 911,
913, 915, 925, 935, 945, 955, 957, 959, 962, 967,
971, 973, 975, 977, 980, 982, 985, 987, 989, 991,
993, 995, 997, 999, 1001, 1004, 1006, 1008, 1010, 1012,
1014, 1018, 1021, 1020, 1033, 1034, 1035, 1040, 1044, 1046,
1051, 1053, 1056, 1058, 1060, 1065, 1067, 1072, 1073, 1078,
1079, 1085, 1089, 1090, 1091, 1094, 1095, 1098, 1102, 1106,
1112, 1118, 1120, 1124, 1128, 1129, 1133, 1134, 1138, 1139,
1144, 1146, 1148, 1151
};
#endif
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
#if YYDEBUG || YYERROR_VERBOSE || 0
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
@ -242,18 +242,18 @@ static const char *const yytname[] =
"BITOROP", "BITANDOP", "SHIFTOP", "MATCHOP", "'!'", "'~'", "REFGEN",
"UMINUS", "POWOP", "POSTJOIN", "POSTDEC", "POSTINC", "PREDEC", "PREINC",
"ARROW", "')'", "'('", "';'", "'$'", "'*'", "'/'", "$accept", "grammar",
"@1", "@2", "@3", "@4", "@5", "@6", "block", "formblock", "remember",
"mblock", "mremember", "stmtseq", "formstmtseq", "fullstmt",
"labfullstmt", "barestmt", "@7", "@8", "@9", "@10", "@11", "@12", "@13",
"formline", "formarg", "sideff", "else", "cont", "mintro", "nexpr",
"texpr", "iexpr", "mexpr", "mnexpr", "miexpr", "formname", "startsub",
"startanonsub", "startformsub", "subname", "proto", "subattrlist",
"myattrlist", "subsignature", "@14", "optsubbody", "expr", "listexpr",
"listop", "@15", "method", "subscripted", "termbinop", "termunop",
"anonymous", "termdo", "term", "@16", "myattrterm", "myterm",
"$@1", "$@2", "$@3", "$@4", "$@5", "$@6", "block", "formblock",
"remember", "mblock", "mremember", "stmtseq", "formstmtseq", "fullstmt",
"labfullstmt", "barestmt", "$@7", "$@8", "$@9", "$@10", "$@11", "@12",
"$@13", "formline", "formarg", "sideff", "else", "cont", "mintro",
"nexpr", "texpr", "iexpr", "mexpr", "mnexpr", "miexpr", "formname",
"startsub", "startanonsub", "startformsub", "subname", "proto",
"subattrlist", "myattrlist", "subsignature", "@14", "optsubbody", "expr",
"listexpr", "listop", "@15", "method", "subscripted", "termbinop",
"termunop", "anonymous", "termdo", "term", "@16", "myattrterm", "myterm",
"optlistexpr", "optexpr", "optrepl", "my_scalar", "my_var",
"refgen_topic", "amper", "scalar", "ary", "hsh", "arylen", "star",
"sliceme", "kvslice", "gelem", "indirob", 0
"sliceme", "kvslice", "gelem", "indirob", YY_NULL
};
#endif
@ -338,8 +338,8 @@ static const yytype_uint8 yyr2[] =
1, 1, 1, 1
};
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
STATE-NUM when YYTABLE doesn't specify something else to do. Zero
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
Performed when YYTABLE doesn't specify something else to do. Zero
means the default is an error. */
static const yytype_uint8 yydefact[] =
{
@ -482,8 +482,7 @@ static const yytype_int16 yypgoto[] =
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
number is the opposite. If zero, do what YYDEFACT says.
If YYTABLE_NINF, syntax error. */
number is the opposite. If YYTABLE_NINF, syntax error. */
#define YYTABLE_NINF -249
static const yytype_int16 yytable[] =
{
@ -783,6 +782,12 @@ static const yytype_int16 yytable[] =
184
};
#define yypact_value_is_default(Yystate) \
(!!((Yystate) == (-402)))
#define yytable_value_is_error(Yytable_value) \
(!!((Yytable_value) == (-249)))
static const yytype_int16 yycheck[] =
{
15, 308, 9, 325, 9, 40, 46, 46, 115, 9,
@ -1160,21 +1165,21 @@ static const toketypes yy_type_tab[] =
toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival,
toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival,
toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival,
toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_opval, toketype_opval, toketype_ival,
toketype_opval, toketype_ival, toketype_opval, toketype_opval, toketype_opval,
toketype_opval, toketype_opval, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival,
toketype_opval, toketype_opval, toketype_opval, toketype_opval, toketype_opval, toketype_ival, toketype_opval,
toketype_opval, toketype_opval, toketype_opval, toketype_opval, toketype_opval, toketype_opval, toketype_ival,
toketype_ival, toketype_ival, toketype_opval, toketype_opval, toketype_opval,
toketype_opval, toketype_opval, toketype_ival, toketype_opval, toketype_opval, toketype_opval,
toketype_opval, toketype_ival, toketype_opval, toketype_opval, toketype_opval, toketype_opval,
toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_opval, toketype_opval,
toketype_ival, toketype_opval, toketype_ival, toketype_opval, toketype_opval, toketype_opval,
toketype_opval, toketype_opval, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival, toketype_ival,
toketype_ival, toketype_opval, toketype_opval, toketype_opval, toketype_opval, toketype_opval, toketype_ival,
toketype_opval, toketype_opval, toketype_opval, toketype_opval, toketype_opval, toketype_opval, toketype_opval,
toketype_ival, toketype_ival, toketype_ival, toketype_opval, toketype_opval,
toketype_opval, toketype_opval, toketype_opval, toketype_ival, toketype_opval, toketype_opval,
toketype_opval, toketype_opval, toketype_ival, toketype_opval, toketype_opval, toketype_opval,
toketype_opval, toketype_opval, toketype_opval, toketype_opval, toketype_ival, toketype_opval, toketype_opval,
toketype_opval, toketype_opval, toketype_opval, toketype_opval, toketype_opval,
toketype_opval, toketype_opval, toketype_opval, toketype_opval, toketype_opval, toketype_opval, toketype_opval,
toketype_opval, toketype_opval, toketype_opval, toketype_opval
};
/* Generated from:
* e2ef3626c25dd92c66987e4c2f707e7f194c2bd5df74da27c51df206d9809412 perly.y
* a0bc910627eeeffe8245b9a63dd97238e2e6b27b544be36b37d078cf6aba699b perly.y
* d1d4df7b8e30ac9dede664af9179e6e5e7ddc7f2ad9c4eff9e2e5b32c9e16a6e regen_perly.pl
* ex: set ro: */

View File

@ -366,13 +366,7 @@ barestmt: PLUGSTMT
}
| GIVEN '(' remember mexpr ')' mblock
{
const PADOFFSET offset = pad_findmy_pvs("$_", 0);
$$ = block_end($3,
newGIVENOP($4, op_scope($6),
offset == NOT_IN_PAD
|| PAD_COMPNAME_FLAGS_isOUR(offset)
? 0
: offset));
$$ = block_end($3, newGIVENOP($4, op_scope($6), 0));
parser->copline = (line_t)$1;
}
| WHEN '(' remember mexpr ')' mblock

View File

@ -4340,15 +4340,9 @@ PP(pp_entergiven)
ENTER_with_name("given");
SAVETMPS;
if (PL_op->op_targ) {
SAVEPADSVANDMORTALIZE(PL_op->op_targ);
SvREFCNT_dec(PAD_SVl(PL_op->op_targ));
PAD_SVl(PL_op->op_targ) = SvREFCNT_inc_NN(POPs);
}
else {
SAVE_DEFSV;
DEFSV_set(POPs);
}
assert(!PL_op->op_targ); /* used to be set for lexical $_ */
SAVE_DEFSV;
DEFSV_set(POPs);
PUSHBLOCK(cx, CXt_GIVEN, SP);
PUSHGIVEN(cx);