pub mod annotation;
pub mod constant;
pub mod deployment;
pub mod exception;
pub mod interface;
pub mod member;
pub mod module;
pub mod type_;
pub use annotation::{AnnotationDefNode, AnnotationMemberNode};
pub use constant::{
BinaryOp, ConstExpr, ConstExprNode, ConstNode, ConstValue, EvalError, Literal, UnaryOp,
};
pub use deployment::{
DomainNode, EndpointNode, EndpointRole, LibraryNode, ParticipantNode, QosPolicy, QosPolicyKind,
QosProfileNode, TopicNode,
};
pub use exception::ExceptionNode;
pub use interface::{
AttributeNode, InterfaceKind, InterfaceNode, OperationNode, ParamDirection, ParamNode,
};
pub use member::{BitValueNode, BitfieldNode, CaseLabel, CaseNode, EnumeratorNode, MemberNode};
pub use module::ModuleNode;
pub use type_::{Bound, CharWidth, Completeness, PrimitiveKind, TypeKind, TypeNode, ValuetypeKind};
use crate::kind::NodeKind;
use zerodds_ast_core::{Id, NodeId};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum AnyId {
Module(Id<ModuleNode>, NodeId),
Type(Id<TypeNode>, NodeId),
Member(Id<MemberNode>, NodeId),
Case(Id<CaseNode>, NodeId),
Enumerator(Id<EnumeratorNode>, NodeId),
BitValue(Id<BitValueNode>, NodeId),
Bitfield(Id<BitfieldNode>, NodeId),
Const(Id<ConstNode>, NodeId),
ConstExpr(Id<ConstExprNode>, NodeId),
Interface(Id<InterfaceNode>, NodeId),
Operation(Id<OperationNode>, NodeId),
Param(Id<ParamNode>, NodeId),
Attribute(Id<AttributeNode>, NodeId),
Exception(Id<ExceptionNode>, NodeId),
AnnotationDef(Id<AnnotationDefNode>, NodeId),
AnnotationMember(Id<AnnotationMemberNode>, NodeId),
Domain(Id<DomainNode>, NodeId),
Topic(Id<TopicNode>, NodeId),
QosProfile(Id<QosProfileNode>, NodeId),
Participant(Id<ParticipantNode>, NodeId),
Endpoint(Id<EndpointNode>, NodeId),
Library(Id<LibraryNode>, NodeId),
}
impl AnyId {
#[must_use]
pub const fn node_id(self) -> NodeId {
match self {
Self::Module(_, id)
| Self::Type(_, id)
| Self::Member(_, id)
| Self::Case(_, id)
| Self::Enumerator(_, id)
| Self::BitValue(_, id)
| Self::Bitfield(_, id)
| Self::Const(_, id)
| Self::ConstExpr(_, id)
| Self::Interface(_, id)
| Self::Operation(_, id)
| Self::Param(_, id)
| Self::Attribute(_, id)
| Self::Exception(_, id)
| Self::AnnotationDef(_, id)
| Self::AnnotationMember(_, id)
| Self::Domain(_, id)
| Self::Topic(_, id)
| Self::QosProfile(_, id)
| Self::Participant(_, id)
| Self::Endpoint(_, id)
| Self::Library(_, id) => id,
}
}
#[must_use]
pub const fn kind(self) -> NodeKind {
match self {
Self::Module(..) => NodeKind::Module,
Self::Type(..) => NodeKind::Type,
Self::Member(..) => NodeKind::Member,
Self::Case(..) => NodeKind::Case,
Self::Enumerator(..) => NodeKind::Enumerator,
Self::BitValue(..) => NodeKind::BitValue,
Self::Bitfield(..) => NodeKind::Bitfield,
Self::Const(..) => NodeKind::Const,
Self::ConstExpr(..) => NodeKind::ConstExpr,
Self::Interface(..) => NodeKind::Interface,
Self::Operation(..) => NodeKind::Operation,
Self::Param(..) => NodeKind::Param,
Self::Attribute(..) => NodeKind::Attribute,
Self::Exception(..) => NodeKind::Exception,
Self::AnnotationDef(..) => NodeKind::AnnotationDef,
Self::AnnotationMember(..) => NodeKind::AnnotationMember,
Self::Domain(..) => NodeKind::Domain,
Self::Topic(..) => NodeKind::Topic,
Self::QosProfile(..) => NodeKind::QosProfile,
Self::Participant(..) => NodeKind::Participant,
Self::Endpoint(..) => NodeKind::Endpoint,
Self::Library(..) => NodeKind::Library,
}
}
#[must_use]
pub const fn as_type(self) -> Option<Id<TypeNode>> {
match self {
Self::Type(id, _) => Some(id),
_ => None,
}
}
#[must_use]
pub const fn as_interface(self) -> Option<Id<crate::InterfaceNode>> {
match self {
Self::Interface(id, _) => Some(id),
_ => None,
}
}
#[must_use]
pub const fn as_module(self) -> Option<Id<ModuleNode>> {
match self {
Self::Module(id, _) => Some(id),
_ => None,
}
}
#[must_use]
pub const fn as_member(self) -> Option<Id<MemberNode>> {
match self {
Self::Member(id, _) => Some(id),
_ => None,
}
}
}