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

Unified Diff: src/preparser.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/preparser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index 00332ada0985fdb644f006195d5ffd5f9fdbd30f..154a9ae5278116fc3f96cf220962afa13feb518c 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -715,15 +715,6 @@ PreParser::Statement PreParser::ParseWhileStatement(bool* ok) {
}
-bool PreParser::CheckInOrOf(bool accept_OF) {
- if (Check(Token::IN) ||
- (accept_OF && CheckContextualKeyword(CStrVector("of")))) {
- return true;
- }
- return false;
-}
-
-
PreParser::Statement PreParser::ParseForStatement(bool* ok) {
// ForStatement ::
// 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement
@@ -732,6 +723,7 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
Expect(Token::LPAREN, CHECK_OK);
bool is_let_identifier_expression = false;
if (peek() != Token::SEMICOLON) {
+ ForEachStatement::VisitMode visit_mode;
if (peek() == Token::VAR || peek() == Token::CONST ||
(peek() == Token::LET && is_strict(language_mode()))) {
bool is_lexical = peek() == Token::LET ||
@@ -743,10 +735,10 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
bool has_initializers = decl_props == kHasInitializers;
bool accept_IN = decl_count == 1 && !(is_lexical && has_initializers);
bool accept_OF = !has_initializers;
- if (accept_IN && CheckInOrOf(accept_OF)) {
+ if (accept_IN && CheckInOrOf(accept_OF, &visit_mode, ok)) {
+ if (!*ok) return Statement::Default();
ParseExpression(true, CHECK_OK);
Expect(Token::RPAREN, CHECK_OK);
-
ParseSubStatement(CHECK_OK);
return Statement::Default();
}
@@ -754,10 +746,10 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
Expression lhs = ParseExpression(false, CHECK_OK);
is_let_identifier_expression =
lhs.IsIdentifier() && lhs.AsIdentifier().IsLet();
- if (CheckInOrOf(lhs.IsIdentifier())) {
+ if (CheckInOrOf(lhs.IsIdentifier(), &visit_mode, ok)) {
+ if (!*ok) return Statement::Default();
ParseExpression(true, CHECK_OK);
Expect(Token::RPAREN, CHECK_OK);
-
ParseSubStatement(CHECK_OK);
return Statement::Default();
}
« no previous file with comments | « src/preparser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698