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

Side by Side Diff: src/parser.cc

Issue 1315673009: Sloppy-mode let parsing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: clarify comment Created 5 years, 3 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 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 } 1395 }
1396 return ParseClassDeclaration(NULL, ok); 1396 return ParseClassDeclaration(NULL, ok);
1397 case Token::CONST: 1397 case Token::CONST:
1398 if (allow_const()) { 1398 if (allow_const()) {
1399 return ParseVariableStatement(kStatementListItem, NULL, ok); 1399 return ParseVariableStatement(kStatementListItem, NULL, ok);
1400 } 1400 }
1401 break; 1401 break;
1402 case Token::VAR: 1402 case Token::VAR:
1403 return ParseVariableStatement(kStatementListItem, NULL, ok); 1403 return ParseVariableStatement(kStatementListItem, NULL, ok);
1404 case Token::LET: 1404 case Token::LET:
1405 if (allow_let()) { 1405 if (IsNextLetKeyword()) {
1406 return ParseVariableStatement(kStatementListItem, NULL, ok); 1406 return ParseVariableStatement(kStatementListItem, NULL, ok);
1407 } 1407 }
1408 break; 1408 break;
1409 default: 1409 default:
1410 break; 1410 break;
1411 } 1411 }
1412 return ParseStatement(NULL, ok); 1412 return ParseStatement(NULL, ok);
1413 } 1413 }
1414 1414
1415 1415
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
2645 ? MessageTemplate::kStrongConstructorThis 2645 ? MessageTemplate::kStrongConstructorThis
2646 : MessageTemplate::kStrongConstructorSuper); 2646 : MessageTemplate::kStrongConstructorSuper);
2647 *ok = false; 2647 *ok = false;
2648 return nullptr; 2648 return nullptr;
2649 } 2649 }
2650 } 2650 }
2651 return factory()->NewExpressionStatement(expr, pos); 2651 return factory()->NewExpressionStatement(expr, pos);
2652 } 2652 }
2653 break; 2653 break;
2654 2654
2655 // TODO(arv): Handle `let [`
2656 // https://code.google.com/p/v8/issues/detail?id=3847
2657
2658 default: 2655 default:
2659 break; 2656 break;
2660 } 2657 }
2661 2658
2662 bool starts_with_idenfifier = peek_any_identifier(); 2659 bool starts_with_idenfifier = peek_any_identifier();
2663 Expression* expr = ParseExpression(true, CHECK_OK); 2660 Expression* expr = ParseExpression(true, CHECK_OK);
2664 if (peek() == Token::COLON && starts_with_idenfifier && expr != NULL && 2661 if (peek() == Token::COLON && starts_with_idenfifier && expr != NULL &&
2665 expr->AsVariableProxy() != NULL && 2662 expr->AsVariableProxy() != NULL &&
2666 !expr->AsVariableProxy()->is_this()) { 2663 !expr->AsVariableProxy()->is_this()) {
2667 // Expression is a single identifier, and not, e.g., a parenthesized 2664 // Expression is a single identifier, and not, e.g., a parenthesized
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
3557 Scope* saved_scope = scope_; 3554 Scope* saved_scope = scope_;
3558 Scope* for_scope = NewScope(scope_, BLOCK_SCOPE); 3555 Scope* for_scope = NewScope(scope_, BLOCK_SCOPE);
3559 scope_ = for_scope; 3556 scope_ = for_scope;
3560 Expect(Token::FOR, CHECK_OK); 3557 Expect(Token::FOR, CHECK_OK);
3561 Expect(Token::LPAREN, CHECK_OK); 3558 Expect(Token::LPAREN, CHECK_OK);
3562 for_scope->set_start_position(scanner()->location().beg_pos); 3559 for_scope->set_start_position(scanner()->location().beg_pos);
3563 bool is_let_identifier_expression = false; 3560 bool is_let_identifier_expression = false;
3564 DeclarationParsingResult parsing_result; 3561 DeclarationParsingResult parsing_result;
3565 if (peek() != Token::SEMICOLON) { 3562 if (peek() != Token::SEMICOLON) {
3566 if (peek() == Token::VAR || (peek() == Token::CONST && allow_const()) || 3563 if (peek() == Token::VAR || (peek() == Token::CONST && allow_const()) ||
3567 (peek() == Token::LET && allow_let())) { 3564 (peek() == Token::LET && IsNextLetKeyword())) {
3568 ParseVariableDeclarations(kForStatement, &parsing_result, CHECK_OK); 3565 ParseVariableDeclarations(kForStatement, &parsing_result, CHECK_OK);
3569 is_const = parsing_result.descriptor.mode == CONST; 3566 is_const = parsing_result.descriptor.mode == CONST;
3570 3567
3571 int num_decl = parsing_result.declarations.length(); 3568 int num_decl = parsing_result.declarations.length();
3572 bool accept_IN = num_decl >= 1; 3569 bool accept_IN = num_decl >= 1;
3573 bool accept_OF = true; 3570 bool accept_OF = true;
3574 ForEachStatement::VisitMode mode; 3571 ForEachStatement::VisitMode mode;
3575 int each_beg_pos = scanner()->location().beg_pos; 3572 int each_beg_pos = scanner()->location().beg_pos;
3576 int each_end_pos = scanner()->location().end_pos; 3573 int each_end_pos = scanner()->location().end_pos;
3577 3574
(...skipping 2528 matching lines...) Expand 10 before | Expand all | Expand 10 after
6106 6103
6107 Expression* Parser::SpreadCallNew(Expression* function, 6104 Expression* Parser::SpreadCallNew(Expression* function,
6108 ZoneList<v8::internal::Expression*>* args, 6105 ZoneList<v8::internal::Expression*>* args,
6109 int pos) { 6106 int pos) {
6110 args->InsertAt(0, function, zone()); 6107 args->InsertAt(0, function, zone());
6111 6108
6112 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos); 6109 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos);
6113 } 6110 }
6114 } // namespace internal 6111 } // namespace internal
6115 } // namespace v8 6112 } // 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