mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Add StatementHandlerRegistry
This commit is contained in:
22
pythonbpf/functions/func_registry_handlers.py
Normal file
22
pythonbpf/functions/func_registry_handlers.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from typing import Dict
|
||||||
|
|
||||||
|
|
||||||
|
class StatementHandlerRegistry:
|
||||||
|
"""Registry for statement handlers."""
|
||||||
|
|
||||||
|
_handlers: Dict = {}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def register(cls, stmt_type):
|
||||||
|
"""Register a handler for a specific statement type."""
|
||||||
|
|
||||||
|
def decorator(handler):
|
||||||
|
cls._handlers[stmt_type] = handler
|
||||||
|
return handler
|
||||||
|
|
||||||
|
return decorator
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_handler(cls, stmt_type):
|
||||||
|
"""Get the handler for a specific statement type."""
|
||||||
|
return cls._handlers.get(stmt_type, None)
|
||||||
Reference in New Issue
Block a user