mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user