Commit 88213614 authored by Stefan Behnel's avatar Stefan Behnel

some more cythonisation in Visitor.py

parent aaa5c5f9
cdef class BasicVisitor: cdef class BasicVisitor:
cdef object dispatch_table cdef dict dispatch_table
cpdef visit(self, obj) cpdef visit(self, obj)
cdef class TreeVisitor(BasicVisitor): cdef class TreeVisitor(BasicVisitor):
cdef public access_path cdef public list access_path
cpdef visitchild(self, child, parent, attrname, idx) cpdef visitchild(self, child, parent, attrname, idx)
cdef class VisitorTransform(TreeVisitor): cdef class VisitorTransform(TreeVisitor):
cdef object _super_visitchildren
cpdef visitchildren(self, parent, attrs=*) cpdef visitchildren(self, parent, attrs=*)
cpdef recurse_to_children(self, node) cpdef recurse_to_children(self, node)
......
...@@ -142,9 +142,12 @@ class VisitorTransform(TreeVisitor): ...@@ -142,9 +142,12 @@ class VisitorTransform(TreeVisitor):
was not, an exception will be raised. (Typically you want to ensure that you was not, an exception will be raised. (Typically you want to ensure that you
are within a StatListNode or similar before doing this.) are within a StatListNode or similar before doing this.)
""" """
def __init__(self):
super(VisitorTransform, self).__init__()
self._super_visitchildren = super(VisitorTransform, self).visitchildren
def visitchildren(self, parent, attrs=None): def visitchildren(self, parent, attrs=None):
# result = super(VisitorTransform, self).visitchildren(parent, attrs) result = self._super_visitchildren(parent, attrs)
result = TreeVisitor.visitchildren(self, parent, attrs)
for attr, newnode in result.iteritems(): for attr, newnode in result.iteritems():
if not isinstance(newnode, list): if not isinstance(newnode, list):
setattr(parent, attr, newnode) setattr(parent, attr, newnode)
......
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