Mark closure visitor
authorRobert Bradshaw <robertwb@math.washington.edu>
Thu, 19 Jun 2008 20:34:49 +0000 (13:34 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Thu, 19 Jun 2008 20:34:49 +0000 (13:34 -0700)
Cython/Compiler/Nodes.py
Cython/Compiler/ParseTreeTransforms.py

index faf16dc96dbd447751277284fe8e883165b35944..f363f17ddc360eb2be1eee7aa7e5b1ffb2389198 100644 (file)
@@ -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'
index ef4d9b8328ac6420bbaa1896f5ba88c10273b538..d11dd5e76126f518a4d46eb5b9646594aaf8f4b2 100644 (file)
@@ -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
+