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: Rebase + Bunch of tests + Nits fixed 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 2593 matching lines...) Expand 10 before | Expand all | Expand 10 after
2604 break; 2604 break;
2605 2605
2606 // TODO(arv): Handle `let [` 2606 // TODO(arv): Handle `let [`
2607 // https://code.google.com/p/v8/issues/detail?id=3847 2607 // https://code.google.com/p/v8/issues/detail?id=3847
2608 2608
2609 default: 2609 default:
2610 break; 2610 break;
2611 } 2611 }
2612 2612
2613 bool starts_with_idenfifier = peek_any_identifier(); 2613 bool starts_with_idenfifier = peek_any_identifier();
2614
2614 Expression* expr = ParseExpression(true, CHECK_OK); 2615 Expression* expr = ParseExpression(true, CHECK_OK);
2615 if (peek() == Token::COLON && starts_with_idenfifier && expr != NULL && 2616 if (peek() == Token::COLON && starts_with_idenfifier && expr != NULL &&
2616 expr->AsVariableProxy() != NULL && 2617 expr->AsVariableProxy() != NULL &&
2617 !expr->AsVariableProxy()->is_this()) { 2618 !expr->AsVariableProxy()->is_this()) {
2618 // Expression is a single identifier, and not, e.g., a parenthesized 2619 // Expression is a single identifier, and not, e.g., a parenthesized
2619 // identifier. 2620 // identifier.
2620 VariableProxy* var = expr->AsVariableProxy(); 2621 VariableProxy* var = expr->AsVariableProxy();
2621 const AstRawString* label = var->raw_name(); 2622 const AstRawString* label = var->raw_name();
2622 // TODO(1240780): We don't check for redeclaration of labels 2623 // TODO(1240780): We don't check for redeclaration of labels
2623 // during preparsing since keeping track of the set of active 2624 // during preparsing since keeping track of the set of active
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
3452 3453
3453 inner_scope->set_end_position(scanner()->location().end_pos); 3454 inner_scope->set_end_position(scanner()->location().end_pos);
3454 inner_block->set_scope(inner_scope); 3455 inner_block->set_scope(inner_scope);
3455 scope_ = for_scope; 3456 scope_ = for_scope;
3456 3457
3457 outer_loop->Initialize(NULL, NULL, NULL, inner_block); 3458 outer_loop->Initialize(NULL, NULL, NULL, inner_block);
3458 return outer_block; 3459 return outer_block;
3459 } 3460 }
3460 3461
3461 3462
3463 Expression* Parser::DesugarDestructuringAssignment(Expression* expr, bool* ok) {
3464 // TODO(caitp): implement the desugaring
3465 DCHECK(expr->IsAssignment());
3466 Assignment* assign = expr->AsAssignment();
3467 while (assign->value()->IsAssignment()) {
3468 assign = assign->value()->AsAssignment();
3469 }
3470 return assign->value();
3471 }
3472
3473
3462 Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels, 3474 Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
3463 bool* ok) { 3475 bool* ok) {
3464 // ForStatement :: 3476 // ForStatement ::
3465 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement 3477 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement
3466 3478
3467 int stmt_pos = peek_position(); 3479 int stmt_pos = peek_position();
3468 bool is_const = false; 3480 bool is_const = false;
3469 Statement* init = NULL; 3481 Statement* init = NULL;
3470 ZoneList<const AstRawString*> lexical_bindings(1, zone()); 3482 ZoneList<const AstRawString*> lexical_bindings(1, zone());
3471 3483
(...skipping 2379 matching lines...) Expand 10 before | Expand all | Expand 10 after
5851 Expression* Parser::SpreadCallNew(Expression* function, 5863 Expression* Parser::SpreadCallNew(Expression* function,
5852 ZoneList<v8::internal::Expression*>* args, 5864 ZoneList<v8::internal::Expression*>* args,
5853 int pos) { 5865 int pos) {
5854 args->InsertAt(0, function, zone()); 5866 args->InsertAt(0, function, zone());
5855 5867
5856 return factory()->NewCallRuntime( 5868 return factory()->NewCallRuntime(
5857 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 5869 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
5858 } 5870 }
5859 } // namespace internal 5871 } // namespace internal
5860 } // namespace v8 5872 } // 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