From 4cf284a81ff5a1e0eb8a6e43246152d711f2eead Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Fri, 26 Sep 2025 00:24:10 +0530 Subject: [PATCH] provide type as weel in eval_expr --- pythonbpf/expr_pass.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pythonbpf/expr_pass.py b/pythonbpf/expr_pass.py index cc969a5..479d153 100644 --- a/pythonbpf/expr_pass.py +++ b/pythonbpf/expr_pass.py @@ -8,15 +8,15 @@ def eval_expr(func, module, builder, expr, local_sym_tab, map_sym_tab, structs_s if expr.id in local_sym_tab: var = local_sym_tab[expr.id][0] val = builder.load(var) - return val + return val, local_sym_tab[expr.id][1] # return value and type else: print(f"Undefined variable {expr.id}") return None elif isinstance(expr, ast.Constant): if isinstance(expr.value, int): - return ir.Constant(ir.IntType(64), expr.value) + return ir.Constant(ir.IntType(64), expr.value), ir.IntType(64) elif isinstance(expr.value, bool): - return ir.Constant(ir.IntType(1), int(expr.value)) + return ir.Constant(ir.IntType(1), int(expr.value)), ir.IntType(1) else: print("Unsupported constant type") return None @@ -44,8 +44,9 @@ def eval_expr(func, module, builder, expr, local_sym_tab, map_sym_tab, structs_s if arg is None: print("Failed to evaluate deref argument") return None + # Since we are handling only name case, directly take type from sym tab val = builder.load(arg) - return val + return val, local_sym_tab[expr.args[0].id][1] # check for helpers if expr.func.id in helper_func_list: