OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/parser.h" | 5 #include "vm/parser.h" |
6 | 6 |
7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
9 #include "vm/ast_transformer.h" | 9 #include "vm/ast_transformer.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
(...skipping 6718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6729 // Generate the Ast nodes for the implicit code of the async* function. | 6729 // Generate the Ast nodes for the implicit code of the async* function. |
6730 // | 6730 // |
6731 // f(...) async* { | 6731 // f(...) async* { |
6732 // var :controller; | 6732 // var :controller; |
6733 // var :await_jump_var = -1; | 6733 // var :await_jump_var = -1; |
6734 // var :await_context_var; | 6734 // var :await_context_var; |
6735 // f_async_body() { | 6735 // f_async_body() { |
6736 // ... source code of f ... | 6736 // ... source code of f ... |
6737 // } | 6737 // } |
6738 // var :async_op = f_async_body; | 6738 // var :async_op = f_async_body; |
6739 // :controller = new _AsyncStarStreamController(f_async_body); | 6739 // :controller = new _AsyncStarStreamController(:async_op); |
6740 // return :controller.stream; | 6740 // return :controller.stream; |
6741 // } | 6741 // } |
6742 SequenceNode* Parser::CloseAsyncGeneratorFunction(const Function& closure, | 6742 SequenceNode* Parser::CloseAsyncGeneratorFunction(const Function& closure_func, |
6743 SequenceNode* closure_body) { | 6743 SequenceNode* closure_body) { |
6744 TRACE_PARSER("CloseAsyncGeneratorFunction"); | 6744 TRACE_PARSER("CloseAsyncGeneratorFunction"); |
6745 ASSERT(!closure.IsNull()); | 6745 ASSERT(!closure_func.IsNull()); |
6746 ASSERT(closure_body != NULL); | 6746 ASSERT(closure_body != NULL); |
6747 | 6747 |
6748 // The block for the async closure body has already been closed. Close the | 6748 // The block for the async closure body has already been closed. Close the |
6749 // corresponding function block. | 6749 // corresponding function block. |
6750 CloseBlock(); | 6750 CloseBlock(); |
6751 | 6751 |
6752 // Make sure the implicit variables of the async generator function | 6752 // Make sure the implicit variables of the async generator function |
6753 // are captured. | 6753 // are captured. |
6754 closure_body->scope()->LookupVariable(Symbols::AwaitJumpVar(), false); | 6754 closure_body->scope()->LookupVariable(Symbols::AwaitJumpVar(), false); |
6755 closure_body->scope()->LookupVariable(Symbols::AwaitContextVar(), false); | 6755 closure_body->scope()->LookupVariable(Symbols::AwaitContextVar(), false); |
(...skipping 12 matching lines...) Expand all Loading... |
6768 current_block_->scope->LookupVariable(Symbols::AwaitJumpVar(), false); | 6768 current_block_->scope->LookupVariable(Symbols::AwaitJumpVar(), false); |
6769 LiteralNode* init_value = | 6769 LiteralNode* init_value = |
6770 new(Z) LiteralNode(Scanner::kNoSourcePos, Smi::ZoneHandle(Smi::New(-1))); | 6770 new(Z) LiteralNode(Scanner::kNoSourcePos, Smi::ZoneHandle(Smi::New(-1))); |
6771 current_block_->statements->Add( | 6771 current_block_->statements->Add( |
6772 new(Z) StoreLocalNode(Scanner::kNoSourcePos, jump_var, init_value)); | 6772 new(Z) StoreLocalNode(Scanner::kNoSourcePos, jump_var, init_value)); |
6773 | 6773 |
6774 // Add to AST: | 6774 // Add to AST: |
6775 // :async_op = <closure>; (containing the original body) | 6775 // :async_op = <closure>; (containing the original body) |
6776 LocalVariable* async_op_var = | 6776 LocalVariable* async_op_var = |
6777 current_block_->scope->LookupVariable(Symbols::AsyncOperation(), false); | 6777 current_block_->scope->LookupVariable(Symbols::AsyncOperation(), false); |
6778 ClosureNode* cn = new(Z) ClosureNode( | 6778 ClosureNode* closure_obj = new(Z) ClosureNode( |
6779 Scanner::kNoSourcePos, closure, NULL, closure_body->scope()); | 6779 Scanner::kNoSourcePos, closure_func, NULL, closure_body->scope()); |
6780 StoreLocalNode* store_async_op = new (Z) StoreLocalNode( | 6780 StoreLocalNode* store_async_op = new (Z) StoreLocalNode( |
6781 Scanner::kNoSourcePos, | 6781 Scanner::kNoSourcePos, |
6782 async_op_var, | 6782 async_op_var, |
6783 cn); | 6783 closure_obj); |
6784 current_block_->statements->Add(store_async_op); | 6784 current_block_->statements->Add(store_async_op); |
6785 | 6785 |
6786 // :controller = new _AsyncStarStreamController(body_closure); | 6786 // :controller = new _AsyncStarStreamController(body_closure); |
6787 ArgumentListNode* arguments = new(Z) ArgumentListNode(Scanner::kNoSourcePos); | 6787 ArgumentListNode* arguments = new(Z) ArgumentListNode(Scanner::kNoSourcePos); |
6788 ClosureNode* closure_obj = new(Z) ClosureNode( | 6788 arguments->Add(new (Z) LoadLocalNode(Scanner::kNoSourcePos, async_op_var)); |
6789 Scanner::kNoSourcePos, closure, NULL, closure_body->scope()); | |
6790 arguments->Add(closure_obj); | |
6791 ConstructorCallNode* controller_constructor_call = | 6789 ConstructorCallNode* controller_constructor_call = |
6792 new(Z) ConstructorCallNode(Scanner::kNoSourcePos, | 6790 new(Z) ConstructorCallNode(Scanner::kNoSourcePos, |
6793 TypeArguments::ZoneHandle(Z), | 6791 TypeArguments::ZoneHandle(Z), |
6794 controller_constructor, | 6792 controller_constructor, |
6795 arguments); | 6793 arguments); |
6796 LocalVariable* controller_var = | 6794 LocalVariable* controller_var = |
6797 current_block_->scope->LookupVariable(Symbols::Controller(), false); | 6795 current_block_->scope->LookupVariable(Symbols::Controller(), false); |
6798 StoreLocalNode* store_controller = | 6796 StoreLocalNode* store_controller = |
6799 new(Z) StoreLocalNode(Scanner::kNoSourcePos, | 6797 new(Z) StoreLocalNode(Scanner::kNoSourcePos, |
6800 controller_var, | 6798 controller_var, |
(...skipping 6826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13627 void Parser::SkipQualIdent() { | 13625 void Parser::SkipQualIdent() { |
13628 ASSERT(IsIdentifier()); | 13626 ASSERT(IsIdentifier()); |
13629 ConsumeToken(); | 13627 ConsumeToken(); |
13630 if (CurrentToken() == Token::kPERIOD) { | 13628 if (CurrentToken() == Token::kPERIOD) { |
13631 ConsumeToken(); // Consume the kPERIOD token. | 13629 ConsumeToken(); // Consume the kPERIOD token. |
13632 ExpectIdentifier("identifier expected after '.'"); | 13630 ExpectIdentifier("identifier expected after '.'"); |
13633 } | 13631 } |
13634 } | 13632 } |
13635 | 13633 |
13636 } // namespace dart | 13634 } // namespace dart |
OLD | NEW |