use bitflags::bitflags;
use oxc_allocator::{Allocator, CloneIn, Dummy};
use oxc_ast_macros::ast;
use oxc_index::define_nonmax_u32_index_type;
define_nonmax_u32_index_type! {
#[ast]
#[clone_in(default)]
#[content_eq(skip)]
#[estree(skip)]
pub struct NodeId;
}
impl NodeId {
pub const DUMMY: Self = NodeId::new(0);
pub const ROOT: Self = NodeId::new(0);
}
impl Default for NodeId {
#[inline]
fn default() -> Self {
Self::DUMMY
}
}
impl<'a> Dummy<'a> for NodeId {
#[inline]
fn dummy(_: &'a Allocator) -> Self {
Self::DUMMY
}
}
impl<'alloc> CloneIn<'alloc> for NodeId {
type Cloned = Self;
fn clone_in(&self, _: &'alloc Allocator) -> Self {
unreachable!();
}
#[inline]
fn clone_in_with_semantic_ids(&self, _: &'alloc Allocator) -> Self {
*self
}
}
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct NodeFlags: u8 {
const JSDoc = 1 << 0;
const HasYield = 1 << 2;
}
}
impl NodeFlags {
#[inline]
pub fn has_jsdoc(self) -> bool {
self.contains(Self::JSDoc)
}
#[inline]
pub fn has_yield(self) -> bool {
self.contains(Self::HasYield)
}
}