| 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 | 7 |
| 8 import '../tree/tree.dart'; | 8 import '../tree/tree.dart'; |
| 9 import '../util/util.dart'; | 9 import '../util/util.dart'; |
| 10 import '../resolution/resolution.dart'; | 10 import '../resolution/resolution.dart'; |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 bool isForeign(Compiler compiler); | 379 bool isForeign(Compiler compiler); |
| 380 | 380 |
| 381 void addMetadata(MetadataAnnotation annotation); | 381 void addMetadata(MetadataAnnotation annotation); |
| 382 void setNative(String name); | 382 void setNative(String name); |
| 383 void setFixedBackendName(String name); | 383 void setFixedBackendName(String name); |
| 384 | 384 |
| 385 Scope buildScope(); | 385 Scope buildScope(); |
| 386 | 386 |
| 387 void diagnose(Element context, DiagnosticListener listener); | 387 void diagnose(Element context, DiagnosticListener listener); |
| 388 | 388 |
| 389 TreeElements get treeElements; | 389 // TODO(johnniwinther): Move this to [AstElement]. |
| 390 /// Returns the [Element] that holds the [TreeElements] for this element. |
| 391 AnalyzableElement get analyzableElement; |
| 390 | 392 |
| 391 accept(ElementVisitor visitor); | 393 accept(ElementVisitor visitor); |
| 392 } | 394 } |
| 393 | 395 |
| 394 class Elements { | 396 class Elements { |
| 395 static bool isUnresolved(Element e) { | 397 static bool isUnresolved(Element e) { |
| 396 return e == null || e.isErroneous; | 398 return e == null || e.isErroneous; |
| 397 } | 399 } |
| 398 static bool isErroneousElement(Element e) => e != null && e.isErroneous; | 400 static bool isErroneousElement(Element e) => e != null && e.isErroneous; |
| 399 | 401 |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 PartOf get partTag; | 777 PartOf get partTag; |
| 776 | 778 |
| 777 void forEachLocalMember(f(Element element)); | 779 void forEachLocalMember(f(Element element)); |
| 778 void addMember(Element element, DiagnosticListener listener); | 780 void addMember(Element element, DiagnosticListener listener); |
| 779 void setPartOf(PartOf tag, DiagnosticListener listener); | 781 void setPartOf(PartOf tag, DiagnosticListener listener); |
| 780 bool get hasMembers; | 782 bool get hasMembers; |
| 781 | 783 |
| 782 int compareTo(CompilationUnitElement other); | 784 int compareTo(CompilationUnitElement other); |
| 783 } | 785 } |
| 784 | 786 |
| 785 abstract class LibraryElement extends Element implements ScopeContainerElement { | 787 abstract class LibraryElement extends Element |
| 788 implements ScopeContainerElement, AnalyzableElement { |
| 786 /** | 789 /** |
| 787 * The canonical uri for this library. | 790 * The canonical uri for this library. |
| 788 * | 791 * |
| 789 * For user libraries the canonical uri is the script uri. For platform | 792 * For user libraries the canonical uri is the script uri. For platform |
| 790 * libraries the canonical uri is of the form [:dart:x:]. | 793 * libraries the canonical uri is of the form [:dart:x:]. |
| 791 */ | 794 */ |
| 792 Uri get canonicalUri; | 795 Uri get canonicalUri; |
| 793 CompilationUnitElement get entryCompilationUnit; | 796 CompilationUnitElement get entryCompilationUnit; |
| 794 Link<CompilationUnitElement> get compilationUnits; | 797 Link<CompilationUnitElement> get compilationUnits; |
| 795 Link<LibraryTag> get tags; | 798 Link<LibraryTag> get tags; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 GenericType get rawType; | 1039 GenericType get rawType; |
| 1037 | 1040 |
| 1038 /** | 1041 /** |
| 1039 * The type variables declared on this declaration. The type variables are not | 1042 * The type variables declared on this declaration. The type variables are not |
| 1040 * available until the type of the element has been computed through | 1043 * available until the type of the element has been computed through |
| 1041 * [computeType]. | 1044 * [computeType]. |
| 1042 */ | 1045 */ |
| 1043 Link<DartType> get typeVariables; | 1046 Link<DartType> get typeVariables; |
| 1044 | 1047 |
| 1045 bool get isResolved; | 1048 bool get isResolved; |
| 1049 |
| 1050 int get resolutionState; |
| 1051 |
| 1052 void ensureResolved(Compiler compiler); |
| 1046 } | 1053 } |
| 1047 | 1054 |
| 1048 abstract class ClassElement extends TypeDeclarationElement | 1055 abstract class ClassElement extends TypeDeclarationElement |
| 1049 implements ScopeContainerElement { | 1056 implements ScopeContainerElement { |
| 1050 int get id; | 1057 int get id; |
| 1051 | 1058 |
| 1052 /// The length of the longest inheritance path from [:Object:]. | 1059 /// The length of the longest inheritance path from [:Object:]. |
| 1053 int get hierarchyDepth; | 1060 int get hierarchyDepth; |
| 1054 | 1061 |
| 1055 InterfaceType get rawType; | 1062 InterfaceType get rawType; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1073 | 1080 |
| 1074 bool get hasConstructor; | 1081 bool get hasConstructor; |
| 1075 Link<Element> get constructors; | 1082 Link<Element> get constructors; |
| 1076 | 1083 |
| 1077 ClassElement get patch; | 1084 ClassElement get patch; |
| 1078 ClassElement get origin; | 1085 ClassElement get origin; |
| 1079 ClassElement get declaration; | 1086 ClassElement get declaration; |
| 1080 ClassElement get implementation; | 1087 ClassElement get implementation; |
| 1081 | 1088 |
| 1082 int get supertypeLoadState; | 1089 int get supertypeLoadState; |
| 1083 int get resolutionState; | |
| 1084 String get nativeTagInfo; | 1090 String get nativeTagInfo; |
| 1085 | 1091 |
| 1086 bool get isMixinApplication; | 1092 bool get isMixinApplication; |
| 1087 bool get isUnnamedMixinApplication; | 1093 bool get isUnnamedMixinApplication; |
| 1088 bool get hasBackendMembers; | 1094 bool get hasBackendMembers; |
| 1089 bool get hasLocalScopeMembers; | 1095 bool get hasLocalScopeMembers; |
| 1090 | 1096 |
| 1091 // TODO(kasperl): These are bit fishy. Do we really need them? | |
| 1092 void set supertype(DartType value); | |
| 1093 void set interfaces(Link<DartType> value); | |
| 1094 void set supertypeLoadState(int value); | |
| 1095 void set resolutionState(int value); | |
| 1096 void set nativeTagInfo(String value); | |
| 1097 | |
| 1098 bool isObject(Compiler compiler); | 1097 bool isObject(Compiler compiler); |
| 1099 bool isSubclassOf(ClassElement cls); | 1098 bool isSubclassOf(ClassElement cls); |
| 1100 /// Returns true if `this` explicitly/nominally implements [intrface]. | 1099 /// Returns true if `this` explicitly/nominally implements [intrface]. |
| 1101 /// | 1100 /// |
| 1102 /// Note that, if [intrface] is the `Function` class, this method returns | 1101 /// Note that, if [intrface] is the `Function` class, this method returns |
| 1103 /// falso for a class that has a `call` method but does not explicitly | 1102 /// falso for a class that has a `call` method but does not explicitly |
| 1104 /// implement `Function`. | 1103 /// implement `Function`. |
| 1105 bool implementsInterface(ClassElement intrface); | 1104 bool implementsInterface(ClassElement intrface); |
| 1106 bool hasFieldShadowedBy(Element fieldMember); | 1105 bool hasFieldShadowedBy(Element fieldMember); |
| 1107 | 1106 |
| 1108 /// Returns `true` if this class has a @proxy annotation. | 1107 /// Returns `true` if this class has a @proxy annotation. |
| 1109 bool get isProxy; | 1108 bool get isProxy; |
| 1110 | 1109 |
| 1111 /// Returns `true` if the class hierarchy for this class contains errors. | 1110 /// Returns `true` if the class hierarchy for this class contains errors. |
| 1112 bool get hasIncompleteHierarchy; | 1111 bool get hasIncompleteHierarchy; |
| 1113 | 1112 |
| 1114 void ensureResolved(Compiler compiler); | |
| 1115 | |
| 1116 void addMember(Element element, DiagnosticListener listener); | 1113 void addMember(Element element, DiagnosticListener listener); |
| 1117 void addToScope(Element element, DiagnosticListener listener); | 1114 void addToScope(Element element, DiagnosticListener listener); |
| 1118 | 1115 |
| 1119 void setDefaultConstructor(FunctionElement constructor, Compiler compiler); | 1116 void setDefaultConstructor(FunctionElement constructor, Compiler compiler); |
| 1120 | 1117 |
| 1121 void addBackendMember(Element element); | 1118 void addBackendMember(Element element); |
| 1122 void reverseBackendMembers(); | 1119 void reverseBackendMembers(); |
| 1123 | 1120 |
| 1124 Element lookupMember(String memberName); | 1121 Element lookupMember(String memberName); |
| 1125 Element lookupSelector(Selector selector, Compiler compiler); | 1122 Element lookupSelector(Selector selector, Compiler compiler); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 } | 1216 } |
| 1220 | 1217 |
| 1221 abstract class MetadataAnnotation implements Spannable { | 1218 abstract class MetadataAnnotation implements Spannable { |
| 1222 /// The front-end constant of this metadata annotation. | 1219 /// The front-end constant of this metadata annotation. |
| 1223 Constant get value; | 1220 Constant get value; |
| 1224 Element get annotatedElement; | 1221 Element get annotatedElement; |
| 1225 int get resolutionState; | 1222 int get resolutionState; |
| 1226 Token get beginToken; | 1223 Token get beginToken; |
| 1227 Token get endToken; | 1224 Token get endToken; |
| 1228 | 1225 |
| 1229 // TODO(kasperl): Try to get rid of these. | |
| 1230 void set annotatedElement(Element value); | |
| 1231 | |
| 1232 MetadataAnnotation ensureResolved(Compiler compiler); | 1226 MetadataAnnotation ensureResolved(Compiler compiler); |
| 1233 } | 1227 } |
| 1234 | 1228 |
| 1235 /// An [Element] that has a type. | 1229 /// An [Element] that has a type. |
| 1236 abstract class TypedElement extends Element { | 1230 abstract class TypedElement extends Element { |
| 1237 DartType get type; | 1231 DartType get type; |
| 1238 } | 1232 } |
| 1239 | 1233 |
| 1240 /// An [Element] that can define a function type. | 1234 /// An [Element] that can define a function type. |
| 1241 abstract class FunctionTypedElement extends Element { | 1235 abstract class FunctionTypedElement extends Element { |
| 1242 /// The function signature for the function type defined by this element, | 1236 /// The function signature for the function type defined by this element, |
| 1243 /// if any. | 1237 /// if any. |
| 1244 FunctionSignature get functionSignature; | 1238 FunctionSignature get functionSignature; |
| 1245 } | 1239 } |
| 1246 | 1240 |
| 1241 /// An [Element] that holds a [TreeElements] mapping. |
| 1242 abstract class AnalyzableElement extends Element { |
| 1243 /// Returns the [TreeElements] that hold the resolution information for the |
| 1244 /// AST nodes of this element. |
| 1245 TreeElements get treeElements; |
| 1246 } |
| 1247 |
| 1247 /// An [Element] that (potentially) has a node. | 1248 /// An [Element] that (potentially) has a node. |
| 1248 /// | 1249 /// |
| 1249 /// Synthesized elements may return `null` from [node]. | 1250 /// Synthesized elements may return `null` from [node]. |
| 1250 abstract class AstElement extends Element { | 1251 abstract class AstElement extends AnalyzableElement { |
| 1251 Node get node; | 1252 Node get node; |
| 1252 } | 1253 } |
| 1253 | 1254 |
| 1254 /// A [MemberSignature] is a member of an interface. | 1255 /// A [MemberSignature] is a member of an interface. |
| 1255 /// | 1256 /// |
| 1256 /// A signature is either a method or a getter or setter, possibly implicitly | 1257 /// A signature is either a method or a getter or setter, possibly implicitly |
| 1257 /// defined by a field declarations. Fields themselves are not members of an | 1258 /// defined by a field declarations. Fields themselves are not members of an |
| 1258 /// interface. | 1259 /// interface. |
| 1259 /// | 1260 /// |
| 1260 /// A [MemberSignature] may be defined by a member declaration or may be | 1261 /// A [MemberSignature] may be defined by a member declaration or may be |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 bool get isDeclaredByField; | 1325 bool get isDeclaredByField; |
| 1325 | 1326 |
| 1326 /// Returns `true` if this member is abstract. | 1327 /// Returns `true` if this member is abstract. |
| 1327 bool get isAbstract; | 1328 bool get isAbstract; |
| 1328 | 1329 |
| 1329 /// If abstract, [implementation] points to the overridden concrete member, | 1330 /// If abstract, [implementation] points to the overridden concrete member, |
| 1330 /// if any. Otherwise [implementation] points to the member itself. | 1331 /// if any. Otherwise [implementation] points to the member itself. |
| 1331 Member get implementation; | 1332 Member get implementation; |
| 1332 } | 1333 } |
| 1333 | 1334 |
| OLD | NEW |