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.enqueue; | 5 library dart2js.enqueue; |
6 | 6 |
7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
8 | 8 |
9 import 'common/resolution.dart' show Resolution; | 9 import 'common/resolution.dart' show Resolution; |
10 import 'common/tasks.dart' show CompilerTask; | 10 import 'common/tasks.dart' show CompilerTask; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 /// processed and its elements do not need to be seen in the next round. When | 140 /// processed and its elements do not need to be seen in the next round. When |
141 /// `false` is returned, [onQueueEmpty] will be called again once the | 141 /// `false` is returned, [onQueueEmpty] will be called again once the |
142 /// resolution queue has drained and [recentClasses] will be a superset of the | 142 /// resolution queue has drained and [recentClasses] will be a superset of the |
143 /// current value. | 143 /// current value. |
144 /// | 144 /// |
145 /// There is no guarantee that a class is only present once in | 145 /// There is no guarantee that a class is only present once in |
146 /// [recentClasses], but every class seen by the [enqueuer] will be present in | 146 /// [recentClasses], but every class seen by the [enqueuer] will be present in |
147 /// [recentClasses] at least once. | 147 /// [recentClasses] at least once. |
148 bool onQueueEmpty(Enqueuer enqueuer, Iterable<ClassEntity> recentClasses); | 148 bool onQueueEmpty(Enqueuer enqueuer, Iterable<ClassEntity> recentClasses); |
149 | 149 |
| 150 /// Called when to the queue has been closed. |
| 151 void onQueueClosed(); |
| 152 |
150 /// Called when to the queue is emptied. | 153 /// Called when to the queue is emptied. |
151 void logSummary(void log(String message)); | 154 void logSummary(void log(String message)); |
152 } | 155 } |
153 | 156 |
154 abstract class EnqueuerImpl extends Enqueuer { | 157 abstract class EnqueuerImpl extends Enqueuer { |
155 CompilerTask get task; | 158 CompilerTask get task; |
156 EnqueuerStrategy get strategy; | 159 EnqueuerStrategy get strategy; |
157 void checkClass(ClassEntity cls); | 160 void checkClass(ClassEntity cls); |
158 void processStaticUse(StaticUse staticUse); | 161 void processStaticUse(StaticUse staticUse); |
159 void processTypeUse(TypeUse typeUse); | 162 void processTypeUse(TypeUse typeUse); |
160 void processDynamicUse(DynamicUse dynamicUse); | 163 void processDynamicUse(DynamicUse dynamicUse); |
161 void processConstantUse(ConstantUse constantUse); | 164 void processConstantUse(ConstantUse constantUse); |
162 EnqueuerListener get listener; | 165 EnqueuerListener get listener; |
163 | 166 |
164 // TODO(johnniwinther): Initialize [_impactStrategy] to `null`. | 167 // TODO(johnniwinther): Initialize [_impactStrategy] to `null`. |
165 ImpactStrategy _impactStrategy = const ImpactStrategy(); | 168 ImpactStrategy _impactStrategy = const ImpactStrategy(); |
166 | 169 |
167 ImpactStrategy get impactStrategy => _impactStrategy; | 170 ImpactStrategy get impactStrategy => _impactStrategy; |
168 | 171 |
169 void open(ImpactStrategy impactStrategy, FunctionEntity mainMethod, | 172 void open(ImpactStrategy impactStrategy, FunctionEntity mainMethod, |
170 Iterable<LibraryEntity> libraries) { | 173 Iterable<LibraryEntity> libraries) { |
171 _impactStrategy = impactStrategy; | 174 _impactStrategy = impactStrategy; |
172 listener.onQueueOpen(this, mainMethod, libraries); | 175 listener.onQueueOpen(this, mainMethod, libraries); |
173 } | 176 } |
174 | 177 |
175 void close() { | 178 void close() { |
176 // TODO(johnniwinther): Set [_impactStrategy] to `null` and [queueIsClosed] | 179 // TODO(johnniwinther): Set [_impactStrategy] to `null` and [queueIsClosed] |
177 // to `true` here. | 180 // to `true` here. |
178 _impactStrategy = const ImpactStrategy(); | 181 _impactStrategy = const ImpactStrategy(); |
| 182 listener.onQueueClosed(); |
179 } | 183 } |
180 } | 184 } |
181 | 185 |
182 /// [Enqueuer] which is specific to resolution. | 186 /// [Enqueuer] which is specific to resolution. |
183 class ResolutionEnqueuer extends EnqueuerImpl { | 187 class ResolutionEnqueuer extends EnqueuerImpl { |
184 static const ImpactUseCase IMPACT_USE = | 188 static const ImpactUseCase IMPACT_USE = |
185 const ImpactUseCase('ResolutionEnqueuer'); | 189 const ImpactUseCase('ResolutionEnqueuer'); |
186 | 190 |
187 final CompilerTask task; | 191 final CompilerTask task; |
188 final String name; | 192 final String name; |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 @override | 607 @override |
604 WorkItem createWorkItem(MemberElement element) { | 608 WorkItem createWorkItem(MemberElement element) { |
605 assert(invariant(element, element.isDeclaration)); | 609 assert(invariant(element, element.isDeclaration)); |
606 if (element.isMalformed) return null; | 610 if (element.isMalformed) return null; |
607 | 611 |
608 assert(invariant(element, element is AnalyzableElement, | 612 assert(invariant(element, element is AnalyzableElement, |
609 message: 'Element $element is not analyzable.')); | 613 message: 'Element $element is not analyzable.')); |
610 return _resolution.createWorkItem(element); | 614 return _resolution.createWorkItem(element); |
611 } | 615 } |
612 } | 616 } |
OLD | NEW |