private List <Object> getValoresParam(Ambito ambito)
        {
            List <Object> valores = new List <object>();

            foreach (Expresion e in this.expresiones)
            {
                //object val = e.getValor(ambito);
                object val = e.getValor(Estatico.temporal);
                if (val != null)
                {
                    valores.Add(val);
                }
            }
            return(valores);
        }
        /*
         * Metodo de la implementacion
         * @ts tabla de simbolos global
         * @user usuario que ejecuta la accion
         * @baseD base de datos donde estamos ejecutando todo
         * @mensajes linkedlist con la salida deseada
         */
        public object ejecutar(TablaDeSimbolos ts, Ambito ambito, TablaDeSimbolos tsT)
        {
            Mensaje             ms       = new Mensaje();
            object              valores  = (expresion == null) ? null : expresion.ejecutar(ts, ambito, tsT);
            LinkedList <string> mensajes = ambito.mensajes;

            if (valores != null)
            {
                if (valores.GetType() == typeof(LinkedList <object>))
                {
                    LinkedList <object> lista = (LinkedList <object>)valores;
                    if (lista.Count() == listaId.Count())
                    {
                        for (int i = 0; i < lista.Count(); i++)
                        {
                            string tipo = ts.getTipo(listaId.ElementAt(i)).ToLower().TrimEnd().TrimStart();
                            if (!tipo.Equals("none"))
                            {
                                object res = checkValues(lista.ElementAt(i), tipo, mensajes, ts, listaId.ElementAt(i));
                                if (res == null)
                                {
                                    return(null);
                                }
                            }
                            else
                            {
                                mensajes.AddLast(ms.error("La variable: " + listaId.ElementAt(i) + " no existe en este ambito", l, c, "Semantico"));
                                return(null);
                            }
                        }
                        return("");
                    }
                    else
                    {
                        mensajes.AddLast(ms.error("No coincide la cantidad de valores con la cantidad de variables", l, c, "Semantico"));
                    }
                }
                else
                {
                    mensajes.AddLast(ms.error("No se puede asignar este valor: " + valores + " a la lista de ID'S", l, c, "Semantico"));
                }
            }
            else
            {
                mensajes.AddLast(ms.error("No se puede asignar un valor null a la lista de ID's", l, c, "Semantico"));
            }
            return(null);
        }
        public object Ejecutar(Ambito ambito)
        {
            try
            {
                object path      = ruta.getValor(ambito);
                object condicion = condicional.getValor(ambito);
                if (path is String && condicion is Boolean)
                {
                    //String currentDir = System.IO.Directory.GetCurrentDirectory() + "\\";

                    String currentDir = Estatico.PROYECT_PATH + "\\";

                    String  cad  = (String)path;
                    Boolean cond = (Boolean)condicion;

                    if (System.IO.File.Exists(cad))
                    {
                        XForms.GUI.Funciones.DisplayImage im = new GUI.Funciones.DisplayImage(cad);
                        im.ShowDialog();
                    }
                    else if (System.IO.File.Exists(currentDir + cad))
                    {
                        XForms.GUI.Funciones.DisplayImage im = new GUI.Funciones.DisplayImage(currentDir + cad);
                        im.ShowDialog();
                    }
                    else
                    {
                        TError error = new TError("Semantico", "La ruta de la Imagen a desplegar no existe, Ruta: \"" + cad + "\" | Tampoco se encontro en el directorio raiz: \"" + currentDir + "\" | Clase: " + clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                        Estatico.ColocaError(error);
                        Estatico.errores.Add(error);
                    }
                    return(new Nulo());
                }
                else
                {
                    TError error = new TError("Semantico", "La funcion Imagen() recibe como parametros unicamente: (Cadena, Booleano) | Clase: " + clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                    Estatico.ColocaError(error);
                    Estatico.errores.Add(error);
                }
            }
            catch (Exception e)
            {
                TError error = new TError("Ejecucion", "Error al ejecutar la funcion Imagen() | Clase: " + clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
                Estatico.ColocaError(error);
                Estatico.errores.Add(error);
            }
            return(new Nulo());
        }
Exemple #4
0
        public FCaso(Ambito amb, String tipo, Object valor)
        {
            this.ambito = amb;
            this.Tipo   = tipo;

            switch (this.Tipo)
            {
            case Constante.TNumber:
                this.ValNumero = Double.Parse(valor.ToString());
                break;

            case Constante.TString:
                this.ValCadena = valor.ToString();
                break;
            }
        }
 public string getTipo(Ambito ambito)
 {
     if (valor is int)
     {
         return("entero");
     }
     if (valor is String)
     {
         return("cadena");
     }
     if (valor is double)
     {
         return("decimal");
     }
     return("nulo");
 }
        public object Ejecutar(Ambito ambito)
        {
            try
            {
                call.getValor(ambito);

                return(new Nulo());
            }
            catch
            {
                TError error = new TError("", "Error en la ejecucion de la llamada a funcion | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                Estatico.errores.Add(error);
                Estatico.ColocaError(error);
            }
            return(new Nulo());
        }
Exemple #7
0
 public object getValor(Ambito ambito)
 {
     try
     {
         Object val = this.valor.getValor(ambito);
         this.val = val.ToString();
         return(this.val);
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al intentar comventir en cadena: Funcion: Cadena() | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new Nulo());
 }
Exemple #8
0
 public object getValor(Ambito ambito)
 {
     try
     {
         DateTime ahora = DateTime.Now;
         Date d = new Date(ahora);
         return d;
     }
     catch(Exception e)
     {
         TError error = new TError("Ejecucion", "Error al ejecutar la funcion hoy() | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return new Nulo();
 }
Exemple #9
0
 public object ejecutar(Ambito amb, AST arbol)
 {
     if ((bool)(Condicion.getValorImplicito(amb, arbol)))
     {
         //Si se cumple
         Ambito local = new Ambito(amb);
         foreach (NodoAST nodo in condInstrucciones)
         {
             if (nodo is Instruccion)
             {
                 Instruccion ins    = (Instruccion)nodo;
                 object      result = ins.ejecutar(local, arbol);
                 if (result != null)
                 {
                     return(result);
                 }
             }
             else if (nodo is Exp)
             {
                 Exp expr = (Exp)nodo;
                 return(expr.getValorImplicito(local, arbol));
             }
         }
     }//Si no se cumple
     else
     {
         Ambito local = new Ambito(amb);
         foreach (NodoAST nodo in InstruccionesElse)
         {
             if (nodo is Instruccion)
             {
                 Instruccion ins    = (Instruccion)nodo;
                 object      result = ins.ejecutar(local, arbol);
                 if (result != null)
                 {
                     return(result);
                 }
             }
             else if (nodo is Exp)
             {
                 Exp expr = (Exp)nodo;
                 return(expr.getValorImplicito(local, arbol));
             }
         }
     }
     return(null);
 }
        private Type dameTipo(Ambito ambitoPregunta)
        {
            Simbolo s = (Simbolo)ambitoPregunta.getSimbolo("respuesta");

            if (s != null)
            {
                String tipo = s.Tipo.ToLower();
                switch (tipo)
                {
                case "booleano":
                {
                    return(typeof(Boolean));
                }

                case "entero":
                {
                    return(typeof(int));
                }

                case "decimal":
                {
                    return(typeof(double));
                }

                case "cadena":
                {
                    return(typeof(String));
                }

                case "fecha":
                {
                    return(typeof(Date));
                }

                case "hora":
                {
                    return(typeof(Hour));
                }

                case "fechahora":
                {
                    return(typeof(DateTime));
                }
                }
            }
            return(null);
        }
Exemple #11
0
 private void declaracionApartirDeArbol(Ambito ambito)
 {
     if (!ambito.existeVariable(this.idArr.ToLower()))
     {
         GeneradorArreglo gen = new GeneradorArreglo(this.arbolArreglo);
         if (!gen.huboError)
         {
             int numaux = gen.numDimensiones;
             if (NumDim == gen.numDimensiones)
             {
                 ///FALTA COMPROBAR SI TODOS LOS ELEMENTOS DEL ARREGLO SON DEL MISMO TIPO
                 ///
                 List <Object> valores = linealizadaValores(gen.linealizacion, ambito);
                 if (valores != null)
                 {
                     Arreglo arr = new Arreglo(this.arbolArreglo, valores, gen.dimensiones, this.NumDim, this.idArr.ToLower(), true, this.visibilidad, this.tipo);
                     ambito.agregarVariableAlAmbito(this.idArr.ToLower(), arr);
                 }
                 else
                 {
                     TError error = new TError("Semantico", "El Arreglo: \"" + this.idArr + "\" no concuerda con el tipo esperado: " + this.tipo + " | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
                     Estatico.errores.Add(error);
                     Estatico.ColocaError(error);
                 }
             }
             else
             {
                 TError error = new TError("Semantico", "Las dimensiones declaradas para: \"" + this.idArr + "\" No concuerdan, Se esperaban: " + this.NumDim + " y se encontro: " + gen.numDimensiones + " | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
                 Estatico.errores.Add(error);
                 Estatico.ColocaError(error);
             }
         }
         else
         {
             TError error = new TError("Semantico", "Declaracion erreonea de Arreglo: \"" + this.idArr + "\" en este Ambito | Error: " + gen.mensajesError + " | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
             Estatico.errores.Add(error);
             Estatico.ColocaError(error);
         }
     }
     else
     {
         TError error = new TError("Semantico", "Ya existe una declaracion de: \"" + this.idArr + "\" en este Ambito | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
 }
 private void ejecutaLasDeclaracionesPregunta(Ambito ambito, List <Instruccion> declaraciones)
 {
     foreach (Instruccion instruccion in declaraciones)
     {
         if (instruccion is DeclaracionFuncion)
         {
             instruccion.Ejecutar(ambito);
         }
     }
     foreach (Instruccion instruccion in declaraciones)
     {
         if (instruccion is DeclaracionVar || instruccion is DeclaracionArreglo)
         {
             instruccion.Ejecutar(ambito);
         }
     }
 }
 public string getTipo(Ambito ambito)
 {
     if (this.valor is bool)
     {
         return("Booleano");
     }
     else if (this.valor is string)
     {
         return("Cadena");
     }
     else if (this.valor is int)
     {
         return("Entero");
     }
     else if (this.valor is double)
     {
         return("Decimal");
     }
     else if (this.valor is System.DateTime)
     {
         return("FechaHora");
     }
     else if (this.valor is Date)
     {
         return("Fecha");
     }
     else if (this.valor is Hour)
     {
         return("Hora");
     }
     else if (this.valor is Nulo)
     {
         return("Nulo");
     }
     else if (this.valor is Objeto)
     {
         Objeto aux = (Objeto)this.valor;
         return(aux.idClase);
     }
     else if (this.valor is Arreglo)
     {
         return("Arreglo");
     }
     //AQUI FALTA EL TIPO OBJETO
     return("Objeto");
 }
Exemple #14
0
        private List <int> getDimensiones(Ambito ambito)
        {
            List <int> dims = new List <int>();

            foreach (Expresion e in this.dimensiones)
            {
                Object valor = e.getValor(ambito);
                if (valor is int)
                {
                    dims.Add((int)valor);
                }
                else
                {
                    return(null);
                }
            }
            return(dims);
        }
Exemple #15
0
                                                  //Actualizar estado
                                                  public async Task UpdateEstado(Ambito Ambito)
                                                  {
                                                      try
                                                      {
                                                          var _Ambito = await _ctx.Ambito.FirstOrDefaultAsync(e => e.AmbitoId == Ambito.AmbitoId);

                                                          if (_Ambito != null)
                                                          {
                                                              _Ambito.estado = Ambito.estado;

                                                              await _ctx.SaveChangesAsync();
                                                          }
                                                      }
                                                      catch (Exception e)
                                                      {
                                                          throw new Exception(e.Message, e);
                                                      }
                                                  }
        public object getValor(Ambito ambito)
        {
            try
            {
                Object cad     = cadena.getValor(ambito);
                String tipoCad = cadena.getTipo(ambito);

                Object pos     = posicion.getValor(ambito);
                String tipoPos = posicion.getTipo(ambito);

                if (cad is String && pos is int)
                {
                    String cadenaAux = (String)cad;
                    int    posi      = (int)pos;
                    if (posi > 0 && posi < cadenaAux.Length)
                    {
                        char aux = cadenaAux[posi];

                        tipo = aux.ToString();

                        return(tipo);
                    }
                    else
                    {
                        TError error = new TError("Semantico", "La funcion PosCad, el parametro entero debe estar dentro de los limites: 0 y " + cadenaAux.Length + " | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                        Estatico.errores.Add(error);
                        Estatico.ColocaError(error);
                    }
                }
                else
                {
                    TError error = new TError("Semantico", "Funcion PosCad requiere parametros: (cadena, entero) y se encontro: (" + tipoCad + "," + tipoPos + ") | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                    Estatico.errores.Add(error);
                    Estatico.ColocaError(error);
                }
            }
            catch (Exception e)
            {
                TError error = new TError("Ejecucion", "Error al ejecutar la funcion Poscade | Clase: " + clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
                Estatico.errores.Add(error);
                Estatico.ColocaError(error);
            }
            return(new Nulo());
        }
Exemple #17
0
                                                  //Actualizar Ambito
                                                  public async Task Update(Ambito Ambito)
                                                  {
                                                      try
                                                      {
                                                          var _Ambito = await _ctx.Ambito.FirstOrDefaultAsync(e => e.AmbitoId == Ambito.AmbitoId);

                                                          if (_Ambito != null)
                                                          {
                                                              _Ambito.Descripcion      = Ambito.Descripcion;
                                                              _Ambito.DescripcionCorta = Ambito.DescripcionCorta;

                                                              await _ctx.SaveChangesAsync();
                                                          }
                                                      }
                                                      catch (Exception e)
                                                      {
                                                          throw new Exception(e.Message, e);
                                                      }
                                                  }
Exemple #18
0
        public object getValor(Ambito ambito)
        {
            try
            {
                Object valor = this.exp.getValor(ambito);
                if (valor is String)
                {
                    String real = (String)valor;

                    try
                    {
                        DateTime aux   = DateTime.ParseExact(real + " 00:00:00", "dd/MM/yyyy hh:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
                        Date     fecha = new Date(aux);
                        this.val = fecha.ToString();
                        return(fecha);
                    }
                    catch
                    {
                        TError error = new TError("Semantico", "No se encontro una cadena que cumpla con el formato: dd/mm/yyyy para la funcion Fecha() / o se ingreso valor invalido | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                        Estatico.errores.Add(error);
                        Estatico.ColocaError(error);
                    }
                }
                else if (valor is Date)
                {
                    this.val = valor.ToString();
                    return(valor);
                }
                else
                {
                    TError error = new TError("Semantico", "La funcion Fecha() recibe como parametros solo una cadena | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                    Estatico.errores.Add(error);
                    Estatico.ColocaError(error);
                }
            }
            catch (Exception e)
            {
                TError error = new TError("Ejecucion", "Error al intentar convertir cadena a Fecha: Funcion: Fecha() | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
                Estatico.errores.Add(error);
                Estatico.ColocaError(error);
            }
            return(new Nulo());
        }
 public object getValor(Ambito ambito)
 {
     try
     {
         Object valor = this.exp.getValor(ambito);
         if (valor is String)
         {
             try
             {
                 String   aux  = (String)valor;
                 DateTime real = DateTime.ParseExact("12/10/1996 " + aux, "dd/MM/yyyy hh:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
                 Hour     hora = new Hour(real);
                 this.val = hora.ToString();
                 return(hora);
             }
             catch
             {
                 TError error = new TError("Semantico", "El formato de la cadena para la funcion Hora() no cumple el formato: hh:mm:ss / o se ingreso valor invalido | Clase: " + clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                 Estatico.ColocaError(error);
                 Estatico.errores.Add(error);
             }
         }
         else if (valor is Hour)
         {
             this.val = valor.ToString();
             return(valor);
         }
         else
         {
             TError error = new TError("Semantico", "La funcion Hora() unicamente puede recibir una cadena como parametro una cadena | Clase: " + clase + " | Archivo: " + ambito.archivo, linea, columna, false);
             Estatico.ColocaError(error);
             Estatico.errores.Add(error);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al intentar convertir cedena a hora, en funcion Hora() | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new Nulo());
 }
        private Opciones dameOpciones(Ambito ambitoObjet)
        {
            try
            {
                Simbolo s = (Simbolo)ambitoObjet.getSimbolo("cutz");
                if (s != null)
                {
                    Variable v = (Variable)s;

                    Opciones op = (Opciones)v.valor;

                    return(op);
                }
                return(new Opciones("nada", new Ambito(null, "nada")));
            }
            catch
            {
                return(new Opciones("nada", new Ambito(null, "nada")));
            }
        }
Exemple #21
0
 /*
  * Metodo de la implementacion
  * @ts tabla de simbolos global
  * @user usuario que ejecuta la accion
  * @baseD base de datos donde estamos ejecutando todo
  * @mensajes linkedlist con la salida deseada
  */
 public object ejecutar(TablaDeSimbolos ts, Ambito ambito, TablaDeSimbolos tsT)
 {
     if (valor != null)
     {
         if (valor.GetType() == typeof(Expresion))
         {
             object res = (valor == null) ? null : ((Expresion)valor).ejecutar(ts, ambito, tsT);
             return(new Retorno(res));
         }
         LinkedList <Expresion> listaExpresiones = (LinkedList <Expresion>)valor;
         LinkedList <object>    valoresReturn    = new LinkedList <object>();
         foreach (Expresion e in listaExpresiones)
         {
             object res = (e == null) ? null : e.ejecutar(ts, ambito, tsT);
             valoresReturn.AddLast(res);
         }
         return(new Retorno(valoresReturn));
     }
     return(new Retorno(null));
 }
 public object getValor(Ambito ambito)
 {
     try
     {
         Estatico.temporal = ambito;      //AQUI SETEO EL TEMPORAL
         if (this.expresiones.Count == 1) //SI SOLO SE HACE REFERENCIA A UN ID O UNA LLAMADA A UNA FUNCION
         {
             this.valorAux = expresiones.ElementAt(0).getValor(ambito);
             if (valorAux is Este)
             {
                 //return new Nulo();
                 return(new Este());
             }
             return(valorAux);
         }
         else if (this.expresiones.Count > 1)//AQUI ES DONDE YA SE VA A HACER REFERENCIA A OBJETOS
         {
             Ambito ambitoAux = null;
             Object auxiliar  = this.expresiones.ElementAt(0).getValor(ambito);
             if (auxiliar is Este)
             {
                 ambitoAux = (Ambito)buscaAtributoDeClase(ambito);
                 return(recorreExpresiones(ambitoAux, auxiliar));
             }
             else if (auxiliar is Objeto)
             {
                 Objeto ob = (Objeto)auxiliar;
                 ambitoAux = ob.ambito;
                 return(recorreExpresiones(ambitoAux, ob));
             }
             return(new Nulo());
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Ocurrio un Error al acceder a Objeto en Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Error: " + e.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new Nulo());
 }
Exemple #23
0
 public object getValor(Ambito ambito)
 {
     try
     {
         Object valor = exp.getValor(ambito);
         if (valor is int)
         {
             int v = (int)valor;
             if (v < 0)
             {
                 this.valor = 0.0; return(0.0);
             }
             this.valor = Math.Log10(v);
             return(this.valor);
         }
         else if (valor is double)
         {
             double v = (double)valor;
             if (v < 0)
             {
                 this.valor = 0.0; return(0.0);
             }
             this.valor = Math.Log10(v);
             return(this.valor);
         }
         else
         {
             TError error = new TError("Semantico", "El parametro que reciba la Funcion Log10() puede ser Entero o Decimal | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
             Estatico.errores.Add(error);
             Estatico.ColocaError(error);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al ejecutar la funcion Log10() | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     this.valor = 0.0;
     return(0.0);
 }
        public object getValor(Ambito ambito)
        {
            try
            {
                if (tipo == 1)
                {
                    int    maximo = this.expresiones.Count - 1;      /// TOMO EL VALOR MAXIMO
                    Random r      = new Random();                    /// FUNCION RANDOM
                    int    index  = r.Next(0, maximo);               /// VALOR DEL INDEX DE LA EXPRESION

                    Expresion v = this.expresiones.ElementAt(index); /// ELEMENTO

                    this.valor = v.getValor(ambito);

                    if (valor is string || valor is int || valor is double)
                    {
                        return(valor);
                    }
                    else
                    {
                        TError error = new TError("Semantico", "La Funcion Random() solo permite retornar valores: Cadena, entero o Decimal | Clase: " + clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                        Estatico.errores.Add(error);
                        Estatico.ColocaError(error);
                    }
                    return(new Nulo());
                }
                else
                {
                    Random r = new Random();
                    this.valor = r.Next(0, 1);
                    return(this.valor);
                }
            }
            catch (Exception e)
            {
                TError error = new TError("Ejecucion", "Error al ejecutar la funcion: Random() | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
                Estatico.errores.Add(error);
                Estatico.ColocaError(error);
            }
            return(new Nulo());
        }
Exemple #25
0
 public object ejecutar(Ambito amb, AST arbol)
 {
     foreach (NodoAST nodo in LLInstrucciones)
     {
         if (nodo is Instruccion)
         {
             Instruccion ins       = (Instruccion)nodo;
             object      objResult = ins.ejecutar(amb, arbol);
             if (objResult != null)
             {
                 if (verificarTipo(this.Tipo, objResult))
                 {
                     return(objResult);
                 }
                 else
                 {
                     Console.WriteLine("error");
                     return(null);
                 }
             }
         }
         else if (nodo is Exp)
         {
             Exp    expr   = (Exp)nodo;
             object result = expr.getValorImplicito(amb, arbol);
             if (result != null)
             {
                 if (expr.getTipo(amb, arbol) == this.Tipo)
                 {
                     return(result);
                 }
                 else
                 {
                     Console.Write("EL tipo del retorno no es el declarado en la funcion");
                     return(null);
                 }
             }
         }
     }
     return(null);
 }
        /*
         * Metodo de la implementacion de la clase InstruccionCQL
         * @ts Tabla de simbolos global
         * @user usuario que ejecuta la accion
         * @baseD base de datos en la que se realizara la accion, es pasada por referencia
         */

        public object ejecutar(TablaDeSimbolos ts, Ambito ambito, TablaDeSimbolos tsT)
        {
            Mensaje        ms      = new Mensaje();
            GuardarArchivo guardar = new GuardarArchivo();

            guardar.guardarArchivo("Principal2");

            foreach (InstruccionCQL ins in cuerpo)
            {
                object respuesta = ins.ejecutar(ts, ambito, tsT);
                if (respuesta == null)
                {
                    ambito.listadoExcepciones.AddLast(new Excepcion("batchexception", "Hubo un error en la ejecucion del batch, Linea: " + l + " Columna: " + c));
                    ambito.mensajes.AddLast(ms.error("Hubo un error en la ejecucion del batch", l, c, "Semantico"));
                    LeerArchivo leer = new LeerArchivo("Principal2.chison");
                    return(null);
                }
            }

            return("");
        }
Exemple #27
0
        internal Variable GetVariable(string id, string ambito)
        {
            Ambito a = GetAmbito(ambito);

            if (a != null)
            {
                foreach (Variable v in a.Variables)
                {
                    if (v.Id.Equals(id))
                    {
                        return(v);
                    }
                }
            }
            if (!ambito.Equals("GLOBAL"))
            {
                return(GetVariable(id, "GLOBAL"));
            }

            return(null);
        }
        /*
         * Constructor de la clase padre
         * @ts tabla de simbolos padre
         * @user usuario que esta ejecutando las acciones
         * @baseD string por referencia de que base de datos estamos trabajando
         * @mensajes el output de la ejecucion
         */
        public object ejecutar(TablaDeSimbolos ts, Ambito ambito, TablaDeSimbolos tsT)
        {
            object  res = ts.getValor(id);
            Mensaje ms  = new Mensaje();

            if (!res.Equals("none"))
            {
                if (res.GetType() == typeof(TypeCursor))
                {
                    if (operacion.Equals("open"))
                    {
                        object tabla = ((TypeCursor)res).consulta.ejecutar(ts, ambito, tsT);
                        if (tabla != null)
                        {
                            ambito.mensajes.RemoveLast();
                            if (tabla.GetType() == typeof(TablaSelect))
                            {
                                ((TypeCursor)res).tabla = (TablaSelect)tabla;
                            }
                        }
                    }
                    else
                    {
                        ((TypeCursor)res).tabla = null;
                    }

                    return("");
                }
                else
                {
                    ambito.mensajes.AddLast(ms.error("La variable tiene que ser de tipo cursor, no se reconoce: " + res, l, c, "Semantico"));
                }
            }
            else
            {
                ambito.mensajes.AddLast(ms.error("No se encuentra la variable: " + id + " en este ambito", l, c, "Semantico"));
            }
            return(null);
        }
Exemple #29
0
        public object getValor(Ambito ambito)
        {
            try
            {
                Ambito ambitoOpcs = new Ambito(null, this.clase, ambito.archivo);                   //CREO EL AMBITO DEL OBJETO

                Opciones listado = new Opciones("opciones", null);                                  // CREO EL LISTADO QUE VA A MANEJAR LOS VALORES

                Variable v = new Variable("cutz", "opciones", Estatico.Vibililidad.LOCAL, listado); // SETEO LA VARIABLE QUE ME VA A GUARDAR EL LISTADO

                ambitoOpcs.agregarVariableAlAmbito("cutz", v);                                      /// LO AGREGO AL AMBITO

                Objeto opciones = new Objeto("opciones", ambitoOpcs);                               /// CREO EL OBJETO OPCIONES


                return(opciones); //LO RETORNO
            }
            catch
            {
            }
            return(new Nulo());
        }
        /*
         * Constructor de la clase padre
         * @ts tabla de simbolos padre
         * @user usuario que esta ejecutando las acciones
         * @baseD string por referencia de que base de datos estamos trabajando
         * @mensajes el output de la ejecucion
         */
        public object ejecutar(TablaDeSimbolos ts, Ambito ambito, TablaDeSimbolos tsT)
        {
            Boolean ejecutar = false;

            foreach (Case c in listado)
            {
                if ((c.isDefault && !ejecutar) || (!c.isDefault))
                {
                    object res = c.ejecutar(ts, ambito, tsT);
                    if (res == null)
                    {
                        return(null);
                    }
                }

                if (c.flag && !ejecutar)
                {
                    ejecutar = c.flag;
                }
            }
            return("");
        }