| Index: tests/compiler/dart2js/serialization_analysis_test.dart
|
| diff --git a/tests/compiler/dart2js/serialization_analysis_test.dart b/tests/compiler/dart2js/serialization_analysis_test.dart
|
| index c77050efe666e099bfb95fec7af7f94e42ba0ded..ebbc6f0c423586286f814803720c4582fe5195f0 100644
|
| --- a/tests/compiler/dart2js/serialization_analysis_test.dart
|
| +++ b/tests/compiler/dart2js/serialization_analysis_test.dart
|
| @@ -10,17 +10,10 @@ import 'package:expect/expect.dart';
|
| import 'package:compiler/src/commandline_options.dart';
|
| import 'package:compiler/src/common/backend_api.dart';
|
| import 'package:compiler/src/common/names.dart';
|
| -import 'package:compiler/src/common/resolution.dart';
|
| import 'package:compiler/src/compiler.dart';
|
| -import 'package:compiler/src/elements/elements.dart';
|
| import 'package:compiler/src/filenames.dart';
|
| -import 'package:compiler/src/serialization/element_serialization.dart';
|
| -import 'package:compiler/src/serialization/impact_serialization.dart';
|
| -import 'package:compiler/src/serialization/json_serializer.dart';
|
| -import 'package:compiler/src/serialization/serialization.dart';
|
| -import 'package:compiler/src/serialization/task.dart';
|
| -import 'package:compiler/src/universe/world_impact.dart';
|
| import 'memory_compiler.dart';
|
| +import 'serialization_helper.dart';
|
|
|
| const List<Test> TESTS = const <Test>[
|
| const Test(const {
|
| @@ -242,15 +235,7 @@ Future analyze(String serializedData, Uri entryPoint, Test test) async {
|
| options: [Flags.analyzeOnly],
|
| diagnosticHandler: diagnosticCollector,
|
| beforeRun: (Compiler compiler) {
|
| - Deserializer deserializer = new Deserializer.fromText(
|
| - new DeserializationContext(),
|
| - serializedData,
|
| - const JsonSerializationDecoder());
|
| - deserializer.plugins.add(compiler.backend.serialization.deserializer);
|
| - compiler.serialization.deserializer =
|
| - new _DeserializerSystem(
|
| - deserializer,
|
| - compiler.backend.impactTransformer);
|
| + deserialize(compiler, serializedData);
|
| });
|
| if (test != null) {
|
| Expect.equals(test.expectedErrorCount, diagnosticCollector.errors.length,
|
| @@ -266,87 +251,3 @@ Future analyze(String serializedData, Uri entryPoint, Test test) async {
|
| }
|
| }
|
|
|
| -Future<String> serializeDartCore() async {
|
| - Compiler compiler = compilerFor(
|
| - options: [Flags.analyzeAll]);
|
| - compiler.serialization.supportSerialization = true;
|
| - await compiler.run(Uris.dart_core);
|
| - return serialize(compiler);
|
| -}
|
| -
|
| -String serialize(Compiler compiler) {
|
| - Serializer serializer = new Serializer();
|
| - serializer.plugins.add(compiler.backend.serialization.serializer);
|
| - serializer.plugins.add(new ResolutionImpactSerializer(compiler.resolution));
|
| -
|
| - for (LibraryElement library in compiler.libraryLoader.libraries) {
|
| - serializer.serialize(library);
|
| - }
|
| - return serializer.toText(const JsonSerializationEncoder());
|
| -}
|
| -
|
| -const String WORLD_IMPACT_TAG = 'worldImpact';
|
| -
|
| -class ResolutionImpactSerializer extends SerializerPlugin {
|
| - final Resolution resolution;
|
| -
|
| - ResolutionImpactSerializer(this.resolution);
|
| -
|
| - @override
|
| - void onElement(Element element, ObjectEncoder createEncoder(String tag)) {
|
| - if (resolution.hasBeenResolved(element)) {
|
| - ResolutionImpact impact = resolution.getResolutionImpact(element);
|
| - ObjectEncoder encoder = createEncoder(WORLD_IMPACT_TAG);
|
| - new ImpactSerializer(encoder).serialize(impact);
|
| - }
|
| - }
|
| -}
|
| -
|
| -class ResolutionImpactDeserializer extends DeserializerPlugin {
|
| - Map<Element, ResolutionImpact> impactMap = <Element, ResolutionImpact>{};
|
| -
|
| - @override
|
| - void onElement(Element element, ObjectDecoder getDecoder(String tag)) {
|
| - ObjectDecoder decoder = getDecoder(WORLD_IMPACT_TAG);
|
| - if (decoder != null) {
|
| - impactMap[element] = ImpactDeserializer.deserializeImpact(decoder);
|
| - }
|
| - }
|
| -}
|
| -
|
| -class _DeserializerSystem extends DeserializerSystem {
|
| - final Deserializer _deserializer;
|
| - final List<LibraryElement> deserializedLibraries = <LibraryElement>[];
|
| - final ResolutionImpactDeserializer _resolutionImpactDeserializer =
|
| - new ResolutionImpactDeserializer();
|
| - final ImpactTransformer _impactTransformer;
|
| -
|
| - _DeserializerSystem(this._deserializer, this._impactTransformer) {
|
| - _deserializer.plugins.add(_resolutionImpactDeserializer);
|
| - }
|
| -
|
| - LibraryElement readLibrary(Uri resolvedUri) {
|
| - LibraryElement library = _deserializer.lookupLibrary(resolvedUri);
|
| - if (library != null) {
|
| - deserializedLibraries.add(library);
|
| - }
|
| - return library;
|
| - }
|
| -
|
| - @override
|
| - WorldImpact computeWorldImpact(Element element) {
|
| - ResolutionImpact resolutionImpact =
|
| - _resolutionImpactDeserializer.impactMap[element];
|
| - if (resolutionImpact == null) {
|
| - print('No impact found for $element (${element.library})');
|
| - return const WorldImpact();
|
| - } else {
|
| - return _impactTransformer.transformResolutionImpact(resolutionImpact);
|
| - }
|
| - }
|
| -
|
| - @override
|
| - bool isDeserialized(Element element) {
|
| - return deserializedLibraries.contains(element.library);
|
| - }
|
| -}
|
|
|