internal static bool IsIntegerConstant(TypeUsage valueType, object value, long expectedValue)
        {
            if (!TypeSemantics.IsIntegerNumericType(valueType) || value == null)
            {
                return(false);
            }
            switch (((PrimitiveType)valueType.EdmType).PrimitiveTypeKind)
            {
            case PrimitiveTypeKind.Byte:
                return(expectedValue == (long)(byte)value);

            case PrimitiveTypeKind.SByte:
                return(expectedValue == (long)(sbyte)value);

            case PrimitiveTypeKind.Int16:
                return(expectedValue == (long)(short)value);

            case PrimitiveTypeKind.Int32:
                return(expectedValue == (long)(int)value);

            case PrimitiveTypeKind.Int64:
                return(expectedValue == (long)value);

            default:
                return(false);
            }
        }
Ejemplo n.º 2
0
 public override void Visit(ConstrainedSortOp op, Node n)
 {
     base.Visit(op, n);
     AssertScalarOp(n.Child1.Op);
     Assert(TypeSemantics.IsIntegerNumericType(n.Child1.Op.Type), "ConstrainedSortOp Skip Count Node must have an integer result type");
     AssertScalarOp(n.Child2.Op);
     Assert(TypeSemantics.IsIntegerNumericType(n.Child2.Op.Type), "ConstrainedSortOp Limit Node must have an integer result type");
 }
Ejemplo n.º 3
0
        internal static bool IsIntegerConstant(TypeUsage valueType, object value, long expectedValue)
        {
            if (!TypeSemantics.IsIntegerNumericType(valueType))
            {
                return(false);
            }

            if (null == value)
            {
                return(false);
            }

            var intType = (PrimitiveType)valueType.EdmType;

            switch (intType.PrimitiveTypeKind)
            {
            case PrimitiveTypeKind.Byte:
                return(expectedValue == (byte)value);

            case PrimitiveTypeKind.Int16:
                return(expectedValue == (short)value);

            case PrimitiveTypeKind.Int32:
                return(expectedValue == (int)value);

            case PrimitiveTypeKind.Int64:
                return(expectedValue == (long)value);

            case PrimitiveTypeKind.SByte:
                return(expectedValue == (sbyte)value);

            default:
            {
                Debug.Assert(false, "Integer primitive type was not one of Byte, Int16, Int32, Int64, SByte?");
                return(false);
            }
            }
        }