Esempio n. 1
0
        public override Objeto execute(Entorno entorno)
        {
            if (entorno.ExisteSimbolo(this.nombre))
            {
                Error error = new Error(base.getLinea(), base.getColumna(), Error.Errores.Semantico,
                                        "Error nombre de simbolo duplicado: " + this.nombre);
                Maestra.getInstancia.addError(error);

                throw new Exception("Error nombre de simbolo duplicado");
            }
            else
            {
                Type_obj nuevo_objeto = new Type_obj(this.nombre);
                nuevo_objeto.entorno_type.setAnterior(entorno);
                foreach (Nodo instruccion in declaraciones)
                {
                    try
                    {
                        instruccion.execute(nuevo_objeto.GetEntorno());
                    }catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                        throw new Exception(e.ToString());
                    }
                }
                entorno.setAnterior(null);
                nuevo_objeto.entorno_type.setAnterior(null);
                Simbolo simbolo = new Simbolo(this.nombre, nuevo_objeto, base.getLinea(), base.getColumna());
                entorno.addSimbolo(simbolo, this.nombre);
            }

            return(null);
        }
Esempio n. 2
0
 public Objeto Copia(Objeto entrada)
 {
     if (entrada.getTipo() == Objeto.TipoObjeto.OBJECTS)
     {
         Type_obj salida = new Type_obj();
         salida = (Type_obj)entrada.Clonar_Objeto();
         return(salida);
     }
     else if (entrada.getTipo() == Objeto.TipoObjeto.ARRAY)
     {
         Arreglo salida = new Arreglo();
         salida = (Arreglo)entrada.Clonar_Objeto();
         return(salida);
     }
     return(null);
 }