mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Swift AST: add some Type APIs
This commit is contained in:
@@ -48,6 +48,8 @@ public struct Type: TypeProperties, CustomStringConvertible, NoReflectionChildre
|
|||||||
|
|
||||||
public var instanceTypeOfMetatype: Type { Type(bridged: bridged.getInstanceTypeOfMetatype()) }
|
public var instanceTypeOfMetatype: Type { Type(bridged: bridged.getInstanceTypeOfMetatype()) }
|
||||||
|
|
||||||
|
public var staticTypeOfDynamicSelf: Type { Type(bridged: bridged.getStaticTypeOfDynamicSelf()) }
|
||||||
|
|
||||||
public var superClassType: Type? {
|
public var superClassType: Type? {
|
||||||
precondition(isClass)
|
precondition(isClass)
|
||||||
let bridgedSuperClassTy = bridged.getSuperClassType()
|
let bridgedSuperClassTy = bridged.getSuperClassType()
|
||||||
@@ -136,10 +138,12 @@ extension TypeProperties {
|
|||||||
|
|
||||||
public var isTuple: Bool { rawType.bridged.isTuple() }
|
public var isTuple: Bool { rawType.bridged.isTuple() }
|
||||||
public var isFunction: Bool { rawType.bridged.isFunction() }
|
public var isFunction: Bool { rawType.bridged.isFunction() }
|
||||||
|
public var isArchetype: Bool { rawType.bridged.isArchetype() }
|
||||||
public var isExistentialArchetype: Bool { rawType.bridged.isExistentialArchetype() }
|
public var isExistentialArchetype: Bool { rawType.bridged.isExistentialArchetype() }
|
||||||
public var isExistentialArchetypeWithError: Bool { rawType.bridged.isExistentialArchetypeWithError() }
|
public var isExistentialArchetypeWithError: Bool { rawType.bridged.isExistentialArchetypeWithError() }
|
||||||
public var isExistential: Bool { rawType.bridged.isExistential() }
|
public var isExistential: Bool { rawType.bridged.isExistential() }
|
||||||
public var isClassExistential: Bool { rawType.bridged.isClassExistential() }
|
public var isClassExistential: Bool { rawType.bridged.isClassExistential() }
|
||||||
|
public var isGenericTypeParameter: Bool { rawType.bridged.isGenericTypeParam() }
|
||||||
public var isUnownedStorageType: Bool { return rawType.bridged.isUnownedStorageType() }
|
public var isUnownedStorageType: Bool { return rawType.bridged.isUnownedStorageType() }
|
||||||
public var isMetatype: Bool { rawType.bridged.isMetatypeType() }
|
public var isMetatype: Bool { rawType.bridged.isMetatypeType() }
|
||||||
public var isExistentialMetatype: Bool { rawType.bridged.isExistentialMetatypeType() }
|
public var isExistentialMetatype: Bool { rawType.bridged.isExistentialMetatypeType() }
|
||||||
@@ -187,6 +191,7 @@ extension TypeProperties {
|
|||||||
public var isEscapable: Bool { rawType.bridged.isEscapable() }
|
public var isEscapable: Bool { rawType.bridged.isEscapable() }
|
||||||
public var isNoEscape: Bool { rawType.bridged.isNoEscape() }
|
public var isNoEscape: Bool { rawType.bridged.isNoEscape() }
|
||||||
public var isBuiltinType: Bool { rawType.bridged.isBuiltinType() }
|
public var isBuiltinType: Bool { rawType.bridged.isBuiltinType() }
|
||||||
|
public var archetypeRequiresClass: Bool { rawType.bridged.archetypeRequiresClass() }
|
||||||
|
|
||||||
public var representationOfMetatype: AST.`Type`.MetatypeRepresentation {
|
public var representationOfMetatype: AST.`Type`.MetatypeRepresentation {
|
||||||
rawType.bridged.getRepresentationOfMetatype().representation
|
rawType.bridged.getRepresentationOfMetatype().representation
|
||||||
|
|||||||
@@ -3100,11 +3100,14 @@ struct BridgedASTType {
|
|||||||
BRIDGED_INLINE bool isGenericAtAnyLevel() const;
|
BRIDGED_INLINE bool isGenericAtAnyLevel() const;
|
||||||
BRIDGED_INLINE bool hasTypeParameter() const;
|
BRIDGED_INLINE bool hasTypeParameter() const;
|
||||||
BRIDGED_INLINE bool hasLocalArchetype() const;
|
BRIDGED_INLINE bool hasLocalArchetype() const;
|
||||||
|
BRIDGED_INLINE bool isArchetype() const;
|
||||||
|
BRIDGED_INLINE bool archetypeRequiresClass() const;
|
||||||
BRIDGED_INLINE bool isExistentialArchetype() const;
|
BRIDGED_INLINE bool isExistentialArchetype() const;
|
||||||
BRIDGED_INLINE bool isExistentialArchetypeWithError() const;
|
BRIDGED_INLINE bool isExistentialArchetypeWithError() const;
|
||||||
BRIDGED_INLINE bool isExistential() const;
|
BRIDGED_INLINE bool isExistential() const;
|
||||||
BRIDGED_INLINE bool isDynamicSelf() const;
|
BRIDGED_INLINE bool isDynamicSelf() const;
|
||||||
BRIDGED_INLINE bool isClassExistential() const;
|
BRIDGED_INLINE bool isClassExistential() const;
|
||||||
|
BRIDGED_INLINE bool isGenericTypeParam() const;
|
||||||
BRIDGED_INLINE bool isEscapable() const;
|
BRIDGED_INLINE bool isEscapable() const;
|
||||||
BRIDGED_INLINE bool isNoEscape() const;
|
BRIDGED_INLINE bool isNoEscape() const;
|
||||||
BRIDGED_INLINE bool isInteger() const;
|
BRIDGED_INLINE bool isInteger() const;
|
||||||
@@ -3129,6 +3132,7 @@ struct BridgedASTType {
|
|||||||
BRIDGED_INLINE TraitResult canBeClass() const;
|
BRIDGED_INLINE TraitResult canBeClass() const;
|
||||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedDeclObj getAnyNominal() const;
|
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedDeclObj getAnyNominal() const;
|
||||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getInstanceTypeOfMetatype() 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;
|
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getSuperClassType() const;
|
||||||
BRIDGED_INLINE MetatypeRepresentation getRepresentationOfMetatype() const;
|
BRIDGED_INLINE MetatypeRepresentation getRepresentationOfMetatype() const;
|
||||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSubstitutionMap getContextSubstitutionMap() const;
|
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSubstitutionMap getContextSubstitutionMap() const;
|
||||||
|
|||||||
@@ -423,6 +423,14 @@ bool BridgedASTType::hasLocalArchetype() const {
|
|||||||
return unbridged()->hasLocalArchetype();
|
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 {
|
bool BridgedASTType::isExistentialArchetype() const {
|
||||||
return unbridged()->is<swift::ExistentialArchetypeType>();
|
return unbridged()->is<swift::ExistentialArchetypeType>();
|
||||||
}
|
}
|
||||||
@@ -443,6 +451,10 @@ bool BridgedASTType::isClassExistential() const {
|
|||||||
return unbridged()->isClassExistentialType();
|
return unbridged()->isClassExistentialType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BridgedASTType::isGenericTypeParam() const {
|
||||||
|
return unbridged()->is<swift::GenericTypeParamType>();
|
||||||
|
}
|
||||||
|
|
||||||
bool BridgedASTType::isEscapable() const {
|
bool BridgedASTType::isEscapable() const {
|
||||||
return unbridged()->isEscapable();
|
return unbridged()->isEscapable();
|
||||||
}
|
}
|
||||||
@@ -551,6 +563,10 @@ BridgedASTType BridgedASTType::getInstanceTypeOfMetatype() const {
|
|||||||
return {unbridged()->getAs<swift::AnyMetatypeType>()->getInstanceType().getPointer()};
|
return {unbridged()->getAs<swift::AnyMetatypeType>()->getInstanceType().getPointer()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BridgedASTType BridgedASTType::getStaticTypeOfDynamicSelf() const {
|
||||||
|
return {unbridged()->getAs<swift::DynamicSelfType>()->getSelfType().getPointer()};
|
||||||
|
}
|
||||||
|
|
||||||
BridgedASTType BridgedASTType::getSuperClassType() const {
|
BridgedASTType BridgedASTType::getSuperClassType() const {
|
||||||
return {unbridged()->getSuperclass().getPointer()};
|
return {unbridged()->getSuperclass().getPointer()};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user