Mercurial > lcfOS
view python/codegen.py @ 281:4496cae24d7f
Improved logview
author | Windel Bouwman |
---|---|
date | Sat, 02 Nov 2013 11:11:40 +0100 |
parents | 02385f62f250 |
children | 7b38782ed496 |
line wrap: on
line source
import ir, target from ppci import CompilerError class CodeGenerator: """ Target independent code generator """ def __init__(self, tg): assert isinstance(tg, target.Target) self.tg = tg def tryMap(self, ii): for mi in self.tg.instructions: if mi.irpattern is ii: return mi.FromIr(ii) raise CompilerError('Cannot map {0}'.format(ii)) def generate(self, ircode): assert isinstance(ircode, ir.Module) obj = object() for gvar in ircode.Variables: print(gvar) raise Exception() # TODO for f in ircode.Functions: for bb in f.Blocks: for ins in bb.Instructions: # Instruction selection: #mi = self.tryMap(ins) pass return obj