| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart2js.serialization_system; | 5 library dart2js.serialization_system; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import '../commandline_options.dart'; | 8 import '../commandline_options.dart'; |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/backend_api.dart'; | 10 import '../common/backend_api.dart'; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 import '../universe/world_impact.dart'; | 21 import '../universe/world_impact.dart'; |
| 22 import '../universe/use.dart'; | 22 import '../universe/use.dart'; |
| 23 import 'json_serializer.dart'; | 23 import 'json_serializer.dart'; |
| 24 import 'modelz.dart'; | 24 import 'modelz.dart'; |
| 25 import 'resolved_ast_serialization.dart'; | 25 import 'resolved_ast_serialization.dart'; |
| 26 import 'serialization.dart'; | 26 import 'serialization.dart'; |
| 27 import 'task.dart'; | 27 import 'task.dart'; |
| 28 | 28 |
| 29 class DeserializerSystemImpl extends DeserializerSystem { | 29 class DeserializerSystemImpl extends DeserializerSystem { |
| 30 final Compiler _compiler; | 30 final Compiler _compiler; |
| 31 final Deserializer _deserializer; | 31 final DeserializationContext deserializationContext; |
| 32 final List<LibraryElement> deserializedLibraries = <LibraryElement>[]; | 32 final List<LibraryElement> deserializedLibraries = <LibraryElement>[]; |
| 33 final ResolutionImpactDeserializer _resolutionImpactDeserializer; | 33 final ResolutionImpactDeserializer _resolutionImpactDeserializer; |
| 34 final ResolvedAstDeserializerPlugin _resolvedAstDeserializer; | 34 final ResolvedAstDeserializerPlugin _resolvedAstDeserializer; |
| 35 final ImpactTransformer _impactTransformer; | 35 final ImpactTransformer _impactTransformer; |
| 36 | 36 |
| 37 factory DeserializerSystemImpl(Compiler compiler, Deserializer deserializer, | 37 factory DeserializerSystemImpl(Compiler compiler, |
| 38 ImpactTransformer impactTransformer) { | 38 ImpactTransformer impactTransformer) { |
| 39 List<DeserializerPlugin> plugins = <DeserializerPlugin>[]; | 39 DeserializationContext context = |
| 40 new DeserializationContext(); |
| 40 DeserializerPlugin backendDeserializer = | 41 DeserializerPlugin backendDeserializer = |
| 41 compiler.backend.serialization.deserializer; | 42 compiler.backend.serialization.deserializer; |
| 42 deserializer.plugins.add(backendDeserializer); | 43 context.plugins.add(backendDeserializer); |
| 43 ResolutionImpactDeserializer resolutionImpactDeserializer = | 44 ResolutionImpactDeserializer resolutionImpactDeserializer = |
| 44 new ResolutionImpactDeserializer(backendDeserializer); | 45 new ResolutionImpactDeserializer(backendDeserializer); |
| 45 deserializer.plugins.add(resolutionImpactDeserializer); | 46 context.plugins.add(resolutionImpactDeserializer); |
| 46 ResolvedAstDeserializerPlugin resolvedAstDeserializer = | 47 ResolvedAstDeserializerPlugin resolvedAstDeserializer = |
| 47 new ResolvedAstDeserializerPlugin( | 48 new ResolvedAstDeserializerPlugin( |
| 48 compiler.parsingContext, backendDeserializer); | 49 compiler.parsingContext, backendDeserializer); |
| 49 deserializer.plugins.add(resolvedAstDeserializer); | 50 context.plugins.add(resolvedAstDeserializer); |
| 50 return new DeserializerSystemImpl._( | 51 return new DeserializerSystemImpl._( |
| 51 compiler, | 52 compiler, |
| 52 deserializer, | 53 context, |
| 53 impactTransformer, | 54 impactTransformer, |
| 54 resolutionImpactDeserializer, | 55 resolutionImpactDeserializer, |
| 55 resolvedAstDeserializer); | 56 resolvedAstDeserializer); |
| 56 } | 57 } |
| 57 | 58 |
| 58 DeserializerSystemImpl._( | 59 DeserializerSystemImpl._( |
| 59 this._compiler, | 60 this._compiler, |
| 60 this._deserializer, | 61 this.deserializationContext, |
| 61 this._impactTransformer, | 62 this._impactTransformer, |
| 62 this._resolutionImpactDeserializer, | 63 this._resolutionImpactDeserializer, |
| 63 this._resolvedAstDeserializer); | 64 this._resolvedAstDeserializer); |
| 64 | 65 |
| 65 @override | 66 @override |
| 66 Future<LibraryElement> readLibrary(Uri resolvedUri) { | 67 Future<LibraryElement> readLibrary(Uri resolvedUri) { |
| 67 LibraryElement library = _deserializer.lookupLibrary(resolvedUri); | 68 LibraryElement library = deserializationContext.lookupLibrary(resolvedUri); |
| 68 if (library != null) { | 69 if (library != null) { |
| 69 deserializedLibraries.add(library); | 70 deserializedLibraries.add(library); |
| 70 return Future.forEach(library.compilationUnits, | 71 return Future.forEach(library.compilationUnits, |
| 71 (CompilationUnitElement compilationUnit) { | 72 (CompilationUnitElement compilationUnit) { |
| 72 ScriptZ script = compilationUnit.script; | 73 ScriptZ script = compilationUnit.script; |
| 73 return _compiler | 74 return _compiler |
| 74 .readScript(script.readableUri) | 75 .readScript(script.readableUri) |
| 75 .then((Script newScript) { | 76 .then((Script newScript) { |
| 76 script.file = newScript.file; | 77 script.file = newScript.file; |
| 77 _resolvedAstDeserializer.sourceFiles[script.resourceUri] = | 78 _resolvedAstDeserializer.sourceFiles[script.resourceUri] = |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 247 } |
| 247 | 248 |
| 248 @override | 249 @override |
| 249 void onElement(Element element, ObjectDecoder getDecoder(String tag)) { | 250 void onElement(Element element, ObjectDecoder getDecoder(String tag)) { |
| 250 ObjectDecoder decoder = getDecoder(RESOLVED_AST_TAG); | 251 ObjectDecoder decoder = getDecoder(RESOLVED_AST_TAG); |
| 251 if (decoder != null) { | 252 if (decoder != null) { |
| 252 _decoderMap[element] = decoder; | 253 _decoderMap[element] = decoder; |
| 253 } | 254 } |
| 254 } | 255 } |
| 255 } | 256 } |
| OLD | NEW |