OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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.common.registry; | 5 library dart2js.common.registry; |
6 | 6 |
| 7 import '../dart_types.dart' show InterfaceType; |
7 import '../elements/elements.dart' show Element; | 8 import '../elements/elements.dart' show Element; |
| 9 import '../enqueue.dart' show Enqueuer; |
| 10 import '../universe/use.dart' show DynamicUse, StaticUse; |
| 11 |
| 12 /// Interface for registration of element dependencies. |
| 13 abstract class Registry { |
| 14 // TODO(johnniwinther): Remove this. |
| 15 void registerDependency(Element element) {} |
| 16 |
| 17 bool get isForResolution; |
| 18 |
| 19 void registerDynamicUse(DynamicUse staticUse); |
| 20 |
| 21 void registerStaticUse(StaticUse staticUse); |
| 22 |
| 23 void registerInstantiation(InterfaceType type); |
| 24 } |
8 | 25 |
9 // TODO(johnniwinther): Remove this. | 26 // TODO(johnniwinther): Remove this. |
10 /// Interface for registration of element dependencies. | 27 class EagerRegistry extends Registry { |
11 abstract class Registry { | 28 final String name; |
12 void registerDependency(Element element) {} | 29 final Enqueuer world; |
| 30 |
| 31 EagerRegistry(this.name, this.world); |
| 32 |
| 33 bool get isForResolution => world.isResolutionQueue; |
| 34 |
| 35 @override |
| 36 void registerDynamicUse(DynamicUse dynamicUse) { |
| 37 world.registerDynamicUse(dynamicUse); |
| 38 } |
| 39 |
| 40 @override |
| 41 void registerInstantiation(InterfaceType type) { |
| 42 world.registerInstantiatedType(type); |
| 43 } |
| 44 |
| 45 @override |
| 46 void registerStaticUse(StaticUse staticUse) { |
| 47 world.registerStaticUse(staticUse); |
| 48 } |
| 49 |
| 50 String toString() => name; |
13 } | 51 } |
OLD | NEW |