use crate::metadata::token::Token;
use crossbeam_skiplist::SkipMap;
use std::sync::Arc;
mod builder;
mod loader;
mod owned;
mod raw;
mod reader;
mod writer;
pub use builder::*;
pub(crate) use loader::*;
pub use owned::*;
pub use raw::*;
pub type FieldMap = SkipMap<Token, FieldRc>;
pub type FieldList = Arc<boxcar::Vec<FieldRc>>;
pub type FieldRc = Arc<Field>;
metadata_flags! {
pub struct FieldAttributes(u32);
}
impl FieldAttributes {
pub const FIELD_ACCESS_MASK: Self = Self(0x0007);
pub const COMPILER_CONTROLLED: Self = Self(0x0000);
pub const PRIVATE: Self = Self(0x0001);
pub const FAM_AND_ASSEM: Self = Self(0x0002);
pub const ASSEMBLY: Self = Self(0x0003);
pub const FAMILY: Self = Self(0x0004);
pub const FAM_OR_ASSEM: Self = Self(0x0005);
pub const PUBLIC: Self = Self(0x0006);
pub const STATIC: Self = Self(0x0010);
pub const INIT_ONLY: Self = Self(0x0020);
pub const LITERAL: Self = Self(0x0040);
pub const NOT_SERIALIZED: Self = Self(0x0080);
pub const SPECIAL_NAME: Self = Self(0x0200);
pub const PINVOKE_IMPL: Self = Self(0x2000);
pub const RTSPECIAL_NAME: Self = Self(0x0400);
pub const HAS_FIELD_MARSHAL: Self = Self(0x1000);
pub const HAS_DEFAULT: Self = Self(0x8000);
pub const HAS_FIELD_RVA: Self = Self(0x0100);
#[inline]
#[must_use]
pub const fn access(self) -> Self {
Self(self.0 & Self::FIELD_ACCESS_MASK.0)
}
#[must_use]
pub fn access_keyword(self) -> &'static str {
match self.access() {
Self::COMPILER_CONTROLLED => "privatescope",
Self::PRIVATE => "private",
Self::FAM_AND_ASSEM => "famandassem",
Self::ASSEMBLY => "assembly",
Self::FAMILY => "family",
Self::FAM_OR_ASSEM => "famorassem",
Self::PUBLIC => "public",
_ => "",
}
}
#[inline]
#[must_use]
pub const fn is_static(self) -> bool {
self.contains(Self::STATIC)
}
#[inline]
#[must_use]
pub const fn is_init_only(self) -> bool {
self.contains(Self::INIT_ONLY)
}
#[inline]
#[must_use]
pub const fn is_literal(self) -> bool {
self.contains(Self::LITERAL)
}
#[inline]
#[must_use]
pub const fn is_not_serialized(self) -> bool {
self.contains(Self::NOT_SERIALIZED)
}
#[inline]
#[must_use]
pub const fn is_special_name(self) -> bool {
self.contains(Self::SPECIAL_NAME)
}
#[inline]
#[must_use]
pub const fn is_rt_special_name(self) -> bool {
self.contains(Self::RTSPECIAL_NAME)
}
#[inline]
#[must_use]
pub const fn has_field_marshal(self) -> bool {
self.contains(Self::HAS_FIELD_MARSHAL)
}
#[inline]
#[must_use]
pub const fn has_default(self) -> bool {
self.contains(Self::HAS_DEFAULT)
}
#[inline]
#[must_use]
pub const fn has_field_rva(self) -> bool {
self.contains(Self::HAS_FIELD_RVA)
}
}