Add deref(), add delete helper, refactor pre-alloc

This commit is contained in:
Pragyansh Chaturvedi
2025-09-12 04:24:40 +05:30
parent 0950d0550c
commit a09e4e1bb6
5 changed files with 156 additions and 25 deletions

View File

@ -1,11 +1,15 @@
import ast
from llvmlite import ir
def handle_binary_op(rval, module, builder, func, local_sym_tab, map_sym_tab):
print(module)
left = rval.left
right = rval.right
op = rval.op
# In case of pointers, we'll deref once.
if isinstance(left, ast.Name):
left = local_sym_tab[left.id]
elif isinstance(left, ast.Constant):
@ -20,6 +24,8 @@ def handle_binary_op(rval, module, builder, func, local_sym_tab, map_sym_tab):
else:
SyntaxError("Unsupported right operand type")
print(f"left is {left}, right is {right}, op is {op}")
if isinstance(op, ast.Add):
result = builder.add(left, right)
elif isinstance(op, ast.Sub):