[NFC] CSApply: Introduce a generalized routine for building single curry thunk bodies

This commit is contained in:
Anthony Latsis
2022-03-14 20:30:38 +03:00
parent 64ff2b22bb
commit f25725279e
3 changed files with 178 additions and 1 deletions

View File

@@ -7533,6 +7533,18 @@ ParameterList *swift::getParameterList(ValueDecl *source) {
return nullptr;
}
ParameterList *swift::getParameterList(DeclContext *source) {
if (auto *D = source->getAsDecl()) {
if (auto *VD = dyn_cast<ValueDecl>(D)) {
return getParameterList(VD);
}
} else if (auto *CE = dyn_cast<AbstractClosureExpr>(source)) {
return CE->getParameters();
}
return nullptr;
}
const ParamDecl *swift::getParameterAt(const ValueDecl *source,
unsigned index) {
if (auto *params = getParameterList(const_cast<ValueDecl *>(source))) {