mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Add handle_variable_assignment stub and boilerplate in handle_assign
This commit is contained in:
4
pythonbpf/assign_pass.py
Normal file
4
pythonbpf/assign_pass.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
def handle_variable_assignment(
|
||||||
|
func, module, builder, var_name, rval, local_sym_tab, map_sym_tab, structs_sym_tab
|
||||||
|
):
|
||||||
|
pass
|
||||||
@ -8,6 +8,7 @@ from pythonbpf.helper import HelperHandlerRegistry, handle_helper_call
|
|||||||
from pythonbpf.type_deducer import ctypes_to_ir
|
from pythonbpf.type_deducer import ctypes_to_ir
|
||||||
from pythonbpf.binary_ops import handle_binary_op
|
from pythonbpf.binary_ops import handle_binary_op
|
||||||
from pythonbpf.expr import eval_expr, handle_expr, convert_to_bool
|
from pythonbpf.expr import eval_expr, handle_expr, convert_to_bool
|
||||||
|
from pythonbpf.assign_pass import handle_variable_assignment
|
||||||
|
|
||||||
from .return_utils import _handle_none_return, _handle_xdp_return, _is_xdp_name
|
from .return_utils import _handle_none_return, _handle_xdp_return, _is_xdp_name
|
||||||
|
|
||||||
@ -55,9 +56,28 @@ def handle_assign(
|
|||||||
logger.error("Multi-target assignment is not supported for now")
|
logger.error("Multi-target assignment is not supported for now")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
target = stmt.targets[0]
|
||||||
|
rval = stmt.value
|
||||||
|
|
||||||
|
if isinstance(target, ast.Name):
|
||||||
|
# NOTE: Simple variable assignment case: x = 5
|
||||||
|
var_name = target.id
|
||||||
|
result = handle_variable_assignment(
|
||||||
|
func,
|
||||||
|
module,
|
||||||
|
builder,
|
||||||
|
var_name,
|
||||||
|
rval,
|
||||||
|
local_sym_tab,
|
||||||
|
map_sym_tab,
|
||||||
|
structs_sym_tab,
|
||||||
|
)
|
||||||
|
if not result:
|
||||||
|
logger.error(f"Failed to handle assignment to {var_name}")
|
||||||
|
return
|
||||||
|
|
||||||
num_types = ("c_int32", "c_int64", "c_uint32", "c_uint64")
|
num_types = ("c_int32", "c_int64", "c_uint32", "c_uint64")
|
||||||
|
|
||||||
target = stmt.targets[0]
|
|
||||||
logger.info(f"Handling assignment to {ast.dump(target)}")
|
logger.info(f"Handling assignment to {ast.dump(target)}")
|
||||||
if not isinstance(target, ast.Name) and not isinstance(target, ast.Attribute):
|
if not isinstance(target, ast.Name) and not isinstance(target, ast.Attribute):
|
||||||
logger.info("Unsupported assignment target")
|
logger.info("Unsupported assignment target")
|
||||||
|
|||||||
Reference in New Issue
Block a user