Skip to content

Commit 1253f51

Browse files
committed
Use deref_to_val instead of recursive_dereferencer in get_operand value
1 parent 23afb0b commit 1253f51

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pythonbpf/binary_ops.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,18 @@ def get_operand_value(operand, builder, local_sym_tab):
4141
"""Extract the value from an operand, handling variables and constants."""
4242
if isinstance(operand, ast.Name):
4343
if operand.id in local_sym_tab:
44-
return recursive_dereferencer(local_sym_tab[operand.id].var, builder)
44+
var = local_sym_tab[operand.id].var
45+
val, chain = deref_to_val(var, builder)
46+
return val, chain, var
4547
raise ValueError(f"Undefined variable: {operand.id}")
4648
elif isinstance(operand, ast.Constant):
4749
if isinstance(operand.value, int):
48-
return ir.Constant(ir.IntType(64), operand.value)
50+
cst = ir.Constant(ir.IntType(64), operand.value)
51+
return cst, [cst], None
4952
raise TypeError(f"Unsupported constant type: {type(operand.value)}")
5053
elif isinstance(operand, ast.BinOp):
51-
return handle_binary_op_impl(operand, builder, local_sym_tab)
54+
res = handle_binary_op_impl(operand, builder, local_sym_tab)
55+
return res, [res], None
5256
raise TypeError(f"Unsupported operand type: {type(operand)}")
5357

5458

0 commit comments

Comments
 (0)