public virtual void Visit(ArithmeticExpression operand)
        {
            bool oldInArithmetic = _inArithmetic;

            _inArithmetic = true;
            operand.Left().Accept(this);
            operand.Right().Accept(this);
            ITypeRef operandType = ArithmeticType(operand);

            switch (operand.Op().Id())
            {
            case ArithmeticOperator.AddId:
            {
                _methodBuilder.Add(operandType);
                break;
            }

            case ArithmeticOperator.SubtractId:
            {
                _methodBuilder.Subtract(operandType);
                break;
            }

            case ArithmeticOperator.MultiplyId:
            {
                _methodBuilder.Multiply(operandType);
                break;
            }

            case ArithmeticOperator.DivideId:
            {
                _methodBuilder.Divide(operandType);
                break;
            }

            case ArithmeticOperator.ModuloId:
            {
                _methodBuilder.Modulo(operandType);
                break;
            }

            default:
            {
                throw new Exception("Unknown operand: " + operand.Op());
            }
            }
            Box(_opClass, !oldInArithmetic);
            _inArithmetic = oldInArithmetic;
        }
Example #2
0
        public void Visit(ArithmeticExpression operand)
        {
            operand.Left().Accept(this);
            object left = _value;

            operand.Right().Accept(this);
            object right = _value;

            switch (operand.Op().Id())
            {
            case ArithmeticOperator.AddId:
            {
                _value = Add(left, right);
                break;
            }

            case ArithmeticOperator.SubtractId:
            {
                _value = Subtract(left, right);
                break;
            }

            case ArithmeticOperator.MultiplyId:
            {
                _value = Multiply(left, right);
                break;
            }

            case ArithmeticOperator.DivideId:
            {
                _value = Divide(left, right);
                break;
            }
            }
        }