| 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'; |
| 11 | 11 |
| 12 import '../dart2jslib.dart' show InterfaceType, | 12 import '../dart2jslib.dart' show InterfaceType, |
| 13 DartType, | 13 DartType, |
| 14 TypeVariableType, | 14 TypeVariableType, |
| 15 TypedefType, | 15 TypedefType, |
| 16 DualKind, | 16 DualKind, |
| 17 MessageKind, | 17 MessageKind, |
| 18 DiagnosticListener, | 18 DiagnosticListener, |
| 19 Script, | 19 Script, |
| 20 FunctionType, | 20 FunctionType, |
| 21 Selector, | 21 Selector, |
| 22 Constant, | 22 Constant, |
| 23 Compiler; | 23 Compiler, |
| 24 isPrivateName; |
| 24 | 25 |
| 25 import '../dart_types.dart'; | 26 import '../dart_types.dart'; |
| 26 | 27 |
| 27 import '../scanner/scannerlib.dart' show Token, | 28 import '../scanner/scannerlib.dart' show Token, |
| 28 isUserDefinableOperator, | 29 isUserDefinableOperator, |
| 29 isMinusOperator; | 30 isMinusOperator; |
| 30 | 31 |
| 31 import '../ordered_typeset.dart' show OrderedTypeSet; | 32 import '../ordered_typeset.dart' show OrderedTypeSet; |
| 32 | 33 |
| 33 import 'visitor.dart' show ElementVisitor; | 34 import 'visitor.dart' show ElementVisitor; |
| 34 | 35 |
| 36 part 'names.dart'; |
| 37 |
| 35 const int STATE_NOT_STARTED = 0; | 38 const int STATE_NOT_STARTED = 0; |
| 36 const int STATE_STARTED = 1; | 39 const int STATE_STARTED = 1; |
| 37 const int STATE_DONE = 2; | 40 const int STATE_DONE = 2; |
| 38 | 41 |
| 39 class ElementCategory { | 42 class ElementCategory { |
| 40 /** | 43 /** |
| 41 * Represents things that we don't expect to find when looking in a | 44 * Represents things that we don't expect to find when looking in a |
| 42 * scope. | 45 * scope. |
| 43 */ | 46 */ |
| 44 static const int NONE = 0; | 47 static const int NONE = 0; |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 void set nativeTagInfo(String value); | 906 void set nativeTagInfo(String value); |
| 904 | 907 |
| 905 bool isObject(Compiler compiler); | 908 bool isObject(Compiler compiler); |
| 906 bool isSubclassOf(ClassElement cls); | 909 bool isSubclassOf(ClassElement cls); |
| 907 bool implementsInterface(ClassElement intrface); | 910 bool implementsInterface(ClassElement intrface); |
| 908 bool hasFieldShadowedBy(Element fieldMember); | 911 bool hasFieldShadowedBy(Element fieldMember); |
| 909 | 912 |
| 910 /// Returns `true` if this class has a @proxy annotation. | 913 /// Returns `true` if this class has a @proxy annotation. |
| 911 bool get isProxy; | 914 bool get isProxy; |
| 912 | 915 |
| 916 /// Returns `true` if the class hierarchy for this class contains errors. |
| 917 bool get hasIncompleteHierarchy; |
| 918 |
| 913 ClassElement ensureResolved(Compiler compiler); | 919 ClassElement ensureResolved(Compiler compiler); |
| 914 | 920 |
| 915 void addMember(Element element, DiagnosticListener listener); | 921 void addMember(Element element, DiagnosticListener listener); |
| 916 void addToScope(Element element, DiagnosticListener listener); | 922 void addToScope(Element element, DiagnosticListener listener); |
| 917 | 923 |
| 918 void setDefaultConstructor(FunctionElement constructor, Compiler compiler); | 924 void setDefaultConstructor(FunctionElement constructor, Compiler compiler); |
| 919 | 925 |
| 920 void addBackendMember(Element element); | 926 void addBackendMember(Element element); |
| 921 void reverseBackendMembers(); | 927 void reverseBackendMembers(); |
| 922 | 928 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 944 void forEachInstanceField(void f(ClassElement enclosingClass, | 950 void forEachInstanceField(void f(ClassElement enclosingClass, |
| 945 FieldElement field), | 951 FieldElement field), |
| 946 {bool includeSuperAndInjectedMembers: false}); | 952 {bool includeSuperAndInjectedMembers: false}); |
| 947 | 953 |
| 948 /// Similar to [forEachInstanceField] but visits static fields. | 954 /// Similar to [forEachInstanceField] but visits static fields. |
| 949 void forEachStaticField(void f(ClassElement enclosingClass, Element field)); | 955 void forEachStaticField(void f(ClassElement enclosingClass, Element field)); |
| 950 | 956 |
| 951 void forEachBackendMember(void f(Element member)); | 957 void forEachBackendMember(void f(Element member)); |
| 952 | 958 |
| 953 Link<DartType> computeTypeParameters(Compiler compiler); | 959 Link<DartType> computeTypeParameters(Compiler compiler); |
| 960 |
| 961 /// Looks up the member [name] in this class. |
| 962 Member lookupClassMember(Name name); |
| 963 |
| 964 /// Calls [f] with each member of this class. |
| 965 void forEachClassMember(f(Member member)); |
| 966 |
| 967 /// Looks up the member [name] in the interface of this class. |
| 968 MemberSignature lookupInterfaceMember(Name name); |
| 969 |
| 970 /// Calls [f] with each member of the interface of this class. |
| 971 void forEachInterfaceMember(f(MemberSignature member)); |
| 954 } | 972 } |
| 955 | 973 |
| 956 abstract class MixinApplicationElement extends ClassElement { | 974 abstract class MixinApplicationElement extends ClassElement { |
| 957 ClassElement get mixin; | 975 ClassElement get mixin; |
| 958 InterfaceType get mixinType; | 976 InterfaceType get mixinType; |
| 959 void set mixinType(InterfaceType value); | 977 void set mixinType(InterfaceType value); |
| 960 void addConstructor(FunctionElement constructor); | 978 void addConstructor(FunctionElement constructor); |
| 961 } | 979 } |
| 962 | 980 |
| 963 abstract class LabelElement extends Element { | 981 abstract class LabelElement extends Element { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 Token get endToken; | 1025 Token get endToken; |
| 1008 | 1026 |
| 1009 // TODO(kasperl): Try to get rid of these. | 1027 // TODO(kasperl): Try to get rid of these. |
| 1010 void set annotatedElement(Element value); | 1028 void set annotatedElement(Element value); |
| 1011 void set resolutionState(int value); | 1029 void set resolutionState(int value); |
| 1012 | 1030 |
| 1013 MetadataAnnotation ensureResolved(Compiler compiler); | 1031 MetadataAnnotation ensureResolved(Compiler compiler); |
| 1014 } | 1032 } |
| 1015 | 1033 |
| 1016 abstract class VoidElement extends Element {} | 1034 abstract class VoidElement extends Element {} |
| 1035 |
| 1036 /// A [MemberSignature] is a member of an interface. |
| 1037 /// |
| 1038 /// A signature is either a method or a getter or setter, possibly implicitly |
| 1039 /// defined by a field declarations. Fields themselves are not members of an |
| 1040 /// interface. |
| 1041 /// |
| 1042 /// A [MemberSignature] may be defined by a member declaration or may be |
| 1043 /// synthetized from a set of declarations. |
| 1044 abstract class MemberSignature { |
| 1045 /// The name of this member. |
| 1046 Name get name; |
| 1047 |
| 1048 /// The type of the member when accessed. For getters and setters this is the |
| 1049 /// return type and argument type, respectively. For methods the type is the |
| 1050 /// [functionType] defined by the return type and parameters. |
| 1051 DartType get type; |
| 1052 |
| 1053 /// The function type of the member. For a getter `Foo get foo` this is |
| 1054 /// `() -> Foo`, for a setter `void set foo(Foo _)` this is `(Foo) -> void`. |
| 1055 /// For methods the function type is defined by the return type and |
| 1056 /// parameters. |
| 1057 FunctionType get functionType; |
| 1058 |
| 1059 /// Returns `true` if this member is a getter, possibly implictly defined by a |
| 1060 /// field declaration. |
| 1061 bool get isGetter; |
| 1062 |
| 1063 /// Returns `true` if this member is a setter, possibly implictly defined by a |
| 1064 /// field declaration. |
| 1065 bool get isSetter; |
| 1066 |
| 1067 /// Returns `true` if this member is a method, that is neither a getter nor |
| 1068 /// setter. |
| 1069 bool get isMethod; |
| 1070 |
| 1071 /// Returns an iterable of the declarations that define this member. |
| 1072 Iterable<Member> get declarations; |
| 1073 } |
| 1074 |
| 1075 /// A [Member] is a member of a class, that is either a method or a getter or |
| 1076 /// setter, possibly implicitly defined by a field declarations. Fields |
| 1077 /// themselves are not members of a class. |
| 1078 /// |
| 1079 /// A [Member] of a class also defines a signature which is a member of the |
| 1080 /// corresponding interface type. |
| 1081 /// |
| 1082 /// A [Member] is implicitly concrete. An abstract declaration only declares |
| 1083 /// a signature in the interface of its class. |
| 1084 /// |
| 1085 /// A [Member] is always declared by an [Element] which is accessibly through |
| 1086 /// the [element] getter. |
| 1087 abstract class Member extends MemberSignature { |
| 1088 /// The [Element] that declared this member, possibly implicitly in case of |
| 1089 /// a getter or setter defined by a field. |
| 1090 Element get element; |
| 1091 |
| 1092 /// The instance of the class that declared this member. |
| 1093 /// |
| 1094 /// For instance: |
| 1095 /// class A<T> { T m() {} } |
| 1096 /// class B<S> extends A<S> {} |
| 1097 /// The declarer of `m` in `A` is `A<T>` whereas the declarer of `m` in `B` is |
| 1098 /// `A<S>`. |
| 1099 InterfaceType get declarer; |
| 1100 |
| 1101 /// Returns `true` if this member is static. |
| 1102 bool get isStatic; |
| 1103 |
| 1104 /// Returns `true` if this member is a getter or setter implicitly declared |
| 1105 /// by a field. |
| 1106 bool get isDeclaredByField; |
| 1107 } |
| 1108 |
| OLD | NEW |