mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SILDeclRef] RuntimeMetadata: Add a special kind for runtime attribute generator
A new `RuntimeAttributeGenerator` is used to reference runtime attribute generator functions synthesized by SILGen. `#function` magic literal points to the declaration that declaration attribute is attached to.
This commit is contained in:
@@ -1135,6 +1135,21 @@ void SILGenModule::emitFunctionDefinition(SILDeclRef constant, SILFunction *f) {
|
||||
postEmitFunction(constant, f);
|
||||
return;
|
||||
}
|
||||
|
||||
case SILDeclRef::Kind::RuntimeAttributeGenerator: {
|
||||
auto *decl = constant.getDecl();
|
||||
auto *attr = constant.pointer.get<CustomAttr *>();
|
||||
auto *DC = decl->getDeclContext()->getParentSourceFile();
|
||||
|
||||
Expr *generator = decl->getRuntimeDiscoverableAttributeGenerator(attr);
|
||||
auto loc = RegularLocation::getAutoGeneratedLocation(generator);
|
||||
preEmitFunction(constant, f, loc);
|
||||
PrettyStackTraceSILFunction X("silgen emitRuntimeAttributeGenerator ", f);
|
||||
SILGenFunction SGF(*this, *f, DC);
|
||||
SGF.emitGeneratorFunction(constant, generator);
|
||||
postEmitFunction(constant, f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2210,9 +2225,9 @@ public:
|
||||
|
||||
for (auto *D : sf->getDeclsWithRuntimeDiscoverableAttrs()) {
|
||||
for (auto *attr : D->getRuntimeDiscoverableAttrs()) {
|
||||
auto *generator = D->getRuntimeDiscoverableAttributeGenerator(attr);
|
||||
assert(generator);
|
||||
emitSILFunctionDefinition(SILDeclRef(generator).asRuntimeAccessible());
|
||||
emitSILFunctionDefinition(
|
||||
SILDeclRef::getRuntimeAttributeGenerator(attr, D)
|
||||
.asRuntimeAccessible());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user