コード例 #1
0
        public override object ejecutar(Entorno entorno, Reporte reporte)
        {
            switch (tipo.tipo)
            {
            case Tipos.DOUBLE:
                valorDefecto         = 0;
                tipoDatoValorDefecto = 0;
                break;

            case Tipos.NUMBER:
                valorDefecto         = 0;
                tipoDatoValorDefecto = 0;
                break;

            case Tipos.STRING:
                valorDefecto         = "";
                tipoDatoValorDefecto = 0;
                break;

            case Tipos.BOOLEAN:
                valorDefecto         = false;
                tipoDatoValorDefecto = 0;
                break;

            case Tipos.TYPE:
                Simbolo Valorestype = entorno.types[tipo.tipoAuxiliar];


                if (Valorestype.tipo.tipo == Tipos.ARRAY)
                {
                    //Es un arreglo de arreglos
                    valorDefecto         = new Dictionary <int, object>((Dictionary <int, object>)Valorestype.valor);
                    tipoDatoValorDefecto = 1;
                }
                else
                {
                    //Es un arreglo de objetos
                    valorDefecto         = new Objeto((Objeto)Valorestype.valor);
                    tipoDatoValorDefecto = 2;
                }
                //valorDefecto = entorno.types[tipo.tipoAuxiliar];
                break;
            }


            Arreglo hijo = null;

            foreach (Dictionary <string, int> dimension in dimensiones)
            {
                int min = dimension["min"];
                int max = dimension["max"];
                hijo = new Arreglo(hijo, min, max, this.valorDefecto, tipoDatoValorDefecto);
                hijo.ejecutar(entorno, reporte);
            }

            entorno.declararType(this.nombre, new Simbolo(new Dictionary <int, object>(hijo.diccionario), new Tipo(Tipos.ARRAY, null), nombre), fila, columna);
            if (tipo.tipoAuxiliar != null)
            {
                entorno.tipoArreglo.Add(nombre, entorno.types[tipo.tipoAuxiliar].tipo.tipo);
            }
            else
            {
                entorno.tipoArreglo.Add(nombre, tipo.tipo);
            }


            return(null);
        }