Skip to content

Commit 0280141

Browse files
committed
[TBDGen] Add async function pointers.
In order to call async functions, instances of the AsyncFunctionPointer struct must be used. If those functions are exported from a module, the AsyncFunctionPointer by means of which the function is to be called must be exported as well. For now, the symbol is exported by manually appending the relevant suffix to the mangled name of the function.
1 parent 745356f commit 0280141

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/TBDGen/TBDGen.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,16 @@ void TBDGenVisitor::visitAbstractFunctionDecl(AbstractFunctionDecl *AFD) {
718718
AFD->getGenericSignature()));
719719

720720
visitDefaultArguments(AFD, AFD->getParameters());
721+
722+
if (AFD->isAsyncContext()) {
723+
// TODO: Replace manual symbol naming with LinkEntity construction of the
724+
// following form:
725+
//
726+
// addSymbol(LinkEntity::forAsyncFunctionPointer(...));
727+
auto declRef = SILDeclRef(AFD);
728+
addSymbol(SILDeclRef(AFD).mangle().append("AD"),
729+
SymbolSource::forSILDeclRef(declRef));
730+
}
721731
}
722732

723733
void TBDGenVisitor::visitFuncDecl(FuncDecl *FD) {

0 commit comments

Comments
 (0)