| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.task; | 5 library dart2js.serialization.task; |
| 6 | 6 |
| 7 import 'dart:async' show EventSink, Future; | 7 import 'dart:async' show EventSink, Future; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../common/resolution.dart' show ResolutionImpact, ResolutionWorkItem; | 9 import '../common/resolution.dart' show ResolutionImpact, ResolutionWorkItem; |
| 10 import '../common/tasks.dart' show CompilerTask; | 10 import '../common/tasks.dart' show CompilerTask; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 measure(() { | 105 measure(() { |
| 106 sink | 106 sink |
| 107 ..add(createSerializer(libraries) | 107 ..add(createSerializer(libraries) |
| 108 .toText(const JsonSerializationEncoder())) | 108 .toText(const JsonSerializationEncoder())) |
| 109 ..close(); | 109 ..close(); |
| 110 }); | 110 }); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void deserializeFromText(String serializedData) { | 113 void deserializeFromText(String serializedData) { |
| 114 measure(() { | 114 measure(() { |
| 115 if (deserializer == null) { |
| 116 deserializer = new DeserializerSystemImpl( |
| 117 compiler, compiler.backend.impactTransformer); |
| 118 } |
| 119 DeserializerSystemImpl deserializerImpl = deserializer; |
| 120 DeserializationContext context = deserializerImpl.deserializationContext; |
| 115 Deserializer dataDeserializer = new Deserializer.fromText( | 121 Deserializer dataDeserializer = new Deserializer.fromText( |
| 116 new DeserializationContext(), | 122 context, serializedData, const JsonSerializationDecoder()); |
| 117 serializedData, | 123 context.deserializers.add(dataDeserializer); |
| 118 const JsonSerializationDecoder()); | |
| 119 dataDeserializer.plugins.add(compiler.backend.serialization.deserializer); | |
| 120 deserializer = new DeserializerSystemImpl( | |
| 121 compiler, dataDeserializer, compiler.backend.impactTransformer); | |
| 122 }); | 124 }); |
| 123 } | 125 } |
| 124 } | 126 } |
| 125 | 127 |
| 126 /// A [ResolutionWorkItem] for a deserialized element. | 128 /// A [ResolutionWorkItem] for a deserialized element. |
| 127 /// | 129 /// |
| 128 /// This will not resolve the element but only compute the [WorldImpact]. | 130 /// This will not resolve the element but only compute the [WorldImpact]. |
| 129 class DeserializedResolutionWorkItem implements ResolutionWorkItem { | 131 class DeserializedResolutionWorkItem implements ResolutionWorkItem { |
| 130 final Element element; | 132 final Element element; |
| 131 final ItemCompilationContext compilationContext; | 133 final ItemCompilationContext compilationContext; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 150 /// elements. | 152 /// elements. |
| 151 abstract class DeserializerSystem { | 153 abstract class DeserializerSystem { |
| 152 Future<LibraryElement> readLibrary(Uri resolvedUri); | 154 Future<LibraryElement> readLibrary(Uri resolvedUri); |
| 153 bool isDeserialized(Element element); | 155 bool isDeserialized(Element element); |
| 154 bool hasResolvedAst(ExecutableElement element); | 156 bool hasResolvedAst(ExecutableElement element); |
| 155 ResolvedAst getResolvedAst(ExecutableElement element); | 157 ResolvedAst getResolvedAst(ExecutableElement element); |
| 156 bool hasResolutionImpact(Element element); | 158 bool hasResolutionImpact(Element element); |
| 157 ResolutionImpact getResolutionImpact(Element element); | 159 ResolutionImpact getResolutionImpact(Element element); |
| 158 WorldImpact computeWorldImpact(Element element); | 160 WorldImpact computeWorldImpact(Element element); |
| 159 } | 161 } |
| OLD | NEW |