Replace strongMode with legacyMode in CompilerOptions

Also, remove --strong and --strong-mode flags (use --legacy-mode
flag to enable legacy mode).

Change-Id: I577ab5f755a2bee88f0f4d63915a6e852e792f06
Reviewed-on: https://dart-review.googlesource.com/c/79000
Commit-Queue: Jens Johansen <jensj@google.com>
Auto-Submit: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
This commit is contained in:
Peter von der Ahé 2018-10-10 12:04:26 +00:00 committed by commit-bot@chromium.org
parent aa6fb2d3a4
commit ee97806084
33 changed files with 47 additions and 59 deletions

View file

@ -76,7 +76,6 @@ CompilerOptions _makeCompilerOptions(Uri packagesFileUri, Uri platformUri,
..fileSystem = fileSystem
..packagesFileUri = packagesFileUri
..sdkSummary = platformUri
..strongMode = true
..target = target
..throwOnErrorsForDebugging = false
..embedSourceText = false

View file

@ -137,8 +137,8 @@ class CompilerOptions {
@deprecated
bool chaseDependencies;
/// Whether to interpret Dart sources in strong-mode.
bool strongMode = true;
/// True if enabling legacy mode (Dart 1 compatibility).
bool legacyMode = false;
/// Patch files to apply on the core libraries for a specific target platform.
///

View file

@ -106,7 +106,7 @@ InitializedCompilerState initializeCompiler(
CompilerOptions options = new CompilerOptions()
..target = target
..strongMode = target.strongMode
..legacyMode = !target.strongMode
..linkedDependencies = [sdkPlatformUri]
..librariesSpecificationUri = librariesSpecificationUri
..packagesFileUri = packagesFileUri;

View file

@ -300,15 +300,14 @@ class ProcessedOptions {
/// effect.
void clearFileSystemCache() => _fileSystem = null;
/// Whether to interpret Dart sources in strong-mode.
bool get strongMode => _raw.strongMode;
bool get legacyMode => _raw.legacyMode;
/// Whether to generate bytecode.
bool get bytecode => _raw.bytecode;
Target _target;
Target get target => _target ??=
_raw.target ?? new NoneTarget(new TargetFlags(strongMode: strongMode));
_raw.target ?? new NoneTarget(new TargetFlags(strongMode: !legacyMode));
/// Get an outline component that summarizes the SDK, if any.
// TODO(sigmund): move, this doesn't feel like an "option".
@ -624,7 +623,7 @@ class ProcessedOptions {
'(provided: ${_raw.librariesSpecificationUri})');
sb.writeln('SDK summary: ${_sdkSummary} (provided: ${_raw.sdkSummary})');
sb.writeln('Strong: ${strongMode}');
sb.writeln('Legacy mode: ${legacyMode}');
sb.writeln('Target: ${_target?.name} (provided: ${_raw.target?.name})');
sb.writeln('throwOnErrorsForDebugging: ${throwOnErrorsForDebugging}');

View file

@ -188,7 +188,7 @@ bool isCompileTimeError(Severity severity) {
return true;
case Severity.errorLegacyWarning:
return CompilerContext.current.options.strongMode;
return !CompilerContext.current.options.legacyMode;
case Severity.warning:
case Severity.context:

View file

@ -140,8 +140,7 @@ void main() {
..onProblem = (FormattedMessage message, Severity severity,
List<FormattedMessage> context) {
Expect.fail("Unexpected error: ${message.formatted}");
}
..strongMode = true;
};
Component p = await compileScript(test.source,
options: options, fileName: 'synthetic-test.dart');
Expect.isNotNull(p);

View file

@ -53,7 +53,6 @@ Future runCompiler(Uri compiler, Uri input, Uri output) async {
"--compile-sdk=sdk/",
"--output=${output.toFilePath()}",
"--verify",
"--strong",
input.toFilePath(),
],
suppressOutput: false);

View file

@ -378,7 +378,6 @@ Future<Context> createContext(
final List<CompilationMessage> errors = <CompilationMessage>[];
final CompilerOptions optionBuilder = new CompilerOptions()
..strongMode = true
..target = new VmTarget(new TargetFlags(strongMode: true))
..reportMessages = true
..verbose = true

View file

@ -41,7 +41,7 @@ test({bool sdkFromSource}) async {
final CompilerOptions optionBuilder = new CompilerOptions()
..packagesFileUri = Uri.base.resolve(".packages")
..target = new VmTarget(new TargetFlags(strongMode: false))
..strongMode = false
..legacyMode = true
..onProblem = problemHandler;
if (sdkFromSource) {

View file

@ -214,7 +214,7 @@ Future<Context> createContext(
final List<CompilationMessage> errors = <CompilationMessage>[];
final CompilerOptions optionBuilder = new CompilerOptions()
..strongMode = false
..legacyMode = true
..reportMessages = true
..verbose = true
..fileSystem = fs

View file

@ -465,8 +465,7 @@ class Compile extends Step<Example, Null, MessageTestSuite> {
..onProblem = (FormattedMessage problem, Severity severity,
List<FormattedMessage> context) {
problems.add([problem, severity]);
}
..strongMode = true,
},
main,
output);

View file

@ -85,8 +85,7 @@ ProblemHandler _makeProblemHandler(Set<String> names) {
testDisabledSuperMixins() async {
var missingSuperMethodNames = new Set<String>();
var options = new CompilerOptions()
..onProblem = _makeProblemHandler(missingSuperMethodNames)
..strongMode = true;
..onProblem = _makeProblemHandler(missingSuperMethodNames);
await compileScript(testSource, options: options);
Expect.setEquals(
const <String>['bar', 'baz', 'foo', 'quux'], missingSuperMethodNames);
@ -100,11 +99,10 @@ testEnabledSuperMixins() async {
var missingSuperMethodNames = new Set<String>();
var options = new CompilerOptions()
..onProblem = _makeProblemHandler(missingSuperMethodNames)
..strongMode = true
..target = new NoneTargetWithSuperMixins(new TargetFlags(strongMode: true));
await compileScript(testSource, options: options);
Expect
.setEquals(const <String>['baz', 'foo', 'quux'], missingSuperMethodNames);
Expect.setEquals(
const <String>['baz', 'foo', 'quux'], missingSuperMethodNames);
}
void main() {

View file

@ -242,7 +242,9 @@ class Run extends Step<Uri, int, FastaContext> {
try {
var args = <String>[];
if (context.strongMode) {
// TODO(ahe): This argument is probably ignored by the VM.
args.add('--strong');
// TODO(ahe): This argument is probably ignored by the VM.
args.add('--reify-generic-functions');
}
args.add(generated.path);
@ -276,6 +278,7 @@ class Outline extends Step<TestDescription, Component, FastaContext> {
StringBuffer errors = new StringBuffer();
ProcessedOptions options = new ProcessedOptions(
options: new CompilerOptions()
..legacyMode = !strongMode
..onProblem = (FormattedMessage problem, Severity severity,
List<FormattedMessage> context) {
if (errors.isNotEmpty) {

View file

@ -299,7 +299,7 @@ IncrementalKernelGenerator createIncrementalCompiler(
var options = new CompilerOptions()
..sdkRoot = sdkRoot
..librariesSpecificationUri = Uri.base.resolve("sdk/lib/libraries.json")
..strongMode = false
..legacyMode = true
..fileSystem = fs;
return new IncrementalKernelGenerator(options, entryUri);
}

View file

@ -64,7 +64,7 @@ CompilerOptions getOptions(bool strong) {
List<FormattedMessage> context) {
// ignore
}
..strongMode = strong;
..legacyMode = !strong;
if (strong) {
options.sdkSummary =
computePlatformBinariesLocation().resolve("vm_platform_strong.dill");
@ -155,7 +155,7 @@ class RunTest extends Step<TestDescription, TestDescription, Context> {
}
for (int i = 0; i < length; ++i) {
if (a[i] != b[i]) {
Expect.fail("Data differs at byte ${i+1}.");
Expect.fail("Data differs at byte ${i + 1}.");
}
}
Expect.equals(a.length, b.length);

View file

@ -367,7 +367,7 @@ CompilerOptions getOptions(bool strong) {
Expect.fail("Unexpected error: ${problem.formatted}");
}
}
..strongMode = strong;
..legacyMode = !strong;
if (strong) {
options.sdkSummary = sdkRoot.resolve("vm_platform_strong.dill");
} else {

View file

@ -222,7 +222,7 @@ const Map<String, dynamic> optionSpecification = const <String, dynamic>{
"--fatal": ",",
"--help": false,
"--legacy": "--legacy-mode",
"--legacy-mode": true,
"--legacy-mode": false,
"--libraries-json": Uri,
"--output": Uri,
"--packages": Uri,
@ -230,8 +230,6 @@ const Map<String, dynamic> optionSpecification = const <String, dynamic>{
"--sdk": Uri,
"--single-root-scheme": String,
"--single-root-base": Uri,
"--strong": "--strong-mode",
"--strong-mode": false,
"--sync-async": true,
"--target": String,
"--verbose": false,
@ -267,14 +265,14 @@ ProcessedOptions analyzeCommandLine(
"Can't specify both '--compile-sdk' and '--platform'.");
}
final bool strongMode = options["--strong-mode"] || !options["--legacy-mode"];
final bool legacyMode = options["--legacy-mode"];
final bool syncAsync = options["--sync-async"];
final String targetName = options["--target"] ?? "vm";
final TargetFlags flags =
new TargetFlags(strongMode: strongMode, syncAsync: syncAsync);
new TargetFlags(strongMode: !legacyMode, syncAsync: syncAsync);
final Target target = getTarget(targetName, flags);
if (target == null) {
@ -342,7 +340,7 @@ ProcessedOptions analyzeCommandLine(
..setExitCodeOnProblem = true
..fileSystem = fileSystem
..packagesFileUri = packages
..strongMode = strongMode
..legacyMode = legacyMode
..target = target
..throwOnErrorsForDebugging = errorsAreFatal
..throwOnWarningsForDebugging = warningsAreFatal
@ -368,7 +366,7 @@ ProcessedOptions analyzeCommandLine(
? null
: (options["--platform"] ??
computePlatformBinariesLocation().resolve(
strongMode ? "vm_platform_strong.dill" : "vm_platform.dill"));
legacyMode ? "vm_platform.dill" : "vm_platform_strong.dill"));
CompilerOptions compilerOptions = new CompilerOptions()
..compileSdk = compileSdk
@ -376,7 +374,7 @@ ProcessedOptions analyzeCommandLine(
..sdkRoot = sdk
..sdkSummary = platform
..packagesFileUri = packages
..strongMode = strongMode
..legacyMode = legacyMode
..target = target
..throwOnErrorsForDebugging = errorsAreFatal
..throwOnWarningsForDebugging = warningsAreFatal

View file

@ -24,7 +24,6 @@ main(List<String> arguments) {
ProcessResult result = await Process.run(dartVm.toFilePath(), <String>[
compilePlatform.toFilePath(),
"-v",
"--strong",
"dart:core",
librariesJson.toFilePath(),
outlineDill.toFilePath(),

View file

@ -229,7 +229,7 @@ class CompileTask {
}
KernelTarget createKernelTarget(
DillTarget dillTarget, UriTranslator uriTranslator, bool strongMode) {
DillTarget dillTarget, UriTranslator uriTranslator) {
return new KernelTarget(c.fileSystem, false, dillTarget, uriTranslator,
uriToSource: c.uriToSource);
}
@ -238,8 +238,7 @@ class CompileTask {
UriTranslator uriTranslator = await c.options.getUriTranslator();
ticker.logMs("Read packages file");
DillTarget dillTarget = createDillTarget(uriTranslator);
KernelTarget kernelTarget =
createKernelTarget(dillTarget, uriTranslator, c.options.strongMode);
KernelTarget kernelTarget = createKernelTarget(dillTarget, uriTranslator);
Uri platform = c.options.sdkSummary;
if (platform != null) {
_appendDillForUri(dillTarget, platform);
@ -330,7 +329,7 @@ Future compilePlatformInternal(CompilerContext c, Uri fullOutput,
c.options.ticker.logMs("Wrote outline to ${outlineOutput.toFilePath()}");
if (c.options.bytecode) {
generateBytecode(result.component, strongMode: c.options.strongMode);
generateBytecode(result.component, strongMode: !c.options.legacyMode);
}
await writeComponentToFile(result.component, fullOutput,

View file

@ -232,7 +232,7 @@ generateKernel(Uri entryUri,
..sdkRoot = sdkRoot
..reportMessages = true
..onError = onErrorHandler(strongMode)
..strongMode = strongMode
..legacyMode = !strongMode
..target = createTarget(isFlutter: false, strongMode: strongMode)
..packagesFileUri = Uri.base.resolve('.packages')
..compileSdk = compileSdk;

View file

@ -111,7 +111,7 @@ Future benchmark(
var compilerOptions = new CompilerOptions()
..verbose = verboseCompilation
..fileSystem = overlayFs
..strongMode = strongMode
..legacyMode = !strongMode
..onError = onErrorHandler(strongMode)
..target = createTarget(isFlutter: isFlutter, strongMode: strongMode);
if (sdkSummary != null) {

View file

@ -97,7 +97,7 @@ Future<int> compile(List<String> arguments) async {
final errorDetector = new ErrorDetector(previousErrorHandler: errorPrinter);
final CompilerOptions compilerOptions = new CompilerOptions()
..strongMode = strongMode
..legacyMode = !strongMode
..target = new VmTarget(
new TargetFlags(strongMode: strongMode, syncAsync: syncAsync))
..linkedDependencies = <Uri>[

View file

@ -88,7 +88,7 @@ abstract class Compiler {
}
options = new CompilerOptions()
..strongMode = strongMode
..legacyMode = !strongMode
..fileSystem = fileSystem
..target = new VmTarget(
new TargetFlags(strongMode: strongMode, syncAsync: syncAsync))

View file

@ -267,7 +267,7 @@ class FrontendCompiler implements CompilerInterface {
final CompilerOptions compilerOptions = new CompilerOptions()
..sdkRoot = sdkRoot
..packagesFileUri = _getFileOrUri(_options['packages'])
..strongMode = options['strong']
..legacyMode = !options['strong']
..sdkSummary = sdkRoot.resolve(platformKernelDill)
..verbose = options['verbose']
..embedSourceText = options['embed-source-text']

View file

@ -64,7 +64,7 @@ Future<Component> compileToKernel(Uri source, CompilerOptions options,
source,
options,
component,
options.strongMode,
!options.legacyMode,
useGlobalTypeFlowAnalysis,
environmentDefines,
enableAsserts,
@ -75,7 +75,7 @@ Future<Component> compileToKernel(Uri source, CompilerOptions options,
if (genBytecode && !errorDetector.hasCompilationErrors && component != null) {
await runWithFrontEndCompilerContext(source, options, component, () {
generateBytecode(component,
strongMode: options.strongMode,
strongMode: !options.legacyMode,
dropAST: dropAST,
environmentDefines: environmentDefines);
});

View file

@ -24,7 +24,6 @@ runTestCase(Uri source) async {
enableSuperMixins: enableSuperMixins);
final options = new CompilerOptions()
..strongMode = true
..onDiagnostic = (DiagnosticMessage message) {
fail("Compilation error: ${message.plainTextFormatted.join('\n')}");
};

View file

@ -35,7 +35,6 @@ Future<Component> compileTestCaseToKernelProgram(Uri sourceUri,
target ??= new TestingVmTarget(new TargetFlags(strongMode: true))
..enableSuperMixins = enableSuperMixins;
final options = new CompilerOptions()
..strongMode = true
..target = target
..linkedDependencies = <Uri>[platformKernel]
..onDiagnostic = (DiagnosticMessage message) {

View file

@ -29,7 +29,6 @@ main() {
final sdkRoot = computePlatformBinariesLocation();
final options = new CompilerOptions()
..sdkRoot = sdkRoot
..strongMode = true
..target = new VmTarget(new TargetFlags(strongMode: true))
..linkedDependencies = <Uri>[platformKernel]
..onDiagnostic = (DiagnosticMessage message) {

View file

@ -105,7 +105,10 @@ compile_platform("vm_legacy_platform") {
"$root_out_dir/vm_outline.dill",
]
args = [ "dart:core" ]
args = [
"--legacy-mode",
"dart:core",
]
}
compile_platform("vm_platform") {
@ -120,10 +123,7 @@ compile_platform("vm_platform") {
"$root_out_dir/vm_outline_strong.dill",
]
args = [
"--strong-mode",
"dart:core",
]
args = [ "dart:core" ]
if (dart_platform_bytecode) {
args += [ "--bytecode" ]

View file

@ -192,7 +192,7 @@ Future<List<Uri>> compilePlatform(
Uri patchedSdk, Target target, Uri packages, Uri output) async {
var options = new CompilerOptions()
..setExitCodeOnProblem = true
..strongMode = false
..legacyMode = true
..compileSdk = true
..sdkRoot = patchedSdk
..packagesFileUri = packages

View file

@ -1136,8 +1136,8 @@ class FastaCompilerConfiguration extends CompilerConfiguration {
var outputFileName = output.toFilePath();
var compilerArguments = <String>[];
if (!_isLegacy) {
compilerArguments.add("--strong-mode");
if (_isLegacy) {
compilerArguments.add("--legacy-mode");
}
compilerArguments.addAll(

View file

@ -480,9 +480,11 @@ class VMTestSuite extends TestSuite {
void _addTest(ExpectationSet testExpectations, String testName) {
var args = configuration.standardOptions.toList();
if (configuration.compilerConfiguration.previewDart2) {
// TODO(ahe): Are any of these arguments used or needed?
args.add('--use-dart-frontend');
// '--dfe' has to be the first argument for run_vm_test to pick it up.
args.insert(0, '--dfe=$buildDir/gen/kernel-service.dart.snapshot');
// TODO(ahe): This argument is probably ignored by the VM.
args.add('--strong');
}

View file

@ -88,7 +88,6 @@ compile_platform("compile_dart2js_platform") {
args = [
"--target=dart2js",
"--strong",
"dart:core",
]
}
@ -104,7 +103,6 @@ compile_platform("compile_dart2js_server_platform") {
args = [
"--target=dart2js_server",
"--strong",
"dart:core",
]
}