Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: pkg/compiler/lib/src/enqueue.dart

Issue 2982783003: Use failedAt in more places (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/tasks.dart' show CompilerTask; 9 import 'common/tasks.dart' show CompilerTask;
10 import 'common/work.dart' show WorkItem; 10 import 'common/work.dart' show WorkItem;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 _impactVisitor = new EnqueuerImplImpactVisitor(this); 223 _impactVisitor = new EnqueuerImplImpactVisitor(this);
224 } 224 }
225 225
226 ResolutionWorldBuilder get worldBuilder => _worldBuilder; 226 ResolutionWorldBuilder get worldBuilder => _worldBuilder;
227 227
228 bool get queueIsEmpty => _queue.isEmpty; 228 bool get queueIsEmpty => _queue.isEmpty;
229 229
230 @override 230 @override
231 void checkQueueIsEmpty() { 231 void checkQueueIsEmpty() {
232 if (_queue.isNotEmpty) { 232 if (_queue.isNotEmpty) {
233 throw new SpannableAssertionFailure( 233 failedAt(_queue.first.element, "$name queue is not empty.");
234 _queue.first.element, "$name queue is not empty.");
235 } 234 }
236 } 235 }
237 236
238 Iterable<ClassEntity> get processedClasses => _worldBuilder.processedClasses; 237 Iterable<ClassEntity> get processedClasses => _worldBuilder.processedClasses;
239 238
240 void applyImpact(WorldImpact worldImpact, {var impactSource}) { 239 void applyImpact(WorldImpact worldImpact, {var impactSource}) {
241 if (worldImpact.isEmpty) return; 240 if (worldImpact.isEmpty) return;
242 impactStrategy.visitImpact( 241 impactStrategy.visitImpact(
243 impactSource, worldImpact, _impactVisitor, impactUse); 242 impactSource, worldImpact, _impactVisitor, impactUse);
244 } 243 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 } 427 }
429 428
430 /// Create a [WorkItem] for [entity] and add it to the work list if it has not 429 /// Create a [WorkItem] for [entity] and add it to the work list if it has not
431 /// already been processed. 430 /// already been processed.
432 void _addToWorkList(MemberEntity entity) { 431 void _addToWorkList(MemberEntity entity) {
433 if (_processedEntities.contains(entity)) return; 432 if (_processedEntities.contains(entity)) return;
434 WorkItem workItem = _workItemBuilder.createWorkItem(entity); 433 WorkItem workItem = _workItemBuilder.createWorkItem(entity);
435 if (workItem == null) return; 434 if (workItem == null) return;
436 435
437 if (queueIsClosed) { 436 if (queueIsClosed) {
438 throw new SpannableAssertionFailure( 437 failedAt(
439 entity, "Resolution work list is closed. Trying to add $entity."); 438 entity, "Resolution work list is closed. Trying to add $entity.");
440 } 439 }
441 440
442 applyImpact(listener.registerUsedElement(entity), 441 applyImpact(listener.registerUsedElement(entity),
443 impactSource: 'used element'); 442 impactSource: 'used element');
444 _worldBuilder.registerUsedElement(entity); 443 _worldBuilder.registerUsedElement(entity);
445 _queue.add(workItem); 444 _queue.add(workItem);
446 } 445 }
447 446
448 /// Adds an action to the deferred task queue. 447 /// Adds an action to the deferred task queue.
449 /// The action is performed the next time the resolution queue has been 448 /// The action is performed the next time the resolution queue has been
450 /// emptied. 449 /// emptied.
451 /// 450 ///
452 /// The queue is processed in FIFO order. 451 /// The queue is processed in FIFO order.
453 void addDeferredAction(DeferredAction deferredAction) { 452 void addDeferredAction(DeferredAction deferredAction) {
454 if (queueIsClosed) { 453 if (queueIsClosed) {
455 throw new SpannableAssertionFailure( 454 failedAt(
456 deferredAction.element, 455 deferredAction.element,
457 "Resolution work list is closed. " 456 "Resolution work list is closed. "
458 "Trying to add deferred action for ${deferredAction.element}"); 457 "Trying to add deferred action for ${deferredAction.element}");
459 } 458 }
460 _deferredQueue.add(deferredAction); 459 _deferredQueue.add(deferredAction);
461 } 460 }
462 461
463 void addDeferredActions(Iterable<DeferredAction> deferredActions) { 462 void addDeferredActions(Iterable<DeferredAction> deferredActions) {
464 deferredActions.forEach(addDeferredAction); 463 deferredActions.forEach(addDeferredAction);
465 } 464 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 final Entity element; 596 final Entity element;
598 final DeferredActionFunction action; 597 final DeferredActionFunction action;
599 598
600 DeferredAction(this.element, this.action); 599 DeferredAction(this.element, this.action);
601 } 600 }
602 601
603 /// Interface for creating work items for enqueued member entities. 602 /// Interface for creating work items for enqueued member entities.
604 abstract class WorkItemBuilder { 603 abstract class WorkItemBuilder {
605 WorkItem createWorkItem(covariant MemberEntity entity); 604 WorkItem createWorkItem(covariant MemberEntity entity);
606 } 605 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/elements/modelx.dart ('k') | pkg/compiler/lib/src/inferrer/inferrer_engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698