use crate::ir::model::expr::Expr;
use crate::ir::model::types::{BinOp, UnOp};
impl Expr {
#[must_use]
#[inline(always)]
pub fn add(left: Self, right: Self) -> Self {
Self::BinOp {
op: BinOp::Add,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn sub(left: Self, right: Self) -> Self {
Self::BinOp {
op: BinOp::Sub,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn mul(left: Self, right: Self) -> Self {
Self::BinOp {
op: BinOp::Mul,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn div(left: Self, right: Self) -> Self {
Self::BinOp {
op: BinOp::Div,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn rem(left: Self, right: Self) -> Self {
Self::BinOp {
op: BinOp::Mod,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn negate(operand: Self) -> Self {
Self::UnOp {
op: UnOp::Negate,
operand: Box::new(operand),
}
}
#[must_use]
#[inline(always)]
pub fn abs_diff(left: Self, right: Self) -> Self {
Self::BinOp {
op: BinOp::AbsDiff,
left: Box::new(left),
right: Box::new(right),
}
}
}