Rename temps_allocator to closure_temps and move it to funcstate
authorVitja Makarov <vitja.makarov@gmail.com>
Mon, 13 Dec 2010 17:28:55 +0000 (20:28 +0300)
committerVitja Makarov <vitja.makarov@gmail.com>
Mon, 13 Dec 2010 17:28:55 +0000 (20:28 +0300)
Cython/Compiler/Code.py
Cython/Compiler/ExprNodes.py
Cython/Compiler/Nodes.py

index ec11fd978e58db310b65cb4aef737431f0ff1e0b..4048074d7ff59b9a0e208ba8bc9aa2c7831645a6 100644 (file)
@@ -117,6 +117,7 @@ class FunctionState(object):
         self.temps_free = {} # (type, manage_ref) -> list of free vars with same type/managed status
         self.temps_used_type = {} # name -> (type, manage_ref)
         self.temp_counter = 0
+        self.closure_temps = None
 
     # labels
 
@@ -270,6 +271,9 @@ class FunctionState(object):
                 if manage_ref
                 for cname in freelist]
 
+    def init_closure_temps(self, scope):
+        self.closure_temps = ClosureTempAllocator(scope)
+
 
 class IntConst(object):
     """Global info about a Python integer constant held by GlobalState.
@@ -1397,7 +1401,7 @@ class PyrexCodeWriter(object):
 
 
 class ClosureTempAllocator(object):
-    def __init__(self, klass=None):
+    def __init__(self, klass):
         self.klass = klass
         self.temps_allocated = {}
         self.temps_free = {}
index 78af3e15d24714ffff9216945d77807fcf346726..2fde811bd588fa4d783b28be6f562474586f4de5 100755 (executable)
@@ -5006,10 +5006,10 @@ class YieldExprNode(ExprNode):
         else:
             code.put_init_to_py_none(Naming.retval_cname, py_object_type)
         saved = []
-        code.temp_allocator.reset()
+        code.funcstate.closure_temps.reset()
         code.putln('/* Save temporary variables */')
         for cname, type, manage_ref in code.funcstate.temps_in_use():
-            save_cname = code.temp_allocator.allocate_temp(type)
+            save_cname = code.funcstate.closure_temps.allocate_temp(type)
             saved.append((cname, save_cname, type))
             if type.is_pyobject:
                 code.put_xgiveref(cname)
index ca893e57ec7f93dce18a376a6702e9fead783dce..a22d610061662146211753fe025700458dfaed90 100644 (file)
@@ -1361,7 +1361,7 @@ class FuncDefNode(StatNode, BlockNode):
         if not self.is_generator:
             self.generate_preamble(env, code)
         if self.is_generator:
-            code.temp_allocator = ClosureTempAllocator(lenv.scope_class.type.scope)
+            code.funcstate.init_closure_temps(lenv.scope_class.type.scope)
             resume_code = code.insertion_point()
             first_run_label = code.new_label('first_run')
             code.use_label(first_run_label)