diff python/c3/codegenerator.py @ 275:6f2423df0675

Fixed serve arm-as
author Windel Bouwman
date Sat, 14 Sep 2013 17:29:10 +0200
parents ea93e0a7a31e
children 2ccd57b1d78c
line wrap: on
line diff
--- a/python/c3/codegenerator.py	Wed Sep 04 17:35:06 2013 +0200
+++ b/python/c3/codegenerator.py	Sat Sep 14 17:29:10 2013 +0200
@@ -35,7 +35,6 @@
             f = self.newFunction(s.name)
             self.funcMap[s] = f
         for v in pkg.innerScope.Variables:
-            #print(v)
             self.varMap[v] = self.newTemp()
         for s in pkg.innerScope.Functions:
             self.genFunction(s)
@@ -54,15 +53,14 @@
         for sym in fn.innerScope:
             # TODO: handle parameters different
             if sym.isParameter:
-                print('param', sym)
                 v = ir.Parameter(sym.name)
                 f.addParameter(v)
             elif sym.isLocal:
-                print('local', sym)
-                v = self.newTemp()
+                v = ir.LocalVariable(sym.name)
+                f.addLocal(v)
             else:
-                v = self.newTemp()
-                #raise NotImplementedError('{}'.format(sym))
+                #v = self.newTemp()
+                raise NotImplementedError('{}'.format(sym))
             # TODO: make this ssa here??
             self.varMap[sym] = v
 
@@ -84,7 +82,7 @@
             lval = self.genExprCode(code.lval)
             self.emit(ir.Move(lval, rval))
         elif type(code) is astnodes.ExpressionStatement:
-            self.genExprCode(code.ex)
+            self.emit(ir.Exp(self.genExprCode(code.ex)))
         elif type(code) is astnodes.IfStatement:
             bbtrue = self.newBlock()
             bbfalse = self.newBlock()