|
18 | 18 | #include "swift/AST/AutoDiff.h"
|
19 | 19 | #include "swift/AST/DiagnosticsSema.h"
|
20 | 20 | #include "swift/AST/Expr.h"
|
| 21 | +#include "swift/AST/ForeignAsyncConvention.h" |
21 | 22 | #include "swift/AST/ForeignErrorConvention.h"
|
22 | 23 | #include "swift/AST/GenericEnvironment.h"
|
23 | 24 | #include "swift/AST/Initializer.h"
|
@@ -2697,6 +2698,8 @@ class DeclDeserializer {
|
2697 | 2698 |
|
2698 | 2699 | if (auto errorConvention = MF.maybeReadForeignErrorConvention())
|
2699 | 2700 | ctor->setForeignErrorConvention(*errorConvention);
|
| 2701 | + if (auto asyncConvention = MF.maybeReadForeignAsyncConvention()) |
| 2702 | + ctor->setForeignAsyncConvention(*asyncConvention); |
2700 | 2703 |
|
2701 | 2704 | if (auto bodyText = MF.maybeReadInlinableBodyText())
|
2702 | 2705 | ctor->setBodyStringRepresentation(*bodyText);
|
@@ -3182,6 +3185,8 @@ class DeclDeserializer {
|
3182 | 3185 |
|
3183 | 3186 | if (auto errorConvention = MF.maybeReadForeignErrorConvention())
|
3184 | 3187 | fn->setForeignErrorConvention(*errorConvention);
|
| 3188 | + if (auto asyncConvention = MF.maybeReadForeignAsyncConvention()) |
| 3189 | + fn->setForeignAsyncConvention(*asyncConvention); |
3185 | 3190 |
|
3186 | 3191 | if (auto bodyText = MF.maybeReadInlinableBodyText())
|
3187 | 3192 | fn->setBodyStringRepresentation(*bodyText);
|
@@ -5485,7 +5490,7 @@ class TypeDeserializer {
|
5485 | 5490 |
|
5486 | 5491 | auto extInfo =
|
5487 | 5492 | SILFunctionType::ExtInfoBuilder(*representation, pseudogeneric,
|
5488 |
| - noescape, concurrent, async, *diffKind, |
| 5493 | + noescape, concurrent, async, *diffKind, |
5489 | 5494 | clangFunctionType)
|
5490 | 5495 | .build();
|
5491 | 5496 |
|
@@ -6477,3 +6482,49 @@ Optional<ForeignErrorConvention> ModuleFile::maybeReadForeignErrorConvention() {
|
6477 | 6482 |
|
6478 | 6483 | llvm_unreachable("Unhandled ForeignErrorConvention in switch.");
|
6479 | 6484 | }
|
| 6485 | + |
| 6486 | +Optional<ForeignAsyncConvention> ModuleFile::maybeReadForeignAsyncConvention() { |
| 6487 | + using namespace decls_block; |
| 6488 | + |
| 6489 | + SmallVector<uint64_t, 8> scratch; |
| 6490 | + |
| 6491 | + BCOffsetRAII restoreOffset(DeclTypeCursor); |
| 6492 | + |
| 6493 | + llvm::BitstreamEntry next = |
| 6494 | + fatalIfUnexpected(DeclTypeCursor.advance(AF_DontPopBlockAtEnd)); |
| 6495 | + if (next.Kind != llvm::BitstreamEntry::Record) |
| 6496 | + return None; |
| 6497 | + |
| 6498 | + unsigned recKind = |
| 6499 | + fatalIfUnexpected(DeclTypeCursor.readRecord(next.ID, scratch)); |
| 6500 | + switch (recKind) { |
| 6501 | + case FOREIGN_ASYNC_CONVENTION: |
| 6502 | + restoreOffset.reset(); |
| 6503 | + break; |
| 6504 | + |
| 6505 | + default: |
| 6506 | + return None; |
| 6507 | + } |
| 6508 | + |
| 6509 | + TypeID completionHandlerTypeID; |
| 6510 | + unsigned completionHandlerParameterIndex; |
| 6511 | + unsigned rawErrorParameterIndex; |
| 6512 | + ForeignAsyncConventionLayout::readRecord(scratch, |
| 6513 | + completionHandlerTypeID, |
| 6514 | + completionHandlerParameterIndex, |
| 6515 | + rawErrorParameterIndex); |
| 6516 | + |
| 6517 | + Type completionHandlerType = getType(completionHandlerTypeID); |
| 6518 | + CanType canCompletionHandlerType; |
| 6519 | + if (completionHandlerType) |
| 6520 | + canCompletionHandlerType = completionHandlerType->getCanonicalType(); |
| 6521 | + |
| 6522 | + // Decode the error parameter. |
| 6523 | + Optional<unsigned> completionHandlerErrorParamIndex; |
| 6524 | + if (rawErrorParameterIndex > 0) |
| 6525 | + completionHandlerErrorParamIndex = rawErrorParameterIndex - 1; |
| 6526 | + |
| 6527 | + return ForeignAsyncConvention( |
| 6528 | + canCompletionHandlerType, completionHandlerParameterIndex, |
| 6529 | + completionHandlerErrorParamIndex); |
| 6530 | +} |
0 commit comments