Пример #1
0
        public void Visit(GreatExpr greatExpr, object[] args)
        {
            greatExpr.FirstOp.Accept(this);
            greatExpr.SecondOp.Accept(this);

            RightValue v1 = readRightValue(greatExpr.FirstOp);
            RightValue v2 = readRightValue(greatExpr.SecondOp);


            DataType  resultType = readAlgoOperand(v1, v2, greatExpr.Location);
            BoolConst result     = new BoolConst();

            if (resultType == DataType.Int)
            {
                result.Value = Convert.ToInt32(v1.GetValueObject()) > Convert.ToInt32(v2.GetValueObject());
            }
            else if (resultType == DataType.Float)
            {
                result.Value = Convert.ToDouble(v1.GetValueObject()) > Convert.ToDouble(v2.GetValueObject());
            }
            else
            {
                throw new Exception();
            }
            greatExpr.RightValue = result;
        }
        public void Visit(GreatExpr greatExpr, object[] args)
        {
            greatExpr.FirstOp.Accept(this);
            greatExpr.SecondOp.Accept(this);

            RightValue v1 = readRightValue(greatExpr.FirstOp);
            RightValue v2 = readRightValue(greatExpr.SecondOp);

            DataType resultType = readAlgoOperand(v1, v2, greatExpr.Location);
            BoolConst result = new BoolConst();
            if (resultType == DataType.Int)
            {
                result.Value = Convert.ToInt32(v1.GetValueObject()) > Convert.ToInt32(v2.GetValueObject());

            }
            else if (resultType == DataType.Float)
            {
                result.Value = Convert.ToDouble(v1.GetValueObject()) > Convert.ToDouble(v2.GetValueObject());
            }
            else
            {
                throw new Exception();
            }
            greatExpr.RightValue = result;
        }