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

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

Issue 2989453002: Add support for compiling Dart via the FE in dart2js. (Closed)
Patch Set: update status Created 3 years, 4 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) 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 controlling diagnostic messages. 10 /// Options used for controlling diagnostic messages.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 /// Whether to trust primitive types during inference and optimizations. 193 /// Whether to trust primitive types during inference and optimizations.
194 final bool trustPrimitives; 194 final bool trustPrimitives;
195 195
196 /// Whether to trust type annotations during inference and optimizations. 196 /// Whether to trust type annotations during inference and optimizations.
197 final bool trustTypeAnnotations; 197 final bool trustTypeAnnotations;
198 198
199 /// Whether to generate code compliant with content security policy (CSP). 199 /// Whether to generate code compliant with content security policy (CSP).
200 final bool useContentSecurityPolicy; 200 final bool useContentSecurityPolicy;
201 201
202 /// Whether to use kernel internally as part of compilation. 202 /// Whether to use kernel internally as part of compilation.
203 final bool useKernelInSsa;
204
205 /// Preview the unified front-end and compilation from kernel.
206 ///
207 /// When enabled the compiler will use the unified front-end to compile
208 /// sources to kernel, and then continue compilation from the kernel
209 /// representation. Setting this flag will implicitly set [useKernelInSsa] to
210 /// true as well.
211 ///
212 /// When this flag is on, the compiler also acccepts reading .dill files from
213 /// disk. The compiler reads the sources differently depending on the
214 /// extension format.
203 final bool useKernel; 215 final bool useKernel;
204 216
205 /// Read input from a .dill file rather than a .dart input (only to be used in
206 /// conjunction with useKernel = true).
207 final bool loadFromDill;
208
209 // Whether to use kernel internally for global type inference calculations. 217 // Whether to use kernel internally for global type inference calculations.
210 // TODO(efortuna): Remove this and consolidate with useKernel. 218 // TODO(efortuna): Remove this and consolidate with useKernel.
211 final bool kernelGlobalInference; 219 final bool kernelGlobalInference;
212 220
213 /// When obfuscating for minification, whether to use the frequency of a name 221 /// When obfuscating for minification, whether to use the frequency of a name
214 /// as an heuristic to pick shorter names. 222 /// as an heuristic to pick shorter names.
215 final bool useFrequencyNamer; 223 final bool useFrequencyNamer;
216 224
217 /// Whether to generate source-information from both the old and the new 225 /// Whether to generate source-information from both the old and the new
218 /// source-information engines. (experimental) 226 /// source-information engines. (experimental)
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 resolveOnly: _hasOption(options, Flags.resolveOnly), 324 resolveOnly: _hasOption(options, Flags.resolveOnly),
317 sourceMapUri: _extractUriOption(options, '--source-map='), 325 sourceMapUri: _extractUriOption(options, '--source-map='),
318 strips: _extractCsvOption(options, '--force-strip='), 326 strips: _extractCsvOption(options, '--force-strip='),
319 testMode: _hasOption(options, Flags.testMode), 327 testMode: _hasOption(options, Flags.testMode),
320 trustJSInteropTypeAnnotations: 328 trustJSInteropTypeAnnotations:
321 _hasOption(options, Flags.trustJSInteropTypeAnnotations), 329 _hasOption(options, Flags.trustJSInteropTypeAnnotations),
322 trustPrimitives: _hasOption(options, Flags.trustPrimitives), 330 trustPrimitives: _hasOption(options, Flags.trustPrimitives),
323 trustTypeAnnotations: _hasOption(options, Flags.trustTypeAnnotations), 331 trustTypeAnnotations: _hasOption(options, Flags.trustTypeAnnotations),
324 useContentSecurityPolicy: 332 useContentSecurityPolicy:
325 _hasOption(options, Flags.useContentSecurityPolicy), 333 _hasOption(options, Flags.useContentSecurityPolicy),
334 useKernelInSsa: _hasOption(options, Flags.useKernelInSsa),
326 useKernel: _hasOption(options, Flags.useKernel), 335 useKernel: _hasOption(options, Flags.useKernel),
327 loadFromDill: _hasOption(options, Flags.loadFromDill),
328 useFrequencyNamer: 336 useFrequencyNamer:
329 !_hasOption(options, Flags.noFrequencyBasedMinification), 337 !_hasOption(options, Flags.noFrequencyBasedMinification),
330 useMultiSourceInfo: _hasOption(options, Flags.useMultiSourceInfo), 338 useMultiSourceInfo: _hasOption(options, Flags.useMultiSourceInfo),
331 useNewSourceInfo: _hasOption(options, Flags.useNewSourceInfo), 339 useNewSourceInfo: _hasOption(options, Flags.useNewSourceInfo),
332 useStartupEmitter: _hasOption(options, Flags.fastStartup), 340 useStartupEmitter: _hasOption(options, Flags.fastStartup),
333 verbose: _hasOption(options, Flags.verbose)); 341 verbose: _hasOption(options, Flags.verbose));
334 } 342 }
335 343
336 /// Creates an option object for the compiler. 344 /// Creates an option object for the compiler.
337 /// 345 ///
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 List<Uri> resolutionInputs: null, 387 List<Uri> resolutionInputs: null,
380 Uri resolutionOutput: null, 388 Uri resolutionOutput: null,
381 bool resolveOnly: false, 389 bool resolveOnly: false,
382 Uri sourceMapUri: null, 390 Uri sourceMapUri: null,
383 List<String> strips: const [], 391 List<String> strips: const [],
384 bool testMode: false, 392 bool testMode: false,
385 bool trustJSInteropTypeAnnotations: false, 393 bool trustJSInteropTypeAnnotations: false,
386 bool trustPrimitives: false, 394 bool trustPrimitives: false,
387 bool trustTypeAnnotations: false, 395 bool trustTypeAnnotations: false,
388 bool useContentSecurityPolicy: false, 396 bool useContentSecurityPolicy: false,
397 bool useKernelInSsa: false,
389 bool useKernel: false, 398 bool useKernel: false,
390 bool loadFromDill: false,
391 bool useFrequencyNamer: true, 399 bool useFrequencyNamer: true,
392 bool useMultiSourceInfo: false, 400 bool useMultiSourceInfo: false,
393 bool useNewSourceInfo: false, 401 bool useNewSourceInfo: false,
394 bool useStartupEmitter: false, 402 bool useStartupEmitter: false,
395 bool verbose: false}) { 403 bool verbose: false}) {
396 // TODO(sigmund): should entrypoint be here? should we validate it is not 404 // TODO(sigmund): should entrypoint be here? should we validate it is not
397 // null? In unittests we use the same compiler to analyze or build multiple 405 // null? In unittests we use the same compiler to analyze or build multiple
398 // entrypoints. 406 // entrypoints.
399 if (libraryRoot == null) { 407 if (libraryRoot == null) {
400 throw new ArgumentError("[libraryRoot] is null."); 408 throw new ArgumentError("[libraryRoot] is null.");
(...skipping 24 matching lines...) Expand all
425 analyzeOnly: 433 analyzeOnly:
426 analyzeOnly || analyzeSignaturesOnly || analyzeAll || resolveOnly, 434 analyzeOnly || analyzeSignaturesOnly || analyzeAll || resolveOnly,
427 analyzeSignaturesOnly: analyzeSignaturesOnly, 435 analyzeSignaturesOnly: analyzeSignaturesOnly,
428 buildId: buildId, 436 buildId: buildId,
429 deferredMapUri: deferredMapUri, 437 deferredMapUri: deferredMapUri,
430 fatalWarnings: fatalWarnings, 438 fatalWarnings: fatalWarnings,
431 terseDiagnostics: terseDiagnostics, 439 terseDiagnostics: terseDiagnostics,
432 suppressWarnings: suppressWarnings, 440 suppressWarnings: suppressWarnings,
433 suppressHints: suppressHints, 441 suppressHints: suppressHints,
434 shownPackageWarnings: shownPackageWarnings, 442 shownPackageWarnings: shownPackageWarnings,
435 disableInlining: disableInlining, 443 // TODO(sigmund): remove once we support inlining and type-inference
436 disableTypeInference: disableTypeInference, 444 // with `useKernel`.
445 disableInlining: disableInlining || useKernel,
446 disableTypeInference: disableTypeInference || useKernel,
437 dumpInfo: dumpInfo, 447 dumpInfo: dumpInfo,
438 enableAssertMessage: enableAssertMessage, 448 enableAssertMessage: enableAssertMessage,
439 enableExperimentalMirrors: enableExperimentalMirrors, 449 enableExperimentalMirrors: enableExperimentalMirrors,
440 enableMinification: enableMinification, 450 enableMinification: enableMinification,
441 enableNativeLiveTypeAnalysis: enableNativeLiveTypeAnalysis, 451 enableNativeLiveTypeAnalysis: enableNativeLiveTypeAnalysis,
442 enableTypeAssertions: enableTypeAssertions, 452 enableTypeAssertions: enableTypeAssertions,
443 enableUserAssertions: enableUserAssertions, 453 enableUserAssertions: enableUserAssertions,
444 experimentalTrackAllocations: experimentalTrackAllocations, 454 experimentalTrackAllocations: experimentalTrackAllocations,
445 experimentalAllocationsPath: experimentalAllocationsPath, 455 experimentalAllocationsPath: experimentalAllocationsPath,
446 generateCodeWithCompileTimeErrors: generateCodeWithCompileTimeErrors, 456 generateCodeWithCompileTimeErrors:
457 generateCodeWithCompileTimeErrors && !useKernel,
447 generateSourceMap: generateSourceMap, 458 generateSourceMap: generateSourceMap,
448 kernelGlobalInference: kernelGlobalInference, 459 kernelGlobalInference: kernelGlobalInference,
449 outputUri: outputUri, 460 outputUri: outputUri,
450 platformConfigUri: platformConfigUri ?? 461 platformConfigUri: platformConfigUri ??
451 _resolvePlatformConfig(libraryRoot, null, const []), 462 _resolvePlatformConfig(libraryRoot, null, const []),
452 preserveComments: preserveComments, 463 preserveComments: preserveComments,
453 preserveUris: preserveUris, 464 preserveUris: preserveUris,
454 resolutionInputs: resolutionInputs, 465 resolutionInputs: resolutionInputs,
455 resolutionOutput: resolutionOutput, 466 resolutionOutput: resolutionOutput,
456 resolveOnly: resolveOnly, 467 resolveOnly: resolveOnly,
457 sourceMapUri: sourceMapUri, 468 sourceMapUri: sourceMapUri,
458 strips: strips, 469 strips: strips,
459 testMode: testMode, 470 testMode: testMode,
460 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations, 471 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations,
461 trustPrimitives: trustPrimitives, 472 trustPrimitives: trustPrimitives,
462 trustTypeAnnotations: trustTypeAnnotations, 473 trustTypeAnnotations: trustTypeAnnotations,
463 useContentSecurityPolicy: useContentSecurityPolicy, 474 useContentSecurityPolicy: useContentSecurityPolicy,
475 useKernelInSsa: useKernelInSsa || useKernel,
464 useKernel: useKernel, 476 useKernel: useKernel,
465 loadFromDill: loadFromDill,
466 useFrequencyNamer: useFrequencyNamer, 477 useFrequencyNamer: useFrequencyNamer,
467 useMultiSourceInfo: useMultiSourceInfo, 478 useMultiSourceInfo: useMultiSourceInfo,
468 useNewSourceInfo: useNewSourceInfo, 479 useNewSourceInfo: useNewSourceInfo,
469 useStartupEmitter: useStartupEmitter, 480 useStartupEmitter: useStartupEmitter,
470 verbose: verbose); 481 verbose: verbose);
471 } 482 }
472 483
473 CompilerOptions._(this.entryPoint, this.libraryRoot, this.packageRoot, 484 CompilerOptions._(this.entryPoint, this.libraryRoot, this.packageRoot,
474 this.packageConfig, this.packagesDiscoveryProvider, this.environment, 485 this.packageConfig, this.packagesDiscoveryProvider, this.environment,
475 {this.allowMockCompilation: false, 486 {this.allowMockCompilation: false,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 this.resolutionOutput: null, 518 this.resolutionOutput: null,
508 this.resolveOnly: false, 519 this.resolveOnly: false,
509 this.compileOnly: false, 520 this.compileOnly: false,
510 this.sourceMapUri: null, 521 this.sourceMapUri: null,
511 this.strips: const [], 522 this.strips: const [],
512 this.testMode: false, 523 this.testMode: false,
513 this.trustJSInteropTypeAnnotations: false, 524 this.trustJSInteropTypeAnnotations: false,
514 this.trustPrimitives: false, 525 this.trustPrimitives: false,
515 this.trustTypeAnnotations: false, 526 this.trustTypeAnnotations: false,
516 this.useContentSecurityPolicy: false, 527 this.useContentSecurityPolicy: false,
528 this.useKernelInSsa: false,
517 this.useKernel: false, 529 this.useKernel: false,
518 this.loadFromDill: false,
519 this.useFrequencyNamer: false, 530 this.useFrequencyNamer: false,
520 this.useMultiSourceInfo: false, 531 this.useMultiSourceInfo: false,
521 this.useNewSourceInfo: false, 532 this.useNewSourceInfo: false,
522 this.useStartupEmitter: false, 533 this.useStartupEmitter: false,
523 this.verbose: false}) 534 this.verbose: false})
524 : _shownPackageWarnings = shownPackageWarnings; 535 : _shownPackageWarnings = shownPackageWarnings;
525 536
526 /// Creates a copy of the [CompilerOptions] where the provided non-null 537 /// Creates a copy of the [CompilerOptions] where the provided non-null
527 /// option values replace existing. 538 /// option values replace existing.
528 static CompilerOptions copy(CompilerOptions options, 539 static CompilerOptions copy(CompilerOptions options,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 resolutionOutput, 578 resolutionOutput,
568 resolveOnly, 579 resolveOnly,
569 compileOnly, 580 compileOnly,
570 sourceMapUri, 581 sourceMapUri,
571 strips, 582 strips,
572 testMode, 583 testMode,
573 trustJSInteropTypeAnnotations, 584 trustJSInteropTypeAnnotations,
574 trustPrimitives, 585 trustPrimitives,
575 trustTypeAnnotations, 586 trustTypeAnnotations,
576 useContentSecurityPolicy, 587 useContentSecurityPolicy,
588 useKernelInSsa,
577 useKernel, 589 useKernel,
578 loadFromDill,
579 useFrequencyNamer, 590 useFrequencyNamer,
580 useMultiSourceInfo, 591 useMultiSourceInfo,
581 useNewSourceInfo, 592 useNewSourceInfo,
582 useStartupEmitter, 593 useStartupEmitter,
583 verbose}) { 594 verbose}) {
584 return new CompilerOptions._( 595 return new CompilerOptions._(
585 entryPoint ?? options.entryPoint, 596 entryPoint ?? options.entryPoint,
586 libraryRoot ?? options.libraryRoot, 597 libraryRoot ?? options.libraryRoot,
587 packageRoot ?? options.packageRoot, 598 packageRoot ?? options.packageRoot,
588 packageConfig ?? options.packageConfig, 599 packageConfig ?? options.packageConfig,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 sourceMapUri: sourceMapUri ?? options.sourceMapUri, 650 sourceMapUri: sourceMapUri ?? options.sourceMapUri,
640 strips: strips ?? options.strips, 651 strips: strips ?? options.strips,
641 testMode: testMode ?? options.testMode, 652 testMode: testMode ?? options.testMode,
642 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations ?? 653 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations ??
643 options.trustJSInteropTypeAnnotations, 654 options.trustJSInteropTypeAnnotations,
644 trustPrimitives: trustPrimitives ?? options.trustPrimitives, 655 trustPrimitives: trustPrimitives ?? options.trustPrimitives,
645 trustTypeAnnotations: 656 trustTypeAnnotations:
646 trustTypeAnnotations ?? options.trustTypeAnnotations, 657 trustTypeAnnotations ?? options.trustTypeAnnotations,
647 useContentSecurityPolicy: 658 useContentSecurityPolicy:
648 useContentSecurityPolicy ?? options.useContentSecurityPolicy, 659 useContentSecurityPolicy ?? options.useContentSecurityPolicy,
660 useKernelInSsa: useKernelInSsa ?? options.useKernelInSsa,
649 useKernel: useKernel ?? options.useKernel, 661 useKernel: useKernel ?? options.useKernel,
650 loadFromDill: loadFromDill ?? options.loadFromDill,
651 useFrequencyNamer: useFrequencyNamer ?? options.useFrequencyNamer, 662 useFrequencyNamer: useFrequencyNamer ?? options.useFrequencyNamer,
652 useMultiSourceInfo: useMultiSourceInfo ?? options.useMultiSourceInfo, 663 useMultiSourceInfo: useMultiSourceInfo ?? options.useMultiSourceInfo,
653 useNewSourceInfo: useNewSourceInfo ?? options.useNewSourceInfo, 664 useNewSourceInfo: useNewSourceInfo ?? options.useNewSourceInfo,
654 useStartupEmitter: useStartupEmitter ?? options.useStartupEmitter, 665 useStartupEmitter: useStartupEmitter ?? options.useStartupEmitter,
655 verbose: verbose ?? options.verbose); 666 verbose: verbose ?? options.verbose);
656 } 667 }
657 668
658 /// Returns `true` if warnings and hints are shown for all packages. 669 /// Returns `true` if warnings and hints are shown for all packages.
659 bool get showAllPackageWarnings { 670 bool get showAllPackageWarnings {
660 return _shownPackageWarnings != null && _shownPackageWarnings.isEmpty; 671 return _shownPackageWarnings != null && _shownPackageWarnings.isEmpty;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 _extractStringOption(options, "--platform-config=", null), 758 _extractStringOption(options, "--platform-config=", null),
748 _extractCsvOption(options, '--categories=')); 759 _extractCsvOption(options, '--categories='));
749 } 760 }
750 761
751 /// Locations of the platform descriptor files relative to the library root. 762 /// Locations of the platform descriptor files relative to the library root.
752 const String _clientPlatform = "lib/dart_client.platform"; 763 const String _clientPlatform = "lib/dart_client.platform";
753 const String _serverPlatform = "lib/dart_server.platform"; 764 const String _serverPlatform = "lib/dart_server.platform";
754 const String _sharedPlatform = "lib/dart_shared.platform"; 765 const String _sharedPlatform = "lib/dart_shared.platform";
755 766
756 const String _UNDETERMINED_BUILD_ID = "build number could not be determined"; 767 const String _UNDETERMINED_BUILD_ID = "build number could not be determined";
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698