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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/serialization/modelz.dart
diff --git a/pkg/compiler/lib/src/serialization/modelz.dart b/pkg/compiler/lib/src/serialization/modelz.dart
index e77d5c0925c5c208536f281d8d0e72c22483dcf7..2bfb6e13987cb7c3029e9e077c9940ef56bbdeb6 100644
--- a/pkg/compiler/lib/src/serialization/modelz.dart
+++ b/pkg/compiler/lib/src/serialization/modelz.dart
@@ -30,6 +30,7 @@ import '../tree/tree.dart';
import '../util/util.dart' show Link, LinkBuilder;
import 'keys.dart';
import 'serialization.dart';
+import 'serialization_util.dart';
/// Compute a [Link] from an [Iterable].
Link toLink(Iterable iterable) {
@@ -1065,6 +1066,7 @@ abstract class ConstructorElementZ extends DeserializedElementZ
MemberElementMixin
implements ConstructorElement {
ConstantConstructor _constantConstructor;
+ ConstructorElement _effectiveTarget;
ConstructorElementZ(ObjectDecoder decoder) : super(decoder);
@@ -1103,24 +1105,29 @@ abstract class ConstructorElementZ extends DeserializedElementZ
AsyncMarker get asyncMarker => AsyncMarker.SYNC;
@override
- InterfaceType computeEffectiveTargetType(InterfaceType newType) {
- return _unsupported('computeEffectiveTargetType');
- }
-
- @override
ConstructorElement get definingConstructor {
- return _unsupported('definingConstructor');
+ String name =
+ _decoder.getString(Key.DEFINING_CONSTRUCTOR, isOptional: true);
+ if (name != null) {
+ return enclosingClass.superclass.lookupConstructor(name);
+ }
+ return null;
}
@override
ConstructorElement get effectiveTarget {
- return _unsupported('effectiveTarget');
+ if (_effectiveTarget == null) {
+ _effectiveTarget =
+ _decoder.getElement(Key.EFFECTIVE_TARGET, isOptional: true);
+ if (_effectiveTarget == null) {
+ _effectiveTarget = this;
+ }
+ }
+ return _effectiveTarget;
}
@override
- ConstructorElement get immediateRedirectionTarget {
- return _unsupported('immediateRedirectionTarget');
- }
+ ConstructorElement get immediateRedirectionTarget => null;
@override
bool get isEffectiveTargetMalformed {
@@ -1128,18 +1135,19 @@ abstract class ConstructorElementZ extends DeserializedElementZ
}
@override
- bool get isRedirectingFactory => _unsupported('isRedirectingFactory');
+ bool get isCyclicRedirection => _unsupported('isCyclicRedirection');
@override
- bool get isRedirectingGenerative => _unsupported('isRedirectingGenerative');
+ bool get isRedirectingFactory => false;
@override
- bool get isCyclicRedirection => _unsupported('isCyclicRedirection');
+ bool get isRedirectingGenerative => false;
@override
- PrefixElement get redirectionDeferredPrefix {
- return _unsupported('redirectionDeferredPrefix');
- }
+ PrefixElement get redirectionDeferredPrefix => null;
+
+ @override
+ InterfaceType computeEffectiveTargetType(InterfaceType newType) => newType;
}
class GenerativeConstructorElementZ extends ConstructorElementZ {
@@ -1149,8 +1157,7 @@ class GenerativeConstructorElementZ extends ConstructorElementZ {
ElementKind get kind => ElementKind.GENERATIVE_CONSTRUCTOR;
@override
- bool get isEffectiveTargetMalformed =>
- _unsupported('isEffectiveTargetMalformed');
+ bool get isRedirectingGenerative => _decoder.getBool(Key.IS_REDIRECTING);
}
class FactoryConstructorElementZ extends ConstructorElementZ {
@@ -1158,10 +1165,66 @@ class FactoryConstructorElementZ extends ConstructorElementZ {
@override
ElementKind get kind => ElementKind.FACTORY_CONSTRUCTOR;
+}
+
+class RedirectingFactoryConstructorElementZ extends ConstructorElementZ {
+ InterfaceType _effectiveTargetType;
+ ConstructorElement _immediateRedirectionTarget;
+ PrefixElement _redirectionDeferredPrefix;
+
+ RedirectingFactoryConstructorElementZ(ObjectDecoder decoder) : super(decoder);
+
+ @override
+ ElementKind get kind => ElementKind.FACTORY_CONSTRUCTOR;
@override
- bool get isEffectiveTargetMalformed =>
- _unsupported('isEffectiveTargetMalformed');
+ bool get isRedirectingFactory => true;
+
+ void _ensureEffectiveTarget() {
+ if (_effectiveTarget == null) {
+ _effectiveTarget =
+ _decoder.getElement(Key.EFFECTIVE_TARGET, isOptional: true);
+ if (_effectiveTarget == null) {
+ _effectiveTarget = this;
+ _effectiveTargetType = enclosingClass.thisType;
+ } else {
+ _effectiveTargetType = _decoder.getType(Key.EFFECTIVE_TARGET_TYPE);
+ }
+ }
+ }
+
+ @override
+ ConstructorElement get effectiveTarget {
+ _ensureEffectiveTarget();
+ return _effectiveTarget;
+ }
+
+ @override
+ InterfaceType computeEffectiveTargetType(InterfaceType newType) {
+ _ensureEffectiveTarget();
+ return _effectiveTargetType.substByContext(newType);
+ }
+
+ void _ensureRedirection() {
+ if (_immediateRedirectionTarget == null) {
+ _immediateRedirectionTarget =
+ _decoder.getElement(Key.IMMEDIATE_REDIRECTION_TARGET);
+ _redirectionDeferredPrefix =
+ _decoder.getElement(Key.PREFIX, isOptional: true);
+ }
+ }
+
+ @override
+ 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
+ _ensureRedirection();
+ return _immediateRedirectionTarget;
+ }
+
+ @override
+ PrefixElement get redirectionDeferredPrefix {
+ _ensureRedirection();
+ return _redirectionDeferredPrefix;
+ }
}
class ForwardingConstructorElementZ extends ElementZ
« 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