swift SIL: add some SIL type related bridging

* `Function.argumentTypes` and `Function.resultType`
* `Type.isNominal`, `Type.isClass`, `Type.isTuple`, `Type.isStruct` and `Type.isEnum`
* `Type.getFieldIndexOfNominal`
* `Type.getFieldTypeOfNominal`
* `Type.tupleElements`
* `Type.description` for better debugging

# Conflicts:
#	SwiftCompilerSources/Sources/SIL/Type.swift
#	SwiftCompilerSources/Sources/SIL/Utils.swift
#	SwiftCompilerSources/Sources/SIL/Value.swift
#	include/swift/SIL/SILBridging.h
#	lib/SIL/Utils/SILBridging.cpp
This commit is contained in:
Erik Eckstein
2022-01-13 18:56:36 +01:00
committed by Max Desiatov
parent b964dba177
commit cec4b82b39
6 changed files with 191 additions and 12 deletions

View File

@@ -219,3 +219,12 @@ extension Optional where Wrapped == UnsafeMutablePointer<BridgedSwiftObject> {
return nil
}
}
extension BridgedArrayRef {
func withElements<T, R>(ofType ty: T.Type, _ c: (UnsafeBufferPointer<T>) -> R) -> R {
return data.withMemoryRebound(to: ty, capacity: numElements) { (ptr: UnsafePointer<T>) -> R in
let buffer = UnsafeBufferPointer(start: ptr, count: numElements)
return c(buffer)
}
}
}