Chromium Code Reviews| 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 /// `true` if a synthesized class for a closurized method or local function. | |
|
Siggi Cherem (dart-lang)
2017/03/14 04:54:59
nit: if a => if this is a ?
Johnni Winther
2017/03/15 12:07:09
Done.
| |
| 33 bool get isClosure; | 39 bool get isClosure; |
| 34 } | 40 } |
| 35 | 41 |
| 36 abstract class TypeVariableEntity extends Entity { | 42 abstract class TypeVariableEntity extends Entity { |
| 43 /// The class or generic method that declared this type variable. | |
| 37 Entity get typeDeclaration; | 44 Entity get typeDeclaration; |
| 45 | |
| 46 /// The index of this type variable in the type variables of its | |
| 47 /// [typeDeclaration]. | |
| 38 int get index; | 48 int get index; |
| 39 } | 49 } |
| 40 | 50 |
| 41 /// Stripped down super interface for member like entities, that is, | 51 /// Stripped down super interface for member like entities, that is, |
| 42 /// constructors, methods, fields etc. | 52 /// constructors, methods, fields etc. |
| 43 /// | 53 /// |
| 44 /// Currently only [MemberElement] but later also kernel based Dart members | 54 /// Currently only [MemberElement] but later also kernel based Dart members |
| 45 /// and/or Dart-in-JS properties. | 55 /// and/or Dart-in-JS properties. |
| 46 abstract class MemberEntity extends Entity { | 56 abstract class MemberEntity extends Entity { |
| 57 /// `true` if this is a member of a library. | |
|
Siggi Cherem (dart-lang)
2017/03/14 04:54:59
(optional) I tend to use the form "Whether ..." in
Johnni Winther
2017/03/15 12:07:09
Done.
| |
| 47 bool get isTopLevel; | 58 bool get isTopLevel; |
| 59 | |
| 60 /// `true` if this is a static member of a class. | |
| 48 bool get isStatic; | 61 bool get isStatic; |
| 62 | |
| 63 /// `true` if this is an instance member of a class. | |
| 49 bool get isInstanceMember; | 64 bool get isInstanceMember; |
| 65 | |
| 66 /// `true` if this is a constructor. | |
| 50 bool get isConstructor; | 67 bool get isConstructor; |
| 68 | |
| 69 /// `true` if this is a field. | |
| 51 bool get isField; | 70 bool get isField; |
| 71 | |
| 72 /// `true` if this is a normal method (neither constructor, getter or setter) | |
| 73 /// or operator method. | |
| 52 bool get isFunction; | 74 bool get isFunction; |
| 75 | |
| 76 /// `true` if this is a getter. | |
| 53 bool get isGetter; | 77 bool get isGetter; |
| 78 | |
| 79 /// `true` if this is a setter. | |
| 54 bool get isSetter; | 80 bool get isSetter; |
| 81 | |
| 82 /// `true` if this member is assignable, i.e. a non-final field. | |
| 55 bool get isAssignable; | 83 bool get isAssignable; |
| 84 | |
| 85 /// The enclosing class if this is a constuctor, instance member or | |
| 86 /// static member of a class. | |
| 56 ClassEntity get enclosingClass; | 87 ClassEntity get enclosingClass; |
| 88 | |
| 89 /// The enclosing library if this is a library member, other wise the | |
|
Siggi Cherem (dart-lang)
2017/03/14 04:54:59
other wise => otherwise
Johnni Winther
2017/03/15 12:07:09
Done.
| |
| 90 /// enclosing library of the [enclosingClass]. | |
| 91 LibraryEntity get library; | |
| 57 } | 92 } |
| 58 | 93 |
| 59 /// Stripped down super interface for field like entities. | 94 /// Stripped down super interface for field like entities. |
| 60 /// | 95 /// |
| 61 /// Currently only [FieldElement] but later also kernel based Dart fields | 96 /// Currently only [FieldElement] but later also kernel based Dart fields |
| 62 /// and/or Dart-in-JS field-like properties. | 97 /// and/or Dart-in-JS field-like properties. |
| 63 abstract class FieldEntity extends MemberEntity {} | 98 abstract class FieldEntity extends MemberEntity {} |
| 64 | 99 |
| 65 /// Stripped down super interface for function like entities. | 100 /// Stripped down super interface for function like entities. |
| 66 /// | 101 /// |
| 67 /// Currently only [MethodElement] but later also kernel based Dart constructors | 102 /// Currently only [MethodElement] but later also kernel based Dart constructors |
| 68 /// and methods and/or Dart-in-JS function-like properties. | 103 /// and methods and/or Dart-in-JS function-like properties. |
| 69 abstract class FunctionEntity extends MemberEntity {} | 104 abstract class FunctionEntity extends MemberEntity { |
| 105 /// `true` if this function is external, i.e. the body is not defined in terms | |
| 106 /// of Dart code. | |
|
Siggi Cherem (dart-lang)
2017/03/14 04:54:59
... and it is marked with the 'external' modifier
Johnni Winther
2017/03/15 12:07:09
That should be only one way to define it. A JEleme
| |
| 107 bool get isExternal; | |
| 108 } | |
| 70 | 109 |
| 71 /// Stripped down super interface for constructor like entities. | 110 /// Stripped down super interface for constructor like entities. |
| 72 /// | 111 /// |
| 73 /// Currently only [ConstructorElement] but later also kernel based Dart | 112 /// Currently only [ConstructorElement] but later also kernel based Dart |
| 74 /// constructors and/or Dart-in-JS constructor-like properties. | 113 /// constructors and/or Dart-in-JS constructor-like properties. |
| 75 // TODO(johnniwinther): Remove factory constructors from the set of | 114 // TODO(johnniwinther): Remove factory constructors from the set of |
| 76 // constructors. | 115 // constructors. |
| 77 abstract class ConstructorEntity extends FunctionEntity { | 116 abstract class ConstructorEntity extends FunctionEntity { |
| 117 /// `true` if this is a generative constructor, possibly redirecting. | |
| 78 bool get isGenerativeConstructor; | 118 bool get isGenerativeConstructor; |
| 119 | |
| 120 /// `true` if this is a factory constructor, possibly redirecting. | |
| 79 bool get isFactoryConstructor; | 121 bool get isFactoryConstructor; |
| 80 } | 122 } |
| 81 | 123 |
| 82 /// An entity that defines a local entity (memory slot) in generated code. | 124 /// An entity that defines a local entity (memory slot) in generated code. |
| 83 /// | 125 /// |
| 84 /// Parameters, local variables and local functions (can) define local entity | 126 /// Parameters, local variables and local functions (can) define local entity |
| 85 /// and thus implement [Local] through [LocalElement]. For non-element locals, | 127 /// and thus implement [Local] through [LocalElement]. For non-element locals, |
| 86 /// like `this` and boxes, specialized [Local] classes are created. | 128 /// like `this` and boxes, specialized [Local] classes are created. |
| 87 /// | 129 /// |
| 88 /// Type variables can introduce locals in factories and constructors | 130 /// Type variables can introduce locals in factories and constructors |
| 89 /// but since one type variable can introduce different locals in different | 131 /// but since one type variable can introduce different locals in different |
| 90 /// factories and constructors it is not itself a [Local] but instead | 132 /// factories and constructors it is not itself a [Local] but instead |
| 91 /// a non-element [Local] is created through a specialized class. | 133 /// a non-element [Local] is created through a specialized class. |
| 92 // TODO(johnniwinther): Should [Local] have `isAssignable` or `type`? | 134 // TODO(johnniwinther): Should [Local] have `isAssignable` or `type`? |
| 93 abstract class Local extends Entity { | 135 abstract class Local extends Entity { |
| 94 /// The context in which this local is defined. | 136 /// The context in which this local is defined. |
| 95 Entity get executableContext; | 137 Entity get executableContext; |
| 96 | 138 |
| 97 /// The outermost member that contains this element. | 139 /// The outermost member that contains this element. |
| 98 /// | 140 /// |
| 99 /// For top level, static or instance members, the member context is the | 141 /// For top level, static or instance members, the member context is the |
| 100 /// element itself. For parameters, local variables and nested closures, the | 142 /// 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 | 143 /// member context is the top level, static or instance member in which it is |
| 102 /// defined. | 144 /// defined. |
| 103 MemberEntity get memberContext; | 145 MemberEntity get memberContext; |
| 104 } | 146 } |
| OLD | NEW |