diff python/c3/codegenerator.py @ 269:5f8c04a8d26b

Towards better modularity
author Windel Bouwman
date Sun, 18 Aug 2013 17:43:18 +0200
parents 5ec7580976d9
children e64bae57cda8
line wrap: on
line diff
--- a/python/c3/codegenerator.py	Wed Aug 14 20:12:40 2013 +0200
+++ b/python/c3/codegenerator.py	Sun Aug 18 17:43:18 2013 +0200
@@ -40,7 +40,11 @@
     def genFunction(self, fn):
         # TODO: handle arguments
         f = self.funcMap[fn]
+        # TODO reserve room for stack, this can be done at later point?
         self.setFunction(f)
+        l2 = self.newBlock()
+        self.emit(ir.Jump(l2))
+        self.setBlock(l2)
         # generate room for locals:
 
         for sym in fn.innerScope:
@@ -51,7 +55,8 @@
 
         self.genCode(fn.body)
         # TODO handle return?
-        self.emit(ir.Return(ir.Const(0)))
+        self.emit(ir.Jump(f.epiloog))
+        #self.emit(ir.Return(ir.Const(0)))
         self.setFunction(None)
 
     def genCode(self, code):