Mercurial > lcfOS
annotate 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 |
rev | line source |
---|---|
155 | 1 import ir |
2 from . import astnodes | |
151 | 3 |
155 | 4 def genModule(pkg): |
5 m = ir.Module(pkg.name) | |
6 for s in pkg.scope: | |
7 print(s) | |
8 if type(s) is astnodes.Variable: | |
9 genGlobal(m, s) | |
10 return m | |
11 | |
12 def genGlobal(m, var): | |
13 v = ir.Value() | |
14 v.name = var.name | |
15 m.Globals.append(v) | |
151 | 16 |
17 class CodeGenerator: | |
18 """ Generates intermediate code """ | |
19 def gencode(self, ast): | |
155 | 20 print('Code generator') |
21 assert type(ast) is astnodes.Package | |
22 return genModule(ast) | |
151 | 23 |