mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 01:48:35 +00:00
The first version synthesised an Assign(BinOp(...)) node and fed it back through handle_assign. That is a standard compiler move, but it is not how this compiler works: every pass walks the tree the user wrote, and a node invented mid-codegen is invisible to the allocation pass that already ran, carries no source location for diagnostics, and shows up in logs as a statement nobody typed. handle_aug_assign now resolves the target slot (declared global, local, or struct field), loads it, evaluates the right-hand side, applies the operator, and stores back. Semantic agreement with "x = x op v" no longer rests on shared AST but on shared value-level helpers: the RHS goes through get_operand_value like any other read, and the operator table is extracted from binary-op evaluation into apply_binop so it exists exactly once. Two behavioural refinements fall out: augmented assignment to a global name without a global statement is now the same loud SyntaxError plain assignment gives (previously it slipped past the allocation pass, which only walks Assign), and struct-field targets compute their GEP once rather than twice. Target read precedes RHS evaluation, matching Python. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L1PX8EuP9C3o3veWGA84RF
19 lines
562 B
Python
19 lines
562 B
Python
from .expr_pass import eval_expr, handle_expr, get_operand_value
|
|
from .type_normalization import convert_to_bool, get_base_type_and_depth
|
|
from .ir_ops import deref_to_depth, access_struct_field, apply_binop
|
|
from .call_registry import CallHandlerRegistry
|
|
from .vmlinux_registry import VmlinuxHandlerRegistry
|
|
|
|
__all__ = [
|
|
"eval_expr",
|
|
"handle_expr",
|
|
"convert_to_bool",
|
|
"get_base_type_and_depth",
|
|
"deref_to_depth",
|
|
"apply_binop",
|
|
"access_struct_field",
|
|
"get_operand_value",
|
|
"CallHandlerRegistry",
|
|
"VmlinuxHandlerRegistry",
|
|
]
|