Skip to content

Commit 91a3fe1

Browse files
committed
Remove unnecessary return artifacts from get_operand_value
1 parent c2c1774 commit 91a3fe1

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

pythonbpf/binary_ops.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,31 @@ def get_operand_value(func, operand, builder, local_sym_tab):
1818
base_type, depth = get_base_type_and_depth(var_type)
1919
logger.info(f"var is {var}, base_type is {base_type}, depth is {depth}")
2020
val = deref_to_depth(func, builder, var, depth)
21-
return val, [val], var
21+
return val
2222
raise ValueError(f"Undefined variable: {operand.id}")
2323
elif isinstance(operand, ast.Constant):
2424
if isinstance(operand.value, int):
2525
cst = ir.Constant(ir.IntType(64), int(operand.value))
26-
return cst, [cst], None
26+
return cst
2727
raise TypeError(f"Unsupported constant type: {type(operand.value)}")
2828
elif isinstance(operand, ast.BinOp):
2929
res = handle_binary_op_impl(func, operand, builder, local_sym_tab)
30-
return res, [res], None
30+
return res
3131
elif isinstance(operand, ast.Call):
3232
res = eval_expr(func, None, builder, operand, local_sym_tab, {}, {})
3333
if res is None:
3434
raise ValueError(f"Failed to evaluate call expression: {operand}")
35-
val, val_type = res
36-
return val, [val], None
35+
val, _ = res
36+
return val
3737
raise TypeError(f"Unsupported operand type: {type(operand)}")
3838

3939

4040
def handle_binary_op_impl(func, rval, builder, local_sym_tab):
4141
op = rval.op
42-
left, lchain, _ = get_operand_value(func, rval.left, builder, local_sym_tab)
43-
right, rchain, _ = get_operand_value(func, rval.right, builder, local_sym_tab)
42+
left = get_operand_value(func, rval.left, builder, local_sym_tab)
43+
right = get_operand_value(func, rval.right, builder, local_sym_tab)
4444
logger.info(f"left is {left}, right is {right}, op is {op}")
4545

46-
logger.info(f"left chain: {lchain}, right chain: {rchain}")
47-
4846
# NOTE: Before doing the operation, if the operands are integers
4947
# we always extend them to i64. The assignment to LHS will take
5048
# care of truncation if needed.

0 commit comments

Comments
 (0)