| 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 9036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9047 current_block_->scope->AddVariable(iterator_var); | 9047 current_block_->scope->AddVariable(iterator_var); |
| 9048 | 9048 |
| 9049 // Generate initialization of iterator variable. | 9049 // Generate initialization of iterator variable. |
| 9050 ArgumentListNode* no_args = new(Z) ArgumentListNode(collection_pos); | 9050 ArgumentListNode* no_args = new(Z) ArgumentListNode(collection_pos); |
| 9051 AstNode* get_iterator = new(Z) InstanceGetterNode( | 9051 AstNode* get_iterator = new(Z) InstanceGetterNode( |
| 9052 collection_pos, collection_expr, Symbols::Iterator()); | 9052 collection_pos, collection_expr, Symbols::Iterator()); |
| 9053 AstNode* iterator_init = | 9053 AstNode* iterator_init = |
| 9054 new(Z) StoreLocalNode(collection_pos, iterator_var, get_iterator); | 9054 new(Z) StoreLocalNode(collection_pos, iterator_var, get_iterator); |
| 9055 current_block_->statements->Add(iterator_init); | 9055 current_block_->statements->Add(iterator_init); |
| 9056 | 9056 |
| 9057 // Generate while loop condition. |
| 9058 AstNode* iterator_moveNext = new(Z) InstanceCallNode( |
| 9059 collection_pos, |
| 9060 new(Z) LoadLocalNode(collection_pos, iterator_var), |
| 9061 Symbols::MoveNext(), |
| 9062 no_args); |
| 9063 |
| 9057 // Parse the for loop body. Ideally, we would use ParseNestedStatement() | 9064 // Parse the for loop body. Ideally, we would use ParseNestedStatement() |
| 9058 // here, but that does not work well because we have to insert an implicit | 9065 // here, but that does not work well because we have to insert an implicit |
| 9059 // variable assignment and potentially a variable declaration in the | 9066 // variable assignment and potentially a variable declaration in the |
| 9060 // loop body. | 9067 // loop body. |
| 9061 OpenLoopBlock(); | 9068 OpenLoopBlock(); |
| 9062 current_block_->scope->AddLabel(label); | 9069 current_block_->scope->AddLabel(label); |
| 9063 const TokenPosition loop_var_assignment_pos = TokenPos(); | 9070 const TokenPosition loop_var_assignment_pos = TokenPos(); |
| 9064 | 9071 |
| 9065 // Generate while loop condition. | |
| 9066 AstNode* iterator_moveNext = new(Z) InstanceCallNode( | |
| 9067 loop_var_assignment_pos, | |
| 9068 new(Z) LoadLocalNode(loop_var_assignment_pos, iterator_var), | |
| 9069 Symbols::MoveNext(), | |
| 9070 no_args); | |
| 9071 | |
| 9072 AstNode* iterator_current = new(Z) InstanceGetterNode( | 9072 AstNode* iterator_current = new(Z) InstanceGetterNode( |
| 9073 loop_var_assignment_pos, | 9073 loop_var_assignment_pos, |
| 9074 new(Z) LoadLocalNode(loop_var_assignment_pos, iterator_var), | 9074 new(Z) LoadLocalNode(loop_var_assignment_pos, iterator_var), |
| 9075 Symbols::Current()); | 9075 Symbols::Current()); |
| 9076 | 9076 |
| 9077 // Generate assignment of next iterator value to loop variable. | 9077 // Generate assignment of next iterator value to loop variable. |
| 9078 AstNode* loop_var_assignment = NULL; | 9078 AstNode* loop_var_assignment = NULL; |
| 9079 if (new_loop_var) { | 9079 if (new_loop_var) { |
| 9080 // The for loop variable is new for each iteration. | 9080 // The for loop variable is new for each iteration. |
| 9081 // Create a variable and add it to the loop body scope. | 9081 // Create a variable and add it to the loop body scope. |
| (...skipping 5578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14660 const ArgumentListNode& function_args, | 14660 const ArgumentListNode& function_args, |
| 14661 const LocalVariable* temp_for_last_arg, | 14661 const LocalVariable* temp_for_last_arg, |
| 14662 bool is_super_invocation) { | 14662 bool is_super_invocation) { |
| 14663 UNREACHABLE(); | 14663 UNREACHABLE(); |
| 14664 return NULL; | 14664 return NULL; |
| 14665 } | 14665 } |
| 14666 | 14666 |
| 14667 } // namespace dart | 14667 } // namespace dart |
| 14668 | 14668 |
| 14669 #endif // DART_PRECOMPILED_RUNTIME | 14669 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |