| 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 4699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4710 LocalScope* incr_scope = current_block_->scope; | 4710 LocalScope* incr_scope = current_block_->scope; |
| 4711 if (CurrentToken() != Token::kRPAREN) { | 4711 if (CurrentToken() != Token::kRPAREN) { |
| 4712 increment = ParseExprList(); | 4712 increment = ParseExprList(); |
| 4713 } | 4713 } |
| 4714 ExpectToken(Token::kRPAREN); | 4714 ExpectToken(Token::kRPAREN); |
| 4715 const bool parsing_loop_body = true; | 4715 const bool parsing_loop_body = true; |
| 4716 SequenceNode* body = ParseNestedStatement(parsing_loop_body, NULL); | 4716 SequenceNode* body = ParseNestedStatement(parsing_loop_body, NULL); |
| 4717 | 4717 |
| 4718 // Check whether any of the variables in the initializer part of | 4718 // Check whether any of the variables in the initializer part of |
| 4719 // the for statement are captured by a closure. If so, we insert a | 4719 // the for statement are captured by a closure. If so, we insert a |
| 4720 // node that creates a new Context at the end of the loop body (but | 4720 // node that creates a new Context for the loop variable before |
| 4721 // before the increment expression is evaluated). | 4721 // the increment expression is evaluated. |
| 4722 for (int i = 0; i < init_scope->num_variables(); i++) { | 4722 for (int i = 0; i < init_scope->num_variables(); i++) { |
| 4723 if (init_scope->VariableAt(i)->is_captured() && | 4723 if (init_scope->VariableAt(i)->is_captured() && |
| 4724 (init_scope->VariableAt(i)->owner() == init_scope)) { | 4724 (init_scope->VariableAt(i)->owner() == init_scope)) { |
| 4725 body->Add(new CloneContextNode(for_pos)); | 4725 SequenceNode* incr_sequence = new SequenceNode(incr_pos, incr_scope); |
| 4726 incr_sequence->Add(new CloneContextNode(for_pos)); |
| 4727 if (increment != NULL) { |
| 4728 incr_sequence->Add(increment); |
| 4729 } |
| 4730 increment = incr_sequence; |
| 4726 break; | 4731 break; |
| 4727 } | 4732 } |
| 4728 } | 4733 } |
| 4729 CloseBlock(); | 4734 CloseBlock(); |
| 4730 return new ForNode(for_pos, | 4735 return new ForNode(for_pos, |
| 4731 label, | 4736 label, |
| 4732 NodeAsSequenceNode(init_pos, initializer, init_scope), | 4737 NodeAsSequenceNode(init_pos, initializer, init_scope), |
| 4733 condition, | 4738 condition, |
| 4734 NodeAsSequenceNode(incr_pos, increment, incr_scope), | 4739 NodeAsSequenceNode(incr_pos, increment, incr_scope), |
| 4735 body); | 4740 body); |
| (...skipping 3511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8247 void Parser::SkipQualIdent() { | 8252 void Parser::SkipQualIdent() { |
| 8248 ASSERT(IsIdentifier()); | 8253 ASSERT(IsIdentifier()); |
| 8249 ConsumeToken(); | 8254 ConsumeToken(); |
| 8250 if (CurrentToken() == Token::kPERIOD) { | 8255 if (CurrentToken() == Token::kPERIOD) { |
| 8251 ConsumeToken(); // Consume the kPERIOD token. | 8256 ConsumeToken(); // Consume the kPERIOD token. |
| 8252 ExpectIdentifier("identifier expected after '.'"); | 8257 ExpectIdentifier("identifier expected after '.'"); |
| 8253 } | 8258 } |
| 8254 } | 8259 } |
| 8255 | 8260 |
| 8256 } // namespace dart | 8261 } // namespace dart |
| OLD | NEW |