From 258121cfb53b6b002dd0d2f68b91ce5234011620 Mon Sep 17 00:00:00 2001 From: Erik Oosting Date: Tue, 12 Dec 2023 16:24:03 +0100 Subject: first visit method done --- ExpBuilder.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'ExpBuilder.py') diff --git a/ExpBuilder.py b/ExpBuilder.py index 761140e..1c9699a 100644 --- a/ExpBuilder.py +++ b/ExpBuilder.py @@ -1,9 +1,19 @@ +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.module = Module(name="Program") + 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()) -- cgit 1.4.1-2-gfad0