| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 entities; | 5 library entities; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 | 8 |
| 9 /// Abstract interface for entities. | 9 /// Abstract interface for entities. |
| 10 /// | 10 /// |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 /// | 23 /// |
| 24 /// Currently only [LibraryElement] but later also kernel based Dart classes | 24 /// Currently only [LibraryElement] but later also kernel based Dart classes |
| 25 /// and/or Dart-in-JS classes. | 25 /// and/or Dart-in-JS classes. |
| 26 abstract class LibraryEntity extends Entity {} | 26 abstract class LibraryEntity extends Entity {} |
| 27 | 27 |
| 28 /// Stripped down super interface for class like entities. | 28 /// Stripped down super interface for class like entities. |
| 29 /// | 29 /// |
| 30 /// Currently only [ClassElement] but later also kernel based Dart classes | 30 /// Currently only [ClassElement] but later also kernel based Dart classes |
| 31 /// and/or Dart-in-JS classes. | 31 /// and/or Dart-in-JS classes. |
| 32 abstract class ClassEntity extends Entity { | 32 abstract class ClassEntity extends Entity { |
| 33 /// If this is a normal class, the enclosing library for this class. If this |
| 34 /// is a closure class, the enclosing class of the closure for which it was |
| 35 /// created. |
| 36 LibraryEntity get library; |
| 37 |
| 38 /// Whether this is a synthesized class for a closurized method or local |
| 39 /// function. |
| 33 bool get isClosure; | 40 bool get isClosure; |
| 34 } | 41 } |
| 35 | 42 |
| 36 abstract class TypeVariableEntity extends Entity { | 43 abstract class TypeVariableEntity extends Entity { |
| 44 /// The class or generic method that declared this type variable. |
| 37 Entity get typeDeclaration; | 45 Entity get typeDeclaration; |
| 46 |
| 47 /// The index of this type variable in the type variables of its |
| 48 /// [typeDeclaration]. |
| 38 int get index; | 49 int get index; |
| 39 } | 50 } |
| 40 | 51 |
| 41 /// Stripped down super interface for member like entities, that is, | 52 /// Stripped down super interface for member like entities, that is, |
| 42 /// constructors, methods, fields etc. | 53 /// constructors, methods, fields etc. |
| 43 /// | 54 /// |
| 44 /// Currently only [MemberElement] but later also kernel based Dart members | 55 /// Currently only [MemberElement] but later also kernel based Dart members |
| 45 /// and/or Dart-in-JS properties. | 56 /// and/or Dart-in-JS properties. |
| 46 abstract class MemberEntity extends Entity { | 57 abstract class MemberEntity extends Entity { |
| 58 /// Whether this is a member of a library. |
| 47 bool get isTopLevel; | 59 bool get isTopLevel; |
| 60 |
| 61 /// Whether this is a static member of a class. |
| 48 bool get isStatic; | 62 bool get isStatic; |
| 63 |
| 64 /// Whether this is an instance member of a class. |
| 49 bool get isInstanceMember; | 65 bool get isInstanceMember; |
| 66 |
| 67 /// Whether this is a constructor. |
| 50 bool get isConstructor; | 68 bool get isConstructor; |
| 69 |
| 70 /// Whether this is a field. |
| 51 bool get isField; | 71 bool get isField; |
| 72 |
| 73 /// Whether this is a normal method (neither constructor, getter or setter) |
| 74 /// or operator method. |
| 52 bool get isFunction; | 75 bool get isFunction; |
| 76 |
| 77 /// Whether this is a getter. |
| 53 bool get isGetter; | 78 bool get isGetter; |
| 79 |
| 80 /// Whether this is a setter. |
| 54 bool get isSetter; | 81 bool get isSetter; |
| 82 |
| 83 /// Whether this member is assignable, i.e. a non-final field. |
| 55 bool get isAssignable; | 84 bool get isAssignable; |
| 85 |
| 86 /// The enclosing class if this is a constuctor, instance member or |
| 87 /// static member of a class. |
| 56 ClassEntity get enclosingClass; | 88 ClassEntity get enclosingClass; |
| 89 |
| 90 /// The enclosing library if this is a library member, otherwise the |
| 91 /// enclosing library of the [enclosingClass]. |
| 92 LibraryEntity get library; |
| 57 } | 93 } |
| 58 | 94 |
| 59 /// Stripped down super interface for field like entities. | 95 /// Stripped down super interface for field like entities. |
| 60 /// | 96 /// |
| 61 /// Currently only [FieldElement] but later also kernel based Dart fields | 97 /// Currently only [FieldElement] but later also kernel based Dart fields |
| 62 /// and/or Dart-in-JS field-like properties. | 98 /// and/or Dart-in-JS field-like properties. |
| 63 abstract class FieldEntity extends MemberEntity {} | 99 abstract class FieldEntity extends MemberEntity {} |
| 64 | 100 |
| 65 /// Stripped down super interface for function like entities. | 101 /// Stripped down super interface for function like entities. |
| 66 /// | 102 /// |
| 67 /// Currently only [MethodElement] but later also kernel based Dart constructors | 103 /// Currently only [MethodElement] but later also kernel based Dart constructors |
| 68 /// and methods and/or Dart-in-JS function-like properties. | 104 /// and methods and/or Dart-in-JS function-like properties. |
| 69 abstract class FunctionEntity extends MemberEntity {} | 105 abstract class FunctionEntity extends MemberEntity { |
| 106 /// Whether this function is external, i.e. the body is not defined in terms |
| 107 /// of Dart code. |
| 108 bool get isExternal; |
| 109 } |
| 70 | 110 |
| 71 /// Stripped down super interface for constructor like entities. | 111 /// Stripped down super interface for constructor like entities. |
| 72 /// | 112 /// |
| 73 /// Currently only [ConstructorElement] but later also kernel based Dart | 113 /// Currently only [ConstructorElement] but later also kernel based Dart |
| 74 /// constructors and/or Dart-in-JS constructor-like properties. | 114 /// constructors and/or Dart-in-JS constructor-like properties. |
| 75 // TODO(johnniwinther): Remove factory constructors from the set of | 115 // TODO(johnniwinther): Remove factory constructors from the set of |
| 76 // constructors. | 116 // constructors. |
| 77 abstract class ConstructorEntity extends FunctionEntity { | 117 abstract class ConstructorEntity extends FunctionEntity { |
| 118 /// Whether this is a generative constructor, possibly redirecting. |
| 78 bool get isGenerativeConstructor; | 119 bool get isGenerativeConstructor; |
| 120 |
| 121 /// Whether this is a factory constructor, possibly redirecting. |
| 79 bool get isFactoryConstructor; | 122 bool get isFactoryConstructor; |
| 80 } | 123 } |
| 81 | 124 |
| 82 /// An entity that defines a local entity (memory slot) in generated code. | 125 /// An entity that defines a local entity (memory slot) in generated code. |
| 83 /// | 126 /// |
| 84 /// Parameters, local variables and local functions (can) define local entity | 127 /// Parameters, local variables and local functions (can) define local entity |
| 85 /// and thus implement [Local] through [LocalElement]. For non-element locals, | 128 /// and thus implement [Local] through [LocalElement]. For non-element locals, |
| 86 /// like `this` and boxes, specialized [Local] classes are created. | 129 /// like `this` and boxes, specialized [Local] classes are created. |
| 87 /// | 130 /// |
| 88 /// Type variables can introduce locals in factories and constructors | 131 /// Type variables can introduce locals in factories and constructors |
| 89 /// but since one type variable can introduce different locals in different | 132 /// but since one type variable can introduce different locals in different |
| 90 /// factories and constructors it is not itself a [Local] but instead | 133 /// factories and constructors it is not itself a [Local] but instead |
| 91 /// a non-element [Local] is created through a specialized class. | 134 /// a non-element [Local] is created through a specialized class. |
| 92 // TODO(johnniwinther): Should [Local] have `isAssignable` or `type`? | 135 // TODO(johnniwinther): Should [Local] have `isAssignable` or `type`? |
| 93 abstract class Local extends Entity { | 136 abstract class Local extends Entity { |
| 94 /// The context in which this local is defined. | 137 /// The context in which this local is defined. |
| 95 Entity get executableContext; | 138 Entity get executableContext; |
| 96 | 139 |
| 97 /// The outermost member that contains this element. | 140 /// The outermost member that contains this element. |
| 98 /// | 141 /// |
| 99 /// For top level, static or instance members, the member context is the | 142 /// For top level, static or instance members, the member context is the |
| 100 /// element itself. For parameters, local variables and nested closures, the | 143 /// element itself. For parameters, local variables and nested closures, the |
| 101 /// member context is the top level, static or instance member in which it is | 144 /// member context is the top level, static or instance member in which it is |
| 102 /// defined. | 145 /// defined. |
| 103 MemberEntity get memberContext; | 146 MemberEntity get memberContext; |
| 104 } | 147 } |
| OLD | NEW |