ABT.TypeCast.IntegralPromotion C# (CSharp) Method

IntegralPromotion() public static method

All integrals are converted to LongType or ULongType.
public static IntegralPromotion ( Expr expr ) : ExprTypeKind>.Tuple
expr Expr /// The integral expression to be casted. ///
return ExprTypeKind>.Tuple
        public static Tuple<Expr, ExprTypeKind> IntegralPromotion(Expr expr) {
            if (!expr.Type.IsIntegral) {
                throw new InvalidProgramException();
            }

            switch (expr.Type.Kind) {
                case ExprTypeKind.CHAR:
                case ExprTypeKind.SHORT:
                case ExprTypeKind.LONG:
                    return Tuple.Create(MakeCast(expr, new LongType(expr.Type.IsConst, expr.Type.IsVolatile)), ExprTypeKind.LONG);

                case ExprTypeKind.UCHAR:
                case ExprTypeKind.USHORT:
                case ExprTypeKind.ULONG:
                    return Tuple.Create(MakeCast(expr, new ULongType(expr.Type.IsConst, expr.Type.IsVolatile)), ExprTypeKind.ULONG);

                default:
                    throw new InvalidProgramException();
            }
        }