From: Robert Bradshaw Date: Thu, 19 Jun 2008 20:34:49 +0000 (-0700) Subject: Mark closure visitor X-Git-Tag: 0.9.8.1~49^2~118 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=be671f42562d946073a04555c8c5e5479142ce74;p=cython.git Mark closure visitor --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index faf16dc9..f363f17d 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -1883,9 +1883,10 @@ class OverrideCheckNode(StatNode): # code.put_decref(self.func_temp, PyrexTypes.py_object_type) code.putln("}") +class ClassDefNode(StatNode, BlockNode): + pass - -class PyClassDefNode(StatNode, BlockNode): +class PyClassDefNode(ClassDefNode): # A Python class definition. # # name EncodedString Name of the class @@ -1957,7 +1958,7 @@ class PyClassDefNode(StatNode, BlockNode): self.dict.generate_disposal_code(code) -class CClassDefNode(StatNode, BlockNode): +class CClassDefNode(ClassDefNode): # An extension type definition. # # visibility 'private' or 'public' or 'extern' diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py index ef4d9b83..d11dd5e7 100644 --- a/Cython/Compiler/ParseTreeTransforms.py +++ b/Cython/Compiler/ParseTreeTransforms.py @@ -185,3 +185,26 @@ class AnalyseExpressionsTransform(VisitorTransform): self.visitchildren(node) return node +class MarkClosureNode(VisitorTransform): + + needs_closure = False + + def visit_FuncDefNode(self, node): + self.needs_closure = False + self.visitchildren(node) + node.needs_closure = self.needs_closure + self.needs_closure = True + return node + + def visit_ClassDefNode(self, node): + self.visitchildren(node) + self.needs_closure = True + return node + + def visit_YieldNode(self, node): + self.needs_closure = True + + def visit_Node(self, node): + self.visitchildren(node) + return node +