|
|
|
@ -1,128 +1,6 @@
|
|
|
|
|
// impl<S: Storage> Evaluator<S>
|
|
|
|
|
// where Evaluator<S>: Env<Structured> {
|
|
|
|
|
//
|
|
|
|
|
// fn mod_exprs<'a>(&self, exprs: &[Expr<'a>]) -> Result<Expr<'a>> {
|
|
|
|
|
// match exprs {
|
|
|
|
|
// [a, b] => {
|
|
|
|
|
// let a = self.visit_expr(a)?;
|
|
|
|
|
// let b = self.visit_expr(b)?;
|
|
|
|
|
// if a == Const(Null) || b == Const(Null) {
|
|
|
|
|
// return Ok(Const(Null));
|
|
|
|
|
// }
|
|
|
|
|
// Ok(Const(match (a, b) {
|
|
|
|
|
// (Const(a), Const(b)) => {
|
|
|
|
|
// match (a, b) {
|
|
|
|
|
// (Int(a), Int(b)) => Int(a % b),
|
|
|
|
|
// (_, _) => return Err(CozoError::TypeError)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// (a, b) => return Ok(Apply(Op::Mod, vec![a, b]))
|
|
|
|
|
// }))
|
|
|
|
|
// }
|
|
|
|
|
// _ => unreachable!()
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// fn gt_exprs<'a>(&self, exprs: &[Expr<'a>]) -> Result<Expr<'a>> {
|
|
|
|
|
// match exprs {
|
|
|
|
|
// [a, b] => {
|
|
|
|
|
// let a = self.visit_expr(a)?;
|
|
|
|
|
// let b = self.visit_expr(b)?;
|
|
|
|
|
// if a == Const(Null) || b == Const(Null) {
|
|
|
|
|
// return Ok(Const(Null));
|
|
|
|
|
// }
|
|
|
|
|
// match (a, b) {
|
|
|
|
|
// (Const(a), Const(b)) => {
|
|
|
|
|
// match (a, b) {
|
|
|
|
|
// (Int(a), Int(b)) => Ok(Const(Bool(a > b))),
|
|
|
|
|
// (Float(a), Int(b)) => Ok(Const(Bool(a > b as f64))),
|
|
|
|
|
// (Int(a), Float(b)) => Ok(Const(Bool(a as f64 > b))),
|
|
|
|
|
// (Float(a), Float(b)) => Ok(Const(Bool(a > b))),
|
|
|
|
|
// (_, _) => Err(CozoError::TypeError)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// (a, b) => Ok(Apply(Op::Gt, vec![a, b]))
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// _ => unreachable!()
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// fn ge_exprs<'a>(&self, exprs: &[Expr<'a>]) -> Result<Expr<'a>> {
|
|
|
|
|
// match exprs {
|
|
|
|
|
// [a, b] => {
|
|
|
|
|
// let a = self.visit_expr(a)?;
|
|
|
|
|
// let b = self.visit_expr(b)?;
|
|
|
|
|
// if a == Const(Null) || b == Const(Null) {
|
|
|
|
|
// return Ok(Const(Null));
|
|
|
|
|
// }
|
|
|
|
|
// match (a, b) {
|
|
|
|
|
// (Const(a), Const(b)) => {
|
|
|
|
|
// match (a, b) {
|
|
|
|
|
// (Int(a), Int(b)) => Ok(Const(Bool(a >= b))),
|
|
|
|
|
// (Float(a), Int(b)) => Ok(Const(Bool(a >= b as f64))),
|
|
|
|
|
// (Int(a), Float(b)) => Ok(Const(Bool(a as f64 >= b))),
|
|
|
|
|
// (Float(a), Float(b)) => Ok(Const(Bool(a >= b))),
|
|
|
|
|
// (_, _) => Err(CozoError::TypeError)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// (a, b) => Ok(Apply(Op::Ge, vec![a, b]))
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// _ => unreachable!()
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// fn lt_exprs<'a>(&self, exprs: &[Expr<'a>]) -> Result<Expr<'a>> {
|
|
|
|
|
// match exprs {
|
|
|
|
|
// [a, b] => {
|
|
|
|
|
// let a = self.visit_expr(a)?;
|
|
|
|
|
// let b = self.visit_expr(b)?;
|
|
|
|
|
// if a == Const(Null) || b == Const(Null) {
|
|
|
|
|
// return Ok(Const(Null));
|
|
|
|
|
// }
|
|
|
|
|
// match (a, b) {
|
|
|
|
|
// (Const(a), Const(b)) => {
|
|
|
|
|
// match (a, b) {
|
|
|
|
|
// (Int(a), Int(b)) => Ok(Const(Bool(a < b))),
|
|
|
|
|
// (Float(a), Int(b)) => Ok(Const(Bool(a < b as f64))),
|
|
|
|
|
// (Int(a), Float(b)) => Ok(Const(Bool((a as f64) < b))),
|
|
|
|
|
// (Float(a), Float(b)) => Ok(Const(Bool(a < b))),
|
|
|
|
|
// (_, _) => Err(CozoError::TypeError)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// (a, b) => Ok(Apply(Op::Lt, vec![a, b]))
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// _ => unreachable!()
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// fn le_exprs<'a>(&self, exprs: &[Expr<'a>]) -> Result<Expr<'a>> {
|
|
|
|
|
// match exprs {
|
|
|
|
|
// [a, b] => {
|
|
|
|
|
// let a = self.visit_expr(a)?;
|
|
|
|
|
// let b = self.visit_expr(b)?;
|
|
|
|
|
// if a == Const(Null) || b == Const(Null) {
|
|
|
|
|
// return Ok(Const(Null));
|
|
|
|
|
// }
|
|
|
|
|
// match (a, b) {
|
|
|
|
|
// (Const(a), Const(b)) => {
|
|
|
|
|
// match (a, b) {
|
|
|
|
|
// (Int(a), Int(b)) => Ok(Const(Bool(a <= b))),
|
|
|
|
|
// (Float(a), Int(b)) => Ok(Const(Bool(a <= b as f64))),
|
|
|
|
|
// (Int(a), Float(b)) => Ok(Const(Bool((a as f64) <= b))),
|
|
|
|
|
// (Float(a), Float(b)) => Ok(Const(Bool(a <= b))),
|
|
|
|
|
// (_, _) => Err(CozoError::TypeError)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// (a, b) => Ok(Apply(Op::Le, vec![a, b]))
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// _ => unreachable!()
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// fn pow_exprs<'a>(&self, exprs: &[Expr<'a>]) -> Result<Expr<'a>> {
|
|
|
|
|
// match exprs {
|
|
|
|
|
// [a, b] => {
|
|
|
|
|