|
22 | 22 | #include "SILBridging.h" |
23 | 23 | #include "swift/AST/Builtins.h" |
24 | 24 | #include "swift/AST/Decl.h" |
| 25 | +#include "swift/AST/ProtocolConformance.h" |
| 26 | +#include "swift/AST/ProtocolConformanceRef.h" |
25 | 27 | #include "swift/AST/SubstitutionMap.h" |
26 | 28 | #include "swift/AST/Types.h" |
27 | 29 | #include "swift/Basic/BasicBridging.h" |
@@ -978,6 +980,42 @@ BridgedType BridgedSILTypeArray::getAt(SwiftInt index) const { |
978 | 980 | return unbridged()[index]; |
979 | 981 | } |
980 | 982 |
|
| 983 | +//===----------------------------------------------------------------------===// |
| 984 | +// BridgedProtocolConformance |
| 985 | +//===----------------------------------------------------------------------===// |
| 986 | + |
| 987 | +static_assert(sizeof(BridgedProtocolConformance) == sizeof(swift::ProtocolConformanceRef)); |
| 988 | + |
| 989 | +bool BridgedProtocolConformance::isConcrete() const { |
| 990 | + return unbridged().isConcrete(); |
| 991 | +} |
| 992 | + |
| 993 | +bool BridgedProtocolConformance::isValid() const { |
| 994 | + return !unbridged().isInvalid(); |
| 995 | +} |
| 996 | + |
| 997 | +bool BridgedProtocolConformance::isSpecializedConformance() const { |
| 998 | + return swift::isa<swift::SpecializedProtocolConformance>(unbridged().getConcrete()); |
| 999 | +} |
| 1000 | + |
| 1001 | +BridgedProtocolConformance BridgedProtocolConformance::getGenericConformance() const { |
| 1002 | + auto *specPC = swift::cast<swift::SpecializedProtocolConformance>(unbridged().getConcrete()); |
| 1003 | + return {swift::ProtocolConformanceRef(specPC->getGenericConformance())}; |
| 1004 | +} |
| 1005 | + |
| 1006 | +BridgedSubstitutionMap BridgedProtocolConformance::getSpecializedSubstitutions() const { |
| 1007 | + auto *specPC = swift::cast<swift::SpecializedProtocolConformance>(unbridged().getConcrete()); |
| 1008 | + return {specPC->getSubstitutionMap()}; |
| 1009 | +} |
| 1010 | + |
| 1011 | +//===----------------------------------------------------------------------===// |
| 1012 | +// BridgedProtocolConformanceArray |
| 1013 | +//===----------------------------------------------------------------------===// |
| 1014 | + |
| 1015 | +BridgedProtocolConformance BridgedProtocolConformanceArray::getAt(SwiftInt index) const { |
| 1016 | + return unbridged()[index]; |
| 1017 | +} |
| 1018 | + |
981 | 1019 | //===----------------------------------------------------------------------===// |
982 | 1020 | // BridgedInstruction |
983 | 1021 | //===----------------------------------------------------------------------===// |
@@ -1131,6 +1169,14 @@ bool BridgedInstruction::IndexAddrInst_needsStackProtection() const { |
1131 | 1169 | return getAs<swift::IndexAddrInst>()->needsStackProtection(); |
1132 | 1170 | } |
1133 | 1171 |
|
| 1172 | +BridgedProtocolConformanceArray BridgedInstruction::InitExistentialRefInst_getConformances() const { |
| 1173 | + return getAs<swift::InitExistentialRefInst>()->getConformances(); |
| 1174 | +} |
| 1175 | + |
| 1176 | +BridgedASTType BridgedInstruction::InitExistentialRefInst_getFormalConcreteType() const { |
| 1177 | + return {getAs<swift::InitExistentialRefInst>()->getFormalConcreteType().getPointer()}; |
| 1178 | +} |
| 1179 | + |
1134 | 1180 | BridgedGlobalVar BridgedInstruction::GlobalAccessInst_getGlobal() const { |
1135 | 1181 | return {getAs<swift::GlobalAccessInst>()->getReferencedGlobal()}; |
1136 | 1182 | } |
@@ -2036,20 +2082,19 @@ BridgedInstruction BridgedBuilder::createStore(BridgedValue src, BridgedValue ds |
2036 | 2082 |
|
2037 | 2083 | BridgedInstruction BridgedBuilder::createInitExistentialRef(BridgedValue instance, |
2038 | 2084 | BridgedType type, |
2039 | | - BridgedInstruction useConformancesOf) const { |
2040 | | - auto *src = useConformancesOf.getAs<swift::InitExistentialRefInst>(); |
| 2085 | + BridgedASTType formalConcreteType, |
| 2086 | + BridgedProtocolConformanceArray conformances) const { |
2041 | 2087 | return {unbridged().createInitExistentialRef( |
2042 | | - regularLoc(), type.unbridged(), src->getFormalConcreteType(), |
2043 | | - instance.getSILValue(), src->getConformances())}; |
| 2088 | + regularLoc(), type.unbridged(), swift::CanType(formalConcreteType.unbridged()), |
| 2089 | + instance.getSILValue(), conformances.unbridged())}; |
2044 | 2090 | } |
2045 | 2091 |
|
2046 | 2092 | BridgedInstruction BridgedBuilder::createInitExistentialMetatype(BridgedValue metatype, |
2047 | 2093 | BridgedType existentialType, |
2048 | | - BridgedInstruction useConformancesOf) const { |
2049 | | - auto *src = useConformancesOf.getAs<swift::InitExistentialMetatypeInst>(); |
| 2094 | + BridgedProtocolConformanceArray conformances) const { |
2050 | 2095 | return {unbridged().createInitExistentialMetatype( |
2051 | 2096 | regularLoc(), metatype.getSILValue(), existentialType.unbridged(), |
2052 | | - src->getConformances())}; |
| 2097 | + conformances.unbridged())}; |
2053 | 2098 | } |
2054 | 2099 |
|
2055 | 2100 | BridgedInstruction BridgedBuilder::createMetatype(BridgedType type, |
|
0 commit comments