Ejemplo n.º 1
0
        static void EmitPrimitive(CljILGen ilg, object val)
        {
            switch (Type.GetTypeCode(val.GetType()))
            {
            case TypeCode.Boolean:
                ilg.EmitBoolean((bool)val); break;

            case TypeCode.Byte:
                ilg.EmitByte((byte)val); break;

            case TypeCode.Char:
                ilg.EmitChar((char)val); break;

            case TypeCode.Decimal:
                ilg.EmitDecimal((decimal)val); break;

            case TypeCode.Double:
                ilg.EmitDouble((double)val); break;

            case TypeCode.Int16:
                ilg.EmitShort((short)val); break;

            case TypeCode.Int32:
                ilg.EmitInt((int)val); break;

            case TypeCode.Int64:
                ilg.EmitLong((long)val); break;

            case TypeCode.SByte:
                ilg.EmitSByte((sbyte)val); break;

            case TypeCode.Single:
                ilg.EmitSingle((float)val); break;

            case TypeCode.UInt16:
                ilg.EmitUShort((ushort)val); break;

            case TypeCode.UInt32:
                ilg.EmitUInt((uint)val); break;

            case TypeCode.UInt64:
                ilg.EmitULong((ulong)val); break;

            default:
                throw new InvalidOperationException("Unknown constant type in EmitPrimitive");
            }
        }
Ejemplo n.º 2
0
 static void EmitPrimitive(CljILGen ilg, object val)
 {
     switch (Type.GetTypeCode(val.GetType()) )
     {
         case TypeCode.Boolean:
             ilg.EmitBoolean((bool)val); break;
         case TypeCode.Byte:
             ilg.EmitByte((byte)val); break;
         case TypeCode.Char:
             ilg.EmitChar((char)val); break;
         case TypeCode.Decimal:
             ilg.EmitDecimal((decimal)val); break;
         case TypeCode.Double:
             ilg.EmitDouble((double)val); break;
         case TypeCode.Int16:
             ilg.EmitShort((short)val); break;
         case TypeCode.Int32:
             ilg.EmitInt((int)val); break;
         case TypeCode.Int64:
             ilg.EmitLong((long)val); break;
         case TypeCode.SByte:
             ilg.EmitSByte((sbyte)val); break;
         case TypeCode.Single:
             ilg.EmitSingle((float)val); break;
         case TypeCode.UInt16:
             ilg.EmitUShort((ushort)val); break;
         case TypeCode.UInt32:
             ilg.EmitUInt((uint)val); break;
         case TypeCode.UInt64:
             ilg.EmitULong((ulong)val); break;
         default:
             throw new InvalidOperationException("Unknown constant type in EmitPrimitive");
     }
 }