|
25 | 25 |
|
26 | 26 | using namespace swift;
|
27 | 27 |
|
| 28 | +extern "C" void *swift_ASTGen_lookupMacro(const char *macroName); |
| 29 | + |
| 30 | +extern "C" void swift_ASTGen_destroyMacro(void *macro); |
| 31 | + |
| 32 | +extern "C" void swift_ASTGen_getMacroTypeSignature( |
| 33 | + void *sourceFile, void *declContext, void *astContext, void *macro, |
| 34 | + void **genericSignature, |
| 35 | + void **signature); |
| 36 | + |
28 | 37 | extern "C" ptrdiff_t swift_ASTGen_evaluateMacro(
|
29 | 38 | void *sourceFile, const void *sourceLocation,
|
30 | 39 | const char **evaluatedSource, ptrdiff_t *evaluatedSourceLength);
|
31 | 40 |
|
32 | 41 | #if SWIFT_SWIFT_PARSER
|
| 42 | + |
| 43 | +llvm::Optional<ASTGenMacroRAII> ASTGenMacroRAII::lookup(StringRef macroName, |
| 44 | + void *sourceFile, |
| 45 | + DeclContext *DC, |
| 46 | + ASTContext &ctx) { |
| 47 | + auto *macro = swift_ASTGen_lookupMacro(macroName.str().c_str()); |
| 48 | + if (!macro) |
| 49 | + return None; |
| 50 | + |
| 51 | + void *genericParamList = nullptr; |
| 52 | + void *signatureAST = nullptr; |
| 53 | + swift_ASTGen_getMacroTypeSignature(sourceFile, (void *)DC, (void *)&ctx, |
| 54 | + macro, &genericParamList, |
| 55 | + &signatureAST); |
| 56 | + |
| 57 | + return ASTGenMacroRAII{macro, (TypeRepr *)signatureAST, |
| 58 | + (GenericParamList *)genericParamList}; |
| 59 | +} |
| 60 | + |
| 61 | +ASTGenMacroRAII::~ASTGenMacroRAII() { /*swift_ASTGen_destroyMacro(opaqueMacro);*/ } |
| 62 | + |
33 | 63 | Expr *swift::expandMacroExpr(
|
34 | 64 | DeclContext *dc, Expr *expr, StringRef macroName, Type expandedType
|
35 | 65 | ) {
|
|
0 commit comments