diff python/c3/codegenerator.py @ 232:e621e3ba78d2

Added left shift instruction
author Windel Bouwman
date Sun, 14 Jul 2013 11:50:58 +0200
parents 521567d17388
children d3dccf12ca88
line wrap: on
line diff
--- a/python/c3/codegenerator.py	Sat Jul 13 20:20:44 2013 +0200
+++ b/python/c3/codegenerator.py	Sun Jul 14 11:50:58 2013 +0200
@@ -4,7 +4,8 @@
 from ppci import CompilerError
 from .typecheck import theType
 
-tmpnames = {'+':'add', '-':'sub', '*': 'mul', '/':'div', '|':'or', '&':'and'}
+tmpnames = {'+':'add', '-':'sub', '*': 'mul', '/':'div', '|':'or', \
+    '&':'and', '>>':'shl', '<<':'shr'}
 
 class CodeGenerator:
     """ Generates intermediate code from a package """
@@ -141,7 +142,7 @@
         if type(expr) is astnodes.Binop:
              ra = self.genExprCode(expr.a)
              rb = self.genExprCode(expr.b)
-             ops = ['+', '-', '*', '/', '|', '&']
+             ops = ['+', '-', '*', '/', '|', '&', '<<', '>>']
              if expr.op in ops:
                 tmp = self.builder.newTmp(tmpnames[expr.op])
                 op = expr.op