Attribute

Trait Attribute 

Source
pub trait Attribute:
    Printable
    + Verify
    + Downcast
    + Sync
    + Send
    + DynClone
    + Debug {
    // Required methods
    fn hash_attr(&self) -> TypeValueHash;
    fn eq_attr(&self, other: &dyn Attribute) -> bool;
    fn get_attr_id(&self) -> AttrId;
    fn get_attr_id_static() -> AttrId
       where Self: Sized;
    fn verify_interfaces(&self, ctx: &Context) -> Result<()>;

    // Provided method
    fn register_attr_in_dialect<A: Attribute>(
        ctx: &mut Context,
        attr_parser: ParserFn<(), A>,
    )
       where Self: Sized { ... }
}
Expand description

Basic functionality that every attribute in the IR must implement.

See module documentation for more information.

Required Methods§

Source

fn hash_attr(&self) -> TypeValueHash

Compute and get the hash for this instance of Self. Hash collisions can be a possibility.

Source

fn eq_attr(&self, other: &dyn Attribute) -> bool

Is self equal to an other Attribute?

Source

fn get_attr_id(&self) -> AttrId

Get an Attribute’s static name. This is not per instantnce. It is mostly useful for printing and parsing the attribute.

Source

fn get_attr_id_static() -> AttrId
where Self: Sized,

Same as get_attr_id, but without the self reference.

Source

fn verify_interfaces(&self, ctx: &Context) -> Result<()>

Verify all interfaces implemented by this attribute.

Provided Methods§

Source

fn register_attr_in_dialect<A: Attribute>( ctx: &mut Context, attr_parser: ParserFn<(), A>, )
where Self: Sized,

Register this attribute’s AttrId in the dialect it belongs to.

Implementations§

Source§

impl dyn Attribute

Source

pub fn is<__T: Attribute>(&self) -> bool

Returns true if the trait object wraps an object of type __T.

Source

pub fn downcast<__T: Attribute>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>

Returns a boxed object from a boxed trait object if the underlying object is of type __T. Returns the original boxed trait if it isn’t.

Source

pub fn downcast_rc<__T: Attribute>(self: Rc<Self>) -> Result<Rc<__T>, Rc<Self>>

Returns an Rc-ed object from an Rc-ed trait object if the underlying object is of type __T. Returns the original Rc-ed trait if it isn’t.

Source

pub fn downcast_ref<__T: Attribute>(&self) -> Option<&__T>

Returns a reference to the object within the trait object if it is of type __T, or None if it isn’t.

Source

pub fn downcast_mut<__T: Attribute>(&mut self) -> Option<&mut __T>

Returns a mutable reference to the object within the trait object if it is of type __T, or None if it isn’t.

Implementors§