3
3
4
4
from .bpf_helper_handler import helper_func_list , handle_helper_call
5
5
from .type_deducer import ctypes_to_ir
6
+ from .unary_and_binary_ops import handle_binary_op , handle_unary_op
6
7
7
8
8
9
def get_probe_string (func_node ):
@@ -21,6 +22,16 @@ def get_probe_string(func_node):
21
22
return arg .value
22
23
return "helper"
23
24
25
+ def handle_unary_assign (func , module , builder , stmt , map_sym_tab , local_sym_tab ):
26
+ """Handle unary assignment statements in the function body."""
27
+ SyntaxError ("Unary assignment not supported" )
28
+ target = stmt .target
29
+ if not isinstance (target , ast .Name ):
30
+ SyntaxError ("Unsupported assignment target" )
31
+ return
32
+ else :
33
+ handle_unary_op (func , module , builder , stmt , map_sym_tab , local_sym_tab )
34
+ return
24
35
25
36
def handle_assign (func , module , builder , stmt , map_sym_tab , local_sym_tab ):
26
37
"""Handle assignment statements in the function body."""
@@ -95,6 +106,8 @@ def handle_assign(func, module, builder, stmt, map_sym_tab, local_sym_tab):
95
106
print ("Unsupported assignment call structure" )
96
107
else :
97
108
print ("Unsupported assignment call function type" )
109
+ elif isinstance (rval , ast .BinOp ):
110
+ handle_binary_op (rval , module , builder , func , local_sym_tab , map_sym_tab )
98
111
else :
99
112
print ("Unsupported assignment value type" )
100
113
@@ -237,11 +250,13 @@ def handle_if(func, module, builder, stmt, map_sym_tab, local_sym_tab):
237
250
238
251
239
252
def process_stmt (func , module , builder , stmt , local_sym_tab , map_sym_tab , did_return , ret_type = ir .IntType (64 )):
240
- # print(f"Processing statement: {ast.dump(stmt)}")
253
+ print (f"Processing statement: { ast .dump (stmt )} " )
241
254
if isinstance (stmt , ast .Expr ):
242
255
handle_expr (func , module , builder , stmt , local_sym_tab , map_sym_tab )
243
256
elif isinstance (stmt , ast .Assign ):
244
257
handle_assign (func , module , builder , stmt , map_sym_tab , local_sym_tab )
258
+ elif isinstance (stmt , ast .AugAssign ):
259
+ handle_unary_assign (func , module , builder , stmt , map_sym_tab , local_sym_tab )
245
260
elif isinstance (stmt , ast .If ):
246
261
handle_if (func , module , builder , stmt , map_sym_tab , local_sym_tab )
247
262
elif isinstance (stmt , ast .Return ):
0 commit comments