mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Improve block/instruction lists and similar collections * pretty print collections in the form “[a, b, c]” * also do this for lazy sequences * define a custom Mirror * in a collection, only print the name of blocks, functions and globals (instead of the full object) * replace `BasicBlock.reverseInstructions` with `BasicBlock.instructions.reversed()` - in an efficient way
36 lines
1.2 KiB
Swift
36 lines
1.2 KiB
Swift
//===--- CalleeAnalysis.swift - the callee analysis -----------------------===//
|
|
//
|
|
// 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 OptimizerBridging
|
|
import SIL
|
|
|
|
public struct CalleeAnalysis {
|
|
let bridged: BridgedCalleeAnalysis
|
|
|
|
public func getCallees(callee: Value) -> FunctionArray {
|
|
return FunctionArray(bridged: CalleeAnalysis_getCallees(bridged, callee.bridged))
|
|
}
|
|
}
|
|
|
|
public struct FunctionArray : RandomAccessCollection, FormattedLikeArray {
|
|
fileprivate let bridged: BridgedCalleeList
|
|
|
|
public var startIndex: Int { 0 }
|
|
public var endIndex: Int { BridgedFunctionArray_size(bridged) }
|
|
|
|
public subscript(_ index: Int) -> Function {
|
|
return BridgedFunctionArray_get(bridged, index).function
|
|
}
|
|
|
|
public var allCalleesKnown: Bool { bridged.incomplete == 0 }
|
|
}
|