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

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: Completion-value reusing that may not necessarily accomplish anything 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
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 3585 matching lines...) Expand 10 before | Expand all | Expand 10 after
3596 3596
3597 inner_scope->set_end_position(scanner()->location().end_pos); 3597 inner_scope->set_end_position(scanner()->location().end_pos);
3598 inner_block->set_scope(inner_scope); 3598 inner_block->set_scope(inner_scope);
3599 scope_ = for_scope; 3599 scope_ = for_scope;
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::DesugarDestructuringAssignmentInternal(Expression* expr,
3607 Variable** result) {
3608 Assignment* assign = expr->AsAssignment();
3609 Expression* value = assign->value();
3610 Expression* target = assign->target();
3611 if (value->IsAssignment()) {
3612 value = DesugarDestructuringAssignmentInternal(value, result);
3613 }
3614 if (target->IsObjectLiteral() || target->IsArrayLiteral()) {
3615 Block* block = factory()->NewBlock(nullptr, 8, false, expr->position());
3616 bool ok = true;
3617 *result = PatternRewriter::RewriteDestructuringAssignment(
3618 this, block, target, value, *result, &ok);
3619 DCHECK_EQ(ok, true);
3620 DCHECK_NOT_NULL(*result);
3621 return factory()->NewDoExpression(block, *result, expr->position());
3622 }
3623
3624 return expr;
3625 }
3626
3627
3606 Expression* Parser::DesugarDestructuringAssignment(Expression* expr) { 3628 Expression* Parser::DesugarDestructuringAssignment(Expression* expr) {
3607 // TODO(caitp): implement the desugaring
3608 DCHECK(expr->IsAssignment()); 3629 DCHECK(expr->IsAssignment());
3609 Assignment* assign = expr->AsAssignment(); 3630 Variable* result = nullptr;
3610 while (assign->value()->IsAssignment()) { 3631
3611 assign = assign->value()->AsAssignment(); 3632 return DesugarDestructuringAssignmentInternal(expr, &result);
3612 }
3613 return assign->value();
3614 } 3633 }
3615 3634
3616 3635
3617 Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels, 3636 Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
3618 bool* ok) { 3637 bool* ok) {
3619 // ForStatement :: 3638 // ForStatement ::
3620 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement 3639 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement
3621 3640
3622 int stmt_pos = peek_position(); 3641 int stmt_pos = peek_position();
3623 bool is_const = false; 3642 bool is_const = false;
(...skipping 2774 matching lines...) Expand 10 before | Expand all | Expand 10 after
6398 6417
6399 Expression* Parser::SpreadCallNew(Expression* function, 6418 Expression* Parser::SpreadCallNew(Expression* function,
6400 ZoneList<v8::internal::Expression*>* args, 6419 ZoneList<v8::internal::Expression*>* args,
6401 int pos) { 6420 int pos) {
6402 args->InsertAt(0, function, zone()); 6421 args->InsertAt(0, function, zone());
6403 6422
6404 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos); 6423 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos);
6405 } 6424 }
6406 } // namespace internal 6425 } // namespace internal
6407 } // namespace v8 6426 } // namespace v8
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/pattern-rewriter.cc » ('j') | src/pattern-rewriter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698