mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Address review comments
This commit is contained in:
@@ -29,6 +29,10 @@ public class Decl: CustomStringConvertible, Hashable {
|
||||
// True if this declaration is imported from C/C++/ObjC.
|
||||
public var hasClangNode: Bool { bridged.hasClangNode() }
|
||||
|
||||
public var declContext: DeclContext { bridgedDecl.declContext }
|
||||
|
||||
var bridgedDecl: BridgedDecl { BridgedDecl(raw: bridged.obj) }
|
||||
|
||||
public static func ==(lhs: Decl, rhs: Decl) -> Bool { lhs === rhs }
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
@@ -39,7 +43,7 @@ public class Decl: CustomStringConvertible, Hashable {
|
||||
public class ValueDecl: Decl {
|
||||
final public var nameLoc: SourceLoc? { SourceLoc(bridged: bridged.Value_getNameLoc()) }
|
||||
final public var userFacingName: StringRef { StringRef(bridged: bridged.Value_getUserFacingName()) }
|
||||
final public var baseIdentifier: swift.Identifier { bridged.Value_getBaseIdentifier() }
|
||||
final public var baseIdentifier: Identifier { bridged.Value_getBaseIdentifier() }
|
||||
final public var isObjC: Bool { bridged.Value_isObjC() }
|
||||
}
|
||||
|
||||
@@ -58,8 +62,8 @@ public class NominalTypeDecl: GenericTypeDecl {
|
||||
bridged.NominalType_getValueTypeDestructor().getAs(DestructorDecl.self)
|
||||
}
|
||||
|
||||
public var declaredInterfaceType : AST.`Type` {
|
||||
AST.`Type`(bridged: bridged.NominalType_getDeclaredInterfaceType())
|
||||
public var declaredInterfaceType: Type {
|
||||
Type(bridged: bridged.NominalType_getDeclaredInterfaceType())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,8 +127,8 @@ final public class MacroDecl: ValueDecl {}
|
||||
|
||||
final public class EnumElementDecl: ValueDecl {
|
||||
public var hasAssociatedValues: Bool { bridged.EnumElementDecl_hasAssociatedValues() }
|
||||
public var parameterList: BridgedParameterList { bridged.EnumElementDecl_getParameterList() }
|
||||
public var nameStr: StringRef { StringRef(bridged: bridged.EnumElementDecl_getNameStr()) }
|
||||
public var parameterList: ParameterList { bridged.EnumElementDecl_getParameterList() }
|
||||
public var name: StringRef { StringRef(bridged: bridged.EnumElementDecl_getNameStr()) }
|
||||
}
|
||||
|
||||
final public class ExtensionDecl: Decl {}
|
||||
@@ -172,3 +176,150 @@ extension Optional where Wrapped == Decl {
|
||||
OptionalBridgedDeclObj(self?.bridged.obj)
|
||||
}
|
||||
}
|
||||
|
||||
public typealias Identifier = swift.Identifier
|
||||
|
||||
public typealias GenericTypeParamKind = swift.GenericTypeParamKind
|
||||
|
||||
public typealias ASTContext = BridgedASTContext
|
||||
|
||||
public typealias DeclContext = BridgedDeclContext
|
||||
|
||||
public typealias Expr = BridgedExpr
|
||||
|
||||
public typealias ParameterList = BridgedParameterList
|
||||
|
||||
public typealias SourceFile = BridgedSourceFile
|
||||
|
||||
public typealias FileUnit = BridgedFileUnit
|
||||
|
||||
public typealias GenericParamList = BridgedGenericParamList
|
||||
|
||||
public typealias TrailingWhereClause = BridgedTrailingWhereClause
|
||||
|
||||
public typealias BridgedParamDecl = ASTBridging.BridgedParamDecl
|
||||
|
||||
public typealias BridgedGenericTypeParamDecl = ASTBridging.BridgedGenericTypeParamDecl
|
||||
|
||||
public typealias BridgedEnumDecl = ASTBridging.BridgedEnumDecl
|
||||
|
||||
public typealias BridgedEnumElementDecl = ASTBridging.BridgedEnumElementDecl
|
||||
|
||||
extension ParameterList {
|
||||
public subscript(_ index: Int) -> BridgedParamDecl {
|
||||
return get(index)
|
||||
}
|
||||
|
||||
public static func createParsed(
|
||||
_ astContext: ASTContext, leftParenLoc: SourceLoc?, parameters: [BridgedParamDecl],
|
||||
rightParenLoc: SourceLoc?
|
||||
) -> ParameterList {
|
||||
parameters.withBridgedArrayRef {
|
||||
ParameterList.createParsed(
|
||||
astContext, leftParenLoc: leftParenLoc.bridgedLocation, parameters: $0,
|
||||
rightParenLoc: rightParenLoc.bridgedLocation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension GenericParamList {
|
||||
public static func createParsed(
|
||||
_ astContext: ASTContext, leftAngleLoc: SourceLoc?, parameters: [BridgedGenericTypeParamDecl],
|
||||
genericWhereClause: TrailingWhereClause?,
|
||||
rightAngleLoc: SourceLoc?
|
||||
) -> GenericParamList {
|
||||
return parameters.withBridgedArrayRef {
|
||||
GenericParamList.createParsed(
|
||||
astContext, leftAngleLoc: leftAngleLoc.bridgedLocation, parameters: $0,
|
||||
genericWhereClause: genericWhereClause.bridged, rightAngleLoc: rightAngleLoc.bridgedLocation
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension BridgedDecl {
|
||||
public var declObj: BridgedDeclObj {
|
||||
BridgedDeclObj(SwiftObject(raw.bindMemory(to: BridgedSwiftObject.self, capacity: 1)))
|
||||
}
|
||||
public var decl: Decl { declObj.decl }
|
||||
}
|
||||
|
||||
extension BridgedEnumDecl {
|
||||
public static func createParsed(
|
||||
_ astContext: ASTContext, declContext: DeclContext, enumKeywordLoc: SourceLoc?, name: String,
|
||||
nameLoc: SourceLoc?, genericParamList: GenericParamList?, inheritedTypes: [Type],
|
||||
genericWhereClause: TrailingWhereClause?, braceRange: SourceRange
|
||||
) -> BridgedEnumDecl {
|
||||
return name.withCString { strPtr in
|
||||
inheritedTypes.withBridgedArrayRef { types in
|
||||
BridgedEnumDecl.createParsed(
|
||||
astContext, declContext: declContext,
|
||||
enumKeywordLoc: enumKeywordLoc.bridgedLocation,
|
||||
name: astContext.getIdentifier(BridgedStringRef(data: strPtr, count: name.count)),
|
||||
nameLoc: nameLoc.bridgedLocation,
|
||||
genericParamList: genericParamList.bridged,
|
||||
inheritedTypes: types,
|
||||
genericWhereClause: genericWhereClause.bridged,
|
||||
braceRange: braceRange.bridged)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension BridgedEnumElementDecl {
|
||||
public static func createParsed(
|
||||
_ astContext: ASTContext, declContext: DeclContext,
|
||||
name: Identifier, nameLoc: SourceLoc?,
|
||||
parameterList: ParameterList?,
|
||||
equalsLoc: SourceLoc?, rawValue: Expr?
|
||||
) -> BridgedEnumElementDecl {
|
||||
BridgedEnumElementDecl.createParsed(
|
||||
astContext, declContext: declContext,
|
||||
name: name, nameLoc: nameLoc.bridgedLocation,
|
||||
parameterList: parameterList.bridged,
|
||||
equalsLoc: equalsLoc.bridgedLocation, rawValue: rawValue.bridged)
|
||||
}
|
||||
}
|
||||
|
||||
extension SourceFile {
|
||||
public init?(bridged: BridgedNullableSourceFile) {
|
||||
guard let raw = bridged.raw else {
|
||||
return nil
|
||||
}
|
||||
self.init(raw: raw)
|
||||
}
|
||||
}
|
||||
|
||||
extension FileUnit {
|
||||
public var asSourceFile: SourceFile? { SourceFile(bridged: self.castToSourceFile()) }
|
||||
}
|
||||
|
||||
extension BridgedParamDecl {
|
||||
public func setInterfaceType(type: Type) {
|
||||
self.setInterfaceType(type.bridged)
|
||||
}
|
||||
}
|
||||
|
||||
extension ParameterList? {
|
||||
public var bridged: BridgedNullableParameterList {
|
||||
BridgedNullableParameterList(raw: self?.raw)
|
||||
}
|
||||
}
|
||||
|
||||
extension GenericParamList? {
|
||||
public var bridged: BridgedNullableGenericParamList {
|
||||
BridgedNullableGenericParamList(raw: self?.raw)
|
||||
}
|
||||
}
|
||||
|
||||
extension Expr? {
|
||||
public var bridged: BridgedNullableExpr {
|
||||
BridgedNullableExpr(raw: self?.raw)
|
||||
}
|
||||
}
|
||||
|
||||
extension TrailingWhereClause? {
|
||||
public var bridged: BridgedNullableTrailingWhereClause {
|
||||
BridgedNullableTrailingWhereClause(raw: self?.raw)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,10 +36,12 @@ public struct GenericSignature: CustomStringConvertible, NoReflectionChildren {
|
||||
|
||||
public var isEmpty: Bool { bridged.impl == nil }
|
||||
|
||||
public var canonicalSignature: CanGenericSignature { CanGenericSignature(bridged: bridged.getCanonicalSignature()) }
|
||||
public var canonicalSignature: CanonicalGenericSignature {
|
||||
CanonicalGenericSignature(bridged: bridged.getCanonicalSignature())
|
||||
}
|
||||
}
|
||||
|
||||
public struct CanGenericSignature {
|
||||
public struct CanonicalGenericSignature {
|
||||
public let bridged: BridgedCanGenericSignature
|
||||
|
||||
public init(bridged: BridgedCanGenericSignature) {
|
||||
@@ -48,5 +50,7 @@ public struct CanGenericSignature {
|
||||
|
||||
public var isEmpty: Bool { bridged.impl == nil }
|
||||
|
||||
public var genericSignature: GenericSignature { GenericSignature(bridged: bridged.getGenericSignature()) }
|
||||
public var genericSignature: GenericSignature {
|
||||
GenericSignature(bridged: bridged.getGenericSignature())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,24 +71,26 @@ public struct Type: TypeProperties, CustomStringConvertible, NoReflectionChildre
|
||||
return Type(bridged: bridged.mapTypeOutOfContext())
|
||||
}
|
||||
|
||||
public func getReducedType(sig: GenericSignature) -> CanonicalType {
|
||||
CanonicalType(bridged: bridged.getReducedType(sig.bridged))
|
||||
/// Returns a stronger canonicalization which folds away equivalent
|
||||
/// associated types, or type parameters that have been made concrete.
|
||||
public func getReducedType(of signature: GenericSignature) -> CanonicalType {
|
||||
CanonicalType(bridged: bridged.getReducedType(signature.bridged))
|
||||
}
|
||||
|
||||
public func GenericTypeParam_getName() -> swift.Identifier {
|
||||
return bridged.GenericTypeParam_getName()
|
||||
public var nameOfGenericTypeParameter: Identifier {
|
||||
bridged.GenericTypeParam_getName()
|
||||
}
|
||||
|
||||
public func GenericTypeParam_getDepth() -> UInt {
|
||||
return bridged.GenericTypeParam_getDepth()
|
||||
public var depthOfGenericTypeParameter: Int {
|
||||
bridged.GenericTypeParam_getDepth()
|
||||
}
|
||||
|
||||
public func GenericTypeParam_getIndex() -> UInt {
|
||||
return bridged.GenericTypeParam_getIndex()
|
||||
public var indexOfGenericTypeParameter: Int {
|
||||
bridged.GenericTypeParam_getIndex()
|
||||
}
|
||||
|
||||
public func GenericTypeParam_getParamKind() -> swift.GenericTypeParamKind {
|
||||
return bridged.GenericTypeParam_getParamKind()
|
||||
public var kindOfGenericTypeParameter: GenericTypeParameterKind {
|
||||
bridged.GenericTypeParam_getParamKind()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,10 +112,6 @@ public struct CanonicalType: TypeProperties, CustomStringConvertible, NoReflecti
|
||||
public func subst(with substitutionMap: SubstitutionMap) -> CanonicalType {
|
||||
return rawType.subst(with: substitutionMap).canonical
|
||||
}
|
||||
|
||||
public func SILFunctionType_getSubstGenericSignature() -> CanGenericSignature {
|
||||
CanGenericSignature(bridged: bridged.SILFunctionType_getSubstGenericSignature())
|
||||
}
|
||||
}
|
||||
|
||||
/// Implements the common members of `AST.Type`, `AST.CanonicalType` and `SIL.Type`.
|
||||
@@ -270,6 +268,12 @@ extension TypeProperties {
|
||||
public func checkConformance(to protocol: ProtocolDecl) -> Conformance {
|
||||
return Conformance(bridged: rawType.bridged.checkConformance(`protocol`.bridged))
|
||||
}
|
||||
|
||||
/// The generic signature that the component types are specified in terms of, if any.
|
||||
public var substitutedGenericSignatureOfFunctionType: CanonicalGenericSignature {
|
||||
CanonicalGenericSignature(
|
||||
bridged: rawType.canonical.bridged.SILFunctionType_getSubstGenericSignature())
|
||||
}
|
||||
}
|
||||
|
||||
public struct TypeArray : RandomAccessCollection, CustomReflectable {
|
||||
@@ -327,3 +331,5 @@ extension CanonicalType: Equatable {
|
||||
lhs.rawType == rhs.rawType
|
||||
}
|
||||
}
|
||||
|
||||
public typealias GenericTypeParameterKind = swift.GenericTypeParamKind
|
||||
|
||||
@@ -35,6 +35,14 @@ extension Optional<SourceLoc> {
|
||||
}
|
||||
}
|
||||
|
||||
public struct SourceRange {
|
||||
public let bridged: swift.SourceRange
|
||||
|
||||
public init(start: SourceLoc?) {
|
||||
self.bridged = swift.SourceRange(start: start.bridgedLocation)
|
||||
}
|
||||
}
|
||||
|
||||
public struct CharSourceRange {
|
||||
public let start: SourceLoc
|
||||
public let byteLength: UInt32
|
||||
|
||||
@@ -50,10 +50,6 @@ public class Argument : Value, Hashable {
|
||||
|
||||
public var sourceLoc: SourceLoc? { findVarDecl()?.nameLoc }
|
||||
|
||||
public func replaceAllUsesWith(newArg: Argument) {
|
||||
bridged.replaceAllUsesWith(newArg.bridged)
|
||||
}
|
||||
|
||||
public static func ==(lhs: Argument, rhs: Argument) -> Bool {
|
||||
lhs === rhs
|
||||
}
|
||||
|
||||
@@ -68,7 +68,9 @@ final public class BasicBlock : CustomStringConvertible, HasShortDescription, Ha
|
||||
(decl as Decl?).bridged).argument as! FunctionArgument
|
||||
}
|
||||
|
||||
public func insertPhiArgument(atPosition: Int, type: Type, ownership: Ownership, _ context: some MutatingContext) -> Argument {
|
||||
public func insertPhiArgument(
|
||||
atPosition: Int, type: Type, ownership: Ownership, _ context: some MutatingContext
|
||||
) -> Argument {
|
||||
context.notifyInstructionsChanged()
|
||||
return bridged.insertPhiArgument(atPosition, type.bridged, ownership._bridged).argument
|
||||
}
|
||||
|
||||
@@ -662,13 +662,6 @@ public struct Builder {
|
||||
return notifyNew(tuple.getAs(TupleInst.self))
|
||||
}
|
||||
|
||||
public func createTuple(elements: [Value]) -> TupleInst {
|
||||
let tuple = elements.withBridgedValues { valuesRef in
|
||||
return bridged.createTuple(valuesRef)
|
||||
}
|
||||
return notifyNew(tuple.getAs(TupleInst.self))
|
||||
}
|
||||
|
||||
public func createTupleExtract(tuple: Value, elementIndex: Int) -> TupleExtractInst {
|
||||
return notifyNew(bridged.createTupleExtract(tuple.bridged, elementIndex).getAs(TupleExtractInst.self))
|
||||
}
|
||||
|
||||
@@ -49,10 +49,7 @@ extension Context {
|
||||
public func getBuiltinIntegerType(bitWidth: Int) -> Type { _bridged.getBuiltinIntegerType(bitWidth).type }
|
||||
|
||||
public func getTupleType(elements: [Type]) -> AST.`Type` {
|
||||
let bridgedElements = elements.map { $0.bridged }
|
||||
return bridgedElements.withBridgedArrayRef {
|
||||
AST.`Type`(bridged: _bridged.getTupleType($0))
|
||||
}
|
||||
return getTupleType(elements: elements.map{ $0.rawType })
|
||||
}
|
||||
|
||||
public func getTupleType(elements: [AST.`Type`]) -> AST.`Type` {
|
||||
@@ -62,11 +59,10 @@ extension Context {
|
||||
}
|
||||
}
|
||||
|
||||
public func getTupleTypeWithLabels(elements: [AST.`Type`], labels: [swift.Identifier]) -> AST.`Type` {
|
||||
assert(elements.count == labels.count)
|
||||
return elements.withBridgedArrayRef{
|
||||
eltArr in labels.withBridgedArrayRef{labelsArr in
|
||||
AST.`Type`(bridged: _bridged.getTupleTypeWithLabels(eltArr, labelsArr))}}
|
||||
public func getTupleType(elements: [(label: Identifier, type: AST.`Type`)]) -> AST.`Type` {
|
||||
return elements.map{$0.type}.withBridgedArrayRef{
|
||||
types in elements.map{$0.label}.withBridgedArrayRef{labels in
|
||||
AST.`Type`(bridged: _bridged.getTupleTypeWithLabels(types, labels))}}
|
||||
}
|
||||
|
||||
public var swiftArrayDecl: NominalTypeDecl {
|
||||
|
||||
@@ -26,9 +26,7 @@ final public class Function : CustomStringConvertible, HasShortDescription, Hash
|
||||
return Location(bridged: bridged.getLocation())
|
||||
}
|
||||
|
||||
public var sourceFile: BridgedNullableSourceFile {
|
||||
return bridged.getSourceFile()
|
||||
}
|
||||
public var sourceFile: SourceFile? { SourceFile(bridged: bridged.getSourceFile()) }
|
||||
|
||||
final public var description: String {
|
||||
return String(taking: bridged.getDebugDescription())
|
||||
|
||||
@@ -1351,7 +1351,6 @@ final public class PartialApplyInst : SingleValueInstruction, ApplySite {
|
||||
public var hasUnknownResultIsolation: Bool { bridged.PartialApplyInst_hasUnknownResultIsolation() }
|
||||
public var unappliedArgumentCount: Int { bridged.PartialApply_getCalleeArgIndexOfFirstAppliedArg() }
|
||||
public var calleeConvention: ArgumentConvention { type.bridged.getCalleeConvention().convention }
|
||||
public var substitutionMap: SubstitutionMap { SubstitutionMap(bridged: bridged.PartialApplyInst_getSubstitutionMap()) }
|
||||
}
|
||||
|
||||
final public class ApplyInst : SingleValueInstruction, FullApplySite {
|
||||
@@ -1930,7 +1929,6 @@ final public class SwitchValueInst : TermInst {
|
||||
final public class SwitchEnumInst : TermInst {
|
||||
|
||||
public var enumOp: Value { operands[0].value }
|
||||
public var numCases: Int { bridged.SwitchEnumInst_getNumCases() }
|
||||
|
||||
public struct CaseIndexArray : RandomAccessCollection {
|
||||
fileprivate let switchEnum: SwitchEnumInst
|
||||
@@ -1949,6 +1947,8 @@ final public class SwitchEnumInst : TermInst {
|
||||
zip(caseIndices, successors)
|
||||
}
|
||||
|
||||
public var numCases: Int { caseIndices.count }
|
||||
|
||||
// This does not handle the special case where the default covers exactly
|
||||
// the "missing" case.
|
||||
public func getUniqueSuccessor(forCaseIndex: Int) -> BasicBlock? {
|
||||
|
||||
@@ -27,7 +27,6 @@ public struct Type : TypeProperties, CustomStringConvertible, NoReflectionChildr
|
||||
|
||||
public var isAddress: Bool { bridged.isAddress() }
|
||||
public var isObject: Bool { !isAddress }
|
||||
public var category: ValueCategory { ValueCategory(bridged: bridged.getCategory()) }
|
||||
|
||||
public var addressType: Type { bridged.getAddressType().type }
|
||||
public var objectType: Type { bridged.getObjectType().type }
|
||||
@@ -186,6 +185,22 @@ public struct Type : TypeProperties, CustomStringConvertible, NoReflectionChildr
|
||||
return EnumCases(enumType: self, function: function)
|
||||
}
|
||||
|
||||
public func getEnumCase(in function: Function, at index: Int) -> EnumCase? {
|
||||
guard let enumCases = getEnumCases(in: function) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
var enumCaseIndex = 0
|
||||
for enumCase in enumCases {
|
||||
if index == enumCaseIndex {
|
||||
return enumCase
|
||||
}
|
||||
enumCaseIndex += 1
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
public func getIndexOfEnumCase(withName name: String) -> Int? {
|
||||
let idx = name._withBridgedStringRef {
|
||||
bridged.getCaseIdxOfEnumType($0)
|
||||
@@ -216,14 +231,8 @@ public struct Type : TypeProperties, CustomStringConvertible, NoReflectionChildr
|
||||
return false
|
||||
}
|
||||
|
||||
public func getEnumCasePayload(caseIdx: Int, function: Function) -> Type {
|
||||
bridged.getEnumCasePayload(caseIdx, function.bridged).type
|
||||
}
|
||||
|
||||
public func mapTypeOutOfContext() -> Type { bridged.mapTypeOutOfContext().type }
|
||||
|
||||
public static func getPrimitiveType(canType: CanonicalType, silValueCategory: ValueCategory) -> Type {
|
||||
BridgedType.getPrimitiveType(canType: canType.bridged, silValueCategory: silValueCategory._bridged).type
|
||||
public func mapTypeOutOfContext(in function: Function) -> Type {
|
||||
rawType.mapTypeOutOfContext().canonical.loweredType(in: function)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,7 +327,7 @@ public struct TupleElementArray : RandomAccessCollection, FormattedLikeArray {
|
||||
type.bridged.getTupleElementType(index).type
|
||||
}
|
||||
|
||||
public func label(at index: Int) -> swift.Identifier {
|
||||
public func label(at index: Int) -> Identifier {
|
||||
type.bridged.getTupleElementLabel(index)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,27 +41,6 @@ public protocol Value : AnyObject, CustomStringConvertible {
|
||||
var isLexical: Bool { get }
|
||||
}
|
||||
|
||||
public enum ValueCategory {
|
||||
case address
|
||||
case object
|
||||
|
||||
public init(bridged: BridgedValueCategory) {
|
||||
switch bridged {
|
||||
case .Address: self = .address
|
||||
case .Object: self = .object
|
||||
default:
|
||||
fatalError("unsupported value category")
|
||||
}
|
||||
}
|
||||
|
||||
public var _bridged: BridgedValueCategory {
|
||||
switch self {
|
||||
case .address: return BridgedValueCategory.Address
|
||||
case .object: return BridgedValueCategory.Object
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum Ownership {
|
||||
/// A Value with `unowned` ownership kind is an independent value that
|
||||
/// has a lifetime that is only guaranteed to last until the next program
|
||||
|
||||
@@ -1332,7 +1332,7 @@ SWIFT_NAME("BridgedDecl.forEachDeclToHoist(self:_:)")
|
||||
void BridgedDecl_forEachDeclToHoist(BridgedDecl decl,
|
||||
BridgedSwiftClosure closure);
|
||||
|
||||
SWIFT_NAME("BridgedDecl.getDeclContext(self:)")
|
||||
SWIFT_NAME("getter:BridgedDecl.declContext(self:)")
|
||||
BridgedDeclContext BridgedDecl_getDeclContext(BridgedDecl decl);
|
||||
|
||||
enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedStaticSpelling {
|
||||
@@ -2923,8 +2923,8 @@ BridgedGenericTypeParamDecl BridgedGenericTypeParamDecl_createParsed(
|
||||
SWIFT_NAME("BridgedGenericTypeParamDecl.createImplicit(declContext:"
|
||||
"name:depth:index:paramKind:)")
|
||||
BridgedGenericTypeParamDecl BridgedGenericTypeParamDecl_createImplicit(
|
||||
BridgedDeclContext cDeclContext, swift::Identifier name, SwiftUInt depth,
|
||||
SwiftUInt index, swift::GenericTypeParamKind paramKind);
|
||||
BridgedDeclContext cDeclContext, swift::Identifier name, SwiftInt depth,
|
||||
SwiftInt index, swift::GenericTypeParamKind paramKind);
|
||||
|
||||
SWIFT_NAME(
|
||||
"BridgedTrailingWhereClause.createParsed(_:whereKeywordLoc:requirements:)")
|
||||
@@ -3042,14 +3042,14 @@ 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 BridgedConformance checkConformance(BridgedDeclObj proto) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedConformance checkConformance(BridgedDeclObj proto) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType mapTypeOutOfContext() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedCanType
|
||||
getReducedType(BridgedGenericSignature sig) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE swift::Identifier
|
||||
GenericTypeParam_getName() const;
|
||||
BRIDGED_INLINE SwiftUInt GenericTypeParam_getDepth() const;
|
||||
BRIDGED_INLINE SwiftUInt GenericTypeParam_getIndex() const;
|
||||
BRIDGED_INLINE SwiftInt GenericTypeParam_getDepth() const;
|
||||
BRIDGED_INLINE SwiftInt GenericTypeParam_getIndex() const;
|
||||
BRIDGED_INLINE swift::GenericTypeParamKind
|
||||
GenericTypeParam_getParamKind() const;
|
||||
};
|
||||
|
||||
@@ -683,11 +683,11 @@ swift::Identifier BridgedASTType::GenericTypeParam_getName() const {
|
||||
return llvm::cast<swift::GenericTypeParamType>(type)->getName();
|
||||
}
|
||||
|
||||
SwiftUInt BridgedASTType::GenericTypeParam_getDepth() const {
|
||||
SwiftInt BridgedASTType::GenericTypeParam_getDepth() const {
|
||||
return llvm::cast<swift::GenericTypeParamType>(type)->getDepth();
|
||||
}
|
||||
|
||||
SwiftUInt BridgedASTType::GenericTypeParam_getIndex() const {
|
||||
SwiftInt BridgedASTType::GenericTypeParam_getIndex() const {
|
||||
return llvm::cast<swift::GenericTypeParamType>(type)->getIndex();
|
||||
}
|
||||
|
||||
|
||||
@@ -251,8 +251,6 @@ BridgedYieldInfoArray SILFunctionType_getYields(BridgedCanType);
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedLifetimeDependenceInfoArray
|
||||
SILFunctionType_getLifetimeDependencies(BridgedCanType);
|
||||
|
||||
enum class BridgedValueCategory { Address, Object };
|
||||
|
||||
struct BridgedType {
|
||||
void * _Nullable opaqueValue;
|
||||
|
||||
@@ -266,12 +264,12 @@ 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 mapTypeOutOfContext() const;
|
||||
|
||||
static SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType createSILType(BridgedCanType canTy);
|
||||
BRIDGED_INLINE BridgedOwnedString getDebugDescription() const;
|
||||
BRIDGED_INLINE bool isNull() const;
|
||||
BRIDGED_INLINE bool isAddress() const;
|
||||
BRIDGED_INLINE BridgedValueCategory getCategory() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getAddressType() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getObjectType() const;
|
||||
BRIDGED_INLINE bool isTrivial(BridgedFunction f) const;
|
||||
@@ -312,13 +310,8 @@ struct BridgedType {
|
||||
getTupleElementLabel(SwiftInt idx) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getFunctionTypeWithNoEscape(bool withNoEscape) const;
|
||||
BRIDGED_INLINE BridgedArgumentConvention getCalleeConvention() const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType mapTypeOutOfContext() const;
|
||||
};
|
||||
|
||||
SWIFT_NAME("BridgedType.getPrimitiveType(canType:silValueCategory:)")
|
||||
BRIDGED_INLINE BridgedType BridgedType_getPrimitiveType(
|
||||
BridgedCanType canType, BridgedValueCategory silValueCategory);
|
||||
|
||||
// SIL Bridging
|
||||
|
||||
struct BridgedValue {
|
||||
@@ -983,7 +976,6 @@ struct BridgedArgument {
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedDeclObj getDecl() const;
|
||||
BRIDGED_INLINE void copyFlags(BridgedArgument fromArgument) const;
|
||||
BRIDGED_INLINE BridgedValue::Ownership getOwnership() const;
|
||||
BRIDGED_INLINE void replaceAllUsesWith(BridgedArgument arg) const;
|
||||
};
|
||||
|
||||
struct OptionalBridgedArgument {
|
||||
@@ -1368,8 +1360,6 @@ struct BridgedBuilder{
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedInstruction createDestructureStruct(BridgedValue str) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedInstruction createTuple(BridgedType type,
|
||||
BridgedValueArray elements) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedInstruction
|
||||
createTuple(BridgedValueArray elements) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedInstruction createTupleExtract(BridgedValue str,
|
||||
SwiftInt elementIndex) const;
|
||||
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedInstruction createTupleElementAddr(BridgedValue addr,
|
||||
|
||||
@@ -321,17 +321,8 @@ bool BridgedType::isAddress() const {
|
||||
return unbridged().isAddress();
|
||||
}
|
||||
|
||||
static inline BridgedValueCategory bridge(swift::SILValueCategory category) {
|
||||
switch (category) {
|
||||
case swift::SILValueCategory::Address:
|
||||
return BridgedValueCategory::Address;
|
||||
case swift::SILValueCategory::Object:
|
||||
return BridgedValueCategory::Object;
|
||||
}
|
||||
}
|
||||
|
||||
BridgedValueCategory BridgedType::getCategory() const {
|
||||
return bridge(unbridged().getCategory());
|
||||
BridgedType BridgedType::mapTypeOutOfContext() const {
|
||||
return unbridged().mapTypeOutOfContext();
|
||||
}
|
||||
|
||||
BridgedCanType BridgedType::getCanType() const {
|
||||
@@ -488,26 +479,6 @@ BridgedArgumentConvention BridgedType::getCalleeConvention() const {
|
||||
return getArgumentConvention(fnType->getCalleeConvention());
|
||||
}
|
||||
|
||||
BridgedType BridgedType::mapTypeOutOfContext() const {
|
||||
return unbridged().mapTypeOutOfContext();
|
||||
}
|
||||
|
||||
static inline swift::SILValueCategory unbridge(BridgedValueCategory category) {
|
||||
switch (category) {
|
||||
case BridgedValueCategory::Address:
|
||||
return swift::SILValueCategory::Address;
|
||||
case BridgedValueCategory::Object:
|
||||
return swift::SILValueCategory::Object;
|
||||
}
|
||||
}
|
||||
|
||||
BridgedType
|
||||
BridgedType_getPrimitiveType(BridgedCanType canType,
|
||||
BridgedValueCategory silValueCategory) {
|
||||
return swift::SILType::getPrimitiveType(canType.unbridged(),
|
||||
unbridge(silValueCategory));
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// BridgedValue
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -668,10 +639,6 @@ BridgedValue::Ownership BridgedArgument::getOwnership() const {
|
||||
return BridgedValue{SwiftObject{val}}.getOwnership();
|
||||
}
|
||||
|
||||
void BridgedArgument::replaceAllUsesWith(BridgedArgument arg) const {
|
||||
getArgument()->replaceAllUsesWith(arg.getArgument());
|
||||
}
|
||||
|
||||
swift::SILArgument * _Nullable OptionalBridgedArgument::unbridged() const {
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
@@ -2731,23 +2698,6 @@ BridgedInstruction BridgedBuilder::createTuple(BridgedType type, BridgedValueArr
|
||||
elements.getValues(elementValues))};
|
||||
}
|
||||
|
||||
BridgedInstruction
|
||||
BridgedBuilder::createTuple(BridgedValueArray elements) const {
|
||||
llvm::SmallVector<swift::SILValue, 16> elementValues;
|
||||
llvm::ArrayRef<swift::SILValue> values = elements.getValues(elementValues);
|
||||
llvm::SmallVector<swift::TupleTypeElt, 16> tupleTyElts;
|
||||
tupleTyElts.reserve(values.size());
|
||||
for (const swift::SILValue &value : values) {
|
||||
tupleTyElts.emplace_back(value->getType().getASTType());
|
||||
}
|
||||
swift::Type tupleTy =
|
||||
swift::TupleType::get(tupleTyElts, unbridged().getASTContext());
|
||||
swift::SILType silTupleTy =
|
||||
swift::SILType::getPrimitiveObjectType(tupleTy->getCanonicalType());
|
||||
|
||||
return {unbridged().createTuple(regularLoc(), silTupleTy, values)};
|
||||
}
|
||||
|
||||
BridgedInstruction BridgedBuilder::createTupleExtract(BridgedValue str, SwiftInt elementIndex) const {
|
||||
swift::SILValue v = str.getSILValue();
|
||||
return {unbridged().createTupleExtract(regularLoc(), v, elementIndex)};
|
||||
|
||||
@@ -60,8 +60,8 @@ BridgedGenericTypeParamDecl BridgedGenericTypeParamDecl_createParsed(
|
||||
}
|
||||
|
||||
BridgedGenericTypeParamDecl BridgedGenericTypeParamDecl_createImplicit(
|
||||
BridgedDeclContext cDeclContext, swift::Identifier name, SwiftUInt depth,
|
||||
SwiftUInt index, swift::GenericTypeParamKind paramKind) {
|
||||
BridgedDeclContext cDeclContext, swift::Identifier name, SwiftInt depth,
|
||||
SwiftInt index, swift::GenericTypeParamKind paramKind) {
|
||||
auto *param = GenericTypeParamDecl::createImplicit(
|
||||
cDeclContext.unbridged(), name, depth, index, paramKind);
|
||||
param->setDeclContext(cDeclContext.unbridged());
|
||||
|
||||
Reference in New Issue
Block a user