Chromium Code Reviews| 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 '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/resolution.dart' show Resolution; | 8 import '../common/resolution.dart' show Resolution; |
| 9 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
| 10 import '../constants/constructors.dart'; | 10 import '../constants/constructors.dart'; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 /// Entities defined within the Dart language should implement [Element]. | 121 /// Entities defined within the Dart language should implement [Element]. |
| 122 /// | 122 /// |
| 123 /// For instance, the JavaScript backend need to create synthetic variables for | 123 /// For instance, the JavaScript backend need to create synthetic variables for |
| 124 /// calling intercepted classes and such variables do not correspond to an | 124 /// calling intercepted classes and such variables do not correspond to an |
| 125 /// entity in the Dart source code nor in the terminology of the Dart language | 125 /// entity in the Dart source code nor in the terminology of the Dart language |
| 126 /// and should therefore implement [Entity] directly. | 126 /// and should therefore implement [Entity] directly. |
| 127 abstract class Entity implements Spannable { | 127 abstract class Entity implements Spannable { |
| 128 String get name; | 128 String get name; |
| 129 } | 129 } |
| 130 | 130 |
| 131 /// Stripped down super interface for class like entities. | |
| 132 /// | |
| 133 /// Currently only [ClassElement] but later also kernel based Dart classes | |
| 134 /// and/or Dart-in-JS classes. | |
| 135 abstract class ClassLike extends Entity { | |
|
Siggi Cherem (dart-lang)
2016/11/03 00:52:30
maybe it is too early to tell, but how much from C
Johnni Winther
2016/11/03 09:55:06
Not much: I plan to move most queries on relations
| |
| 136 bool get isClosure; | |
| 137 void forEachInstanceField(f(ClassLike cls, FieldLike field), | |
| 138 {bool includeSuperAndInjectedMembers: false}); | |
| 139 } | |
| 140 | |
| 141 /// Stripped down super interface for member like entities, that is, | |
| 142 /// constructors, methods, fields etc. | |
| 143 /// | |
| 144 /// Currently only [MemberElement] but later also kernel based Dart members | |
| 145 /// and/or Dart-in-JS properties. | |
| 146 abstract class MemberLike extends Entity { | |
| 147 bool get isField; | |
| 148 bool get isFunction; | |
| 149 bool get isGetter; | |
| 150 bool get isAssignable; | |
| 151 ClassLike get enclosingClass; | |
| 152 } | |
| 153 | |
| 154 /// Stripped down super interface for field like entities. | |
| 155 /// | |
| 156 /// Currently only [FieldElement] but later also kernel based Dart fields | |
| 157 /// and/or Dart-in-JS field-like properties. | |
| 158 abstract class FieldLike extends MemberLike {} | |
| 159 | |
| 160 /// Stripped down super interface for function like entities. | |
| 161 /// | |
| 162 /// Currently only [FieldElement] but later also kernel based Dart constructors | |
| 163 /// and methods and/or Dart-in-JS function-like properties. | |
| 164 abstract class FunctionLike extends MemberLike {} | |
|
Siggi Cherem (dart-lang)
2016/11/03 00:52:30
I'm not yet convinced on using the "XLike" names :
Johnni Winther
2016/11/03 09:55:06
Moved to 'entities.dart', use 'Entity' as suffix.
| |
| 165 | |
| 131 /** | 166 /** |
| 132 * A declared element of a program. | 167 * A declared element of a program. |
| 133 * | 168 * |
| 134 * The declared elements of a program include classes, methods, | 169 * The declared elements of a program include classes, methods, |
| 135 * fields, variables, parameters, etc. | 170 * fields, variables, parameters, etc. |
| 136 * | 171 * |
| 137 * Sometimes it makes sense to construct "synthetic" elements that | 172 * Sometimes it makes sense to construct "synthetic" elements that |
| 138 * have not been declared anywhere in a program, for example, there | 173 * have not been declared anywhere in a program, for example, there |
| 139 * are elements corresponding to "dynamic", "null", and unresolved | 174 * are elements corresponding to "dynamic", "null", and unresolved |
| 140 * references. | 175 * references. |
| (...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1040 /// element itself. For parameters, local variables and nested closures, the | 1075 /// element itself. For parameters, local variables and nested closures, the |
| 1041 /// member context is the top level, static or instance member in which it is | 1076 /// member context is the top level, static or instance member in which it is |
| 1042 /// defined. | 1077 /// defined. |
| 1043 MemberElement get memberContext; | 1078 MemberElement get memberContext; |
| 1044 } | 1079 } |
| 1045 | 1080 |
| 1046 /// A top-level, static or instance field or method, or a constructor. | 1081 /// A top-level, static or instance field or method, or a constructor. |
| 1047 /// | 1082 /// |
| 1048 /// A [MemberElement] is the outermost executable element for any executable | 1083 /// A [MemberElement] is the outermost executable element for any executable |
| 1049 /// context. | 1084 /// context. |
| 1050 abstract class MemberElement extends Element implements ExecutableElement { | 1085 abstract class MemberElement extends Element |
| 1086 implements ExecutableElement, MemberLike { | |
| 1051 /// The local functions defined within this member. | 1087 /// The local functions defined within this member. |
| 1052 List<FunctionElement> get nestedClosures; | 1088 List<FunctionElement> get nestedClosures; |
| 1053 | 1089 |
| 1054 /// The name of this member, taking privacy into account. | 1090 /// The name of this member, taking privacy into account. |
| 1055 Name get memberName; | 1091 Name get memberName; |
| 1056 } | 1092 } |
| 1057 | 1093 |
| 1058 /// A function, variable or parameter defined in an executable context. | 1094 /// A function, variable or parameter defined in an executable context. |
| 1059 abstract class LocalElement extends Element | 1095 abstract class LocalElement extends Element |
| 1060 implements AstElement, TypedElement, Local {} | 1096 implements AstElement, TypedElement, Local {} |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1093 } | 1129 } |
| 1094 | 1130 |
| 1095 /// A variable or parameter that is local to an executable context. | 1131 /// A variable or parameter that is local to an executable context. |
| 1096 /// | 1132 /// |
| 1097 /// The executable context is the [ExecutableElement] in which this variable | 1133 /// The executable context is the [ExecutableElement] in which this variable |
| 1098 /// is defined. | 1134 /// is defined. |
| 1099 abstract class LocalVariableElement extends VariableElement | 1135 abstract class LocalVariableElement extends VariableElement |
| 1100 implements LocalElement {} | 1136 implements LocalElement {} |
| 1101 | 1137 |
| 1102 /// A top-level, static or instance field. | 1138 /// A top-level, static or instance field. |
| 1103 abstract class FieldElement extends VariableElement implements MemberElement {} | 1139 abstract class FieldElement extends VariableElement |
| 1140 implements MemberElement, FieldLike {} | |
| 1104 | 1141 |
| 1105 /// A parameter-like element of a function signature. | 1142 /// A parameter-like element of a function signature. |
| 1106 /// | 1143 /// |
| 1107 /// If the function signature comes from a typedef or an inline function-typed | 1144 /// If the function signature comes from a typedef or an inline function-typed |
| 1108 /// parameter (e.g. the parameter 'f' in `method(void f())`), then its | 1145 /// parameter (e.g. the parameter 'f' in `method(void f())`), then its |
| 1109 /// parameters are not real parameters in that they can take no argument and | 1146 /// parameters are not real parameters in that they can take no argument and |
| 1110 /// hold no value. Such parameter-like elements are modeled by [FormalElement]. | 1147 /// hold no value. Such parameter-like elements are modeled by [FormalElement]. |
| 1111 /// | 1148 /// |
| 1112 /// If the function signature comes from a function or constructor, its | 1149 /// If the function signature comes from a function or constructor, its |
| 1113 /// parameters are real parameters and are modeled by [ParameterElement]. | 1150 /// parameters are real parameters and are modeled by [ParameterElement]. |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1284 ASYNC_STAR | 1321 ASYNC_STAR |
| 1285 ]; | 1322 ]; |
| 1286 | 1323 |
| 1287 /// Index to this marker within [values]. | 1324 /// Index to this marker within [values]. |
| 1288 /// | 1325 /// |
| 1289 /// Added to make [AsyncMarker] enum-like. | 1326 /// Added to make [AsyncMarker] enum-like. |
| 1290 int get index => values.indexOf(this); | 1327 int get index => values.indexOf(this); |
| 1291 } | 1328 } |
| 1292 | 1329 |
| 1293 /// A top level, static or instance function. | 1330 /// A top level, static or instance function. |
| 1294 abstract class MethodElement extends FunctionElement implements MemberElement {} | 1331 abstract class MethodElement extends FunctionElement |
| 1332 implements MemberElement, FunctionLike {} | |
| 1295 | 1333 |
| 1296 /// A local function or closure (anonymous local function). | 1334 /// A local function or closure (anonymous local function). |
| 1297 abstract class LocalFunctionElement extends FunctionElement | 1335 abstract class LocalFunctionElement extends FunctionElement |
| 1298 implements LocalElement {} | 1336 implements LocalElement {} |
| 1299 | 1337 |
| 1300 /// A constructor. | 1338 /// A constructor. |
| 1301 abstract class ConstructorElement extends FunctionElement | 1339 abstract class ConstructorElement extends MethodElement { |
| 1302 implements MemberElement { | |
| 1303 /// Returns `true` if [effectiveTarget] has been computed for this | 1340 /// Returns `true` if [effectiveTarget] has been computed for this |
| 1304 /// constructor. | 1341 /// constructor. |
| 1305 bool get hasEffectiveTarget; | 1342 bool get hasEffectiveTarget; |
| 1306 | 1343 |
| 1307 /// The effective target of this constructor, that is the non-redirecting | 1344 /// The effective target of this constructor, that is the non-redirecting |
| 1308 /// constructor that is called on invocation of this constructor. | 1345 /// constructor that is called on invocation of this constructor. |
| 1309 /// | 1346 /// |
| 1310 /// Consider for instance this hierarchy: | 1347 /// Consider for instance this hierarchy: |
| 1311 /// | 1348 /// |
| 1312 /// class C { factory C.c() = D.d; } | 1349 /// class C { factory C.c() = D.d; } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1463 * the input source has used explicit type arguments. | 1500 * the input source has used explicit type arguments. |
| 1464 */ | 1501 */ |
| 1465 GenericType get rawType; | 1502 GenericType get rawType; |
| 1466 | 1503 |
| 1467 bool get isResolved; | 1504 bool get isResolved; |
| 1468 | 1505 |
| 1469 void ensureResolved(Resolution resolution); | 1506 void ensureResolved(Resolution resolution); |
| 1470 } | 1507 } |
| 1471 | 1508 |
| 1472 abstract class ClassElement extends TypeDeclarationElement | 1509 abstract class ClassElement extends TypeDeclarationElement |
| 1473 implements ScopeContainerElement { | 1510 implements ScopeContainerElement, ClassLike { |
| 1474 /// The length of the longest inheritance path from [:Object:]. | 1511 /// The length of the longest inheritance path from [:Object:]. |
| 1475 int get hierarchyDepth; | 1512 int get hierarchyDepth; |
| 1476 | 1513 |
| 1477 InterfaceType get rawType; | 1514 InterfaceType get rawType; |
| 1478 InterfaceType get thisType; | 1515 InterfaceType get thisType; |
| 1479 ClassElement get superclass; | 1516 ClassElement get superclass; |
| 1480 | 1517 |
| 1481 /// The direct supertype of this class. | 1518 /// The direct supertype of this class. |
| 1482 DartType get supertype; | 1519 DartType get supertype; |
| 1483 | 1520 |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1918 /// by a field. | 1955 /// by a field. |
| 1919 bool get isDeclaredByField; | 1956 bool get isDeclaredByField; |
| 1920 | 1957 |
| 1921 /// Returns `true` if this member is abstract. | 1958 /// Returns `true` if this member is abstract. |
| 1922 bool get isAbstract; | 1959 bool get isAbstract; |
| 1923 | 1960 |
| 1924 /// If abstract, [implementation] points to the overridden concrete member, | 1961 /// If abstract, [implementation] points to the overridden concrete member, |
| 1925 /// if any. Otherwise [implementation] points to the member itself. | 1962 /// if any. Otherwise [implementation] points to the member itself. |
| 1926 Member get implementation; | 1963 Member get implementation; |
| 1927 } | 1964 } |
| OLD | NEW |