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

Unified Diff: pkg/compiler/lib/src/serialization/element_serialization.dart

Issue 1873823002: Update elements, nodes and visitors for serialization. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix LocalVariableElementZ.constant 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 86c3337ac57553c2a3f2851236f8f84b88791f58..6a3b827d7c744bd411b11ed8bc69932e7242b6c1 100644
--- a/pkg/compiler/lib/src/serialization/element_serialization.dart
+++ b/pkg/compiler/lib/src/serialization/element_serialization.dart
@@ -26,6 +26,7 @@ enum SerializedElementKind {
TOPLEVEL_FIELD,
STATIC_FIELD,
INSTANCE_FIELD,
+ ENUM_CONSTANT,
TOPLEVEL_FUNCTION,
TOPLEVEL_GETTER,
TOPLEVEL_SETTER,
@@ -43,6 +44,7 @@ enum SerializedElementKind {
IMPORT,
EXPORT,
PREFIX,
+ LOCAL_VARIABLE,
EXTERNAL_LIBRARY,
EXTERNAL_LIBRARY_MEMBER,
EXTERNAL_STATIC_MEMBER,
@@ -69,6 +71,7 @@ const List<ElementSerializer> ELEMENT_SERIALIZERS = const [
const ImportSerializer(),
const ExportSerializer(),
const PrefixSerializer(),
+ const LocalVariableSerializer(),
];
/// Interface for a function that can serialize a set of element kinds.
@@ -362,7 +365,12 @@ class FieldSerializer implements ElementSerializer {
SerializedElementKind getSerializedKind(Element element) {
if (element.isField) {
if (element.isTopLevel) return SerializedElementKind.TOPLEVEL_FIELD;
- if (element.isStatic) return SerializedElementKind.STATIC_FIELD;
+ if (element.isStatic) {
+ if (element is EnumConstantElement) {
+ return SerializedElementKind.ENUM_CONSTANT;
+ }
+ return SerializedElementKind.STATIC_FIELD;
+ }
if (element.isInstanceMember) return SerializedElementKind.INSTANCE_FIELD;
}
return null;
@@ -386,6 +394,10 @@ class FieldSerializer implements ElementSerializer {
encoder.setElement(Key.LIBRARY, element.library);
encoder.setElement(Key.COMPILATION_UNIT, element.compilationUnit);
}
+ if (element is EnumConstantElement) {
+ EnumConstantElement enumConstant = element;
+ encoder.setInt(Key.INDEX, enumConstant.index);
+ }
}
}
@@ -520,6 +532,35 @@ class ParameterSerializer implements ElementSerializer {
}
}
+
+class LocalVariableSerializer implements ElementSerializer {
+ const LocalVariableSerializer();
+
+ SerializedElementKind getSerializedKind(Element element) {
+ if (element.isVariable) {
+ return SerializedElementKind.LOCAL_VARIABLE;
+ }
+ return null;
+ }
+
+ void serialize(LocalVariableElement element,
+ ObjectEncoder encoder,
+ SerializedElementKind kind) {
+ encoder.setString(Key.NAME, element.name);
+ SerializerUtil.serializePosition(element, encoder);
+ encoder.setType(Key.TYPE, element.type);
+ encoder.setBool(Key.IS_FINAL, element.isFinal);
+ encoder.setBool(Key.IS_CONST, element.isConst);
+ if (element.isConst) {
+ ConstantExpression constant = element.constant;
+ encoder.setConstant(Key.CONSTANT, constant);
+ }
+ encoder.setElement(
+ Key.EXECUTABLE_CONTEXT, element.executableContext);
+ }
+}
+
+
class ImportSerializer implements ElementSerializer {
const ImportSerializer();
@@ -618,6 +659,8 @@ class ElementDeserializer {
return new TopLevelFieldElementZ(decoder);
case SerializedElementKind.STATIC_FIELD:
return new StaticFieldElementZ(decoder);
+ case SerializedElementKind.ENUM_CONSTANT:
+ return new EnumConstantElementZ(decoder);
case SerializedElementKind.INSTANCE_FIELD:
return new InstanceFieldElementZ(decoder);
case SerializedElementKind.GENERATIVE_CONSTRUCTOR:
@@ -658,6 +701,8 @@ class ElementDeserializer {
return new ExportElementZ(decoder);
case SerializedElementKind.PREFIX:
return new PrefixElementZ(decoder);
+ case SerializedElementKind.LOCAL_VARIABLE:
+ return new LocalVariableElementZ(decoder);
case SerializedElementKind.EXTERNAL_LIBRARY:
case SerializedElementKind.EXTERNAL_LIBRARY_MEMBER:
case SerializedElementKind.EXTERNAL_STATIC_MEMBER:

Powered by Google App Engine
This is Rietveld 408576698