mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add deserialization and stable encodings for ReferenceStorageType.
Jordan, please review. Swift SVN r6111
This commit is contained in:
@@ -1003,6 +1003,18 @@ static Optional<swift::AbstractCC> getActualCC(uint8_t cc) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Translate from the serialization Ownership enumerators, which are
|
||||
/// guaranteed to be stable, to the AST ones.
|
||||
static
|
||||
Optional<swift::Ownership> getActualOwnership(serialization::Ownership raw) {
|
||||
switch (raw) {
|
||||
case serialization::Ownership::Strong: return swift::Ownership::Strong;
|
||||
case serialization::Ownership::Unowned: return swift::Ownership::Unowned;
|
||||
case serialization::Ownership::Weak: return swift::Ownership::Weak;
|
||||
}
|
||||
return Nothing;
|
||||
}
|
||||
|
||||
Type ModuleFile::getType(TypeID TID) {
|
||||
if (TID == 0)
|
||||
return Type();
|
||||
@@ -1149,6 +1161,24 @@ Type ModuleFile::getType(TypeID TID) {
|
||||
break;
|
||||
}
|
||||
|
||||
case decls_block::REFERENCE_STORAGE_TYPE: {
|
||||
uint8_t rawOwnership;
|
||||
TypeID referentTypeID;
|
||||
decls_block::ReferenceStorageTypeLayout::readRecord(scratch, rawOwnership,
|
||||
referentTypeID);
|
||||
|
||||
auto ownership =
|
||||
getActualOwnership((serialization::Ownership) rawOwnership);
|
||||
if (!ownership.hasValue()) {
|
||||
error();
|
||||
break;
|
||||
}
|
||||
|
||||
typeOrOffset = ReferenceStorageType::get(getType(referentTypeID),
|
||||
ownership.getValue(), ctx);
|
||||
break;
|
||||
}
|
||||
|
||||
case decls_block::ARCHETYPE_TYPE: {
|
||||
IdentifierID nameID;
|
||||
bool isPrimary;
|
||||
|
||||
Reference in New Issue
Block a user