Ejemplo n.º 1
0
 public override bool Equals(object obj)
 {
     if (obj is ClaveFuncion)
     {
         ClaveFuncion aux = (ClaveFuncion)obj;
         //ES IGUAL EL NOMNBRE DE LA FUNCION, TIPO Y NUMERO DE PARAMETROS?
         if (this.idFuncion == aux.idFuncion && this.Tipo == aux.Tipo && this.parametros.Count == aux.parametros.Count)
         {
             for (int x = 0; x < this.parametros.Count; x++)
             {
                 if (!this.parametros.ElementAt(x).Equals(aux.parametros.ElementAt(x)))
                 {
                     this.mensajeError = "Parametro: " + this.parametros.ElementAt(x).idparam + ", no concuerda en: " + this.parametros.ElementAt(x).mensajeError;
                     return(false);
                 }
             }
             return(true);
         }
         mensajeError = "No se encontro una funcion: \"" + this.idFuncion + "\" de tipo: \"" + this.Tipo + "\" que reciba: \"" + this.parametros.Count + "\" cantidad de parametros";
         return(false);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
        public Pregunta getPregunta(Ambito ambito)
        {
            try
            {
                Simbolo s = (Simbolo)ambito.getSimbolo(this.identificador.ToLower());
                if (s != null)
                {
                    if (s is Variable)
                    {
                        Variable v     = (Variable)s;
                        Object   valor = v.valor;
                        if (valor is Objeto)
                        {
                            Objeto        ob      = (Objeto)valor;
                            List <Object> valores = getValoresParams(ambito);
                            this.ob = ob;
                            if (ob.idClase.ToLower().Equals("pregunta"))
                            {
                                Ambito       ambitoPregunta = ob.ambito; /*oteniendo el ambito de la pregunta*/
                                ClaveFuncion clave          = new ClaveFuncion(this.identificador.ToLower(), "vacio", getNodosParametros(ambito));
                                Constructor  constructor    = (Constructor)ambitoPregunta.getConstructor(clave);
                                if (constructor != null)
                                {
                                    Variable           instruc       = (Variable)ambitoPregunta.getSimbolo("instr");
                                    List <Instruccion> declaraciones = (List <Instruccion>)instruc.valor;/*ya tengo las instrucciones que hacen la ejecucion de delcaraciones*/
                                    if (existePropiedad("etiqueta", ambitoPregunta))
                                    {
                                        /*EN CASO QUE LA PROPIEDAD YA EXISTA EN LA PREGUNTA: RESETEO EL AMBITO*/
                                        ambitoPregunta = new Ambito(ambitoPregunta.Anterior, ambitoPregunta.idAmbito, ambitoPregunta.archivo);
                                        ambitoPregunta.agregarConstructor(clave, constructor);
                                        ambitoPregunta.agregarVariableAlAmbito("instr", instruc);
                                    }

                                    ambitoPregunta = constructor.seteaParametrosLocales(ambitoPregunta, valores);
                                    ejecutaLasDeclaracionesPregunta(ambitoPregunta, declaraciones);                       /*carga todo lo de la pregunta*/

                                    Pregunta p = new Pregunta(ambitoPregunta, this.identificador.ToLower(), this.numero); // formo la pregunta

                                    this.ambPregu = ambitoPregunta;

                                    return(p);
                                }
                                else
                                {
                                    TError error = new TError("Semantico", "Para el simbolo: \"" + identificador + "\" No existe una pregunta de tipo " + this.tipoPregunta + " que rebiba los parametros especificados | Clase: " + clase + " | Archivo: " + ambito.archivo, linea, col, false);
                                    Estatico.ColocaError(error);
                                    Estatico.errores.Add(error);
                                }
                            }
                            else
                            {
                                TError error = new TError("Semantico", "Error Al Mostrar Pregunta: \"" + this.identificador + "\" ya que El simbolo  no es de Tipo " + this.tipoPregunta + " | Clase: " + clase + " | Archivo: " + ambito.archivo, linea, col, false);
                                Estatico.errores.Add(error);
                                Estatico.ColocaError(error);
                            }
                        }
                        else
                        {
                            TError error = new TError("Semantico", "Error Al Mostrar Pregunta: \"" + this.identificador + "\" ya que El simbolo  no es de Tipo " + this.tipoPregunta + " | Clase: " + clase + " | Archivo: " + ambito.archivo, linea, col, false);
                            Estatico.errores.Add(error);
                            Estatico.ColocaError(error);
                        }
                    }
                    else
                    {
                        TError error = new TError("Semantico", "Error Al Mostrar Pregunta: \"" + this.identificador + "\" ya que El simbolo  no es de Tipo " + this.tipoPregunta + " | Clase: " + clase + " | Archivo: " + ambito.archivo, linea, col, false);
                        Estatico.errores.Add(error);
                        Estatico.ColocaError(error);
                    }
                }
                else
                {
                    TError error = new TError("Semantico", "Error Al Mostrar Pregunta: \"" + this.identificador + "\" ya que este Simbolo no Existe en este Contexto | Clase: " + clase + " | Archivo: " + ambito.archivo, linea, col, false);
                    Estatico.errores.Add(error);
                    Estatico.ColocaError(error);
                }
            }
            catch (Exception e)
            {
                TError error = new TError("Ejecucion", "Error al ejecutar Pregunta: " + this.identificador + " | Clase: " + clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, col, false);
                Estatico.ColocaError(error);
                Estatico.errores.Add(error);
            }
            return(null);
        }