compiler: Use Macro to Derive CompilableStatement Implementations
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -439,17 +439,14 @@ public struct CliTestDeclarationMacro: PeerMacro, Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
public struct DeriveCompilableStatement: PeerMacro, Sendable {
|
||||
public enum DeriveCompilableStatement: MemberMacro {
|
||||
public static func expansion(
|
||||
of node: AttributeSyntax,
|
||||
providingPeersOf declaration: some DeclSyntaxProtocol,
|
||||
in context: some MacroExpansionContext
|
||||
of: AttributeSyntax, providingMembersOf type: some DeclGroupSyntax, conformingTo: [TypeSyntax],
|
||||
in: some MacroExpansionContext
|
||||
) throws -> [DeclSyntax] {
|
||||
|
||||
let type_name = declaration.cast(ExtensionDeclSyntax.self).extendedType
|
||||
let implementation = DeclSyntax(
|
||||
"""
|
||||
extension VariableDeclarationStatement: CompilableStatement {
|
||||
public static func CompileStatement(
|
||||
node: Node, withContext context: CompilerContext
|
||||
) -> Result<P4Statement> {
|
||||
@@ -458,7 +455,6 @@ public struct DeriveCompilableStatement: PeerMacro, Sendable {
|
||||
case .Error(let e): .Error(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
""")
|
||||
return [implementation]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user