mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
provide type as weel in eval_expr
This commit is contained in:
@ -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:
|
||||
|
||||
Reference in New Issue
Block a user