Mercurial > lcfOS
diff 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 diff
--- a/python/c3/codegenerator.py Sat Mar 02 10:19:38 2013 +0100 +++ b/python/c3/codegenerator.py Sun Mar 03 13:20:03 2013 +0100 @@ -1,8 +1,23 @@ +import ir +from . import astnodes -#from ppci import ircode +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): - pass + print('Code generator') + assert type(ast) is astnodes.Package + return genModule(ast)