示例#1
0
        public static DataType?GetResult(this ArithmeticOperation operation, DataType operand)
        {
            Contract.Requires(operation.IsUnary());
            Contract.Requires(operand.IsStackType());

            // ECMA 335 III.1.5 Table 3: Unary Numeric Operations (neg - plus 'not')
            switch (operation)
            {
            case ArithmeticOperation.Negate: return(operand.IsNumericStackType() ? operand : (DataType?)null);

            case ArithmeticOperation.BitwiseNot: return(operand.IsIntegerStackType() ? operand : (DataType?)null);

            default: throw new ArgumentException("operation");
            }
        }