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

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

Issue 1901683002: Support deserialization of ResolutionImpact for members of unnamed mixin applications (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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/serialization_util.dart
diff --git a/pkg/compiler/lib/src/serialization/serialization_util.dart b/pkg/compiler/lib/src/serialization/serialization_util.dart
index 13184e9a486900c184a70f30d22f8b52c39b245b..24aa6f88ef58e2ba5f9f14109124f5e21d9b1548 100644
--- a/pkg/compiler/lib/src/serialization/serialization_util.dart
+++ b/pkg/compiler/lib/src/serialization/serialization_util.dart
@@ -4,6 +4,7 @@
library dart2js.serialization.util;
+import '../common.dart';
import '../constants/expressions.dart';
import '../dart_types.dart';
import '../elements/elements.dart';
@@ -474,3 +475,45 @@ AccessSemantics deserializeAccessSemantics(ObjectDecoder decoder) {
throw new UnsupportedError('Unsupported access kind: $kind');
}
}
+
+/// Serialize a reference from [context] to an [element] which might be a member
+/// of an unnamed mixin application. If it is, [element] is by serialized
+/// indirectly by name in the [nameKey] of [encoder], otherwise [element] is
+/// serialized directly in [elementKey] in [encoder].
+void serializeElementReference(Element context, Key elementKey, Key nameKey,
+ ObjectEncoder encoder, Element element) {
+ if (element.isGenerativeConstructor &&
+ element.enclosingClass.isUnnamedMixinApplication) {
+ assert(invariant(element, element.isConstructor,
+ message: "Unexpected reference of forwarding constructor "
+ "${element} from $context."));
+ encoder.setString(nameKey, element.name);
+ } else {
+ encoder.setElement(elementKey, element);
+ }
+}
+
+/// Deserialize a reference from [context] to an [Element] which might be a
+/// member of an unnamed mixin application. If it is, the [Element] is by
+/// deserialized indirectly by name from [nameKey] in [decoder], otherwise
+/// the [Element] is deserialized directly from [elementKey] in [encoder].
+Element deserializeElementReference(
+ Element context, Key elementKey, Key nameKey, ObjectDecoder decoder,
+ {bool isOptional: false}) {
+ Element element = decoder.getElement(elementKey, isOptional: true);
+ if (element == null) {
+ String elementName = decoder.getString(nameKey, isOptional: isOptional);
+ if (elementName == null) {
+ return null;
+ }
+ assert(invariant(NO_LOCATION_SPANNABLE, context.isConstructor,
+ message: "Unexpected reference of forwarding constructor "
+ "'${elementName}' from $context."));
+ ClassElement superclass = context.enclosingClass.superclass;
+ element = superclass.lookupConstructor(elementName);
+ assert(invariant(NO_LOCATION_SPANNABLE, element != null,
+ message: "Unresolved reference of forwarding constructor "
+ "'${elementName}' from $context."));
+ }
+ return element;
+}
« no previous file with comments | « pkg/compiler/lib/src/serialization/resolved_ast_serialization.dart ('k') | pkg/compiler/lib/src/serialization/task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698