Swift SIL: make Function.name and GlobalVariable.name return a StringRef and not a String

and introduce the StringRef struct.
It's more efficient.

Also, rename the `HasName` protocol to `HasShortDescription`, which introduces the new requirement `shortDescription`. This is need because `name` now has `StringRef` type and not `String` anymore
This commit is contained in:
Erik Eckstein
2022-05-12 10:00:25 +02:00
parent e8194155f0
commit cd456fa792
6 changed files with 43 additions and 13 deletions

View File

@@ -13,11 +13,11 @@
import Basic
import SILBridging
final public class Function : CustomStringConvertible, HasName {
final public class Function : CustomStringConvertible, HasShortDescription {
public private(set) var effects = FunctionEffects()
public var name: String {
return SILFunction_getName(bridged).string
public var name: StringRef {
return StringRef(bridged: SILFunction_getName(bridged))
}
final public var description: String {
@@ -25,6 +25,8 @@ final public class Function : CustomStringConvertible, HasName {
return String(cString: s.c_str())
}
public var shortDescription: String { name.string }
public var entryBlock: BasicBlock {
SILFunction_firstBlock(bridged).block!
}