Skip to content

Commit 6cf5115

Browse files
committed
Eval LHS and RHS in _handle_compare
1 parent f11a430 commit 6cf5115

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

pythonbpf/expr_pass.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,37 @@ def _handle_ctypes_call(
133133

134134

135135
def _handle_compare(
136-
func, module, builder, expr, local_sym_tab, map_sym_tab, structs_sym_tab=None
136+
func, module, builder, cond, local_sym_tab, map_sym_tab, structs_sym_tab=None
137137
):
138-
pass
138+
if len(cond.ops) != 1 or len(cond.comparators) != 1:
139+
logger.error("Only single comparisons are supported")
140+
return None
141+
lhs = eval_expr(
142+
func,
143+
module,
144+
builder,
145+
cond.left,
146+
local_sym_tab,
147+
map_sym_tab,
148+
structs_sym_tab,
149+
)
150+
rhs = eval_expr(
151+
func,
152+
module,
153+
builder,
154+
cond.comparators[0],
155+
local_sym_tab,
156+
map_sym_tab,
157+
structs_sym_tab,
158+
)
159+
160+
if lhs is None or rhs is None:
161+
logger.error("Failed to evaluate comparison operands")
162+
return None
163+
164+
lhs, _ = lhs
165+
rhs, _ = rhs
166+
return None
139167

140168

141169
def eval_expr(

0 commit comments

Comments
 (0)