mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Swift Bridging: use C++ instead of C bridging for the optimizer
This commit is contained in:
@@ -17,7 +17,7 @@ public struct CalleeAnalysis {
|
||||
let bridged: BridgedCalleeAnalysis
|
||||
|
||||
static func register() {
|
||||
CalleeAnalysis_register(
|
||||
BridgedCalleeAnalysis.registerAnalysis(
|
||||
// isDeinitBarrierFn:
|
||||
{ (inst : BridgedInstruction, bca: BridgedCalleeAnalysis) -> Bool in
|
||||
return inst.instruction.isDeinitBarrier(bca.analysis)
|
||||
@@ -33,19 +33,19 @@ public struct CalleeAnalysis {
|
||||
}
|
||||
|
||||
public func getCallees(callee: Value) -> FunctionArray? {
|
||||
let bridgedFuncs = CalleeAnalysis_getCallees(bridged, callee.bridged)
|
||||
if bridgedFuncs.incomplete != 0 {
|
||||
let bridgedFuncs = bridged.getCallees(callee.bridged)
|
||||
if bridgedFuncs.isIncomplete() {
|
||||
return nil
|
||||
}
|
||||
return FunctionArray(bridged: bridgedFuncs)
|
||||
}
|
||||
|
||||
public func getIncompleteCallees(callee: Value) -> FunctionArray {
|
||||
return FunctionArray(bridged: CalleeAnalysis_getCallees(bridged, callee.bridged))
|
||||
return FunctionArray(bridged: bridged.getCallees(callee.bridged))
|
||||
}
|
||||
|
||||
public func getDestructor(ofExactType type: Type) -> Function? {
|
||||
let destructors = FunctionArray(bridged: CalleeAnalysis_getDestructors(bridged, type.bridged, /*isExactType*/ 1))
|
||||
let destructors = FunctionArray(bridged: bridged.getDestructors(type.bridged, /*isExactType*/ true))
|
||||
if destructors.count == 1 {
|
||||
return destructors[0]
|
||||
}
|
||||
@@ -53,8 +53,8 @@ public struct CalleeAnalysis {
|
||||
}
|
||||
|
||||
public func getDestructors(of type: Type) -> FunctionArray? {
|
||||
let bridgedDtors = CalleeAnalysis_getDestructors(bridged, type.bridged, /*isExactType*/ 0)
|
||||
if bridgedDtors.incomplete != 0 {
|
||||
let bridgedDtors = bridged.getDestructors(type.bridged, /*isExactType*/ false)
|
||||
if bridgedDtors.isIncomplete() {
|
||||
return nil
|
||||
}
|
||||
return FunctionArray(bridged: bridgedDtors)
|
||||
@@ -123,13 +123,13 @@ extension Instruction {
|
||||
}
|
||||
|
||||
public struct FunctionArray : RandomAccessCollection, FormattedLikeArray {
|
||||
fileprivate let bridged: BridgedCalleeList
|
||||
fileprivate let bridged: swift.CalleeList
|
||||
|
||||
public var startIndex: Int { 0 }
|
||||
public var endIndex: Int { BridgedFunctionArray_size(bridged) }
|
||||
public var endIndex: Int { Int(bridged.getCount()) }
|
||||
|
||||
public subscript(_ index: Int) -> Function {
|
||||
return BridgedFunctionArray_get(bridged, index).function
|
||||
return BridgedCalleeAnalysis.getCallee(bridged, index).function
|
||||
}
|
||||
}
|
||||
// Bridging utilities
|
||||
|
||||
Reference in New Issue
Block a user