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

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

Issue 1417463004: Revert of [es6] Fix scoping for default parameters in arrow functions (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 unified diff | Download patch
« no previous file with comments | « src/parser.cc ('k') | src/preparser.h » ('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.h" 5 #include "src/ast.h"
6 #include "src/messages.h" 6 #include "src/messages.h"
7 #include "src/parameter-initializer-rewriter.h"
8 #include "src/parser.h" 7 #include "src/parser.h"
9 8
10 namespace v8 { 9 namespace v8 {
11 10
12 namespace internal { 11 namespace internal {
13 12
14 13
15 void Parser::PatternRewriter::DeclareAndInitializeVariables( 14 void Parser::PatternRewriter::DeclareAndInitializeVariables(
16 Block* block, const DeclarationDescriptor* declaration_descriptor, 15 Block* block, const DeclarationDescriptor* declaration_descriptor,
17 const DeclarationParsingResult::Declaration* declaration, 16 const DeclarationParsingResult::Declaration* declaration,
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 // let {<pattern> = <init>} = <value> 352 // let {<pattern> = <init>} = <value>
354 // becomes 353 // becomes
355 // temp = <value>; 354 // temp = <value>;
356 // <pattern> = temp === undefined ? <init> : temp; 355 // <pattern> = temp === undefined ? <init> : temp;
357 DCHECK(node->op() == Token::ASSIGN); 356 DCHECK(node->op() == Token::ASSIGN);
358 auto temp = CreateTempVar(current_value_); 357 auto temp = CreateTempVar(current_value_);
359 Expression* is_undefined = factory()->NewCompareOperation( 358 Expression* is_undefined = factory()->NewCompareOperation(
360 Token::EQ_STRICT, factory()->NewVariableProxy(temp), 359 Token::EQ_STRICT, factory()->NewVariableProxy(temp),
361 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), 360 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition),
362 RelocInfo::kNoPosition); 361 RelocInfo::kNoPosition);
363 Expression* initializer = node->value();
364 if (descriptor_->declaration_kind == DeclarationDescriptor::PARAMETER &&
365 descriptor_->scope->is_arrow_scope()) {
366 // TODO(adamk): Only call this if necessary.
367 RewriteParameterInitializerScope(
368 descriptor_->parser->stack_limit(), initializer,
369 descriptor_->scope->outer_scope(), descriptor_->scope);
370 }
371 Expression* value = factory()->NewConditional( 362 Expression* value = factory()->NewConditional(
372 is_undefined, initializer, factory()->NewVariableProxy(temp), 363 is_undefined, node->value(), factory()->NewVariableProxy(temp),
373 RelocInfo::kNoPosition); 364 RelocInfo::kNoPosition);
374 RecurseIntoSubpattern(node->target(), value); 365 RecurseIntoSubpattern(node->target(), value);
375 } 366 }
376 367
377 368
378 // =============== UNREACHABLE ============================= 369 // =============== UNREACHABLE =============================
379 370
380 void Parser::PatternRewriter::Visit(AstNode* node) { UNREACHABLE(); } 371 void Parser::PatternRewriter::Visit(AstNode* node) { UNREACHABLE(); }
381 372
382 #define NOT_A_PATTERN(Node) \ 373 #define NOT_A_PATTERN(Node) \
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 NOT_A_PATTERN(TryFinallyStatement) 416 NOT_A_PATTERN(TryFinallyStatement)
426 NOT_A_PATTERN(UnaryOperation) 417 NOT_A_PATTERN(UnaryOperation)
427 NOT_A_PATTERN(VariableDeclaration) 418 NOT_A_PATTERN(VariableDeclaration)
428 NOT_A_PATTERN(WhileStatement) 419 NOT_A_PATTERN(WhileStatement)
429 NOT_A_PATTERN(WithStatement) 420 NOT_A_PATTERN(WithStatement)
430 NOT_A_PATTERN(Yield) 421 NOT_A_PATTERN(Yield)
431 422
432 #undef NOT_A_PATTERN 423 #undef NOT_A_PATTERN
433 } // namespace internal 424 } // namespace internal
434 } // namespace v8 425 } // namespace v8
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698