| 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 Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import '../../compiler_new.dart'; | 9 import '../../compiler_new.dart'; |
| 10 import '../common/resolution.dart' show ResolutionImpact, ResolutionWorkItem; | 10 import '../common/resolution.dart' show ResolutionImpact, ResolutionWorkItem; |
| 11 import '../common/tasks.dart' show CompilerTask; | 11 import '../common/tasks.dart' show CompilerTask; |
| 12 import '../compiler.dart' show Compiler; | 12 import '../compiler.dart' show Compiler; |
| 13 import '../elements/elements.dart'; | 13 import '../elements/elements.dart'; |
| 14 import '../elements/entities.dart' show Entity; |
| 14 import '../universe/world_impact.dart' show WorldImpact; | 15 import '../universe/world_impact.dart' show WorldImpact; |
| 15 import 'json_serializer.dart'; | 16 import 'json_serializer.dart'; |
| 16 import 'serialization.dart'; | 17 import 'serialization.dart'; |
| 17 import 'system.dart'; | 18 import 'system.dart'; |
| 18 | 19 |
| 19 /// A deserializer that can load a library element by reading it's information | 20 /// A deserializer that can load a library element by reading it's information |
| 20 /// from a serialized form. | 21 /// from a serialized form. |
| 21 abstract class LibraryDeserializer { | 22 abstract class LibraryDeserializer { |
| 22 /// Loads the [LibraryElement] associated with a library under [uri], or null | 23 /// Loads the [LibraryElement] associated with a library under [uri], or null |
| 23 /// if no serialized information is available for the given library. | 24 /// if no serialized information is available for the given library. |
| 24 Future<LibraryElement> readLibrary(Uri uri); | 25 Future<LibraryElement> readLibrary(Uri uri); |
| 25 | 26 |
| 26 /// Returns `true` if [element] has been deserialized. | 27 /// Returns `true` if [element] has been deserialized. |
| 27 bool isDeserialized(Element element); | 28 bool isDeserialized(Entity element); |
| 28 } | 29 } |
| 29 | 30 |
| 30 /// Task that supports deserialization of elements. | 31 /// Task that supports deserialization of elements. |
| 31 class SerializationTask extends CompilerTask implements LibraryDeserializer { | 32 class SerializationTask extends CompilerTask implements LibraryDeserializer { |
| 32 final Compiler compiler; | 33 final Compiler compiler; |
| 33 SerializationTask(Compiler compiler) | 34 SerializationTask(Compiler compiler) |
| 34 : compiler = compiler, | 35 : compiler = compiler, |
| 35 super(compiler.measurer); | 36 super(compiler.measurer); |
| 36 | 37 |
| 37 DeserializerSystem deserializer; | 38 DeserializerSystem deserializer; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 51 bool get supportsDeserialization => deserializer != null; | 52 bool get supportsDeserialization => deserializer != null; |
| 52 | 53 |
| 53 /// Returns the [LibraryElement] for [resolvedUri] if available from | 54 /// Returns the [LibraryElement] for [resolvedUri] if available from |
| 54 /// serialization. | 55 /// serialization. |
| 55 Future<LibraryElement> readLibrary(Uri resolvedUri) { | 56 Future<LibraryElement> readLibrary(Uri resolvedUri) { |
| 56 if (deserializer == null) return new Future<LibraryElement>.value(); | 57 if (deserializer == null) return new Future<LibraryElement>.value(); |
| 57 return deserializer.readLibrary(resolvedUri); | 58 return deserializer.readLibrary(resolvedUri); |
| 58 } | 59 } |
| 59 | 60 |
| 60 /// Returns `true` if [element] has been deserialized. | 61 /// Returns `true` if [element] has been deserialized. |
| 61 bool isDeserialized(Element element) { | 62 bool isDeserialized(Entity element) { |
| 62 return deserializer != null && deserializer.isDeserialized(element); | 63 return deserializer != null && deserializer.isDeserialized(element); |
| 63 } | 64 } |
| 64 | 65 |
| 65 bool hasResolutionImpact(Element element) { | 66 bool hasResolutionImpact(Element element) { |
| 66 return deserializer != null && deserializer.hasResolutionImpact(element); | 67 return deserializer != null && deserializer.hasResolutionImpact(element); |
| 67 } | 68 } |
| 68 | 69 |
| 69 ResolutionImpact getResolutionImpact(Element element) { | 70 ResolutionImpact getResolutionImpact(Element element) { |
| 70 return deserializer != null | 71 return deserializer != null |
| 71 ? deserializer.getResolutionImpact(element) | 72 ? deserializer.getResolutionImpact(element) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 @override | 147 @override |
| 147 WorldImpact run() { | 148 WorldImpact run() { |
| 148 return worldImpact; | 149 return worldImpact; |
| 149 } | 150 } |
| 150 } | 151 } |
| 151 | 152 |
| 152 /// The interface for a system that supports deserialization of libraries and | 153 /// The interface for a system that supports deserialization of libraries and |
| 153 /// elements. | 154 /// elements. |
| 154 abstract class DeserializerSystem { | 155 abstract class DeserializerSystem { |
| 155 Future<LibraryElement> readLibrary(Uri resolvedUri); | 156 Future<LibraryElement> readLibrary(Uri resolvedUri); |
| 156 bool isDeserialized(Element element); | 157 bool isDeserialized(Entity element); |
| 157 bool hasResolvedAst(ExecutableElement element); | 158 bool hasResolvedAst(ExecutableElement element); |
| 158 ResolvedAst getResolvedAst(ExecutableElement element); | 159 ResolvedAst getResolvedAst(ExecutableElement element); |
| 159 bool hasResolutionImpact(Element element); | 160 bool hasResolutionImpact(Element element); |
| 160 ResolutionImpact getResolutionImpact(Element element); | 161 ResolutionImpact getResolutionImpact(Element element); |
| 161 WorldImpact computeWorldImpact(Element element); | 162 WorldImpact computeWorldImpact(Element element); |
| 162 } | 163 } |
| OLD | NEW |