SIL: Let SubstitutionMap.replacementTypes return AST types rather than optional SIL types.

This is what the C++ SubstitutionMap does. One has to use `Type.loweredType` to get from the AST type to the SIL type.
This commit is contained in:
Erik Eckstein
2024-12-19 11:43:17 +01:00
parent 1f4332ad39
commit 1545e01ab5
10 changed files with 62 additions and 61 deletions

View File

@@ -2293,6 +2293,15 @@ public:
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getType() const;
};
struct BridgedASTTypeArray {
BridgedArrayRef typeArray;
SwiftInt getCount() const { return SwiftInt(typeArray.Length); }
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE
BridgedASTType getAt(SwiftInt index) const;
};
struct BridgedConformance {
void * _Nullable opaqueValue;
@@ -2330,6 +2339,7 @@ struct BridgedSubstitutionMap {
BRIDGED_INLINE bool hasAnySubstitutableParams() const;
BRIDGED_INLINE SwiftInt getNumConformances() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedConformance getConformance(SwiftInt index) const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTTypeArray getReplacementTypes() const;
};
struct BridgedFingerprint {

View File

@@ -338,6 +338,15 @@ BridgedASTType BridgedCanType::getType() const {
return {type};
}
//===----------------------------------------------------------------------===//
// MARK: BridgedASTTypeArray
//===----------------------------------------------------------------------===//
BridgedASTType BridgedASTTypeArray::getAt(SwiftInt index) const {
return {typeArray.unbridged<swift::Type>()[index].getPointer()};
}
//===----------------------------------------------------------------------===//
// MARK: BridgedConformance
//===----------------------------------------------------------------------===//
@@ -462,6 +471,10 @@ BridgedConformance BridgedSubstitutionMap::getConformance(SwiftInt index) const
return unbridged().getConformances()[index];
}
BridgedASTTypeArray BridgedSubstitutionMap::getReplacementTypes() const {
return {unbridged().getReplacementTypes()};
}
//===----------------------------------------------------------------------===//
// MARK: BridgedFingerprint
//===----------------------------------------------------------------------===//

View File

@@ -614,18 +614,6 @@ struct BridgedMultiValueResult {
BRIDGED_INLINE SwiftInt getIndex() const;
};
struct BridgedTypeArray {
BridgedArrayRef typeArray;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE
static BridgedTypeArray fromReplacementTypes(BridgedSubstitutionMap substMap);
SwiftInt getCount() const { return SwiftInt(typeArray.Length); }
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE
BridgedType getAt(SwiftInt index) const;
};
struct BridgedSILTypeArray {
BridgedArrayRef typeArray;

View File

@@ -988,24 +988,7 @@ SwiftInt BridgedMultiValueResult::getIndex() const {
}
//===----------------------------------------------------------------------===//
// BridgedTypeArray
//===----------------------------------------------------------------------===//
BridgedTypeArray
BridgedTypeArray::fromReplacementTypes(BridgedSubstitutionMap substMap) {
return {substMap.unbridged().getReplacementTypes()};
}
BridgedType BridgedTypeArray::getAt(SwiftInt index) const {
swift::Type origTy = typeArray.unbridged<swift::Type>()[index];
auto ty = origTy->getCanonicalType();
if (ty->isLegalSILType())
return swift::SILType::getPrimitiveObjectType(ty);
return swift::SILType();
}
//===----------------------------------------------------------------------===//
// BridgedTypeArray
// BridgedSILTypeArray
//===----------------------------------------------------------------------===//
BridgedType BridgedSILTypeArray::getAt(SwiftInt index) const {