| 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 8997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9008 // The case without a type is handled above, so require a type here. | 9008 // The case without a type is handled above, so require a type here. |
| 9009 // Delay creation of the local variable until we know its actual | 9009 // Delay creation of the local variable until we know its actual |
| 9010 // position, which is inside the loop body. | 9010 // position, which is inside the loop body. |
| 9011 new_loop_var = true; | 9011 new_loop_var = true; |
| 9012 loop_var_type = ParseConstFinalVarOrType( | 9012 loop_var_type = ParseConstFinalVarOrType( |
| 9013 I->type_checks() ? ClassFinalizer::kCanonicalize : | 9013 I->type_checks() ? ClassFinalizer::kCanonicalize : |
| 9014 ClassFinalizer::kIgnore); | 9014 ClassFinalizer::kIgnore); |
| 9015 loop_var_name = ExpectIdentifier("variable name expected"); | 9015 loop_var_name = ExpectIdentifier("variable name expected"); |
| 9016 } | 9016 } |
| 9017 ExpectToken(Token::kIN); | 9017 ExpectToken(Token::kIN); |
| 9018 |
| 9019 // Ensure that the block token range contains the call to moveNext and it |
| 9020 // also starts the block at a different token position than the following |
| 9021 // loop block. Both blocks can allocate contexts and if they have a matching |
| 9022 // token position range, it can be an issue (cf. bug 26941). |
| 9023 OpenBlock(); // Implicit block around while loop. |
| 9024 |
| 9018 const TokenPosition collection_pos = TokenPos(); | 9025 const TokenPosition collection_pos = TokenPos(); |
| 9019 AstNode* collection_expr = | 9026 AstNode* collection_expr = |
| 9020 ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); | 9027 ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); |
| 9021 ExpectToken(Token::kRPAREN); | 9028 ExpectToken(Token::kRPAREN); |
| 9022 | 9029 |
| 9023 OpenBlock(); // Implicit block around while loop. | |
| 9024 | |
| 9025 // Generate implicit iterator variable and add to scope. | 9030 // Generate implicit iterator variable and add to scope. |
| 9026 // We could set the type of the implicit iterator variable to Iterator<T> | 9031 // We could set the type of the implicit iterator variable to Iterator<T> |
| 9027 // where T is the type of the for loop variable. However, the type error | 9032 // where T is the type of the for loop variable. However, the type error |
| 9028 // would refer to the compiler generated iterator and could confuse the user. | 9033 // would refer to the compiler generated iterator and could confuse the user. |
| 9029 // It is better to leave the iterator untyped and postpone the type error | 9034 // It is better to leave the iterator untyped and postpone the type error |
| 9030 // until the loop variable is assigned to. | 9035 // until the loop variable is assigned to. |
| 9031 const AbstractType& iterator_type = Object::dynamic_type(); | 9036 const AbstractType& iterator_type = Object::dynamic_type(); |
| 9032 LocalVariable* iterator_var = new(Z) LocalVariable( | 9037 LocalVariable* iterator_var = new(Z) LocalVariable( |
| 9033 collection_pos, Symbols::ForInIter(), iterator_type); | 9038 collection_pos, Symbols::ForInIter(), iterator_type); |
| 9034 current_block_->scope->AddVariable(iterator_var); | 9039 current_block_->scope->AddVariable(iterator_var); |
| (...skipping 5612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14647 const ArgumentListNode& function_args, | 14652 const ArgumentListNode& function_args, |
| 14648 const LocalVariable* temp_for_last_arg, | 14653 const LocalVariable* temp_for_last_arg, |
| 14649 bool is_super_invocation) { | 14654 bool is_super_invocation) { |
| 14650 UNREACHABLE(); | 14655 UNREACHABLE(); |
| 14651 return NULL; | 14656 return NULL; |
| 14652 } | 14657 } |
| 14653 | 14658 |
| 14654 } // namespace dart | 14659 } // namespace dart |
| 14655 | 14660 |
| 14656 #endif // DART_PRECOMPILED_RUNTIME | 14661 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |