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

Unified Diff: pkg/compiler/lib/src/serialization/element_serialization.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
Index: pkg/compiler/lib/src/serialization/element_serialization.dart
diff --git a/pkg/compiler/lib/src/serialization/element_serialization.dart b/pkg/compiler/lib/src/serialization/element_serialization.dart
index 6f5dc4d83cd17ded8f670874a3d2e135d65114b3..5c8c0d68fc326fb5a79b9a41f29c6d81a8566d9e 100644
--- a/pkg/compiler/lib/src/serialization/element_serialization.dart
+++ b/pkg/compiler/lib/src/serialization/element_serialization.dart
@@ -13,6 +13,7 @@ import 'constant_serialization.dart';
import 'keys.dart';
import 'modelz.dart';
import 'serialization.dart';
+import 'serialization_util.dart';
/// Enum kinds used for encoding [Element]s.
enum SerializedElementKind {
@@ -23,6 +24,7 @@ enum SerializedElementKind {
NAMED_MIXIN_APPLICATION,
GENERATIVE_CONSTRUCTOR,
FACTORY_CONSTRUCTOR,
+ REDIRECTING_FACTORY_CONSTRUCTOR,
FORWARDING_CONSTRUCTOR,
TOPLEVEL_FIELD,
STATIC_FIELD,
@@ -346,7 +348,12 @@ class ConstructorSerializer implements ElementSerializer {
return SerializedElementKind.GENERATIVE_CONSTRUCTOR;
}
} else if (element.isFactoryConstructor) {
- return SerializedElementKind.FACTORY_CONSTRUCTOR;
+ ConstructorElement constructor = element;
+ if (constructor.isRedirectingFactory) {
+ return SerializedElementKind.REDIRECTING_FACTORY_CONSTRUCTOR;
+ } else {
+ return SerializedElementKind.FACTORY_CONSTRUCTOR;
+ }
}
return null;
}
@@ -363,13 +370,37 @@ class ConstructorSerializer implements ElementSerializer {
SerializerUtil.serializeParameters(element, encoder);
encoder.setBool(Key.IS_CONST, element.isConst);
encoder.setBool(Key.IS_EXTERNAL, element.isExternal);
- if (element.isExternal) return;
if (element.isConst && !element.isFromEnvironmentConstructor) {
ConstantConstructor constantConstructor = element.constantConstructor;
ObjectEncoder constantEncoder = encoder.createObject(Key.CONSTRUCTOR);
const ConstantConstructorSerializer()
.visit(constantConstructor, constantEncoder);
}
+ if (element.definingConstructor != null) {
+ assert(invariant(
+ element,
+ element.definingConstructor.enclosingClass ==
+ element.enclosingClass.superclass,
+ message: "Unexpected defining constructor: "
+ "${element.definingConstructor}"));
+ encoder.setString(
+ Key.DEFINING_CONSTRUCTOR, element.definingConstructor.name);
+ }
+ if (kind == SerializedElementKind.GENERATIVE_CONSTRUCTOR) {
+ encoder.setBool(Key.IS_REDIRECTING, element.isRedirectingGenerative);
+ }
+ encoder.setElement(Key.EFFECTIVE_TARGET, element.effectiveTarget);
+ if (kind == SerializedElementKind.REDIRECTING_FACTORY_CONSTRUCTOR) {
+ encoder.setType(
+ Key.EFFECTIVE_TARGET_TYPE,
+ element
+ .computeEffectiveTargetType(element.enclosingClass.thisType));
+ encoder.setElement(Key.IMMEDIATE_REDIRECTION_TARGET,
+ element.immediateRedirectionTarget);
+ if (element.redirectionDeferredPrefix != null) {
+ encoder.setElement(Key.PREFIX, element.redirectionDeferredPrefix);
+ }
+ }
}
}
}
@@ -660,6 +691,8 @@ class ElementDeserializer {
return new GenerativeConstructorElementZ(decoder);
case SerializedElementKind.FACTORY_CONSTRUCTOR:
return new FactoryConstructorElementZ(decoder);
+ case SerializedElementKind.REDIRECTING_FACTORY_CONSTRUCTOR:
+ return new RedirectingFactoryConstructorElementZ(decoder);
case SerializedElementKind.FORWARDING_CONSTRUCTOR:
return new ForwardingConstructorElementZ(
decoder.getElement(Key.CLASS), decoder.getElement(Key.ELEMENT));
« no previous file with comments | « no previous file | pkg/compiler/lib/src/serialization/keys.dart » ('j') | pkg/compiler/lib/src/serialization/modelz.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698