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:
@@ -11,6 +11,7 @@ add_swift_compiler_module(AST
|
||||
Basic
|
||||
SOURCES
|
||||
Declarations.swift
|
||||
DeclContext.swift
|
||||
Conformance.swift
|
||||
DiagnosticEngine.swift
|
||||
GenericSignature.swift
|
||||
|
||||
28
SwiftCompilerSources/Sources/AST/DeclContext.swift
Normal file
28
SwiftCompilerSources/Sources/AST/DeclContext.swift
Normal file
@@ -0,0 +1,28 @@
|
||||
//===--- DeclContext.swift -----------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See https://swift.org/LICENSE.txt for license information
|
||||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import ASTBridging
|
||||
|
||||
public protocol DeclContext : AnyObject {
|
||||
var bridgedDeclContext: BridgedDeclContext { get }
|
||||
}
|
||||
|
||||
extension DeclContext {
|
||||
public var astContext: ASTContext { bridgedDeclContext.astContext }
|
||||
}
|
||||
|
||||
// Used for DeclContext classes which are not Decls and are not bridged, yet. E.g. `FileUnit`.
|
||||
// TODO: once we have bridged those DeclContext classes, get rid of UnknownDeclContext
|
||||
public class UnknownDeclContext : DeclContext {
|
||||
public var bridgedDeclContext: BridgedDeclContext
|
||||
public init(bridged: BridgedDeclContext) { bridgedDeclContext = bridged }
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors
|
||||
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See https://swift.org/LICENSE.txt for license information
|
||||
@@ -16,37 +16,65 @@ import ASTBridging
|
||||
/// The base class for all declarations in Swift.
|
||||
@_semantics("arc.immortal")
|
||||
public class Decl: CustomStringConvertible, Hashable {
|
||||
public var bridged: BridgedDeclObj { BridgedDeclObj(SwiftObject(self)) }
|
||||
final public var bridged: BridgedDeclObj { BridgedDeclObj(SwiftObject(self)) }
|
||||
|
||||
public var description: String { String(taking: bridged.getDebugDescription()) }
|
||||
final public var description: String { String(taking: bridged.getDebugDescription()) }
|
||||
|
||||
/// The module in which this declaration resides.
|
||||
public var parentModule: ModuleDecl { bridged.getModuleContext().getAs(ModuleDecl.self) }
|
||||
final public var parentModule: ModuleDecl { bridged.getModuleContext().getAs(ModuleDecl.self) }
|
||||
|
||||
/// The parent DeclContext if it is a Decl.
|
||||
public var parent: Decl? { bridged.getParent().decl }
|
||||
/// The parent DeclContext.
|
||||
final public var parentDeclContext: DeclContext? {
|
||||
if let decl = bridged.getParent().decl {
|
||||
return decl as! DeclContext
|
||||
}
|
||||
if let bridgedDeclContext = BridgedDeclContext(bridged: bridged.getDeclContext()) {
|
||||
// A DeclContext which is not a Decl.
|
||||
// TODO: once we have bridged those DeclContext classes, get rid of UnknownDeclContext
|
||||
return UnknownDeclContext(bridged: bridgedDeclContext)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// True if this declaration is imported from C/C++/ObjC.
|
||||
public var hasClangNode: Bool { bridged.hasClangNode() }
|
||||
final public var hasClangNode: Bool { bridged.hasClangNode() }
|
||||
|
||||
final public var bridgedDecl: BridgedDecl { BridgedDecl(raw: bridged.obj) }
|
||||
|
||||
public static func ==(lhs: Decl, rhs: Decl) -> Bool { lhs === rhs }
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
final public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(ObjectIdentifier(self))
|
||||
}
|
||||
|
||||
final public func setImplicit() { bridged.setImplicit() }
|
||||
}
|
||||
|
||||
public protocol GenericContext: Decl, DeclContext {}
|
||||
|
||||
extension GenericContext {
|
||||
public func setGenericSignature(_ genericSignature: GenericSignature) {
|
||||
bridged.GenericContext_setGenericSignature(genericSignature.bridged)
|
||||
}
|
||||
|
||||
public var bridgedDeclContext: BridgedDeclContext { bridged.asGenericContext() }
|
||||
}
|
||||
|
||||
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: Identifier { bridged.Value_getBaseIdentifier() }
|
||||
final public var isObjC: Bool { bridged.Value_isObjC() }
|
||||
final public func setAccess(_ accessLevel : AccessLevel) {
|
||||
bridged.ValueDecl_setAccess(accessLevel)
|
||||
}
|
||||
}
|
||||
|
||||
public class TypeDecl: ValueDecl {
|
||||
final public var name: StringRef { StringRef(bridged: bridged.Type_getName()) }
|
||||
}
|
||||
|
||||
public class GenericTypeDecl: TypeDecl {
|
||||
public class GenericTypeDecl: TypeDecl, GenericContext {
|
||||
final public var isGenericAtAnyLevel: Bool { bridged.GenericType_isGenericAtAnyLevel() }
|
||||
}
|
||||
|
||||
@@ -56,10 +84,38 @@ public class NominalTypeDecl: GenericTypeDecl {
|
||||
final public var valueTypeDestructor: DestructorDecl? {
|
||||
bridged.NominalType_getValueTypeDestructor().getAs(DestructorDecl.self)
|
||||
}
|
||||
|
||||
public var declaredInterfaceType: Type {
|
||||
Type(bridged: bridged.NominalType_getDeclaredInterfaceType())
|
||||
}
|
||||
|
||||
public func add(member: Decl) {
|
||||
bridged.NominalTypeDecl_addMember(member.bridged)
|
||||
}
|
||||
}
|
||||
|
||||
final public class EnumDecl: NominalTypeDecl {
|
||||
public var hasRawType: Bool { bridged.Enum_hasRawType() }
|
||||
|
||||
public static func create(
|
||||
declContext: DeclContext, enumKeywordLoc: SourceLoc?, name: String,
|
||||
nameLoc: SourceLoc?, genericParamList: GenericParameterList?, inheritedTypes: [Type],
|
||||
genericWhereClause: TrailingWhereClause?, braceRange: SourceRange, _ astContext: ASTContext
|
||||
) -> EnumDecl {
|
||||
name.withCString { strPtr in
|
||||
inheritedTypes.withBridgedArrayRef { types in
|
||||
ASTBridging.BridgedEnumDecl.createParsed(
|
||||
astContext, declContext: declContext.bridgedDeclContext,
|
||||
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)
|
||||
}
|
||||
}.asDecl.declObj.getAs(EnumDecl.self)
|
||||
}
|
||||
}
|
||||
|
||||
final public class StructDecl: NominalTypeDecl {
|
||||
@@ -84,11 +140,25 @@ final public class OpaqueTypeDecl: GenericTypeDecl {}
|
||||
|
||||
final public class TypeAliasDecl: GenericTypeDecl {}
|
||||
|
||||
final public class GenericTypeParamDecl: TypeDecl {}
|
||||
final public class GenericTypeParamDecl: TypeDecl {
|
||||
public static func create(
|
||||
declContext: DeclContext,
|
||||
name: Identifier,
|
||||
depth: Int,
|
||||
index: Int,
|
||||
paramKind: GenericTypeParameterKind) -> GenericTypeParamDecl {
|
||||
ASTBridging.BridgedGenericTypeParamDecl.createImplicit(
|
||||
declContext: declContext.bridgedDeclContext,
|
||||
name: name, depth: depth, index: index,
|
||||
paramKind: paramKind).asDecl.declObj.getAs(GenericTypeParamDecl.self)
|
||||
}
|
||||
}
|
||||
|
||||
final public class AssociatedTypeDecl: TypeDecl {}
|
||||
|
||||
final public class ModuleDecl: TypeDecl {}
|
||||
final public class ModuleDecl: TypeDecl, DeclContext {
|
||||
public var bridgedDeclContext: BridgedDeclContext { bridged.asModuleDecl() }
|
||||
}
|
||||
|
||||
public class AbstractStorageDecl: ValueDecl {
|
||||
final public var isConst: Bool { bridged.AbstractStorage_isConst() }
|
||||
@@ -96,11 +166,19 @@ public class AbstractStorageDecl: ValueDecl {
|
||||
|
||||
public class VarDecl: AbstractStorageDecl {}
|
||||
|
||||
final public class ParamDecl: VarDecl {}
|
||||
final public class ParamDecl: VarDecl {
|
||||
public func cloneWithoutType() -> ParamDecl {
|
||||
BridgedParamDecl(raw: bridged.obj).cloneWithoutType().asDecl.declObj.getAs(ParamDecl.self)
|
||||
}
|
||||
|
||||
final public class SubscriptDecl: AbstractStorageDecl {}
|
||||
public func setInterfaceType(type: Type) {
|
||||
BridgedParamDecl(raw: bridged.obj).setInterfaceType(type.bridged)
|
||||
}
|
||||
}
|
||||
|
||||
public class AbstractFunctionDecl: ValueDecl {
|
||||
final public class SubscriptDecl: AbstractStorageDecl, GenericContext {}
|
||||
|
||||
public class AbstractFunctionDecl: ValueDecl, GenericContext {
|
||||
public var isOverridden: Bool { bridged.AbstractFunction_isOverridden() }
|
||||
}
|
||||
|
||||
@@ -118,11 +196,29 @@ final public class MacroDecl: ValueDecl {}
|
||||
|
||||
final public class EnumElementDecl: ValueDecl {
|
||||
public var hasAssociatedValues: Bool { bridged.EnumElementDecl_hasAssociatedValues() }
|
||||
public var parameterList: ParameterList { ParameterList(bridged: bridged.EnumElementDecl_getParameterList()) }
|
||||
public var name: StringRef { StringRef(bridged: bridged.EnumElementDecl_getNameStr()) }
|
||||
|
||||
public static func create(
|
||||
declContext: DeclContext,
|
||||
name: Identifier, nameLoc: SourceLoc?,
|
||||
parameterList: ParameterList?,
|
||||
equalsLoc: SourceLoc?, rawValue: Expr?, _ astContext: ASTContext
|
||||
) -> EnumElementDecl {
|
||||
BridgedEnumElementDecl.createParsed(
|
||||
astContext, declContext: declContext.bridgedDeclContext,
|
||||
name: name, nameLoc: nameLoc.bridgedLocation,
|
||||
parameterList: parameterList.bridged.bridged,
|
||||
equalsLoc: equalsLoc.bridgedLocation,
|
||||
rawValue: rawValue.bridged).asDecl.declObj.getAs(EnumElementDecl.self)
|
||||
}
|
||||
}
|
||||
|
||||
final public class ExtensionDecl: Decl {}
|
||||
final public class ExtensionDecl: Decl, GenericContext {}
|
||||
|
||||
final public class TopLevelCodeDecl: Decl {}
|
||||
final public class TopLevelCodeDecl: Decl, DeclContext {
|
||||
public var bridgedDeclContext: BridgedDeclContext { bridged.asTopLevelCodeDecl() }
|
||||
}
|
||||
|
||||
final public class ImportDecl: Decl {}
|
||||
|
||||
@@ -165,3 +261,124 @@ extension Optional where Wrapped == Decl {
|
||||
OptionalBridgedDeclObj(self?.bridged.obj)
|
||||
}
|
||||
}
|
||||
|
||||
public typealias AccessLevel = swift.AccessLevel
|
||||
|
||||
public typealias Identifier = swift.Identifier
|
||||
|
||||
public typealias GenericTypeParamKind = swift.GenericTypeParamKind
|
||||
|
||||
public typealias ASTContext = BridgedASTContext
|
||||
|
||||
public typealias Expr = BridgedExpr
|
||||
|
||||
public typealias SourceFile = BridgedSourceFile
|
||||
|
||||
public typealias FileUnit = BridgedFileUnit
|
||||
|
||||
public class GenericParameterList {
|
||||
public var bridged: BridgedGenericParamList
|
||||
public init(bridged: BridgedGenericParamList) { self.bridged = bridged }
|
||||
}
|
||||
|
||||
public typealias TrailingWhereClause = BridgedTrailingWhereClause
|
||||
|
||||
public class ParameterList : RandomAccessCollection {
|
||||
public var startIndex: Int { 0 }
|
||||
public var endIndex: Int { bridged.size }
|
||||
|
||||
public var bridged: BridgedParameterList
|
||||
|
||||
public init(bridged: BridgedParameterList) {
|
||||
self.bridged = bridged
|
||||
}
|
||||
|
||||
public subscript(_ index: Int) -> ParamDecl {
|
||||
return bridged.get(index).asDecl.declObj.getAs(ParamDecl.self)
|
||||
}
|
||||
|
||||
public static func create(
|
||||
leftParenLoc: SourceLoc?, parameters: [ParamDecl],
|
||||
rightParenLoc: SourceLoc?, _ astContext: ASTContext
|
||||
) -> ParameterList {
|
||||
ParameterList(bridged: parameters.map{BridgedParamDecl(raw: $0.bridged.obj)}.withBridgedArrayRef {
|
||||
BridgedParameterList.createParsed(
|
||||
astContext, leftParenLoc: leftParenLoc.bridgedLocation, parameters: $0,
|
||||
rightParenLoc: rightParenLoc.bridgedLocation)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
extension GenericParameterList {
|
||||
public static func create(
|
||||
leftAngleLoc: SourceLoc?, parameters: [GenericTypeParamDecl],
|
||||
genericWhereClause: TrailingWhereClause?,
|
||||
rightAngleLoc: SourceLoc?, _ astContext: ASTContext
|
||||
) -> GenericParameterList {
|
||||
let paramsNew = parameters.map{ ASTBridging.BridgedGenericTypeParamDecl(raw: $0.bridged.obj) }
|
||||
return paramsNew.withBridgedArrayRef {
|
||||
GenericParameterList(bridged: BridgedGenericParamList.createParsed(
|
||||
astContext, leftAngleLoc: leftAngleLoc.bridgedLocation, parameters: $0,
|
||||
genericWhereClause: genericWhereClause.bridged, rightAngleLoc: rightAngleLoc.bridgedLocation
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension BridgedDecl {
|
||||
public var declObj: BridgedDeclObj {
|
||||
BridgedDeclObj(self)
|
||||
}
|
||||
}
|
||||
|
||||
extension BridgedDeclContext {
|
||||
public init?(bridged: BridgedNullableDeclContext) {
|
||||
guard let raw = bridged.raw else {
|
||||
return nil
|
||||
}
|
||||
self.init(raw: raw)
|
||||
}
|
||||
}
|
||||
|
||||
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 ParameterList? {
|
||||
public var bridged: BridgedParameterList? {
|
||||
return self?.bridged
|
||||
}
|
||||
}
|
||||
|
||||
extension BridgedParameterList? {
|
||||
public var bridged: BridgedNullableParameterList {
|
||||
BridgedNullableParameterList(raw: self?.raw)
|
||||
}
|
||||
}
|
||||
|
||||
extension GenericParameterList? {
|
||||
public var bridged: BridgedNullableGenericParamList {
|
||||
BridgedNullableGenericParamList(raw: self?.bridged.raw)
|
||||
}
|
||||
}
|
||||
|
||||
extension Expr? {
|
||||
public var bridged: BridgedNullableExpr {
|
||||
BridgedNullableExpr(raw: self?.raw)
|
||||
}
|
||||
}
|
||||
|
||||
extension TrailingWhereClause? {
|
||||
public var bridged: BridgedNullableTrailingWhereClause {
|
||||
BridgedNullableTrailingWhereClause(raw: self?.raw)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,4 +35,22 @@ public struct GenericSignature: CustomStringConvertible, NoReflectionChildren {
|
||||
}
|
||||
|
||||
public var isEmpty: Bool { bridged.impl == nil }
|
||||
|
||||
public var canonicalSignature: CanonicalGenericSignature {
|
||||
CanonicalGenericSignature(bridged: bridged.getCanonicalSignature())
|
||||
}
|
||||
}
|
||||
|
||||
public struct CanonicalGenericSignature {
|
||||
public let bridged: BridgedCanGenericSignature
|
||||
|
||||
public init(bridged: BridgedCanGenericSignature) {
|
||||
self.bridged = bridged
|
||||
}
|
||||
|
||||
public var isEmpty: Bool { bridged.impl == nil }
|
||||
|
||||
public var genericSignature: GenericSignature {
|
||||
GenericSignature(bridged: bridged.getGenericSignature())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,32 @@ public struct Type: TypeProperties, CustomStringConvertible, NoReflectionChildre
|
||||
public func subst(with substitutionMap: SubstitutionMap) -> Type {
|
||||
return Type(bridged: bridged.subst(substitutionMap.bridged))
|
||||
}
|
||||
|
||||
public func mapOutOfEnvironment() -> Type {
|
||||
return Type(bridged: bridged.mapOutOfEnvironment())
|
||||
}
|
||||
|
||||
/// 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 var nameOfGenericTypeParameter: Identifier {
|
||||
bridged.GenericTypeParam_getName()
|
||||
}
|
||||
|
||||
public var depthOfGenericTypeParameter: Int {
|
||||
bridged.GenericTypeParam_getDepth()
|
||||
}
|
||||
|
||||
public var indexOfGenericTypeParameter: Int {
|
||||
bridged.GenericTypeParam_getIndex()
|
||||
}
|
||||
|
||||
public var kindOfGenericTypeParameter: GenericTypeParameterKind {
|
||||
bridged.GenericTypeParam_getParamKind()
|
||||
}
|
||||
}
|
||||
|
||||
/// A Type that is statically known to be canonical.
|
||||
@@ -266,6 +292,12 @@ extension TypeProperties {
|
||||
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 var containsSILPackExpansionType: Bool {
|
||||
return rawType.bridged.containsSILPackExpansionType()
|
||||
}
|
||||
@@ -330,3 +362,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
|
||||
|
||||
@@ -347,7 +347,7 @@ private extension Function {
|
||||
if decl is DestructorDecl || decl is ConstructorDecl {
|
||||
return 4
|
||||
}
|
||||
if let parent = decl.parent, parent is ClassDecl {
|
||||
if let parent = decl.parentDeclContext, parent is ClassDecl {
|
||||
return 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,13 @@ extension TypeProperties {
|
||||
public func loweredType(in function: Function, maximallyAbstracted: Bool = false) -> Type {
|
||||
function.bridged.getLoweredType(rawType.bridged, maximallyAbstracted).type.objectType
|
||||
}
|
||||
|
||||
// Lowers the AST type to a SIL type - in a specific function.
|
||||
// In contrast to `loweredType`, this takes `AbstractionPattern` constructed from `function`'s
|
||||
// `SubstGenericSignature` into account when getting the lowered type.
|
||||
public func loweredTypeWithAbstractionPattern(in function: Function) -> Type {
|
||||
function.bridged.getLoweredTypeWithAbstractionPattern(rawType.canonical.bridged).type
|
||||
}
|
||||
}
|
||||
|
||||
extension CanonicalType {
|
||||
|
||||
@@ -68,6 +68,13 @@ 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 {
|
||||
context.notifyInstructionsChanged()
|
||||
return bridged.insertPhiArgument(atPosition, type.bridged, ownership._bridged).argument
|
||||
}
|
||||
|
||||
public func eraseArgument(at index: Int, _ context: some MutatingContext) {
|
||||
context.notifyInstructionsChanged()
|
||||
bridged.eraseArgument(index)
|
||||
|
||||
@@ -49,12 +49,22 @@ extension Context {
|
||||
public func getBuiltinIntegerType(bitWidth: Int) -> Type { _bridged.getBuiltinIntegerType(bitWidth).type }
|
||||
|
||||
public func getTupleType(elements: [Type]) -> AST.`Type` {
|
||||
return getTupleType(elements: elements.map{ $0.rawType })
|
||||
}
|
||||
|
||||
public func getTupleType(elements: [AST.`Type`]) -> AST.`Type` {
|
||||
let bridgedElements = elements.map { $0.bridged }
|
||||
return bridgedElements.withBridgedArrayRef {
|
||||
AST.`Type`(bridged: _bridged.getTupleType($0))
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
_bridged.getSwiftArrayDecl().getAs(NominalTypeDecl.self)
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ public struct DeclRef: CustomStringConvertible, NoReflectionChildren {
|
||||
public func calleesAreStaticallyKnowable(_ context: some Context) -> Bool {
|
||||
context._bridged.calleesAreStaticallyKnowable(bridged)
|
||||
}
|
||||
|
||||
public var sourceFile: SourceFile? { SourceFile(bridged: bridged.getSourceFile()) }
|
||||
}
|
||||
|
||||
extension DeclRef: DiagnosticArgument {
|
||||
|
||||
@@ -26,6 +26,10 @@ final public class Function : CustomStringConvertible, HasShortDescription, Hash
|
||||
return Location(bridged: bridged.getLocation())
|
||||
}
|
||||
|
||||
public var declRef: DeclRef { DeclRef(bridged: bridged.getDeclRef()) }
|
||||
|
||||
public var sourceFile: SourceFile? { declRef.sourceFile }
|
||||
|
||||
final public var description: String {
|
||||
return String(taking: bridged.getDebugDescription())
|
||||
}
|
||||
@@ -90,6 +94,10 @@ final public class Function : CustomStringConvertible, HasShortDescription, Hash
|
||||
return AST.`Type`(bridged: bridged.mapTypeIntoEnvironment(type.bridged))
|
||||
}
|
||||
|
||||
public func mapTypeIntoEnvironment(_ type: Type) -> Type {
|
||||
return Type(bridged: bridged.mapTypeIntoEnvironment(type.bridged))
|
||||
}
|
||||
|
||||
/// Returns true if the function is a definition and not only an external declaration.
|
||||
///
|
||||
/// This is the case if the function contains a body, i.e. some basic blocks.
|
||||
|
||||
@@ -1992,12 +1992,18 @@ 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? {
|
||||
cases.first(where: { $0.0 == forCaseIndex })?.1
|
||||
}
|
||||
|
||||
public func getSuccessorForDefault() -> BasicBlock? {
|
||||
return self.bridged.SwitchEnumInst_getSuccessorForDefault().block
|
||||
}
|
||||
|
||||
// This does not handle the special case where the default covers exactly
|
||||
// the "missing" case.
|
||||
public func getUniqueCase(forSuccessor: BasicBlock) -> Int? {
|
||||
|
||||
@@ -232,6 +232,10 @@ public struct Type : TypeProperties, CustomStringConvertible, NoReflectionChildr
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
public func mapOutOfEnvironment(in function: Function) -> Type {
|
||||
rawType.mapOutOfEnvironment().canonical.loweredType(in: function)
|
||||
}
|
||||
}
|
||||
|
||||
extension Type: Equatable {
|
||||
@@ -284,6 +288,7 @@ public struct NominalFieldsArray : RandomAccessCollection, FormattedLikeArray {
|
||||
}
|
||||
|
||||
public struct EnumCase {
|
||||
public let enumElementDecl : EnumElementDecl
|
||||
public let payload: Type?
|
||||
public let index: Int
|
||||
}
|
||||
@@ -306,7 +311,24 @@ public struct EnumCases : CollectionLikeSequence, IteratorProtocol {
|
||||
caseIterator = caseIterator.getNext()
|
||||
caseIndex += 1
|
||||
}
|
||||
return EnumCase(payload: enumType.bridged.getEnumCasePayload(caseIterator, function.bridged).typeOrNil,
|
||||
return EnumCase(enumElementDecl: enumType.bridged.getEnumElementDecl(caseIterator).getAs(EnumElementDecl.self),
|
||||
payload: enumType.bridged.getEnumCasePayload(caseIterator, function.bridged).typeOrNil,
|
||||
index: caseIndex)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Note: this has O(n) complexity where n is number of enum cases
|
||||
public subscript(_ index: Int) -> EnumCase? {
|
||||
var iterator = enumType.bridged.getFirstEnumCaseIterator()
|
||||
var currentIndex = 0
|
||||
while currentIndex != index && !enumType.bridged.isEndCaseIterator(iterator) {
|
||||
iterator = iterator.getNext()
|
||||
currentIndex += 1
|
||||
}
|
||||
if currentIndex == index && !enumType.bridged.isEndCaseIterator(iterator) {
|
||||
return EnumCase(enumElementDecl: enumType.bridged.getEnumElementDecl(iterator).getAs(EnumElementDecl.self),
|
||||
payload: enumType.bridged.getEnumCasePayload(iterator, function.bridged).typeOrNil,
|
||||
index: caseIndex)
|
||||
}
|
||||
return nil
|
||||
@@ -322,6 +344,10 @@ public struct TupleElementArray : RandomAccessCollection, FormattedLikeArray {
|
||||
public subscript(_ index: Int) -> Type {
|
||||
type.bridged.getTupleElementType(index).type
|
||||
}
|
||||
|
||||
public func label(at index: Int) -> Identifier {
|
||||
type.bridged.getTupleElementLabel(index)
|
||||
}
|
||||
}
|
||||
|
||||
public struct BoxFieldsArray : RandomAccessCollection, FormattedLikeArray {
|
||||
|
||||
@@ -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()};
|
||||
}
|
||||
|
||||
@@ -95,6 +95,16 @@ BridgedDeclNameLoc BridgedDeclNameLoc_createParsed(BridgedASTContext cContext,
|
||||
#define ABSTRACT_DECL(Id, Parent) DECL(Id, Parent)
|
||||
#include "swift/AST/DeclNodes.def"
|
||||
|
||||
// Define `.asNominalTypeDecl` on each BridgedXXXDecl type that's also a
|
||||
// NominalTypeDecl.
|
||||
#define DECL(Id, Parent)
|
||||
#define NOMINAL_TYPE_DECL(Id, Parent) \
|
||||
BridgedNominalTypeDecl Bridged##Id##Decl_asNominalTypeDecl( \
|
||||
Bridged##Id##Decl decl) { \
|
||||
return static_cast<NominalTypeDecl *>(decl.unbridged()); \
|
||||
}
|
||||
#include "swift/AST/DeclNodes.def"
|
||||
|
||||
// Define `.asDeclContext` on each BridgedXXXDecl type that's also a
|
||||
// DeclContext.
|
||||
#define DECL(Id, Parent)
|
||||
@@ -339,7 +349,7 @@ convertToInheritedEntries(ASTContext &ctx, BridgedArrayRef cInheritedTypes) {
|
||||
[](auto &e) { return InheritedEntry(e.unbridged()); });
|
||||
}
|
||||
|
||||
BridgedNominalTypeDecl BridgedEnumDecl_createParsed(
|
||||
BridgedEnumDecl BridgedEnumDecl_createParsed(
|
||||
BridgedASTContext cContext, BridgedDeclContext cDeclContext,
|
||||
SourceLoc enumKeywordLoc, swift::Identifier name, SourceLoc nameLoc,
|
||||
BridgedNullableGenericParamList genericParamList,
|
||||
@@ -348,7 +358,7 @@ BridgedNominalTypeDecl BridgedEnumDecl_createParsed(
|
||||
SourceRange braceRange) {
|
||||
ASTContext &context = cContext.unbridged();
|
||||
|
||||
NominalTypeDecl *decl = new (context)
|
||||
auto *decl = new (context)
|
||||
EnumDecl(enumKeywordLoc, name, nameLoc,
|
||||
convertToInheritedEntries(context, cInheritedTypes),
|
||||
genericParamList.unbridged(), cDeclContext.unbridged());
|
||||
|
||||
@@ -59,6 +59,15 @@ BridgedGenericTypeParamDecl BridgedGenericTypeParamDecl_createParsed(
|
||||
return decl;
|
||||
}
|
||||
|
||||
BridgedGenericTypeParamDecl BridgedGenericTypeParamDecl_createImplicit(
|
||||
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());
|
||||
return param;
|
||||
}
|
||||
|
||||
BridgedTrailingWhereClause
|
||||
BridgedTrailingWhereClause_createParsed(BridgedASTContext cContext,
|
||||
SourceLoc whereKeywordLoc,
|
||||
|
||||
@@ -1067,7 +1067,7 @@ void IterableDeclContext::addMember(Decl *member, Decl *hint, bool insertAtHead)
|
||||
case IterableDeclContextKind::NominalTypeDecl: {
|
||||
auto nominal = cast<NominalTypeDecl>(this);
|
||||
nominal->addedMember(member);
|
||||
assert(member->getDeclContext() == nominal &&
|
||||
assert(member->getDeclContext() == static_cast<DeclContext *>(nominal) &&
|
||||
"Added member to the wrong context");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ extension ASTGenVisitor {
|
||||
return decl
|
||||
}
|
||||
|
||||
func generate(enumDecl node: EnumDeclSyntax) -> BridgedNominalTypeDecl? {
|
||||
func generate(enumDecl node: EnumDeclSyntax) -> BridgedEnumDecl? {
|
||||
let attrs = self.generateDeclAttributes(node, allowStatic: false)
|
||||
guard let (name, nameLoc) = self.generateIdentifierDeclNameAndLoc(node.name) else {
|
||||
return nil
|
||||
@@ -135,7 +135,7 @@ extension ASTGenVisitor {
|
||||
self.generate(memberBlockItemList: node.memberBlock.members)
|
||||
}
|
||||
let fp = self.generateFingerprint(declGroup: node)
|
||||
decl.setParsedMembers(
|
||||
decl.asNominalTypeDecl.setParsedMembers(
|
||||
members.lazy.bridgedArray(in: self),
|
||||
fingerprint: fp.bridged
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user