OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Implementation of the element model used for deserialiation. | 5 /// Implementation of the element model used for deserialiation. |
6 /// | 6 /// |
7 /// These classes are created by [ElementDeserializer] triggered by the | 7 /// These classes are created by [ElementDeserializer] triggered by the |
8 /// [Deserializer]. | 8 /// [Deserializer]. |
9 | 9 |
10 library dart2js.serialization.modelz; | 10 library dart2js.serialization.modelz; |
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 | 964 |
965 class NamedMixinApplicationElementZ extends ClassElementZ | 965 class NamedMixinApplicationElementZ extends ClassElementZ |
966 with MixinApplicationElementMixin { | 966 with MixinApplicationElementMixin { |
967 Link<Element> _constructors; | 967 Link<Element> _constructors; |
968 InterfaceType _mixinType; | 968 InterfaceType _mixinType; |
969 | 969 |
970 NamedMixinApplicationElementZ(ObjectDecoder decoder) : super(decoder); | 970 NamedMixinApplicationElementZ(ObjectDecoder decoder) : super(decoder); |
971 | 971 |
972 @override | 972 @override |
973 InterfaceType get mixinType => _mixinType ??= _decoder.getType(Key.MIXIN); | 973 InterfaceType get mixinType => _mixinType ??= _decoder.getType(Key.MIXIN); |
| 974 |
| 975 @override |
| 976 ClassElement get subclass => null; |
974 } | 977 } |
975 | 978 |
976 class UnnamedMixinApplicationElementZ extends ElementZ | 979 class UnnamedMixinApplicationElementZ extends ElementZ |
977 with | 980 with |
978 ClassElementCommon, | 981 ClassElementCommon, |
979 ClassElementMixin, | 982 ClassElementMixin, |
980 class_members.ClassMemberMixin, | 983 class_members.ClassMemberMixin, |
981 TypeDeclarationMixin<InterfaceType>, | 984 TypeDeclarationMixin<InterfaceType>, |
982 AnalyzableElementMixin, | 985 AnalyzableElementMixin, |
983 AstElementMixinZ, | 986 AstElementMixinZ, |
984 MixinApplicationElementCommon, | 987 MixinApplicationElementCommon, |
985 MixinApplicationElementMixin { | 988 MixinApplicationElementMixin { |
986 final String name; | 989 final String name; |
987 final ClassElement _subclass; | 990 final ClassElement subclass; |
988 final InterfaceType _supertypeBase; | 991 final InterfaceType _supertypeBase; |
989 final InterfaceType _mixinBase; | 992 final InterfaceType _mixinBase; |
990 InterfaceType _supertype; | 993 InterfaceType _supertype; |
991 Link<DartType> _interfaces; | 994 Link<DartType> _interfaces; |
992 OrderedTypeSet _allSupertypesAndSelf; | 995 OrderedTypeSet _allSupertypesAndSelf; |
993 Link<ConstructorElement> _constructors; | 996 Link<ConstructorElement> _constructors; |
994 | 997 |
995 UnnamedMixinApplicationElementZ( | 998 UnnamedMixinApplicationElementZ( |
996 ClassElement subclass, InterfaceType supertype, InterfaceType mixin) | 999 this.subclass, InterfaceType supertype, InterfaceType mixin) |
997 : this._subclass = subclass, | 1000 : this._supertypeBase = supertype, |
998 this._supertypeBase = supertype, | |
999 this._mixinBase = mixin, | 1001 this._mixinBase = mixin, |
1000 this.name = "${supertype.name}+${mixin.name}"; | 1002 this.name = "${supertype.name}+${mixin.name}"; |
1001 | 1003 |
1002 @override | 1004 @override |
1003 CompilationUnitElement get compilationUnit => _subclass.compilationUnit; | 1005 CompilationUnitElement get compilationUnit => subclass.compilationUnit; |
1004 | 1006 |
1005 @override | 1007 @override |
1006 bool get isTopLevel => true; | 1008 bool get isTopLevel => true; |
1007 | 1009 |
1008 @override | 1010 @override |
1009 bool get isAbstract => true; | 1011 bool get isAbstract => true; |
1010 | 1012 |
1011 @override | 1013 @override |
1012 bool get isUnnamedMixinApplication => true; | 1014 bool get isUnnamedMixinApplication => true; |
1013 | 1015 |
(...skipping 14 matching lines...) Expand all Loading... |
1028 _constructors = builder.toLink(); | 1030 _constructors = builder.toLink(); |
1029 } | 1031 } |
1030 return _constructors; | 1032 return _constructors; |
1031 } | 1033 } |
1032 | 1034 |
1033 @override | 1035 @override |
1034 List<DartType> _getTypeVariables() { | 1036 List<DartType> _getTypeVariables() { |
1035 // Create synthetic type variables for the mixin application. | 1037 // Create synthetic type variables for the mixin application. |
1036 List<DartType> typeVariables = <DartType>[]; | 1038 List<DartType> typeVariables = <DartType>[]; |
1037 int index = 0; | 1039 int index = 0; |
1038 for (TypeVariableType type in _subclass.typeVariables) { | 1040 for (TypeVariableType type in subclass.typeVariables) { |
1039 SyntheticTypeVariableElementZ typeVariableElement = | 1041 SyntheticTypeVariableElementZ typeVariableElement = |
1040 new SyntheticTypeVariableElementZ(this, index, type.name); | 1042 new SyntheticTypeVariableElementZ(this, index, type.name); |
1041 TypeVariableType typeVariable = new TypeVariableType(typeVariableElement); | 1043 TypeVariableType typeVariable = new TypeVariableType(typeVariableElement); |
1042 typeVariables.add(typeVariable); | 1044 typeVariables.add(typeVariable); |
1043 index++; | 1045 index++; |
1044 } | 1046 } |
1045 // Setup bounds on the synthetic type variables. | 1047 // Setup bounds on the synthetic type variables. |
1046 for (TypeVariableType type in _subclass.typeVariables) { | 1048 for (TypeVariableType type in subclass.typeVariables) { |
1047 TypeVariableType typeVariable = typeVariables[type.element.index]; | 1049 TypeVariableType typeVariable = typeVariables[type.element.index]; |
1048 SyntheticTypeVariableElementZ typeVariableElement = typeVariable.element; | 1050 SyntheticTypeVariableElementZ typeVariableElement = typeVariable.element; |
1049 typeVariableElement._type = typeVariable; | 1051 typeVariableElement._type = typeVariable; |
1050 typeVariableElement._bound = | 1052 typeVariableElement._bound = |
1051 type.element.bound.subst(typeVariables, _subclass.typeVariables); | 1053 type.element.bound.subst(typeVariables, subclass.typeVariables); |
1052 } | 1054 } |
1053 return typeVariables; | 1055 return typeVariables; |
1054 } | 1056 } |
1055 | 1057 |
1056 @override | 1058 @override |
1057 InterfaceType get supertype { | 1059 InterfaceType get supertype { |
1058 if (_supertype == null) { | 1060 if (_supertype == null) { |
1059 // Substitute the type variables in [_supertypeBase] provided by | 1061 // Substitute the type variables in [_supertypeBase] provided by |
1060 // [_subclass] with the type variables in this unnamed mixin application. | 1062 // [_subclass] with the type variables in this unnamed mixin application. |
1061 // | 1063 // |
1062 // For instance | 1064 // For instance |
1063 // class S<S.T> {} | 1065 // class S<S.T> {} |
1064 // class M<M.T> {} | 1066 // class M<M.T> {} |
1065 // class C<C.T> extends S<C.T> with M<C.T> {} | 1067 // class C<C.T> extends S<C.T> with M<C.T> {} |
1066 // the unnamed mixin application should be | 1068 // the unnamed mixin application should be |
1067 // abstract class S+M<S+M.T> extends S<S+M.T> implements M<S+M.T> {} | 1069 // abstract class S+M<S+M.T> extends S<S+M.T> implements M<S+M.T> {} |
1068 // but the supertype is provided as S<C.T> and we need to substitute S+M.T | 1070 // but the supertype is provided as S<C.T> and we need to substitute S+M.T |
1069 // for C.T. | 1071 // for C.T. |
1070 _supertype = _supertypeBase.subst(typeVariables, _subclass.typeVariables); | 1072 _supertype = _supertypeBase.subst(typeVariables, subclass.typeVariables); |
1071 } | 1073 } |
1072 return _supertype; | 1074 return _supertype; |
1073 } | 1075 } |
1074 | 1076 |
1075 @override | 1077 @override |
1076 Link<DartType> get interfaces { | 1078 Link<DartType> get interfaces { |
1077 if (_interfaces == null) { | 1079 if (_interfaces == null) { |
1078 // Substitute the type variables in [_mixinBase] provided by | 1080 // Substitute the type variables in [_mixinBase] provided by |
1079 // [_subclass] with the type variables in this unnamed mixin application. | 1081 // [_subclass] with the type variables in this unnamed mixin application. |
1080 // | 1082 // |
1081 // For instance | 1083 // For instance |
1082 // class S<S.T> {} | 1084 // class S<S.T> {} |
1083 // class M<M.T> {} | 1085 // class M<M.T> {} |
1084 // class C<C.T> extends S<C.T> with M<C.T> {} | 1086 // class C<C.T> extends S<C.T> with M<C.T> {} |
1085 // the unnamed mixin application should be | 1087 // the unnamed mixin application should be |
1086 // abstract class S+M<S+M.T> extends S<S+M.T> implements M<S+M.T> {} | 1088 // abstract class S+M<S+M.T> extends S<S+M.T> implements M<S+M.T> {} |
1087 // but the mixin is provided as M<C.T> and we need to substitute S+M.T | 1089 // but the mixin is provided as M<C.T> and we need to substitute S+M.T |
1088 // for C.T. | 1090 // for C.T. |
1089 _interfaces = const Link<DartType>() | 1091 _interfaces = const Link<DartType>() |
1090 .prepend(_mixinBase.subst(typeVariables, _subclass.typeVariables)); | 1092 .prepend(_mixinBase.subst(typeVariables, subclass.typeVariables)); |
1091 } | 1093 } |
1092 return _interfaces; | 1094 return _interfaces; |
1093 } | 1095 } |
1094 | 1096 |
1095 @override | 1097 @override |
1096 accept(ElementVisitor visitor, arg) { | 1098 accept(ElementVisitor visitor, arg) { |
1097 return visitor.visitMixinApplicationElement(this, arg); | 1099 return visitor.visitMixinApplicationElement(this, arg); |
1098 } | 1100 } |
1099 | 1101 |
1100 @override | 1102 @override |
1101 OrderedTypeSet get allSupertypesAndSelf { | 1103 OrderedTypeSet get allSupertypesAndSelf { |
1102 if (_allSupertypesAndSelf == null) { | 1104 if (_allSupertypesAndSelf == null) { |
1103 _allSupertypesAndSelf = new OrderedTypeSetBuilder(this) | 1105 _allSupertypesAndSelf = new OrderedTypeSetBuilder(this) |
1104 .createOrderedTypeSet(supertype, interfaces); | 1106 .createOrderedTypeSet(supertype, interfaces); |
1105 } | 1107 } |
1106 return _allSupertypesAndSelf; | 1108 return _allSupertypesAndSelf; |
1107 } | 1109 } |
1108 | 1110 |
1109 @override | 1111 @override |
1110 Element get enclosingElement => _subclass.enclosingElement; | 1112 Element get enclosingElement => subclass.enclosingElement; |
1111 | 1113 |
1112 @override | 1114 @override |
1113 bool get isObject => false; | 1115 bool get isObject => false; |
1114 | 1116 |
1115 @override | 1117 @override |
1116 bool get isProxy => false; | 1118 bool get isProxy => false; |
1117 | 1119 |
1118 @override | 1120 @override |
1119 LibraryElement get library => enclosingElement.library; | 1121 LibraryElement get library => enclosingElement.library; |
1120 | 1122 |
1121 @override | 1123 @override |
1122 InterfaceType get mixinType => interfaces.head; | 1124 InterfaceType get mixinType => interfaces.head; |
1123 | 1125 |
1124 @override | 1126 @override |
1125 int get sourceOffset => _subclass.sourceOffset; | 1127 int get sourceOffset => subclass.sourceOffset; |
1126 | 1128 |
1127 @override | 1129 @override |
1128 SourceSpan get sourcePosition => _subclass.sourcePosition; | 1130 SourceSpan get sourcePosition => subclass.sourcePosition; |
1129 } | 1131 } |
1130 | 1132 |
1131 class EnumClassElementZ extends ClassElementZ implements EnumClassElement { | 1133 class EnumClassElementZ extends ClassElementZ implements EnumClassElement { |
1132 List<FieldElement> _enumValues; | 1134 List<FieldElement> _enumValues; |
1133 | 1135 |
1134 EnumClassElementZ(ObjectDecoder decoder) : super(decoder); | 1136 EnumClassElementZ(ObjectDecoder decoder) : super(decoder); |
1135 | 1137 |
1136 @override | 1138 @override |
1137 bool get isEnumClass => true; | 1139 bool get isEnumClass => true; |
1138 | 1140 |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2241 } | 2243 } |
2242 | 2244 |
2243 @override | 2245 @override |
2244 ElementKind get kind => ElementKind.PREFIX; | 2246 ElementKind get kind => ElementKind.PREFIX; |
2245 | 2247 |
2246 @override | 2248 @override |
2247 Element lookupLocalMember(String memberName) { | 2249 Element lookupLocalMember(String memberName) { |
2248 return _unsupported('lookupLocalMember'); | 2250 return _unsupported('lookupLocalMember'); |
2249 } | 2251 } |
2250 } | 2252 } |
OLD | NEW |