| 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. | 10 /// Options used for parsing. |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 214 |
| 215 /// Whether to trust primitive types during inference and optimizations. | 215 /// Whether to trust primitive types during inference and optimizations. |
| 216 final bool trustPrimitives; | 216 final bool trustPrimitives; |
| 217 | 217 |
| 218 /// Whether to trust type annotations during inference and optimizations. | 218 /// Whether to trust type annotations during inference and optimizations. |
| 219 final bool trustTypeAnnotations; | 219 final bool trustTypeAnnotations; |
| 220 | 220 |
| 221 /// Whether to generate code compliant with content security policy (CSP). | 221 /// Whether to generate code compliant with content security policy (CSP). |
| 222 final bool useContentSecurityPolicy; | 222 final bool useContentSecurityPolicy; |
| 223 | 223 |
| 224 /// Whether to use kernel internally as part of compilation. |
| 225 final bool useKernel; |
| 226 |
| 224 /// When obfuscating for minification, whether to use the frequency of a name | 227 /// When obfuscating for minification, whether to use the frequency of a name |
| 225 /// as an heuristic to pick shorter names. | 228 /// as an heuristic to pick shorter names. |
| 226 final bool useFrequencyNamer; | 229 final bool useFrequencyNamer; |
| 227 | 230 |
| 228 /// Whether to use the new source-information implementation for source-maps. | 231 /// Whether to use the new source-information implementation for source-maps. |
| 229 /// (experimental) | 232 /// (experimental) |
| 230 final bool useNewSourceInfo; | 233 final bool useNewSourceInfo; |
| 231 | 234 |
| 232 /// Whether the user requested to use the fast startup emitter. The full | 235 /// Whether the user requested to use the fast startup emitter. The full |
| 233 /// emitter might still be used if the program uses dart:mirrors. | 236 /// emitter might still be used if the program uses dart:mirrors. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 resolveOnly: _hasOption(options, Flags.resolveOnly), | 314 resolveOnly: _hasOption(options, Flags.resolveOnly), |
| 312 sourceMapUri: _extractUriOption(options, '--source-map='), | 315 sourceMapUri: _extractUriOption(options, '--source-map='), |
| 313 strips: _extractCsvOption(options, '--force-strip='), | 316 strips: _extractCsvOption(options, '--force-strip='), |
| 314 testMode: _hasOption(options, Flags.testMode), | 317 testMode: _hasOption(options, Flags.testMode), |
| 315 trustJSInteropTypeAnnotations: | 318 trustJSInteropTypeAnnotations: |
| 316 _hasOption(options, Flags.trustJSInteropTypeAnnotations), | 319 _hasOption(options, Flags.trustJSInteropTypeAnnotations), |
| 317 trustPrimitives: _hasOption(options, Flags.trustPrimitives), | 320 trustPrimitives: _hasOption(options, Flags.trustPrimitives), |
| 318 trustTypeAnnotations: _hasOption(options, Flags.trustTypeAnnotations), | 321 trustTypeAnnotations: _hasOption(options, Flags.trustTypeAnnotations), |
| 319 useContentSecurityPolicy: | 322 useContentSecurityPolicy: |
| 320 _hasOption(options, Flags.useContentSecurityPolicy), | 323 _hasOption(options, Flags.useContentSecurityPolicy), |
| 324 useKernel: _hasOption(options, Flags.useKernel), |
| 321 useFrequencyNamer: | 325 useFrequencyNamer: |
| 322 !_hasOption(options, Flags.noFrequencyBasedMinification), | 326 !_hasOption(options, Flags.noFrequencyBasedMinification), |
| 323 useNewSourceInfo: _hasOption(options, Flags.useNewSourceInfo), | 327 useNewSourceInfo: _hasOption(options, Flags.useNewSourceInfo), |
| 324 useStartupEmitter: _hasOption(options, Flags.fastStartup), | 328 useStartupEmitter: _hasOption(options, Flags.fastStartup), |
| 325 verbose: _hasOption(options, Flags.verbose)); | 329 verbose: _hasOption(options, Flags.verbose)); |
| 326 } | 330 } |
| 327 | 331 |
| 328 /// Creates an option object for the compiler. | 332 /// Creates an option object for the compiler. |
| 329 /// | 333 /// |
| 330 /// This validates and normalizes dependent options to be consistent. For | 334 /// This validates and normalizes dependent options to be consistent. For |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 List<Uri> resolutionInputs: null, | 375 List<Uri> resolutionInputs: null, |
| 372 Uri resolutionOutput: null, | 376 Uri resolutionOutput: null, |
| 373 bool resolveOnly: false, | 377 bool resolveOnly: false, |
| 374 Uri sourceMapUri: null, | 378 Uri sourceMapUri: null, |
| 375 List<String> strips: const [], | 379 List<String> strips: const [], |
| 376 bool testMode: false, | 380 bool testMode: false, |
| 377 bool trustJSInteropTypeAnnotations: false, | 381 bool trustJSInteropTypeAnnotations: false, |
| 378 bool trustPrimitives: false, | 382 bool trustPrimitives: false, |
| 379 bool trustTypeAnnotations: false, | 383 bool trustTypeAnnotations: false, |
| 380 bool useContentSecurityPolicy: false, | 384 bool useContentSecurityPolicy: false, |
| 385 bool useKernel: false, |
| 381 bool useFrequencyNamer: true, | 386 bool useFrequencyNamer: true, |
| 382 bool useNewSourceInfo: false, | 387 bool useNewSourceInfo: false, |
| 383 bool useStartupEmitter: false, | 388 bool useStartupEmitter: false, |
| 384 bool verbose: false}) { | 389 bool verbose: false}) { |
| 385 // TODO(sigmund): should entrypoint be here? should we validate it is not | 390 // TODO(sigmund): should entrypoint be here? should we validate it is not |
| 386 // null? In unittests we use the same compiler to analyze or build multiple | 391 // null? In unittests we use the same compiler to analyze or build multiple |
| 387 // entrypoints. | 392 // entrypoints. |
| 388 if (libraryRoot == null) { | 393 if (libraryRoot == null) { |
| 389 throw new ArgumentError("[libraryRoot] is null."); | 394 throw new ArgumentError("[libraryRoot] is null."); |
| 390 } | 395 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 resolutionInputs: resolutionInputs, | 448 resolutionInputs: resolutionInputs, |
| 444 resolutionOutput: resolutionOutput, | 449 resolutionOutput: resolutionOutput, |
| 445 resolveOnly: resolveOnly, | 450 resolveOnly: resolveOnly, |
| 446 sourceMapUri: sourceMapUri, | 451 sourceMapUri: sourceMapUri, |
| 447 strips: strips, | 452 strips: strips, |
| 448 testMode: testMode, | 453 testMode: testMode, |
| 449 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations, | 454 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations, |
| 450 trustPrimitives: trustPrimitives, | 455 trustPrimitives: trustPrimitives, |
| 451 trustTypeAnnotations: trustTypeAnnotations, | 456 trustTypeAnnotations: trustTypeAnnotations, |
| 452 useContentSecurityPolicy: useContentSecurityPolicy, | 457 useContentSecurityPolicy: useContentSecurityPolicy, |
| 458 useKernel: useKernel, |
| 453 useFrequencyNamer: useFrequencyNamer, | 459 useFrequencyNamer: useFrequencyNamer, |
| 454 useNewSourceInfo: useNewSourceInfo, | 460 useNewSourceInfo: useNewSourceInfo, |
| 455 useStartupEmitter: useStartupEmitter, | 461 useStartupEmitter: useStartupEmitter, |
| 456 verbose: verbose); | 462 verbose: verbose); |
| 457 } | 463 } |
| 458 | 464 |
| 459 CompilerOptions._(this.entryPoint, this.libraryRoot, this.packageRoot, | 465 CompilerOptions._(this.entryPoint, this.libraryRoot, this.packageRoot, |
| 460 this.packageConfig, this.packagesDiscoveryProvider, this.environment, | 466 this.packageConfig, this.packagesDiscoveryProvider, this.environment, |
| 461 {this.allowMockCompilation: false, | 467 {this.allowMockCompilation: false, |
| 462 this.allowNativeExtensions: false, | 468 this.allowNativeExtensions: false, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 493 this.resolutionOutput: null, | 499 this.resolutionOutput: null, |
| 494 this.resolveOnly: false, | 500 this.resolveOnly: false, |
| 495 this.compileOnly: false, | 501 this.compileOnly: false, |
| 496 this.sourceMapUri: null, | 502 this.sourceMapUri: null, |
| 497 this.strips: const [], | 503 this.strips: const [], |
| 498 this.testMode: false, | 504 this.testMode: false, |
| 499 this.trustJSInteropTypeAnnotations: false, | 505 this.trustJSInteropTypeAnnotations: false, |
| 500 this.trustPrimitives: false, | 506 this.trustPrimitives: false, |
| 501 this.trustTypeAnnotations: false, | 507 this.trustTypeAnnotations: false, |
| 502 this.useContentSecurityPolicy: false, | 508 this.useContentSecurityPolicy: false, |
| 509 this.useKernel: false, |
| 503 this.useFrequencyNamer: false, | 510 this.useFrequencyNamer: false, |
| 504 this.useNewSourceInfo: false, | 511 this.useNewSourceInfo: false, |
| 505 this.useStartupEmitter: false, | 512 this.useStartupEmitter: false, |
| 506 this.verbose: false}) | 513 this.verbose: false}) |
| 507 : _shownPackageWarnings = shownPackageWarnings; | 514 : _shownPackageWarnings = shownPackageWarnings; |
| 508 | 515 |
| 509 /// Creates a copy of the [CompilerOptions] where the provided non-null | 516 /// Creates a copy of the [CompilerOptions] where the provided non-null |
| 510 /// option values replace existing. | 517 /// option values replace existing. |
| 511 static CompilerOptions copy(CompilerOptions options, | 518 static CompilerOptions copy(CompilerOptions options, |
| 512 {entryPoint, | 519 {entryPoint, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 resolutionOutput, | 557 resolutionOutput, |
| 551 resolveOnly, | 558 resolveOnly, |
| 552 compileOnly, | 559 compileOnly, |
| 553 sourceMapUri, | 560 sourceMapUri, |
| 554 strips, | 561 strips, |
| 555 testMode, | 562 testMode, |
| 556 trustJSInteropTypeAnnotations, | 563 trustJSInteropTypeAnnotations, |
| 557 trustPrimitives, | 564 trustPrimitives, |
| 558 trustTypeAnnotations, | 565 trustTypeAnnotations, |
| 559 useContentSecurityPolicy, | 566 useContentSecurityPolicy, |
| 567 useKernel, |
| 560 useFrequencyNamer, | 568 useFrequencyNamer, |
| 561 useNewSourceInfo, | 569 useNewSourceInfo, |
| 562 useStartupEmitter, | 570 useStartupEmitter, |
| 563 verbose}) { | 571 verbose}) { |
| 564 return new CompilerOptions._( | 572 return new CompilerOptions._( |
| 565 entryPoint ?? options.entryPoint, | 573 entryPoint ?? options.entryPoint, |
| 566 libraryRoot ?? options.libraryRoot, | 574 libraryRoot ?? options.libraryRoot, |
| 567 packageRoot ?? options.packageRoot, | 575 packageRoot ?? options.packageRoot, |
| 568 packageConfig ?? options.packageConfig, | 576 packageConfig ?? options.packageConfig, |
| 569 packagesDiscoveryProvider ?? options.packagesDiscoveryProvider, | 577 packagesDiscoveryProvider ?? options.packagesDiscoveryProvider, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 sourceMapUri: sourceMapUri ?? options.sourceMapUri, | 627 sourceMapUri: sourceMapUri ?? options.sourceMapUri, |
| 620 strips: strips ?? options.strips, | 628 strips: strips ?? options.strips, |
| 621 testMode: testMode ?? options.testMode, | 629 testMode: testMode ?? options.testMode, |
| 622 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations ?? | 630 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations ?? |
| 623 options.trustJSInteropTypeAnnotations, | 631 options.trustJSInteropTypeAnnotations, |
| 624 trustPrimitives: trustPrimitives ?? options.trustPrimitives, | 632 trustPrimitives: trustPrimitives ?? options.trustPrimitives, |
| 625 trustTypeAnnotations: | 633 trustTypeAnnotations: |
| 626 trustTypeAnnotations ?? options.trustTypeAnnotations, | 634 trustTypeAnnotations ?? options.trustTypeAnnotations, |
| 627 useContentSecurityPolicy: | 635 useContentSecurityPolicy: |
| 628 useContentSecurityPolicy ?? options.useContentSecurityPolicy, | 636 useContentSecurityPolicy ?? options.useContentSecurityPolicy, |
| 637 useKernel: useKernel ?? options.useKernel, |
| 629 useFrequencyNamer: useFrequencyNamer ?? options.useFrequencyNamer, | 638 useFrequencyNamer: useFrequencyNamer ?? options.useFrequencyNamer, |
| 630 useNewSourceInfo: useNewSourceInfo ?? options.useNewSourceInfo, | 639 useNewSourceInfo: useNewSourceInfo ?? options.useNewSourceInfo, |
| 631 useStartupEmitter: useStartupEmitter ?? options.useStartupEmitter, | 640 useStartupEmitter: useStartupEmitter ?? options.useStartupEmitter, |
| 632 verbose: verbose ?? options.verbose); | 641 verbose: verbose ?? options.verbose); |
| 633 } | 642 } |
| 634 | 643 |
| 635 /// Returns `true` if warnings and hints are shown for all packages. | 644 /// Returns `true` if warnings and hints are shown for all packages. |
| 636 bool get showAllPackageWarnings { | 645 bool get showAllPackageWarnings { |
| 637 return _shownPackageWarnings != null && _shownPackageWarnings.isEmpty; | 646 return _shownPackageWarnings != null && _shownPackageWarnings.isEmpty; |
| 638 } | 647 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 } | 735 } |
| 727 | 736 |
| 728 /// Locations of the platform descriptor files relative to the library root. | 737 /// Locations of the platform descriptor files relative to the library root. |
| 729 const String _clientPlatform = "lib/dart_client.platform"; | 738 const String _clientPlatform = "lib/dart_client.platform"; |
| 730 const String _serverPlatform = "lib/dart_server.platform"; | 739 const String _serverPlatform = "lib/dart_server.platform"; |
| 731 const String _sharedPlatform = "lib/dart_shared.platform"; | 740 const String _sharedPlatform = "lib/dart_shared.platform"; |
| 732 | 741 |
| 733 const String _UNDETERMINED_BUILD_ID = "build number could not be determined"; | 742 const String _UNDETERMINED_BUILD_ID = "build number could not be determined"; |
| 734 const bool _forceIncrementalSupport = | 743 const bool _forceIncrementalSupport = |
| 735 const bool.fromEnvironment('DART2JS_EXPERIMENTAL_INCREMENTAL_SUPPORT'); | 744 const bool.fromEnvironment('DART2JS_EXPERIMENTAL_INCREMENTAL_SUPPORT'); |
| OLD | NEW |