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

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

Issue 2637403008: [async-iteration] add support for for-await-of loops in Async Functions (Closed)
Patch Set: remove that comment Created 3 years, 10 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-base.h ('k') | src/parsing/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/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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 Variable* temp_var = nullptr; 423 Variable* temp_var = nullptr;
424 VisitObjectLiteral(node, &temp_var); 424 VisitObjectLiteral(node, &temp_var);
425 } 425 }
426 426
427 427
428 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node, 428 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node,
429 Variable** temp_var) { 429 Variable** temp_var) {
430 DCHECK(block_->ignore_completion_value()); 430 DCHECK(block_->ignore_completion_value());
431 431
432 auto temp = *temp_var = CreateTempVar(current_value_); 432 auto temp = *temp_var = CreateTempVar(current_value_);
433 auto iterator = CreateTempVar(factory()->NewGetIterator( 433 auto iterator = CreateTempVar(
434 factory()->NewVariableProxy(temp), kNoSourcePosition)); 434 factory()->NewGetIterator(factory()->NewVariableProxy(temp),
435 IteratorType::kNormal, kNoSourcePosition));
435 auto done = 436 auto done =
436 CreateTempVar(factory()->NewBooleanLiteral(false, kNoSourcePosition)); 437 CreateTempVar(factory()->NewBooleanLiteral(false, kNoSourcePosition));
437 auto result = CreateTempVar(); 438 auto result = CreateTempVar();
438 auto v = CreateTempVar(); 439 auto v = CreateTempVar();
439 auto completion = CreateTempVar(); 440 auto completion = CreateTempVar();
440 auto nopos = kNoSourcePosition; 441 auto nopos = kNoSourcePosition;
441 442
442 // For the purpose of iterator finalization, we temporarily set block_ to a 443 // For the purpose of iterator finalization, we temporarily set block_ to a
443 // new block. In the main body of this function, we write to block_ (both 444 // new block. In the main body of this function, we write to block_ (both
444 // explicitly and implicitly via recursion). At the end of the function, we 445 // explicitly and implicitly via recursion). At the end of the function, we
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 factory()->NewExpressionStatement( 511 factory()->NewExpressionStatement(
511 factory()->NewAssignment( 512 factory()->NewAssignment(
512 Token::ASSIGN, factory()->NewVariableProxy(done), 513 Token::ASSIGN, factory()->NewVariableProxy(done),
513 factory()->NewBooleanLiteral(true, nopos), nopos), 514 factory()->NewBooleanLiteral(true, nopos), nopos),
514 nopos), 515 nopos),
515 zone()); 516 zone());
516 next_block->statements()->Add( 517 next_block->statements()->Add(
517 factory()->NewExpressionStatement( 518 factory()->NewExpressionStatement(
518 parser_->BuildIteratorNextResult( 519 parser_->BuildIteratorNextResult(
519 factory()->NewVariableProxy(iterator), result, 520 factory()->NewVariableProxy(iterator), result,
520 kNoSourcePosition), 521 IteratorType::kNormal, kNoSourcePosition),
521 kNoSourcePosition), 522 kNoSourcePosition),
522 zone()); 523 zone());
523 next_block->statements()->Add(inner_if, zone()); 524 next_block->statements()->Add(inner_if, zone());
524 525
525 if_not_done = factory()->NewIfStatement( 526 if_not_done = factory()->NewIfStatement(
526 factory()->NewUnaryOperation( 527 factory()->NewUnaryOperation(
527 Token::NOT, factory()->NewVariableProxy(done), kNoSourcePosition), 528 Token::NOT, factory()->NewVariableProxy(done), kNoSourcePosition),
528 next_block, factory()->NewEmptyStatement(kNoSourcePosition), 529 next_block, factory()->NewEmptyStatement(kNoSourcePosition),
529 kNoSourcePosition); 530 kNoSourcePosition);
530 } 531 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 // done = true; 582 // done = true;
582 Statement* set_done = factory()->NewExpressionStatement( 583 Statement* set_done = factory()->NewExpressionStatement(
583 factory()->NewAssignment( 584 factory()->NewAssignment(
584 Token::ASSIGN, factory()->NewVariableProxy(done), 585 Token::ASSIGN, factory()->NewVariableProxy(done),
585 factory()->NewBooleanLiteral(true, nopos), nopos), 586 factory()->NewBooleanLiteral(true, nopos), nopos),
586 nopos); 587 nopos);
587 588
588 // result = IteratorNext(iterator); 589 // result = IteratorNext(iterator);
589 Statement* get_next = factory()->NewExpressionStatement( 590 Statement* get_next = factory()->NewExpressionStatement(
590 parser_->BuildIteratorNextResult(factory()->NewVariableProxy(iterator), 591 parser_->BuildIteratorNextResult(factory()->NewVariableProxy(iterator),
591 result, nopos), 592 result, IteratorType::kNormal, nopos),
592 nopos); 593 nopos);
593 594
594 // %AppendElement(array, result.value); 595 // %AppendElement(array, result.value);
595 Statement* append_element; 596 Statement* append_element;
596 { 597 {
597 auto args = new (zone()) ZoneList<Expression*>(2, zone()); 598 auto args = new (zone()) ZoneList<Expression*>(2, zone());
598 args->Add(factory()->NewVariableProxy(array), zone()); 599 args->Add(factory()->NewVariableProxy(array), zone());
599 args->Add(factory()->NewProperty( 600 args->Add(factory()->NewProperty(
600 factory()->NewVariableProxy(result), 601 factory()->NewVariableProxy(result),
601 factory()->NewStringLiteral( 602 factory()->NewStringLiteral(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 651
651 block_->statements()->Add(loop, zone()); 652 block_->statements()->Add(loop, zone());
652 RecurseIntoSubpattern(spread->expression(), 653 RecurseIntoSubpattern(spread->expression(),
653 factory()->NewVariableProxy(array)); 654 factory()->NewVariableProxy(array));
654 } 655 }
655 656
656 Expression* closing_condition = factory()->NewUnaryOperation( 657 Expression* closing_condition = factory()->NewUnaryOperation(
657 Token::NOT, factory()->NewVariableProxy(done), nopos); 658 Token::NOT, factory()->NewVariableProxy(done), nopos);
658 659
659 parser_->FinalizeIteratorUse(scope(), completion, closing_condition, iterator, 660 parser_->FinalizeIteratorUse(scope(), completion, closing_condition, iterator,
660 block_, target); 661 block_, target, IteratorType::kNormal);
661 block_ = target; 662 block_ = target;
662 } 663 }
663 664
664 665
665 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node) { 666 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node) {
666 Variable* temp_var = nullptr; 667 Variable* temp_var = nullptr;
667 VisitArrayLiteral(node, &temp_var); 668 VisitArrayLiteral(node, &temp_var);
668 } 669 }
669 670
670 671
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 NOT_A_PATTERN(TryFinallyStatement) 759 NOT_A_PATTERN(TryFinallyStatement)
759 NOT_A_PATTERN(UnaryOperation) 760 NOT_A_PATTERN(UnaryOperation)
760 NOT_A_PATTERN(VariableDeclaration) 761 NOT_A_PATTERN(VariableDeclaration)
761 NOT_A_PATTERN(WhileStatement) 762 NOT_A_PATTERN(WhileStatement)
762 NOT_A_PATTERN(WithStatement) 763 NOT_A_PATTERN(WithStatement)
763 NOT_A_PATTERN(Yield) 764 NOT_A_PATTERN(Yield)
764 765
765 #undef NOT_A_PATTERN 766 #undef NOT_A_PATTERN
766 } // namespace internal 767 } // namespace internal
767 } // namespace v8 768 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser-base.h ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698