| 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 5927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5938 LocalVariable* async_completer = current_block_->scope->LookupVariable( | 5938 LocalVariable* async_completer = current_block_->scope->LookupVariable( |
| 5939 Symbols::AsyncCompleter(), false); | 5939 Symbols::AsyncCompleter(), false); |
| 5940 ASSERT(async_completer != NULL); | 5940 ASSERT(async_completer != NULL); |
| 5941 ArgumentListNode* completer_args = | 5941 ArgumentListNode* completer_args = |
| 5942 new (Z) ArgumentListNode(Scanner::kNoSourcePos); | 5942 new (Z) ArgumentListNode(Scanner::kNoSourcePos); |
| 5943 completer_args->Add( | 5943 completer_args->Add( |
| 5944 new (Z) LoadLocalNode(Scanner::kNoSourcePos, exception_param.var)); | 5944 new (Z) LoadLocalNode(Scanner::kNoSourcePos, exception_param.var)); |
| 5945 completer_args->Add( | 5945 completer_args->Add( |
| 5946 new (Z) LoadLocalNode(Scanner::kNoSourcePos, stack_trace_param.var)); | 5946 new (Z) LoadLocalNode(Scanner::kNoSourcePos, stack_trace_param.var)); |
| 5947 current_block_->statements->Add(new (Z) InstanceCallNode( | 5947 current_block_->statements->Add(new (Z) InstanceCallNode( |
| 5948 Scanner::kNoSourcePos, | 5948 TokenPos(), |
| 5949 new (Z) LoadLocalNode(Scanner::kNoSourcePos, async_completer), | 5949 new (Z) LoadLocalNode(Scanner::kNoSourcePos, async_completer), |
| 5950 Symbols::CompleterCompleteError(), | 5950 Symbols::CompleterCompleteError(), |
| 5951 completer_args)); | 5951 completer_args)); |
| 5952 ReturnNode* return_node = new (Z) ReturnNode(Scanner::kNoSourcePos); | 5952 ReturnNode* return_node = new (Z) ReturnNode(Scanner::kNoSourcePos); |
| 5953 // Behavior like a continuation return, i.e,. don't call a completer. | 5953 // Behavior like a continuation return, i.e,. don't call a completer. |
| 5954 return_node->set_return_type(ReturnNode::kContinuation); | 5954 return_node->set_return_type(ReturnNode::kContinuation); |
| 5955 current_block_->statements->Add(return_node); | 5955 current_block_->statements->Add(return_node); |
| 5956 AstNode* catch_block = CloseBlock(); | 5956 AstNode* catch_block = CloseBlock(); |
| 5957 current_block_->statements->Add(catch_block); | 5957 current_block_->statements->Add(catch_block); |
| 5958 SequenceNode* catch_handler_list = CloseBlock(); | 5958 SequenceNode* catch_handler_list = CloseBlock(); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6227 Symbols::AsyncOperation(), false); | 6227 Symbols::AsyncOperation(), false); |
| 6228 ClosureNode* cn = new(Z) ClosureNode( | 6228 ClosureNode* cn = new(Z) ClosureNode( |
| 6229 Scanner::kNoSourcePos, closure, NULL, closure_body->scope()); | 6229 Scanner::kNoSourcePos, closure, NULL, closure_body->scope()); |
| 6230 StoreLocalNode* store_async_op = new (Z) StoreLocalNode( | 6230 StoreLocalNode* store_async_op = new (Z) StoreLocalNode( |
| 6231 Scanner::kNoSourcePos, | 6231 Scanner::kNoSourcePos, |
| 6232 async_op_var, | 6232 async_op_var, |
| 6233 cn); | 6233 cn); |
| 6234 current_block_->statements->Add(store_async_op); | 6234 current_block_->statements->Add(store_async_op); |
| 6235 | 6235 |
| 6236 // Add to AST: | 6236 // Add to AST: |
| 6237 // new Future(:async_op); | 6237 // new Future.microtask(:async_op); |
| 6238 ArgumentListNode* arguments = new (Z) ArgumentListNode(Scanner::kNoSourcePos); | 6238 ArgumentListNode* arguments = new (Z) ArgumentListNode(Scanner::kNoSourcePos); |
| 6239 arguments->Add(new (Z) LoadLocalNode( | 6239 arguments->Add(new (Z) LoadLocalNode( |
| 6240 Scanner::kNoSourcePos, async_op_var)); | 6240 Scanner::kNoSourcePos, async_op_var)); |
| 6241 ConstructorCallNode* future_node = new (Z) ConstructorCallNode( | 6241 ConstructorCallNode* future_node = new (Z) ConstructorCallNode( |
| 6242 Scanner::kNoSourcePos, TypeArguments::ZoneHandle(Z), constructor, | 6242 Scanner::kNoSourcePos, TypeArguments::ZoneHandle(Z), constructor, |
| 6243 arguments); | 6243 arguments); |
| 6244 current_block_->statements->Add(future_node); | 6244 current_block_->statements->Add(future_node); |
| 6245 | 6245 |
| 6246 // Add to AST: | 6246 // Add to AST: |
| 6247 // return :async_completer.future; | 6247 // return :async_completer.future; |
| (...skipping 3161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9409 | 9409 |
| 9410 | 9410 |
| 9411 AstNode* Parser::ParseUnaryExpr() { | 9411 AstNode* Parser::ParseUnaryExpr() { |
| 9412 TRACE_PARSER("ParseUnaryExpr"); | 9412 TRACE_PARSER("ParseUnaryExpr"); |
| 9413 AstNode* expr = NULL; | 9413 AstNode* expr = NULL; |
| 9414 const intptr_t op_pos = TokenPos(); | 9414 const intptr_t op_pos = TokenPos(); |
| 9415 if (IsAwaitKeyword()) { | 9415 if (IsAwaitKeyword()) { |
| 9416 TRACE_PARSER("ParseAwaitExpr"); | 9416 TRACE_PARSER("ParseAwaitExpr"); |
| 9417 ConsumeToken(); | 9417 ConsumeToken(); |
| 9418 parsed_function()->record_await(); | 9418 parsed_function()->record_await(); |
| 9419 expr = new (Z) AwaitNode(TokenPos(), ParseUnaryExpr()); | 9419 expr = new (Z) AwaitNode(op_pos, ParseUnaryExpr()); |
| 9420 } else if (IsPrefixOperator(CurrentToken())) { | 9420 } else if (IsPrefixOperator(CurrentToken())) { |
| 9421 Token::Kind unary_op = CurrentToken(); | 9421 Token::Kind unary_op = CurrentToken(); |
| 9422 if (unary_op == Token::kSUB) { | 9422 if (unary_op == Token::kSUB) { |
| 9423 unary_op = Token::kNEGATE; | 9423 unary_op = Token::kNEGATE; |
| 9424 } | 9424 } |
| 9425 ConsumeToken(); | 9425 ConsumeToken(); |
| 9426 expr = ParseUnaryExpr(); | 9426 expr = ParseUnaryExpr(); |
| 9427 if (expr->IsPrimaryNode() && (expr->AsPrimaryNode()->IsSuper())) { | 9427 if (expr->IsPrimaryNode() && (expr->AsPrimaryNode()->IsSuper())) { |
| 9428 expr = BuildUnarySuperOperator(unary_op, expr->AsPrimaryNode()); | 9428 expr = BuildUnarySuperOperator(unary_op, expr->AsPrimaryNode()); |
| 9429 } else { | 9429 } else { |
| (...skipping 2812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12242 void Parser::SkipQualIdent() { | 12242 void Parser::SkipQualIdent() { |
| 12243 ASSERT(IsIdentifier()); | 12243 ASSERT(IsIdentifier()); |
| 12244 ConsumeToken(); | 12244 ConsumeToken(); |
| 12245 if (CurrentToken() == Token::kPERIOD) { | 12245 if (CurrentToken() == Token::kPERIOD) { |
| 12246 ConsumeToken(); // Consume the kPERIOD token. | 12246 ConsumeToken(); // Consume the kPERIOD token. |
| 12247 ExpectIdentifier("identifier expected after '.'"); | 12247 ExpectIdentifier("identifier expected after '.'"); |
| 12248 } | 12248 } |
| 12249 } | 12249 } |
| 12250 | 12250 |
| 12251 } // namespace dart | 12251 } // namespace dart |
| OLD | NEW |