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

Side by Side Diff: src/parsing/pattern-rewriter.cc

Issue 1767063002: Fix completion value of empty catch block in the presence of destructuring. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 9 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
« no previous file with comments | « src/parsing/parser.cc ('k') | test/mjsunit/harmony/destructuring.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/ast/ast.h" 5 #include "src/ast/ast.h"
6 #include "src/messages.h" 6 #include "src/messages.h"
7 #include "src/parsing/parameter-initializer-rewriter.h" 7 #include "src/parsing/parameter-initializer-rewriter.h"
8 #include "src/parsing/parser.h" 8 #include "src/parsing/parser.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 11
12 namespace internal { 12 namespace internal {
13 13
14 void Parser::PatternRewriter::DeclareAndInitializeVariables( 14 void Parser::PatternRewriter::DeclareAndInitializeVariables(
15 Block* block, const DeclarationDescriptor* declaration_descriptor, 15 Block* block, const DeclarationDescriptor* declaration_descriptor,
16 const DeclarationParsingResult::Declaration* declaration, 16 const DeclarationParsingResult::Declaration* declaration,
17 ZoneList<const AstRawString*>* names, bool* ok) { 17 ZoneList<const AstRawString*>* names, bool* ok) {
18 PatternRewriter rewriter; 18 PatternRewriter rewriter;
19 19
20 DCHECK(block->ignore_completion_value());
21
20 rewriter.scope_ = declaration_descriptor->scope; 22 rewriter.scope_ = declaration_descriptor->scope;
21 rewriter.parser_ = declaration_descriptor->parser; 23 rewriter.parser_ = declaration_descriptor->parser;
22 rewriter.context_ = BINDING; 24 rewriter.context_ = BINDING;
23 rewriter.pattern_ = declaration->pattern; 25 rewriter.pattern_ = declaration->pattern;
24 rewriter.initializer_position_ = declaration->initializer_position; 26 rewriter.initializer_position_ = declaration->initializer_position;
25 rewriter.block_ = block; 27 rewriter.block_ = block;
26 rewriter.descriptor_ = declaration_descriptor; 28 rewriter.descriptor_ = declaration_descriptor;
27 rewriter.names_ = names; 29 rewriter.names_ = names;
28 rewriter.ok_ = ok; 30 rewriter.ok_ = ok;
29 rewriter.recursion_level_ = 0; 31 rewriter.recursion_level_ = 0;
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), 353 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition),
352 RelocInfo::kNoPosition); 354 RelocInfo::kNoPosition);
353 value = factory()->NewConditional(is_undefined, initializer, 355 value = factory()->NewConditional(is_undefined, initializer,
354 factory()->NewVariableProxy(temp_var), 356 factory()->NewVariableProxy(temp_var),
355 RelocInfo::kNoPosition); 357 RelocInfo::kNoPosition);
356 } 358 }
357 359
358 PatternContext old_context = SetAssignmentContextIfNeeded(initializer); 360 PatternContext old_context = SetAssignmentContextIfNeeded(initializer);
359 int pos = assign->position(); 361 int pos = assign->position();
360 Block* old_block = block_; 362 Block* old_block = block_;
361 block_ = factory()->NewBlock(nullptr, 8, false, pos); 363 block_ = factory()->NewBlock(nullptr, 8, true, pos);
362 Variable* temp = nullptr; 364 Variable* temp = nullptr;
363 Expression* pattern = assign->target(); 365 Expression* pattern = assign->target();
364 Expression* old_value = current_value_; 366 Expression* old_value = current_value_;
365 current_value_ = value; 367 current_value_ = value;
366 if (pattern->IsObjectLiteral()) { 368 if (pattern->IsObjectLiteral()) {
367 VisitObjectLiteral(pattern->AsObjectLiteral(), &temp); 369 VisitObjectLiteral(pattern->AsObjectLiteral(), &temp);
368 } else { 370 } else {
369 DCHECK(pattern->IsArrayLiteral()); 371 DCHECK(pattern->IsArrayLiteral());
370 VisitArrayLiteral(pattern->AsArrayLiteral(), &temp); 372 VisitArrayLiteral(pattern->AsArrayLiteral(), &temp);
371 } 373 }
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 NOT_A_PATTERN(TryFinallyStatement) 617 NOT_A_PATTERN(TryFinallyStatement)
616 NOT_A_PATTERN(UnaryOperation) 618 NOT_A_PATTERN(UnaryOperation)
617 NOT_A_PATTERN(VariableDeclaration) 619 NOT_A_PATTERN(VariableDeclaration)
618 NOT_A_PATTERN(WhileStatement) 620 NOT_A_PATTERN(WhileStatement)
619 NOT_A_PATTERN(WithStatement) 621 NOT_A_PATTERN(WithStatement)
620 NOT_A_PATTERN(Yield) 622 NOT_A_PATTERN(Yield)
621 623
622 #undef NOT_A_PATTERN 624 #undef NOT_A_PATTERN
623 } // namespace internal 625 } // namespace internal
624 } // namespace v8 626 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | test/mjsunit/harmony/destructuring.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698