parameters: (val, get_type_id)
return_statement: return AttrOrTypePrinter(type_id, impl.cast(storage_type))
docstring: Returns a printer for mlir::Attribute or mlir::Type.
docstring_summary: Returns a printer for mlir::Attribute or mlir::Type.
docstring_tokens: Returns a printer for mlir :: Attribute or mlir :: Type .
function: def get_attr_or_type_printer(val, get_type_id):
    """Returns a printer for mlir::Attribute or mlir::Type."""
  
    class AttrOrTypePrinter:
  
      def __init__(self, type_id, impl):
        self.type_id = type_id
        self.impl = impl
  
      def children(self):
        yield 'typeID', self.type_id
        yield 'cast<%s>(impl)' % self.impl.type, self.impl
  
    if not val['impl']:
      return None
    impl = val['impl'].dereference()
    type_id = get_type_id(impl)
    concrete_type = storage_type_map[type_id]
    if not concrete_type:
      return None
    # 3rd template argument of StorageUserBase is the storage type.
    storage_type = concrete_type.fields()[0].type.template_argument(2)
    if not storage_type:
      return None
    return AttrOrTypePrinter(type_id, impl.cast(storage_type))
function_tokens: def get_attr_or_type_printer ( val , get_type_id ) : class AttrOrTypePrinter : def __init__ ( self , type_id , impl ) : self . type_id = type_id self . impl = impl def children ( self ) : yield 'typeID' , self . type_id yield 'cast<%s>(impl)' % self . impl . type , self . impl if not val [ 'impl' ] : return None impl = val [ 'impl' ] . dereference ( ) type_id = get_type_id ( impl ) concrete_type = storage_type_map [ type_id ] if not concrete_type : return None # 3rd template argument of StorageUserBase is the storage type. storage_type = concrete_type . fields ( ) [ 0 ] . type . template_argument ( 2 ) if not storage_type : return None return AttrOrTypePrinter ( type_id , impl . cast ( storage_type ) )