Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: runtime/vm/parser.cc

Issue 2193113002: Set correct token position range for statement block containing moveNext call of (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9010 matching lines...) Expand 10 before | Expand all | Expand 10 after
9021 // The case without a type is handled above, so require a type here. 9021 // The case without a type is handled above, so require a type here.
9022 // Delay creation of the local variable until we know its actual 9022 // Delay creation of the local variable until we know its actual
9023 // position, which is inside the loop body. 9023 // position, which is inside the loop body.
9024 new_loop_var = true; 9024 new_loop_var = true;
9025 loop_var_type = ParseConstFinalVarOrType( 9025 loop_var_type = ParseConstFinalVarOrType(
9026 I->type_checks() ? ClassFinalizer::kCanonicalize : 9026 I->type_checks() ? ClassFinalizer::kCanonicalize :
9027 ClassFinalizer::kIgnore); 9027 ClassFinalizer::kIgnore);
9028 loop_var_name = ExpectIdentifier("variable name expected"); 9028 loop_var_name = ExpectIdentifier("variable name expected");
9029 } 9029 }
9030 ExpectToken(Token::kIN); 9030 ExpectToken(Token::kIN);
9031
9032 OpenBlock(); // Implicit block around while loop.
hausner 2016/07/29 17:59:35 Maybe add a comment that explains why we open a bl
regis 2016/07/29 21:31:47 Done.
9033
9031 const TokenPosition collection_pos = TokenPos(); 9034 const TokenPosition collection_pos = TokenPos();
9032 AstNode* collection_expr = 9035 AstNode* collection_expr =
9033 ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); 9036 ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL);
9034 ExpectToken(Token::kRPAREN); 9037 ExpectToken(Token::kRPAREN);
9035 9038
9036 OpenBlock(); // Implicit block around while loop.
9037
9038 // Generate implicit iterator variable and add to scope. 9039 // Generate implicit iterator variable and add to scope.
9039 // We could set the type of the implicit iterator variable to Iterator<T> 9040 // We could set the type of the implicit iterator variable to Iterator<T>
9040 // where T is the type of the for loop variable. However, the type error 9041 // where T is the type of the for loop variable. However, the type error
9041 // would refer to the compiler generated iterator and could confuse the user. 9042 // would refer to the compiler generated iterator and could confuse the user.
9042 // It is better to leave the iterator untyped and postpone the type error 9043 // It is better to leave the iterator untyped and postpone the type error
9043 // until the loop variable is assigned to. 9044 // until the loop variable is assigned to.
9044 const AbstractType& iterator_type = Object::dynamic_type(); 9045 const AbstractType& iterator_type = Object::dynamic_type();
9045 LocalVariable* iterator_var = new(Z) LocalVariable( 9046 LocalVariable* iterator_var = new(Z) LocalVariable(
9046 collection_pos, Symbols::ForInIter(), iterator_type); 9047 collection_pos, Symbols::ForInIter(), iterator_type);
9047 current_block_->scope->AddVariable(iterator_var); 9048 current_block_->scope->AddVariable(iterator_var);
(...skipping 5612 matching lines...) Expand 10 before | Expand all | Expand 10 after
14660 const ArgumentListNode& function_args, 14661 const ArgumentListNode& function_args,
14661 const LocalVariable* temp_for_last_arg, 14662 const LocalVariable* temp_for_last_arg,
14662 bool is_super_invocation) { 14663 bool is_super_invocation) {
14663 UNREACHABLE(); 14664 UNREACHABLE();
14664 return NULL; 14665 return NULL;
14665 } 14666 }
14666 14667
14667 } // namespace dart 14668 } // namespace dart
14668 14669
14669 #endif // DART_PRECOMPILED_RUNTIME 14670 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698