from antlr4 import TerminalNode from gen import ANFVisitor from gen.ANFParser import ANFParser from llvmlite.ir import * class ExpBuilder(ANFVisitor): module = Module("Program") def __init__(self): self.currentFunc: Function | None = None def visitDef(self, ctx: ANFParser.DefContext): args = [i.getText() for i in ctx.IDENT()][1:] i_type = IntType(64) self.currentFunc = Function(self.module, FunctionType(i_type, [i_type] * len(args)), name=ctx.IDENT(0)) self.visit(ctx.cexp())