mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-03-26 23:21:27 +00:00
Add remaining docstrings to complete documentation coverage
Co-authored-by: varun-r-mallya <100590632+varun-r-mallya@users.noreply.github.com>
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
"""Registry for statement handler functions."""
|
||||
|
||||
from typing import Dict
|
||||
|
||||
|
||||
@ -11,6 +13,7 @@ class StatementHandlerRegistry:
|
||||
"""Register a handler for a specific statement type."""
|
||||
|
||||
def decorator(handler):
|
||||
"""Decorator that registers the handler."""
|
||||
cls._handlers[stmt_type] = handler
|
||||
return handler
|
||||
|
||||
|
||||
@ -25,11 +25,20 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
@dataclass
|
||||
class LocalSymbol:
|
||||
"""
|
||||
Represents a local variable in a BPF function.
|
||||
|
||||
Attributes:
|
||||
var: LLVM IR alloca instruction for the variable
|
||||
ir_type: LLVM IR type of the variable
|
||||
metadata: Optional metadata (e.g., struct type name)
|
||||
"""
|
||||
var: ir.AllocaInstr
|
||||
ir_type: ir.Type
|
||||
metadata: Any = None
|
||||
|
||||
def __iter__(self):
|
||||
"""Support tuple unpacking of LocalSymbol."""
|
||||
yield self.var
|
||||
yield self.ir_type
|
||||
yield self.metadata
|
||||
@ -692,6 +701,7 @@ def infer_return_type(func_node: ast.FunctionDef):
|
||||
found_type = None
|
||||
|
||||
def _expr_type(e):
|
||||
"""Helper function to extract type from an expression."""
|
||||
if e is None:
|
||||
return "None"
|
||||
if isinstance(e, ast.Constant):
|
||||
|
||||
Reference in New Issue
Block a user