|
| 1 | +//===--- Declarations.swift -----------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors |
| 6 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +// |
| 8 | +// See https://swift.org/LICENSE.txt for license information |
| 9 | +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +import SILBridging |
| 14 | + |
| 15 | +// TODO: move all declarations to an AST module, once we have it |
| 16 | + |
| 17 | +public struct NominalTypeDecl : Equatable, Hashable { |
| 18 | + public let bridged: BridgedNominalTypeDecl |
| 19 | + |
| 20 | + public init(_bridged: BridgedNominalTypeDecl) { |
| 21 | + self.bridged = _bridged |
| 22 | + } |
| 23 | + |
| 24 | + public var name: StringRef { StringRef(bridged: bridged.getName()) } |
| 25 | + |
| 26 | + public static func ==(lhs: NominalTypeDecl, rhs: NominalTypeDecl) -> Bool { |
| 27 | + lhs.bridged.raw == rhs.bridged.raw |
| 28 | + } |
| 29 | + |
| 30 | + public func hash(into hasher: inout Hasher) { |
| 31 | + hasher.combine(bridged.raw) |
| 32 | + } |
| 33 | + |
| 34 | + public var location: Location { Location(bridged: BridgedLocation.fromNominalTypeDecl(bridged)) } |
| 35 | + |
| 36 | + public func isResilient(in function: Function) -> Bool { |
| 37 | + function.bridged.isResilientNominalDecl(bridged) |
| 38 | + } |
| 39 | + |
| 40 | + public var isStructWithUnreferenceableStorage: Bool { |
| 41 | + bridged.isStructWithUnreferenceableStorage() |
| 42 | + } |
| 43 | + |
| 44 | + public var isGlobalActor: Bool { |
| 45 | + return bridged.isGlobalActor() |
| 46 | + } |
| 47 | + |
| 48 | + public var hasValueDeinit: Bool { |
| 49 | + return bridged.hasValueDeinit() |
| 50 | + } |
| 51 | + |
| 52 | + public var isClass: Bool { bridged.isClass() } |
| 53 | + |
| 54 | + public var superClassType: Type? { |
| 55 | + precondition(isClass) |
| 56 | + return BridgedType.getSuperClassTypeOfClassDecl(bridged).typeOrNil |
| 57 | + } |
| 58 | + |
| 59 | + public var isGenericAtAnyLevel: Bool { bridged.isGenericAtAnyLevel() } |
| 60 | +} |
| 61 | + |
| 62 | +public struct DeclRef { |
| 63 | + public let bridged: BridgedDeclRef |
| 64 | + |
| 65 | + public var location: Location { Location(bridged: bridged.getLocation()) } |
| 66 | +} |
0 commit comments