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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.h ('k') | src/pattern-rewriter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index dac59b7d4437ee5fd406740cf7023277dfecd0f6..61c169965d48378954a2fc30d7d91f93936ebb41 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -3607,10 +3607,26 @@ Expression* Parser::DesugarDestructuringAssignment(Expression* expr) {
// TODO(caitp): implement the desugaring
DCHECK(expr->IsAssignment());
Assignment* assign = expr->AsAssignment();
- while (assign->value()->IsAssignment()) {
- assign = assign->value()->AsAssignment();
+ Expression* value = assign->value();
+ Expression* target = assign->target();
+ Variable* result = nullptr;
+ if (value->IsAssignment()) {
caitp (gmail) 2015/10/19 11:17:39 I'll make all of this completion-value-saving code
+ value = DesugarDestructuringAssignment(value);
+ if (value->IsDoExpression()) {
+ result = value->AsDoExpression()->result()->var();
+ }
+ }
+ if (target->IsObjectLiteral() || target->IsArrayLiteral()) {
+ Block* block = factory()->NewBlock(nullptr, 8, false, expr->position());
+ bool ok = true;
+ result = PatternRewriter::RewriteDestructuringAssignment(
+ this, block, target, value, result, &ok);
+ DCHECK_EQ(ok, true);
+ DCHECK_NOT_NULL(result);
+ return factory()->NewDoExpression(block, result, expr->position());
}
- return assign->value();
+
+ return expr;
}
« 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