| 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/objects-inl.h" | 7 #include "src/objects-inl.h" |
| 8 #include "src/parsing/parameter-initializer-rewriter.h" | 8 #include "src/parsing/parameter-initializer-rewriter.h" |
| 9 #include "src/parsing/parser.h" | 9 #include "src/parsing/parser.h" |
| 10 | 10 |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 Variable* temp_var = nullptr; | 411 Variable* temp_var = nullptr; |
| 412 VisitObjectLiteral(node, &temp_var); | 412 VisitObjectLiteral(node, &temp_var); |
| 413 } | 413 } |
| 414 | 414 |
| 415 | 415 |
| 416 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node, | 416 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node, |
| 417 Variable** temp_var) { | 417 Variable** temp_var) { |
| 418 DCHECK(block_->ignore_completion_value()); | 418 DCHECK(block_->ignore_completion_value()); |
| 419 | 419 |
| 420 auto temp = *temp_var = CreateTempVar(current_value_); | 420 auto temp = *temp_var = CreateTempVar(current_value_); |
| 421 auto iterator = CreateTempVar(factory()->NewGetIterator( | 421 auto iterator = CreateTempVar( |
| 422 factory()->NewVariableProxy(temp), kNoSourcePosition)); | 422 factory()->NewGetIterator(factory()->NewVariableProxy(temp), |
| 423 IteratorType::kNormal, kNoSourcePosition)); |
| 423 auto done = | 424 auto done = |
| 424 CreateTempVar(factory()->NewBooleanLiteral(false, kNoSourcePosition)); | 425 CreateTempVar(factory()->NewBooleanLiteral(false, kNoSourcePosition)); |
| 425 auto result = CreateTempVar(); | 426 auto result = CreateTempVar(); |
| 426 auto v = CreateTempVar(); | 427 auto v = CreateTempVar(); |
| 427 auto completion = CreateTempVar(); | 428 auto completion = CreateTempVar(); |
| 428 auto nopos = kNoSourcePosition; | 429 auto nopos = kNoSourcePosition; |
| 429 | 430 |
| 430 // For the purpose of iterator finalization, we temporarily set block_ to a | 431 // For the purpose of iterator finalization, we temporarily set block_ to a |
| 431 // new block. In the main body of this function, we write to block_ (both | 432 // new block. In the main body of this function, we write to block_ (both |
| 432 // explicitly and implicitly via recursion). At the end of the function, we | 433 // explicitly and implicitly via recursion). At the end of the function, we |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 factory()->NewExpressionStatement( | 499 factory()->NewExpressionStatement( |
| 499 factory()->NewAssignment( | 500 factory()->NewAssignment( |
| 500 Token::ASSIGN, factory()->NewVariableProxy(done), | 501 Token::ASSIGN, factory()->NewVariableProxy(done), |
| 501 factory()->NewBooleanLiteral(true, nopos), nopos), | 502 factory()->NewBooleanLiteral(true, nopos), nopos), |
| 502 nopos), | 503 nopos), |
| 503 zone()); | 504 zone()); |
| 504 next_block->statements()->Add( | 505 next_block->statements()->Add( |
| 505 factory()->NewExpressionStatement( | 506 factory()->NewExpressionStatement( |
| 506 parser_->BuildIteratorNextResult( | 507 parser_->BuildIteratorNextResult( |
| 507 factory()->NewVariableProxy(iterator), result, | 508 factory()->NewVariableProxy(iterator), result, |
| 508 kNoSourcePosition), | 509 IteratorType::kNormal, kNoSourcePosition), |
| 509 kNoSourcePosition), | 510 kNoSourcePosition), |
| 510 zone()); | 511 zone()); |
| 511 next_block->statements()->Add(inner_if, zone()); | 512 next_block->statements()->Add(inner_if, zone()); |
| 512 | 513 |
| 513 if_not_done = factory()->NewIfStatement( | 514 if_not_done = factory()->NewIfStatement( |
| 514 factory()->NewUnaryOperation( | 515 factory()->NewUnaryOperation( |
| 515 Token::NOT, factory()->NewVariableProxy(done), kNoSourcePosition), | 516 Token::NOT, factory()->NewVariableProxy(done), kNoSourcePosition), |
| 516 next_block, factory()->NewEmptyStatement(kNoSourcePosition), | 517 next_block, factory()->NewEmptyStatement(kNoSourcePosition), |
| 517 kNoSourcePosition); | 518 kNoSourcePosition); |
| 518 } | 519 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 // done = true; | 573 // done = true; |
| 573 Statement* set_done = factory()->NewExpressionStatement( | 574 Statement* set_done = factory()->NewExpressionStatement( |
| 574 factory()->NewAssignment( | 575 factory()->NewAssignment( |
| 575 Token::ASSIGN, factory()->NewVariableProxy(done), | 576 Token::ASSIGN, factory()->NewVariableProxy(done), |
| 576 factory()->NewBooleanLiteral(true, nopos), nopos), | 577 factory()->NewBooleanLiteral(true, nopos), nopos), |
| 577 nopos); | 578 nopos); |
| 578 | 579 |
| 579 // result = IteratorNext(iterator); | 580 // result = IteratorNext(iterator); |
| 580 Statement* get_next = factory()->NewExpressionStatement( | 581 Statement* get_next = factory()->NewExpressionStatement( |
| 581 parser_->BuildIteratorNextResult(factory()->NewVariableProxy(iterator), | 582 parser_->BuildIteratorNextResult(factory()->NewVariableProxy(iterator), |
| 582 result, nopos), | 583 result, IteratorType::kNormal, nopos), |
| 583 nopos); | 584 nopos); |
| 584 | 585 |
| 585 // %AppendElement(array, result.value); | 586 // %AppendElement(array, result.value); |
| 586 Statement* append_element; | 587 Statement* append_element; |
| 587 { | 588 { |
| 588 auto args = new (zone()) ZoneList<Expression*>(2, zone()); | 589 auto args = new (zone()) ZoneList<Expression*>(2, zone()); |
| 589 args->Add(factory()->NewVariableProxy(array), zone()); | 590 args->Add(factory()->NewVariableProxy(array), zone()); |
| 590 args->Add(factory()->NewProperty( | 591 args->Add(factory()->NewProperty( |
| 591 factory()->NewVariableProxy(result), | 592 factory()->NewVariableProxy(result), |
| 592 factory()->NewStringLiteral( | 593 factory()->NewStringLiteral( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 | 642 |
| 642 block_->statements()->Add(loop, zone()); | 643 block_->statements()->Add(loop, zone()); |
| 643 RecurseIntoSubpattern(spread->expression(), | 644 RecurseIntoSubpattern(spread->expression(), |
| 644 factory()->NewVariableProxy(array)); | 645 factory()->NewVariableProxy(array)); |
| 645 } | 646 } |
| 646 | 647 |
| 647 Expression* closing_condition = factory()->NewUnaryOperation( | 648 Expression* closing_condition = factory()->NewUnaryOperation( |
| 648 Token::NOT, factory()->NewVariableProxy(done), nopos); | 649 Token::NOT, factory()->NewVariableProxy(done), nopos); |
| 649 | 650 |
| 650 parser_->FinalizeIteratorUse(scope(), completion, closing_condition, iterator, | 651 parser_->FinalizeIteratorUse(scope(), completion, closing_condition, iterator, |
| 651 block_, target); | 652 block_, target, IteratorType::kNormal); |
| 652 block_ = target; | 653 block_ = target; |
| 653 } | 654 } |
| 654 | 655 |
| 655 | 656 |
| 656 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node) { | 657 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node) { |
| 657 Variable* temp_var = nullptr; | 658 Variable* temp_var = nullptr; |
| 658 VisitArrayLiteral(node, &temp_var); | 659 VisitArrayLiteral(node, &temp_var); |
| 659 } | 660 } |
| 660 | 661 |
| 661 | 662 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 NOT_A_PATTERN(TryFinallyStatement) | 750 NOT_A_PATTERN(TryFinallyStatement) |
| 750 NOT_A_PATTERN(UnaryOperation) | 751 NOT_A_PATTERN(UnaryOperation) |
| 751 NOT_A_PATTERN(VariableDeclaration) | 752 NOT_A_PATTERN(VariableDeclaration) |
| 752 NOT_A_PATTERN(WhileStatement) | 753 NOT_A_PATTERN(WhileStatement) |
| 753 NOT_A_PATTERN(WithStatement) | 754 NOT_A_PATTERN(WithStatement) |
| 754 NOT_A_PATTERN(Yield) | 755 NOT_A_PATTERN(Yield) |
| 755 | 756 |
| 756 #undef NOT_A_PATTERN | 757 #undef NOT_A_PATTERN |
| 757 } // namespace internal | 758 } // namespace internal |
| 758 } // namespace v8 | 759 } // namespace v8 |
| OLD | NEW |