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

Unified Diff: src/parsing/parser.cc

Issue 1511773009: Revert of [es6] support AssignmentPattern as LHS in for-in/of loops (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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.h ('k') | src/parsing/pattern-rewriter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index ca5554ddeb8661eb302c32388b498b2ef2ee688f..d2919e1216e3a32ea3cfb90f5b726bba75854ddb 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -3322,10 +3322,9 @@
void Parser::InitializeForEachStatement(ForEachStatement* stmt,
- Expression* each, Expression* subject,
- Statement* body,
- bool is_destructuring) {
- DCHECK(!is_destructuring || allow_harmony_destructuring_assignment());
+ Expression* each,
+ Expression* subject,
+ Statement* body) {
ForOfStatement* for_of = stmt->AsForOfStatement();
if (for_of != NULL) {
@@ -3376,10 +3375,6 @@
result_proxy, value_literal, RelocInfo::kNoPosition);
assign_each = factory()->NewAssignment(Token::ASSIGN, each, result_value,
RelocInfo::kNoPosition);
- if (is_destructuring) {
- assign_each = PatternRewriter::RewriteDestructuringAssignment(
- this, assign_each->AsAssignment(), scope_);
- }
}
for_of->Initialize(each, subject, body,
@@ -3388,23 +3383,6 @@
result_done,
assign_each);
} else {
- if (is_destructuring) {
- Variable* temp =
- scope_->NewTemporary(ast_value_factory()->empty_string());
- VariableProxy* temp_proxy = factory()->NewVariableProxy(temp);
- Expression* assign_each = PatternRewriter::RewriteDestructuringAssignment(
- this, factory()->NewAssignment(Token::ASSIGN, each, temp_proxy,
- RelocInfo::kNoPosition),
- scope_);
- auto block =
- factory()->NewBlock(nullptr, 2, false, RelocInfo::kNoPosition);
- block->statements()->Add(factory()->NewExpressionStatement(
- assign_each, RelocInfo::kNoPosition),
- zone());
- block->statements()->Add(body, zone());
- body = block;
- each = factory()->NewVariableProxy(temp);
- }
stmt->Initialize(each, subject, body);
}
}
@@ -3789,8 +3767,7 @@
body_block->statements()->Add(body, zone());
VariableProxy* temp_proxy =
factory()->NewVariableProxy(temp, each_beg_pos, each_end_pos);
- InitializeForEachStatement(loop, temp_proxy, enumerable, body_block,
- false);
+ InitializeForEachStatement(loop, temp_proxy, enumerable, body_block);
scope_ = for_scope;
body_scope->set_end_position(scanner()->location().end_pos);
body_scope = body_scope->FinalizeBlockScope();
@@ -3841,8 +3818,7 @@
}
} else {
int lhs_beg_pos = peek_position();
- ExpressionClassifier classifier;
- Expression* expression = ParseExpression(false, &classifier, CHECK_OK);
+ Expression* expression = ParseExpression(false, CHECK_OK);
int lhs_end_pos = scanner()->location().end_pos;
ForEachStatement::VisitMode mode;
is_let_identifier_expression =
@@ -3852,17 +3828,9 @@
if (CheckInOrOf(&mode, ok)) {
if (!*ok) return nullptr;
- bool is_destructuring =
- allow_harmony_destructuring_assignment() &&
- (expression->IsArrayLiteral() || expression->IsObjectLiteral());
- if (is_destructuring) {
- ValidateAssignmentPattern(&classifier, CHECK_OK);
- } else {
- ValidateExpression(&classifier, CHECK_OK);
- expression = this->CheckAndRewriteReferenceExpression(
- expression, lhs_beg_pos, lhs_end_pos,
- MessageTemplate::kInvalidLhsInFor, kSyntaxError, CHECK_OK);
- }
+ expression = this->CheckAndRewriteReferenceExpression(
+ expression, lhs_beg_pos, lhs_end_pos,
+ MessageTemplate::kInvalidLhsInFor, kSyntaxError, CHECK_OK);
ForEachStatement* loop =
factory()->NewForEachStatement(mode, labels, stmt_pos);
@@ -3883,8 +3851,7 @@
factory()->NewBlock(NULL, 1, false, RelocInfo::kNoPosition);
Statement* body = ParseSubStatement(NULL, CHECK_OK);
block->statements()->Add(body, zone());
- InitializeForEachStatement(loop, expression, enumerable, block,
- is_destructuring);
+ InitializeForEachStatement(loop, expression, enumerable, block);
scope_ = saved_scope;
body_scope->set_end_position(scanner()->location().end_pos);
body_scope = body_scope->FinalizeBlockScope();
@@ -4584,8 +4551,10 @@
expr->AsRewritableAssignmentExpression();
if (to_rewrite == nullptr || to_rewrite->is_rewritten()) return;
+ bool ok = true;
Parser::PatternRewriter::RewriteDestructuringAssignment(parser_, to_rewrite,
- scope_);
+ scope_, &ok);
+ DCHECK(ok);
}
private:
@@ -6554,7 +6523,10 @@
Scope* scope = pair.scope;
DCHECK_NOT_NULL(to_rewrite);
if (!to_rewrite->is_rewritten()) {
- PatternRewriter::RewriteDestructuringAssignment(this, to_rewrite, scope);
+ bool ok = true;
+ PatternRewriter::RewriteDestructuringAssignment(this, to_rewrite, scope,
+ &ok);
+ DCHECK(ok);
}
}
}
« no previous file with comments | « src/parsing/parser.h ('k') | src/parsing/pattern-rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698