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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 /// | 391 /// |
390 /// See [:patch_parser.dart:] for a description of the terminology. | 392 /// See [:patch_parser.dart:] for a description of the terminology. |
391 Element get origin; | 393 Element get origin; |
392 | 394 |
393 bool get isSynthesized; | 395 bool get isSynthesized; |
394 bool get isMixinApplication; | 396 bool get isMixinApplication; |
395 | 397 |
396 bool get hasFixedBackendName; | 398 bool get hasFixedBackendName; |
397 String get fixedBackendName; | 399 String get fixedBackendName; |
398 | 400 |
| 401 String get fixedBackendReceiver; |
| 402 |
399 bool get isAbstract; | 403 bool get isAbstract; |
400 | 404 |
401 Scope buildScope(); | 405 Scope buildScope(); |
402 | 406 |
403 void diagnose(Element context, DiagnosticListener listener); | 407 void diagnose(Element context, DiagnosticListener listener); |
404 | 408 |
405 // TODO(johnniwinther): Move this to [AstElement]. | 409 // TODO(johnniwinther): Move this to [AstElement]. |
406 /// Returns the [Element] that holds the [TreeElements] for this element. | 410 /// Returns the [Element] that holds the [TreeElements] for this element. |
407 AnalyzableElement get analyzableElement; | 411 AnalyzableElement get analyzableElement; |
408 | 412 |
409 accept(ElementVisitor visitor, arg); | 413 accept(ElementVisitor visitor, arg); |
| 414 |
| 415 void setJsInterop(String name); |
410 } | 416 } |
411 | 417 |
412 class Elements { | 418 class Elements { |
413 static bool isUnresolved(Element e) { | 419 static bool isUnresolved(Element e) { |
414 return e == null || e.isErroneous; | 420 return e == null || e.isErroneous; |
415 } | 421 } |
416 static bool isErroneous(Element e) => e != null && e.isErroneous; | 422 static bool isErroneous(Element e) => e != null && e.isErroneous; |
417 | 423 |
418 /// Unwraps [element] reporting any warnings attached to it, if any. | 424 /// Unwraps [element] reporting any warnings attached to it, if any. |
419 static Element unwrap(Element element, | 425 static Element unwrap(Element element, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 // it specially. | 510 // it specially. |
505 if (element.isGenerativeConstructorBody) return true; | 511 if (element.isGenerativeConstructorBody) return true; |
506 return !Elements.isUnresolved(element) && | 512 return !Elements.isUnresolved(element) && |
507 !element.isAbstract && | 513 !element.isAbstract && |
508 element.isInstanceMember && | 514 element.isInstanceMember && |
509 (element.isFunction || element.isAccessor); | 515 (element.isFunction || element.isAccessor); |
510 } | 516 } |
511 | 517 |
512 static bool isNativeOrExtendsNative(ClassElement element) { | 518 static bool isNativeOrExtendsNative(ClassElement element) { |
513 if (element == null) return false; | 519 if (element == null) return false; |
514 if (element.isNative) return true; | 520 if (element.isNative || element.isJsInterop) return true; |
515 assert(element.isResolved); | 521 assert(element.isResolved); |
516 return isNativeOrExtendsNative(element.superclass); | 522 return isNativeOrExtendsNative(element.superclass); |
517 } | 523 } |
518 | 524 |
519 static bool isInstanceSend(Send send, TreeElements elements) { | 525 static bool isInstanceSend(Send send, TreeElements elements) { |
520 Element element = elements[send]; | 526 Element element = elements[send]; |
521 if (element == null) return !isClosureSend(send, element); | 527 if (element == null) return !isClosureSend(send, element); |
522 return isInstanceMethod(element) || | 528 return isInstanceMethod(element) || |
523 isInstanceField(element) || | 529 isInstanceField(element) || |
524 (send.isConditional && !element.isStatic); | 530 (send.isConditional && !element.isStatic); |
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1653 bool get isDeclaredByField; | 1659 bool get isDeclaredByField; |
1654 | 1660 |
1655 /// Returns `true` if this member is abstract. | 1661 /// Returns `true` if this member is abstract. |
1656 bool get isAbstract; | 1662 bool get isAbstract; |
1657 | 1663 |
1658 /// If abstract, [implementation] points to the overridden concrete member, | 1664 /// If abstract, [implementation] points to the overridden concrete member, |
1659 /// if any. Otherwise [implementation] points to the member itself. | 1665 /// if any. Otherwise [implementation] points to the member itself. |
1660 Member get implementation; | 1666 Member get implementation; |
1661 } | 1667 } |
1662 | 1668 |
OLD | NEW |