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: