comparison python/ppci/c3/codegenerator.py @ 303:be7f60545368

Final fixups
author Windel Bouwman
date Fri, 06 Dec 2013 12:37:48 +0100
parents 6753763d3bec
children 0615b5308710
comparison
equal deleted inserted replaced
302:2ef2247f8dda 303:be7f60545368
95 if code.falsestatement: 95 if code.falsestatement:
96 self.genCode(code.falsestatement) 96 self.genCode(code.falsestatement)
97 self.emit(ir.Jump(te)) 97 self.emit(ir.Jump(te))
98 self.setBlock(te) 98 self.setBlock(te)
99 elif type(code) is astnodes.ReturnStatement: 99 elif type(code) is astnodes.ReturnStatement:
100 if code.expr: 100 assert code.expr
101 re = self.genExprCode(code.expr) 101 re = self.genExprCode(code.expr)
102 self.emit(ir.Move(self.fn.return_value, re)) 102 self.emit(ir.Move(self.fn.return_value, re))
103 self.emit(ir.Jump(self.fn.epiloog)) 103 self.emit(ir.Jump(self.fn.epiloog))
104 b = self.newBlock() 104 b = self.newBlock()
105 self.setBlock(b) 105 self.setBlock(b)
106 else:
107 self.builder.addIns(ir.Return())
108 elif type(code) is astnodes.WhileStatement: 106 elif type(code) is astnodes.WhileStatement:
109 bbdo = self.newBlock() 107 bbdo = self.newBlock()
110 bbtest = self.newBlock() 108 bbtest = self.newBlock()
111 te = self.newBlock() 109 te = self.newBlock()
112 self.emit(ir.Jump(bbtest)) 110 self.emit(ir.Jump(bbtest))