| 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 library elements; | 5 library elements; |
| 6 | 6 |
| 7 | 7 |
| 8 import '../tree/tree.dart'; | 8 import '../tree/tree.dart'; |
| 9 import '../util/util.dart'; | 9 import '../util/util.dart'; |
| 10 import '../resolution/resolution.dart'; | 10 import '../resolution/resolution.dart'; |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 return isStaticOrTopLevel(element) | 325 return isStaticOrTopLevel(element) |
| 326 && (identical(element.kind, ElementKind.FUNCTION)); | 326 && (identical(element.kind, ElementKind.FUNCTION)); |
| 327 } | 327 } |
| 328 | 328 |
| 329 static bool isInstanceMethod(Element element) { | 329 static bool isInstanceMethod(Element element) { |
| 330 return !Elements.isUnresolved(element) | 330 return !Elements.isUnresolved(element) |
| 331 && element.isInstanceMember() | 331 && element.isInstanceMember() |
| 332 && (identical(element.kind, ElementKind.FUNCTION)); | 332 && (identical(element.kind, ElementKind.FUNCTION)); |
| 333 } | 333 } |
| 334 | 334 |
| 335 static bool isNativeOrExtendsNative(ClassElement element) { |
| 336 if (element == null) return false; |
| 337 if (element.isNative()) return true; |
| 338 return isNativeOrExtendsNative(element.superclass); |
| 339 } |
| 340 |
| 335 static bool isInstanceSend(Send send, TreeElements elements) { | 341 static bool isInstanceSend(Send send, TreeElements elements) { |
| 336 Element element = elements[send]; | 342 Element element = elements[send]; |
| 337 if (element == null) return !isClosureSend(send, element); | 343 if (element == null) return !isClosureSend(send, element); |
| 338 return isInstanceMethod(element) || isInstanceField(element); | 344 return isInstanceMethod(element) || isInstanceField(element); |
| 339 } | 345 } |
| 340 | 346 |
| 341 static bool isClosureSend(Send send, Element element) { | 347 static bool isClosureSend(Send send, Element element) { |
| 342 if (send.isPropertyAccess) return false; | 348 if (send.isPropertyAccess) return false; |
| 343 if (send.receiver != null) return false; | 349 if (send.receiver != null) return false; |
| 344 Node selector = send.selector; | 350 Node selector = send.selector; |
| 345 // this(). | 351 // this(). |
| 346 if (selector.isThis()) return true; | 352 if (selector.isThis()) return true; |
| 347 // (o)() or foo()(). | 353 // (o)() or foo()(). |
| 348 if (element == null && selector.asIdentifier() == null) return true; | 354 if (element == null && selector.asIdentifier() == null) return true; |
| 349 if (element == null) return false; | 355 if (element == null) return false; |
| 350 // foo() with foo a local or a parameter. | 356 // foo() with foo a local or a parameter. |
| 351 return isLocal(element); | 357 return isLocal(element); |
| 352 } | 358 } |
| 353 | 359 |
| 354 static SourceString reconstructConstructorNameSourceString(Element element) { | 360 static SourceString reconstructConstructorNameSourceString(Element element) { |
| 355 if (element.name == const SourceString('')) { | 361 if (element.name == const SourceString('')) { |
| 356 return element.getEnclosingClass().name; | 362 return element.getEnclosingClass().name; |
| 357 } else { | 363 } else { |
| 358 return new SourceString(reconstructConstructorName(element)); | 364 return new SourceString(reconstructConstructorName(element)); |
| 359 } | 365 } |
| 360 } | 366 } |
| 361 | 367 |
| 362 // TODO(johnniwinther): Remove this method. | 368 // TODO(johnniwinther): Remove this method. |
| 363 static String reconstructConstructorName(Element element) { | 369 static String reconstructConstructorName(Element element) { |
| 364 String className = element.getEnclosingClass().name.slowToString(); | 370 String className = element.getEnclosingClass().name.slowToString(); |
| 365 if (element.name == const SourceString('')) { | 371 if (element.name == const SourceString('')) { |
| 366 return className; | 372 return className; |
| 367 } else { | 373 } else { |
| 368 return '$className\$${element.name.slowToString()}'; | 374 return '$className\$${element.name.slowToString()}'; |
| 369 } | 375 } |
| 370 } | 376 } |
| 371 | 377 |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 int get resolutionState; | 943 int get resolutionState; |
| 938 Token get beginToken; | 944 Token get beginToken; |
| 939 Token get endToken; | 945 Token get endToken; |
| 940 | 946 |
| 941 // TODO(kasperl): Try to get rid of these. | 947 // TODO(kasperl): Try to get rid of these. |
| 942 void set annotatedElement(Element value); | 948 void set annotatedElement(Element value); |
| 943 void set resolutionState(int value); | 949 void set resolutionState(int value); |
| 944 | 950 |
| 945 MetadataAnnotation ensureResolved(Compiler compiler); | 951 MetadataAnnotation ensureResolved(Compiler compiler); |
| 946 } | 952 } |
| OLD | NEW |