From eaad966eb46c1ee19bb06e215c6727aaf7eade3c Mon Sep 17 00:00:00 2001 From: Vitja Makarov Date: Fri, 1 Apr 2011 10:16:48 +0200 Subject: [PATCH] Move parallel deletion flatten into PostParseTransform --- Cython/Compiler/Nodes.py | 19 ++++--------------- Cython/Compiler/ParseTreeTransforms.py | 14 ++++++++++++++ Cython/Compiler/TypeInference.py | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 37e49e2d..7b91add2 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -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: diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py index 11a2baee..7edaeca9 100644 --- a/Cython/Compiler/ParseTreeTransforms.py +++ b/Cython/Compiler/ParseTreeTransforms.py @@ -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 diff --git a/Cython/Compiler/TypeInference.py b/Cython/Compiler/TypeInference.py index 87fcb869..c788d02c 100644 --- a/Cython/Compiler/TypeInference.py +++ b/Cython/Compiler/TypeInference.py @@ -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 -- 2.26.2