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

Side by Side Diff: src/parser.cc

Issue 1168643005: [es6] parse destructuring assignment (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arrow function parsing Created 5 years, 6 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 | « src/parser.h ('k') | src/preparser.h » ('j') | src/preparser.h » ('J')
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/v8.h" 5 #include "src/v8.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/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 2576 matching lines...) Expand 10 before | Expand all | Expand 10 after
2587 break; 2587 break;
2588 2588
2589 // TODO(arv): Handle `let [` 2589 // TODO(arv): Handle `let [`
2590 // https://code.google.com/p/v8/issues/detail?id=3847 2590 // https://code.google.com/p/v8/issues/detail?id=3847
2591 2591
2592 default: 2592 default:
2593 break; 2593 break;
2594 } 2594 }
2595 2595
2596 bool starts_with_idenfifier = peek_any_identifier(); 2596 bool starts_with_idenfifier = peek_any_identifier();
2597
2597 Expression* expr = ParseExpression(true, CHECK_OK); 2598 Expression* expr = ParseExpression(true, CHECK_OK);
2598 if (peek() == Token::COLON && starts_with_idenfifier && expr != NULL && 2599 if (peek() == Token::COLON && starts_with_idenfifier && expr != NULL &&
2599 expr->AsVariableProxy() != NULL && 2600 expr->AsVariableProxy() != NULL &&
2600 !expr->AsVariableProxy()->is_this()) { 2601 !expr->AsVariableProxy()->is_this()) {
2601 // Expression is a single identifier, and not, e.g., a parenthesized 2602 // Expression is a single identifier, and not, e.g., a parenthesized
2602 // identifier. 2603 // identifier.
2603 VariableProxy* var = expr->AsVariableProxy(); 2604 VariableProxy* var = expr->AsVariableProxy();
2604 const AstRawString* label = var->raw_name(); 2605 const AstRawString* label = var->raw_name();
2605 // TODO(1240780): We don't check for redeclaration of labels 2606 // TODO(1240780): We don't check for redeclaration of labels
2606 // during preparsing since keeping track of the set of active 2607 // during preparsing since keeping track of the set of active
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
3423 3424
3424 inner_scope->set_end_position(scanner()->location().end_pos); 3425 inner_scope->set_end_position(scanner()->location().end_pos);
3425 inner_block->set_scope(inner_scope); 3426 inner_block->set_scope(inner_scope);
3426 scope_ = for_scope; 3427 scope_ = for_scope;
3427 3428
3428 outer_loop->Initialize(NULL, NULL, NULL, inner_block); 3429 outer_loop->Initialize(NULL, NULL, NULL, inner_block);
3429 return outer_block; 3430 return outer_block;
3430 } 3431 }
3431 3432
3432 3433
3434 Expression* Parser::DesugarDestructuringAssignment(Expression* expr) {
3435 // TODO(caitp): implement the desugaring
3436 DCHECK(expr->IsAssignment());
3437 Assignment* assign = expr->AsAssignment();
3438 while (assign->value()->IsAssignment()) {
3439 assign = assign->value()->AsAssignment();
3440 }
3441 return assign->value();
3442 }
3443
3444
3433 Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels, 3445 Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
3434 bool* ok) { 3446 bool* ok) {
3435 // ForStatement :: 3447 // ForStatement ::
3436 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement 3448 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement
3437 3449
3438 int stmt_pos = peek_position(); 3450 int stmt_pos = peek_position();
3439 bool is_const = false; 3451 bool is_const = false;
3440 Statement* init = NULL; 3452 Statement* init = NULL;
3441 ZoneList<const AstRawString*> lexical_bindings(1, zone()); 3453 ZoneList<const AstRawString*> lexical_bindings(1, zone());
3442 3454
(...skipping 2375 matching lines...) Expand 10 before | Expand all | Expand 10 after
5818 Expression* Parser::SpreadCallNew(Expression* function, 5830 Expression* Parser::SpreadCallNew(Expression* function,
5819 ZoneList<v8::internal::Expression*>* args, 5831 ZoneList<v8::internal::Expression*>* args,
5820 int pos) { 5832 int pos) {
5821 args->InsertAt(0, function, zone()); 5833 args->InsertAt(0, function, zone());
5822 5834
5823 return factory()->NewCallRuntime( 5835 return factory()->NewCallRuntime(
5824 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 5836 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
5825 } 5837 }
5826 } // namespace internal 5838 } // namespace internal
5827 } // namespace v8 5839 } // namespace v8
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | src/preparser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698