Skip to content

[Macros] Introduce Macro AST #62071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 12, 2022
Merged

[Macros] Introduce Macro AST #62071

merged 4 commits into from
Nov 12, 2022

Conversation

DougGregor
Copy link
Member

Introduce an AST entity Macro to describe macros. Create a Macro instance for each builtin or plugin-provided macro that is used in the program, populating it with all of the information needed for semantic analysis and macro expansion. In doing so, unify the code paths for builtin and plugin-provided macros as much as we can.

We had two implementations of the code that forms the macro evaluation
context buffer, one in ASTGen and one in Sema. Unify them into a single
place, and unify the creation of macros so we localize this arcane
knowledge.
The macro signature context was a (possibly generic) struct declaration
containing a typealias. We don't need the struct itself, because the
typealias can be generic as well. This eliminates an extra, annoying
hop through name lookup.
…Macro.

Plumb the information about the owning module and supplemental
signature modules through to the Macro data structure, for both
built-in and plugin macros.

We're resolving the given module names into module declarations, but
otherwise performing no checking and not emitting any diagnostics.
This information is not yet used.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@rxwei
Copy link
Contributor

rxwei commented Nov 12, 2022

Does this have a corresponding swift-syntax PR?

@DougGregor DougGregor merged commit baa1d49 into swiftlang:main Nov 12, 2022
@DougGregor DougGregor deleted the macro-ast branch November 12, 2022 06:35
@DougGregor
Copy link
Member Author

The swift-syntax part was swiftlang/swift-syntax#1071

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants