[SIL] Add support for delete notification handlers.

This commit adds the basic support for delete notification handlers. The SIL
Module is notified every time an instruction is deleted. The module will forward
notification messages to users who ask to be notified.  The motivation for this
work is described in the upcoming commit to OptimizerDesign.md.
This commit is contained in:
Nadav Rotem
2015-12-04 07:10:49 -08:00
parent 5ba9a3785b
commit 37991af1cf
4 changed files with 78 additions and 0 deletions

View File

@@ -664,3 +664,20 @@ lookUpFunctionInVTable(ClassDecl *Class, SILDeclRef Member) {
return nullptr;
}
void SILModule::
registerDeleteNotificationHandler(DeleteNotificationHandler* Handler) {
NotificationHandlers.insert(Handler);
}
void SILModule::
removeDeleteNotificationHandler(DeleteNotificationHandler* Handler) {
NotificationHandlers.remove(Handler);
}
void SILModule::notifyDeleteHandlers(SILInstruction *Item) {
for (auto *Handler : NotificationHandlers) {
Handler->handleDeleteNotification(Item);
}
}