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 'commandline_options.dart' show Flags; | 7 import 'commandline_options.dart' show Flags; |
8 import '../compiler.dart' show PackagesDiscoveryProvider; | 8 import '../compiler.dart' show PackagesDiscoveryProvider; |
9 | 9 |
10 /// Options used for parsing. | 10 /// Options used for parsing. |
11 /// | 11 /// |
12 /// Use this to conditionally support certain constructs, e.g., | 12 /// Use this to conditionally support certain constructs, e.g., |
13 /// experimental ones. | 13 /// experimental ones. |
14 abstract class ParserOptions { | 14 abstract class ParserOptions { |
15 const ParserOptions(); | 15 const ParserOptions(); |
16 | 16 |
17 /// Support conditional directives, e.g., configurable imports. | |
18 bool get enableConditionalDirectives; | |
19 | |
20 /// Support parsing of generic method declarations, and invocations of | 17 /// Support parsing of generic method declarations, and invocations of |
21 /// methods where type arguments are passed. | 18 /// methods where type arguments are passed. |
22 bool get enableGenericMethodSyntax; | 19 bool get enableGenericMethodSyntax; |
23 } | 20 } |
24 | 21 |
25 /// Options used for controlling diagnostic messages. | 22 /// Options used for controlling diagnostic messages. |
26 abstract class DiagnosticOptions { | 23 abstract class DiagnosticOptions { |
27 const DiagnosticOptions(); | 24 const DiagnosticOptions(); |
28 | 25 |
29 /// If `true`, warnings cause the compilation to fail. | 26 /// If `true`, warnings cause the compilation to fail. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 /// Whether to emit a .json file with a summary of the information used by the | 138 /// Whether to emit a .json file with a summary of the information used by the |
142 /// compiler during optimization. This includes resolution details, | 139 /// compiler during optimization. This includes resolution details, |
143 /// dependencies between elements, results of type inference, and the output | 140 /// dependencies between elements, results of type inference, and the output |
144 /// code for each function. | 141 /// code for each function. |
145 final bool dumpInfo; | 142 final bool dumpInfo; |
146 | 143 |
147 /// Whether we allow passing an extra argument to `assert`, containing a | 144 /// Whether we allow passing an extra argument to `assert`, containing a |
148 /// reason for why an assertion fails. (experimental) | 145 /// reason for why an assertion fails. (experimental) |
149 final bool enableAssertMessage; | 146 final bool enableAssertMessage; |
150 | 147 |
151 /// Whether to enable the experimental conditional directives feature. | |
152 final bool enableConditionalDirectives; | |
153 | |
154 /// Support parsing of generic method declarations, and invocations of | 148 /// Support parsing of generic method declarations, and invocations of |
155 /// methods where type arguments are passed. | 149 /// methods where type arguments are passed. |
156 final bool enableGenericMethodSyntax; | 150 final bool enableGenericMethodSyntax; |
157 | 151 |
158 /// Whether the user specified a flag to allow the use of dart:mirrors. This | 152 /// Whether the user specified a flag to allow the use of dart:mirrors. This |
159 /// silences a warning produced by the compiler. | 153 /// silences a warning produced by the compiler. |
160 final bool enableExperimentalMirrors; | 154 final bool enableExperimentalMirrors; |
161 | 155 |
162 /// Whether to enable minification | 156 /// Whether to enable minification |
163 // TODO(sigmund): rename to minify | 157 // TODO(sigmund): rename to minify |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 suppressWarnings: _hasOption(options, Flags.suppressWarnings), | 272 suppressWarnings: _hasOption(options, Flags.suppressWarnings), |
279 suppressHints: _hasOption(options, Flags.suppressHints), | 273 suppressHints: _hasOption(options, Flags.suppressHints), |
280 shownPackageWarnings: | 274 shownPackageWarnings: |
281 _extractOptionalCsvOption(options, Flags.showPackageWarnings), | 275 _extractOptionalCsvOption(options, Flags.showPackageWarnings), |
282 disableInlining: _hasOption(options, Flags.disableInlining), | 276 disableInlining: _hasOption(options, Flags.disableInlining), |
283 disableTypeInference: _hasOption(options, Flags.disableTypeInference), | 277 disableTypeInference: _hasOption(options, Flags.disableTypeInference), |
284 dumpInfo: _hasOption(options, Flags.dumpInfo), | 278 dumpInfo: _hasOption(options, Flags.dumpInfo), |
285 emitJavaScript: !(_hasOption(options, '--output-type=dart') || | 279 emitJavaScript: !(_hasOption(options, '--output-type=dart') || |
286 _hasOption(options, '--output-type=dart-multi')), | 280 _hasOption(options, '--output-type=dart-multi')), |
287 enableAssertMessage: _hasOption(options, Flags.enableAssertMessage), | 281 enableAssertMessage: _hasOption(options, Flags.enableAssertMessage), |
288 enableConditionalDirectives: | |
289 _hasOption(options, Flags.conditionalDirectives), | |
290 enableGenericMethodSyntax: | 282 enableGenericMethodSyntax: |
291 _hasOption(options, Flags.genericMethodSyntax), | 283 _hasOption(options, Flags.genericMethodSyntax), |
292 enableExperimentalMirrors: | 284 enableExperimentalMirrors: |
293 _hasOption(options, Flags.enableExperimentalMirrors), | 285 _hasOption(options, Flags.enableExperimentalMirrors), |
294 enableMinification: _hasOption(options, Flags.minify), | 286 enableMinification: _hasOption(options, Flags.minify), |
295 enableNativeLiveTypeAnalysis: | 287 enableNativeLiveTypeAnalysis: |
296 !_hasOption(options, Flags.disableNativeLiveTypeAnalysis), | 288 !_hasOption(options, Flags.disableNativeLiveTypeAnalysis), |
297 enableTypeAssertions: _hasOption(options, Flags.enableCheckedMode), | 289 enableTypeAssertions: _hasOption(options, Flags.enableCheckedMode), |
298 enableUserAssertions: _hasOption(options, Flags.enableCheckedMode), | 290 enableUserAssertions: _hasOption(options, Flags.enableCheckedMode), |
299 generateCodeWithCompileTimeErrors: | 291 generateCodeWithCompileTimeErrors: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 bool fatalWarnings: false, | 339 bool fatalWarnings: false, |
348 bool terseDiagnostics: false, | 340 bool terseDiagnostics: false, |
349 bool suppressWarnings: false, | 341 bool suppressWarnings: false, |
350 bool suppressHints: false, | 342 bool suppressHints: false, |
351 List<String> shownPackageWarnings: null, | 343 List<String> shownPackageWarnings: null, |
352 bool disableInlining: false, | 344 bool disableInlining: false, |
353 bool disableTypeInference: false, | 345 bool disableTypeInference: false, |
354 bool dumpInfo: false, | 346 bool dumpInfo: false, |
355 bool emitJavaScript: true, | 347 bool emitJavaScript: true, |
356 bool enableAssertMessage: false, | 348 bool enableAssertMessage: false, |
357 bool enableConditionalDirectives: false, | |
358 bool enableGenericMethodSyntax: false, | 349 bool enableGenericMethodSyntax: false, |
359 bool enableExperimentalMirrors: false, | 350 bool enableExperimentalMirrors: false, |
360 bool enableMinification: false, | 351 bool enableMinification: false, |
361 bool enableNativeLiveTypeAnalysis: true, | 352 bool enableNativeLiveTypeAnalysis: true, |
362 bool enableTypeAssertions: false, | 353 bool enableTypeAssertions: false, |
363 bool enableUserAssertions: false, | 354 bool enableUserAssertions: false, |
364 bool generateCodeWithCompileTimeErrors: false, | 355 bool generateCodeWithCompileTimeErrors: false, |
365 bool generateSourceMap: true, | 356 bool generateSourceMap: true, |
366 bool hasIncrementalSupport: false, | 357 bool hasIncrementalSupport: false, |
367 Uri outputUri: null, | 358 Uri outputUri: null, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 fatalWarnings: fatalWarnings, | 408 fatalWarnings: fatalWarnings, |
418 terseDiagnostics: terseDiagnostics, | 409 terseDiagnostics: terseDiagnostics, |
419 suppressWarnings: suppressWarnings, | 410 suppressWarnings: suppressWarnings, |
420 suppressHints: suppressHints, | 411 suppressHints: suppressHints, |
421 shownPackageWarnings: shownPackageWarnings, | 412 shownPackageWarnings: shownPackageWarnings, |
422 disableInlining: disableInlining || hasIncrementalSupport, | 413 disableInlining: disableInlining || hasIncrementalSupport, |
423 disableTypeInference: disableTypeInference || !emitJavaScript, | 414 disableTypeInference: disableTypeInference || !emitJavaScript, |
424 dumpInfo: dumpInfo, | 415 dumpInfo: dumpInfo, |
425 emitJavaScript: emitJavaScript, | 416 emitJavaScript: emitJavaScript, |
426 enableAssertMessage: enableAssertMessage, | 417 enableAssertMessage: enableAssertMessage, |
427 enableConditionalDirectives: enableConditionalDirectives, | |
428 enableGenericMethodSyntax: enableGenericMethodSyntax, | 418 enableGenericMethodSyntax: enableGenericMethodSyntax, |
429 enableExperimentalMirrors: enableExperimentalMirrors, | 419 enableExperimentalMirrors: enableExperimentalMirrors, |
430 enableMinification: enableMinification, | 420 enableMinification: enableMinification, |
431 enableNativeLiveTypeAnalysis: enableNativeLiveTypeAnalysis, | 421 enableNativeLiveTypeAnalysis: enableNativeLiveTypeAnalysis, |
432 enableTypeAssertions: enableTypeAssertions, | 422 enableTypeAssertions: enableTypeAssertions, |
433 enableUserAssertions: enableUserAssertions, | 423 enableUserAssertions: enableUserAssertions, |
434 generateCodeWithCompileTimeErrors: generateCodeWithCompileTimeErrors, | 424 generateCodeWithCompileTimeErrors: generateCodeWithCompileTimeErrors, |
435 generateSourceMap: generateSourceMap, | 425 generateSourceMap: generateSourceMap, |
436 hasIncrementalSupport: hasIncrementalSupport, | 426 hasIncrementalSupport: hasIncrementalSupport, |
437 outputUri: outputUri, | 427 outputUri: outputUri, |
(...skipping 30 matching lines...) Expand all Loading... |
468 this.fatalWarnings: false, | 458 this.fatalWarnings: false, |
469 this.terseDiagnostics: false, | 459 this.terseDiagnostics: false, |
470 this.suppressWarnings: false, | 460 this.suppressWarnings: false, |
471 this.suppressHints: false, | 461 this.suppressHints: false, |
472 List<String> shownPackageWarnings: null, | 462 List<String> shownPackageWarnings: null, |
473 this.disableInlining: false, | 463 this.disableInlining: false, |
474 this.disableTypeInference: false, | 464 this.disableTypeInference: false, |
475 this.dumpInfo: false, | 465 this.dumpInfo: false, |
476 this.emitJavaScript: true, | 466 this.emitJavaScript: true, |
477 this.enableAssertMessage: false, | 467 this.enableAssertMessage: false, |
478 this.enableConditionalDirectives: false, | |
479 this.enableGenericMethodSyntax: false, | 468 this.enableGenericMethodSyntax: false, |
480 this.enableExperimentalMirrors: false, | 469 this.enableExperimentalMirrors: false, |
481 this.enableMinification: false, | 470 this.enableMinification: false, |
482 this.enableNativeLiveTypeAnalysis: false, | 471 this.enableNativeLiveTypeAnalysis: false, |
483 this.enableTypeAssertions: false, | 472 this.enableTypeAssertions: false, |
484 this.enableUserAssertions: false, | 473 this.enableUserAssertions: false, |
485 this.generateCodeWithCompileTimeErrors: false, | 474 this.generateCodeWithCompileTimeErrors: false, |
486 this.generateSourceMap: true, | 475 this.generateSourceMap: true, |
487 this.hasIncrementalSupport: false, | 476 this.hasIncrementalSupport: false, |
488 this.outputUri: null, | 477 this.outputUri: null, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 | 590 |
602 /// Locations of the platform descriptor files relative to the library root. | 591 /// Locations of the platform descriptor files relative to the library root. |
603 const String _clientPlatform = "lib/dart_client.platform"; | 592 const String _clientPlatform = "lib/dart_client.platform"; |
604 const String _serverPlatform = "lib/dart_server.platform"; | 593 const String _serverPlatform = "lib/dart_server.platform"; |
605 const String _sharedPlatform = "lib/dart_shared.platform"; | 594 const String _sharedPlatform = "lib/dart_shared.platform"; |
606 const String _dart2dartPlatform = "lib/dart2dart.platform"; | 595 const String _dart2dartPlatform = "lib/dart2dart.platform"; |
607 | 596 |
608 const String _UNDETERMINED_BUILD_ID = "build number could not be determined"; | 597 const String _UNDETERMINED_BUILD_ID = "build number could not be determined"; |
609 const bool _forceIncrementalSupport = | 598 const bool _forceIncrementalSupport = |
610 const bool.fromEnvironment('DART2JS_EXPERIMENTAL_INCREMENTAL_SUPPORT'); | 599 const bool.fromEnvironment('DART2JS_EXPERIMENTAL_INCREMENTAL_SUPPORT'); |
OLD | NEW |