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 "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
(...skipping 5678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5689 const String& iterator_method_name = | 5689 const String& iterator_method_name = |
5690 String::ZoneHandle(Symbols::GetIterator()); | 5690 String::ZoneHandle(Symbols::GetIterator()); |
5691 ArgumentListNode* no_args = new ArgumentListNode(collection_pos); | 5691 ArgumentListNode* no_args = new ArgumentListNode(collection_pos); |
5692 AstNode* get_iterator = new InstanceCallNode( | 5692 AstNode* get_iterator = new InstanceCallNode( |
5693 collection_pos, collection_expr, iterator_method_name, no_args); | 5693 collection_pos, collection_expr, iterator_method_name, no_args); |
5694 AstNode* iterator_init = | 5694 AstNode* iterator_init = |
5695 new StoreLocalNode(collection_pos, iterator_var, get_iterator); | 5695 new StoreLocalNode(collection_pos, iterator_var, get_iterator); |
5696 current_block_->statements->Add(iterator_init); | 5696 current_block_->statements->Add(iterator_init); |
5697 | 5697 |
5698 // Generate while loop condition. | 5698 // Generate while loop condition. |
5699 AstNode* iterator_has_next = new InstanceCallNode( | 5699 AstNode* iterator_has_next = new InstanceGetterNode( |
5700 collection_pos, | 5700 collection_pos, |
5701 new LoadLocalNode(collection_pos, iterator_var), | 5701 new LoadLocalNode(collection_pos, iterator_var), |
5702 String::ZoneHandle(Symbols::HasNext()), | 5702 String::ZoneHandle(Symbols::HasNext())); |
5703 no_args); | |
5704 | 5703 |
5705 // Parse the for loop body. Ideally, we would use ParseNestedStatement() | 5704 // Parse the for loop body. Ideally, we would use ParseNestedStatement() |
5706 // here, but that does not work well because we have to insert an implicit | 5705 // here, but that does not work well because we have to insert an implicit |
5707 // variable assignment and potentially a variable declaration in the | 5706 // variable assignment and potentially a variable declaration in the |
5708 // loop body. | 5707 // loop body. |
5709 OpenLoopBlock(); | 5708 OpenLoopBlock(); |
5710 current_block_->scope->AddLabel(label); | 5709 current_block_->scope->AddLabel(label); |
5711 | 5710 |
5712 AstNode* iterator_next = new InstanceCallNode( | 5711 AstNode* iterator_next = new InstanceCallNode( |
5713 collection_pos, | 5712 collection_pos, |
(...skipping 4042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9756 void Parser::SkipQualIdent() { | 9755 void Parser::SkipQualIdent() { |
9757 ASSERT(IsIdentifier()); | 9756 ASSERT(IsIdentifier()); |
9758 ConsumeToken(); | 9757 ConsumeToken(); |
9759 if (CurrentToken() == Token::kPERIOD) { | 9758 if (CurrentToken() == Token::kPERIOD) { |
9760 ConsumeToken(); // Consume the kPERIOD token. | 9759 ConsumeToken(); // Consume the kPERIOD token. |
9761 ExpectIdentifier("identifier expected after '.'"); | 9760 ExpectIdentifier("identifier expected after '.'"); |
9762 } | 9761 } |
9763 } | 9762 } |
9764 | 9763 |
9765 } // namespace dart | 9764 } // namespace dart |
OLD | NEW |