mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 12:51:57 +00:00
closes #949 closes #950 closes #951 All minifier tests are disable from this PR. We are going to fix the compilation errors first, then the behavioral errors.
55 lines
1.3 KiB
Rust
55 lines
1.3 KiB
Rust
use bitflags::bitflags;
|
|
use oxc_index::define_index_type;
|
|
|
|
define_index_type! {
|
|
pub struct ReferenceId = u32;
|
|
}
|
|
|
|
bitflags! {
|
|
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq)]
|
|
pub struct ReferenceFlag: u8 {
|
|
const None = 0;
|
|
const Read = 1 << 0;
|
|
const Write = 1 << 1;
|
|
const ReadWrite = Self::Read.bits() | Self::Write.bits();
|
|
}
|
|
}
|
|
|
|
impl ReferenceFlag {
|
|
pub const fn read() -> Self {
|
|
Self::Read
|
|
}
|
|
|
|
pub const fn write() -> Self {
|
|
Self::Write
|
|
}
|
|
|
|
pub const fn read_write() -> Self {
|
|
Self::ReadWrite
|
|
}
|
|
|
|
/// The identifier is read from. It may also be written to.
|
|
pub const fn is_read(&self) -> bool {
|
|
self.intersects(Self::Read)
|
|
}
|
|
|
|
/// The identifier is only read from.
|
|
pub const fn is_read_only(&self) -> bool {
|
|
self.contains(Self::Read)
|
|
}
|
|
|
|
/// The identifier is written to. It may also be read from.
|
|
pub const fn is_write(&self) -> bool {
|
|
self.intersects(Self::Write)
|
|
}
|
|
|
|
/// The identifier is only written to. It is not read from in this reference.
|
|
pub const fn is_write_only(&self) -> bool {
|
|
self.contains(Self::Write)
|
|
}
|
|
|
|
/// The identifier is both read from and written to, e.g `a += 1`.
|
|
pub const fn is_read_write(&self) -> bool {
|
|
self.contains(Self::ReadWrite)
|
|
}
|
|
}
|