Commit eaad966e authored by Vitja Makarov's avatar Vitja Makarov

Move parallel deletion flatten into PostParseTransform

parent 6a57acd5
...@@ -3784,23 +3784,12 @@ class DelStatNode(StatNode): ...@@ -3784,23 +3784,12 @@ class DelStatNode(StatNode):
child_attrs = ["args"] 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): def analyse_declarations(self, env):
for arg in self.flatten_args(): for arg in self.args:
arg.analyse_target_declaration(env) arg.analyse_target_declaration(env)
def analyse_expressions(self, env): def analyse_expressions(self, env):
for arg in self.flatten_args(): for arg in self.args:
arg.analyse_target_expression(env, None) arg.analyse_target_expression(env, None)
if arg.type.is_pyobject: if arg.type.is_pyobject:
pass pass
...@@ -3813,14 +3802,14 @@ class DelStatNode(StatNode): ...@@ -3813,14 +3802,14 @@ class DelStatNode(StatNode):
#arg.release_target_temp(env) #arg.release_target_temp(env)
def nogil_check(self, env): def nogil_check(self, env):
for arg in self.flatten_args(): for arg in self.args:
if arg.type.is_pyobject: if arg.type.is_pyobject:
self.gil_error() self.gil_error()
gil_message = "Deleting Python object" gil_message = "Deleting Python object"
def generate_execution_code(self, code): def generate_execution_code(self, code):
for arg in self.flatten_args(): for arg in self.args:
if arg.type.is_pyobject: if arg.type.is_pyobject:
arg.generate_deletion_code(code) arg.generate_deletion_code(code)
elif arg.type.is_ptr and arg.type.base_type.is_cpp_class: elif arg.type.is_ptr and arg.type.base_type.is_cpp_class:
......
...@@ -299,6 +299,20 @@ class PostParse(ScopeTrackingTransform): ...@@ -299,6 +299,20 @@ class PostParse(ScopeTrackingTransform):
return assign_node 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): def eliminate_rhs_duplicates(expr_list_list, ref_node_sequence):
"""Replace rhs items by LetRefNodes if they appear more than once. """Replace rhs items by LetRefNodes if they appear more than once.
Creates a sequence of LetRefNodes that set up the required temps Creates a sequence of LetRefNodes that set up the required temps
......
...@@ -122,7 +122,7 @@ class MarkAssignments(CythonTransform): ...@@ -122,7 +122,7 @@ class MarkAssignments(CythonTransform):
return node return node
def visit_DelStatNode(self, node): def visit_DelStatNode(self, node):
for arg in node.flatten_args(): for arg in node.args:
self.mark_assignment(arg, arg) self.mark_assignment(arg, arg)
self.visitchildren(node) self.visitchildren(node)
return node return node
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment