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 #include "vm/flags.h" | 6 #include "vm/flags.h" |
7 | 7 |
8 #ifndef DART_PRECOMPILED_RUNTIME | 8 #ifndef DART_PRECOMPILED_RUNTIME |
9 | 9 |
10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
(...skipping 8701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8712 new(Z) LoadLocalNode(await_for_pos, exception_var), | 8712 new(Z) LoadLocalNode(await_for_pos, exception_var), |
8713 new(Z) LoadLocalNode(await_for_pos, stack_trace_var))); | 8713 new(Z) LoadLocalNode(await_for_pos, stack_trace_var))); |
8714 | 8714 |
8715 TryStack* try_statement = PopTry(); | 8715 TryStack* try_statement = PopTry(); |
8716 const intptr_t try_index = try_statement->try_index(); | 8716 const intptr_t try_index = try_statement->try_index(); |
8717 TryStack* outer_try = try_stack_; | 8717 TryStack* outer_try = try_stack_; |
8718 const intptr_t outer_try_index = (outer_try != NULL) ? | 8718 const intptr_t outer_try_index = (outer_try != NULL) ? |
8719 outer_try->try_index() : CatchClauseNode::kInvalidTryIndex; | 8719 outer_try->try_index() : CatchClauseNode::kInvalidTryIndex; |
8720 | 8720 |
8721 // The finally block contains a call to cancel the stream. | 8721 // The finally block contains a call to cancel the stream. |
8722 // :for-in-iter.cancel() | 8722 // :for-in-iter.cancel(); |
8723 | 8723 |
8724 // Inline the finally block to the exit points in the try block. | 8724 // Inline the finally block to the exit points in the try block. |
8725 intptr_t node_index = 0; | 8725 intptr_t node_index = 0; |
8726 SequenceNode* finally_clause = NULL; | 8726 SequenceNode* finally_clause = NULL; |
8727 if (try_stack_ != NULL) { | 8727 if (try_stack_ != NULL) { |
8728 try_stack_->enter_finally(); | 8728 try_stack_->enter_finally(); |
8729 } | 8729 } |
8730 do { | 8730 do { |
8731 OpenBlock(); | 8731 OpenBlock(); |
| 8732 |
| 8733 // Restore the saved try context of the enclosing try block if one |
| 8734 // exists. |
| 8735 if (outer_saved_try_ctx != NULL) { |
| 8736 current_block_->statements->Add(new (Z) StoreLocalNode( |
| 8737 TokenPosition::kNoSource, |
| 8738 outer_saved_try_ctx, |
| 8739 new (Z) LoadLocalNode(TokenPosition::kNoSource, |
| 8740 outer_async_saved_try_ctx))); |
| 8741 } |
| 8742 // :for-in-iter.cancel(); |
8732 ArgumentListNode* no_args = | 8743 ArgumentListNode* no_args = |
8733 new(Z) ArgumentListNode(TokenPosition::kNoSource); | 8744 new(Z) ArgumentListNode(TokenPosition::kNoSource); |
8734 current_block_->statements->Add( | 8745 current_block_->statements->Add( |
8735 new(Z) InstanceCallNode(TokenPosition::kNoSource, | 8746 new(Z) InstanceCallNode(TokenPosition::kNoSource, |
8736 new(Z) LoadLocalNode(TokenPosition::kNoSource, iterator_var), | 8747 new(Z) LoadLocalNode(TokenPosition::kNoSource, iterator_var), |
8737 Symbols::Cancel(), | 8748 Symbols::Cancel(), |
8738 no_args)); | 8749 no_args)); |
8739 finally_clause = CloseBlock(); | 8750 finally_clause = CloseBlock(); |
| 8751 |
8740 AstNode* node_to_inline = try_statement->GetNodeToInlineFinally(node_index); | 8752 AstNode* node_to_inline = try_statement->GetNodeToInlineFinally(node_index); |
8741 if (node_to_inline != NULL) { | 8753 if (node_to_inline != NULL) { |
8742 InlinedFinallyNode* node = | 8754 InlinedFinallyNode* node = |
8743 new(Z) InlinedFinallyNode(TokenPosition::kNoSource, | 8755 new(Z) InlinedFinallyNode(TokenPosition::kNoSource, |
8744 finally_clause, | 8756 finally_clause, |
8745 context_var, | 8757 context_var, |
8746 outer_try_index); | 8758 outer_try_index); |
8747 finally_clause = NULL; | 8759 finally_clause = NULL; |
8748 AddFinallyClauseToNode(true, node_to_inline, node); | 8760 AddFinallyClauseToNode(true, node_to_inline, node); |
8749 node_index++; | 8761 node_index++; |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9120 TRACE_PARSER("EnsureFinallyClause"); | 9132 TRACE_PARSER("EnsureFinallyClause"); |
9121 ASSERT(parse || (is_async && (try_stack_ != NULL))); | 9133 ASSERT(parse || (is_async && (try_stack_ != NULL))); |
9122 OpenBlock(); | 9134 OpenBlock(); |
9123 if (parse) { | 9135 if (parse) { |
9124 ExpectToken(Token::kLBRACE); | 9136 ExpectToken(Token::kLBRACE); |
9125 } | 9137 } |
9126 | 9138 |
9127 if (try_stack_ != NULL) { | 9139 if (try_stack_ != NULL) { |
9128 try_stack_->enter_finally(); | 9140 try_stack_->enter_finally(); |
9129 } | 9141 } |
9130 // In case of async closures we need to restore the saved try index of an | 9142 // In case of async closures we need to restore the saved try context of an |
9131 // outer try block (if it exists). The current try block has already been | 9143 // outer try block (if it exists). The current try block has already been |
9132 // removed from the stack of try blocks. | 9144 // removed from the stack of try blocks. |
9133 if (is_async) { | 9145 if (is_async) { |
9134 if (try_stack_ != NULL) { | 9146 if (try_stack_ != NULL) { |
9135 LocalScope* scope = try_stack_->try_block()->scope; | 9147 LocalScope* scope = try_stack_->try_block()->scope; |
9136 if (scope->function_level() == current_block_->scope->function_level()) { | 9148 if (scope->function_level() == current_block_->scope->function_level()) { |
9137 LocalVariable* saved_try_ctx = | 9149 LocalVariable* saved_try_ctx = |
9138 LookupSavedTryContextVar(scope->parent()); | 9150 LookupSavedTryContextVar(scope->parent()); |
9139 LocalVariable* async_saved_try_ctx = | 9151 LocalVariable* async_saved_try_ctx = |
9140 LookupAsyncSavedTryContextVar(async_temp_scope_, | 9152 LookupAsyncSavedTryContextVar(async_temp_scope_, |
(...skipping 5255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14396 const ArgumentListNode& function_args, | 14408 const ArgumentListNode& function_args, |
14397 const LocalVariable* temp_for_last_arg, | 14409 const LocalVariable* temp_for_last_arg, |
14398 bool is_super_invocation) { | 14410 bool is_super_invocation) { |
14399 UNREACHABLE(); | 14411 UNREACHABLE(); |
14400 return NULL; | 14412 return NULL; |
14401 } | 14413 } |
14402 | 14414 |
14403 } // namespace dart | 14415 } // namespace dart |
14404 | 14416 |
14405 #endif // DART_PRECOMPILED_RUNTIME | 14417 #endif // DART_PRECOMPILED_RUNTIME |
OLD | NEW |