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/bootstrap.h" | 9 #include "vm/bootstrap.h" |
10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 6767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6778 } | 6778 } |
6779 iterator->AddNodeForFinallyInlining(node); | 6779 iterator->AddNodeForFinallyInlining(node); |
6780 iterator = iterator->outer_try_block(); | 6780 iterator = iterator->outer_try_block(); |
6781 } | 6781 } |
6782 } | 6782 } |
6783 | 6783 |
6784 | 6784 |
6785 // Add the inlined finally block to the specified node. | 6785 // Add the inlined finally block to the specified node. |
6786 void Parser::AddFinallyBlockToNode(AstNode* node, | 6786 void Parser::AddFinallyBlockToNode(AstNode* node, |
6787 InlinedFinallyNode* finally_node) { | 6787 InlinedFinallyNode* finally_node) { |
6788 if (node->IsReturnNode()) { | 6788 ReturnNode* return_node = node->AsReturnNode(); |
6789 node->AsReturnNode()->AddInlinedFinallyNode(finally_node); | 6789 if (return_node != NULL) { |
6790 } else { | 6790 return_node->AddInlinedFinallyNode(finally_node); |
6791 ASSERT(node->IsJumpNode()); | 6791 if (return_node->saved_return_value_var() == NULL) { |
6792 node->AsJumpNode()->AddInlinedFinallyNode(finally_node); | 6792 LocalVariable* temp = |
| 6793 CreateTempConstVariable(node->token_pos(), "finally_ret_val"); |
| 6794 return_node->set_saved_return_value_var(temp); |
| 6795 } |
| 6796 return; |
6793 } | 6797 } |
| 6798 JumpNode* jump_node = node->AsJumpNode(); |
| 6799 ASSERT(jump_node != NULL); |
| 6800 jump_node->AddInlinedFinallyNode(finally_node); |
6794 } | 6801 } |
6795 | 6802 |
6796 | 6803 |
6797 SequenceNode* Parser::ParseCatchClauses( | 6804 SequenceNode* Parser::ParseCatchClauses( |
6798 intptr_t handler_pos, | 6805 intptr_t handler_pos, |
6799 LocalVariable* exception_var, | 6806 LocalVariable* exception_var, |
6800 LocalVariable* stack_trace_var, | 6807 LocalVariable* stack_trace_var, |
6801 const GrowableObjectArray& handler_types, | 6808 const GrowableObjectArray& handler_types, |
6802 bool* needs_stack_trace) { | 6809 bool* needs_stack_trace) { |
6803 // All catch blocks are merged into an if-then-else sequence of the | 6810 // All catch blocks are merged into an if-then-else sequence of the |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7046 TryBlocks* inner_try_block = PopTryBlock(); | 7053 TryBlocks* inner_try_block = PopTryBlock(); |
7047 const intptr_t try_index = inner_try_block->try_index(); | 7054 const intptr_t try_index = inner_try_block->try_index(); |
7048 TryBlocks* outer_try_block = try_blocks_list_; | 7055 TryBlocks* outer_try_block = try_blocks_list_; |
7049 const intptr_t outer_try_index = (outer_try_block != NULL) | 7056 const intptr_t outer_try_index = (outer_try_block != NULL) |
7050 ? outer_try_block->try_index() | 7057 ? outer_try_block->try_index() |
7051 : CatchClauseNode::kInvalidTryIndex; | 7058 : CatchClauseNode::kInvalidTryIndex; |
7052 | 7059 |
7053 // Finally parse the 'finally' block. | 7060 // Finally parse the 'finally' block. |
7054 SequenceNode* finally_block = NULL; | 7061 SequenceNode* finally_block = NULL; |
7055 if (CurrentToken() == Token::kFINALLY) { | 7062 if (CurrentToken() == Token::kFINALLY) { |
7056 current_function().set_has_finally(true); | |
7057 ConsumeToken(); // Consume the 'finally'. | 7063 ConsumeToken(); // Consume the 'finally'. |
7058 const intptr_t finally_pos = TokenPos(); | 7064 const intptr_t finally_pos = TokenPos(); |
7059 // Add the finally block to the exit points recorded so far. | 7065 // Add the finally block to the exit points recorded so far. |
7060 intptr_t node_index = 0; | 7066 intptr_t node_index = 0; |
7061 AstNode* node_to_inline = | 7067 AstNode* node_to_inline = |
7062 inner_try_block->GetNodeToInlineFinally(node_index); | 7068 inner_try_block->GetNodeToInlineFinally(node_index); |
7063 while (node_to_inline != NULL) { | 7069 while (node_to_inline != NULL) { |
7064 finally_block = ParseFinallyBlock(); | 7070 finally_block = ParseFinallyBlock(); |
7065 InlinedFinallyNode* node = new InlinedFinallyNode(finally_pos, | 7071 InlinedFinallyNode* node = new InlinedFinallyNode(finally_pos, |
7066 finally_block, | 7072 finally_block, |
(...skipping 3724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10791 void Parser::SkipQualIdent() { | 10797 void Parser::SkipQualIdent() { |
10792 ASSERT(IsIdentifier()); | 10798 ASSERT(IsIdentifier()); |
10793 ConsumeToken(); | 10799 ConsumeToken(); |
10794 if (CurrentToken() == Token::kPERIOD) { | 10800 if (CurrentToken() == Token::kPERIOD) { |
10795 ConsumeToken(); // Consume the kPERIOD token. | 10801 ConsumeToken(); // Consume the kPERIOD token. |
10796 ExpectIdentifier("identifier expected after '.'"); | 10802 ExpectIdentifier("identifier expected after '.'"); |
10797 } | 10803 } |
10798 } | 10804 } |
10799 | 10805 |
10800 } // namespace dart | 10806 } // namespace dart |
OLD | NEW |