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

Side by Side Diff: src/parser.cc

Issue 1295883002: Sloppy-mode let parsing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Replace array with direct ivars Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/preparser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/parser.h" 5 #include "src/parser.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/ast-literal-reindexer.h" 9 #include "src/ast-literal-reindexer.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 } 1385 }
1386 return ParseClassDeclaration(NULL, ok); 1386 return ParseClassDeclaration(NULL, ok);
1387 case Token::CONST: 1387 case Token::CONST:
1388 if (allow_const()) { 1388 if (allow_const()) {
1389 return ParseVariableStatement(kStatementListItem, NULL, ok); 1389 return ParseVariableStatement(kStatementListItem, NULL, ok);
1390 } 1390 }
1391 break; 1391 break;
1392 case Token::VAR: 1392 case Token::VAR:
1393 return ParseVariableStatement(kStatementListItem, NULL, ok); 1393 return ParseVariableStatement(kStatementListItem, NULL, ok);
1394 case Token::LET: 1394 case Token::LET:
1395 if (allow_let()) { 1395 if (IsNextLetKeyword()) {
1396 return ParseVariableStatement(kStatementListItem, NULL, ok); 1396 return ParseVariableStatement(kStatementListItem, NULL, ok);
1397 } 1397 }
1398 break; 1398 break;
1399 default: 1399 default:
1400 break; 1400 break;
1401 } 1401 }
1402 return ParseStatement(NULL, ok); 1402 return ParseStatement(NULL, ok);
1403 } 1403 }
1404 1404
1405 1405
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2632 ? MessageTemplate::kStrongConstructorThis 2632 ? MessageTemplate::kStrongConstructorThis
2633 : MessageTemplate::kStrongConstructorSuper); 2633 : MessageTemplate::kStrongConstructorSuper);
2634 *ok = false; 2634 *ok = false;
2635 return nullptr; 2635 return nullptr;
2636 } 2636 }
2637 } 2637 }
2638 return factory()->NewExpressionStatement(expr, pos); 2638 return factory()->NewExpressionStatement(expr, pos);
2639 } 2639 }
2640 break; 2640 break;
2641 2641
2642 // TODO(arv): Handle `let [`
2643 // https://code.google.com/p/v8/issues/detail?id=3847
2644
2645 default: 2642 default:
2646 break; 2643 break;
2647 } 2644 }
2648 2645
2649 bool starts_with_idenfifier = peek_any_identifier(); 2646 bool starts_with_idenfifier = peek_any_identifier();
2650 Expression* expr = ParseExpression(true, CHECK_OK); 2647 Expression* expr = ParseExpression(true, CHECK_OK);
2651 if (peek() == Token::COLON && starts_with_idenfifier && expr != NULL && 2648 if (peek() == Token::COLON && starts_with_idenfifier && expr != NULL &&
2652 expr->AsVariableProxy() != NULL && 2649 expr->AsVariableProxy() != NULL &&
2653 !expr->AsVariableProxy()->is_this()) { 2650 !expr->AsVariableProxy()->is_this()) {
2654 // Expression is a single identifier, and not, e.g., a parenthesized 2651 // Expression is a single identifier, and not, e.g., a parenthesized
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
3509 Scope* saved_scope = scope_; 3506 Scope* saved_scope = scope_;
3510 Scope* for_scope = NewScope(scope_, BLOCK_SCOPE); 3507 Scope* for_scope = NewScope(scope_, BLOCK_SCOPE);
3511 scope_ = for_scope; 3508 scope_ = for_scope;
3512 Expect(Token::FOR, CHECK_OK); 3509 Expect(Token::FOR, CHECK_OK);
3513 Expect(Token::LPAREN, CHECK_OK); 3510 Expect(Token::LPAREN, CHECK_OK);
3514 for_scope->set_start_position(scanner()->location().beg_pos); 3511 for_scope->set_start_position(scanner()->location().beg_pos);
3515 bool is_let_identifier_expression = false; 3512 bool is_let_identifier_expression = false;
3516 DeclarationParsingResult parsing_result; 3513 DeclarationParsingResult parsing_result;
3517 if (peek() != Token::SEMICOLON) { 3514 if (peek() != Token::SEMICOLON) {
3518 if (peek() == Token::VAR || (peek() == Token::CONST && allow_const()) || 3515 if (peek() == Token::VAR || (peek() == Token::CONST && allow_const()) ||
3519 (peek() == Token::LET && allow_let())) { 3516 (peek() == Token::LET && IsNextLetKeyword())) {
3520 ParseVariableDeclarations(kForStatement, &parsing_result, CHECK_OK); 3517 ParseVariableDeclarations(kForStatement, &parsing_result, CHECK_OK);
3521 is_const = parsing_result.descriptor.mode == CONST; 3518 is_const = parsing_result.descriptor.mode == CONST;
3522 3519
3523 int num_decl = parsing_result.declarations.length(); 3520 int num_decl = parsing_result.declarations.length();
3524 bool accept_IN = num_decl >= 1; 3521 bool accept_IN = num_decl >= 1;
3525 bool accept_OF = true; 3522 bool accept_OF = true;
3526 ForEachStatement::VisitMode mode; 3523 ForEachStatement::VisitMode mode;
3527 int each_beg_pos = scanner()->location().beg_pos; 3524 int each_beg_pos = scanner()->location().beg_pos;
3528 int each_end_pos = scanner()->location().end_pos; 3525 int each_end_pos = scanner()->location().end_pos;
3529 3526
(...skipping 2512 matching lines...) Expand 10 before | Expand all | Expand 10 after
6042 Expression* Parser::SpreadCallNew(Expression* function, 6039 Expression* Parser::SpreadCallNew(Expression* function,
6043 ZoneList<v8::internal::Expression*>* args, 6040 ZoneList<v8::internal::Expression*>* args,
6044 int pos) { 6041 int pos) {
6045 args->InsertAt(0, function, zone()); 6042 args->InsertAt(0, function, zone());
6046 6043
6047 return factory()->NewCallRuntime( 6044 return factory()->NewCallRuntime(
6048 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 6045 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
6049 } 6046 }
6050 } // namespace internal 6047 } // namespace internal
6051 } // namespace v8 6048 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698