9
9
def recursive_dereferencer (var , builder ):
10
10
"""dereference until primitive type comes out"""
11
11
# TODO: Not worrying about stack overflow for now
12
+ logger .info (f"Dereferencing { var } , type is { var .type } " )
12
13
if isinstance (var .type , ir .PointerType ):
13
14
a = builder .load (var )
14
15
return recursive_dereferencer (a , builder )
@@ -18,7 +19,7 @@ def recursive_dereferencer(var, builder):
18
19
raise TypeError (f"Unsupported type for dereferencing: { var .type } " )
19
20
20
21
21
- def get_operand_value (operand , module , builder , local_sym_tab ):
22
+ def get_operand_value (operand , builder , local_sym_tab ):
22
23
"""Extract the value from an operand, handling variables and constants."""
23
24
if isinstance (operand , ast .Name ):
24
25
if operand .id in local_sym_tab :
@@ -29,14 +30,14 @@ def get_operand_value(operand, module, builder, local_sym_tab):
29
30
return ir .Constant (ir .IntType (64 ), operand .value )
30
31
raise TypeError (f"Unsupported constant type: { type (operand .value )} " )
31
32
elif isinstance (operand , ast .BinOp ):
32
- return handle_binary_op_impl (operand , module , builder , local_sym_tab )
33
+ return handle_binary_op_impl (operand , builder , local_sym_tab )
33
34
raise TypeError (f"Unsupported operand type: { type (operand )} " )
34
35
35
36
36
- def handle_binary_op_impl (rval , module , builder , local_sym_tab ):
37
+ def handle_binary_op_impl (rval , builder , local_sym_tab ):
37
38
op = rval .op
38
- left = get_operand_value (rval .left , module , builder , local_sym_tab )
39
- right = get_operand_value (rval .right , module , builder , local_sym_tab )
39
+ left = get_operand_value (rval .left , builder , local_sym_tab )
40
+ right = get_operand_value (rval .right , builder , local_sym_tab )
40
41
logger .info (f"left is { left } , right is { right } , op is { op } " )
41
42
42
43
# Map AST operation nodes to LLVM IR builder methods
@@ -61,8 +62,8 @@ def handle_binary_op_impl(rval, module, builder, local_sym_tab):
61
62
raise SyntaxError ("Unsupported binary operation" )
62
63
63
64
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 )
65
+ def handle_binary_op (rval , builder , var_name , local_sym_tab ):
66
+ result = handle_binary_op_impl (rval , builder , local_sym_tab )
66
67
if var_name in local_sym_tab :
67
68
builder .store (result , local_sym_tab [var_name ].var )
68
69
return result , result .type
0 commit comments