示例#1
0
        public override Tipo EvaluateSemantic()
        {
            var ltipo = LeftOperand.EvaluateSemantic();
            var rtipo = RightOperand.EvaluateSemantic();

            if (ltipo.GetType() == rtipo.GetType())
            {
                if (ltipo is IntTipo)
                {
                    return(ltipo);
                }
            }
            throw new SemanticException($"No se puede dividir entre tipo: {ltipo} y {rtipo}");
        }
        public override ExpressionCode GenerateCode()
        {
            var leftType  = LeftOperand.EvaluateSemantic();
            var rightType = RightOperand.EvaluateSemantic();

            if (leftType != null && rightType != null)
            {
                var stringCode = "( getIntLeftShiftValue( " + LeftOperand.GenerateCode().Code + " , " +
                                 RightOperand.GenerateCode().Code + " ) )";
                return(new ExpressionCode {
                    Code = stringCode, Type = "int"
                });
            }
            throw new GenerationException("Cannot generate code from null type operand");
        }
示例#3
0
        public override Tipo EvaluateSemantic()
        {
            var ltipo = LeftOperand.EvaluateSemantic();
            var rtipo = RightOperand.EvaluateSemantic();

            if (ltipo.GetType() != rtipo.GetType())
            {
                throw new SemanticException($"No se puede sumar entre tipo: {ltipo} y {rtipo}");
            }
            if (ltipo is IntTipo || ltipo is StringTipo || ltipo is BoolTipo)
            {
                return(ltipo);
            }
            throw new SemanticException($"No se puede sumar entre tipo: {ltipo} y {rtipo}");
        }