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

Unified Diff: src/parsing/pattern-rewriter.cc

Issue 1517973002: [es6] support AssignmentPattern as LHS in for-in/of loops (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Centralize the error validation to a single place, to ease confusion Created 5 years 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/parsing/parser.cc ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/pattern-rewriter.cc
diff --git a/src/parsing/pattern-rewriter.cc b/src/parsing/pattern-rewriter.cc
index a9875bdf96f60017c8664b39b8d34be0c5f7d041..ead3081f9e90178f99e85099f0b42f953449a87a 100644
--- a/src/parsing/pattern-rewriter.cc
+++ b/src/parsing/pattern-rewriter.cc
@@ -32,12 +32,12 @@ void Parser::PatternRewriter::DeclareAndInitializeVariables(
void Parser::PatternRewriter::RewriteDestructuringAssignment(
- Parser* parser, RewritableAssignmentExpression* to_rewrite, Scope* scope,
- bool* ok) {
+ Parser* parser, RewritableAssignmentExpression* to_rewrite, Scope* scope) {
PatternRewriter rewriter;
DCHECK(!to_rewrite->is_rewritten());
+ bool ok = true;
rewriter.scope_ = scope;
rewriter.parser_ = parser;
rewriter.context_ = ASSIGNMENT;
@@ -45,9 +45,21 @@ void Parser::PatternRewriter::RewriteDestructuringAssignment(
rewriter.block_ = nullptr;
rewriter.descriptor_ = nullptr;
rewriter.names_ = nullptr;
- rewriter.ok_ = ok;
+ rewriter.ok_ = &ok;
rewriter.RecurseIntoSubpattern(rewriter.pattern_, nullptr);
+ DCHECK(ok);
+}
+
+
+Expression* Parser::PatternRewriter::RewriteDestructuringAssignment(
+ Parser* parser, Assignment* assignment, Scope* scope) {
+ DCHECK_NOT_NULL(assignment);
+ DCHECK_EQ(Token::ASSIGN, assignment->op());
+ auto to_rewrite =
+ parser->factory()->NewRewritableAssignmentExpression(assignment);
+ RewriteDestructuringAssignment(parser, to_rewrite, scope);
+ return to_rewrite->expression();
}
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698