| 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;
|
| +}
|
|
|