Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library dart2js.serialization.task; | |
| 6 | |
| 7 import '../dart2jslib.dart'; | |
| 8 import '../elements/elements.dart'; | |
| 9 | |
| 10 /// Task that supports deserialization of elements. | |
| 11 class SerializationTask extends CompilerTask { | |
| 12 SerializationTask(Compiler compiler) : super(compiler); | |
| 13 | |
| 14 DeserializerSystem deserializer; | |
| 15 | |
| 16 String get name => 'Serialization'; | |
| 17 | |
| 18 /// Returns the [LibraryElement] for [resolvedUri] if available from | |
| 19 /// serialization. | |
| 20 LibraryElement readLibrary(Uri resolvedUri) { | |
| 21 if (deserializer == null) return null; | |
| 22 return deserializer.readLibrary(resolvedUri); | |
| 23 } | |
| 24 | |
| 25 /// Returns `true` if [element] has been deserialized. | |
| 26 bool isDeserialized(Element element) { | |
| 27 return deserializer != null && deserializer.isDeserialized(element); | |
| 28 } | |
| 29 | |
| 30 /// Creates the [ResolutionWorkItem] for the deserialized [element]. | |
| 31 ResolutionWorkItem createResolutionWorkItem( | |
| 32 Element element, ItemCompilationContext context) { | |
| 33 assert(deserializer != null); | |
| 34 assert(isDeserialized(element)); | |
| 35 return new DeserializedResolutionWorkItem( | |
| 36 element, context, deserializer.getWorldImpact(element)); | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 /// A [ResolutionWorkItem] for a deserialized element. | |
| 41 /// | |
| 42 /// This will not resolved the element but only compute the [WorldImpact]. | |
|
floitsch
2015/06/26 20:54:06
resolve
Johnni Winther
2015/07/03 12:13:45
Done.
| |
| 43 class DeserializedResolutionWorkItem implements ResolutionWorkItem { | |
| 44 final Element element; | |
| 45 final ItemCompilationContext compilationContext; | |
| 46 final WorldImpact worldImpact; | |
| 47 bool _isAnalyzed = false; | |
| 48 | |
| 49 DeserializedResolutionWorkItem( | |
| 50 this.element, this.compilationContext, this.worldImpact); | |
| 51 | |
| 52 @override | |
| 53 bool get isAnalyzed => _isAnalyzed; | |
| 54 | |
| 55 @override | |
| 56 WorldImpact run(Compiler compiler, ResolutionEnqueuer world) { | |
| 57 _isAnalyzed = true; | |
| 58 world.registerResolvedElement(element); | |
| 59 return worldImpact; | |
| 60 } | |
| 61 } | |
| 62 | |
| 63 /// The interface for a system that supports deserialization of libraries and | |
| 64 /// elements. | |
| 65 abstract class DeserializerSystem { | |
| 66 LibraryElement readLibrary(Uri resolvedUri); | |
| 67 bool isDeserialized(Element element); | |
| 68 WorldImpact getWorldImpact(Element element); | |
|
floitsch
2015/06/26 20:54:05
computeWorldImpact?
Johnni Winther
2015/07/03 12:13:45
Done.
| |
| 69 } | |
| OLD | NEW |