Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Unified Diff: src/parser.cc

Issue 939063002: [strong] Deprecate for-in (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index bb8cb52b75068f0aee6941880fd7d1ecfe58bd29..1fc131c4dbf17a4d9cd5b9b097e720354bf80280 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -2881,19 +2881,6 @@ WhileStatement* Parser::ParseWhileStatement(
}
-bool Parser::CheckInOrOf(bool accept_OF,
- ForEachStatement::VisitMode* visit_mode) {
- if (Check(Token::IN)) {
- *visit_mode = ForEachStatement::ENUMERATE;
- return true;
- } else if (accept_OF && CheckContextualKeyword(CStrVector("of"))) {
- *visit_mode = ForEachStatement::ITERATE;
- return true;
- }
- return false;
-}
-
-
void Parser::InitializeForEachStatement(ForEachStatement* stmt,
Expression* each,
Expression* subject,
@@ -3222,7 +3209,8 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
ForEachStatement::VisitMode mode;
int each_pos = position();
- if (name != NULL && CheckInOrOf(accept_OF, &mode)) {
+ if (name != NULL && CheckInOrOf(accept_OF, &mode, ok)) {
+ if (!*ok) return nullptr;
ForEachStatement* loop =
factory()->NewForEachStatement(mode, labels, stmt_pos);
Target target(&this->target_stack_, loop);
@@ -3259,7 +3247,9 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
ForEachStatement::VisitMode mode;
int each_pos = position();
- if (accept_IN && CheckInOrOf(accept_OF, &mode)) {
+ if (accept_IN && CheckInOrOf(accept_OF, &mode, ok)) {
+ if (!*ok) return nullptr;
+
// Rewrite a for-in statement of the form
//
// for (let/const x in e) b
@@ -3321,7 +3311,8 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
expression->AsVariableProxy()->raw_name() ==
ast_value_factory()->let_string();
- if (CheckInOrOf(accept_OF, &mode)) {
+ if (CheckInOrOf(accept_OF, &mode, ok)) {
+ if (!*ok) return nullptr;
expression = this->CheckAndRewriteReferenceExpression(
expression, lhs_location, "invalid_lhs_in_for", CHECK_OK);
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698