use crate::ir::model::expr::Expr;
use crate::ir::model::types::{BinOp, UnOp};
impl Expr {
#[must_use]
#[inline(always)]
pub fn eq(left: Self, right: Self) -> Self {
Self::BinOp {
op: BinOp::Eq,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn lt(left: Self, right: Self) -> Self {
Self::BinOp {
op: BinOp::Lt,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn ne(left: Self, right: Self) -> Self {
Self::BinOp {
op: BinOp::Ne,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn gt(left: Self, right: Self) -> Self {
Self::BinOp {
op: BinOp::Gt,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn le(left: Self, right: Self) -> Self {
Self::BinOp {
op: BinOp::Le,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn ge(left: Self, right: Self) -> Self {
Self::BinOp {
op: BinOp::Ge,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn and(left: Self, right: Self) -> Self {
Self::BinOp {
op: BinOp::And,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn or(left: Self, right: Self) -> Self {
Self::BinOp {
op: BinOp::Or,
left: Box::new(left),
right: Box::new(right),
}
}
#[must_use]
#[inline(always)]
pub fn not(operand: Self) -> Self {
Self::UnOp {
op: UnOp::LogicalNot,
operand: Box::new(operand),
}
}
#[must_use]
#[inline(always)]
pub fn sin(operand: Self) -> Self {
Self::UnOp {
op: UnOp::Sin,
operand: Box::new(operand),
}
}
#[must_use]
#[inline(always)]
pub fn cos(operand: Self) -> Self {
Self::UnOp {
op: UnOp::Cos,
operand: Box::new(operand),
}
}
#[must_use]
#[inline(always)]
pub fn abs(operand: Self) -> Self {
Self::UnOp {
op: UnOp::Abs,
operand: Box::new(operand),
}
}
#[must_use]
#[inline(always)]
pub fn sqrt(operand: Self) -> Self {
Self::UnOp {
op: UnOp::Sqrt,
operand: Box::new(operand),
}
}
}