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

Side by Side Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 1503063002: Handle const loop variable. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years 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
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 library dart2js.resolution.members; 5 library dart2js.resolution.members;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/names.dart' show 8 import '../common/names.dart' show
9 Selectors; 9 Selectors;
10 import '../common/resolution.dart' show 10 import '../common/resolution.dart' show
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 /// `prefix.Class.staticMethod()`. 119 /// `prefix.Class.staticMethod()`.
120 bool sendIsMemberAccess = false; 120 bool sendIsMemberAccess = false;
121 121
122 StatementScope statementScope; 122 StatementScope statementScope;
123 int allowedCategory = ElementCategory.VARIABLE | ElementCategory.FUNCTION 123 int allowedCategory = ElementCategory.VARIABLE | ElementCategory.FUNCTION
124 | ElementCategory.IMPLIES_TYPE; 124 | ElementCategory.IMPLIES_TYPE;
125 125
126 /// When visiting the type declaration of the variable in a [ForIn] loop, 126 /// When visiting the type declaration of the variable in a [ForIn] loop,
127 /// the initializer of the variable is implicit and we should not emit an 127 /// the initializer of the variable is implicit and we should not emit an
128 /// error when verifying that all final variables are initialized. 128 /// error when verifying that all final variables are initialized.
129 bool allowFinalWithoutInitializer = false; 129 bool inLoopVariable = false;
130 130
131 /// The nodes for which variable access and mutation must be registered in 131 /// The nodes for which variable access and mutation must be registered in
132 /// order to determine when the static type of variables types is promoted. 132 /// order to determine when the static type of variables types is promoted.
133 Link<Node> promotionScope = const Link<Node>(); 133 Link<Node> promotionScope = const Link<Node>();
134 134
135 bool isPotentiallyMutableTarget(Element target) { 135 bool isPotentiallyMutableTarget(Element target) {
136 if (target == null) return false; 136 if (target == null) return false;
137 return (target.isVariable || target.isParameter) && 137 return (target.isVariable || target.isParameter) &&
138 !(target.isFinal || target.isConst); 138 !(target.isFinal || target.isConst);
139 } 139 }
(...skipping 4240 matching lines...) Expand 10 before | Expand all | Expand 10 after
4380 visitLoopBodyIn(node, node.body, blockScope); 4380 visitLoopBodyIn(node, node.body, blockScope);
4381 return const NoneResult(); 4381 return const NoneResult();
4382 } 4382 }
4383 4383
4384 void visitForInDeclaredIdentifierIn( 4384 void visitForInDeclaredIdentifierIn(
4385 Node declaration, 4385 Node declaration,
4386 ForIn node, 4386 ForIn node,
4387 Scope blockScope) { 4387 Scope blockScope) {
4388 LibraryElement library = enclosingElement.library; 4388 LibraryElement library = enclosingElement.library;
4389 4389
4390 bool oldAllowFinalWithoutInitializer = allowFinalWithoutInitializer; 4390 bool oldAllowFinalWithoutInitializer = inLoopVariable;
4391 allowFinalWithoutInitializer = true; 4391 inLoopVariable = true;
4392 visitIn(declaration, blockScope); 4392 visitIn(declaration, blockScope);
4393 allowFinalWithoutInitializer = oldAllowFinalWithoutInitializer; 4393 inLoopVariable = oldAllowFinalWithoutInitializer;
4394 4394
4395 Send send = declaration.asSend(); 4395 Send send = declaration.asSend();
4396 VariableDefinitions variableDefinitions = 4396 VariableDefinitions variableDefinitions =
4397 declaration.asVariableDefinitions(); 4397 declaration.asVariableDefinitions();
4398 Element loopVariable; 4398 Element loopVariable;
4399 Selector loopVariableSelector; 4399 Selector loopVariableSelector;
4400 if (send != null) { 4400 if (send != null) {
4401 loopVariable = registry.getDefinition(send); 4401 loopVariable = registry.getDefinition(send);
4402 Identifier identifier = send.selector.asIdentifier(); 4402 Identifier identifier = send.selector.asIdentifier();
4403 if (identifier == null) { 4403 if (identifier == null) {
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
4851 } 4851 }
4852 return const NoneResult(); 4852 return const NoneResult();
4853 } 4853 }
4854 } 4854 }
4855 4855
4856 /// Looks up [name] in [scope] and unwraps the result. 4856 /// Looks up [name] in [scope] and unwraps the result.
4857 Element lookupInScope(DiagnosticReporter reporter, Node node, 4857 Element lookupInScope(DiagnosticReporter reporter, Node node,
4858 Scope scope, String name) { 4858 Scope scope, String name) {
4859 return Elements.unwrap(scope.lookup(name), reporter, node); 4859 return Elements.unwrap(scope.lookup(name), reporter, node);
4860 } 4860 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698