mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 09:58:34 +00:00
Core: Give every symbol kind a common Symbol base class
LocalSymbol, BpfGlobalSymbol and MapSymbol each named the storage behind a name differently (var, var, sym) and shared no type. They now all derive from symbols.Symbol, which carries what every symbol has -- the storage pointer (alloca, GlobalVariable, or None for the context parameter) and its IR type -- and each subclass adds only what its kind needs: LocalSymbol its metadata and declared_global flag, BpfGlobalSymbol its ctypes name, MapSymbol its map type and params. MapSymbol.sym becomes var to match. local_symbol.py is folded into the new symbols.py. LocalSymbol keeps its three-field __iter__ for the call sites that tuple-unpack a symbol. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BSDVsZH5NtoASyxB8FCtGU
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
from llvmlite import ir
|
||||
import ast
|
||||
|
||||
from dataclasses import dataclass
|
||||
from logging import Logger
|
||||
import logging
|
||||
from .type_deducer import ctypes_to_ir
|
||||
from .symbols import BpfGlobalSymbol
|
||||
from .debuginfo import DebugInfoGenerator
|
||||
from .expr import VmlinuxHandlerRegistry
|
||||
from .debuginfo import dwarf_constants as dc
|
||||
@ -26,20 +26,6 @@ _SIGNED_CTYPES = {
|
||||
_C_NAME_BY_WIDTH = {8: "char", 16: "short", 32: "int", 64: "long long"}
|
||||
|
||||
|
||||
@dataclass
|
||||
class BpfGlobalSymbol:
|
||||
"""A mutable BPF global variable declared with @bpfglobal.
|
||||
|
||||
Lands in .bss (zero initializer) or .data (non-zero) and is read with a
|
||||
plain load / written with a plain store; libbpf exposes the sections to
|
||||
userspace as global-data maps.
|
||||
"""
|
||||
|
||||
var: ir.GlobalVariable
|
||||
ir_type: ir.Type
|
||||
ctype_name: str
|
||||
|
||||
|
||||
def populate_global_symbol_table(tree, compilation_context):
|
||||
"""
|
||||
compilation_context: CompilationContext
|
||||
|
||||
Reference in New Issue
Block a user