Move parallel deletion flatten into PostParseTransform
authorVitja Makarov <vitja.makarov@gmail.com>
Fri, 1 Apr 2011 08:16:48 +0000 (10:16 +0200)
committerVitja Makarov <vitja.makarov@gmail.com>
Fri, 1 Apr 2011 08:16:48 +0000 (10:16 +0200)
Cython/Compiler/Nodes.py
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/TypeInference.py

index 37e49e2d1778172421c664c23c68833052c1b412..7b91add2c5c0f4f2401b00cc5ed049345b5f2ae7 100644 (file)
@@ -3784,23 +3784,12 @@ class DelStatNode(StatNode):
 
     child_attrs = ["args"]
 
-    def flatten_args(self):
-        return self._flatten_args(self, [])
-
-    def _flatten_args(self, seq, result):
-        for arg in seq.args:
-            if arg.is_sequence_constructor:
-                self._flatten_args(arg, result)
-            else:
-                result.append(arg)
-        return result
-
     def analyse_declarations(self, env):
-        for arg in self.flatten_args():
+        for arg in self.args:
             arg.analyse_target_declaration(env)
 
     def analyse_expressions(self, env):
-        for arg in self.flatten_args():
+        for arg in self.args:
             arg.analyse_target_expression(env, None)
             if arg.type.is_pyobject:
                 pass
@@ -3813,14 +3802,14 @@ class DelStatNode(StatNode):
             #arg.release_target_temp(env)
 
     def nogil_check(self, env):
-        for arg in self.flatten_args():
+        for arg in self.args:
             if arg.type.is_pyobject:
                 self.gil_error()
 
     gil_message = "Deleting Python object"
 
     def generate_execution_code(self, code):
-        for arg in self.flatten_args():
+        for arg in self.args:
             if arg.type.is_pyobject:
                 arg.generate_deletion_code(code)
             elif arg.type.is_ptr and arg.type.base_type.is_cpp_class:
index 11a2baeeebd94894e84216c3d6f5dc15a03634fd..7edaeca9b6a6ada3a7dcfc489c659105f5b9def6 100644 (file)
@@ -299,6 +299,20 @@ class PostParse(ScopeTrackingTransform):
 
         return assign_node
 
+    def _flatten_sequence(self, seq, result):
+        for arg in seq.args:
+            if arg.is_sequence_constructor:
+                self._flatten_sequence(arg, result)
+            else:
+                result.append(arg)
+        return result
+
+    def visit_DelStatNode(self, node):
+        self.visitchildren(node)
+        node.args = self._flatten_sequence(node, [])
+        return node
+
+
 def eliminate_rhs_duplicates(expr_list_list, ref_node_sequence):
     """Replace rhs items by LetRefNodes if they appear more than once.
     Creates a sequence of LetRefNodes that set up the required temps
index 87fcb869837a85d07bc2872fc809ebc6d4874eec..c788d02c3897a515dd62adbc70cc733d6758c95a 100644 (file)
@@ -122,7 +122,7 @@ class MarkAssignments(CythonTransform):
         return node
 
     def visit_DelStatNode(self, node):
-        for arg in node.flatten_args():
+        for arg in node.args:
             self.mark_assignment(arg, arg)
         self.visitchildren(node)
         return node