use num_bigint::BigInt;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct IrVar(pub u32);
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct IrLabel(pub usize);
impl IrLabel {
pub const fn new(id: usize) -> Self {
Self(id)
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum IrConstant {
Nil,
Bool(bool),
Int(BigInt),
Float(f64),
String(String),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum IrBinaryOp {
Add,
Sub,
Mul,
Div,
IDiv,
Mod,
Pow,
BitAnd,
BitOr,
BitXor,
Shl,
Shr,
LShl,
LShr,
Concat,
Eq,
Ne,
Lt,
Le,
Gt,
Ge,
Coalesce,
}
impl IrBinaryOp {
pub fn is_comparison(self) -> bool {
matches!(
self,
IrBinaryOp::Eq
| IrBinaryOp::Ne
| IrBinaryOp::Lt
| IrBinaryOp::Le
| IrBinaryOp::Gt
| IrBinaryOp::Ge
)
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum IrUnaryOp {
Neg,
Not,
Len,
BitNot,
}