Commit 3921281e authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Drop conditionally adding rewritten assignment to parent block

After rewriting a rewritable assignment expression we possibly add the
resulting do-expression in two places: the rewritten expression and the parent
block. That would observably generate duplicate code. Luckily this can't happen
since the only recursive paths that would call this function again change the
context to ASSIGNMENT_ELEMENT from ASSIGNMENT. Hence simply DCHECK_NULL(block_)
and reset it to nullptr at the end.

Change-Id: I17b84dedcd7daf800d9ccb90e3dd975e84b12717
Reviewed-on: https://chromium-review.googlesource.com/c/1264282Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56404}
parent 24fb7b47
......@@ -312,7 +312,7 @@ void PatternRewriter::VisitRewritableExpression(RewritableExpression* node) {
DCHECK_EQ(Token::ASSIGN, assign->op());
int pos = assign->position();
Block* old_block = block_;
DCHECK_NULL(block_);
block_ = factory()->NewBlock(8, true);
Variable* temp = nullptr;
Expression* pattern = assign->target();
......@@ -328,11 +328,7 @@ void PatternRewriter::VisitRewritableExpression(RewritableExpression* node) {
current_value_ = old_value;
Expression* expr = factory()->NewDoExpression(block_, temp, pos);
node->Rewrite(expr);
block_ = old_block;
if (block_) {
block_->statements()->Add(factory()->NewExpressionStatement(expr, pos),
zone());
}
block_ = nullptr;
}
bool PatternRewriter::DeclaresParameterContainingSloppyEval() const {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment