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§
Sourcefn hash_attr(&self) -> TypeValueHash
fn hash_attr(&self) -> TypeValueHash
Compute and get the hash for this instance of Self. Hash collisions can be a possibility.
Sourcefn get_attr_id(&self) -> AttrId
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.
Sourcefn get_attr_id_static() -> AttrIdwhere
Self: Sized,
fn get_attr_id_static() -> AttrIdwhere
Self: Sized,
Same as get_attr_id, but without the self reference.
Sourcefn verify_interfaces(&self, ctx: &Context) -> Result<()>
fn verify_interfaces(&self, ctx: &Context) -> Result<()>
Verify all interfaces implemented by this attribute.
Provided Methods§
Implementations§
Source§impl dyn Attribute
impl dyn Attribute
Sourcepub fn is<__T: Attribute>(&self) -> bool
pub fn is<__T: Attribute>(&self) -> bool
Returns true if the trait object wraps an object of type __T.
Sourcepub fn downcast<__T: Attribute>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>
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.
Sourcepub fn downcast_rc<__T: Attribute>(self: Rc<Self>) -> Result<Rc<__T>, Rc<Self>>
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.
Sourcepub fn downcast_ref<__T: Attribute>(&self) -> Option<&__T>
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.
Sourcepub fn downcast_mut<__T: Attribute>(&mut self) -> Option<&mut __T>
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.