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 5859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5870 SequenceNode* Parser::CloseAsyncFunction(const Function& closure, | 5870 SequenceNode* Parser::CloseAsyncFunction(const Function& closure, |
5871 SequenceNode* closure_body) { | 5871 SequenceNode* closure_body) { |
5872 TRACE_PARSER("CloseAsyncFunction"); | 5872 TRACE_PARSER("CloseAsyncFunction"); |
5873 ASSERT(!closure.IsNull()); | 5873 ASSERT(!closure.IsNull()); |
5874 ASSERT(closure_body != NULL); | 5874 ASSERT(closure_body != NULL); |
5875 // The block for the async closure body has already been closed. Close the | 5875 // The block for the async closure body has already been closed. Close the |
5876 // corresponding function block. | 5876 // corresponding function block. |
5877 CloseBlock(); | 5877 CloseBlock(); |
5878 | 5878 |
5879 closure_body->scope()->LookupVariable(Symbols::AwaitJumpVar(), false); | 5879 closure_body->scope()->LookupVariable(Symbols::AwaitJumpVar(), false); |
| 5880 closure_body->scope()->LookupVariable(Symbols::AwaitContextVar(), false); |
5880 closure_body->scope()->CaptureVariable(Symbols::AsyncCompleter()); | 5881 closure_body->scope()->CaptureVariable(Symbols::AsyncCompleter()); |
5881 | 5882 |
5882 // Create and return a new future that executes a closure with the current | 5883 // Create and return a new future that executes a closure with the current |
5883 // body. | 5884 // body. |
5884 | 5885 |
5885 // No need to capture parameters or other variables, since they have already | 5886 // No need to capture parameters or other variables, since they have already |
5886 // been captured in the corresponding scope as the body has been parsed within | 5887 // been captured in the corresponding scope as the body has been parsed within |
5887 // a nested block (contained in the async funtion's block). | 5888 // a nested block (contained in the async funtion's block). |
5888 const Class& future = Class::ZoneHandle(I, | 5889 const Class& future = Class::ZoneHandle(I, |
5889 GetClassForAsync(Symbols::Future())); | 5890 GetClassForAsync(Symbols::Future())); |
(...skipping 19 matching lines...) Expand all Loading... |
5909 Scanner::kNoSourcePos, | 5910 Scanner::kNoSourcePos, |
5910 TypeArguments::ZoneHandle(I), | 5911 TypeArguments::ZoneHandle(I), |
5911 completer_constructor, | 5912 completer_constructor, |
5912 empty_args); | 5913 empty_args); |
5913 StoreLocalNode* store_completer = new (I) StoreLocalNode( | 5914 StoreLocalNode* store_completer = new (I) StoreLocalNode( |
5914 Scanner::kNoSourcePos, | 5915 Scanner::kNoSourcePos, |
5915 async_completer, | 5916 async_completer, |
5916 completer_constructor_node); | 5917 completer_constructor_node); |
5917 current_block_->statements->Add(store_completer); | 5918 current_block_->statements->Add(store_completer); |
5918 | 5919 |
| 5920 // :await_jump_var = -1; |
| 5921 LocalVariable* jump_var = current_block_->scope->LookupVariable( |
| 5922 Symbols::AwaitJumpVar(), false); |
| 5923 LiteralNode* init_value = |
| 5924 new(I) LiteralNode(Scanner::kNoSourcePos, Smi::ZoneHandle(Smi::New(-1))); |
| 5925 current_block_->statements->Add( |
| 5926 new (I) StoreLocalNode(Scanner::kNoSourcePos, jump_var, init_value)); |
| 5927 |
5919 // Add to AST: | 5928 // Add to AST: |
5920 // :async_op = <closure>; (containing the original body) | 5929 // :async_op = <closure>; (containing the original body) |
5921 LocalVariable* async_op_var = current_block_->scope->LookupVariable( | 5930 LocalVariable* async_op_var = current_block_->scope->LookupVariable( |
5922 Symbols::AsyncOperation(), false); | 5931 Symbols::AsyncOperation(), false); |
5923 ClosureNode* cn = new(I) ClosureNode( | 5932 ClosureNode* cn = new(I) ClosureNode( |
5924 Scanner::kNoSourcePos, closure, NULL, closure_body->scope()); | 5933 Scanner::kNoSourcePos, closure, NULL, closure_body->scope()); |
5925 StoreLocalNode* store_async_op = new (I) StoreLocalNode( | 5934 StoreLocalNode* store_async_op = new (I) StoreLocalNode( |
5926 Scanner::kNoSourcePos, | 5935 Scanner::kNoSourcePos, |
5927 async_op_var, | 5936 async_op_var, |
5928 cn); | 5937 cn); |
(...skipping 5879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11808 void Parser::SkipQualIdent() { | 11817 void Parser::SkipQualIdent() { |
11809 ASSERT(IsIdentifier()); | 11818 ASSERT(IsIdentifier()); |
11810 ConsumeToken(); | 11819 ConsumeToken(); |
11811 if (CurrentToken() == Token::kPERIOD) { | 11820 if (CurrentToken() == Token::kPERIOD) { |
11812 ConsumeToken(); // Consume the kPERIOD token. | 11821 ConsumeToken(); // Consume the kPERIOD token. |
11813 ExpectIdentifier("identifier expected after '.'"); | 11822 ExpectIdentifier("identifier expected after '.'"); |
11814 } | 11823 } |
11815 } | 11824 } |
11816 | 11825 |
11817 } // namespace dart | 11826 } // namespace dart |
OLD | NEW |