Пример #1
0
        public override int GenerateCode(int loc, IVirtualMachine vm, CheckerInformation info)
        {
            loc = Factor.GenerateCode(loc, vm, info);
            loc = RepFactor.GenerateCode(loc, vm, info);

            var type = GetExpressionType(info);

            if (type == Type.INT32)
            {
                switch (Operator)
                {
                case Operators.TIMES:
                    vm.IntMult(loc++);
                    break;

                case Operators.DIV:
                    vm.IntDiv(loc++);
                    break;

                case Operators.MOD:
                    vm.IntMod(loc++);
                    break;

                default:
                    throw new IVirtualMachine.InternalError(
                              "There's an invalid operator in ASTMultOpr. Operator: " + Operator.ToString());
                }
            }
            else if (type == Type.DECIMAL)
            {
                switch (Operator)
                {
                case Operators.TIMES:
                    vm.DecimalMult(loc++);
                    break;

                case Operators.DIV:
                    vm.DecimalDiv(loc++);
                    break;

                case Operators.MOD:
                    vm.DecimalMod(loc++);
                    break;

                default:
                    throw new IVirtualMachine.InternalError(
                              "There's an invalid operator in ASTMultOpr. Operator: " + Operator.ToString());
                }
            }
            else
            {
                throw new IVirtualMachine.InternalError(
                          "There's an invalid operand in ASTMultOpr. operand: " + type.ToString());
            }
            return(loc);
        }