comparison 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
comparison
equal deleted inserted replaced
154:81e08e2e7777 155:b28a11c01dbe
1 import ir
2 from . import astnodes
1 3
2 #from ppci import ircode 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)
3 16
4 class CodeGenerator: 17 class CodeGenerator:
5 """ Generates intermediate code """ 18 """ Generates intermediate code """
6 def gencode(self, ast): 19 def gencode(self, ast):
7 pass 20 print('Code generator')
21 assert type(ast) is astnodes.Package
22 return genModule(ast)
8 23