SIL: add an API to replace all entries of a VTable

* add `ModulePassContext.replaceVTableEntries()`
* add `ModulePassContext.notifyFunctionTablesChanged()`
This commit is contained in:
Erik Eckstein
2024-10-14 11:11:36 +02:00
parent a9d59034b3
commit e0533e6125
8 changed files with 61 additions and 4 deletions

View File

@@ -168,6 +168,14 @@ struct ModulePassContext : Context, CustomStringConvertible {
return VTable(bridged: bridgedVTable)
}
func replaceVTableEntries(of vTable: VTable, with entries: [VTable.Entry]) {
let bridgedEntries = entries.map { $0.bridged }
bridgedEntries.withBridgedArrayRef {
vTable.bridged.replaceEntries($0)
}
notifyFunctionTablesChanged()
}
func createEmptyFunction(
name: String,
parameters: [ParameterInfo],
@@ -201,6 +209,10 @@ struct ModulePassContext : Context, CustomStringConvertible {
}
}
}
func notifyFunctionTablesChanged() {
_bridged.asNotificationHandler().notifyChanges(.functionTablesChanged)
}
}
extension GlobalVariable {