Mercurial > lcfOS
diff python/c3/codegenerator.py @ 177:460db5669efa
Added clean pass for IR
author | Windel Bouwman |
---|---|
date | Mon, 22 Apr 2013 23:54:54 +0200 |
parents | 5fd02aa38b42 |
children | 46d62dadd61b |
line wrap: on
line diff
--- a/python/c3/codegenerator.py Sat Apr 20 12:00:51 2013 +0200 +++ b/python/c3/codegenerator.py Mon Apr 22 23:54:54 2013 +0200 @@ -124,15 +124,17 @@ if type(expr) is astnodes.Binop: ra = self.genExprCode(expr.a) rb = self.genExprCode(expr.b) - tmp = self.builder.newTmp() - ops = ['+', '-', '*', '/', 'and', 'or'] + ops = ['+', '-', '*', '/'] if expr.op in ops: + tmpnames = {'+':'addtmp', '-':'subtmp', '*': 'multmp', '/':'divtmp'} + tmp = self.builder.newTmp(tmpnames[expr.op]) op = expr.op ins = ir.BinaryOperator(tmp, op, ra, rb) self.builder.addIns(ins) return tmp else: print('Unknown {0}'.format(expr)) + tmp = self.builder.newTmp() # TODO return tmp elif type(expr) is astnodes.Constant: