Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b3a5dfa

Browse files
johnniwintherCommit Bot
authored andcommitted
[cfe] Add MacroAnnotationParser to support early recognition
This CL adds a parser listener that supports (the initial) part of the syntax needed to support detection of macro application early in the pipeline. The listener is deliberately implementing (as opposed to extending) the listener interface to ensure that all case handled in the listener itself. The listener keeps track of whether unsupported constructs have been seen to ensure that only valid syntax results in a macro application. Change-Id: I6742a0daa39c80f09759b41b9abdd7e693da4cc0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225723 Reviewed-by: Chloe Stefantsova <[email protected]> Commit-Queue: Johnni Winther <[email protected]>
1 parent 4c2111e commit b3a5dfa

File tree

13 files changed

+2127
-76
lines changed

13 files changed

+2127
-76
lines changed

pkg/front_end/lib/src/fasta/kernel/kernel_target.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ class KernelTarget extends TargetImplementation {
395395
List<SourceClassBuilder> sourceClassBuilders =
396396
loader.checkSemantics(objectClassBuilder);
397397
loader.computeMacroDeclarations(sourceClassBuilders);
398+
loader.computeMacroApplications();
398399
loader.finishTypeVariables(objectClassBuilder, dynamicType);
399400
loader.createTypeInferenceEngine();
400401
loader.buildComponent();
@@ -416,7 +417,6 @@ class KernelTarget extends TargetImplementation {
416417
loader.checkMixins(sourceClassBuilders);
417418
loader.buildOutlineExpressions(
418419
loader.coreTypes, synthesizedFunctionNodes);
419-
loader.computeMacroApplications();
420420
loader.checkTypes();
421421
loader.checkRedirectingFactories(sourceClassBuilders);
422422
loader.checkMainMethods();

pkg/front_end/lib/src/fasta/kernel/macro.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,19 @@ class MacroApplicationData {
2121
}
2222

2323
class MacroApplications {
24-
final List<Class> macros;
24+
final List<MacroApplication> macros;
2525

2626
MacroApplications(this.macros);
2727
}
2828

29+
class MacroApplication {
30+
final Class cls;
31+
final String constructorName;
32+
// TODO(johnniwinther): Add support for arguments.
33+
34+
MacroApplication(this.cls, this.constructorName);
35+
}
36+
2937
class LibraryMacroApplicationData {
3038
Map<Class, ClassMacroApplicationData> classData = {};
3139
Map<Member, MacroApplications> memberApplications = {};

0 commit comments

Comments
 (0)