mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Extend SILModule with an API for linking of SILFunctions by their SILDeclRef.
Before, providing a full SILFunction declaration object with a proper SILType was the only way to link a function. And constructing such a SILFunction declaration by hand using low-level SIL APIs is very annoying and requires a lot of code to be written. This new linkFunction API allows for a lookup using SILDeclRef and essentially performs linking of a SILFunction by its mangled name (assuming this name is unique), which is much easier to invoke. The new API is useful, e.g. when you need to link a well-known function from a standard library. Swift SVN r26252
This commit is contained in:
@@ -57,6 +57,22 @@ SILFunction *SerializedSILLoader::lookupSILFunction(SILFunction *Callee) {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
SILFunction *SerializedSILLoader::lookupSILFunction(StringRef Name) {
|
||||
// It is possible that one module has a declaration of a SILFunction, while
|
||||
// another has the full definition.
|
||||
SILFunction *retVal = nullptr;
|
||||
for (auto &Des : LoadedSILSections) {
|
||||
if (auto Func = Des->lookupSILFunction(Name)) {
|
||||
DEBUG(llvm::dbgs() << "Deserialized " << Func->getName() << " from "
|
||||
<< Des->getModuleIdentifier().str() << "\n");
|
||||
if (!Func->empty())
|
||||
return Func;
|
||||
retVal = Func;
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
SILVTable *SerializedSILLoader::lookupVTable(Identifier Name) {
|
||||
for (auto &Des : LoadedSILSections) {
|
||||
if (auto VT = Des->lookupVTable(Name))
|
||||
|
||||
Reference in New Issue
Block a user