Files
swift-mirror/SwiftCompilerSources/Sources/SIL/VTable.swift
Erik Eckstein aea26bbc6e Swift SIL: add a utility protocol NoReflectionChildren for better debug output with lldb po
Let's lldb's `po` command not print any "internal" properties of the conforming type.
This is useful if the `description` already contains all the information of a type instance.
2022-10-05 07:37:41 +02:00

52 lines
1.7 KiB
Swift

//===--- VTable.swift -----------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2022 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 SILBridging
public struct VTable : CustomStringConvertible, NoReflectionChildren {
let bridged: BridgedVTable
public init(bridged: BridgedVTable) { self.bridged = bridged }
public struct Entry : CustomStringConvertible, NoReflectionChildren {
fileprivate let bridged: BridgedVTableEntry
public var function: Function { SILVTableEntry_getFunction(bridged).function }
public var description: String {
let stdString = SILVTableEntry_debugDescription(bridged)
return String(_cxxString: stdString)
}
}
public struct EntryArray : BridgedRandomAccessCollection {
fileprivate let bridgedArray: BridgedArrayRef
public var startIndex: Int { return 0 }
public var endIndex: Int { return Int(bridgedArray.numElements) }
public subscript(_ index: Int) -> Entry {
assert(index >= 0 && index < endIndex)
return Entry(bridged: BridgedVTableEntry(ptr: bridgedArray.data! + index &* BridgedVTableEntrySize))
}
}
public var entries: EntryArray {
EntryArray(bridgedArray: SILVTable_getEntries(bridged))
}
public var description: String {
let stdString = SILVTable_debugDescription(bridged)
return String(_cxxString: stdString)
}
}