mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
AST: add enum FunctionTypeRepresentation and TypeProperties.functionTypeRepresentation
This commit is contained in:
@@ -2985,6 +2985,22 @@ struct BridgedASTType {
|
||||
ObjC
|
||||
};
|
||||
|
||||
enum class FunctionTypeRepresentation {
|
||||
Thick = 0,
|
||||
Block,
|
||||
Thin,
|
||||
CFunctionPointer,
|
||||
Method = 8,
|
||||
ObjCMethod,
|
||||
WitnessMethod,
|
||||
Closure,
|
||||
CXXMethod,
|
||||
KeyPathAccessorGetter,
|
||||
KeyPathAccessorSetter,
|
||||
KeyPathAccessorEquals,
|
||||
KeyPathAccessorHash
|
||||
};
|
||||
|
||||
swift::TypeBase * _Nullable type;
|
||||
|
||||
BRIDGED_INLINE swift::Type unbridged() const;
|
||||
@@ -3047,6 +3063,7 @@ struct BridgedASTType {
|
||||
BRIDGED_INLINE BridgedOptionalInt getValueOfIntegerType() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSubstitutionMap getContextSubstitutionMap() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedGenericSignature getInvocationGenericSignatureOfFunctionType() const;
|
||||
BRIDGED_INLINE FunctionTypeRepresentation getFunctionTypeRepresentation() 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
|
||||
|
||||
@@ -713,6 +713,25 @@ BridgedGenericSignature BridgedASTType::getInvocationGenericSignatureOfFunctionT
|
||||
return {unbridged()->castTo<swift::SILFunctionType>()->getInvocationGenericSignature().getPointer()};
|
||||
}
|
||||
|
||||
BridgedASTType::FunctionTypeRepresentation BridgedASTType::getFunctionTypeRepresentation() const {
|
||||
static_assert((int)FunctionTypeRepresentation::Thick == (int)swift::SILFunctionTypeRepresentation::Thick);
|
||||
static_assert((int)FunctionTypeRepresentation::Block == (int)swift::SILFunctionTypeRepresentation::Block);
|
||||
static_assert((int)FunctionTypeRepresentation::Thin == (int)swift::SILFunctionTypeRepresentation::Thin);
|
||||
static_assert((int)FunctionTypeRepresentation::CFunctionPointer == (int)swift::SILFunctionTypeRepresentation::CFunctionPointer);
|
||||
static_assert((int)FunctionTypeRepresentation::Method == (int)swift::SILFunctionTypeRepresentation::Method);
|
||||
static_assert((int)FunctionTypeRepresentation::ObjCMethod == (int)swift::SILFunctionTypeRepresentation::ObjCMethod);
|
||||
static_assert((int)FunctionTypeRepresentation::WitnessMethod == (int)swift::SILFunctionTypeRepresentation::WitnessMethod);
|
||||
static_assert((int)FunctionTypeRepresentation::Closure == (int)swift::SILFunctionTypeRepresentation::Closure);
|
||||
static_assert((int)FunctionTypeRepresentation::CXXMethod == (int)swift::SILFunctionTypeRepresentation::CXXMethod);
|
||||
static_assert((int)FunctionTypeRepresentation::KeyPathAccessorGetter == (int)swift::SILFunctionTypeRepresentation::KeyPathAccessorGetter);
|
||||
static_assert((int)FunctionTypeRepresentation::KeyPathAccessorSetter == (int)swift::SILFunctionTypeRepresentation::KeyPathAccessorSetter);
|
||||
static_assert((int)FunctionTypeRepresentation::KeyPathAccessorEquals == (int)swift::SILFunctionTypeRepresentation::KeyPathAccessorEquals);
|
||||
static_assert((int)FunctionTypeRepresentation::KeyPathAccessorHash == (int)swift::SILFunctionTypeRepresentation::KeyPathAccessorHash);
|
||||
|
||||
auto fnType = unbridged()->castTo<swift::SILFunctionType>();
|
||||
return (FunctionTypeRepresentation)(fnType->getRepresentation());
|
||||
}
|
||||
|
||||
BridgedASTType BridgedASTType::subst(BridgedSubstitutionMap substMap) const {
|
||||
return {unbridged().subst(substMap.unbridged()).getPointer()};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user