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
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.
class ClosureTempAllocator(object):
- def __init__(self, klass=None):
+ def __init__(self, klass):
self.klass = klass
self.temps_allocated = {}
self.temps_free = {}
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)
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)