Chromium Code Reviews| 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 'cache_strategy.dart'; | 9 import 'cache_strategy.dart'; |
| 10 import 'common/backend_api.dart' show Backend; | 10 import 'common/backend_api.dart' show Backend; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 CacheStrategy cacheStrategy, | 161 CacheStrategy cacheStrategy, |
| 162 [this.name = 'resolution enqueuer']) | 162 [this.name = 'resolution enqueuer']) |
| 163 : this.backend = backend, | 163 : this.backend = backend, |
| 164 this._resolution = resolution, | 164 this._resolution = resolution, |
| 165 this.nativeEnqueuer = backend.nativeResolutionEnqueuer(), | 165 this.nativeEnqueuer = backend.nativeResolutionEnqueuer(), |
| 166 _universe = new ResolutionWorldBuilderImpl( | 166 _universe = new ResolutionWorldBuilderImpl( |
| 167 backend, resolution, cacheStrategy, const OpenWorldStrategy()) { | 167 backend, resolution, cacheStrategy, const OpenWorldStrategy()) { |
| 168 _impactVisitor = new EnqueuerImplImpactVisitor(this); | 168 _impactVisitor = new EnqueuerImplImpactVisitor(this); |
| 169 } | 169 } |
| 170 | 170 |
| 171 ResolutionWorldBuilder get universe => _universe; | 171 ResolutionWorldBuilder get universe => _universe; |
|
Siggi Cherem (dart-lang)
2016/12/20 15:42:33
let's add a TODO: rename `universe` to `worldBuild
Johnni Winther
2016/12/21 08:52:28
Added a TODO to [Enqueuer.universe].
_universe ha
| |
| 172 | 172 |
| 173 OpenWorld get _openWorld => universe.openWorld; | |
| 174 | |
| 175 bool get queueIsEmpty => _queue.isEmpty; | 173 bool get queueIsEmpty => _queue.isEmpty; |
| 176 | 174 |
| 177 DiagnosticReporter get _reporter => _resolution.reporter; | 175 DiagnosticReporter get _reporter => _resolution.reporter; |
| 178 | 176 |
| 179 Iterable<ClassEntity> get processedClasses => _universe.processedClasses; | 177 Iterable<ClassEntity> get processedClasses => _universe.processedClasses; |
| 180 | 178 |
| 181 void applyImpact(WorldImpact worldImpact, {var impactSource}) { | 179 void applyImpact(WorldImpact worldImpact, {var impactSource}) { |
| 182 if (worldImpact.isEmpty) return; | 180 if (worldImpact.isEmpty) return; |
| 183 impactStrategy.visitImpact( | 181 impactStrategy.visitImpact( |
| 184 impactSource, worldImpact, _impactVisitor, impactUse); | 182 impactSource, worldImpact, _impactVisitor, impactUse); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 case TypeUseKind.CATCH_TYPE: | 291 case TypeUseKind.CATCH_TYPE: |
| 294 _registerIsCheck(type); | 292 _registerIsCheck(type); |
| 295 break; | 293 break; |
| 296 case TypeUseKind.CHECKED_MODE_CHECK: | 294 case TypeUseKind.CHECKED_MODE_CHECK: |
| 297 if (_options.enableTypeAssertions) { | 295 if (_options.enableTypeAssertions) { |
| 298 _registerIsCheck(type); | 296 _registerIsCheck(type); |
| 299 } | 297 } |
| 300 break; | 298 break; |
| 301 case TypeUseKind.TYPE_LITERAL: | 299 case TypeUseKind.TYPE_LITERAL: |
| 302 if (type.isTypedef) { | 300 if (type.isTypedef) { |
| 303 universe.openWorld.registerTypedef(type.element); | 301 universe.registerTypedef(type.element); |
| 304 } | 302 } |
| 305 break; | 303 break; |
| 306 } | 304 } |
| 307 } | 305 } |
| 308 | 306 |
| 309 void _registerIsCheck(DartType type) { | 307 void _registerIsCheck(DartType type) { |
| 310 type = _universe.registerIsCheck(type); | 308 type = _universe.registerIsCheck(type); |
| 311 // Even in checked mode, type annotations for return type and argument | 309 // Even in checked mode, type annotations for return type and argument |
| 312 // types do not imply type checks, so there should never be a check | 310 // types do not imply type checks, so there should never be a check |
| 313 // against the type variable of a typedef. | 311 // against the type variable of a typedef. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 | 377 |
| 380 assert(invariant(element, element is AnalyzableElement, | 378 assert(invariant(element, element is AnalyzableElement, |
| 381 message: 'Element $element is not analyzable.')); | 379 message: 'Element $element is not analyzable.')); |
| 382 if (hasBeenProcessed(element)) return; | 380 if (hasBeenProcessed(element)) return; |
| 383 if (queueIsClosed) { | 381 if (queueIsClosed) { |
| 384 throw new SpannableAssertionFailure( | 382 throw new SpannableAssertionFailure( |
| 385 element, "Resolution work list is closed. Trying to add $element."); | 383 element, "Resolution work list is closed. Trying to add $element."); |
| 386 } | 384 } |
| 387 | 385 |
| 388 applyImpact(backend.registerUsedElement(element, forResolution: true)); | 386 applyImpact(backend.registerUsedElement(element, forResolution: true)); |
| 389 _openWorld.registerUsedElement(element); | 387 _universe.registerUsedElement(element); |
| 390 | 388 |
| 391 ResolutionWorkItem workItem = _resolution.createWorkItem(element); | 389 ResolutionWorkItem workItem = _resolution.createWorkItem(element); |
| 392 _queue.add(workItem); | 390 _queue.add(workItem); |
| 393 } | 391 } |
| 394 | 392 |
| 395 /// Adds an action to the deferred task queue. | 393 /// Adds an action to the deferred task queue. |
| 396 /// The action is performed the next time the resolution queue has been | 394 /// The action is performed the next time the resolution queue has been |
| 397 /// emptied. | 395 /// emptied. |
| 398 /// | 396 /// |
| 399 /// The queue is processed in FIFO order. | 397 /// The queue is processed in FIFO order. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 } | 522 } |
| 525 | 523 |
| 526 typedef void _DeferredActionFunction(); | 524 typedef void _DeferredActionFunction(); |
| 527 | 525 |
| 528 class _DeferredAction { | 526 class _DeferredAction { |
| 529 final Element element; | 527 final Element element; |
| 530 final _DeferredActionFunction action; | 528 final _DeferredActionFunction action; |
| 531 | 529 |
| 532 _DeferredAction(this.element, this.action); | 530 _DeferredAction(this.element, this.action); |
| 533 } | 531 } |
| OLD | NEW |