use crate::types::{Class, Tag};
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct Identifier {
pub tag: Tag,
pub(crate) is_constructed: bool,
}
impl Identifier {
#[must_use]
pub fn new(class: Class, is_constructed: bool, tag: u32) -> Self {
Self {
tag: Tag::new(class, tag),
is_constructed,
}
}
#[must_use]
pub fn from_tag(tag: Tag, is_constructed: bool) -> Self {
Self {
tag,
is_constructed,
}
}
#[must_use]
pub fn tag(self, tag: u32) -> Self {
Self {
tag: self.tag.set_value(tag),
is_constructed: self.is_constructed,
}
}
#[must_use]
pub fn is_constructed(&self) -> bool {
self.is_constructed
}
#[must_use]
pub fn is_primitive(&self) -> bool {
!self.is_constructed()
}
}
impl core::ops::Deref for Identifier {
type Target = Tag;
fn deref(&self) -> &Self::Target {
&self.tag
}
}