From 5e6e3aeeb6ef8856b9deebd5e178be15999a7f2e Mon Sep 17 00:00:00 2001 From: Vitja Makarov Date: Mon, 13 Dec 2010 20:28:55 +0300 Subject: [PATCH] Rename temps_allocator to closure_temps and move it to funcstate --- Cython/Compiler/Code.py | 6 +++++- Cython/Compiler/ExprNodes.py | 4 ++-- Cython/Compiler/Nodes.py | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Cython/Compiler/Code.py b/Cython/Compiler/Code.py index ec11fd97..4048074d 100644 --- a/Cython/Compiler/Code.py +++ b/Cython/Compiler/Code.py @@ -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 = {} diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 78af3e15..2fde811b 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index ca893e57..a22d6100 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -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) -- 2.26.2