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

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

Issue 1383483006: Extract DiagnosticReporter implementation from Compiler. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fixes after rebase. Created 5 years, 2 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
« no previous file with comments | « pkg/compiler/lib/src/elements/modelx.dart ('k') | pkg/compiler/lib/src/helpers/helpers.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7 import 'dart:collection' show
8 Queue; 8 Queue;
9 9
10 import 'common/names.dart' show 10 import 'common/names.dart' show
11 Identifiers; 11 Identifiers;
12 import 'common/resolution.dart' show 12 import 'common/resolution.dart' show
13 Resolution; 13 Resolution;
14 import 'common/work.dart' show 14 import 'common/work.dart' show
15 ItemCompilationContext, 15 ItemCompilationContext,
16 WorkItem; 16 WorkItem;
17 import 'common/tasks.dart' show 17 import 'common/tasks.dart' show
18 CompilerTask, 18 CompilerTask,
19 DeferredAction, 19 DeferredAction,
20 DeferredTask; 20 DeferredTask;
21 import 'common/codegen.dart' show 21 import 'common/codegen.dart' show
22 CodegenWorkItem; 22 CodegenWorkItem;
23 import 'common/resolution.dart' show 23 import 'common/resolution.dart' show
24 ResolutionWorkItem; 24 ResolutionWorkItem;
25 import 'compiler.dart' show 25 import 'compiler.dart' show
26 Compiler; 26 Compiler;
27 import 'dart_types.dart' show 27 import 'dart_types.dart' show
28 DartType, 28 DartType,
29 InterfaceType; 29 InterfaceType;
30 import 'diagnostics/diagnostic_listener.dart' show
31 DiagnosticReporter;
30 import 'diagnostics/invariant.dart' show 32 import 'diagnostics/invariant.dart' show
31 invariant; 33 invariant;
32 import 'diagnostics/spannable.dart' show 34 import 'diagnostics/spannable.dart' show
33 SpannableAssertionFailure; 35 SpannableAssertionFailure;
34 import 'elements/elements.dart' show 36 import 'elements/elements.dart' show
35 AnalyzableElement, 37 AnalyzableElement,
36 AstElement, 38 AstElement,
37 ClassElement, 39 ClassElement,
38 ConstructorElement, 40 ConstructorElement,
39 Element, 41 Element,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 Resolution get resolution => compiler.resolution; 149 Resolution get resolution => compiler.resolution;
148 150
149 Queue<WorkItem> get queue; 151 Queue<WorkItem> get queue;
150 bool get queueIsEmpty => queue.isEmpty; 152 bool get queueIsEmpty => queue.isEmpty;
151 153
152 /// Returns [:true:] if this enqueuer is the resolution enqueuer. 154 /// Returns [:true:] if this enqueuer is the resolution enqueuer.
153 bool get isResolutionQueue => false; 155 bool get isResolutionQueue => false;
154 156
155 QueueFilter get filter => compiler.enqueuerFilter; 157 QueueFilter get filter => compiler.enqueuerFilter;
156 158
159 DiagnosticReporter get reporter => compiler.reporter;
160
157 /// Returns [:true:] if [member] has been processed by this enqueuer. 161 /// Returns [:true:] if [member] has been processed by this enqueuer.
158 bool isProcessed(Element member); 162 bool isProcessed(Element member);
159 163
160 /** 164 /**
161 * Documentation wanted -- johnniwinther 165 * Documentation wanted -- johnniwinther
162 * 166 *
163 * Invariant: [element] must be a declaration element. 167 * Invariant: [element] must be a declaration element.
164 */ 168 */
165 void addToWorkList(Element element) { 169 void addToWorkList(Element element) {
166 assert(invariant(element, element.isDeclaration)); 170 assert(invariant(element, element.isDeclaration));
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 void enqueueReflectiveElements(Iterable<ClassElement> recents) { 523 void enqueueReflectiveElements(Iterable<ClassElement> recents) {
520 if (!hasEnqueuedReflectiveElements) { 524 if (!hasEnqueuedReflectiveElements) {
521 logEnqueueReflectiveAction("!START enqueueAll"); 525 logEnqueueReflectiveAction("!START enqueueAll");
522 // First round of enqueuing, visit everything that is visible to 526 // First round of enqueuing, visit everything that is visible to
523 // also pick up static top levels, etc. 527 // also pick up static top levels, etc.
524 // Also, during the first round, consider all classes that have been seen 528 // Also, during the first round, consider all classes that have been seen
525 // as recently seen, as we do not know how many rounds of resolution might 529 // as recently seen, as we do not know how many rounds of resolution might
526 // have run before tree shaking is disabled and thus everything is 530 // have run before tree shaking is disabled and thus everything is
527 // enqueued. 531 // enqueued.
528 recents = _processedClasses.toSet(); 532 recents = _processedClasses.toSet();
529 compiler.log('Enqueuing everything'); 533 reporter.log('Enqueuing everything');
530 for (LibraryElement lib in compiler.libraryLoader.libraries) { 534 for (LibraryElement lib in compiler.libraryLoader.libraries) {
531 enqueueReflectiveElementsInLibrary(lib, recents); 535 enqueueReflectiveElementsInLibrary(lib, recents);
532 } 536 }
533 enqueueReflectiveSpecialClasses(); 537 enqueueReflectiveSpecialClasses();
534 hasEnqueuedReflectiveElements = true; 538 hasEnqueuedReflectiveElements = true;
535 hasEnqueuedReflectiveStaticFields = true; 539 hasEnqueuedReflectiveStaticFields = true;
536 logEnqueueReflectiveAction("!DONE enqueueAll"); 540 logEnqueueReflectiveAction("!DONE enqueueAll");
537 } else if (recents.isNotEmpty) { 541 } else if (recents.isNotEmpty) {
538 // Keep looking at new classes until fixpoint is reached. 542 // Keep looking at new classes until fixpoint is reached.
539 logEnqueueReflectiveAction("!START enqueueRecents"); 543 logEnqueueReflectiveAction("!START enqueueRecents");
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 } 900 }
897 901
898 bool onQueueEmpty(Iterable<ClassElement> recentClasses) { 902 bool onQueueEmpty(Iterable<ClassElement> recentClasses) {
899 emptyDeferredTaskQueue(); 903 emptyDeferredTaskQueue();
900 return super.onQueueEmpty(recentClasses); 904 return super.onQueueEmpty(recentClasses);
901 } 905 }
902 906
903 void emptyDeferredTaskQueue() { 907 void emptyDeferredTaskQueue() {
904 while (!deferredTaskQueue.isEmpty) { 908 while (!deferredTaskQueue.isEmpty) {
905 DeferredTask task = deferredTaskQueue.removeFirst(); 909 DeferredTask task = deferredTaskQueue.removeFirst();
906 compiler.withCurrentElement(task.element, task.action); 910 reporter.withCurrentElement(task.element, task.action);
907 } 911 }
908 } 912 }
909 913
910 void _logSpecificSummary(log(message)) { 914 void _logSpecificSummary(log(message)) {
911 log('Resolved ${resolvedElements.length} elements.'); 915 log('Resolved ${resolvedElements.length} elements.');
912 } 916 }
913 917
914 void forgetElement(Element element) { 918 void forgetElement(Element element) {
915 super.forgetElement(element); 919 super.forgetElement(element);
916 resolvedElements.remove(element); 920 resolvedElements.remove(element);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 @override 1069 @override
1066 void processStaticUse(Enqueuer enqueuer, Element element) { 1070 void processStaticUse(Enqueuer enqueuer, Element element) {
1067 enqueuer.registerStaticUseInternal(element); 1071 enqueuer.registerStaticUseInternal(element);
1068 } 1072 }
1069 1073
1070 @override 1074 @override
1071 void processSelector(Enqueuer enqueuer, UniverseSelector selector) { 1075 void processSelector(Enqueuer enqueuer, UniverseSelector selector) {
1072 enqueuer.handleUnseenSelectorInternal(selector); 1076 enqueuer.handleUnseenSelectorInternal(selector);
1073 } 1077 }
1074 } 1078 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/elements/modelx.dart ('k') | pkg/compiler/lib/src/helpers/helpers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698