Here are the examples of the csharp api System.Reflection.Emit.ILGenerator.EmitInt(int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
10 Examples
19
Source : EmitExtensions.cs
with MIT License
from fs7744
with MIT License
from fs7744
public static void EmitByte(this ILGenerator il, byte value)
{
il.EmitInt(value);
il.Emit(OpCodes.Conv_U1);
}
19
Source : EmitExtensions.cs
with MIT License
from fs7744
with MIT License
from fs7744
public static void EmitSByte(this ILGenerator il, sbyte value)
{
il.EmitInt(value);
il.Emit(OpCodes.Conv_I1);
}
19
Source : EmitExtensions.cs
with MIT License
from fs7744
with MIT License
from fs7744
public static void EmitShort(this ILGenerator il, short value)
{
il.EmitInt(value);
il.Emit(OpCodes.Conv_I2);
}
19
Source : EmitExtensions.cs
with MIT License
from fs7744
with MIT License
from fs7744
public static void EmitUShort(this ILGenerator il, ushort value)
{
il.EmitInt(value);
il.Emit(OpCodes.Conv_U2);
}
19
Source : EmitExtensions.cs
with MIT License
from fs7744
with MIT License
from fs7744
public static void EmitUInt(this ILGenerator il, uint value)
{
il.EmitInt((int)value);
il.Emit(OpCodes.Conv_U4);
}
19
Source : EmitExtensions.cs
with MIT License
from fs7744
with MIT License
from fs7744
public static void EmitDecimal(this ILGenerator il, decimal value)
{
if (Decimal.Truncate(value) == value)
{
if (Int32.MinValue <= value && value <= Int32.MaxValue)
{
int intValue = Decimal.ToInt32(value);
il.EmitInt(intValue);
il.Emit(OpCodes.Newobj, typeof(Decimal).GetTypeInfo().GetConstructor(new Type[] { typeof(int) }));
}
else if (Int64.MinValue <= value && value <= Int64.MaxValue)
{
long longValue = Decimal.ToInt64(value);
il.EmitLong(longValue);
il.Emit(OpCodes.Newobj, typeof(Decimal).GetTypeInfo().GetConstructor(new Type[] { typeof(long) }));
}
else
{
il.EmitDecimalBits(value);
}
}
else
{
il.EmitDecimalBits(value);
}
}
19
Source : EmitExtensions.cs
with MIT License
from fs7744
with MIT License
from fs7744
private static void EmitDecimalBits(this ILGenerator il, decimal value)
{
int[] bits = Decimal.GetBits(value);
il.EmitInt(bits[0]);
il.EmitInt(bits[1]);
il.EmitInt(bits[2]);
il.EmitBoolean((bits[3] & 0x80000000) != 0);
il.EmitByte((byte)(bits[3] >> 16));
il.Emit(OpCodes.Newobj, typeof(decimal).GetTypeInfo().GetConstructor(new Type[] { typeof(int), typeof(int), typeof(int), typeof(bool), typeof(byte) }));
}
19
Source : EmitExtensions.cs
with MIT License
from fs7744
with MIT License
from fs7744
public static void EmitArray(this ILGenerator il, Array items, Type elementType)
{
il.EmitInt(items.Length);
il.Emit(OpCodes.Newarr, elementType);
for (int i = 0; i < items.Length; i++)
{
il.Emit(OpCodes.Dup);
il.EmitInt(i);
il.EmitConstant(items.GetValue(i), elementType);
il.EmitStoreElement(elementType);
}
}
19
Source : EmitExtensions.cs
with MIT License
from fs7744
with MIT License
from fs7744
private static bool TryEmitILConstant(this ILGenerator il, object value, Type type)
{
switch (Type.GetTypeCode(type))
{
case TypeCode.Boolean:
il.EmitBoolean((bool)value);
return true;
case TypeCode.SByte:
il.EmitSByte((sbyte)value);
return true;
case TypeCode.Int16:
il.EmitShort((short)value);
return true;
case TypeCode.Int32:
il.EmitInt((int)value);
return true;
case TypeCode.Int64:
il.EmitLong((long)value);
return true;
case TypeCode.Single:
il.EmitSingle((float)value);
return true;
case TypeCode.Double:
il.EmitDouble((double)value);
return true;
case TypeCode.Char:
il.EmitChar((char)value);
return true;
case TypeCode.Byte:
il.EmitByte((byte)value);
return true;
case TypeCode.UInt16:
il.EmitUShort((ushort)value);
return true;
case TypeCode.UInt32:
il.EmitUInt((uint)value);
return true;
case TypeCode.UInt64:
il.EmitULong((ulong)value);
return true;
case TypeCode.Decimal:
il.EmitDecimal((decimal)value);
return true;
case TypeCode.String:
il.EmitString((string)value);
return true;
default:
return false;
}
}
19
Source : EmitExtensions.cs
with MIT License
from fs7744
with MIT License
from fs7744
public static void EmitChar(this ILGenerator il, char value)
{
il.EmitInt(value);
il.Emit(OpCodes.Conv_U2);
}