summary refs log tree commit diff
path: root/ExpBuilder.py
blob: 1c9699a1207a0d78621e219fb6975d8aef82cfe9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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.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())