mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #84648 from swiftlang/users/kovdan01/ast-bridges-for-autodiff-closure-spec
Bridging: Implement bridges required for ongoing AutoDiff changes
This commit is contained in:
@@ -45,6 +45,7 @@ class AvailabilityDomainOrIdentifier;
|
||||
class Argument;
|
||||
class ASTContext;
|
||||
struct ASTNode;
|
||||
class CanGenericSignature;
|
||||
struct CaptureListEntry;
|
||||
class DeclAttributes;
|
||||
class DeclBaseName;
|
||||
@@ -87,6 +88,7 @@ class BridgedASTContext;
|
||||
class BridgedLangOptions;
|
||||
struct BridgedSubstitutionMap;
|
||||
struct BridgedGenericSignature;
|
||||
struct BridgedCanGenericSignature;
|
||||
struct BridgedConformance;
|
||||
class BridgedParameterList;
|
||||
|
||||
@@ -317,18 +319,28 @@ struct BridgedDeclObj {
|
||||
#endif
|
||||
|
||||
BridgedDeclObj(SwiftObject obj) : obj(obj) {}
|
||||
BRIDGED_INLINE BridgedDeclObj(BridgedDecl decl);
|
||||
BridgedOwnedString getDebugDescription() const;
|
||||
BRIDGED_INLINE swift::SourceLoc getLoc() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclObj getModuleContext() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedDeclObj getParent() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedNullableDeclContext getDeclContext() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclContext asGenericContext() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclContext asTopLevelCodeDecl() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclContext asModuleDecl() const;
|
||||
BRIDGED_INLINE void setImplicit() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef Type_getName() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef Value_getUserFacingName() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE swift::SourceLoc Value_getNameLoc() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE swift::Identifier
|
||||
Value_getBaseIdentifier() const;
|
||||
BRIDGED_INLINE bool hasClangNode() const;
|
||||
BRIDGED_INLINE bool Value_isObjC() const;
|
||||
BRIDGED_INLINE bool AbstractStorage_isConst() const;
|
||||
BRIDGED_INLINE bool GenericType_isGenericAtAnyLevel() const;
|
||||
BRIDGED_INLINE bool NominalType_isGlobalActor() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType
|
||||
NominalType_getDeclaredInterfaceType() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedDeclObj NominalType_getValueTypeDestructor() const;
|
||||
BRIDGED_INLINE bool Enum_hasRawType() const;
|
||||
BRIDGED_INLINE bool Struct_hasUnreferenceableStorage() const;
|
||||
@@ -338,7 +350,14 @@ struct BridgedDeclObj {
|
||||
BRIDGED_INLINE bool AbstractFunction_isOverridden() const;
|
||||
BRIDGED_INLINE bool Destructor_isIsolated() const;
|
||||
BRIDGED_INLINE bool EnumElementDecl_hasAssociatedValues() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedParameterList
|
||||
EnumElementDecl_getParameterList() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef
|
||||
EnumElementDecl_getNameStr() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef AccessorDecl_getKindName() const;
|
||||
BRIDGED_INLINE void GenericContext_setGenericSignature(BridgedGenericSignature genericSignature) const;
|
||||
BRIDGED_INLINE void ValueDecl_setAccess(swift::AccessLevel accessLevel) const;
|
||||
BRIDGED_INLINE void NominalTypeDecl_addMember(BridgedDeclObj member) const;
|
||||
};
|
||||
|
||||
enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedASTNodeKind : uint8_t {
|
||||
@@ -391,6 +410,15 @@ public:
|
||||
#define ABSTRACT_DECL(Id, Parent) DECL(Id, Parent)
|
||||
#include "swift/AST/DeclNodes.def"
|
||||
|
||||
// Declare `.asNominalTypeDecl` on each BridgedXXXDecl type that's also a
|
||||
// NominalTypeDecl.
|
||||
#define DECL(Id, Parent)
|
||||
#define NOMINAL_TYPE_DECL(Id, Parent) \
|
||||
SWIFT_NAME("getter:Bridged" #Id "Decl.asNominalTypeDecl(self:)") \
|
||||
BridgedNominalTypeDecl Bridged##Id##Decl_asNominalTypeDecl( \
|
||||
Bridged##Id##Decl decl);
|
||||
#include "swift/AST/DeclNodes.def"
|
||||
|
||||
// Declare `.asDeclContext` on each BridgedXXXDecl type that's also a
|
||||
// DeclContext.
|
||||
#define DECL(Id, Parent)
|
||||
@@ -577,6 +605,14 @@ BridgedDeclContext_getParentSourceFile(BridgedDeclContext dc);
|
||||
SWIFT_NAME("getter:BridgedSourceFile.isScriptMode(self:)")
|
||||
BRIDGED_INLINE bool BridgedSourceFile_isScriptMode(BridgedSourceFile sf);
|
||||
|
||||
SWIFT_NAME("BridgedSourceFile.addTopLevelDecl(self:_:)")
|
||||
BRIDGED_INLINE void BridgedSourceFile_addTopLevelDecl(BridgedSourceFile sf,
|
||||
BridgedDecl decl);
|
||||
|
||||
SWIFT_NAME("BridgedFileUnit.castToSourceFile(self:)")
|
||||
BRIDGED_INLINE BridgedNullableSourceFile
|
||||
BridgedFileUnit_castToSourceFile(BridgedFileUnit fileUnit);
|
||||
|
||||
SWIFT_NAME("BridgedPatternBindingInitializer.create(declContext:)")
|
||||
BridgedPatternBindingInitializer
|
||||
BridgedPatternBindingInitializer_create(BridgedDeclContext cDeclContext);
|
||||
@@ -1358,10 +1394,18 @@ BridgedParamDecl BridgedParamDecl_createParsed(
|
||||
swift::SourceLoc paramNameLoc, BridgedNullableExpr defaultValue,
|
||||
BridgedNullableDefaultArgumentInitializer cDefaultArgumentInitContext);
|
||||
|
||||
SWIFT_NAME("BridgedParamDecl.cloneWithoutType(self:)")
|
||||
BRIDGED_INLINE BridgedParamDecl
|
||||
BridgedParamDecl_cloneWithoutType(BridgedParamDecl cDecl);
|
||||
|
||||
SWIFT_NAME("BridgedParamDecl.setTypeRepr(self:_:)")
|
||||
BRIDGED_INLINE void BridgedParamDecl_setTypeRepr(BridgedParamDecl cDecl,
|
||||
BridgedTypeRepr cType);
|
||||
|
||||
SWIFT_NAME("BridgedParamDecl.setInterfaceType(self:_:)")
|
||||
BRIDGED_INLINE void BridgedParamDecl_setInterfaceType(BridgedParamDecl cDecl,
|
||||
BridgedASTType cType);
|
||||
|
||||
/// The various spellings of ownership modifier that can be used in source.
|
||||
enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedParamSpecifier {
|
||||
BridgedParamSpecifierDefault,
|
||||
@@ -1445,7 +1489,7 @@ void BridgedExtensionDecl_setParsedMembers(BridgedExtensionDecl decl,
|
||||
SWIFT_NAME(
|
||||
"BridgedEnumDecl.createParsed(_:declContext:enumKeywordLoc:name:nameLoc:"
|
||||
"genericParamList:inheritedTypes:genericWhereClause:braceRange:)")
|
||||
BridgedNominalTypeDecl BridgedEnumDecl_createParsed(
|
||||
BridgedEnumDecl BridgedEnumDecl_createParsed(
|
||||
BridgedASTContext cContext, BridgedDeclContext cDeclContext,
|
||||
swift::SourceLoc enumKeywordLoc, swift::Identifier name,
|
||||
swift::SourceLoc nameLoc, BridgedNullableGenericParamList genericParamList,
|
||||
@@ -2875,6 +2919,12 @@ BridgedGenericTypeParamDecl BridgedGenericTypeParamDecl_createParsed(
|
||||
swift::SourceLoc nameLoc, BridgedNullableTypeRepr opaqueInheritedType,
|
||||
size_t index, swift::GenericTypeParamKind paramKind);
|
||||
|
||||
SWIFT_NAME("BridgedGenericTypeParamDecl.createImplicit(declContext:"
|
||||
"name:depth:index:paramKind:)")
|
||||
BridgedGenericTypeParamDecl BridgedGenericTypeParamDecl_createImplicit(
|
||||
BridgedDeclContext cDeclContext, swift::Identifier name, SwiftInt depth,
|
||||
SwiftInt index, swift::GenericTypeParamKind paramKind);
|
||||
|
||||
SWIFT_NAME(
|
||||
"BridgedTrailingWhereClause.createParsed(_:whereKeywordLoc:requirements:)")
|
||||
BridgedTrailingWhereClause
|
||||
@@ -2998,6 +3048,15 @@ struct BridgedASTType {
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSubstitutionMap getContextSubstitutionMap() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedGenericSignature getInvocationGenericSignatureOfFunctionType() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType subst(BridgedSubstitutionMap substMap) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType mapOutOfEnvironment() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedCanType
|
||||
getReducedType(BridgedGenericSignature sig) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE swift::Identifier
|
||||
GenericTypeParam_getName() const;
|
||||
BRIDGED_INLINE SwiftInt GenericTypeParam_getDepth() const;
|
||||
BRIDGED_INLINE SwiftInt GenericTypeParam_getIndex() const;
|
||||
BRIDGED_INLINE swift::GenericTypeParamKind
|
||||
GenericTypeParam_getParamKind() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedConformance checkConformance(BridgedDeclObj proto) const;
|
||||
BRIDGED_INLINE bool containsSILPackExpansionType() const;
|
||||
BRIDGED_INLINE bool isSILPackElementAddress() const;
|
||||
@@ -3011,6 +3070,8 @@ public:
|
||||
BRIDGED_INLINE BridgedCanType(swift::CanType ty);
|
||||
BRIDGED_INLINE swift::CanType unbridged() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getRawType() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedCanGenericSignature
|
||||
SILFunctionType_getSubstGenericSignature() const;
|
||||
};
|
||||
|
||||
struct BridgedASTTypeArray {
|
||||
@@ -3075,6 +3136,15 @@ struct BridgedGenericSignature {
|
||||
BridgedOwnedString getDebugDescription() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTTypeArray getGenericParams() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType mapTypeIntoEnvironment(BridgedASTType type) const;
|
||||
BRIDGED_INLINE BridgedCanGenericSignature getCanonicalSignature() const;
|
||||
};
|
||||
|
||||
struct BridgedCanGenericSignature {
|
||||
const swift::GenericSignatureImpl *_Nullable impl;
|
||||
|
||||
BRIDGED_INLINE swift::CanGenericSignature unbridged() const;
|
||||
BRIDGED_INLINE BridgedGenericSignature getGenericSignature() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType mapTypeIntoEnvironment(BridgedASTType type) const;
|
||||
};
|
||||
|
||||
struct BridgedFingerprint {
|
||||
|
||||
@@ -150,10 +150,24 @@ bool BridgedSourceFile_isScriptMode(BridgedSourceFile sf) {
|
||||
return sf.unbridged()->isScriptMode();
|
||||
}
|
||||
|
||||
void BridgedSourceFile_addTopLevelDecl(BridgedSourceFile sf, BridgedDecl decl) {
|
||||
auto &file = sf.unbridged()->getOrCreateSynthesizedFile();
|
||||
file.addTopLevelDecl(decl.unbridged());
|
||||
file.getParentModule()->clearLookupCache();
|
||||
}
|
||||
|
||||
BridgedNullableSourceFile
|
||||
BridgedFileUnit_castToSourceFile(BridgedFileUnit fileUnit) {
|
||||
return llvm::dyn_cast<swift::SourceFile>(fileUnit.unbridged());
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// MARK: BridgedDeclObj
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
BridgedDeclObj::BridgedDeclObj(BridgedDecl decl)
|
||||
: obj(static_cast<SwiftObject>(decl.unbridged())) {}
|
||||
|
||||
swift::SourceLoc BridgedDeclObj::getLoc() const {
|
||||
return unbridged()->getLoc();
|
||||
}
|
||||
@@ -166,6 +180,26 @@ OptionalBridgedDeclObj BridgedDeclObj::getParent() const {
|
||||
return {unbridged()->getDeclContext()->getAsDecl()};
|
||||
}
|
||||
|
||||
BridgedNullableDeclContext BridgedDeclObj::getDeclContext() const {
|
||||
return {unbridged()->getDeclContext()};
|
||||
}
|
||||
|
||||
BridgedDeclContext BridgedDeclObj::asGenericContext() const {
|
||||
return {static_cast<swift::DeclContext *>(getAs<swift::GenericContext>())};
|
||||
}
|
||||
|
||||
BridgedDeclContext BridgedDeclObj::asTopLevelCodeDecl() const {
|
||||
return {static_cast<swift::DeclContext *>(getAs<swift::TopLevelCodeDecl>())};
|
||||
}
|
||||
|
||||
BridgedDeclContext BridgedDeclObj::asModuleDecl() const {
|
||||
return {static_cast<swift::DeclContext *>(getAs<swift::ModuleDecl>())};
|
||||
}
|
||||
|
||||
void BridgedDeclObj::setImplicit() const {
|
||||
unbridged()->setImplicit();
|
||||
}
|
||||
|
||||
BridgedStringRef BridgedDeclObj::Type_getName() const {
|
||||
return getAs<swift::TypeDecl>()->getName().str();
|
||||
}
|
||||
@@ -178,6 +212,10 @@ swift::SourceLoc BridgedDeclObj::Value_getNameLoc() const {
|
||||
return getAs<swift::ValueDecl>()->getNameLoc();
|
||||
}
|
||||
|
||||
swift::Identifier BridgedDeclObj::Value_getBaseIdentifier() const {
|
||||
return getAs<swift::ValueDecl>()->getBaseIdentifier();
|
||||
}
|
||||
|
||||
bool BridgedDeclObj::hasClangNode() const {
|
||||
return unbridged()->hasClangNode();
|
||||
}
|
||||
@@ -236,6 +274,31 @@ bool BridgedDeclObj::EnumElementDecl_hasAssociatedValues() const {
|
||||
return getAs<swift::EnumElementDecl>()->hasAssociatedValues();
|
||||
}
|
||||
|
||||
BridgedParameterList BridgedDeclObj::EnumElementDecl_getParameterList() const {
|
||||
return getAs<swift::EnumElementDecl>()->getParameterList();
|
||||
}
|
||||
|
||||
BridgedStringRef BridgedDeclObj::EnumElementDecl_getNameStr() const {
|
||||
return getAs<swift::EnumElementDecl>()->getNameStr();
|
||||
}
|
||||
|
||||
BridgedASTType BridgedDeclObj::NominalType_getDeclaredInterfaceType() const {
|
||||
return {
|
||||
getAs<swift::NominalTypeDecl>()->getDeclaredInterfaceType().getPointer()};
|
||||
}
|
||||
|
||||
void BridgedDeclObj::GenericContext_setGenericSignature(BridgedGenericSignature genericSignature) const {
|
||||
getAs<swift::GenericContext>()->setGenericSignature(genericSignature.unbridged());
|
||||
}
|
||||
|
||||
void BridgedDeclObj::ValueDecl_setAccess(swift::AccessLevel accessLevel) const {
|
||||
getAs<swift::ValueDecl>()->setAccess(accessLevel);
|
||||
}
|
||||
|
||||
void BridgedDeclObj::NominalTypeDecl_addMember(BridgedDeclObj member) const {
|
||||
getAs<swift::NominalTypeDecl>()->addMember(member.unbridged());
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// MARK: BridgedASTNode
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -339,11 +402,21 @@ swift::ParamSpecifier unbridge(BridgedParamSpecifier specifier) {
|
||||
}
|
||||
}
|
||||
|
||||
BridgedParamDecl BridgedParamDecl_cloneWithoutType(BridgedParamDecl cDecl) {
|
||||
return swift::ParamDecl::cloneWithoutType(cDecl.unbridged()->getASTContext(),
|
||||
cDecl.unbridged());
|
||||
}
|
||||
|
||||
void BridgedParamDecl_setTypeRepr(BridgedParamDecl cDecl,
|
||||
BridgedTypeRepr cType) {
|
||||
cDecl.unbridged()->setTypeRepr(cType.unbridged());
|
||||
}
|
||||
|
||||
void BridgedParamDecl_setInterfaceType(BridgedParamDecl cDecl,
|
||||
BridgedASTType cType) {
|
||||
cDecl.unbridged()->setInterfaceType(cType.unbridged());
|
||||
}
|
||||
|
||||
void BridgedParamDecl_setSpecifier(BridgedParamDecl cDecl,
|
||||
BridgedParamSpecifier cSpecifier) {
|
||||
cDecl.unbridged()->setSpecifier(unbridge(cSpecifier));
|
||||
@@ -656,6 +729,32 @@ bool BridgedASTType::isSILPackElementAddress() const {
|
||||
return unbridged()->castTo<swift::SILPackType>()->isElementAddress();
|
||||
}
|
||||
|
||||
BridgedASTType BridgedASTType::mapOutOfEnvironment() const {
|
||||
return {unbridged()->mapTypeOutOfEnvironment().getPointer()};
|
||||
}
|
||||
|
||||
BridgedCanType
|
||||
BridgedASTType::getReducedType(BridgedGenericSignature sig) const {
|
||||
return {unbridged()->getReducedType(sig.unbridged())};
|
||||
}
|
||||
|
||||
swift::Identifier BridgedASTType::GenericTypeParam_getName() const {
|
||||
return llvm::cast<swift::GenericTypeParamType>(type)->getName();
|
||||
}
|
||||
|
||||
SwiftInt BridgedASTType::GenericTypeParam_getDepth() const {
|
||||
return llvm::cast<swift::GenericTypeParamType>(type)->getDepth();
|
||||
}
|
||||
|
||||
SwiftInt BridgedASTType::GenericTypeParam_getIndex() const {
|
||||
return llvm::cast<swift::GenericTypeParamType>(type)->getIndex();
|
||||
}
|
||||
|
||||
swift::GenericTypeParamKind
|
||||
BridgedASTType::GenericTypeParam_getParamKind() const {
|
||||
return llvm::cast<swift::GenericTypeParamType>(type)->getParamKind();
|
||||
}
|
||||
|
||||
static_assert((int)BridgedASTType::TraitResult::IsNot == (int)swift::TypeTraitResult::IsNot);
|
||||
static_assert((int)BridgedASTType::TraitResult::CanBe == (int)swift::TypeTraitResult::CanBe);
|
||||
static_assert((int)BridgedASTType::TraitResult::Is == (int)swift::TypeTraitResult::Is);
|
||||
@@ -682,6 +781,13 @@ BridgedASTType BridgedCanType::getRawType() const {
|
||||
return {type};
|
||||
}
|
||||
|
||||
BridgedCanGenericSignature
|
||||
BridgedCanType::SILFunctionType_getSubstGenericSignature() const {
|
||||
return {swift::CanSILFunctionType(llvm::cast<swift::SILFunctionType>(type))
|
||||
->getSubstGenericSignature()
|
||||
.getPointer()};
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// MARK: BridgedASTTypeArray
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -873,6 +979,20 @@ BridgedASTType BridgedGenericSignature::mapTypeIntoEnvironment(BridgedASTType ty
|
||||
return {unbridged().getGenericEnvironment()->mapTypeIntoEnvironment(type.unbridged()).getPointer()};
|
||||
}
|
||||
|
||||
BridgedCanGenericSignature
|
||||
BridgedGenericSignature::getCanonicalSignature() const {
|
||||
return BridgedCanGenericSignature{impl};
|
||||
}
|
||||
|
||||
swift::CanGenericSignature BridgedCanGenericSignature::unbridged() const {
|
||||
return swift::GenericSignature(impl).getCanonicalSignature();
|
||||
}
|
||||
|
||||
BridgedGenericSignature
|
||||
BridgedCanGenericSignature::getGenericSignature() const {
|
||||
return BridgedGenericSignature{impl};
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// MARK: BridgedFingerprint
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@@ -94,8 +94,10 @@
|
||||
// Some of the base classes need to be nullable to allow them to be used as
|
||||
// optional parameters.
|
||||
AST_BRIDGING_WRAPPER_NULLABLE(Decl)
|
||||
AST_BRIDGING_WRAPPER_NONNULL(DeclContext)
|
||||
AST_BRIDGING_WRAPPER_NONNULL(SourceFile)
|
||||
AST_BRIDGING_WRAPPER_NULLABLE(DeclContext)
|
||||
AST_BRIDGING_WRAPPER_NONNULL(GenericContext)
|
||||
AST_BRIDGING_WRAPPER_NONNULL(FileUnit)
|
||||
AST_BRIDGING_WRAPPER_NULLABLE(SourceFile)
|
||||
AST_BRIDGING_WRAPPER_NULLABLE(Stmt)
|
||||
AST_BRIDGING_WRAPPER_NULLABLE(Expr)
|
||||
AST_BRIDGING_WRAPPER_NULLABLE(Pattern)
|
||||
|
||||
@@ -272,6 +272,7 @@ struct BridgedType {
|
||||
BRIDGED_INLINE BridgedType(swift::SILType t);
|
||||
BRIDGED_INLINE swift::SILType unbridged() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedCanType getCanType() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType mapTypeOutOfEnvironment() const;
|
||||
|
||||
static SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType createSILType(BridgedCanType canTy);
|
||||
BRIDGED_INLINE BridgedOwnedString getDebugDescription() const;
|
||||
@@ -305,9 +306,15 @@ struct BridgedType {
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE EnumElementIterator getFirstEnumCaseIterator() const;
|
||||
BRIDGED_INLINE bool isEndCaseIterator(EnumElementIterator i) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getEnumCasePayload(EnumElementIterator i, BridgedFunction f) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType
|
||||
getEnumCasePayload(SwiftInt caseIndex, BridgedFunction f) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclObj
|
||||
getEnumElementDecl(EnumElementIterator i) const;
|
||||
BRIDGED_INLINE SwiftInt getNumTupleElements() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType
|
||||
getTupleElementType(SwiftInt idx) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE swift::Identifier
|
||||
getTupleElementLabel(SwiftInt idx) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getFunctionTypeWithNoEscape(bool withNoEscape) const;
|
||||
BRIDGED_INLINE BridgedArgumentConvention getCalleeConvention() const;
|
||||
|
||||
@@ -525,6 +532,7 @@ struct BridgedFunction {
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef getName() const;
|
||||
BridgedOwnedString getDebugDescription() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedLocation getLocation() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedArrayRef getFilesForModule() const;
|
||||
BRIDGED_INLINE bool isAccessor() const;
|
||||
BRIDGED_INLINE bool isInitializer() const;
|
||||
BRIDGED_INLINE bool isDeinitializer() const;
|
||||
@@ -537,6 +545,7 @@ struct BridgedFunction {
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedGenericSignature getGenericSignature() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSubstitutionMap getForwardingSubstitutionMap() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType mapTypeIntoEnvironment(BridgedASTType ty) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType mapTypeIntoEnvironment(BridgedType ty) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedBasicBlock getFirstBlock() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedBasicBlock getLastBlock() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclRef getDeclRef() const;
|
||||
@@ -573,6 +582,8 @@ struct BridgedFunction {
|
||||
BRIDGED_INLINE void setIsPerformanceConstraint(bool isPerfConstraint) const;
|
||||
BRIDGED_INLINE bool isResilientNominalDecl(BridgedDeclObj decl) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getLoweredType(BridgedASTType type, bool maximallyAbstracted) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType
|
||||
getLoweredTypeWithAbstractionPattern(BridgedCanType type) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getLoweredType(BridgedType type) const;
|
||||
BRIDGED_INLINE BridgedLinkage getLinkage() const;
|
||||
BRIDGED_INLINE void setLinkage(BridgedLinkage linkage) const;
|
||||
@@ -867,6 +878,8 @@ struct BridgedInstruction {
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedBasicBlock BranchInst_getTargetBlock() const;
|
||||
BRIDGED_INLINE SwiftInt SwitchEnumInst_getNumCases() const;
|
||||
BRIDGED_INLINE SwiftInt SwitchEnumInst_getCaseIndex(SwiftInt idx) const;
|
||||
BRIDGED_INLINE OptionalBridgedBasicBlock
|
||||
SwitchEnumInst_getSuccessorForDefault() const;
|
||||
BRIDGED_INLINE SwiftInt StoreInst_getStoreOwnership() const;
|
||||
BRIDGED_INLINE SwiftInt AssignInst_getAssignOwnership() const;
|
||||
BRIDGED_INLINE MarkDependenceKind MarkDependenceInst_dependenceKind() const;
|
||||
@@ -1016,6 +1029,9 @@ struct BridgedBasicBlock {
|
||||
BRIDGED_INLINE SwiftInt getNumArguments() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedArgument getArgument(SwiftInt index) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedArgument addBlockArgument(BridgedType type, BridgedValue::Ownership ownership) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedArgument
|
||||
insertPhiArgument(SwiftInt index, BridgedType type,
|
||||
BridgedValue::Ownership ownership) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedArgument addFunctionArgument(BridgedType type) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedArgument insertFunctionArgument(SwiftInt atPosition, BridgedType type,
|
||||
BridgedValue::Ownership ownership,
|
||||
@@ -1058,6 +1074,7 @@ struct BridgedDeclRef {
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedLocation getLocation() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclObj getDecl() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDiagnosticArgument asDiagnosticArgument() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedNullableSourceFile getSourceFile() const;
|
||||
};
|
||||
|
||||
struct BridgedVTableEntry {
|
||||
@@ -1493,6 +1510,8 @@ struct BridgedContext {
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSubstitutionMap getContextSubstitutionMap(BridgedType type) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getBuiltinIntegerType(SwiftInt bitWidth) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getTupleType(BridgedArrayRef elementTypes) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getTupleTypeWithLabels(
|
||||
BridgedArrayRef elementTypes, BridgedArrayRef labels) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclObj getSwiftArrayDecl() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclObj getSwiftMutableSpanDecl() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedValue getSILUndef(BridgedType type) const;
|
||||
|
||||
@@ -342,6 +342,10 @@ bool BridgedType::isAddress() const {
|
||||
return unbridged().isAddress();
|
||||
}
|
||||
|
||||
BridgedType BridgedType::mapTypeOutOfEnvironment() const {
|
||||
return unbridged().mapTypeOutOfEnvironment();
|
||||
}
|
||||
|
||||
BridgedCanType BridgedType::getCanType() const {
|
||||
return unbridged().getASTType();
|
||||
}
|
||||
@@ -462,6 +466,19 @@ BridgedType BridgedType::getEnumCasePayload(EnumElementIterator i, BridgedFuncti
|
||||
return swift::SILType();
|
||||
}
|
||||
|
||||
BridgedDeclObj BridgedType::getEnumElementDecl(EnumElementIterator i) const {
|
||||
swift::EnumElementDecl *elt = *unbridge(i);
|
||||
return {elt};
|
||||
}
|
||||
|
||||
BridgedType BridgedType::getEnumCasePayload(SwiftInt caseIndex,
|
||||
BridgedFunction f) const {
|
||||
swift::EnumElementDecl *elt = unbridged().getEnumElement(caseIndex);
|
||||
if (elt->hasAssociatedValues())
|
||||
return unbridged().getEnumElementType(elt, f.getFunction());
|
||||
return swift::SILType();
|
||||
}
|
||||
|
||||
SwiftInt BridgedType::getNumTupleElements() const {
|
||||
return unbridged().getNumTupleElements();
|
||||
}
|
||||
@@ -470,6 +487,12 @@ BridgedType BridgedType::getTupleElementType(SwiftInt idx) const {
|
||||
return unbridged().getTupleElementType(idx);
|
||||
}
|
||||
|
||||
swift::Identifier BridgedType::getTupleElementLabel(SwiftInt idx) const {
|
||||
return llvm::cast<swift::TupleType>(unbridged().getASTType().getPointer())
|
||||
->getElement(idx)
|
||||
.getName();
|
||||
}
|
||||
|
||||
BridgedType BridgedType::getFunctionTypeWithNoEscape(bool withNoEscape) const {
|
||||
auto fnType = unbridged().getAs<swift::SILFunctionType>();
|
||||
auto newTy = fnType->getWithExtInfo(fnType->getExtInfo().withNoEscape(true));
|
||||
@@ -734,6 +757,10 @@ BridgedLocation BridgedFunction::getLocation() const {
|
||||
return {swift::SILDebugLocation(getFunction()->getLocation(), getFunction()->getDebugScope())};
|
||||
}
|
||||
|
||||
BridgedArrayRef BridgedFunction::getFilesForModule() const {
|
||||
return getFunction()->getModule().getSwiftModule()->getFiles();
|
||||
}
|
||||
|
||||
bool BridgedFunction::isAccessor() const {
|
||||
if (auto *valDecl = getFunction()->getDeclRef().getDecl()) {
|
||||
return llvm::isa<swift::AccessorDecl>(valDecl);
|
||||
@@ -785,6 +812,10 @@ BridgedASTType BridgedFunction::mapTypeIntoEnvironment(BridgedASTType ty) const
|
||||
return {getFunction()->mapTypeIntoEnvironment(ty.unbridged()).getPointer()};
|
||||
}
|
||||
|
||||
BridgedType BridgedFunction::mapTypeIntoEnvironment(BridgedType ty) const {
|
||||
return {getFunction()->mapTypeIntoEnvironment(ty.unbridged())};
|
||||
}
|
||||
|
||||
OptionalBridgedBasicBlock BridgedFunction::getFirstBlock() const {
|
||||
return {getFunction()->empty() ? nullptr : getFunction()->getEntryBlock()};
|
||||
}
|
||||
@@ -964,6 +995,14 @@ BridgedType BridgedFunction::getLoweredType(BridgedASTType type, bool maximallyA
|
||||
return BridgedType(getFunction()->getLoweredType(type.type));
|
||||
}
|
||||
|
||||
BridgedType BridgedFunction::getLoweredTypeWithAbstractionPattern(BridgedCanType type) const {
|
||||
swift::Lowering::AbstractionPattern pattern(
|
||||
getFunction()->getLoweredFunctionType()->getSubstGenericSignature(),
|
||||
type.unbridged());
|
||||
return getFunction()->getModule().Types.getLoweredType(
|
||||
pattern, type.unbridged(), swift::TypeExpansionContext::minimal());
|
||||
}
|
||||
|
||||
BridgedType BridgedFunction::getLoweredType(BridgedType type) const {
|
||||
return BridgedType(getFunction()->getLoweredType(type.unbridged()));
|
||||
}
|
||||
@@ -1531,6 +1570,14 @@ SwiftInt BridgedInstruction::SwitchEnumInst_getCaseIndex(SwiftInt idx) const {
|
||||
return seInst->getModule().getCaseIndex(seInst->getCase(idx).first);
|
||||
}
|
||||
|
||||
OptionalBridgedBasicBlock
|
||||
BridgedInstruction::SwitchEnumInst_getSuccessorForDefault() const {
|
||||
auto *seInst = getAs<swift::SwitchEnumInst>();
|
||||
if (seInst->hasDefault())
|
||||
return {seInst->getDefaultBB()};
|
||||
return {nullptr};
|
||||
}
|
||||
|
||||
SwiftInt BridgedInstruction::StoreInst_getStoreOwnership() const {
|
||||
return (SwiftInt)getAs<swift::StoreInst>()->getOwnershipQualifier();
|
||||
}
|
||||
@@ -1961,6 +2008,13 @@ BridgedArgument BridgedBasicBlock::addBlockArgument(BridgedType type, BridgedVal
|
||||
type.unbridged(), BridgedValue::unbridge(ownership))};
|
||||
}
|
||||
|
||||
BridgedArgument
|
||||
BridgedBasicBlock::insertPhiArgument(SwiftInt index, BridgedType type,
|
||||
BridgedValue::Ownership ownership) const {
|
||||
return {unbridged()->insertPhiArgument(index, type.unbridged(),
|
||||
BridgedValue::unbridge(ownership))};
|
||||
}
|
||||
|
||||
BridgedArgument BridgedBasicBlock::addFunctionArgument(BridgedType type) const {
|
||||
return {unbridged()->createFunctionArgument(type.unbridged())};
|
||||
}
|
||||
@@ -2048,6 +2102,14 @@ BridgedDiagnosticArgument BridgedDeclRef::asDiagnosticArgument() const {
|
||||
return swift::DiagnosticArgument(unbridged().getDecl()->getName());
|
||||
}
|
||||
|
||||
BridgedNullableSourceFile BridgedDeclRef::getSourceFile() const {
|
||||
swift::SILDeclRef declRef = unbridged();
|
||||
if (!declRef)
|
||||
return nullptr;
|
||||
|
||||
return {declRef.getInnermostDeclContext()->getParentSourceFile()};
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// BridgedVTable
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -3032,6 +3094,24 @@ BridgedASTType BridgedContext::getTupleType(BridgedArrayRef elementTypes) const
|
||||
return {swift::TupleType::get(elements, context->getModule()->getASTContext())};
|
||||
}
|
||||
|
||||
BridgedASTType
|
||||
BridgedContext::getTupleTypeWithLabels(BridgedArrayRef elementTypes,
|
||||
BridgedArrayRef labels) const {
|
||||
assert(elementTypes.getCount() == labels.getCount());
|
||||
llvm::SmallVector<swift::TupleTypeElt, 8> elements;
|
||||
elements.reserve(elementTypes.getCount());
|
||||
llvm::ArrayRef<BridgedASTType> elementTypesArr =
|
||||
elementTypes.unbridged<BridgedASTType>();
|
||||
llvm::ArrayRef<swift::Identifier> labelsArr =
|
||||
labels.unbridged<swift::Identifier>();
|
||||
for (const auto &[bridgedElmtTy, label] :
|
||||
llvm::zip_equal(elementTypesArr, labelsArr)) {
|
||||
elements.emplace_back(bridgedElmtTy.unbridged(), label);
|
||||
}
|
||||
return {
|
||||
swift::TupleType::get(elements, context->getModule()->getASTContext())};
|
||||
}
|
||||
|
||||
BridgedDeclObj BridgedContext::getSwiftArrayDecl() const {
|
||||
return {context->getModule()->getASTContext().getArrayDecl()};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user