[cfe] Add flags for new experimental features

Add flags for extension-methods, non-nullable, and triple-shift.

Change-Id: I42d2afbe1b3353a18da8cdfec1fded3ad6694e3a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103620
Auto-Submit: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
This commit is contained in:
Kevin Millikin 2019-05-24 13:54:18 +00:00 committed by commit-bot@chromium.org
parent 052272d998
commit 10692669e3
3 changed files with 21 additions and 1 deletions

View file

@ -7,8 +7,11 @@
enum ExperimentalFlag {
constantUpdate2018,
controlFlowCollections,
extensionMethods,
nonNullable,
setLiterals,
spreadCollections,
tripleShift,
}
ExperimentalFlag parseExperimentalFlag(String flag) {
@ -17,10 +20,16 @@ ExperimentalFlag parseExperimentalFlag(String flag) {
return ExperimentalFlag.constantUpdate2018;
case "control-flow-collections":
return ExperimentalFlag.controlFlowCollections;
case "extension-methods":
return ExperimentalFlag.extensionMethods;
case "non-nullable":
return ExperimentalFlag.nonNullable;
case "set-literals":
return ExperimentalFlag.setLiterals;
case "spread-collections":
return ExperimentalFlag.spreadCollections;
case "triple-shift":
return ExperimentalFlag.tripleShift;
}
return null;
}
@ -28,6 +37,9 @@ ExperimentalFlag parseExperimentalFlag(String flag) {
const Map<ExperimentalFlag, bool> defaultExperimentalFlags = {
ExperimentalFlag.constantUpdate2018: false,
ExperimentalFlag.controlFlowCollections: true,
ExperimentalFlag.extensionMethods: false,
ExperimentalFlag.nonNullable: false,
ExperimentalFlag.setLiterals: true,
ExperimentalFlag.spreadCollections: true,
ExperimentalFlag.tripleShift: false,
};

View file

@ -316,7 +316,6 @@ class ProcessedOptions {
assert(defaultExperimentalFlags.containsKey(flag),
"No default value for $flag.");
// TODO(askesc): Determine default flag value from specification file.
if (flag == ExperimentalFlag.setLiterals) return true;
return _raw.experimentalFlags[flag] ?? defaultExperimentalFlags[flag];
}

View file

@ -50,18 +50,27 @@ abstract class TargetImplementation extends Target {
bool enableConstantUpdate2018;
bool enableControlFlowCollections;
bool enableExtensionMethods;
bool enableNonNullable;
bool enableSetLiterals;
bool enableSpreadCollections;
bool enableTripleShift;
TargetImplementation(Ticker ticker, this.uriTranslator, this.backendTarget)
: enableConstantUpdate2018 = CompilerContext.current.options
.isExperimentEnabled(ExperimentalFlag.constantUpdate2018),
enableControlFlowCollections = CompilerContext.current.options
.isExperimentEnabled(ExperimentalFlag.controlFlowCollections),
enableExtensionMethods = CompilerContext.current.options
.isExperimentEnabled(ExperimentalFlag.extensionMethods),
enableNonNullable = CompilerContext.current.options
.isExperimentEnabled(ExperimentalFlag.nonNullable),
enableSetLiterals = CompilerContext.current.options
.isExperimentEnabled(ExperimentalFlag.setLiterals),
enableSpreadCollections = CompilerContext.current.options
.isExperimentEnabled(ExperimentalFlag.spreadCollections),
enableTripleShift = CompilerContext.current.options
.isExperimentEnabled(ExperimentalFlag.tripleShift),
super(ticker);
/// Creates a [LibraryBuilder] corresponding to [uri], if one doesn't exist