File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,24 @@ def recursive_dereferencer(var, builder):
1919 raise TypeError (f"Unsupported type for dereferencing: { var .type } " )
2020
2121
22+ def deref_to_val (var , builder ):
23+ """Dereference a variable to get its value and pointer chain."""
24+ logger .info (f"Dereferencing { var } , type is { var .type } " )
25+
26+ chain = [var ]
27+ cur = var
28+
29+ while isinstance (cur .type , ir .PointerType ):
30+ cur = builder .load (cur )
31+ chain .append (cur )
32+
33+ if isinstance (cur .type , ir .IntType ):
34+ logger .info (f"dereference chain: { chain } " )
35+ return cur , chain
36+ else :
37+ raise TypeError (f"Unsupported type for dereferencing: { cur .type } " )
38+
39+
2240def get_operand_value (operand , builder , local_sym_tab ):
2341 """Extract the value from an operand, handling variables and constants."""
2442 if isinstance (operand , ast .Name ):
You can’t perform that action at this time.
0 commit comments