mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
48 lines
1.4 KiB
Swift
48 lines
1.4 KiB
Swift
//===--- GlobalVariable.swift - Defines the GlobalVariable class ----------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2021 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 Basic
|
|
import SILBridging
|
|
|
|
final public class GlobalVariable : CustomStringConvertible, HasShortDescription, Hashable {
|
|
public var name: StringRef {
|
|
return StringRef(bridged: bridged.getName())
|
|
}
|
|
|
|
public var description: String {
|
|
let stdString = bridged.getDebugDescription()
|
|
return String(_cxxString: stdString)
|
|
}
|
|
|
|
public var shortDescription: String { name.string }
|
|
|
|
public var isLet: Bool { bridged.isLet() }
|
|
|
|
// TODO: initializer instructions
|
|
|
|
public static func ==(lhs: GlobalVariable, rhs: GlobalVariable) -> Bool {
|
|
lhs === rhs
|
|
}
|
|
|
|
public func hash(into hasher: inout Hasher) {
|
|
hasher.combine(ObjectIdentifier(self))
|
|
}
|
|
|
|
var bridged: BridgedGlobalVar { BridgedGlobalVar(obj: SwiftObject(self)) }
|
|
}
|
|
|
|
// Bridging utilities
|
|
|
|
extension BridgedGlobalVar {
|
|
var globalVar: GlobalVariable { obj.getAs(GlobalVariable.self) }
|
|
}
|