protected virtual Out DispatchCompare(CompareVisitor cmp, Expr left, Expr right, Expr original, In data) { if (Decoder.IsConstant(left) && Decoder.OperatorFor(right) == ExpressionOperator.Sub) // const OP (a - b) { int num; if (Decoder.TryValueOf(left, ExpressionType.Int32, out num) && num == 0) { // 0 OP (a-b) ==> b OP a return(cmp(Decoder.RightExpressionFor(right), Decoder.LeftExpressionFor(right), right, data)); } } else if (Decoder.IsConstant(right) && Decoder.OperatorFor(left) == ExpressionOperator.Sub) // (a-b) OP const { int num; if (Decoder.TryValueOf(right, ExpressionType.Int32, out num) && num == 0) { // (a-b) OP 0 ==> a OP b return(cmp(Decoder.LeftExpressionFor(left), Decoder.RightExpressionFor(left), left, data)); } } return(cmp(left, right, original, data)); }
protected override IntervalEnvironmentBase <TVar, TExpr, TInterval, TNumeric> DispatchCompare( CompareVisitor cmp, TExpr left, TExpr right, TExpr original, IntervalEnvironmentBase <TVar, TExpr, TInterval, TNumeric> data) { data = cmp(left, right, original, data); return(base.DispatchCompare(cmp, left, right, original, data)); }