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

Side by Side Diff: src/parser.cc

Issue 1411203002: [es6] implement destructuring assignment [clean diff] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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/pattern-rewriter.cc » ('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 3589 matching lines...) Expand 10 before | Expand all | Expand 10 after
3600 3600
3601 outer_loop->Initialize(NULL, NULL, NULL, inner_block); 3601 outer_loop->Initialize(NULL, NULL, NULL, inner_block);
3602 return outer_block; 3602 return outer_block;
3603 } 3603 }
3604 3604
3605 3605
3606 Expression* Parser::DesugarDestructuringAssignment(Expression* expr) { 3606 Expression* Parser::DesugarDestructuringAssignment(Expression* expr) {
3607 // TODO(caitp): implement the desugaring 3607 // TODO(caitp): implement the desugaring
3608 DCHECK(expr->IsAssignment()); 3608 DCHECK(expr->IsAssignment());
3609 Assignment* assign = expr->AsAssignment(); 3609 Assignment* assign = expr->AsAssignment();
3610 while (assign->value()->IsAssignment()) { 3610 Expression* value = assign->value();
3611 assign = assign->value()->AsAssignment(); 3611 Expression* target = assign->target();
3612 Variable* result = nullptr;
3613 if (value->IsAssignment()) {
caitp (gmail) 2015/10/19 11:17:39 I'll make all of this completion-value-saving code
3614 value = DesugarDestructuringAssignment(value);
3615 if (value->IsDoExpression()) {
3616 result = value->AsDoExpression()->result()->var();
3617 }
3612 } 3618 }
3613 return assign->value(); 3619 if (target->IsObjectLiteral() || target->IsArrayLiteral()) {
3620 Block* block = factory()->NewBlock(nullptr, 8, false, expr->position());
3621 bool ok = true;
3622 result = PatternRewriter::RewriteDestructuringAssignment(
3623 this, block, target, value, result, &ok);
3624 DCHECK_EQ(ok, true);
3625 DCHECK_NOT_NULL(result);
3626 return factory()->NewDoExpression(block, result, expr->position());
3627 }
3628
3629 return expr;
3614 } 3630 }
3615 3631
3616 3632
3617 Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels, 3633 Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
3618 bool* ok) { 3634 bool* ok) {
3619 // ForStatement :: 3635 // ForStatement ::
3620 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement 3636 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement
3621 3637
3622 int stmt_pos = peek_position(); 3638 int stmt_pos = peek_position();
3623 bool is_const = false; 3639 bool is_const = false;
(...skipping 2774 matching lines...) Expand 10 before | Expand all | Expand 10 after
6398 6414
6399 Expression* Parser::SpreadCallNew(Expression* function, 6415 Expression* Parser::SpreadCallNew(Expression* function,
6400 ZoneList<v8::internal::Expression*>* args, 6416 ZoneList<v8::internal::Expression*>* args,
6401 int pos) { 6417 int pos) {
6402 args->InsertAt(0, function, zone()); 6418 args->InsertAt(0, function, zone());
6403 6419
6404 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos); 6420 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos);
6405 } 6421 }
6406 } // namespace internal 6422 } // namespace internal
6407 } // namespace v8 6423 } // namespace v8
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/pattern-rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698