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

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

Issue 1881013002: Expand ResolvedAst to handle synthetic constructors. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments + fix test, cps and compilation units for injected members. 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 78228ca41395b8220d86395e999bb1b84fa97a54..f4a9b45e63f2c25cb02fd309ee0cf359f7ece451 100644
--- a/pkg/compiler/lib/src/serialization/element_serialization.dart
+++ b/pkg/compiler/lib/src/serialization/element_serialization.dart
@@ -105,8 +105,8 @@ class SerializerUtil {
if (element.sourcePosition != null) {
SourceSpan position = element.sourcePosition;
encoder.setInt(Key.OFFSET, position.begin);
+ // TODO(johnniwinther): What is the base URI in the case?
if (position.uri != element.compilationUnit.script.resourceUri) {
- // TODO(johnniwinther): What is the base URI in the case?
encoder.setUri(Key.URI, element.library.canonicalUri, position.uri);
}
int length = position.end - position.begin;
@@ -116,6 +116,21 @@ class SerializerUtil {
}
}
+ /// Serialize the parent relation for [element] into [encoder], i.e library,
+ /// enclosing class, and compilation unit references.
+ static void serializeParentRelation(Element element, ObjectEncoder encoder) {
+ if (element.enclosingClass != null) {
+ encoder.setElement(Key.CLASS, element.enclosingClass);
+ if (element.enclosingClass.declaration.compilationUnit !=
+ element.compilationUnit) {
+ encoder.setElement(Key.COMPILATION_UNIT, element.compilationUnit);
+ }
+ } else {
+ encoder.setElement(Key.LIBRARY, element.library);
+ encoder.setElement(Key.COMPILATION_UNIT, element.compilationUnit);
+ }
+ }
+
/// Serialize the parameters of [element] into [encoder].
static void serializeParameters(
FunctionElement element, ObjectEncoder encoder) {
@@ -333,7 +348,7 @@ class ConstructorSerializer implements ElementSerializer {
void serialize(ConstructorElement element, ObjectEncoder encoder,
SerializedElementKind kind) {
- encoder.setElement(Key.CLASS, element.enclosingClass);
+ SerializerUtil.serializeParentRelation(element, encoder);
encoder.setType(Key.TYPE, element.type);
encoder.setString(Key.NAME, element.name);
SerializerUtil.serializePosition(element, encoder);
@@ -378,12 +393,7 @@ class FieldSerializer implements ElementSerializer {
ConstantExpression constant = element.constant;
encoder.setConstant(Key.CONSTANT, constant);
}
- if (kind != SerializedElementKind.TOPLEVEL_FIELD) {
- encoder.setElement(Key.CLASS, element.enclosingClass);
- } else {
- encoder.setElement(Key.LIBRARY, element.library);
- encoder.setElement(Key.COMPILATION_UNIT, element.compilationUnit);
- }
+ SerializerUtil.serializeParentRelation(element, encoder);
if (element is EnumConstantElement) {
EnumConstantElement enumConstant = element;
encoder.setInt(Key.INDEX, enumConstant.index);
@@ -431,12 +441,7 @@ class FunctionSerializer implements ElementSerializer {
if (element.isFunction) {
encoder.setBool(Key.IS_OPERATOR, element.isOperator);
}
- if (element.enclosingClass != null) {
- encoder.setElement(Key.CLASS, element.enclosingClass);
- } else {
- encoder.setElement(Key.LIBRARY, element.library);
- encoder.setElement(Key.COMPILATION_UNIT, element.compilationUnit);
- }
+ SerializerUtil.serializeParentRelation(element, encoder);
encoder.setBool(Key.IS_EXTERNAL, element.isExternal);
if (element.isLocal) {
LocalFunctionElement localFunction = element;
« no previous file with comments | « pkg/compiler/lib/src/resolution/resolution.dart ('k') | pkg/compiler/lib/src/serialization/equivalence.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698