Skip to content

Commit b64b5b2

Browse files
remove unary assign
1 parent 6f6f101 commit b64b5b2

File tree

3 files changed

+2
-38
lines changed

3 files changed

+2
-38
lines changed

examples/execve3.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ def hello_again(ctx: c_void_p) -> c_int64:
4949
keema = 8 * 9
5050
keesa = 10 - 11
5151
keeda = 10 / 5
52-
# below does not spit IR
53-
keeda += 1
5452
return c_int64(0)
5553

5654
@bpf

pythonbpf/unary_and_binary_ops.py renamed to pythonbpf/binary_ops.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,3 @@ def handle_binary_op(rval, module, builder, func, local_sym_tab, map_sym_tab):
3333
SyntaxError("Unsupported binary operation")
3434

3535
return result
36-
37-
def handle_unary_op(rval, module, builder, func, local_sym_tab, map_sym_tab):
38-
print("UNARY ASSIGNMENT DOES NOT WORK")
39-
return
40-
# TODO: heavy fixxing needed
41-
operand = rval.gay
42-
op = rval.op
43-
if isinstance(operand, ast.Name):
44-
operand = local_sym_tab[operand.id]
45-
elif isinstance(operand, ast.Constant):
46-
operand = ir.Constant(ir.IntType(64), operand.value)
47-
else:
48-
SyntaxError("Unsupported operand type")
49-
50-
if isinstance(op, ast.UAdd):
51-
result = builder.add(ir.Constant(ir.IntType(64), 0), operand)
52-
elif isinstance(op, ast.USub):
53-
result = builder.sub(ir.Constant(ir.IntType(64), 0), operand)
54-
else:
55-
result = "all my homies hate type errors"
56-
SyntaxError("Unsupported unary operation")
57-
58-
return result

pythonbpf/functions_pass.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from .bpf_helper_handler import helper_func_list, handle_helper_call
55
from .type_deducer import ctypes_to_ir
6-
from .unary_and_binary_ops import handle_binary_op, handle_unary_op
6+
from .binary_ops import handle_binary_op
77

88

99
def get_probe_string(func_node):
@@ -22,17 +22,6 @@ def get_probe_string(func_node):
2222
return arg.value
2323
return "helper"
2424

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
35-
3625
def handle_assign(func, module, builder, stmt, map_sym_tab, local_sym_tab):
3726
"""Handle assignment statements in the function body."""
3827
if len(stmt.targets) != 1:
@@ -256,7 +245,7 @@ def process_stmt(func, module, builder, stmt, local_sym_tab, map_sym_tab, did_re
256245
elif isinstance(stmt, ast.Assign):
257246
handle_assign(func, module, builder, stmt, map_sym_tab, local_sym_tab)
258247
elif isinstance(stmt, ast.AugAssign):
259-
handle_unary_assign(func, module, builder, stmt, map_sym_tab, local_sym_tab)
248+
raise SyntaxError("Augmented assignment not supported")
260249
elif isinstance(stmt, ast.If):
261250
handle_if(func, module, builder, stmt, map_sym_tab, local_sym_tab)
262251
elif isinstance(stmt, ast.Return):

0 commit comments

Comments
 (0)