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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/elements/elements.dart

Issue 13866010: Correctly compile unresolved for-in loops. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Additional problems found during testing. Created 7 years, 8 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 | Annotate | Revision Log
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 elements; 5 library elements;
6 6
7 import 'dart:uri'; 7 import 'dart:uri';
8 8
9 import 'modelx.dart'; 9 import 'modelx.dart';
10 import '../tree/tree.dart'; 10 import '../tree/tree.dart';
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 Link<MetadataAnnotation> get metadata; 178 Link<MetadataAnnotation> get metadata;
179 179
180 Node parseNode(DiagnosticListener listener); 180 Node parseNode(DiagnosticListener listener);
181 DartType computeType(Compiler compiler); 181 DartType computeType(Compiler compiler);
182 182
183 bool isFunction(); 183 bool isFunction();
184 bool isConstructor(); 184 bool isConstructor();
185 bool isClosure(); 185 bool isClosure();
186 bool isMember(); 186 bool isMember();
187 bool isInstanceMember(); 187 bool isInstanceMember();
188 bool isInStaticMember();
189 188
190 bool isFactoryConstructor(); 189 bool isFactoryConstructor();
191 bool isGenerativeConstructor(); 190 bool isGenerativeConstructor();
192 bool isGenerativeConstructorBody(); 191 bool isGenerativeConstructorBody();
193 bool isCompilationUnit(); 192 bool isCompilationUnit();
194 bool isClass(); 193 bool isClass();
195 bool isPrefix(); 194 bool isPrefix();
196 bool isVariable(); 195 bool isVariable();
197 bool isParameter(); 196 bool isParameter();
198 bool isStatement(); 197 bool isStatement();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 286 }
288 return !Elements.isUnresolved(element) 287 return !Elements.isUnresolved(element)
289 && !element.isInstanceMember() 288 && !element.isInstanceMember()
290 && !element.isPrefix() 289 && !element.isPrefix()
291 && element.enclosingElement != null 290 && element.enclosingElement != null
292 && (element.enclosingElement.kind == ElementKind.CLASS || 291 && (element.enclosingElement.kind == ElementKind.CLASS ||
293 element.enclosingElement.kind == ElementKind.COMPILATION_UNIT || 292 element.enclosingElement.kind == ElementKind.COMPILATION_UNIT ||
294 element.enclosingElement.kind == ElementKind.LIBRARY); 293 element.enclosingElement.kind == ElementKind.LIBRARY);
295 } 294 }
296 295
296 static bool isInStaticContext(Element element) {
297 if (isUnresolved(element)) return true;
298 if (element.enclosingElement.isClosure()) {
299 var closureClass = element.enclosingElement;
300 element = closureClass.methodElement;
301 }
302 Element outer = element.getOutermostEnclosingMemberOrTopLevel();
303 if (isUnresolved(outer)) return true;
304 if (outer.isTopLevel()) return true;
305 if (outer.isGenerativeConstructor()) return false;
306 if (outer.isInstanceMember()) return false;
307 return true;
308 }
309
297 static bool isStaticOrTopLevelField(Element element) { 310 static bool isStaticOrTopLevelField(Element element) {
298 return isStaticOrTopLevel(element) 311 return isStaticOrTopLevel(element)
299 && (identical(element.kind, ElementKind.FIELD) 312 && (identical(element.kind, ElementKind.FIELD)
300 || identical(element.kind, ElementKind.GETTER) 313 || identical(element.kind, ElementKind.GETTER)
301 || identical(element.kind, ElementKind.SETTER)); 314 || identical(element.kind, ElementKind.SETTER));
302 } 315 }
303 316
304 static bool isStaticOrTopLevelFunction(Element element) { 317 static bool isStaticOrTopLevelFunction(Element element) {
305 return isStaticOrTopLevel(element) 318 return isStaticOrTopLevel(element)
306 && (identical(element.kind, ElementKind.FUNCTION)); 319 && (identical(element.kind, ElementKind.FUNCTION));
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 int get resolutionState; 871 int get resolutionState;
859 Token get beginToken; 872 Token get beginToken;
860 Token get endToken; 873 Token get endToken;
861 874
862 // TODO(kasperl): Try to get rid of these. 875 // TODO(kasperl): Try to get rid of these.
863 void set annotatedElement(Element value); 876 void set annotatedElement(Element value);
864 void set resolutionState(int value); 877 void set resolutionState(int value);
865 878
866 MetadataAnnotation ensureResolved(Compiler compiler); 879 MetadataAnnotation ensureResolved(Compiler compiler);
867 } 880 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698