| OLD | NEW |
| 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 { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 proxy, descriptor_->mode, descriptor_->scope, | 152 proxy, descriptor_->mode, descriptor_->scope, |
| 153 descriptor_->declaration_pos); | 153 descriptor_->declaration_pos); |
| 154 Variable* var = | 154 Variable* var = |
| 155 parser_->Declare(declaration, descriptor_->declaration_kind, | 155 parser_->Declare(declaration, descriptor_->declaration_kind, |
| 156 descriptor_->mode != VAR, ok_, descriptor_->hoist_scope); | 156 descriptor_->mode != VAR, ok_, descriptor_->hoist_scope); |
| 157 if (!*ok_) return; | 157 if (!*ok_) return; |
| 158 DCHECK_NOT_NULL(var); | 158 DCHECK_NOT_NULL(var); |
| 159 DCHECK(!proxy->is_resolved() || proxy->var() == var); | 159 DCHECK(!proxy->is_resolved() || proxy->var() == var); |
| 160 var->set_initializer_position(initializer_position_); | 160 var->set_initializer_position(initializer_position_); |
| 161 | 161 |
| 162 DCHECK(initializer_position_ != RelocInfo::kNoPosition); | 162 DCHECK(initializer_position_ != kNoSourcePosition); |
| 163 | 163 |
| 164 Scope* declaration_scope = IsLexicalVariableMode(descriptor_->mode) | 164 Scope* declaration_scope = IsLexicalVariableMode(descriptor_->mode) |
| 165 ? descriptor_->scope | 165 ? descriptor_->scope |
| 166 : descriptor_->scope->DeclarationScope(); | 166 : descriptor_->scope->DeclarationScope(); |
| 167 if (declaration_scope->num_var_or_const() > kMaxNumFunctionLocals) { | 167 if (declaration_scope->num_var_or_const() > kMaxNumFunctionLocals) { |
| 168 parser_->ReportMessage(MessageTemplate::kTooManyVariables); | 168 parser_->ReportMessage(MessageTemplate::kTooManyVariables); |
| 169 *ok_ = false; | 169 *ok_ = false; |
| 170 return; | 170 return; |
| 171 } | 171 } |
| 172 if (names_) { | 172 if (names_) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // Note that the function does different things depending on | 241 // Note that the function does different things depending on |
| 242 // the number of arguments (1 or 2). | 242 // the number of arguments (1 or 2). |
| 243 initialize = factory()->NewCallRuntime(Runtime::kInitializeConstGlobal, | 243 initialize = factory()->NewCallRuntime(Runtime::kInitializeConstGlobal, |
| 244 arguments, value->position()); | 244 arguments, value->position()); |
| 245 value = NULL; // zap the value to avoid the unnecessary assignment | 245 value = NULL; // zap the value to avoid the unnecessary assignment |
| 246 } else { | 246 } else { |
| 247 // Add language mode. | 247 // Add language mode. |
| 248 // We may want to pass singleton to avoid Literal allocations. | 248 // We may want to pass singleton to avoid Literal allocations. |
| 249 LanguageMode language_mode = initialization_scope->language_mode(); | 249 LanguageMode language_mode = initialization_scope->language_mode(); |
| 250 arguments->Add( | 250 arguments->Add( |
| 251 factory()->NewNumberLiteral(language_mode, RelocInfo::kNoPosition), | 251 factory()->NewNumberLiteral(language_mode, kNoSourcePosition), |
| 252 zone()); | 252 zone()); |
| 253 | 253 |
| 254 // Be careful not to assign a value to the global variable if | 254 // Be careful not to assign a value to the global variable if |
| 255 // we're in a with. The initialization value should not | 255 // we're in a with. The initialization value should not |
| 256 // necessarily be stored in the global object in that case, | 256 // necessarily be stored in the global object in that case, |
| 257 // which is why we need to generate a separate assignment node. | 257 // which is why we need to generate a separate assignment node. |
| 258 if (value != NULL && !descriptor_->scope->inside_with()) { | 258 if (value != NULL && !descriptor_->scope->inside_with()) { |
| 259 arguments->Add(value, zone()); | 259 arguments->Add(value, zone()); |
| 260 // Construct the call to Runtime_InitializeVarGlobal | 260 // Construct the call to Runtime_InitializeVarGlobal |
| 261 // and add it to the initialization statement block. | 261 // and add it to the initialization statement block. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 factory()->NewExpressionStatement(assignment, pos), zone()); | 303 factory()->NewExpressionStatement(assignment, pos), zone()); |
| 304 } | 304 } |
| 305 } | 305 } |
| 306 | 306 |
| 307 | 307 |
| 308 Variable* Parser::PatternRewriter::CreateTempVar(Expression* value) { | 308 Variable* Parser::PatternRewriter::CreateTempVar(Expression* value) { |
| 309 auto temp = scope()->NewTemporary(ast_value_factory()->empty_string()); | 309 auto temp = scope()->NewTemporary(ast_value_factory()->empty_string()); |
| 310 if (value != nullptr) { | 310 if (value != nullptr) { |
| 311 auto assignment = factory()->NewAssignment( | 311 auto assignment = factory()->NewAssignment( |
| 312 Token::ASSIGN, factory()->NewVariableProxy(temp), value, | 312 Token::ASSIGN, factory()->NewVariableProxy(temp), value, |
| 313 RelocInfo::kNoPosition); | 313 kNoSourcePosition); |
| 314 | 314 |
| 315 block_->statements()->Add( | 315 block_->statements()->Add( |
| 316 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition), | 316 factory()->NewExpressionStatement(assignment, kNoSourcePosition), |
| 317 zone()); | 317 zone()); |
| 318 } | 318 } |
| 319 return temp; | 319 return temp; |
| 320 } | 320 } |
| 321 | 321 |
| 322 | 322 |
| 323 void Parser::PatternRewriter::VisitRewritableExpression( | 323 void Parser::PatternRewriter::VisitRewritableExpression( |
| 324 RewritableExpression* node) { | 324 RewritableExpression* node) { |
| 325 // If this is not a destructuring assignment... | 325 // If this is not a destructuring assignment... |
| 326 if (!IsAssignmentContext() || !node->expression()->IsAssignment()) { | 326 if (!IsAssignmentContext() || !node->expression()->IsAssignment()) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 341 auto value = initializer; | 341 auto value = initializer; |
| 342 | 342 |
| 343 if (IsInitializerContext()) { | 343 if (IsInitializerContext()) { |
| 344 // let {<pattern> = <init>} = <value> | 344 // let {<pattern> = <init>} = <value> |
| 345 // becomes | 345 // becomes |
| 346 // temp = <value>; | 346 // temp = <value>; |
| 347 // <pattern> = temp === undefined ? <init> : temp; | 347 // <pattern> = temp === undefined ? <init> : temp; |
| 348 auto temp_var = CreateTempVar(current_value_); | 348 auto temp_var = CreateTempVar(current_value_); |
| 349 Expression* is_undefined = factory()->NewCompareOperation( | 349 Expression* is_undefined = factory()->NewCompareOperation( |
| 350 Token::EQ_STRICT, factory()->NewVariableProxy(temp_var), | 350 Token::EQ_STRICT, factory()->NewVariableProxy(temp_var), |
| 351 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), | 351 factory()->NewUndefinedLiteral(kNoSourcePosition), kNoSourcePosition); |
| 352 RelocInfo::kNoPosition); | |
| 353 value = factory()->NewConditional(is_undefined, initializer, | 352 value = factory()->NewConditional(is_undefined, initializer, |
| 354 factory()->NewVariableProxy(temp_var), | 353 factory()->NewVariableProxy(temp_var), |
| 355 RelocInfo::kNoPosition); | 354 kNoSourcePosition); |
| 356 } | 355 } |
| 357 | 356 |
| 358 PatternContext old_context = SetAssignmentContextIfNeeded(initializer); | 357 PatternContext old_context = SetAssignmentContextIfNeeded(initializer); |
| 359 int pos = assign->position(); | 358 int pos = assign->position(); |
| 360 Block* old_block = block_; | 359 Block* old_block = block_; |
| 361 block_ = factory()->NewBlock(nullptr, 8, true, pos); | 360 block_ = factory()->NewBlock(nullptr, 8, true, pos); |
| 362 Variable* temp = nullptr; | 361 Variable* temp = nullptr; |
| 363 Expression* pattern = assign->target(); | 362 Expression* pattern = assign->target(); |
| 364 Expression* old_value = current_value_; | 363 Expression* old_value = current_value_; |
| 365 current_value_ = value; | 364 current_value_ = value; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 for (ObjectLiteralProperty* property : *pattern->properties()) { | 421 for (ObjectLiteralProperty* property : *pattern->properties()) { |
| 423 PatternContext context = SetInitializerContextIfNeeded(property->value()); | 422 PatternContext context = SetInitializerContextIfNeeded(property->value()); |
| 424 | 423 |
| 425 // Computed property names contain expressions which might require | 424 // Computed property names contain expressions which might require |
| 426 // scope rewriting. | 425 // scope rewriting. |
| 427 if (!property->key()->IsLiteral()) RewriteParameterScopes(property->key()); | 426 if (!property->key()->IsLiteral()) RewriteParameterScopes(property->key()); |
| 428 | 427 |
| 429 RecurseIntoSubpattern( | 428 RecurseIntoSubpattern( |
| 430 property->value(), | 429 property->value(), |
| 431 factory()->NewProperty(factory()->NewVariableProxy(temp), | 430 factory()->NewProperty(factory()->NewVariableProxy(temp), |
| 432 property->key(), RelocInfo::kNoPosition)); | 431 property->key(), kNoSourcePosition)); |
| 433 set_context(context); | 432 set_context(context); |
| 434 } | 433 } |
| 435 } | 434 } |
| 436 | 435 |
| 437 | 436 |
| 438 void Parser::PatternRewriter::VisitObjectLiteral(ObjectLiteral* node) { | 437 void Parser::PatternRewriter::VisitObjectLiteral(ObjectLiteral* node) { |
| 439 Variable* temp_var = nullptr; | 438 Variable* temp_var = nullptr; |
| 440 VisitObjectLiteral(node, &temp_var); | 439 VisitObjectLiteral(node, &temp_var); |
| 441 } | 440 } |
| 442 | 441 |
| 443 | 442 |
| 444 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node, | 443 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node, |
| 445 Variable** temp_var) { | 444 Variable** temp_var) { |
| 446 DCHECK(block_->ignore_completion_value()); | 445 DCHECK(block_->ignore_completion_value()); |
| 447 | 446 |
| 448 auto temp = *temp_var = CreateTempVar(current_value_); | 447 auto temp = *temp_var = CreateTempVar(current_value_); |
| 449 auto iterator = CreateTempVar(parser_->GetIterator( | 448 auto iterator = CreateTempVar(parser_->GetIterator( |
| 450 factory()->NewVariableProxy(temp), factory(), RelocInfo::kNoPosition)); | 449 factory()->NewVariableProxy(temp), factory(), kNoSourcePosition)); |
| 451 auto done = CreateTempVar( | 450 auto done = |
| 452 factory()->NewBooleanLiteral(false, RelocInfo::kNoPosition)); | 451 CreateTempVar(factory()->NewBooleanLiteral(false, kNoSourcePosition)); |
| 453 auto result = CreateTempVar(); | 452 auto result = CreateTempVar(); |
| 454 auto v = CreateTempVar(); | 453 auto v = CreateTempVar(); |
| 455 auto completion = CreateTempVar(); | 454 auto completion = CreateTempVar(); |
| 456 auto nopos = RelocInfo::kNoPosition; | 455 auto nopos = kNoSourcePosition; |
| 457 | 456 |
| 458 // For the purpose of iterator finalization, we temporarily set block_ to a | 457 // For the purpose of iterator finalization, we temporarily set block_ to a |
| 459 // new block. In the main body of this function, we write to block_ (both | 458 // new block. In the main body of this function, we write to block_ (both |
| 460 // explicitly and implicitly via recursion). At the end of the function, we | 459 // explicitly and implicitly via recursion). At the end of the function, we |
| 461 // wrap this new block in a try-finally statement, restore block_ to its | 460 // wrap this new block in a try-finally statement, restore block_ to its |
| 462 // original value, and add the try-finally statement to block_. | 461 // original value, and add the try-finally statement to block_. |
| 463 auto target = block_; | 462 auto target = block_; |
| 464 block_ = factory()->NewBlock(nullptr, 8, true, nopos); | 463 block_ = factory()->NewBlock(nullptr, 8, true, nopos); |
| 465 | 464 |
| 466 Spread* spread = nullptr; | 465 Spread* spread = nullptr; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 480 // } else { | 479 // } else { |
| 481 // v = result.value; | 480 // v = result.value; |
| 482 // done = false; | 481 // done = false; |
| 483 // } | 482 // } |
| 484 // } | 483 // } |
| 485 Statement* if_not_done; | 484 Statement* if_not_done; |
| 486 { | 485 { |
| 487 auto result_done = factory()->NewProperty( | 486 auto result_done = factory()->NewProperty( |
| 488 factory()->NewVariableProxy(result), | 487 factory()->NewVariableProxy(result), |
| 489 factory()->NewStringLiteral(ast_value_factory()->done_string(), | 488 factory()->NewStringLiteral(ast_value_factory()->done_string(), |
| 490 RelocInfo::kNoPosition), | 489 kNoSourcePosition), |
| 491 RelocInfo::kNoPosition); | 490 kNoSourcePosition); |
| 492 | 491 |
| 493 auto assign_undefined = factory()->NewAssignment( | 492 auto assign_undefined = factory()->NewAssignment( |
| 494 Token::ASSIGN, factory()->NewVariableProxy(v), | 493 Token::ASSIGN, factory()->NewVariableProxy(v), |
| 495 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), | 494 factory()->NewUndefinedLiteral(kNoSourcePosition), kNoSourcePosition); |
| 496 RelocInfo::kNoPosition); | |
| 497 | 495 |
| 498 auto assign_value = factory()->NewAssignment( | 496 auto assign_value = factory()->NewAssignment( |
| 499 Token::ASSIGN, factory()->NewVariableProxy(v), | 497 Token::ASSIGN, factory()->NewVariableProxy(v), |
| 500 factory()->NewProperty( | 498 factory()->NewProperty( |
| 501 factory()->NewVariableProxy(result), | 499 factory()->NewVariableProxy(result), |
| 502 factory()->NewStringLiteral(ast_value_factory()->value_string(), | 500 factory()->NewStringLiteral(ast_value_factory()->value_string(), |
| 503 RelocInfo::kNoPosition), | 501 kNoSourcePosition), |
| 504 RelocInfo::kNoPosition), | 502 kNoSourcePosition), |
| 505 RelocInfo::kNoPosition); | 503 kNoSourcePosition); |
| 506 | 504 |
| 507 auto unset_done = factory()->NewAssignment( | 505 auto unset_done = factory()->NewAssignment( |
| 508 Token::ASSIGN, factory()->NewVariableProxy(done), | 506 Token::ASSIGN, factory()->NewVariableProxy(done), |
| 509 factory()->NewBooleanLiteral(false, RelocInfo::kNoPosition), | 507 factory()->NewBooleanLiteral(false, kNoSourcePosition), |
| 510 RelocInfo::kNoPosition); | 508 kNoSourcePosition); |
| 511 | 509 |
| 512 auto inner_else = | 510 auto inner_else = |
| 513 factory()->NewBlock(nullptr, 2, true, RelocInfo::kNoPosition); | 511 factory()->NewBlock(nullptr, 2, true, kNoSourcePosition); |
| 514 inner_else->statements()->Add( | 512 inner_else->statements()->Add( |
| 515 factory()->NewExpressionStatement(assign_value, nopos), zone()); | 513 factory()->NewExpressionStatement(assign_value, nopos), zone()); |
| 516 inner_else->statements()->Add( | 514 inner_else->statements()->Add( |
| 517 factory()->NewExpressionStatement(unset_done, nopos), zone()); | 515 factory()->NewExpressionStatement(unset_done, nopos), zone()); |
| 518 | 516 |
| 519 auto inner_if = factory()->NewIfStatement( | 517 auto inner_if = factory()->NewIfStatement( |
| 520 result_done, | 518 result_done, |
| 521 factory()->NewExpressionStatement(assign_undefined, nopos), | 519 factory()->NewExpressionStatement(assign_undefined, nopos), |
| 522 inner_else, nopos); | 520 inner_else, nopos); |
| 523 | 521 |
| 524 auto next_block = | 522 auto next_block = |
| 525 factory()->NewBlock(nullptr, 3, true, RelocInfo::kNoPosition); | 523 factory()->NewBlock(nullptr, 3, true, kNoSourcePosition); |
| 526 next_block->statements()->Add( | 524 next_block->statements()->Add( |
| 527 factory()->NewExpressionStatement( | 525 factory()->NewExpressionStatement( |
| 528 factory()->NewAssignment( | 526 factory()->NewAssignment( |
| 529 Token::ASSIGN, factory()->NewVariableProxy(done), | 527 Token::ASSIGN, factory()->NewVariableProxy(done), |
| 530 factory()->NewBooleanLiteral(true, nopos), nopos), | 528 factory()->NewBooleanLiteral(true, nopos), nopos), |
| 531 nopos), | 529 nopos), |
| 532 zone()); | 530 zone()); |
| 533 next_block->statements()->Add( | 531 next_block->statements()->Add( |
| 534 factory()->NewExpressionStatement( | 532 factory()->NewExpressionStatement( |
| 535 parser_->BuildIteratorNextResult( | 533 parser_->BuildIteratorNextResult( |
| 536 factory()->NewVariableProxy(iterator), result, | 534 factory()->NewVariableProxy(iterator), result, |
| 537 RelocInfo::kNoPosition), | 535 kNoSourcePosition), |
| 538 RelocInfo::kNoPosition), | 536 kNoSourcePosition), |
| 539 zone()); | 537 zone()); |
| 540 next_block->statements()->Add(inner_if, zone()); | 538 next_block->statements()->Add(inner_if, zone()); |
| 541 | 539 |
| 542 if_not_done = factory()->NewIfStatement( | 540 if_not_done = factory()->NewIfStatement( |
| 543 factory()->NewUnaryOperation(Token::NOT, | 541 factory()->NewUnaryOperation( |
| 544 factory()->NewVariableProxy(done), | 542 Token::NOT, factory()->NewVariableProxy(done), kNoSourcePosition), |
| 545 RelocInfo::kNoPosition), | 543 next_block, factory()->NewEmptyStatement(kNoSourcePosition), |
| 546 next_block, factory()->NewEmptyStatement(RelocInfo::kNoPosition), | 544 kNoSourcePosition); |
| 547 RelocInfo::kNoPosition); | |
| 548 } | 545 } |
| 549 block_->statements()->Add(if_not_done, zone()); | 546 block_->statements()->Add(if_not_done, zone()); |
| 550 | 547 |
| 551 if (!(value->IsLiteral() && value->AsLiteral()->raw_value()->IsTheHole())) { | 548 if (!(value->IsLiteral() && value->AsLiteral()->raw_value()->IsTheHole())) { |
| 552 { | 549 { |
| 553 // completion = kAbruptCompletion; | 550 // completion = kAbruptCompletion; |
| 554 Expression* proxy = factory()->NewVariableProxy(completion); | 551 Expression* proxy = factory()->NewVariableProxy(completion); |
| 555 Expression* assignment = factory()->NewAssignment( | 552 Expression* assignment = factory()->NewAssignment( |
| 556 Token::ASSIGN, proxy, | 553 Token::ASSIGN, proxy, |
| 557 factory()->NewSmiLiteral(kAbruptCompletion, nopos), nopos); | 554 factory()->NewSmiLiteral(kAbruptCompletion, nopos), nopos); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 // } | 586 // } |
| 590 | 587 |
| 591 // let array = []; | 588 // let array = []; |
| 592 Variable* array; | 589 Variable* array; |
| 593 { | 590 { |
| 594 auto empty_exprs = new (zone()) ZoneList<Expression*>(0, zone()); | 591 auto empty_exprs = new (zone()) ZoneList<Expression*>(0, zone()); |
| 595 array = CreateTempVar(factory()->NewArrayLiteral( | 592 array = CreateTempVar(factory()->NewArrayLiteral( |
| 596 empty_exprs, | 593 empty_exprs, |
| 597 // Reuse pattern's literal index - it is unused since there is no | 594 // Reuse pattern's literal index - it is unused since there is no |
| 598 // actual literal allocated. | 595 // actual literal allocated. |
| 599 node->literal_index(), RelocInfo::kNoPosition)); | 596 node->literal_index(), kNoSourcePosition)); |
| 600 } | 597 } |
| 601 | 598 |
| 602 // done = true; | 599 // done = true; |
| 603 Statement* set_done = factory()->NewExpressionStatement( | 600 Statement* set_done = factory()->NewExpressionStatement( |
| 604 factory()->NewAssignment( | 601 factory()->NewAssignment( |
| 605 Token::ASSIGN, factory()->NewVariableProxy(done), | 602 Token::ASSIGN, factory()->NewVariableProxy(done), |
| 606 factory()->NewBooleanLiteral(true, nopos), nopos), | 603 factory()->NewBooleanLiteral(true, nopos), nopos), |
| 607 nopos); | 604 nopos); |
| 608 | 605 |
| 609 // result = IteratorNext(iterator); | 606 // result = IteratorNext(iterator); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 // <pattern> = temp === undefined ? <init> : temp; | 692 // <pattern> = temp === undefined ? <init> : temp; |
| 696 DCHECK_EQ(Token::ASSIGN, node->op()); | 693 DCHECK_EQ(Token::ASSIGN, node->op()); |
| 697 | 694 |
| 698 auto initializer = node->value(); | 695 auto initializer = node->value(); |
| 699 auto value = initializer; | 696 auto value = initializer; |
| 700 auto temp = CreateTempVar(current_value_); | 697 auto temp = CreateTempVar(current_value_); |
| 701 | 698 |
| 702 if (IsInitializerContext()) { | 699 if (IsInitializerContext()) { |
| 703 Expression* is_undefined = factory()->NewCompareOperation( | 700 Expression* is_undefined = factory()->NewCompareOperation( |
| 704 Token::EQ_STRICT, factory()->NewVariableProxy(temp), | 701 Token::EQ_STRICT, factory()->NewVariableProxy(temp), |
| 705 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), | 702 factory()->NewUndefinedLiteral(kNoSourcePosition), kNoSourcePosition); |
| 706 RelocInfo::kNoPosition); | |
| 707 value = factory()->NewConditional(is_undefined, initializer, | 703 value = factory()->NewConditional(is_undefined, initializer, |
| 708 factory()->NewVariableProxy(temp), | 704 factory()->NewVariableProxy(temp), |
| 709 RelocInfo::kNoPosition); | 705 kNoSourcePosition); |
| 710 } | 706 } |
| 711 | 707 |
| 712 // Initializer may have been parsed in the wrong scope. | 708 // Initializer may have been parsed in the wrong scope. |
| 713 RewriteParameterScopes(initializer); | 709 RewriteParameterScopes(initializer); |
| 714 | 710 |
| 715 PatternContext old_context = SetAssignmentContextIfNeeded(initializer); | 711 PatternContext old_context = SetAssignmentContextIfNeeded(initializer); |
| 716 RecurseIntoSubpattern(node->target(), value); | 712 RecurseIntoSubpattern(node->target(), value); |
| 717 set_context(old_context); | 713 set_context(old_context); |
| 718 } | 714 } |
| 719 | 715 |
| 720 | 716 |
| 721 // =============== AssignmentPattern only ================== | 717 // =============== AssignmentPattern only ================== |
| 722 | 718 |
| 723 void Parser::PatternRewriter::VisitProperty(v8::internal::Property* node) { | 719 void Parser::PatternRewriter::VisitProperty(v8::internal::Property* node) { |
| 724 DCHECK(IsAssignmentContext()); | 720 DCHECK(IsAssignmentContext()); |
| 725 auto value = current_value_; | 721 auto value = current_value_; |
| 726 | 722 |
| 727 Assignment* assignment = | 723 Assignment* assignment = |
| 728 factory()->NewAssignment(Token::ASSIGN, node, value, node->position()); | 724 factory()->NewAssignment(Token::ASSIGN, node, value, node->position()); |
| 729 | 725 |
| 730 block_->statements()->Add( | 726 block_->statements()->Add( |
| 731 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition), | 727 factory()->NewExpressionStatement(assignment, kNoSourcePosition), zone()); |
| 732 zone()); | |
| 733 } | 728 } |
| 734 | 729 |
| 735 | 730 |
| 736 // =============== UNREACHABLE ============================= | 731 // =============== UNREACHABLE ============================= |
| 737 | 732 |
| 738 void Parser::PatternRewriter::Visit(AstNode* node) { UNREACHABLE(); } | 733 void Parser::PatternRewriter::Visit(AstNode* node) { UNREACHABLE(); } |
| 739 | 734 |
| 740 #define NOT_A_PATTERN(Node) \ | 735 #define NOT_A_PATTERN(Node) \ |
| 741 void Parser::PatternRewriter::Visit##Node(v8::internal::Node*) { \ | 736 void Parser::PatternRewriter::Visit##Node(v8::internal::Node*) { \ |
| 742 UNREACHABLE(); \ | 737 UNREACHABLE(); \ |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 NOT_A_PATTERN(TryFinallyStatement) | 777 NOT_A_PATTERN(TryFinallyStatement) |
| 783 NOT_A_PATTERN(UnaryOperation) | 778 NOT_A_PATTERN(UnaryOperation) |
| 784 NOT_A_PATTERN(VariableDeclaration) | 779 NOT_A_PATTERN(VariableDeclaration) |
| 785 NOT_A_PATTERN(WhileStatement) | 780 NOT_A_PATTERN(WhileStatement) |
| 786 NOT_A_PATTERN(WithStatement) | 781 NOT_A_PATTERN(WithStatement) |
| 787 NOT_A_PATTERN(Yield) | 782 NOT_A_PATTERN(Yield) |
| 788 | 783 |
| 789 #undef NOT_A_PATTERN | 784 #undef NOT_A_PATTERN |
| 790 } // namespace internal | 785 } // namespace internal |
| 791 } // namespace v8 | 786 } // namespace v8 |
| OLD | NEW |