some more cythonisation in Visitor.py
authorStefan Behnel <scoder@users.berlios.de>
Sun, 21 Dec 2008 09:54:15 +0000 (10:54 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Sun, 21 Dec 2008 09:54:15 +0000 (10:54 +0100)
Cython/Compiler/Visitor.pxd
Cython/Compiler/Visitor.py

index 9f83c14bd8e61ebbff3c6aaa81103ba72c1947b4..86be5c03157abb5f7beab0e822726391688c187c 100644 (file)
@@ -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)
 
index 5c89e797de6a774c1601a16205e8fd94b0aad340..4dae2f70ff6ff5ab9530da690dbc2f309605113b 100644 (file)
@@ -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)