Skip to content

kirin.ir.attrs.abc.Attribute

← Module overview

classAttributesource

kirin.ir.attrs.abc.Attribute

Bases: ABC, Printable

ABC for compile-time values. All attributes are hashable and thus need to implement the `__hash__` method.

class Attribute

!!! note “Pretty Printing” This object is pretty printable via .print() method.

Attributes

NameTypeDefaultDescription
dialectOptional[Dialect]field(default=None, init=False, repr=False)Dialect of the attribute. (default: None)
namestrfield(init=False, repr=False)Name of the attribute in printing and other text format.
traitsfrozenset[Trait[Attribute]]field(default=(frozenset()), init=False, repr=False)Set of Attribute traits.
TraitType—TypeVar('TraitType', bound=(Trait['Attribute']))

methodis_structurally_equalsource

kirin.ir.attrs.abc.Attribute.is_structurally_equal

Signature
def is_structurally_equal(other: Self, context: dict | None = None) -> bool

Parameters

NameTypeDefaultDescription
otherSelfrequired
contextdict | NoneNone

Returns

bool

source

methodhas_traitsource

kirin.ir.attrs.abc.Attribute.has_trait

def has_trait(trait_type: type[Trait[Attribute]]) -> bool

Check if the Statement has a specific trait.

Parameters

NameTypeDescription
trait_typetype[Trait[Attribute]]The type of trait to check for.

Returns

boolbool: True if the class has the specified trait, False otherwise.

source

methodget_traitsource

kirin.ir.attrs.abc.Attribute.get_trait

def get_trait(trait: type[TraitType]) -> Optional[TraitType]

Get the trait of the attribute.

Parameters

NameTypeDescription
traittype[TraitType]the trait to get

Returns

Optional[TraitType]Optional[Trait]: the trait if found, None otherwise

source