示例#1
0
        public Retorno compilar(Entorno ent)
        {
            Retorno left          = this.left.compilar(ent);
            Retorno right         = this.right.compilar(ent);
            Tipos   tipoResultado = TablaTipos.obtenerTipo("/", left.type, right.type);

            if (tipoResultado == Tipos.ERROR)
            {
                throw new Error("Semántico", "No se puede evaluar una division entre un " + left.type.tipoToString() + " y un " + right.type.tipoToString(), ent.obtenerAmbito(), linea, columna);
            }
            Tipo      tipo      = new Tipo(tipoResultado);
            Generator generator = Generator.getInstance();
            string    temp      = generator.newTemporal();

            //INTEGER, REAL
            if (right.valorToString().Equals("0"))
            {
                throw new Error("Semántico", "Resultado indefinido, no se puede realizar una division entre 0", ent.obtenerAmbito(), linea, columna);
            }
            generator.addExpression(temp, left.getValue(), right.getValue(), "/");
            return(new Retorno(temp, true, tipo));
        }