@@ -18,7 +18,7 @@ def recursive_dereferencer(var, builder):
1818 raise TypeError (f"Unsupported type for dereferencing: { var .type } " )
1919
2020
21- def get_operand_value (operand , builder , local_sym_tab ):
21+ def get_operand_value (operand , module , builder , local_sym_tab ):
2222 """Extract the value from an operand, handling variables and constants."""
2323 if isinstance (operand , ast .Name ):
2424 if operand .id in local_sym_tab :
@@ -28,13 +28,15 @@ def get_operand_value(operand, builder, local_sym_tab):
2828 if isinstance (operand .value , int ):
2929 return ir .Constant (ir .IntType (64 ), operand .value )
3030 raise TypeError (f"Unsupported constant type: { type (operand .value )} " )
31+ elif isinstance (operand , ast .BinOp ):
32+ return handle_binary_op_impl (operand , module , builder , local_sym_tab )
3133 raise TypeError (f"Unsupported operand type: { type (operand )} " )
3234
3335
34- def handle_binary_op (rval , module , builder , var_name , local_sym_tab , map_sym_tab , func ):
36+ def handle_binary_op_impl (rval , module , builder , local_sym_tab ):
3537 op = rval .op
36- left = get_operand_value (rval .left , builder , local_sym_tab )
37- right = get_operand_value (rval .right , builder , local_sym_tab )
38+ left = get_operand_value (rval .left , module , builder , local_sym_tab )
39+ right = get_operand_value (rval .right , module , builder , local_sym_tab )
3840 logger .info (f"left is { left } , right is { right } , op is { op } " )
3941
4042 # Map AST operation nodes to LLVM IR builder methods
@@ -54,6 +56,11 @@ def handle_binary_op(rval, module, builder, var_name, local_sym_tab, map_sym_tab
5456
5557 if type (op ) in op_map :
5658 result = op_map [type (op )](left , right )
57- builder . store ( result , local_sym_tab [ var_name ]. var )
59+ return result
5860 else :
5961 raise SyntaxError ("Unsupported binary operation" )
62+
63+
64+ def handle_binary_op (rval , module , builder , var_name , local_sym_tab ):
65+ result = handle_binary_op_impl (rval , module , builder , local_sym_tab )
66+ builder .store (result , local_sym_tab [var_name ].var )
0 commit comments