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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 Variable* temp_var = nullptr; | 406 Variable* temp_var = nullptr; |
407 VisitObjectLiteral(node, &temp_var); | 407 VisitObjectLiteral(node, &temp_var); |
408 } | 408 } |
409 | 409 |
410 | 410 |
411 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node, | 411 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node, |
412 Variable** temp_var) { | 412 Variable** temp_var) { |
413 DCHECK(block_->ignore_completion_value()); | 413 DCHECK(block_->ignore_completion_value()); |
414 | 414 |
415 auto temp = *temp_var = CreateTempVar(current_value_); | 415 auto temp = *temp_var = CreateTempVar(current_value_); |
416 auto iterator = CreateTempVar(factory()->NewGetIterator( | 416 auto iterator = CreateTempVar( |
417 factory()->NewVariableProxy(temp), kNoSourcePosition)); | 417 factory()->NewGetIterator(factory()->NewVariableProxy(temp), |
| 418 GetIterator::Hint::kNormal, kNoSourcePosition)); |
418 auto done = | 419 auto done = |
419 CreateTempVar(factory()->NewBooleanLiteral(false, kNoSourcePosition)); | 420 CreateTempVar(factory()->NewBooleanLiteral(false, kNoSourcePosition)); |
420 auto result = CreateTempVar(); | 421 auto result = CreateTempVar(); |
421 auto v = CreateTempVar(); | 422 auto v = CreateTempVar(); |
422 auto completion = CreateTempVar(); | 423 auto completion = CreateTempVar(); |
423 auto nopos = kNoSourcePosition; | 424 auto nopos = kNoSourcePosition; |
424 | 425 |
425 // For the purpose of iterator finalization, we temporarily set block_ to a | 426 // For the purpose of iterator finalization, we temporarily set block_ to a |
426 // new block. In the main body of this function, we write to block_ (both | 427 // new block. In the main body of this function, we write to block_ (both |
427 // explicitly and implicitly via recursion). At the end of the function, we | 428 // 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... |
493 factory()->NewExpressionStatement( | 494 factory()->NewExpressionStatement( |
494 factory()->NewAssignment( | 495 factory()->NewAssignment( |
495 Token::ASSIGN, factory()->NewVariableProxy(done), | 496 Token::ASSIGN, factory()->NewVariableProxy(done), |
496 factory()->NewBooleanLiteral(true, nopos), nopos), | 497 factory()->NewBooleanLiteral(true, nopos), nopos), |
497 nopos), | 498 nopos), |
498 zone()); | 499 zone()); |
499 next_block->statements()->Add( | 500 next_block->statements()->Add( |
500 factory()->NewExpressionStatement( | 501 factory()->NewExpressionStatement( |
501 parser_->BuildIteratorNextResult( | 502 parser_->BuildIteratorNextResult( |
502 factory()->NewVariableProxy(iterator), result, | 503 factory()->NewVariableProxy(iterator), result, |
503 kNoSourcePosition), | 504 IteratorType::kNormal, kNoSourcePosition), |
504 kNoSourcePosition), | 505 kNoSourcePosition), |
505 zone()); | 506 zone()); |
506 next_block->statements()->Add(inner_if, zone()); | 507 next_block->statements()->Add(inner_if, zone()); |
507 | 508 |
508 if_not_done = factory()->NewIfStatement( | 509 if_not_done = factory()->NewIfStatement( |
509 factory()->NewUnaryOperation( | 510 factory()->NewUnaryOperation( |
510 Token::NOT, factory()->NewVariableProxy(done), kNoSourcePosition), | 511 Token::NOT, factory()->NewVariableProxy(done), kNoSourcePosition), |
511 next_block, factory()->NewEmptyStatement(kNoSourcePosition), | 512 next_block, factory()->NewEmptyStatement(kNoSourcePosition), |
512 kNoSourcePosition); | 513 kNoSourcePosition); |
513 } | 514 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 // done = true; | 568 // done = true; |
568 Statement* set_done = factory()->NewExpressionStatement( | 569 Statement* set_done = factory()->NewExpressionStatement( |
569 factory()->NewAssignment( | 570 factory()->NewAssignment( |
570 Token::ASSIGN, factory()->NewVariableProxy(done), | 571 Token::ASSIGN, factory()->NewVariableProxy(done), |
571 factory()->NewBooleanLiteral(true, nopos), nopos), | 572 factory()->NewBooleanLiteral(true, nopos), nopos), |
572 nopos); | 573 nopos); |
573 | 574 |
574 // result = IteratorNext(iterator); | 575 // result = IteratorNext(iterator); |
575 Statement* get_next = factory()->NewExpressionStatement( | 576 Statement* get_next = factory()->NewExpressionStatement( |
576 parser_->BuildIteratorNextResult(factory()->NewVariableProxy(iterator), | 577 parser_->BuildIteratorNextResult(factory()->NewVariableProxy(iterator), |
577 result, nopos), | 578 result, IteratorType::kNormal, nopos), |
578 nopos); | 579 nopos); |
579 | 580 |
580 // %AppendElement(array, result.value); | 581 // %AppendElement(array, result.value); |
581 Statement* append_element; | 582 Statement* append_element; |
582 { | 583 { |
583 auto args = new (zone()) ZoneList<Expression*>(2, zone()); | 584 auto args = new (zone()) ZoneList<Expression*>(2, zone()); |
584 args->Add(factory()->NewVariableProxy(array), zone()); | 585 args->Add(factory()->NewVariableProxy(array), zone()); |
585 args->Add(factory()->NewProperty( | 586 args->Add(factory()->NewProperty( |
586 factory()->NewVariableProxy(result), | 587 factory()->NewVariableProxy(result), |
587 factory()->NewStringLiteral( | 588 factory()->NewStringLiteral( |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 | 637 |
637 block_->statements()->Add(loop, zone()); | 638 block_->statements()->Add(loop, zone()); |
638 RecurseIntoSubpattern(spread->expression(), | 639 RecurseIntoSubpattern(spread->expression(), |
639 factory()->NewVariableProxy(array)); | 640 factory()->NewVariableProxy(array)); |
640 } | 641 } |
641 | 642 |
642 Expression* closing_condition = factory()->NewUnaryOperation( | 643 Expression* closing_condition = factory()->NewUnaryOperation( |
643 Token::NOT, factory()->NewVariableProxy(done), nopos); | 644 Token::NOT, factory()->NewVariableProxy(done), nopos); |
644 | 645 |
645 parser_->FinalizeIteratorUse(scope(), completion, closing_condition, iterator, | 646 parser_->FinalizeIteratorUse(scope(), completion, closing_condition, iterator, |
646 block_, target); | 647 block_, target, IteratorType::kNormal); |
647 block_ = target; | 648 block_ = target; |
648 } | 649 } |
649 | 650 |
650 | 651 |
651 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node) { | 652 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node) { |
652 Variable* temp_var = nullptr; | 653 Variable* temp_var = nullptr; |
653 VisitArrayLiteral(node, &temp_var); | 654 VisitArrayLiteral(node, &temp_var); |
654 } | 655 } |
655 | 656 |
656 | 657 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 NOT_A_PATTERN(TryFinallyStatement) | 745 NOT_A_PATTERN(TryFinallyStatement) |
745 NOT_A_PATTERN(UnaryOperation) | 746 NOT_A_PATTERN(UnaryOperation) |
746 NOT_A_PATTERN(VariableDeclaration) | 747 NOT_A_PATTERN(VariableDeclaration) |
747 NOT_A_PATTERN(WhileStatement) | 748 NOT_A_PATTERN(WhileStatement) |
748 NOT_A_PATTERN(WithStatement) | 749 NOT_A_PATTERN(WithStatement) |
749 NOT_A_PATTERN(Yield) | 750 NOT_A_PATTERN(Yield) |
750 | 751 |
751 #undef NOT_A_PATTERN | 752 #undef NOT_A_PATTERN |
752 } // namespace internal | 753 } // namespace internal |
753 } // namespace v8 | 754 } // namespace v8 |
OLD | NEW |