Skip to content

Commit c27cec6

Browse files
johnniwintherCommit Queue
authored andcommitted
[cfe] Remove macro support
This removes the support running macros in the CFE. The scanner and package:kernel still have support for the macro modifier. This will be removed in a follow-up. The metadata expression parser is deliberately left in, since it might serve as the basis for a parser AST. Change-Id: I06d91eb0fac2e7a71e6afde647b03be3814dbd5f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406963 Commit-Queue: Johnni Winther <[email protected]> Reviewed-by: Morgan :) <[email protected]>
1 parent 36f0c32 commit c27cec6

File tree

205 files changed

+144
-18491
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+144
-18491
lines changed
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
cfe=pkg/front_end/test/id_tests/metadata_test.dart
2-
analyzer=pkg/analyzer/test/id_tests/metadata_test.dart
3-
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
cfe=pkg/front_end/test/id_tests/metadata_evaluate_test.dart
2-
analyzer=pkg/analyzer/test/id_tests/metadata_evaluate_test.dart
32

pkg/dev_compiler/lib/src/command/command.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,7 @@ Future<CompilerResult> _compile(List<String> args,
295295
explicitExperimentalFlags: explicitExperimentalFlags,
296296
environmentDefines: declaredVariables,
297297
nnbdMode:
298-
options.soundNullSafety ? fe.NnbdMode.Strong : fe.NnbdMode.Weak,
299-
precompiledMacros: options.precompiledMacros,
300-
macroSerializationMode: options.macroSerializationMode);
298+
options.soundNullSafety ? fe.NnbdMode.Strong : fe.NnbdMode.Weak);
301299
result = await fe.compile(compilerState, inputs, diagnosticMessageHandler);
302300
} else {
303301
// If digests weren't given and if not in worker mode, create fake data and

pkg/front_end/lib/src/api_prototype/compiler_options.dart

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@ import 'package:kernel/ast.dart' show Component, Version;
1111
import 'package:kernel/default_language_version.dart' as kernel
1212
show defaultLanguageVersion;
1313
import 'package:kernel/target/targets.dart' show Target;
14-
import 'package:macros/src/executor/multi_executor.dart';
15-
import 'package:macros/src/executor/serialization.dart' as macros
16-
show SerializationMode;
1714

1815
import '../api_unstable/util.dart';
1916
import '../base/nnbd_mode.dart';
20-
import '../macros/macro_serializer.dart';
2117
import 'experimental_flags.dart'
2218
show
2319
AllowedExperimentalFlags,
@@ -110,42 +106,6 @@ class CompilerOptions {
110106
/// file system. TODO(paulberry): fix this.
111107
FileSystem fileSystem = StandardFileSystem.instance;
112108

113-
/// The [MultiMacroExecutor] for loading and executing macros if supported.
114-
///
115-
/// This is part of the experimental macro feature.
116-
MultiMacroExecutor? macroExecutor;
117-
118-
/// If true, all macro applications must have a corresponding prebuilt macro
119-
/// supplied via `precompiledMacros`.
120-
///
121-
/// Otherwise, that's an error.
122-
///
123-
/// This is part of the experimental macro feature.
124-
bool requirePrebuiltMacros = false;
125-
126-
/// Function that can create a [Uri] for the serialized result of a
127-
/// [Component].
128-
///
129-
/// This is used to turn a precompiled macro into a [Uri] that can be loaded
130-
/// by the [macroExecutor].
131-
///
132-
/// If `null` then an appropriate macro serializer will be created.
133-
///
134-
/// [MacroSerializer.close] will be called when `Uri`s created are no longer
135-
/// needed.
136-
///
137-
/// This is part of the experimental macro feature.
138-
MacroSerializer? macroSerializer;
139-
140-
/// Raw precompiled macro options, each of the format
141-
/// `<program-uri>;<macro-library-uri>`.
142-
///
143-
/// Multiple library URIs may be provided separated by additional semicolons.
144-
List<String>? precompiledMacros;
145-
146-
/// The serialization mode to use for macro communication.
147-
macros.SerializationMode? macroSerializationMode;
148-
149109
/// Whether to generate code for the SDK.
150110
///
151111
/// By default the front end resolves components using a prebuilt SDK summary.
@@ -257,9 +217,6 @@ class CompilerOptions {
257217
/// order to ensure a stable output for testing.
258218
bool omitOsMessageForTesting = false;
259219

260-
/// If `true`, macro generated libraries will be printed during compilation.
261-
bool showGeneratedMacroSourcesForTesting = false;
262-
263220
/// Object used for hooking into the compilation pipeline during testing.
264221
HooksForTesting? hooksForTesting;
265222

@@ -299,16 +256,6 @@ class CompilerOptions {
299256
experimentReleasedVersionForTesting: experimentReleasedVersionForTesting,
300257
allowedExperimentalFlags: allowedExperimentalFlagsForTesting);
301258

302-
/// The precompilations already in progress in an outer compile or that will
303-
/// be built in the current compile.
304-
///
305-
/// When a compile discovers macros that are not prebuilt it launches a new
306-
/// nested compile to build them, a precompilation. That precompilation must
307-
/// itself launch more compilations if it encounters more macros. This set
308-
/// tracks what is running so that already-running precompilations are not
309-
/// launched again.
310-
Set<Uri> runningPrecompilations = {};
311-
312259
// Coverage-ignore(suite): Not run.
313260
/// Returns the minimum language version needed for a library with the given
314261
/// [importUri] to opt into the experiment with the given [flag].
@@ -667,22 +614,6 @@ class Verbosity {
667614
// Coverage-ignore(suite): Not run.
668615
/// Interface for hooking into the compilation pipeline for testing.
669616
class HooksForTesting {
670-
/// Called before the intermediate macro augmentation libraries have been
671-
/// replaced by the merged macro augmentation libraries.
672-
///
673-
/// [Component] is the fully built component at this stage of the compilation.
674-
///
675-
/// If macros are not applied, this is not called.
676-
void beforeMergingMacroAugmentations(Component component) {}
677-
678-
/// Called after the intermediate macro augmentation libraries have been
679-
/// replaced by the merged macro augmentation libraries.
680-
///
681-
/// [Component] is the fully built component at this stage of the compilation.
682-
///
683-
/// If macros are not applied, this is not called.
684-
void afterMergingMacroAugmentations(Component component) {}
685-
686617
/// Called at the end of full compilation in the `KernelTarget.buildComponent`
687618
/// method.
688619
///

pkg/front_end/lib/src/api_unstable/bazel_worker.dart

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -83,28 +83,21 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
8383
trackNeededDillLibraries: trackNeededDillLibraries,
8484
environmentDefines: environmentDefines,
8585
verbose: verbose,
86-
nnbdMode: nnbdMode,
87-
requirePrebuiltMacros: requirePrebuiltMacros,
88-
precompiledMacros: precompiledMacros,
89-
macroSerializationMode: macroSerializationMode);
86+
nnbdMode: nnbdMode);
9087
}
9188

9289
InitializedCompilerState initializeCompiler(
93-
InitializedCompilerState? oldState,
94-
Uri? sdkSummary,
95-
Uri? librariesSpecificationUri,
96-
Uri? packagesFile,
97-
List<Uri> additionalDills,
98-
Target target,
99-
FileSystem fileSystem,
100-
Iterable<String> experiments,
101-
Map<String, String>? environmentDefines, {
102-
bool verbose = false,
103-
NnbdMode nnbdMode = NnbdMode.Strong,
104-
bool requirePrebuiltMacros = false,
105-
List<String> precompiledMacros = const [],
106-
SerializationMode macroSerializationMode = SerializationMode.byteData,
107-
}) {
90+
InitializedCompilerState? oldState,
91+
Uri? sdkSummary,
92+
Uri? librariesSpecificationUri,
93+
Uri? packagesFile,
94+
List<Uri> additionalDills,
95+
Target target,
96+
FileSystem fileSystem,
97+
Iterable<String> experiments,
98+
Map<String, String>? environmentDefines,
99+
{bool verbose = false,
100+
NnbdMode nnbdMode = NnbdMode.Strong}) {
108101
// TODO(sigmund): use incremental compiler when it supports our use case.
109102
// Note: it is common for the summary worker to invoke the compiler with the
110103
// same input summary URIs, but with different contents, so we'd need to be
@@ -122,10 +115,7 @@ InitializedCompilerState initializeCompiler(
122115
parseExperimentalArguments(experiments),
123116
onError: (e) => throw e)
124117
..verbose = verbose
125-
..nnbdMode = nnbdMode
126-
..requirePrebuiltMacros = requirePrebuiltMacros
127-
..precompiledMacros = precompiledMacros
128-
..macroSerializationMode = macroSerializationMode;
118+
..nnbdMode = nnbdMode;
129119

130120
ProcessedOptions processedOpts = new ProcessedOptions(options: options);
131121

pkg/front_end/lib/src/api_unstable/ddc.dart

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'package:_fe_analyzer_shared/src/messages/diagnostic_message.dart'
77
import 'package:kernel/class_hierarchy.dart';
88
import 'package:kernel/kernel.dart' show Component, Library;
99
import 'package:kernel/target/targets.dart' show Target;
10-
import 'package:macros/src/executor/serialization.dart' show SerializationMode;
1110

1211
import '../api_prototype/compiler_options.dart' show CompilerOptions;
1312
import '../api_prototype/experimental_flags.dart' show ExperimentalFlag;
@@ -105,10 +104,7 @@ InitializedCompilerState initializeCompiler(
105104
{FileSystem? fileSystem,
106105
Map<ExperimentalFlag, bool>? explicitExperimentalFlags,
107106
Map<String, String>? environmentDefines,
108-
required NnbdMode nnbdMode,
109-
bool requirePrebuiltMacros = false,
110-
List<String>? precompiledMacros,
111-
String? macroSerializationMode}) {
107+
required NnbdMode nnbdMode}) {
112108
additionalDills.sort((a, b) => a.toString().compareTo(b.toString()));
113109

114110
if (oldState != null &&
@@ -120,9 +116,7 @@ InitializedCompilerState initializeCompiler(
120116
equalLists(oldState.options.additionalDills, additionalDills) &&
121117
equalMaps(oldState.options.explicitExperimentalFlags,
122118
explicitExperimentalFlags) &&
123-
equalMaps(oldState.options.environmentDefines, environmentDefines) &&
124-
equalLists(oldState.options.precompiledMacros, precompiledMacros) &&
125-
oldState.options.requirePrebuiltMacros == requirePrebuiltMacros) {
119+
equalMaps(oldState.options.environmentDefines, environmentDefines)) {
126120
// Reuse old state.
127121
return oldState;
128122
}
@@ -137,11 +131,7 @@ InitializedCompilerState initializeCompiler(
137131
..target = target
138132
..fileSystem = fileSystem ?? StandardFileSystem.instance
139133
..environmentDefines = environmentDefines
140-
..nnbdMode = nnbdMode
141-
..precompiledMacros = precompiledMacros
142-
..macroSerializationMode = macroSerializationMode == null
143-
? null
144-
: new SerializationMode.fromOption(macroSerializationMode);
134+
..nnbdMode = nnbdMode;
145135
if (explicitExperimentalFlags != null) {
146136
options.explicitExperimentalFlags = explicitExperimentalFlags;
147137
}
@@ -191,8 +181,6 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
191181
environmentDefines: environmentDefines,
192182
outlineOnly: false,
193183
omitPlatform: false,
194-
requirePrebuiltMacros: requirePrebuiltMacros,
195-
precompiledMacros: precompiledMacros,
196184
trackNeededDillLibraries: trackNeededDillLibraries,
197185
nnbdMode: nnbdMode);
198186
}

pkg/front_end/lib/src/api_unstable/modular_incremental_compilation.dart

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'dart:typed_data';
66

77
import 'package:kernel/kernel.dart' show Component, CanonicalName, Library;
88
import 'package:kernel/target/targets.dart' show Target;
9-
import 'package:macros/src/executor/serialization.dart' show SerializationMode;
109

1110
import '../api_prototype/compiler_options.dart' show CompilerOptions;
1211
import '../api_prototype/experimental_flags.dart' show ExperimentalFlag;
@@ -17,7 +16,7 @@ import '../base/nnbd_mode.dart' show NnbdMode;
1716
import '../base/processed_options.dart' show ProcessedOptions;
1817
import 'compiler_state.dart'
1918
show InitializedCompilerState, WorkerInputComponent, digestsEqual;
20-
import 'util.dart' show equalLists, equalMaps, equalSets;
19+
import 'util.dart' show equalMaps, equalSets;
2120

2221
/// Initializes the compiler for a modular build.
2322
///
@@ -49,11 +48,7 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
4948
bool omitPlatform = false,
5049
bool trackNeededDillLibraries = false,
5150
bool verbose = false,
52-
NnbdMode nnbdMode = NnbdMode.Strong,
53-
bool requirePrebuiltMacros = false,
54-
List<String> precompiledMacros = const [],
55-
SerializationMode macroSerializationMode =
56-
SerializationMode.byteData}) async {
51+
NnbdMode nnbdMode = NnbdMode.Strong}) async {
5752
bool isRetry = false;
5853
while (true) {
5954
try {
@@ -86,18 +81,13 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
8681
!equalSets(oldState.tags, tags) ||
8782
(sdkSummary != null &&
8883
(cachedSdkInput == null ||
89-
!digestsEqual(cachedSdkInput.digest, sdkDigest))) ||
90-
// TODO(davidmorgan): add correct change detection for macros.
91-
oldState.options.requirePrebuiltMacros != requirePrebuiltMacros ||
92-
!equalLists(oldState.options.precompiledMacros, precompiledMacros) ||
93-
oldState.options.macroSerializationMode != macroSerializationMode) {
84+
!digestsEqual(cachedSdkInput.digest, sdkDigest)))) {
9485
// No - or immediately not correct - previous state.
9586
// We'll load a new sdk, anything loaded already will have a wrong root.
9687
workerInputCache.clear();
9788
workerInputCacheLibs.clear();
9889

9990
// The sdk was either not cached or it has changed.
100-
await oldState?.processedOpts.dispose();
10191
options = new CompilerOptions()
10292
..compileSdk = compileSdk
10393
..sdkRoot = sdkRoot
@@ -110,10 +100,7 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
110100
..environmentDefines = environmentDefines
111101
..explicitExperimentalFlags = explicitExperimentalFlags
112102
..verbose = verbose
113-
..nnbdMode = nnbdMode
114-
..requirePrebuiltMacros = requirePrebuiltMacros
115-
..precompiledMacros = precompiledMacros
116-
..macroSerializationMode = macroSerializationMode;
103+
..nnbdMode = nnbdMode;
117104

118105
processedOpts = new ProcessedOptions(options: options);
119106
if (sdkSummary != null && sdkDigest != null) {

pkg/front_end/lib/src/base/command_line_options.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ class Flags {
3535
static const String omitPlatform = "--omit-platform";
3636
static const String fatal = "--fatal";
3737
static const String fatalSkip = "--fatal-skip";
38-
static const String showGeneratedMacroSources = "--show-macros";
39-
static const String checkMacroOffsets = "--check-macro-offsets";
4038
static const String help = "--help";
4139
static const String librariesJson = "--libraries-json";
4240
static const String noDefines = "--no-defines";
@@ -76,10 +74,6 @@ class Options {
7674
const Option(Flags.fatal, const StringListValue());
7775
static const Option<String?> fatalSkip =
7876
const Option(Flags.fatalSkip, const StringValue());
79-
static const Option<bool> showGeneratedMacroSources =
80-
const Option(Flags.showGeneratedMacroSources, const BoolValue(false));
81-
static const Option<bool> checkMacroOffsets =
82-
const Option(Flags.checkMacroOffsets, const BoolValue(false));
8377
static const Option<int?> forceLateLowering = const Option(
8478
Flags.forceLateLowering,
8579
const IntValue(defaultValue: null, noArgValue: LateLowering.all));

0 commit comments

Comments
 (0)