Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: pkg/compiler/lib/src/serialization/modelz.dart

Issue 1924053003: Serialize more properties of ConstructorElement. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: dartfmt Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 import '../resolution/class_members.dart' as class_members; 23 import '../resolution/class_members.dart' as class_members;
24 import '../resolution/scope.dart' show Scope; 24 import '../resolution/scope.dart' show Scope;
25 import '../resolution/tree_elements.dart' show TreeElements; 25 import '../resolution/tree_elements.dart' show TreeElements;
26 import '../script.dart'; 26 import '../script.dart';
27 import '../serialization/constant_serialization.dart'; 27 import '../serialization/constant_serialization.dart';
28 import '../tokens/token.dart' show Token; 28 import '../tokens/token.dart' show Token;
29 import '../tree/tree.dart'; 29 import '../tree/tree.dart';
30 import '../util/util.dart' show Link, LinkBuilder; 30 import '../util/util.dart' show Link, LinkBuilder;
31 import 'keys.dart'; 31 import 'keys.dart';
32 import 'serialization.dart'; 32 import 'serialization.dart';
33 import 'serialization_util.dart';
33 34
34 /// Compute a [Link] from an [Iterable]. 35 /// Compute a [Link] from an [Iterable].
35 Link toLink(Iterable iterable) { 36 Link toLink(Iterable iterable) {
36 LinkBuilder builder = new LinkBuilder(); 37 LinkBuilder builder = new LinkBuilder();
37 for (var element in iterable) { 38 for (var element in iterable) {
38 builder.addLast(element); 39 builder.addLast(element);
39 } 40 }
40 return builder.toLink(); 41 return builder.toLink();
41 } 42 }
42 43
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 with 1059 with
1059 AnalyzableElementMixin, 1060 AnalyzableElementMixin,
1060 AstElementMixin, 1061 AstElementMixin,
1061 ClassMemberMixin, 1062 ClassMemberMixin,
1062 FunctionTypedElementMixin, 1063 FunctionTypedElementMixin,
1063 ParametersMixin, 1064 ParametersMixin,
1064 TypedElementMixin, 1065 TypedElementMixin,
1065 MemberElementMixin 1066 MemberElementMixin
1066 implements ConstructorElement { 1067 implements ConstructorElement {
1067 ConstantConstructor _constantConstructor; 1068 ConstantConstructor _constantConstructor;
1069 ConstructorElement _effectiveTarget;
1068 1070
1069 ConstructorElementZ(ObjectDecoder decoder) : super(decoder); 1071 ConstructorElementZ(ObjectDecoder decoder) : super(decoder);
1070 1072
1071 accept(ElementVisitor visitor, arg) { 1073 accept(ElementVisitor visitor, arg) {
1072 return visitor.visitConstructorElement(this, arg); 1074 return visitor.visitConstructorElement(this, arg);
1073 } 1075 }
1074 1076
1075 @override 1077 @override
1076 bool get isConst => _decoder.getBool(Key.IS_CONST); 1078 bool get isConst => _decoder.getBool(Key.IS_CONST);
1077 1079
(...skipping 18 matching lines...) Expand all
1096 } 1098 }
1097 _constantConstructor = ConstantConstructorDeserializer.deserialize(data); 1099 _constantConstructor = ConstantConstructorDeserializer.deserialize(data);
1098 } 1100 }
1099 return _constantConstructor; 1101 return _constantConstructor;
1100 } 1102 }
1101 1103
1102 @override 1104 @override
1103 AsyncMarker get asyncMarker => AsyncMarker.SYNC; 1105 AsyncMarker get asyncMarker => AsyncMarker.SYNC;
1104 1106
1105 @override 1107 @override
1106 InterfaceType computeEffectiveTargetType(InterfaceType newType) {
1107 return _unsupported('computeEffectiveTargetType');
1108 }
1109
1110 @override
1111 ConstructorElement get definingConstructor { 1108 ConstructorElement get definingConstructor {
1112 return _unsupported('definingConstructor'); 1109 String name =
1110 _decoder.getString(Key.DEFINING_CONSTRUCTOR, isOptional: true);
1111 if (name != null) {
1112 return enclosingClass.superclass.lookupConstructor(name);
1113 }
1114 return null;
1113 } 1115 }
1114 1116
1115 @override 1117 @override
1116 ConstructorElement get effectiveTarget { 1118 ConstructorElement get effectiveTarget {
1117 return _unsupported('effectiveTarget'); 1119 if (_effectiveTarget == null) {
1120 _effectiveTarget =
1121 _decoder.getElement(Key.EFFECTIVE_TARGET, isOptional: true);
1122 if (_effectiveTarget == null) {
1123 _effectiveTarget = this;
1124 }
1125 }
1126 return _effectiveTarget;
1118 } 1127 }
1119 1128
1120 @override 1129 @override
1121 ConstructorElement get immediateRedirectionTarget { 1130 ConstructorElement get immediateRedirectionTarget => null;
1122 return _unsupported('immediateRedirectionTarget');
1123 }
1124 1131
1125 @override 1132 @override
1126 bool get isEffectiveTargetMalformed { 1133 bool get isEffectiveTargetMalformed {
1127 return _unsupported('isEffectiveTargetMalformed'); 1134 return _unsupported('isEffectiveTargetMalformed');
1128 } 1135 }
1129 1136
1130 @override 1137 @override
1131 bool get isRedirectingFactory => _unsupported('isRedirectingFactory');
1132
1133 @override
1134 bool get isRedirectingGenerative => _unsupported('isRedirectingGenerative');
1135
1136 @override
1137 bool get isCyclicRedirection => _unsupported('isCyclicRedirection'); 1138 bool get isCyclicRedirection => _unsupported('isCyclicRedirection');
1138 1139
1139 @override 1140 @override
1140 PrefixElement get redirectionDeferredPrefix { 1141 bool get isRedirectingFactory => false;
1141 return _unsupported('redirectionDeferredPrefix'); 1142
1142 } 1143 @override
1144 bool get isRedirectingGenerative => false;
1145
1146 @override
1147 PrefixElement get redirectionDeferredPrefix => null;
1148
1149 @override
1150 InterfaceType computeEffectiveTargetType(InterfaceType newType) => newType;
1143 } 1151 }
1144 1152
1145 class GenerativeConstructorElementZ extends ConstructorElementZ { 1153 class GenerativeConstructorElementZ extends ConstructorElementZ {
1146 GenerativeConstructorElementZ(ObjectDecoder decoder) : super(decoder); 1154 GenerativeConstructorElementZ(ObjectDecoder decoder) : super(decoder);
1147 1155
1148 @override 1156 @override
1149 ElementKind get kind => ElementKind.GENERATIVE_CONSTRUCTOR; 1157 ElementKind get kind => ElementKind.GENERATIVE_CONSTRUCTOR;
1150 1158
1151 @override 1159 @override
1152 bool get isEffectiveTargetMalformed => 1160 bool get isRedirectingGenerative => _decoder.getBool(Key.IS_REDIRECTING);
1153 _unsupported('isEffectiveTargetMalformed');
1154 } 1161 }
1155 1162
1156 class FactoryConstructorElementZ extends ConstructorElementZ { 1163 class FactoryConstructorElementZ extends ConstructorElementZ {
1157 FactoryConstructorElementZ(ObjectDecoder decoder) : super(decoder); 1164 FactoryConstructorElementZ(ObjectDecoder decoder) : super(decoder);
1158 1165
1159 @override 1166 @override
1160 ElementKind get kind => ElementKind.FACTORY_CONSTRUCTOR; 1167 ElementKind get kind => ElementKind.FACTORY_CONSTRUCTOR;
1168 }
1169
1170 class RedirectingFactoryConstructorElementZ extends ConstructorElementZ {
1171 InterfaceType _effectiveTargetType;
1172 ConstructorElement _immediateRedirectionTarget;
1173 PrefixElement _redirectionDeferredPrefix;
1174
1175 RedirectingFactoryConstructorElementZ(ObjectDecoder decoder) : super(decoder);
1176
1177 @override
1178 ElementKind get kind => ElementKind.FACTORY_CONSTRUCTOR;
1161 1179
1162 @override 1180 @override
1163 bool get isEffectiveTargetMalformed => 1181 bool get isRedirectingFactory => true;
1164 _unsupported('isEffectiveTargetMalformed'); 1182
1183 void _ensureEffectiveTarget() {
1184 if (_effectiveTarget == null) {
1185 _effectiveTarget =
1186 _decoder.getElement(Key.EFFECTIVE_TARGET, isOptional: true);
1187 if (_effectiveTarget == null) {
1188 _effectiveTarget = this;
1189 _effectiveTargetType = enclosingClass.thisType;
1190 } else {
1191 _effectiveTargetType = _decoder.getType(Key.EFFECTIVE_TARGET_TYPE);
1192 }
1193 }
1194 }
1195
1196 @override
1197 ConstructorElement get effectiveTarget {
1198 _ensureEffectiveTarget();
1199 return _effectiveTarget;
1200 }
1201
1202 @override
1203 InterfaceType computeEffectiveTargetType(InterfaceType newType) {
1204 _ensureEffectiveTarget();
1205 return _effectiveTargetType.substByContext(newType);
1206 }
1207
1208 void _ensureRedirection() {
1209 if (_immediateRedirectionTarget == null) {
1210 _immediateRedirectionTarget =
1211 _decoder.getElement(Key.IMMEDIATE_REDIRECTION_TARGET);
1212 _redirectionDeferredPrefix =
1213 _decoder.getElement(Key.PREFIX, isOptional: true);
1214 }
1215 }
1216
1217 @override
1218 ConstructorElement get immediateRedirectionTarget {
Siggi Cherem (dart-lang) 2016/04/29 20:20:23 optional suggestion, probably not worth it. I'd e
Johnni Winther 2016/04/30 09:04:46 I think it's only really worthwhile to deserialize
Siggi Cherem (dart-lang) 2016/05/02 16:58:35 Yeah, I look forward to the new format. At that po
1219 _ensureRedirection();
1220 return _immediateRedirectionTarget;
1221 }
1222
1223 @override
1224 PrefixElement get redirectionDeferredPrefix {
1225 _ensureRedirection();
1226 return _redirectionDeferredPrefix;
1227 }
1165 } 1228 }
1166 1229
1167 class ForwardingConstructorElementZ extends ElementZ 1230 class ForwardingConstructorElementZ extends ElementZ
1168 with AnalyzableElementMixin, AstElementMixin 1231 with AnalyzableElementMixin, AstElementMixin
1169 implements ConstructorElement { 1232 implements ConstructorElement {
1170 final MixinApplicationElement enclosingClass; 1233 final MixinApplicationElement enclosingClass;
1171 final ConstructorElement definingConstructor; 1234 final ConstructorElement definingConstructor;
1172 1235
1173 ForwardingConstructorElementZ(this.enclosingClass, this.definingConstructor); 1236 ForwardingConstructorElementZ(this.enclosingClass, this.definingConstructor);
1174 1237
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
2020 } 2083 }
2021 2084
2022 @override 2085 @override
2023 ElementKind get kind => ElementKind.PREFIX; 2086 ElementKind get kind => ElementKind.PREFIX;
2024 2087
2025 @override 2088 @override
2026 Element lookupLocalMember(String memberName) { 2089 Element lookupLocalMember(String memberName) {
2027 return _unsupported('lookupLocalMember'); 2090 return _unsupported('lookupLocalMember');
2028 } 2091 }
2029 } 2092 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/keys.dart ('k') | tests/compiler/dart2js/serialization_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698