pub(super) type Id = u32;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(super) struct Operator {
pub(super) code: [u8; 2],
pub(super) name: &'static str,
pub(super) arity: u8,
}
impl Operator {
pub(super) fn is(&self, code: &[u8; 2]) -> bool {
&self.code == code
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(super) enum LiteralStyle {
Default,
Int,
Unsigned,
Long,
UnsignedLong,
LongLong,
UnsignedLongLong,
Bool,
Float,
Void,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(super) struct Builtin {
pub(super) name: &'static str,
pub(super) style: LiteralStyle,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(super) enum Qual {
Restrict,
Volatile,
Const,
RestrictThis,
VolatileThis,
ConstThis,
RefThis,
RvalueRefThis,
TransactionSafe,
Noexcept(Option<Id>),
Throw(Id),
}
impl Qual {
pub(super) fn is_function_qualifier(self) -> bool {
!matches!(self, Self::Restrict | Self::Volatile | Self::Const)
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(super) enum ParamDecl {
Type,
NonType(Id),
Template(Id),
Pack(Id),
}
#[derive(Clone, Debug)]
pub(super) enum Node<'a> {
Name(&'a [u8]),
Text(&'static str),
Qual(Id, Id),
Local(Id, Id),
Typed(Id, Id),
Template(Id, Id),
TemplateParam(u64),
FunctionParam(u64),
Ctor(Id),
Dtor(Id),
Special(&'static str, Id),
CtorVtable(Id, Id),
RefTemp(Id, u64),
Std(&'static str),
Qualified(Qual, Id),
Pointer(Id),
Reference(Id),
RvalueReference(Id),
Complex(Id),
Imaginary(Id),
Builtin(&'static Builtin),
ExtendedBuiltin(&'static str, u64, Option<u8>),
BitInt(bool, Id),
VendorType(Id),
Function(Option<Id>, Id),
Array(Option<Id>, Id),
PtrMem(Id, Id),
Vector(Id, Id),
VendorQual(Id, Id),
Args(Vec<Id>),
TemplateArgs(Vec<Id>),
InitList(Option<Id>, Id),
Operator(&'static Operator),
VendorOperator(u8, Id),
Cast(Id),
Conversion(Id),
Nullary(Id),
Unary {
op: Id,
operand: Id,
postfix: bool,
},
Binary {
op: Id,
left: Id,
right: Id,
},
Trinary {
op: Id,
first: Id,
second: Id,
third: Option<Id>,
},
Literal(Id, Id, bool),
VendorExpr(Id, Id),
Number(u64),
Decltype(Id),
PackExpansion(Id),
Global(&'static str, Id),
Lambda {
head: Option<Id>,
params: Id,
number: u64,
},
Unnamed(u64),
Clone(Id, Id),
AbiTag(Id, Id),
Binding(Vec<Id>),
ModuleEntity(Id, Id),
ModuleName(Option<Id>, Id, bool),
DefaultArg(u64, Id),
Friend(Id),
TemplateParamDecl(ParamDecl),
}