Exemple #1
0
        public void Visit(EquExpr equExpr, object[] args)
        {
            equExpr.FirstOp.Accept(this);
            equExpr.SecondOp.Accept(this);

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


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

            if (resultType == DataType.Int)
            {
                result.Value = Convert.ToInt32(v1.GetValueObject()) == Convert.ToInt32(v2.GetValueObject());
            }
            else if (resultType == DataType.Float)
            {
                kernel.IssueWarning(new Error(ErrorType.EqualOnFloat, equExpr.Location));
                result.Value = Convert.ToDouble(v1.GetValueObject()) == Convert.ToDouble(v2.GetValueObject());
            }
            else
            {
                throw new Exception();
            }
            equExpr.RightValue = result;
        }
        public void Visit(EquExpr equExpr, object[] args)
        {
            equExpr.FirstOp.Accept(this);
            equExpr.SecondOp.Accept(this);

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

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

            }
            else if (resultType == DataType.Float)
            {
                kernel.IssueWarning(new Error(ErrorType.EqualOnFloat, equExpr.Location));
                result.Value = Convert.ToDouble(v1.GetValueObject()) == Convert.ToDouble(v2.GetValueObject());
            }
            else
            {
                throw new Exception();
            }
            equExpr.RightValue = result;
        }