Swift AST: add some Type APIs

This commit is contained in:
Erik Eckstein
2025-04-17 12:46:14 +02:00
parent 55f82ea3a0
commit e84228baf4
3 changed files with 25 additions and 0 deletions

View File

@@ -3100,11 +3100,14 @@ struct BridgedASTType {
BRIDGED_INLINE bool isGenericAtAnyLevel() const;
BRIDGED_INLINE bool hasTypeParameter() const;
BRIDGED_INLINE bool hasLocalArchetype() const;
BRIDGED_INLINE bool isArchetype() const;
BRIDGED_INLINE bool archetypeRequiresClass() const;
BRIDGED_INLINE bool isExistentialArchetype() const;
BRIDGED_INLINE bool isExistentialArchetypeWithError() const;
BRIDGED_INLINE bool isExistential() const;
BRIDGED_INLINE bool isDynamicSelf() const;
BRIDGED_INLINE bool isClassExistential() const;
BRIDGED_INLINE bool isGenericTypeParam() const;
BRIDGED_INLINE bool isEscapable() const;
BRIDGED_INLINE bool isNoEscape() const;
BRIDGED_INLINE bool isInteger() const;
@@ -3129,6 +3132,7 @@ struct BridgedASTType {
BRIDGED_INLINE TraitResult canBeClass() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedDeclObj getAnyNominal() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getInstanceTypeOfMetatype() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getStaticTypeOfDynamicSelf() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getSuperClassType() const;
BRIDGED_INLINE MetatypeRepresentation getRepresentationOfMetatype() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSubstitutionMap getContextSubstitutionMap() const;

View File

@@ -423,6 +423,14 @@ bool BridgedASTType::hasLocalArchetype() const {
return unbridged()->hasLocalArchetype();
}
bool BridgedASTType::isArchetype() const {
return unbridged()->is<swift::ArchetypeType>();
}
bool BridgedASTType::archetypeRequiresClass() const {
return unbridged()->castTo<swift::ArchetypeType>()->requiresClass();
}
bool BridgedASTType::isExistentialArchetype() const {
return unbridged()->is<swift::ExistentialArchetypeType>();
}
@@ -443,6 +451,10 @@ bool BridgedASTType::isClassExistential() const {
return unbridged()->isClassExistentialType();
}
bool BridgedASTType::isGenericTypeParam() const {
return unbridged()->is<swift::GenericTypeParamType>();
}
bool BridgedASTType::isEscapable() const {
return unbridged()->isEscapable();
}
@@ -551,6 +563,10 @@ BridgedASTType BridgedASTType::getInstanceTypeOfMetatype() const {
return {unbridged()->getAs<swift::AnyMetatypeType>()->getInstanceType().getPointer()};
}
BridgedASTType BridgedASTType::getStaticTypeOfDynamicSelf() const {
return {unbridged()->getAs<swift::DynamicSelfType>()->getSelfType().getPointer()};
}
BridgedASTType BridgedASTType::getSuperClassType() const {
return {unbridged()->getSuperclass().getPointer()};
}