| 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 8706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8717 new_loop_var = true; | 8717 new_loop_var = true; |
| 8718 loop_var_type = ParseConstFinalVarOrType( | 8718 loop_var_type = ParseConstFinalVarOrType( |
| 8719 I->type_checks() ? ClassFinalizer::kCanonicalize : | 8719 I->type_checks() ? ClassFinalizer::kCanonicalize : |
| 8720 ClassFinalizer::kIgnore); | 8720 ClassFinalizer::kIgnore); |
| 8721 } | 8721 } |
| 8722 TokenPosition loop_var_pos = TokenPos(); | 8722 TokenPosition loop_var_pos = TokenPos(); |
| 8723 const String* loop_var_name = ExpectIdentifier("variable name expected"); | 8723 const String* loop_var_name = ExpectIdentifier("variable name expected"); |
| 8724 | 8724 |
| 8725 // Parse stream expression. | 8725 // Parse stream expression. |
| 8726 ExpectToken(Token::kIN); | 8726 ExpectToken(Token::kIN); |
| 8727 |
| 8728 // Open a block for the iterator variable and the try-finally statement |
| 8729 // that contains the loop. Ensure that the block starts at a different |
| 8730 // token position than the following loop block. Both blocks can allocate |
| 8731 // contexts and if they have a matching token position range, |
| 8732 // it can be an issue (cf. bug 26941). |
| 8733 OpenBlock(); |
| 8734 const Block* await_for_block = current_block_; |
| 8735 |
| 8727 const TokenPosition stream_expr_pos = TokenPos(); | 8736 const TokenPosition stream_expr_pos = TokenPos(); |
| 8728 AstNode* stream_expr = | 8737 AstNode* stream_expr = |
| 8729 ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); | 8738 ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); |
| 8730 ExpectToken(Token::kRPAREN); | 8739 ExpectToken(Token::kRPAREN); |
| 8731 | 8740 |
| 8732 // Open a block for the iterator variable and the try-finally | |
| 8733 // statement that contains the loop. | |
| 8734 OpenBlock(); | |
| 8735 const Block* loop_block = current_block_; | |
| 8736 | |
| 8737 // Build creation of implicit StreamIterator. | 8741 // Build creation of implicit StreamIterator. |
| 8738 // var :for-in-iter = new StreamIterator(stream_expr). | 8742 // var :for-in-iter = new StreamIterator(stream_expr). |
| 8739 const Class& stream_iterator_cls = | 8743 const Class& stream_iterator_cls = |
| 8740 Class::ZoneHandle(Z, I->object_store()->stream_iterator_class()); | 8744 Class::ZoneHandle(Z, I->object_store()->stream_iterator_class()); |
| 8741 ASSERT(!stream_iterator_cls.IsNull()); | 8745 ASSERT(!stream_iterator_cls.IsNull()); |
| 8742 const Function& iterator_ctor = | 8746 const Function& iterator_ctor = |
| 8743 Function::ZoneHandle(Z, stream_iterator_cls.LookupFunction( | 8747 Function::ZoneHandle(Z, stream_iterator_cls.LookupFunction( |
| 8744 Symbols::StreamIteratorConstructor())); | 8748 Symbols::StreamIteratorConstructor())); |
| 8745 ASSERT(!iterator_ctor.IsNull()); | 8749 ASSERT(!iterator_ctor.IsNull()); |
| 8746 ArgumentListNode* ctor_args = new (Z) ArgumentListNode(stream_expr_pos); | 8750 ArgumentListNode* ctor_args = new (Z) ArgumentListNode(stream_expr_pos); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8976 | 8980 |
| 8977 AstNode* try_catch_node = | 8981 AstNode* try_catch_node = |
| 8978 new(Z) TryCatchNode(await_for_pos, | 8982 new(Z) TryCatchNode(await_for_pos, |
| 8979 try_block, | 8983 try_block, |
| 8980 context_var, | 8984 context_var, |
| 8981 catch_clause, | 8985 catch_clause, |
| 8982 finally_clause, | 8986 finally_clause, |
| 8983 try_index, | 8987 try_index, |
| 8984 finally_clause); | 8988 finally_clause); |
| 8985 | 8989 |
| 8986 ASSERT(current_block_ == loop_block); | 8990 ASSERT(current_block_ == await_for_block); |
| 8987 loop_block->statements->Add(try_catch_node); | 8991 await_for_block->statements->Add(try_catch_node); |
| 8988 | 8992 |
| 8989 return CloseBlock(); // Implicit block around while loop. | 8993 return CloseBlock(); // Implicit block around while loop. |
| 8990 } | 8994 } |
| 8991 | 8995 |
| 8992 | 8996 |
| 8993 AstNode* Parser::ParseForInStatement(TokenPosition forin_pos, | 8997 AstNode* Parser::ParseForInStatement(TokenPosition forin_pos, |
| 8994 SourceLabel* label) { | 8998 SourceLabel* label) { |
| 8995 TRACE_PARSER("ParseForInStatement"); | 8999 TRACE_PARSER("ParseForInStatement"); |
| 8996 bool loop_var_is_final = (CurrentToken() == Token::kFINAL); | 9000 bool loop_var_is_final = (CurrentToken() == Token::kFINAL); |
| 8997 if (CurrentToken() == Token::kCONST) { | 9001 if (CurrentToken() == Token::kCONST) { |
| (...skipping 5654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14652 const ArgumentListNode& function_args, | 14656 const ArgumentListNode& function_args, |
| 14653 const LocalVariable* temp_for_last_arg, | 14657 const LocalVariable* temp_for_last_arg, |
| 14654 bool is_super_invocation) { | 14658 bool is_super_invocation) { |
| 14655 UNREACHABLE(); | 14659 UNREACHABLE(); |
| 14656 return NULL; | 14660 return NULL; |
| 14657 } | 14661 } |
| 14658 | 14662 |
| 14659 } // namespace dart | 14663 } // namespace dart |
| 14660 | 14664 |
| 14661 #endif // DART_PRECOMPILED_RUNTIME | 14665 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |