| 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 | 8 |
| 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; |
| 11 import '../common/work.dart' show ItemCompilationContext; | |
| 12 import '../compiler.dart' show Compiler; | 11 import '../compiler.dart' show Compiler; |
| 13 import '../elements/elements.dart'; | 12 import '../elements/elements.dart'; |
| 14 import '../enqueue.dart' show ResolutionEnqueuer; | 13 import '../enqueue.dart' show ResolutionEnqueuer; |
| 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. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 return deserializer != null && deserializer.hasResolutionImpact(element); | 63 return deserializer != null && deserializer.hasResolutionImpact(element); |
| 65 } | 64 } |
| 66 | 65 |
| 67 ResolutionImpact getResolutionImpact(Element element) { | 66 ResolutionImpact getResolutionImpact(Element element) { |
| 68 return deserializer != null | 67 return deserializer != null |
| 69 ? deserializer.getResolutionImpact(element) | 68 ? deserializer.getResolutionImpact(element) |
| 70 : null; | 69 : null; |
| 71 } | 70 } |
| 72 | 71 |
| 73 /// Creates the [ResolutionWorkItem] for the deserialized [element]. | 72 /// Creates the [ResolutionWorkItem] for the deserialized [element]. |
| 74 ResolutionWorkItem createResolutionWorkItem( | 73 ResolutionWorkItem createResolutionWorkItem(Element element) { |
| 75 Element element, ItemCompilationContext context) { | |
| 76 assert(deserializer != null); | 74 assert(deserializer != null); |
| 77 assert(isDeserialized(element)); | 75 assert(isDeserialized(element)); |
| 78 return new DeserializedResolutionWorkItem( | 76 return new DeserializedResolutionWorkItem( |
| 79 element, context, deserializer.computeWorldImpact(element)); | 77 element, deserializer.computeWorldImpact(element)); |
| 80 } | 78 } |
| 81 | 79 |
| 82 bool hasResolvedAst(ExecutableElement element) { | 80 bool hasResolvedAst(ExecutableElement element) { |
| 83 return deserializer != null ? deserializer.hasResolvedAst(element) : false; | 81 return deserializer != null ? deserializer.hasResolvedAst(element) : false; |
| 84 } | 82 } |
| 85 | 83 |
| 86 ResolvedAst getResolvedAst(ExecutableElement element) { | 84 ResolvedAst getResolvedAst(ExecutableElement element) { |
| 87 return deserializer != null ? deserializer.getResolvedAst(element) : null; | 85 return deserializer != null ? deserializer.getResolvedAst(element) : null; |
| 88 } | 86 } |
| 89 | 87 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 context.deserializers.add(dataDeserializer); | 130 context.deserializers.add(dataDeserializer); |
| 133 }); | 131 }); |
| 134 } | 132 } |
| 135 } | 133 } |
| 136 | 134 |
| 137 /// A [ResolutionWorkItem] for a deserialized element. | 135 /// A [ResolutionWorkItem] for a deserialized element. |
| 138 /// | 136 /// |
| 139 /// This will not resolve the element but only compute the [WorldImpact]. | 137 /// This will not resolve the element but only compute the [WorldImpact]. |
| 140 class DeserializedResolutionWorkItem implements ResolutionWorkItem { | 138 class DeserializedResolutionWorkItem implements ResolutionWorkItem { |
| 141 final Element element; | 139 final Element element; |
| 142 final ItemCompilationContext compilationContext; | |
| 143 final WorldImpact worldImpact; | 140 final WorldImpact worldImpact; |
| 144 bool _isAnalyzed = false; | 141 bool _isAnalyzed = false; |
| 145 | 142 |
| 146 DeserializedResolutionWorkItem( | 143 DeserializedResolutionWorkItem(this.element, this.worldImpact); |
| 147 this.element, this.compilationContext, this.worldImpact); | |
| 148 | 144 |
| 149 @override | 145 @override |
| 150 bool get isAnalyzed => _isAnalyzed; | 146 bool get isAnalyzed => _isAnalyzed; |
| 151 | 147 |
| 152 @override | 148 @override |
| 153 WorldImpact run(Compiler compiler, ResolutionEnqueuer world) { | 149 WorldImpact run(Compiler compiler, ResolutionEnqueuer world) { |
| 154 _isAnalyzed = true; | 150 _isAnalyzed = true; |
| 155 world.registerProcessedElement(element); | 151 world.registerProcessedElement(element); |
| 156 return worldImpact; | 152 return worldImpact; |
| 157 } | 153 } |
| 158 } | 154 } |
| 159 | 155 |
| 160 /// The interface for a system that supports deserialization of libraries and | 156 /// The interface for a system that supports deserialization of libraries and |
| 161 /// elements. | 157 /// elements. |
| 162 abstract class DeserializerSystem { | 158 abstract class DeserializerSystem { |
| 163 Future<LibraryElement> readLibrary(Uri resolvedUri); | 159 Future<LibraryElement> readLibrary(Uri resolvedUri); |
| 164 bool isDeserialized(Element element); | 160 bool isDeserialized(Element element); |
| 165 bool hasResolvedAst(ExecutableElement element); | 161 bool hasResolvedAst(ExecutableElement element); |
| 166 ResolvedAst getResolvedAst(ExecutableElement element); | 162 ResolvedAst getResolvedAst(ExecutableElement element); |
| 167 bool hasResolutionImpact(Element element); | 163 bool hasResolutionImpact(Element element); |
| 168 ResolutionImpact getResolutionImpact(Element element); | 164 ResolutionImpact getResolutionImpact(Element element); |
| 169 WorldImpact computeWorldImpact(Element element); | 165 WorldImpact computeWorldImpact(Element element); |
| 170 } | 166 } |
| OLD | NEW |