cdef dict dispatch_table
cpdef visit(self, obj)
cdef _visit(self, obj)
- cdef find_handler(self, obj)
+ cdef _find_handler(self, obj)
cdef class TreeVisitor(BasicVisitor):
cdef public list access_path
- cdef visitchild(self, child, parent, attrname, idx)
+ cdef _visitchild(self, child, parent, attrname, idx)
@cython.locals(idx=int)
cdef dict _visitchildren(self, parent, attrs)
cpdef visitchildren(self, parent, attrs=*)
try:
handler_method = self.dispatch_table[type(obj)]
except KeyError:
- handler_method = self.find_handler(obj)
+ handler_method = self._find_handler(obj)
self.dispatch_table[type(obj)] = handler_method
return handler_method(obj)
- def find_handler(self, obj):
+ def _find_handler(self, obj):
cls = type(obj)
#print "Cache miss for class %s in visitor %s" % (
# cls.__name__, type(self).__name__)
last_node.pos, self.__class__.__name__,
u'\n'.join(trace), e, stacktrace)
- def visitchild(self, child, parent, attrname, idx):
+ def _visitchild(self, child, parent, attrname, idx):
self.access_path.append((parent, attrname, idx))
try:
result = self._visit(child)
child = getattr(parent, attr)
if child is not None:
if type(child) is list:
- childretval = [self.visitchild(x, parent, attr, idx) for idx, x in enumerate(child)]
+ childretval = [self._visitchild(x, parent, attr, idx) for idx, x in enumerate(child)]
else:
- childretval = self.visitchild(child, parent, attr, None)
+ childretval = self._visitchild(child, parent, attr, None)
assert not isinstance(childretval, list), 'Cannot insert list here: %s in %r' % (attr, parent)
result[attr] = childretval
return result