Swift: extract MacroDecl

This commit is contained in:
Alex Denisov
2023-11-15 13:06:02 +01:00
parent 803ed20962
commit 8b126fe51a
45 changed files with 706 additions and 10 deletions

View File

@@ -1361,3 +1361,31 @@ class BorrowExpr(IdentityExpr):
```
"""
pass
@qltest.test_with('MacroDecl')
class MacroRole(AstNode):
"""
The role of a macro.
"""
kind: int | doc("kind of this macro role (declaration, expression, member, etc.)")
macro_syntax: int | doc("#freestanding or @attached")
conformances: list[TypeExpr] | doc("conformances of this macro role")
names: list[string] | doc("names of this macro role")
class MacroDecl(GenericContext, ValueDecl):
"""
A declaration of a macro. Some examples:
```
@freestanding(declaration)
macro A() = #externalMacro(module: "A", type: "A")
@freestanding(expression)
macro B() = Builtin.B
@attached(member)
macro C() = C.C
```
"""
name: string | doc("name of this macro")
parameters: list[ParamDecl] | doc("parameters of this macro")
roles: list[MacroRole] | doc("roles of this macro")
pass