| 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 import '../compiler.dart' show | 7 import '../compiler.dart' show |
| 8 Compiler; | 8 Compiler; |
| 9 import '../constants/constructors.dart'; | 9 import '../constants/constructors.dart'; |
| 10 import '../constants/expressions.dart'; | 10 import '../constants/expressions.dart'; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 293 |
| 294 /// Returns true if this [Element] is a top level element. | 294 /// Returns true if this [Element] is a top level element. |
| 295 /// That is, if it is not defined within the scope of a class. | 295 /// That is, if it is not defined within the scope of a class. |
| 296 /// | 296 /// |
| 297 /// This means whether the enclosing element is a compilation unit. | 297 /// This means whether the enclosing element is a compilation unit. |
| 298 /// With the exception of [ClosureClassElement] that is considered top level | 298 /// With the exception of [ClosureClassElement] that is considered top level |
| 299 /// as all other classes. | 299 /// as all other classes. |
| 300 bool get isTopLevel; | 300 bool get isTopLevel; |
| 301 bool get isAssignable; | 301 bool get isAssignable; |
| 302 bool get isNative; | 302 bool get isNative; |
| 303 bool get isJsInterop; |
| 304 |
| 303 bool get isDeferredLoaderGetter; | 305 bool get isDeferredLoaderGetter; |
| 304 | 306 |
| 305 /// True if the element is declared in a patch library but has no | 307 /// True if the element is declared in a patch library but has no |
| 306 /// corresponding declaration in the origin library. | 308 /// corresponding declaration in the origin library. |
| 307 bool get isInjected; | 309 bool get isInjected; |
| 308 | 310 |
| 309 /// `true` if this element is a constructor, top level or local variable, | 311 /// `true` if this element is a constructor, top level or local variable, |
| 310 /// or static field that is declared `const`. | 312 /// or static field that is declared `const`. |
| 311 bool get isConst; | 313 bool get isConst; |
| 312 | 314 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 | 402 |
| 401 Scope buildScope(); | 403 Scope buildScope(); |
| 402 | 404 |
| 403 void diagnose(Element context, DiagnosticListener listener); | 405 void diagnose(Element context, DiagnosticListener listener); |
| 404 | 406 |
| 405 // TODO(johnniwinther): Move this to [AstElement]. | 407 // TODO(johnniwinther): Move this to [AstElement]. |
| 406 /// Returns the [Element] that holds the [TreeElements] for this element. | 408 /// Returns the [Element] that holds the [TreeElements] for this element. |
| 407 AnalyzableElement get analyzableElement; | 409 AnalyzableElement get analyzableElement; |
| 408 | 410 |
| 409 accept(ElementVisitor visitor, arg); | 411 accept(ElementVisitor visitor, arg); |
| 412 |
| 413 void setJsInterop(String name); |
| 410 } | 414 } |
| 411 | 415 |
| 412 class Elements { | 416 class Elements { |
| 413 static bool isUnresolved(Element e) { | 417 static bool isUnresolved(Element e) { |
| 414 return e == null || e.isErroneous; | 418 return e == null || e.isErroneous; |
| 415 } | 419 } |
| 416 static bool isErroneous(Element e) => e != null && e.isErroneous; | 420 static bool isErroneous(Element e) => e != null && e.isErroneous; |
| 417 | 421 |
| 418 /// Unwraps [element] reporting any warnings attached to it, if any. | 422 /// Unwraps [element] reporting any warnings attached to it, if any. |
| 419 static Element unwrap(Element element, | 423 static Element unwrap(Element element, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 // it specially. | 508 // it specially. |
| 505 if (element.isGenerativeConstructorBody) return true; | 509 if (element.isGenerativeConstructorBody) return true; |
| 506 return !Elements.isUnresolved(element) && | 510 return !Elements.isUnresolved(element) && |
| 507 !element.isAbstract && | 511 !element.isAbstract && |
| 508 element.isInstanceMember && | 512 element.isInstanceMember && |
| 509 (element.isFunction || element.isAccessor); | 513 (element.isFunction || element.isAccessor); |
| 510 } | 514 } |
| 511 | 515 |
| 512 static bool isNativeOrExtendsNative(ClassElement element) { | 516 static bool isNativeOrExtendsNative(ClassElement element) { |
| 513 if (element == null) return false; | 517 if (element == null) return false; |
| 514 if (element.isNative) return true; | 518 if (element.isNative || element.isJsInterop) return true; |
| 515 assert(element.isResolved); | 519 assert(element.isResolved); |
| 516 return isNativeOrExtendsNative(element.superclass); | 520 return isNativeOrExtendsNative(element.superclass); |
| 517 } | 521 } |
| 518 | 522 |
| 519 static bool isInstanceSend(Send send, TreeElements elements) { | 523 static bool isInstanceSend(Send send, TreeElements elements) { |
| 520 Element element = elements[send]; | 524 Element element = elements[send]; |
| 521 if (element == null) return !isClosureSend(send, element); | 525 if (element == null) return !isClosureSend(send, element); |
| 522 return isInstanceMethod(element) || | 526 return isInstanceMethod(element) || |
| 523 isInstanceField(element) || | 527 isInstanceField(element) || |
| 524 (send.isConditional && !element.isStatic); | 528 (send.isConditional && !element.isStatic); |
| (...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 bool get isDeclaredByField; | 1657 bool get isDeclaredByField; |
| 1654 | 1658 |
| 1655 /// Returns `true` if this member is abstract. | 1659 /// Returns `true` if this member is abstract. |
| 1656 bool get isAbstract; | 1660 bool get isAbstract; |
| 1657 | 1661 |
| 1658 /// If abstract, [implementation] points to the overridden concrete member, | 1662 /// If abstract, [implementation] points to the overridden concrete member, |
| 1659 /// if any. Otherwise [implementation] points to the member itself. | 1663 /// if any. Otherwise [implementation] points to the member itself. |
| 1660 Member get implementation; | 1664 Member get implementation; |
| 1661 } | 1665 } |
| 1662 | 1666 |
| OLD | NEW |