Ejemplo n.º 1
0
        public void Visit(LessEquExpr lessEquExpr, object[] args)
        {
            lessEquExpr.FirstOp.Accept(this);
            lessEquExpr.SecondOp.Accept(this);

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


            DataType  resultType = readAlgoOperand(v1, v2, lessEquExpr.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();
            }
            lessEquExpr.RightValue = result;
        }
        public void Visit(LessEquExpr lessEquExpr, object[] args)
        {
            lessEquExpr.FirstOp.Accept(this);
            lessEquExpr.SecondOp.Accept(this);

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

            DataType resultType = readAlgoOperand(v1, v2, lessEquExpr.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();
            }
            lessEquExpr.RightValue = result;
        }