| 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.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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 * URI of the main source map if the compiler is generating source | 239 * URI of the main source map if the compiler is generating source |
| 240 * maps. | 240 * maps. |
| 241 */ | 241 */ |
| 242 final Uri sourceMapUri; | 242 final Uri sourceMapUri; |
| 243 | 243 |
| 244 /** | 244 /** |
| 245 * URI of the main output if the compiler is generating source maps. | 245 * URI of the main output if the compiler is generating source maps. |
| 246 */ | 246 */ |
| 247 final Uri outputUri; | 247 final Uri outputUri; |
| 248 | 248 |
| 249 /// Emit terse diagnostics without howToFix. | |
| 250 final bool terseDiagnostics; | |
| 251 | |
| 252 /// If `true`, warnings and hints not from user code are reported. | |
| 253 final bool showPackageWarnings; | |
| 254 | |
| 255 final bool suppressWarnings; | |
| 256 final bool fatalWarnings; | |
| 257 | |
| 258 /// If `true`, some values are cached for reuse in incremental compilation. | 249 /// If `true`, some values are cached for reuse in incremental compilation. |
| 259 /// Incremental compilation is basically calling [run] more than once. | 250 /// Incremental compilation is basically calling [run] more than once. |
| 260 final bool hasIncrementalSupport; | 251 final bool hasIncrementalSupport; |
| 261 | 252 |
| 262 /// If `true` native extension syntax is supported by the frontend. | 253 /// If `true` native extension syntax is supported by the frontend. |
| 263 final bool allowNativeExtensions; | 254 final bool allowNativeExtensions; |
| 264 | 255 |
| 265 /// Output provider from user of Compiler API. | 256 /// Output provider from user of Compiler API. |
| 266 api.CompilerOutput userOutputProvider; | 257 api.CompilerOutput userOutputProvider; |
| 267 | 258 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 bool analyzeOnly: false, | 453 bool analyzeOnly: false, |
| 463 this.analyzeMain: false, | 454 this.analyzeMain: false, |
| 464 bool analyzeSignaturesOnly: false, | 455 bool analyzeSignaturesOnly: false, |
| 465 this.preserveComments: false, | 456 this.preserveComments: false, |
| 466 this.useCpsIr: false, | 457 this.useCpsIr: false, |
| 467 this.useFrequencyNamer: false, | 458 this.useFrequencyNamer: false, |
| 468 this.verbose: false, | 459 this.verbose: false, |
| 469 this.sourceMapUri: null, | 460 this.sourceMapUri: null, |
| 470 this.outputUri: null, | 461 this.outputUri: null, |
| 471 this.buildId: UNDETERMINED_BUILD_ID, | 462 this.buildId: UNDETERMINED_BUILD_ID, |
| 472 this.terseDiagnostics: false, | |
| 473 this.deferredMapUri: null, | 463 this.deferredMapUri: null, |
| 474 this.dumpInfo: false, | 464 this.dumpInfo: false, |
| 475 this.showPackageWarnings: false, | |
| 476 bool useStartupEmitter: false, | 465 bool useStartupEmitter: false, |
| 477 this.useContentSecurityPolicy: false, | 466 this.useContentSecurityPolicy: false, |
| 478 this.suppressWarnings: false, | |
| 479 this.fatalWarnings: false, | |
| 480 bool hasIncrementalSupport: false, | 467 bool hasIncrementalSupport: false, |
| 481 this.enableExperimentalMirrors: false, | 468 this.enableExperimentalMirrors: false, |
| 482 this.enableAssertMessage: false, | 469 this.enableAssertMessage: false, |
| 483 this.allowNativeExtensions: false, | 470 this.allowNativeExtensions: false, |
| 484 this.generateCodeWithCompileTimeErrors: false, | 471 this.generateCodeWithCompileTimeErrors: false, |
| 485 this.testMode: false, | 472 this.testMode: false, |
| 473 DiagnosticOptions diagnosticOptions, |
| 486 api.CompilerOutput outputProvider, | 474 api.CompilerOutput outputProvider, |
| 487 List<String> strips: const []}) | 475 List<String> strips: const []}) |
| 488 : this.disableTypeInferenceFlag = | 476 : this.disableTypeInferenceFlag = |
| 489 disableTypeInferenceFlag || !emitJavaScript, | 477 disableTypeInferenceFlag || !emitJavaScript, |
| 490 this.analyzeOnly = | 478 this.analyzeOnly = |
| 491 analyzeOnly || analyzeSignaturesOnly || analyzeAllFlag, | 479 analyzeOnly || analyzeSignaturesOnly || analyzeAllFlag, |
| 492 this.analyzeSignaturesOnly = analyzeSignaturesOnly, | 480 this.analyzeSignaturesOnly = analyzeSignaturesOnly, |
| 493 this.analyzeAllFlag = analyzeAllFlag, | 481 this.analyzeAllFlag = analyzeAllFlag, |
| 494 this.hasIncrementalSupport = hasIncrementalSupport, | 482 this.hasIncrementalSupport = hasIncrementalSupport, |
| 495 cacheStrategy = new CacheStrategy(hasIncrementalSupport), | 483 cacheStrategy = new CacheStrategy(hasIncrementalSupport), |
| 496 this.userOutputProvider = outputProvider == null | 484 this.userOutputProvider = outputProvider == null |
| 497 ? const NullCompilerOutput() : outputProvider { | 485 ? const NullCompilerOutput() : outputProvider { |
| 498 if (hasIncrementalSupport) { | 486 if (hasIncrementalSupport) { |
| 499 // TODO(ahe): This is too much. Any method from platform and package | 487 // TODO(ahe): This is too much. Any method from platform and package |
| 500 // libraries can be inlined. | 488 // libraries can be inlined. |
| 501 disableInlining = true; | 489 disableInlining = true; |
| 502 } | 490 } |
| 503 world = new World(this); | 491 world = new World(this); |
| 504 // TODO(johnniwinther): Initialize core types in [initializeCoreClasses] and | 492 // TODO(johnniwinther): Initialize core types in [initializeCoreClasses] and |
| 505 // make its field final. | 493 // make its field final. |
| 506 _reporter = new _CompilerDiagnosticReporter(this, | 494 _reporter = new _CompilerDiagnosticReporter(this, diagnosticOptions); |
| 507 new DiagnosticOptions( | |
| 508 suppressWarnings: suppressWarnings, | |
| 509 terseDiagnostics: terseDiagnostics, | |
| 510 showPackageWarnings: showPackageWarnings)); | |
| 511 _parsing = new _CompilerParsing(this); | 495 _parsing = new _CompilerParsing(this); |
| 512 _resolution = new _CompilerResolution(this); | 496 _resolution = new _CompilerResolution(this); |
| 513 _coreTypes = new _CompilerCoreTypes(_resolution); | 497 _coreTypes = new _CompilerCoreTypes(_resolution); |
| 514 types = new Types(this); | 498 types = new Types(this); |
| 515 tracer = new Tracer(this, this.outputProvider); | 499 tracer = new Tracer(this, this.outputProvider); |
| 516 | 500 |
| 517 if (verbose) { | 501 if (verbose) { |
| 518 progress = new Stopwatch()..start(); | 502 progress = new Stopwatch()..start(); |
| 519 } | 503 } |
| 520 | 504 |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 message: 'Element $element is not analyzable.')); | 1184 message: 'Element $element is not analyzable.')); |
| 1201 assert(invariant(element, element.isDeclaration)); | 1185 assert(invariant(element, element.isDeclaration)); |
| 1202 ResolutionEnqueuer world = enqueuer.resolution; | 1186 ResolutionEnqueuer world = enqueuer.resolution; |
| 1203 if (world.hasBeenResolved(element)) { | 1187 if (world.hasBeenResolved(element)) { |
| 1204 return const WorldImpact(); | 1188 return const WorldImpact(); |
| 1205 } | 1189 } |
| 1206 assert(parser != null); | 1190 assert(parser != null); |
| 1207 Node tree = parser.parse(element); | 1191 Node tree = parser.parse(element); |
| 1208 assert(invariant(element, !element.isSynthesized || tree == null)); | 1192 assert(invariant(element, !element.isSynthesized || tree == null)); |
| 1209 WorldImpact worldImpact = resolver.resolve(element); | 1193 WorldImpact worldImpact = resolver.resolve(element); |
| 1210 if (tree != null && !analyzeSignaturesOnly && !suppressWarnings) { | 1194 if (tree != null && |
| 1195 !analyzeSignaturesOnly && |
| 1196 !reporter.options.suppressWarnings) { |
| 1211 // Only analyze nodes with a corresponding [TreeElements]. | 1197 // Only analyze nodes with a corresponding [TreeElements]. |
| 1212 checker.check(element); | 1198 checker.check(element); |
| 1213 } | 1199 } |
| 1214 world.registerResolvedElement(element); | 1200 world.registerResolvedElement(element); |
| 1215 return worldImpact; | 1201 return worldImpact; |
| 1216 } | 1202 } |
| 1217 | 1203 |
| 1218 WorldImpact analyze(ResolutionWorkItem work, ResolutionEnqueuer world) { | 1204 WorldImpact analyze(ResolutionWorkItem work, ResolutionEnqueuer world) { |
| 1219 assert(invariant(work.element, identical(world, enqueuer.resolution))); | 1205 assert(invariant(work.element, identical(world, enqueuer.resolution))); |
| 1220 assert(invariant(work.element, !work.isAnalyzed, | 1206 assert(invariant(work.element, !work.isAnalyzed, |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 | 1964 |
| 1979 @override | 1965 @override |
| 1980 void parsePatchClass(ClassElement cls) { | 1966 void parsePatchClass(ClassElement cls) { |
| 1981 compiler.patchParser.measure(() { | 1967 compiler.patchParser.measure(() { |
| 1982 if (cls.isPatch) { | 1968 if (cls.isPatch) { |
| 1983 compiler.patchParser.parsePatchClassNode(cls); | 1969 compiler.patchParser.parsePatchClassNode(cls); |
| 1984 } | 1970 } |
| 1985 }); | 1971 }); |
| 1986 } | 1972 } |
| 1987 } | 1973 } |
| OLD | NEW |