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