From 8821361479936353bae1cea3729e75bf09b55833 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sun, 21 Dec 2008 10:54:15 +0100 Subject: [PATCH] some more cythonisation in Visitor.py --- Cython/Compiler/Visitor.pxd | 5 +++-- Cython/Compiler/Visitor.py | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) 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) -- 2.26.2