Boo.Lang.Compiler.Steps.ConstantFolding.GetFoldedIntegerLiteral C# (CSharp) Метод

GetFoldedIntegerLiteral() статический приватный Метод

static private GetFoldedIntegerLiteral ( BinaryOperatorType @operator, long lhs, long rhs ) : LiteralExpression
@operator BinaryOperatorType
lhs long
rhs long
Результат Boo.Lang.Compiler.Ast.LiteralExpression
        static LiteralExpression GetFoldedIntegerLiteral(BinaryOperatorType @operator, long lhs, long rhs)
        {
            long result;

            switch (@operator)
            {
                //arithmetic
                case BinaryOperatorType.Addition:
                    result = lhs + rhs;
                    break;
                case BinaryOperatorType.Subtraction:
                    result = lhs - rhs;
                    break;
                case BinaryOperatorType.Multiply:
                    result = lhs * rhs;
                    break;
                case BinaryOperatorType.Division:
                    result = lhs / rhs;
                    break;
                case BinaryOperatorType.Modulus:
                    result = lhs % rhs;
                    break;
                case BinaryOperatorType.Exponentiation:
                    result = (long) Math.Pow(lhs, rhs);
                    break;

                //bitwise
                case BinaryOperatorType.BitwiseOr:
                    result = lhs | rhs;
                    break;
                case BinaryOperatorType.BitwiseAnd:
                    result = lhs & rhs;
                    break;
                case BinaryOperatorType.ExclusiveOr:
                    result = lhs ^ rhs;
                    break;
                case BinaryOperatorType.ShiftLeft:
                    result = lhs << (int) rhs;
                    break;
                case BinaryOperatorType.ShiftRight:
                    result = lhs >> (int) rhs;
                    break;

                //comparison
                case BinaryOperatorType.LessThan:
                    return new BoolLiteralExpression(lhs < rhs);
                case BinaryOperatorType.LessThanOrEqual:
                    return new BoolLiteralExpression(lhs <= rhs);
                case BinaryOperatorType.GreaterThan:
                    return new BoolLiteralExpression(lhs > rhs);
                case BinaryOperatorType.GreaterThanOrEqual:
                    return new BoolLiteralExpression(lhs >= rhs);
                case BinaryOperatorType.Equality:
                    return new BoolLiteralExpression(lhs == rhs);
                case BinaryOperatorType.Inequality:
                    return new BoolLiteralExpression(lhs != rhs);

                default:
                    return null; //not supported
            }
            return new IntegerLiteralExpression(result);
        }

Same methods

ConstantFolding::GetFoldedIntegerLiteral ( BinaryOperatorType @operator, ulong lhs, ulong rhs ) : LiteralExpression
ConstantFolding::GetFoldedIntegerLiteral ( UnaryOperatorType @operator, long operand ) : LiteralExpression