Visitor.pxd 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. from __future__ import absolute_import
  2. cimport cython
  3. cdef class TreeVisitor:
  4. cdef public list access_path
  5. cdef dict dispatch_table
  6. cpdef visit(self, obj)
  7. cdef _visit(self, obj)
  8. cdef find_handler(self, obj)
  9. cdef _visitchild(self, child, parent, attrname, idx)
  10. cdef dict _visitchildren(self, parent, attrs)
  11. cpdef visitchildren(self, parent, attrs=*)
  12. cdef class VisitorTransform(TreeVisitor):
  13. cpdef visitchildren(self, parent, attrs=*)
  14. cpdef recurse_to_children(self, node)
  15. cdef class CythonTransform(VisitorTransform):
  16. cdef public context
  17. cdef public current_directives
  18. cdef class ScopeTrackingTransform(CythonTransform):
  19. cdef public scope_type
  20. cdef public scope_node
  21. cdef visit_scope(self, node, scope_type)
  22. cdef class EnvTransform(CythonTransform):
  23. cdef public list env_stack
  24. cdef class MethodDispatcherTransform(EnvTransform):
  25. @cython.final
  26. cdef _visit_binop_node(self, node)
  27. @cython.final
  28. cdef _find_handler(self, match_name, bint has_kwargs)
  29. @cython.final
  30. cdef _delegate_to_assigned_value(self, node, function, arg_list, kwargs)
  31. @cython.final
  32. cdef _dispatch_to_handler(self, node, function, arg_list, kwargs)
  33. @cython.final
  34. cdef _dispatch_to_method_handler(self, attr_name, self_arg,
  35. is_unbound_method, type_name,
  36. node, function, arg_list, kwargs)
  37. cdef class RecursiveNodeReplacer(VisitorTransform):
  38. cdef public orig_node
  39. cdef public new_node
  40. cdef class NodeFinder(TreeVisitor):
  41. cdef node
  42. cdef public bint found