summary refs log tree commit diff
path: root/ExpBuilder.py
diff options
context:
space:
mode:
authorErik Oosting2023-12-12 16:24:03 +0100
committerErik Oosting2023-12-12 16:24:03 +0100
commit258121cfb53b6b002dd0d2f68b91ce5234011620 (patch)
treeb81b6435096a4088d4f110c089206be7ff3a0633 /ExpBuilder.py
parentd9ffc2f3f679bf6e87cf12dc1ed9809badf673da (diff)
first visit method done
Diffstat (limited to 'ExpBuilder.py')
-rw-r--r--ExpBuilder.py12
1 files changed, 11 insertions, 1 deletions
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())