| 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'; |
| 11 import '../constants/expressions.dart'; | 11 import '../constants/expressions.dart'; |
| 12 import '../core_types.dart' show CoreClasses; | 12 import '../core_types.dart' show CoreClasses; |
| 13 import '../dart_types.dart'; | 13 import '../dart_types.dart'; |
| 14 import '../ordered_typeset.dart' show OrderedTypeSet; | 14 import '../ordered_typeset.dart' show OrderedTypeSet; |
| 15 import '../resolution/scope.dart' show Scope; | 15 import '../resolution/scope.dart' show Scope; |
| 16 import '../resolution/tree_elements.dart' show TreeElements; | 16 import '../resolution/tree_elements.dart' show TreeElements; |
| 17 import '../script.dart'; | 17 import '../script.dart'; |
| 18 import '../tokens/token.dart' | 18 import '../tokens/token.dart' |
| 19 show Token, isUserDefinableOperator, isMinusOperator; | 19 show Token, isUserDefinableOperator, isMinusOperator; |
| 20 import '../tree/tree.dart'; | 20 import '../tree/tree.dart'; |
| 21 import '../util/characters.dart' show $_; | 21 import '../util/characters.dart' show $_; |
| 22 import '../util/util.dart'; | 22 import '../util/util.dart'; |
| 23 import 'entities.dart'; |
| 23 import 'visitor.dart' show ElementVisitor; | 24 import 'visitor.dart' show ElementVisitor; |
| 24 | 25 |
| 25 part 'names.dart'; | 26 part 'names.dart'; |
| 26 | 27 |
| 27 const int STATE_NOT_STARTED = 0; | 28 const int STATE_NOT_STARTED = 0; |
| 28 const int STATE_STARTED = 1; | 29 const int STATE_STARTED = 1; |
| 29 const int STATE_DONE = 2; | 30 const int STATE_DONE = 2; |
| 30 | 31 |
| 31 class ElementCategory { | 32 class ElementCategory { |
| 32 /** | 33 /** |
| (...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 /// element itself. For parameters, local variables and nested closures, the | 1041 /// 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 | 1042 /// member context is the top level, static or instance member in which it is |
| 1042 /// defined. | 1043 /// defined. |
| 1043 MemberElement get memberContext; | 1044 MemberElement get memberContext; |
| 1044 } | 1045 } |
| 1045 | 1046 |
| 1046 /// A top-level, static or instance field or method, or a constructor. | 1047 /// A top-level, static or instance field or method, or a constructor. |
| 1047 /// | 1048 /// |
| 1048 /// A [MemberElement] is the outermost executable element for any executable | 1049 /// A [MemberElement] is the outermost executable element for any executable |
| 1049 /// context. | 1050 /// context. |
| 1050 abstract class MemberElement extends Element implements ExecutableElement { | 1051 abstract class MemberElement extends Element |
| 1052 implements ExecutableElement, MemberEntity { |
| 1051 /// The local functions defined within this member. | 1053 /// The local functions defined within this member. |
| 1052 List<FunctionElement> get nestedClosures; | 1054 List<FunctionElement> get nestedClosures; |
| 1053 | 1055 |
| 1054 /// The name of this member, taking privacy into account. | 1056 /// The name of this member, taking privacy into account. |
| 1055 Name get memberName; | 1057 Name get memberName; |
| 1056 } | 1058 } |
| 1057 | 1059 |
| 1058 /// A function, variable or parameter defined in an executable context. | 1060 /// A function, variable or parameter defined in an executable context. |
| 1059 abstract class LocalElement extends Element | 1061 abstract class LocalElement extends Element |
| 1060 implements AstElement, TypedElement, Local {} | 1062 implements AstElement, TypedElement, Local {} |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1080 /// | 1082 /// |
| 1081 /// Parameters, local variables and local functions (can) define local entity | 1083 /// Parameters, local variables and local functions (can) define local entity |
| 1082 /// and thus implement [Local] through [LocalElement]. For non-element locals, | 1084 /// and thus implement [Local] through [LocalElement]. For non-element locals, |
| 1083 /// like `this` and boxes, specialized [Local] classes are created. | 1085 /// like `this` and boxes, specialized [Local] classes are created. |
| 1084 /// | 1086 /// |
| 1085 /// Type variables can introduce locals in factories and constructors | 1087 /// Type variables can introduce locals in factories and constructors |
| 1086 /// but since one type variable can introduce different locals in different | 1088 /// but since one type variable can introduce different locals in different |
| 1087 /// factories and constructors it is not itself a [Local] but instead | 1089 /// factories and constructors it is not itself a [Local] but instead |
| 1088 /// a non-element [Local] is created through a specialized class. | 1090 /// a non-element [Local] is created through a specialized class. |
| 1089 // TODO(johnniwinther): Should [Local] have `isAssignable` or `type`? | 1091 // TODO(johnniwinther): Should [Local] have `isAssignable` or `type`? |
| 1092 // TODO(johnniwinther): Move this to 'entities.dart' when it does not refer |
| 1093 // to [ExecutableElement]. |
| 1090 abstract class Local extends Entity { | 1094 abstract class Local extends Entity { |
| 1091 /// The context in which this local is defined. | 1095 /// The context in which this local is defined. |
| 1092 ExecutableElement get executableContext; | 1096 ExecutableElement get executableContext; |
| 1093 } | 1097 } |
| 1094 | 1098 |
| 1095 /// A variable or parameter that is local to an executable context. | 1099 /// A variable or parameter that is local to an executable context. |
| 1096 /// | 1100 /// |
| 1097 /// The executable context is the [ExecutableElement] in which this variable | 1101 /// The executable context is the [ExecutableElement] in which this variable |
| 1098 /// is defined. | 1102 /// is defined. |
| 1099 abstract class LocalVariableElement extends VariableElement | 1103 abstract class LocalVariableElement extends VariableElement |
| 1100 implements LocalElement {} | 1104 implements LocalElement {} |
| 1101 | 1105 |
| 1102 /// A top-level, static or instance field. | 1106 /// A top-level, static or instance field. |
| 1103 abstract class FieldElement extends VariableElement implements MemberElement {} | 1107 abstract class FieldElement extends VariableElement |
| 1108 implements MemberElement, FieldEntity {} |
| 1104 | 1109 |
| 1105 /// A parameter-like element of a function signature. | 1110 /// A parameter-like element of a function signature. |
| 1106 /// | 1111 /// |
| 1107 /// If the function signature comes from a typedef or an inline function-typed | 1112 /// 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 | 1113 /// 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 | 1114 /// 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]. | 1115 /// hold no value. Such parameter-like elements are modeled by [FormalElement]. |
| 1111 /// | 1116 /// |
| 1112 /// If the function signature comes from a function or constructor, its | 1117 /// If the function signature comes from a function or constructor, its |
| 1113 /// parameters are real parameters and are modeled by [ParameterElement]. | 1118 /// 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 | 1289 ASYNC_STAR |
| 1285 ]; | 1290 ]; |
| 1286 | 1291 |
| 1287 /// Index to this marker within [values]. | 1292 /// Index to this marker within [values]. |
| 1288 /// | 1293 /// |
| 1289 /// Added to make [AsyncMarker] enum-like. | 1294 /// Added to make [AsyncMarker] enum-like. |
| 1290 int get index => values.indexOf(this); | 1295 int get index => values.indexOf(this); |
| 1291 } | 1296 } |
| 1292 | 1297 |
| 1293 /// A top level, static or instance function. | 1298 /// A top level, static or instance function. |
| 1294 abstract class MethodElement extends FunctionElement implements MemberElement {} | 1299 abstract class MethodElement extends FunctionElement |
| 1300 implements MemberElement, FunctionEntity {} |
| 1295 | 1301 |
| 1296 /// A local function or closure (anonymous local function). | 1302 /// A local function or closure (anonymous local function). |
| 1297 abstract class LocalFunctionElement extends FunctionElement | 1303 abstract class LocalFunctionElement extends FunctionElement |
| 1298 implements LocalElement {} | 1304 implements LocalElement {} |
| 1299 | 1305 |
| 1300 /// A constructor. | 1306 /// A constructor. |
| 1301 abstract class ConstructorElement extends FunctionElement | 1307 abstract class ConstructorElement extends MethodElement { |
| 1302 implements MemberElement { | |
| 1303 /// Returns `true` if [effectiveTarget] has been computed for this | 1308 /// Returns `true` if [effectiveTarget] has been computed for this |
| 1304 /// constructor. | 1309 /// constructor. |
| 1305 bool get hasEffectiveTarget; | 1310 bool get hasEffectiveTarget; |
| 1306 | 1311 |
| 1307 /// The effective target of this constructor, that is the non-redirecting | 1312 /// The effective target of this constructor, that is the non-redirecting |
| 1308 /// constructor that is called on invocation of this constructor. | 1313 /// constructor that is called on invocation of this constructor. |
| 1309 /// | 1314 /// |
| 1310 /// Consider for instance this hierarchy: | 1315 /// Consider for instance this hierarchy: |
| 1311 /// | 1316 /// |
| 1312 /// class C { factory C.c() = D.d; } | 1317 /// 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. | 1468 * the input source has used explicit type arguments. |
| 1464 */ | 1469 */ |
| 1465 GenericType get rawType; | 1470 GenericType get rawType; |
| 1466 | 1471 |
| 1467 bool get isResolved; | 1472 bool get isResolved; |
| 1468 | 1473 |
| 1469 void ensureResolved(Resolution resolution); | 1474 void ensureResolved(Resolution resolution); |
| 1470 } | 1475 } |
| 1471 | 1476 |
| 1472 abstract class ClassElement extends TypeDeclarationElement | 1477 abstract class ClassElement extends TypeDeclarationElement |
| 1473 implements ScopeContainerElement { | 1478 implements ScopeContainerElement, ClassEntity { |
| 1474 /// The length of the longest inheritance path from [:Object:]. | 1479 /// The length of the longest inheritance path from [:Object:]. |
| 1475 int get hierarchyDepth; | 1480 int get hierarchyDepth; |
| 1476 | 1481 |
| 1477 InterfaceType get rawType; | 1482 InterfaceType get rawType; |
| 1478 InterfaceType get thisType; | 1483 InterfaceType get thisType; |
| 1479 ClassElement get superclass; | 1484 ClassElement get superclass; |
| 1480 | 1485 |
| 1481 /// The direct supertype of this class. | 1486 /// The direct supertype of this class. |
| 1482 DartType get supertype; | 1487 DartType get supertype; |
| 1483 | 1488 |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1918 /// by a field. | 1923 /// by a field. |
| 1919 bool get isDeclaredByField; | 1924 bool get isDeclaredByField; |
| 1920 | 1925 |
| 1921 /// Returns `true` if this member is abstract. | 1926 /// Returns `true` if this member is abstract. |
| 1922 bool get isAbstract; | 1927 bool get isAbstract; |
| 1923 | 1928 |
| 1924 /// If abstract, [implementation] points to the overridden concrete member, | 1929 /// If abstract, [implementation] points to the overridden concrete member, |
| 1925 /// if any. Otherwise [implementation] points to the member itself. | 1930 /// if any. Otherwise [implementation] points to the member itself. |
| 1926 Member get implementation; | 1931 Member get implementation; |
| 1927 } | 1932 } |
| OLD | NEW |