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

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

Issue 1581943003: Make reporter customizable (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: No changes, hopefully Created 4 years, 11 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.compiler_base; 5 library dart2js.compiler_base;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 EventSink, 8 EventSink,
9 Future; 9 Future;
10 10
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 import 'universe/use.dart' show 140 import 'universe/use.dart' show
141 StaticUse; 141 StaticUse;
142 import 'universe/world_impact.dart' show 142 import 'universe/world_impact.dart' show
143 WorldImpact; 143 WorldImpact;
144 import 'util/util.dart' show 144 import 'util/util.dart' show
145 Link, 145 Link,
146 Setlet; 146 Setlet;
147 import 'world.dart' show 147 import 'world.dart' show
148 World; 148 World;
149 149
150 typedef Backend MakeBackendFuncion(Compiler compiler);
151
152 typedef CompilerDiagnosticReporter MakeReporterFunction(
153 Compiler compiler, DiagnosticOptions diagnosticOptions);
154
150 abstract class Compiler { 155 abstract class Compiler {
151 /// Helper instance for measurements in [CompilerTask]. 156 /// Helper instance for measurements in [CompilerTask].
152 /// 157 ///
153 /// Note: MUST be first field to ensure [Measurer.wallclock] is started 158 /// Note: MUST be first field to ensure [Measurer.wallclock] is started
154 /// before other computations. 159 /// before other computations.
155 final Measurer measurer = new Measurer(); 160 final Measurer measurer = new Measurer();
156 161
157 int nextFreeClassId = 0; 162 int nextFreeClassId = 0;
158 World world; 163 World world;
159 Types types; 164 Types types;
160 _CompilerCoreTypes _coreTypes; 165 _CompilerCoreTypes _coreTypes;
161 _CompilerDiagnosticReporter _reporter; 166 CompilerDiagnosticReporter _reporter;
162 _CompilerResolution _resolution; 167 _CompilerResolution _resolution;
163 _CompilerParsing _parsing; 168 _CompilerParsing _parsing;
164 169
165 final CacheStrategy cacheStrategy; 170 final CacheStrategy cacheStrategy;
166 171
167 /** 172 /**
168 * Map from token to the first preceding comment token. 173 * Map from token to the first preceding comment token.
169 */ 174 */
170 final TokenMap commentMap = new TokenMap(); 175 final TokenMap commentMap = new TokenMap();
171 176
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 this.useContentSecurityPolicy: false, 456 this.useContentSecurityPolicy: false,
452 bool hasIncrementalSupport: false, 457 bool hasIncrementalSupport: false,
453 this.enableExperimentalMirrors: false, 458 this.enableExperimentalMirrors: false,
454 this.enableAssertMessage: false, 459 this.enableAssertMessage: false,
455 this.allowNativeExtensions: false, 460 this.allowNativeExtensions: false,
456 this.generateCodeWithCompileTimeErrors: false, 461 this.generateCodeWithCompileTimeErrors: false,
457 this.testMode: false, 462 this.testMode: false,
458 DiagnosticOptions diagnosticOptions, 463 DiagnosticOptions diagnosticOptions,
459 api.CompilerOutput outputProvider, 464 api.CompilerOutput outputProvider,
460 List<String> strips: const [], 465 List<String> strips: const [],
461 Backend makeBackend(Compiler compiler)}) 466 MakeBackendFuncion makeBackend,
467 MakeReporterFunction makeReporter})
462 : this.disableTypeInferenceFlag = 468 : this.disableTypeInferenceFlag =
463 disableTypeInferenceFlag || !emitJavaScript, 469 disableTypeInferenceFlag || !emitJavaScript,
464 this.analyzeOnly = 470 this.analyzeOnly =
465 analyzeOnly || analyzeSignaturesOnly || analyzeAllFlag, 471 analyzeOnly || analyzeSignaturesOnly || analyzeAllFlag,
466 this.analyzeSignaturesOnly = analyzeSignaturesOnly, 472 this.analyzeSignaturesOnly = analyzeSignaturesOnly,
467 this.analyzeAllFlag = analyzeAllFlag, 473 this.analyzeAllFlag = analyzeAllFlag,
468 this.hasIncrementalSupport = hasIncrementalSupport, 474 this.hasIncrementalSupport = hasIncrementalSupport,
469 cacheStrategy = new CacheStrategy(hasIncrementalSupport), 475 cacheStrategy = new CacheStrategy(hasIncrementalSupport),
470 this.userOutputProvider = outputProvider == null 476 this.userOutputProvider = outputProvider == null
471 ? const NullCompilerOutput() : outputProvider { 477 ? const NullCompilerOutput() : outputProvider {
472 if (hasIncrementalSupport) { 478 if (hasIncrementalSupport) {
473 // TODO(ahe): This is too much. Any method from platform and package 479 // TODO(ahe): This is too much. Any method from platform and package
474 // libraries can be inlined. 480 // libraries can be inlined.
475 disableInlining = true; 481 disableInlining = true;
476 } 482 }
477 world = new World(this); 483 world = new World(this);
478 // TODO(johnniwinther): Initialize core types in [initializeCoreClasses] and 484 if (makeReporter != null) {
479 // make its field final. 485 _reporter = makeReporter(this, diagnosticOptions);
480 _reporter = new _CompilerDiagnosticReporter(this, diagnosticOptions); 486 } else {
487 // TODO(johnniwinther): Initialize core types in [initializeCoreClasses]
488 // and make its field final.
489 _reporter = new CompilerDiagnosticReporter(this, diagnosticOptions);
490 }
481 _parsing = new _CompilerParsing(this); 491 _parsing = new _CompilerParsing(this);
482 _resolution = new _CompilerResolution(this); 492 _resolution = new _CompilerResolution(this);
483 _coreTypes = new _CompilerCoreTypes(_resolution); 493 _coreTypes = new _CompilerCoreTypes(_resolution);
484 types = new Types(_resolution); 494 types = new Types(_resolution);
485 tracer = new Tracer(this, this.outputProvider); 495 tracer = new Tracer(this, this.outputProvider);
486 496
487 if (verbose) { 497 if (verbose) {
488 progress = new Stopwatch()..start(); 498 progress = new Stopwatch()..start();
489 } 499 }
490 500
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 InterfaceType streamType([DartType elementType]) { 1618 InterfaceType streamType([DartType elementType]) {
1609 streamClass.ensureResolved(resolution); 1619 streamClass.ensureResolved(resolution);
1610 InterfaceType type = streamClass.rawType; 1620 InterfaceType type = streamClass.rawType;
1611 if (elementType == null) { 1621 if (elementType == null) {
1612 return type; 1622 return type;
1613 } 1623 }
1614 return type.createInstantiation([elementType]); 1624 return type.createInstantiation([elementType]);
1615 } 1625 }
1616 } 1626 }
1617 1627
1618 class _CompilerDiagnosticReporter extends DiagnosticReporter { 1628 class CompilerDiagnosticReporter extends DiagnosticReporter {
1619 final Compiler compiler; 1629 final Compiler compiler;
1620 final DiagnosticOptions options; 1630 final DiagnosticOptions options;
1621 1631
1622 Element _currentElement; 1632 Element _currentElement;
1623 bool hasCrashed = false; 1633 bool hasCrashed = false;
1624 1634
1625 /// `true` if the last diagnostic was filtered, in which case the 1635 /// `true` if the last diagnostic was filtered, in which case the
1626 /// accompanying info message should be filtered as well. 1636 /// accompanying info message should be filtered as well.
1627 bool lastDiagnosticWasFiltered = false; 1637 bool lastDiagnosticWasFiltered = false;
1628 1638
1629 /// Map containing information about the warnings and hints that have been 1639 /// Map containing information about the warnings and hints that have been
1630 /// suppressed for each library. 1640 /// suppressed for each library.
1631 Map<Uri, SuppressionInfo> suppressedWarnings = <Uri, SuppressionInfo>{}; 1641 Map<Uri, SuppressionInfo> suppressedWarnings = <Uri, SuppressionInfo>{};
1632 1642
1633 _CompilerDiagnosticReporter(this.compiler, this.options); 1643 CompilerDiagnosticReporter(this.compiler, this.options);
1634 1644
1635 Element get currentElement => _currentElement; 1645 Element get currentElement => _currentElement;
1636 1646
1637 DiagnosticMessage createMessage( 1647 DiagnosticMessage createMessage(
1638 Spannable spannable, 1648 Spannable spannable,
1639 MessageKind messageKind, 1649 MessageKind messageKind,
1640 [Map arguments = const {}]) { 1650 [Map arguments = const {}]) {
1641 SourceSpan span = spanFromSpannable(spannable); 1651 SourceSpan span = spanFromSpannable(spannable);
1642 MessageTemplate template = MessageTemplate.TEMPLATES[messageKind]; 1652 MessageTemplate template = MessageTemplate.TEMPLATES[messageKind];
1643 Message message = template.message(arguments, options.terseDiagnostics); 1653 Message message = template.message(arguments, options.terseDiagnostics);
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 if (_otherDependencies == null) { 2107 if (_otherDependencies == null) {
2098 _otherDependencies = new Setlet<Element>(); 2108 _otherDependencies = new Setlet<Element>();
2099 } 2109 }
2100 _otherDependencies.add(element.implementation); 2110 _otherDependencies.add(element.implementation);
2101 } 2111 }
2102 2112
2103 Iterable<Element> get otherDependencies { 2113 Iterable<Element> get otherDependencies {
2104 return _otherDependencies != null ? _otherDependencies : const <Element>[]; 2114 return _otherDependencies != null ? _otherDependencies : const <Element>[];
2105 } 2115 }
2106 } 2116 }
OLDNEW
« pkg/compiler/lib/src/apiimpl.dart ('K') | « pkg/compiler/lib/src/apiimpl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698