From: Stefan Behnel Date: Sun, 21 Dec 2008 09:54:15 +0000 (+0100) Subject: some more cythonisation in Visitor.py X-Git-Tag: 0.11-beta~89 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8821361479936353bae1cea3729e75bf09b55833;p=cython.git some more cythonisation in Visitor.py --- diff --git a/Cython/Compiler/Visitor.pxd b/Cython/Compiler/Visitor.pxd index 9f83c14b..86be5c03 100644 --- a/Cython/Compiler/Visitor.pxd +++ b/Cython/Compiler/Visitor.pxd @@ -1,12 +1,13 @@ cdef class BasicVisitor: - cdef object dispatch_table + cdef dict dispatch_table cpdef visit(self, obj) cdef class TreeVisitor(BasicVisitor): - cdef public access_path + cdef public list access_path cpdef visitchild(self, child, parent, attrname, idx) cdef class VisitorTransform(TreeVisitor): + cdef object _super_visitchildren cpdef visitchildren(self, parent, attrs=*) cpdef recurse_to_children(self, node) diff --git a/Cython/Compiler/Visitor.py b/Cython/Compiler/Visitor.py index 5c89e797..4dae2f70 100644 --- a/Cython/Compiler/Visitor.py +++ b/Cython/Compiler/Visitor.py @@ -142,9 +142,12 @@ class VisitorTransform(TreeVisitor): was not, an exception will be raised. (Typically you want to ensure that you 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): -# result = super(VisitorTransform, self).visitchildren(parent, attrs) - result = TreeVisitor.visitchildren(self, parent, attrs) + result = self._super_visitchildren(parent, attrs) for attr, newnode in result.iteritems(): if not isinstance(newnode, list): setattr(parent, attr, newnode)