public static ILProcessor Sub(this ILProcessor processor, long value) { if (value == 0L) { return(processor); } if (value < 0L && value >= -7L) { return(processor.AddRange(InstructionUtility.LoadConstant(-value)).Add()); } return(processor.AddRange(InstructionUtility.LoadConstant(value)).Sub()); }
public static ILProcessor LdC <T>(this ILProcessor processor, T value) where T : unmanaged { if (typeof(T) == typeof(byte)) { return(processor.Add(InstructionUtility.LoadConstant((sbyte)*(byte *)&value))); } if (typeof(T) == typeof(sbyte)) { return(processor.Add(InstructionUtility.LoadConstant(*(sbyte *)&value))); } if (typeof(T) == typeof(short)) { return(processor.Add(InstructionUtility.LoadConstant(*(short *)&value))); } if (typeof(T) == typeof(ushort)) { return(processor.Add(InstructionUtility.LoadConstant(*(ushort *)&value))); } if (typeof(T) == typeof(int)) { return(processor.Add(InstructionUtility.LoadConstant(*(int *)&value))); } if (typeof(T) == typeof(uint)) { return(processor.Add(InstructionUtility.LoadConstant(*(int *)&value))); } if (typeof(T) == typeof(long)) { return(processor.AddRange(InstructionUtility.LoadConstant(*(long *)&value))); } if (typeof(T) == typeof(ulong)) { return(processor.AddRange(InstructionUtility.LoadConstant(*(long *)&value))); } if (typeof(T) == typeof(float)) { return(processor.Add(InstructionUtility.LoadConstant(*(float *)&value))); } if (typeof(T) == typeof(double)) { return(processor.Add(InstructionUtility.LoadConstant(*(double *)&value))); } if (typeof(T) == typeof(bool)) { return(processor.Add(InstructionUtility.LoadConstant(*(bool *)&value))); } throw new ArgumentException("Type mismatch!" + typeof(T).Name); }
public static ILProcessor Switch <T>(this ILProcessor processor, Instruction[] instructions) => processor.AddRange(InstructionUtility.Switch <T>(instructions));