- } else if (expr_type == TypeManager.intptr_type){
- if (real_target_type == TypeManager.uint64_type){
- return EmptyCast.Create (new OperatorCast (expr, TypeManager.int64_type, true),
- TypeManager.uint64_type);
+ break;
+ case BuiltinTypeSpec.Type.IntPtr:
+ if (target_type.BuiltinType == BuiltinTypeSpec.Type.UInt)
+ return EmptyCast.Create (new OperatorCast (expr, expr.Type, rc.BuiltinTypes.Int, true), target_type);
+ if (target_type.BuiltinType == BuiltinTypeSpec.Type.ULong)
+ return EmptyCast.Create (new OperatorCast (expr, expr.Type, rc.BuiltinTypes.Long, true), target_type);
+
+ break;
+ case BuiltinTypeSpec.Type.Decimal:
+ // From decimal to sbyte, byte, short,
+ // ushort, int, uint, long, ulong, char,
+ // float, or double
+ switch (target_type.BuiltinType) {
+ case BuiltinTypeSpec.Type.SByte:
+ case BuiltinTypeSpec.Type.Byte:
+ case BuiltinTypeSpec.Type.Short:
+ case BuiltinTypeSpec.Type.UShort:
+ case BuiltinTypeSpec.Type.Int:
+ case BuiltinTypeSpec.Type.UInt:
+ case BuiltinTypeSpec.Type.Long:
+ case BuiltinTypeSpec.Type.ULong:
+ case BuiltinTypeSpec.Type.Char:
+ case BuiltinTypeSpec.Type.Float:
+ case BuiltinTypeSpec.Type.Double:
+ return new OperatorCast (expr, expr.Type, target_type, true);