private Func <object, object, bool> GenerateBinaryPredicate(OpCode op) => (o0, o1) => (int)GenerateOpMethod(op)(o0, o1) != 0;
/// <summary> /// Computes the bitwise XOR of two values of this type. /// </summary> /// <param name="operand0">Left-hand operand.</param> /// <param name="operand1">Right-hand operand.</param> /// <returns>The result of the operation.</returns> public object Xor(object operand0, object operand1) => GenerateOpMethod(OpCodes.Xor)(operand0, operand1);
/// <summary> /// Computes the bitwise AND of two values of this type. /// </summary> /// <param name="operand0">Left-hand operand.</param> /// <param name="operand1">Right-hand operand.</param> /// <returns>The result of the operation.</returns> public object And(object operand0, object operand1) => GenerateOpMethod(OpCodes.And)(operand0, operand1);
/// <summary> /// Divides two values of this type. /// </summary> /// <param name="operand0">Left-hand operand.</param> /// <param name="operand1">Right-hand operand.</param> /// <returns>The result of the operation.</returns> public object Divide(object operand0, object operand1) { var opcode = IsSigned ? OpCodes.Div : OpCodes.Div_Un; return(GenerateOpMethod(opcode)(operand0, operand1)); }
/// <summary> /// Multiplies two values of this type. /// </summary> /// <param name="operand0">Left-hand operand.</param> /// <param name="operand1">Right-hand operand.</param> /// <param name="checkForOverflow">True to check for and throw an /// exception on overflow; false to ignore overflow.</param> /// <returns>The result of the operation.</returns> public object Multiply(object operand0, object operand1, bool checkForOverflow) { var opcode = checkForOverflow ? (IsSigned ? OpCodes.Mul_Ovf : OpCodes.Mul_Ovf_Un) : OpCodes.Mul; return(GenerateOpMethod(opcode)(operand0, operand1)); }
/// <summary> /// Subtracts two values of this type. /// </summary> /// <param name="operand0">Left-hand operand.</param> /// <param name="operand1">Right-hand operand.</param> /// <param name="checkForOverflow">True to check for and throw an /// exception on overflow; false to ignore overflow.</param> /// <returns>The result of the operation.</returns> public object Subtract(object operand0, object operand1, bool checkForOverflow) { var opcode = checkForOverflow ? (IsSigned ? OpCodes.Sub_Ovf : OpCodes.Sub_Ovf_Un) : OpCodes.Sub; return(GenerateOpMethod(opcode)(operand0, operand1)); }