Exemple #1
0
            private int OneCompare(ValueTableRow x, ValueTableRow y, ValueTableSortRule Rule)
            {
                IValue xValue = x.Get(Rule.Column);
                IValue yValue = y.Get(Rule.Column);

                int result = xValue.CompareTo(yValue) * Rule.direction;

                return(result);
            }
Exemple #2
0
            public override int Compare(IValue o1, IValue o2)
            {
                context.setValue(arrow.Arguments[0], o1);
                IValue key1 = arrow.Statements.interpret(context);

                context.setValue(arrow.Arguments[0], o2);
                IValue key2   = arrow.Statements.interpret(context);
                int    result = key1.CompareTo(context, key2);

                return(descending ? -result : result);
            }
Exemple #3
0
 protected IValue Max(IValue first, IValue second)
 {
     if (first.CompareTo(second) >= 0)
     {
         return(first);
     }
     else
     {
         return(second);
     }
 }
Exemple #4
0
 private int SafeCompare(IValue x, IValue y)
 {
     try
     {
         return(x.CompareTo(y));
     }
     catch (RuntimeException)
     {
         // Сравнение типов не поддерживается
         return(x.AsString().CompareTo(y.AsString()));
     }
 }
Exemple #5
0
        private BooleanValue compare(Context context, IValue lval, IValue rval)
        {
            Int32 cmp = lval.CompareTo(context, rval);

            switch (oper)
            {
            case CmpOp.GT:
                return(BooleanValue.ValueOf(cmp > 0));

            case CmpOp.LT:
                return(BooleanValue.ValueOf(cmp < 0));

            case CmpOp.GTE:
                return(BooleanValue.ValueOf(cmp >= 0));

            case CmpOp.LTE:
                return(BooleanValue.ValueOf(cmp <= 0));

            default:
                throw new SyntaxError("Illegal compare operand: " + oper.ToString());
            }
        }
Exemple #6
0
 /// <summary>
 /// Меньше
 /// </summary>
 /// <param name="left"></param>
 /// <param name="right"></param>
 /// <returns></returns>
 public static IValue LE(IValue left, IValue right)
 {
     return(Create(left.CompareTo(right) <= 0));
 }