OpCode GetArithmeticOpCode(IType type, BinaryOperatorType op)
{
if (IsCheckedIntegerOperand(type))
{
switch (op)
{
case BinaryOperatorType.Addition: return OpCodes.Add_Ovf;
case BinaryOperatorType.Subtraction: return OpCodes.Sub_Ovf;
case BinaryOperatorType.Multiply: return OpCodes.Mul_Ovf;
case BinaryOperatorType.Division: return OpCodes.Div;
case BinaryOperatorType.Modulus: return OpCodes.Rem;
}
}
else
{
switch (op)
{
case BinaryOperatorType.Addition: return OpCodes.Add;
case BinaryOperatorType.Subtraction: return OpCodes.Sub;
case BinaryOperatorType.Multiply: return OpCodes.Mul;
case BinaryOperatorType.Division: return OpCodes.Div;
case BinaryOperatorType.Modulus: return OpCodes.Rem;
}
}
throw new ArgumentException("op");
}