OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.src.options; | 5 library dart2js.src.options; |
6 | 6 |
7 import '../compiler.dart' show PackagesDiscoveryProvider; | 7 import '../compiler.dart' show PackagesDiscoveryProvider; |
8 import 'commandline_options.dart' show Flags; | 8 import 'commandline_options.dart' show Flags; |
9 | 9 |
10 /// Options used for parsing. | |
11 /// | |
12 /// Use this to conditionally support certain constructs, e.g., | |
13 /// experimental ones. | |
14 abstract class ParserOptions { | |
15 const ParserOptions(); | |
16 | |
17 /// Support parsing of generic method declarations, and invocations of | |
18 /// methods where type arguments are passed. | |
19 bool get enableGenericMethodSyntax; | |
20 } | |
21 | |
22 /// Options used for controlling diagnostic messages. | 10 /// Options used for controlling diagnostic messages. |
23 abstract class DiagnosticOptions { | 11 abstract class DiagnosticOptions { |
24 const DiagnosticOptions(); | 12 const DiagnosticOptions(); |
25 | 13 |
26 /// If `true`, warnings cause the compilation to fail. | 14 /// If `true`, warnings cause the compilation to fail. |
27 bool get fatalWarnings; | 15 bool get fatalWarnings; |
28 | 16 |
29 /// Emit terse diagnostics without howToFix. | 17 /// Emit terse diagnostics without howToFix. |
30 bool get terseDiagnostics; | 18 bool get terseDiagnostics; |
31 | 19 |
32 /// If `true`, warnings are not reported. | 20 /// If `true`, warnings are not reported. |
33 bool get suppressWarnings; | 21 bool get suppressWarnings; |
34 | 22 |
35 /// If `true`, hints are not reported. | 23 /// If `true`, hints are not reported. |
36 bool get suppressHints; | 24 bool get suppressHints; |
37 | 25 |
38 /// Returns `true` if warnings and hints are shown for all packages. | 26 /// Returns `true` if warnings and hints are shown for all packages. |
39 bool get showAllPackageWarnings; | 27 bool get showAllPackageWarnings; |
40 | 28 |
41 /// Returns `true` if warnings and hints are hidden for all packages. | 29 /// Returns `true` if warnings and hints are hidden for all packages. |
42 bool get hidePackageWarnings; | 30 bool get hidePackageWarnings; |
43 | 31 |
44 /// Returns `true` if warnings should be should for [uri]. | 32 /// Returns `true` if warnings should be should for [uri]. |
45 bool showPackageWarningsFor(Uri uri); | 33 bool showPackageWarningsFor(Uri uri); |
46 } | 34 } |
47 | 35 |
48 /// Object for passing options to the compiler. Superclasses are used to select | 36 /// Object for passing options to the compiler. Superclasses are used to select |
49 /// subsets of these options, enabling each part of the compiler to depend on | 37 /// subsets of these options, enabling each part of the compiler to depend on |
50 /// as few as possible. | 38 /// as few as possible. |
51 class CompilerOptions implements DiagnosticOptions, ParserOptions { | 39 class CompilerOptions implements DiagnosticOptions { |
52 /// The entry point of the application that is being compiled. | 40 /// The entry point of the application that is being compiled. |
53 final Uri entryPoint; | 41 final Uri entryPoint; |
54 | 42 |
55 /// Root location where SDK libraries are found. | 43 /// Root location where SDK libraries are found. |
56 final Uri libraryRoot; | 44 final Uri libraryRoot; |
57 | 45 |
58 /// Package root location. | 46 /// Package root location. |
59 /// | 47 /// |
60 /// If not null then [packageConfig] should be null. | 48 /// If not null then [packageConfig] should be null. |
61 final Uri packageRoot; | 49 final Uri packageRoot; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 /// Whether to emit a .json file with a summary of the information used by the | 126 /// Whether to emit a .json file with a summary of the information used by the |
139 /// compiler during optimization. This includes resolution details, | 127 /// compiler during optimization. This includes resolution details, |
140 /// dependencies between elements, results of type inference, and the output | 128 /// dependencies between elements, results of type inference, and the output |
141 /// code for each function. | 129 /// code for each function. |
142 final bool dumpInfo; | 130 final bool dumpInfo; |
143 | 131 |
144 /// Whether we allow passing an extra argument to `assert`, containing a | 132 /// Whether we allow passing an extra argument to `assert`, containing a |
145 /// reason for why an assertion fails. (experimental) | 133 /// reason for why an assertion fails. (experimental) |
146 final bool enableAssertMessage; | 134 final bool enableAssertMessage; |
147 | 135 |
148 /// Support parsing of generic method declarations, and invocations of | |
149 /// methods where type arguments are passed. | |
150 final bool enableGenericMethodSyntax; | |
151 | |
152 /// Support access to initializing formal constructor arguments, e.g., the | 136 /// Support access to initializing formal constructor arguments, e.g., the |
153 /// use of `x` to initialize `y` in `C(this.x) : y = x`. | 137 /// use of `x` to initialize `y` in `C(this.x) : y = x`. |
154 final bool enableInitializingFormalAccess; | 138 final bool enableInitializingFormalAccess; |
155 | 139 |
156 /// Whether the user specified a flag to allow the use of dart:mirrors. This | 140 /// Whether the user specified a flag to allow the use of dart:mirrors. This |
157 /// silences a warning produced by the compiler. | 141 /// silences a warning produced by the compiler. |
158 final bool enableExperimentalMirrors; | 142 final bool enableExperimentalMirrors; |
159 | 143 |
160 /// Whether to enable minification | 144 /// Whether to enable minification |
161 // TODO(sigmund): rename to minify | 145 // TODO(sigmund): rename to minify |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 fatalWarnings: _hasOption(options, Flags.fatalWarnings), | 265 fatalWarnings: _hasOption(options, Flags.fatalWarnings), |
282 terseDiagnostics: _hasOption(options, Flags.terse), | 266 terseDiagnostics: _hasOption(options, Flags.terse), |
283 suppressWarnings: _hasOption(options, Flags.suppressWarnings), | 267 suppressWarnings: _hasOption(options, Flags.suppressWarnings), |
284 suppressHints: _hasOption(options, Flags.suppressHints), | 268 suppressHints: _hasOption(options, Flags.suppressHints), |
285 shownPackageWarnings: | 269 shownPackageWarnings: |
286 _extractOptionalCsvOption(options, Flags.showPackageWarnings), | 270 _extractOptionalCsvOption(options, Flags.showPackageWarnings), |
287 disableInlining: _hasOption(options, Flags.disableInlining), | 271 disableInlining: _hasOption(options, Flags.disableInlining), |
288 disableTypeInference: _hasOption(options, Flags.disableTypeInference), | 272 disableTypeInference: _hasOption(options, Flags.disableTypeInference), |
289 dumpInfo: _hasOption(options, Flags.dumpInfo), | 273 dumpInfo: _hasOption(options, Flags.dumpInfo), |
290 enableAssertMessage: _hasOption(options, Flags.enableAssertMessage), | 274 enableAssertMessage: _hasOption(options, Flags.enableAssertMessage), |
291 enableGenericMethodSyntax: | |
292 true, // No check for `Flags.genericMethodSyntax`: always enabled. | |
293 enableInitializingFormalAccess: | 275 enableInitializingFormalAccess: |
294 _hasOption(options, Flags.initializingFormalAccess), | 276 _hasOption(options, Flags.initializingFormalAccess), |
295 enableExperimentalMirrors: | 277 enableExperimentalMirrors: |
296 _hasOption(options, Flags.enableExperimentalMirrors), | 278 _hasOption(options, Flags.enableExperimentalMirrors), |
297 enableMinification: _hasOption(options, Flags.minify), | 279 enableMinification: _hasOption(options, Flags.minify), |
298 enableNativeLiveTypeAnalysis: | 280 enableNativeLiveTypeAnalysis: |
299 !_hasOption(options, Flags.disableNativeLiveTypeAnalysis), | 281 !_hasOption(options, Flags.disableNativeLiveTypeAnalysis), |
300 enableTypeAssertions: _hasOption(options, Flags.enableCheckedMode), | 282 enableTypeAssertions: _hasOption(options, Flags.enableCheckedMode), |
301 enableUserAssertions: _hasOption(options, Flags.enableCheckedMode), | 283 enableUserAssertions: _hasOption(options, Flags.enableCheckedMode), |
302 generateCodeWithCompileTimeErrors: | 284 generateCodeWithCompileTimeErrors: |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 Uri deferredMapUri: null, | 333 Uri deferredMapUri: null, |
352 bool fatalWarnings: false, | 334 bool fatalWarnings: false, |
353 bool terseDiagnostics: false, | 335 bool terseDiagnostics: false, |
354 bool suppressWarnings: false, | 336 bool suppressWarnings: false, |
355 bool suppressHints: false, | 337 bool suppressHints: false, |
356 List<String> shownPackageWarnings: null, | 338 List<String> shownPackageWarnings: null, |
357 bool disableInlining: false, | 339 bool disableInlining: false, |
358 bool disableTypeInference: false, | 340 bool disableTypeInference: false, |
359 bool dumpInfo: false, | 341 bool dumpInfo: false, |
360 bool enableAssertMessage: false, | 342 bool enableAssertMessage: false, |
361 bool enableGenericMethodSyntax: false, | |
362 bool enableInitializingFormalAccess: false, | 343 bool enableInitializingFormalAccess: false, |
363 bool enableExperimentalMirrors: false, | 344 bool enableExperimentalMirrors: false, |
364 bool enableMinification: false, | 345 bool enableMinification: false, |
365 bool enableNativeLiveTypeAnalysis: true, | 346 bool enableNativeLiveTypeAnalysis: true, |
366 bool enableTypeAssertions: false, | 347 bool enableTypeAssertions: false, |
367 bool enableUserAssertions: false, | 348 bool enableUserAssertions: false, |
368 bool generateCodeWithCompileTimeErrors: false, | 349 bool generateCodeWithCompileTimeErrors: false, |
369 bool generateSourceMap: true, | 350 bool generateSourceMap: true, |
370 bool hasIncrementalSupport: false, | 351 bool hasIncrementalSupport: false, |
371 Uri outputUri: null, | 352 Uri outputUri: null, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 deferredMapUri: deferredMapUri, | 404 deferredMapUri: deferredMapUri, |
424 fatalWarnings: fatalWarnings, | 405 fatalWarnings: fatalWarnings, |
425 terseDiagnostics: terseDiagnostics, | 406 terseDiagnostics: terseDiagnostics, |
426 suppressWarnings: suppressWarnings, | 407 suppressWarnings: suppressWarnings, |
427 suppressHints: suppressHints, | 408 suppressHints: suppressHints, |
428 shownPackageWarnings: shownPackageWarnings, | 409 shownPackageWarnings: shownPackageWarnings, |
429 disableInlining: disableInlining || hasIncrementalSupport, | 410 disableInlining: disableInlining || hasIncrementalSupport, |
430 disableTypeInference: disableTypeInference, | 411 disableTypeInference: disableTypeInference, |
431 dumpInfo: dumpInfo, | 412 dumpInfo: dumpInfo, |
432 enableAssertMessage: enableAssertMessage, | 413 enableAssertMessage: enableAssertMessage, |
433 enableGenericMethodSyntax: enableGenericMethodSyntax, | |
434 enableInitializingFormalAccess: enableInitializingFormalAccess, | 414 enableInitializingFormalAccess: enableInitializingFormalAccess, |
435 enableExperimentalMirrors: enableExperimentalMirrors, | 415 enableExperimentalMirrors: enableExperimentalMirrors, |
436 enableMinification: enableMinification, | 416 enableMinification: enableMinification, |
437 enableNativeLiveTypeAnalysis: enableNativeLiveTypeAnalysis, | 417 enableNativeLiveTypeAnalysis: enableNativeLiveTypeAnalysis, |
438 enableTypeAssertions: enableTypeAssertions, | 418 enableTypeAssertions: enableTypeAssertions, |
439 enableUserAssertions: enableUserAssertions, | 419 enableUserAssertions: enableUserAssertions, |
440 generateCodeWithCompileTimeErrors: generateCodeWithCompileTimeErrors, | 420 generateCodeWithCompileTimeErrors: generateCodeWithCompileTimeErrors, |
441 generateSourceMap: generateSourceMap, | 421 generateSourceMap: generateSourceMap, |
442 hasIncrementalSupport: hasIncrementalSupport, | 422 hasIncrementalSupport: hasIncrementalSupport, |
443 outputUri: outputUri, | 423 outputUri: outputUri, |
(...skipping 30 matching lines...) Expand all Loading... |
474 this.deferredMapUri: null, | 454 this.deferredMapUri: null, |
475 this.fatalWarnings: false, | 455 this.fatalWarnings: false, |
476 this.terseDiagnostics: false, | 456 this.terseDiagnostics: false, |
477 this.suppressWarnings: false, | 457 this.suppressWarnings: false, |
478 this.suppressHints: false, | 458 this.suppressHints: false, |
479 List<String> shownPackageWarnings: null, | 459 List<String> shownPackageWarnings: null, |
480 this.disableInlining: false, | 460 this.disableInlining: false, |
481 this.disableTypeInference: false, | 461 this.disableTypeInference: false, |
482 this.dumpInfo: false, | 462 this.dumpInfo: false, |
483 this.enableAssertMessage: false, | 463 this.enableAssertMessage: false, |
484 this.enableGenericMethodSyntax: false, | |
485 this.enableInitializingFormalAccess: false, | 464 this.enableInitializingFormalAccess: false, |
486 this.enableExperimentalMirrors: false, | 465 this.enableExperimentalMirrors: false, |
487 this.enableMinification: false, | 466 this.enableMinification: false, |
488 this.enableNativeLiveTypeAnalysis: false, | 467 this.enableNativeLiveTypeAnalysis: false, |
489 this.enableTypeAssertions: false, | 468 this.enableTypeAssertions: false, |
490 this.enableUserAssertions: false, | 469 this.enableUserAssertions: false, |
491 this.generateCodeWithCompileTimeErrors: false, | 470 this.generateCodeWithCompileTimeErrors: false, |
492 this.generateSourceMap: true, | 471 this.generateSourceMap: true, |
493 this.hasIncrementalSupport: false, | 472 this.hasIncrementalSupport: false, |
494 this.outputUri: null, | 473 this.outputUri: null, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 deferredMapUri, | 511 deferredMapUri, |
533 fatalWarnings, | 512 fatalWarnings, |
534 terseDiagnostics, | 513 terseDiagnostics, |
535 suppressWarnings, | 514 suppressWarnings, |
536 suppressHints, | 515 suppressHints, |
537 List<String> shownPackageWarnings, | 516 List<String> shownPackageWarnings, |
538 disableInlining, | 517 disableInlining, |
539 disableTypeInference, | 518 disableTypeInference, |
540 dumpInfo, | 519 dumpInfo, |
541 enableAssertMessage, | 520 enableAssertMessage, |
542 enableGenericMethodSyntax, | |
543 enableInitializingFormalAccess, | 521 enableInitializingFormalAccess, |
544 enableExperimentalMirrors, | 522 enableExperimentalMirrors, |
545 enableMinification, | 523 enableMinification, |
546 enableNativeLiveTypeAnalysis, | 524 enableNativeLiveTypeAnalysis, |
547 enableTypeAssertions, | 525 enableTypeAssertions, |
548 enableUserAssertions, | 526 enableUserAssertions, |
549 generateCodeWithCompileTimeErrors, | 527 generateCodeWithCompileTimeErrors, |
550 generateSourceMap, | 528 generateSourceMap, |
551 hasIncrementalSupport, | 529 hasIncrementalSupport, |
552 outputUri, | 530 outputUri, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 terseDiagnostics: terseDiagnostics ?? options.terseDiagnostics, | 569 terseDiagnostics: terseDiagnostics ?? options.terseDiagnostics, |
592 suppressWarnings: suppressWarnings ?? options.suppressWarnings, | 570 suppressWarnings: suppressWarnings ?? options.suppressWarnings, |
593 suppressHints: suppressHints ?? options.suppressHints, | 571 suppressHints: suppressHints ?? options.suppressHints, |
594 shownPackageWarnings: | 572 shownPackageWarnings: |
595 shownPackageWarnings ?? options._shownPackageWarnings, | 573 shownPackageWarnings ?? options._shownPackageWarnings, |
596 disableInlining: disableInlining ?? options.disableInlining, | 574 disableInlining: disableInlining ?? options.disableInlining, |
597 disableTypeInference: | 575 disableTypeInference: |
598 disableTypeInference ?? options.disableTypeInference, | 576 disableTypeInference ?? options.disableTypeInference, |
599 dumpInfo: dumpInfo ?? options.dumpInfo, | 577 dumpInfo: dumpInfo ?? options.dumpInfo, |
600 enableAssertMessage: enableAssertMessage ?? options.enableAssertMessage, | 578 enableAssertMessage: enableAssertMessage ?? options.enableAssertMessage, |
601 enableGenericMethodSyntax: | |
602 enableGenericMethodSyntax ?? options.enableGenericMethodSyntax, | |
603 enableInitializingFormalAccess: enableInitializingFormalAccess ?? | 579 enableInitializingFormalAccess: enableInitializingFormalAccess ?? |
604 options.enableInitializingFormalAccess, | 580 options.enableInitializingFormalAccess, |
605 enableExperimentalMirrors: | 581 enableExperimentalMirrors: |
606 enableExperimentalMirrors ?? options.enableExperimentalMirrors, | 582 enableExperimentalMirrors ?? options.enableExperimentalMirrors, |
607 enableMinification: enableMinification ?? options.enableMinification, | 583 enableMinification: enableMinification ?? options.enableMinification, |
608 enableNativeLiveTypeAnalysis: enableNativeLiveTypeAnalysis ?? | 584 enableNativeLiveTypeAnalysis: enableNativeLiveTypeAnalysis ?? |
609 options.enableNativeLiveTypeAnalysis, | 585 options.enableNativeLiveTypeAnalysis, |
610 enableTypeAssertions: | 586 enableTypeAssertions: |
611 enableTypeAssertions ?? options.enableTypeAssertions, | 587 enableTypeAssertions ?? options.enableTypeAssertions, |
612 enableUserAssertions: | 588 enableUserAssertions: |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 } | 711 } |
736 | 712 |
737 /// Locations of the platform descriptor files relative to the library root. | 713 /// Locations of the platform descriptor files relative to the library root. |
738 const String _clientPlatform = "lib/dart_client.platform"; | 714 const String _clientPlatform = "lib/dart_client.platform"; |
739 const String _serverPlatform = "lib/dart_server.platform"; | 715 const String _serverPlatform = "lib/dart_server.platform"; |
740 const String _sharedPlatform = "lib/dart_shared.platform"; | 716 const String _sharedPlatform = "lib/dart_shared.platform"; |
741 | 717 |
742 const String _UNDETERMINED_BUILD_ID = "build number could not be determined"; | 718 const String _UNDETERMINED_BUILD_ID = "build number could not be determined"; |
743 const bool _forceIncrementalSupport = | 719 const bool _forceIncrementalSupport = |
744 const bool.fromEnvironment('DART2JS_EXPERIMENTAL_INCREMENTAL_SUPPORT'); | 720 const bool.fromEnvironment('DART2JS_EXPERIMENTAL_INCREMENTAL_SUPPORT'); |
OLD | NEW |