| 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 6071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6082 ReturnNode* return_node = new(Z) ReturnNode(Scanner::kNoSourcePos); | 6082 ReturnNode* return_node = new(Z) ReturnNode(Scanner::kNoSourcePos); |
| 6083 AddNodeForFinallyInlining(return_node); | 6083 AddNodeForFinallyInlining(return_node); |
| 6084 current_block_->statements->Add(return_node); | 6084 current_block_->statements->Add(return_node); |
| 6085 AstNode* catch_block = CloseBlock(); | 6085 AstNode* catch_block = CloseBlock(); |
| 6086 current_block_->statements->Add(catch_block); | 6086 current_block_->statements->Add(catch_block); |
| 6087 SequenceNode* catch_handler_list = CloseBlock(); | 6087 SequenceNode* catch_handler_list = CloseBlock(); |
| 6088 | 6088 |
| 6089 TryStack* try_statement = PopTry(); | 6089 TryStack* try_statement = PopTry(); |
| 6090 ASSERT(try_stack_ == NULL); // We popped the outermost try block. | 6090 ASSERT(try_stack_ == NULL); // We popped the outermost try block. |
| 6091 | 6091 |
| 6092 // Finally block: closing the stream and returning. (Note: the return | 6092 // Finally block: closing the stream and returning. Instead of simply |
| 6093 // is necessary otherwise the back-end will append a rethrow of the | 6093 // returning, create an await state and suspend. There may be outstanding |
| 6094 // current exception.) | 6094 // calls to schedule the generator body. This suspension ensures that we |
| 6095 // do not repeat any code of the generator body. |
| 6095 // :controller.close(); | 6096 // :controller.close(); |
| 6096 // return; | 6097 // suspend; |
| 6097 // We need to inline this code in all recorded exit points. | 6098 // We need to inline this code in all recorded exit points. |
| 6098 intptr_t node_index = 0; | 6099 intptr_t node_index = 0; |
| 6099 SequenceNode* finally_clause = NULL; | 6100 SequenceNode* finally_clause = NULL; |
| 6100 do { | 6101 do { |
| 6101 OpenBlock(); | 6102 OpenBlock(); |
| 6102 ArgumentListNode* no_args = | 6103 ArgumentListNode* no_args = |
| 6103 new(Z) ArgumentListNode(Scanner::kNoSourcePos); | 6104 new(Z) ArgumentListNode(Scanner::kNoSourcePos); |
| 6104 current_block_->statements->Add( | 6105 current_block_->statements->Add( |
| 6105 new(Z) InstanceCallNode(try_end_pos, | 6106 new(Z) InstanceCallNode(try_end_pos, |
| 6106 new(Z) LoadLocalNode(Scanner::kNoSourcePos, controller), | 6107 new(Z) LoadLocalNode(Scanner::kNoSourcePos, controller), |
| 6107 Symbols::Close(), | 6108 Symbols::Close(), |
| 6108 no_args)); | 6109 no_args)); |
| 6109 | 6110 |
| 6110 ReturnNode* return_node = new(Z) ReturnNode(Scanner::kNoSourcePos); | 6111 // Suspend after the close. |
| 6111 current_block_->statements->Add(return_node); | 6112 AwaitMarkerNode* await_marker = new(Z) AwaitMarkerNode(); |
| 6113 await_marker->set_scope(current_block_->scope); |
| 6114 current_block_->statements->Add(await_marker); |
| 6115 ReturnNode* continuation_ret = new(Z) ReturnNode(try_end_pos); |
| 6116 continuation_ret->set_return_type(ReturnNode::kContinuationTarget); |
| 6117 current_block_->statements->Add(continuation_ret); |
| 6112 | 6118 |
| 6113 finally_clause = CloseBlock(); | 6119 finally_clause = CloseBlock(); |
| 6114 AstNode* node_to_inline = try_statement->GetNodeToInlineFinally(node_index); | 6120 AstNode* node_to_inline = try_statement->GetNodeToInlineFinally(node_index); |
| 6115 if (node_to_inline != NULL) { | 6121 if (node_to_inline != NULL) { |
| 6116 InlinedFinallyNode* node = | 6122 InlinedFinallyNode* node = |
| 6117 new(Z) InlinedFinallyNode(try_end_pos, | 6123 new(Z) InlinedFinallyNode(try_end_pos, |
| 6118 finally_clause, | 6124 finally_clause, |
| 6119 context_var, | 6125 context_var, |
| 6120 // No outer try statement | 6126 // No outer try statement |
| 6121 CatchClauseNode::kInvalidTryIndex); | 6127 CatchClauseNode::kInvalidTryIndex); |
| (...skipping 7086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13208 void Parser::SkipQualIdent() { | 13214 void Parser::SkipQualIdent() { |
| 13209 ASSERT(IsIdentifier()); | 13215 ASSERT(IsIdentifier()); |
| 13210 ConsumeToken(); | 13216 ConsumeToken(); |
| 13211 if (CurrentToken() == Token::kPERIOD) { | 13217 if (CurrentToken() == Token::kPERIOD) { |
| 13212 ConsumeToken(); // Consume the kPERIOD token. | 13218 ConsumeToken(); // Consume the kPERIOD token. |
| 13213 ExpectIdentifier("identifier expected after '.'"); | 13219 ExpectIdentifier("identifier expected after '.'"); |
| 13214 } | 13220 } |
| 13215 } | 13221 } |
| 13216 | 13222 |
| 13217 } // namespace dart | 13223 } // namespace dart |
| OLD | NEW |