#[derive_attr_get_set]Expand description
Derive getter and setters for operation attributes listed as arguments.
Note: It is suggested to use the pliron_op macro instead of using this macro directly.
The documention here is useful though, because pliron_op’s attributes field
expands to this macro.
The arguments are a comma separated list of attribute names (which must be an Identifier), each of which may have an optional concrete Rust type specified, denoting the Attribute’s concrete type.
// A test for the `derive_attr_get_set` macro.
#[verify_succ]
#[def_op("llvm.with_attrs")]
#[format_op]
#[derive_attr_get_set(name1_any_attr, name2_ty_attr : pliron::builtin::attributes::TypeAttr)]
pub struct WithAttrsOp {}This expands to add the following getter / setter items:
# use pliron::derive::{def_op, format_op, derive_attr_get_set};
# use std::cell::Ref;
# use pliron::dict_key;
# use pliron::{attribute::AttrObj, context::Context};
# use pliron::{builtin::attributes::TypeAttr};
# use pliron::derive::verify_succ;
# #[verify_succ]
#[format_op]
#[def_op("llvm.with_attrs")]
pub struct WithAttrsOp {}
dict_key!(ATTR_KEY_NAME1_ANY_ATTR, "name1_any_attr");
dict_key!(ATTR_KEY_NAME2_TY_ATTR, "name2_ty_attr");
impl WithAttrsOp {
pub fn get_attr_name1_any_attr<'a>
(&self, ctx: &'a Context)-> Option<Ref<'a, AttrObj>> { todo!() }
pub fn set_attr_name1_any_attr(&self, ctx: &Context, value: AttrObj) { todo!() }
pub fn get_attr_name2_ty_attr<'a>
(&self, ctx: &'a Context) -> Option<Ref<'a, TypeAttr>> { todo!() }
pub fn set_attr_name2_ty_attr(&self, ctx: &Context, value: TypeAttr) { todo!() }
}