def compiles(class_, *specs):
 def decorate(fn):
  existing = class_.__dict__.get('_compiler_dispatcher', None)
  existing_dispatch = class_.__dict__.get('_compiler_dispatch')
  if (not existing):
   existing = _dispatcher()
   if existing_dispatch:
    existing.specs['default'] = existing_dispatch
   setattr(class_, '_compiler_dispatch', (lambda *arg, **kw: existing(*arg, **kw)))
   setattr(class_, '_compiler_dispatcher', existing)
  if specs:
   for s in specs:
    existing.specs[s] = fn
  else:
   existing.specs['default'] = fn
  return fn
 return decorate

def compiles ( class_ , * specs ) : def decorate ( fn ) : existing = class_ . __dict__ . get ( '_compiler_dispatcher' , None ) existing_dispatch = class_ . __dict__ . get ( '_compiler_dispatch' ) if ( not existing ) : existing = _dispatcher ( ) if existing_dispatch : existing . specs [ 'default' ] = existing_dispatch setattr ( class_ , '_compiler_dispatch' , ( lambda * arg , ** kw : existing ( * arg , ** kw ) ) ) setattr ( class_ , '_compiler_dispatcher' , existing ) if specs : for s in specs : existing . specs [ s ] = fn else : existing . specs [ 'default' ] = fn return fn return decorate
register a function as a compiler for a given :class: .