Mercurial > lcfOS
view python/c3/codegenerator.py @ 155:b28a11c01dbe
Simplified IR classes
author | Windel Bouwman |
---|---|
date | Sun, 03 Mar 2013 13:20:03 +0100 |
parents | afc8c0207984 |
children | 1b4a85bdd99c |
line wrap: on
line source
import ir from . import astnodes def genModule(pkg): m = ir.Module(pkg.name) for s in pkg.scope: print(s) if type(s) is astnodes.Variable: genGlobal(m, s) return m def genGlobal(m, var): v = ir.Value() v.name = var.name m.Globals.append(v) class CodeGenerator: """ Generates intermediate code """ def gencode(self, ast): print('Code generator') assert type(ast) is astnodes.Package return genModule(ast)