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