Commit 749fe583 authored by Stefan Behnel's avatar Stefan Behnel

Clean up individual child traversals in transforms using the new visitchild() method.

parent 84ed66f4
...@@ -914,7 +914,7 @@ class InterpretCompilerDirectives(CythonTransform): ...@@ -914,7 +914,7 @@ class InterpretCompilerDirectives(CythonTransform):
def visit_NameNode(self, node): def visit_NameNode(self, node):
if node.annotation: if node.annotation:
self.visit(node.annotation) self.visitchild(node, 'annotation')
if node.name in self.cython_module_names: if node.name in self.cython_module_names:
node.is_cython_module = True node.is_cython_module = True
else: else:
...@@ -941,7 +941,7 @@ class InterpretCompilerDirectives(CythonTransform): ...@@ -941,7 +941,7 @@ class InterpretCompilerDirectives(CythonTransform):
return node return node
def visit_NewExprNode(self, node): def visit_NewExprNode(self, node):
self.visit(node.cppclass) self.visitchild(node, 'cppclass')
self.visitchildren(node) self.visitchildren(node)
return node return node
...@@ -950,7 +950,7 @@ class InterpretCompilerDirectives(CythonTransform): ...@@ -950,7 +950,7 @@ class InterpretCompilerDirectives(CythonTransform):
# decorator), returns a list of (directivename, value) pairs. # decorator), returns a list of (directivename, value) pairs.
# Otherwise, returns None # Otherwise, returns None
if isinstance(node, ExprNodes.CallNode): if isinstance(node, ExprNodes.CallNode):
self.visit(node.function) self.visitchild(node, 'function')
optname = node.function.as_cython_attribute() optname = node.function.as_cython_attribute()
if optname: if optname:
directivetype = Options.directive_types.get(optname) directivetype = Options.directive_types.get(optname)
...@@ -1253,7 +1253,7 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations): ...@@ -1253,7 +1253,7 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations):
return node return node
def visit_CallNode(self, node): def visit_CallNode(self, node):
self.visit(node.function) self.visitchild(node, 'function')
if not self.parallel_directive: if not self.parallel_directive:
self.visitchildren(node, exclude=('function',)) self.visitchildren(node, exclude=('function',))
return node return node
...@@ -1286,7 +1286,7 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations): ...@@ -1286,7 +1286,7 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations):
"Nested parallel with blocks are disallowed") "Nested parallel with blocks are disallowed")
self.state = 'parallel with' self.state = 'parallel with'
body = self.visit(node.body) body = self.visitchild(node, 'body')
self.state = None self.state = None
newnode.body = body newnode.body = body
...@@ -1302,13 +1302,13 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations): ...@@ -1302,13 +1302,13 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations):
error(node.pos, "The parallel directive must be called") error(node.pos, "The parallel directive must be called")
return None return None
node.body = self.visit(node.body) self.visitchild(node, 'body')
return node return node
def visit_ForInStatNode(self, node): def visit_ForInStatNode(self, node):
"Rewrite 'for i in cython.parallel.prange(...):'" "Rewrite 'for i in cython.parallel.prange(...):'"
self.visit(node.iterator) self.visitchild(node, 'iterator')
self.visit(node.target) self.visitchild(node, 'target')
in_prange = isinstance(node.iterator.sequence, in_prange = isinstance(node.iterator.sequence,
Nodes.ParallelRangeNode) Nodes.ParallelRangeNode)
...@@ -1331,9 +1331,9 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations): ...@@ -1331,9 +1331,9 @@ class ParallelRangeTransform(CythonTransform, SkipDeclarations):
self.state = 'prange' self.state = 'prange'
self.visit(node.body) self.visitchild(node, 'body')
self.state = previous_state self.state = previous_state
self.visit(node.else_clause) self.visitchild(node, 'else_clause')
return node return node
def visit(self, node): def visit(self, node):
...@@ -1960,7 +1960,7 @@ if VALUE is not None: ...@@ -1960,7 +1960,7 @@ if VALUE is not None:
"Handle def or cpdef fused functions" "Handle def or cpdef fused functions"
# Create PyCFunction nodes for each specialization # Create PyCFunction nodes for each specialization
node.stats.insert(0, node.py_func) node.stats.insert(0, node.py_func)
node.py_func = self.visit(node.py_func) self.visitchild(node, 'py_func')
node.update_fused_defnode_entry(env) node.update_fused_defnode_entry(env)
# For the moment, fused functions do not support METH_FASTCALL # For the moment, fused functions do not support METH_FASTCALL
node.py_func.entry.signature.use_fastcall = False node.py_func.entry.signature.use_fastcall = False
...@@ -2242,13 +2242,12 @@ if VALUE is not None: ...@@ -2242,13 +2242,12 @@ if VALUE is not None:
return None return None
def visit_CnameDecoratorNode(self, node): def visit_CnameDecoratorNode(self, node):
child_node = self.visit(node.node) child_node = self.visitchild(node, 'node')
if not child_node: if not child_node:
return None return None
if type(child_node) is list: # Assignment synthesized if type(child_node) is list: # Assignment synthesized
node.child_node = child_node[0] node.node = child_node[0]
return [node] + child_node[1:] return [node] + child_node[1:]
node.node = child_node
return node return node
def create_Property(self, entry): def create_Property(self, entry):
......
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