From 10692669e3054a0e377d564d079d6fc674f12295 Mon Sep 17 00:00:00 2001 From: Kevin Millikin Date: Fri, 24 May 2019 13:54:18 +0000 Subject: [PATCH] [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 Reviewed-by: Aske Simon Christensen Commit-Queue: Kevin Millikin --- .../lib/src/api_prototype/experimental_flags.dart | 12 ++++++++++++ pkg/front_end/lib/src/base/processed_options.dart | 1 - .../lib/src/fasta/target_implementation.dart | 9 +++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pkg/front_end/lib/src/api_prototype/experimental_flags.dart b/pkg/front_end/lib/src/api_prototype/experimental_flags.dart index d0615fd6a9d..f91b17d077e 100644 --- a/pkg/front_end/lib/src/api_prototype/experimental_flags.dart +++ b/pkg/front_end/lib/src/api_prototype/experimental_flags.dart @@ -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 defaultExperimentalFlags = { ExperimentalFlag.constantUpdate2018: false, ExperimentalFlag.controlFlowCollections: true, + ExperimentalFlag.extensionMethods: false, + ExperimentalFlag.nonNullable: false, ExperimentalFlag.setLiterals: true, ExperimentalFlag.spreadCollections: true, + ExperimentalFlag.tripleShift: false, }; diff --git a/pkg/front_end/lib/src/base/processed_options.dart b/pkg/front_end/lib/src/base/processed_options.dart index 3746481dacc..a3e6cbe5a7c 100644 --- a/pkg/front_end/lib/src/base/processed_options.dart +++ b/pkg/front_end/lib/src/base/processed_options.dart @@ -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]; } diff --git a/pkg/front_end/lib/src/fasta/target_implementation.dart b/pkg/front_end/lib/src/fasta/target_implementation.dart index 6e82a7df864..2ca6f7787ff 100644 --- a/pkg/front_end/lib/src/fasta/target_implementation.dart +++ b/pkg/front_end/lib/src/fasta/target_implementation.dart @@ -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