diff options
author | Erik Oosting | 2023-12-12 16:24:03 +0100 |
---|---|---|
committer | Erik Oosting | 2023-12-12 16:24:03 +0100 |
commit | 258121cfb53b6b002dd0d2f68b91ce5234011620 (patch) | |
tree | b81b6435096a4088d4f110c089206be7ff3a0633 /ExpBuilder.py | |
parent | d9ffc2f3f679bf6e87cf12dc1ed9809badf673da (diff) |
first visit method done
Diffstat (limited to 'ExpBuilder.py')
-rw-r--r-- | ExpBuilder.py | 12 |
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()) |