class Visitor:
+ '''Abstract visitor for the type hierarchy.'''
def visit(self, type, *args, **kwargs):
return type.visit(self, *args, **kwargs)
class OnceVisitor(Visitor):
+ '''Visitor that guarantees that each type is visited only once.'''
def __init__(self):
self.__visited = set()
class Rebuilder(Visitor):
+ '''Visitor which rebuild types as it visits them.
+
+ By itself it is a no-op -- it is intended to be overwritten.
+ '''
def visit_void(self, void):
return void
class Collector(Visitor):
- '''Collect.'''
+ '''Visitor which collects all unique types as it traverses them.'''
def __init__(self):
self.__visited = set()
class API:
+ '''API abstraction.
+
+ Essentially, a collection of types, functions, and interfaces.
+ '''
def __init__(self, name = None):
self.name = name