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();
}
}