コード例 #1
0
 public object Ejecutar(Ambito ambito)
 {
     try
     {
         Object objeto = ObjetoAsignar.getValor(ambito);
         if (objeto is Objeto)
         {
             Objeto aux   = (Objeto)objeto;
             Ambito ambOb = aux.ambito;
             asignacionValor.Ejecutar(ambOb);
         }
         else //EN CASO DE QUE NO FUERA OBJETO
         {
             TError error = new TError("Semantico", "Se esta intentando asignar a un Tipo de dato que no es Objeto! | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
             Estatico.errores.Add(error);
             Estatico.ColocaError(error);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error de Ejecucion al intentar asignar posicion de un Arreglo | " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(null);
 }
コード例 #2
0
        protected override void DoWork()
        {
            String sUrl = mUrl;

            while (true)
            {
                while (NeedToPause())
                {
                    Thread.Sleep(1000);
                }
                if (NeedToStop())
                {
                    break;
                }

                if (mUrl.Length > 0)
                {
                    TError   value = checkGetError(sUrl, mLogger);
                    DateTime time  = DateTime.Now;
                    SetResult(value.ToString());
                }

                Thread.Sleep(60 * 1000);
            }
        }
コード例 #3
0
 public object Ejecutar(Ambito ambito)
 {
     try
     {
         ClaveFuncion clave = new ClaveFuncion(this.clase.ToLower(), "vacio", this.parametros);
         if (!ambito.existeConstructor(clave))
         {
             Constructor c = new Constructor(this.parametros, instrucciones, this.linea, this.columna, this.clase);
             ambito.agregarConstructor(clave, c);
         }
         else
         {
             TError error = new TError("Semantico", "Ya existe una definicion de Constructor: " + this.clase + " con la misma cantidad de parametros y tipo | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
             Estatico.errores.Add(error);
             Estatico.ColocaError(error);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error en la ejecucion de Declaracion de Constructor: " + this.clase + " | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Error: " + e.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(null);
 }
コード例 #4
0
 public object Ejecutar(Ambito ambito)
 {
     try
     {
         foreach (Object ob in this.instrucciones)
         {
             if (ob is Instruccion)
             {
                 Instruccion aux = (Instruccion)ob;
                 Object      res = aux.Ejecutar(ambito);
                 if (res is NodoReturn)
                 {
                     return(res);
                 }
             }
             else if (ob is Expresion)
             {
                 Expresion exp = (Expresion)ob;
                 Object    res = exp.getValor(ambito);
                 if (res is NodoReturn)
                 {
                     return(res);
                 }
             }
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al Ejecutar la funcion: " + idFuncion + " | Error: " + e.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new NodoReturn(new Vacio(), "vacio"));
 }
コード例 #5
0
 public object getValor(Ambito ambito)
 {
     try
     {
         Object valor = exp.getValor(ambito);
         if (valor is int)
         {
             int v = (int)valor;
             this.valor = Math.Tan(v);
             return(this.valor);
         }
         else if (valor is double)
         {
             double v = (double)valor;
             this.valor = Math.Tan(v);
             return(this.valor);
         }
         else
         {
             TError error = new TError("Semantico", "El parametro que reciba la Funcion Tan() 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 Tan() | 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);
 }
コード例 #6
0
 public object Ejecutar(Ambito ambito)
 {
     try
     {
         List <Object> valores = getValoresParam(ambito);
         ClaveFuncion  clave   = new ClaveFuncion("padre", "vacio", getNodoParametros(ambito));
         Ambito        aux     = buscaElGlobal(ambito);
         Constructor   c       = aux.getConstructor(clave);
         if (c != null)
         {
             Ambito local = new Ambito(ambito, "padre", ambito.archivo);
             local = c.seteaParametrosLocales(local, valores);
             c.Ejecutar(local);
             return(new Nulo());
         }
         else if (c == null && this.expresiones.Count == 0)
         {
             return(new Nulo());
         }
         else
         {
             TError error = new TError("Ejecucion", "No existe un construcotr de la clase padre que contenga los parametros indicados en Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
             Estatico.errores.Add(error);
             Estatico.ColocaError(error);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al intentar ejecutar Super 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());
 }
コード例 #7
0
 public object getValor(Ambito ambito)
 {
     try
     {
         if (retornaVacio)
         {
             this.ValorAux = new Vacio();
             NodoReturn n = new NodoReturn(this.ValorAux, "vacio");
             return(n);
         }
         else
         {
             this.ValorAux = this.expresion.getValor(ambito);
             NodoReturn n = new NodoReturn(this.ValorAux, getTipo(ambito).ToLower());
             return(n);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "No se ejecuto de buena forma el retorno: Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | " + e.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new Vacio());
 }
コード例 #8
0
        public object Ejecutar(Ambito ambito)
        {
            try
            {
                DamePregunta dame = new DamePregunta(identificador, parametros, clase, linea, columna, estilo.tipo, "", this.numero);
                Pregunta     p    = dame.getPregunta(ambito);
                if (p != null)
                {
                    Objeto ob       = dame.ob;
                    Ambito auxiliar = dame.ambPregu;

                    llamadaACalcular(auxiliar, null);

                    llamadaACalcular(auxiliar, null);

                    ob.ambito = dame.ambPregu;
                }
            }
            catch (Exception e)
            {
                TError error = new TError("Ejecucion", "Error al ejecutar el metodo Calcular: " + this.identificador + " | Clase: " + clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
                Estatico.ColocaError(error);
                Estatico.errores.Add(error);
            }
            return(new Nulo());
        }
コード例 #9
0
 public object getValor(Ambito ambito)
 {
     try
     {
         //ESTA FUNCION AUN HAY QYE MEJORARLA
         object valorReal = this.exp.getValor(ambito);
         String tam       = valorReal.ToString();
         if (valorReal is Nulo)
         {
             return(0);
         }
         else
         {
             val = "entero";
             return(tam.Length);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al ejecutar la funcion: Tam() | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(0);
 }
コード例 #10
0
 private Ambito soobreEscribeParams(Constructor c, Ambito m, List <Object> valores)
 {
     try
     {
         if (valores.Count == c.parametros.Count)
         {
             for (int x = 0; x < valores.Count; x++)
             {
                 String   tipo = c.parametros.ElementAt(x).tipo.ToLower();
                 String   id   = c.parametros.ElementAt(x).idparam.ToLower();
                 Variable v    = new Variable(id, tipo, Estatico.Vibililidad.LOCAL, valores.ElementAt(x));
                 if (m.existeVariable(id.ToLower()))
                 {
                     Simbolo  s   = m.getSimbolo(id.ToLower());
                     Variable aux = (Variable)s;
                     aux.valor = v.valor;
                 }
             }
         }
     }
     catch
     {
         TError error = new TError("Ejecucion", "Error al ejecutar los parametros en clase: " + this.clase, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(m);
 }
コード例 #11
0
 public object Ejecutar(Ambito ambito)
 {
     try
     {
         Clave clave = new Clave(this.idfuncion.ToLower(), this.parametros, "");
         if (!ambito.existeFuncion(clave))
         {
             Funcion f = new Funcion(this.instrucciones, this.parametros, this.idfuncion.ToLower(), this.tipo, this.visibilidad, this.linea, this.columna, this.clase);
             ambito.agregarFuncionAlAmbito(clave, f);
         }
         else
         {
             TError error = new TError("Semantico", "Ya existe una definicion de Funcion: " + this.idfuncion + " con la misma cantidad de parametros y tipo | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
             Estatico.errores.Add(error);
             Estatico.ColocaError(error);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error en la ejecucion de Declaracion de Funcion: " + this.idfuncion + " | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Error: " + e.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(null);
 }
コード例 #12
0
 public static Result <TError, TResultData> MakeFailure(TError Error = default)
 {
     return(new Result <TError, TResultData>
     {
         Success = false,
         Error = Error
     });
 }
コード例 #13
0
 public object getValor(Ambito ambito)
 {
     try
     {
         Simbolo s = (Simbolo)ambito.getSimbolo(this.id.ToLower());
         if (s != null)
         {
             if (s is Arreglo)
             {
                 Arreglo    aux        = (Arreglo)s;
                 List <int> coordenada = getDimensiones(ambito);
                 if (coordenada != null)
                 {
                     if (aux.esCoordenadaValida(coordenada))
                     {
                         int    realIndex = aux.calcularPosicion(coordenada);
                         Object valor     = aux.getElementFromArray(realIndex);
                         this.ValorAux = valor;
                         return(valor);
                     }
                     else
                     {
                         TError error = new TError("Semantico", "Para el arreglo: \"" + this.id + "\" La Dimension no se encuentra dentro de los limites! | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
                         Estatico.errores.Add(error);
                         Estatico.ColocaError(error);
                     }
                 }
                 else
                 {
                     TError error = new TError("Semantico", "Para el arreglo: \"" + this.id + "\" No se ha proporcionado un Entero como Dimension del Mismo | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
                     Estatico.errores.Add(error);
                     Estatico.ColocaError(error);
                 }
             }
             else
             {
                 TError error = new TError("Semantico", "El simbolo: \"" + this.id + "\" No es un arreglo por lo que no se puede acceder al valor indicado | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
                 Estatico.errores.Add(error);
                 Estatico.ColocaError(error);
             }
         }
         else
         {
             TError error = new TError("Semantico", "No existe el Arreglo: \"" + this.id + "\" en este Ambito | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
             Estatico.errores.Add(error);
             Estatico.ColocaError(error);
         }
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al acceder al valor de arreglo: \"" + id + "\" | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     this.ValorAux = new Nulo();
     return(ValorAux);
 }
コード例 #14
0
ファイル: TResult.cs プロジェクト: Jack-Duan/YunCNetBlog
        /// <summary>
        /// 返回error
        /// </summary>
        /// <param name="error">error</param>
        public static void HandlerError(TError error)
        {
            var result = new
            {
                StatusCode = error
            };

            HttpContext.Current.Response.Write(result.ToJsonString());
        }
コード例 #15
0
        private void declaracionApartirExp(Ambito ambito)
        {
            if (!ambito.existeVariable(this.idArr.ToLower()))
            {
                //TENGO QUE VER SI LO QUE ME RETORNA LA EXPRESION ES UN ARREGLO Y SI HACE MATCH CON LOS DATOS QUE TENGO
                Object arr     = this.exp.getValor(ambito);
                String tipoaux = this.exp.getTipo(ambito);
                if (arr is Arreglo)
                {
                    Arreglo arreglo = (Arreglo)arr;

                    if (this.NumDim == arreglo.numDimensiones)
                    {
                        if (arreglo.Tipo.Equals("nuevo"))
                        {
                            arreglo.setID(this.idArr);
                            arreglo.setTipo(this.tipo.ToLower());
                            arreglo.setVisibilidad(this.visibilidad);

                            ambito.agregarVariableAlAmbito(this.idArr.ToLower(), arreglo);
                        }
                        else if (arreglo.Tipo.ToLower().Equals(this.tipo.ToLower()))
                        {
                            ambito.agregarVariableAlAmbito(this.idArr.ToLower(), arreglo);
                        }
                        else
                        {
                            TError error = new TError("Semantico", "Los tipos del arreglo no concuerdan, se esperaba: \"" + this.tipo + "\" y se econtro: \"" + arreglo.Tipo.ToLower() + "\"" + "  | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
                            Estatico.errores.Add(error);
                            Estatico.ColocaError(error);
                        }
                    }
                    else
                    {
                        TError error = new TError("Semantico", "Para \"" + this.idArr.ToLower() + "\", Las dimensiones no concuerdan se esperaba: " + this.NumDim + ", dimensiones y se encontraron: " + arreglo.numDimensiones + "  | Clase: " + this.clase + " | Archivo: " + ambito.archivo, this.linea, this.columna, false);
                        Estatico.errores.Add(error);
                        Estatico.ColocaError(error);
                    }
                }
                else if (arr is Nulo)
                {
                    ambito.agregarVariableAlAmbito(this.idArr.ToLower(), new Arreglo(new List <object>(), new List <int>(), this.NumDim, this.idArr.ToLower(), true, this.visibilidad, this.tipo));
                }
                else
                {
                    TError error = new TError("Semantico", "Se esperaba un arreglo como valor para: \"" + this.idArr + "\", se encontro: \"" + tipoaux + "\"  | 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);
            }
        }
コード例 #16
0
        private TError checkGetError(string url, Logger log)
        {
            TError bResult = TError.TE_NONE;

            string sURL = url;

            try
            {
                HttpWebRequest wrGETURL;
                wrGETURL = ((HttpWebRequest)HttpWebRequest.Create(sURL));

                Stream objStream;

                HttpWebResponse responce = ((HttpWebResponse)wrGETURL.GetResponse());
                objStream = responce.GetResponseStream();
                responce.Close();
            }
            catch (System.Net.WebException ex)
            {
                if (ex.Status == WebExceptionStatus.Timeout)
                {
                    bResult = TError.TE_TIMEOUT;
                }
                else if (ex.Status == WebExceptionStatus.ProtocolError)
                {
                    HttpStatusCode statusCode = ((HttpWebResponse)(ex.Response)).StatusCode;
                    switch (statusCode)
                    {
                    case HttpStatusCode.ServiceUnavailable:
                        bResult = TError.TE_503;
                        break;

                    case HttpStatusCode.NotFound:
                        bResult = TError.TE_404;
                        break;
                    }
                }

                log.LogError("AppPoolMonitorTimer.checkGetError(): GET " + sURL + " ... FAILED: WebException: " + ex.Message + "; WebExcepttionStatus = " + ex.Status.ToString());

                if (TError.TE_503 == bResult)
                {
                    log.LogError("*** Error 503  - service temporarily unavailable ***");
                }
                if (TError.TE_TIMEOUT == bResult)
                {
                    log.LogError("*** Error TimeOut - no response ***");
                }
            }
            catch (Exception ex)
            {
                log.LogError("AppPoolMonitorTimer.checkGetError(): GET " + sURL + " ... Exception: " + ex.Message);
            }

            return(bResult);
        }
コード例 #17
0
        public object getValor(Ambito ambito)
        {
            try
            {
                Object cad     = cadena.getValor(ambito);
                String tipocad = cadena.getTipo(ambito);

                Object inf     = num1.getValor(ambito);
                String tipoInf = num1.getTipo(ambito);

                Object sup     = num2.getValor(ambito);
                String tipoSup = num2.getTipo(ambito);

                if (cad is String && inf is int && sup is int)
                {
                    String cadena   = (String)cad;
                    int    inferior = (int)inf;
                    int    superior = (int)sup;

                    if (inferior >= 0 && superior >= 0)
                    {
                        if (superior < cadena.Length)
                        {
                            tipo = cadena.Substring(inferior, superior);
                            return(tipo);
                        }
                        else
                        {
                            TError error = new TError("Semantico", "El limite superior no debe ser menor al largo de la cadena! | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                            Estatico.errores.Add(error);
                            Estatico.ColocaError(error);
                        }
                    }
                    else
                    {
                        TError error = new TError("Semantico", "Parametros de Funcion SubCadena deben ser mayores a 0 | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                        Estatico.errores.Add(error);
                        Estatico.ColocaError(error);
                    }
                }
                else
                {
                    TError error = new TError("Semantico", "Funcion SubCade requiere parametros: (cadena, entero, entero) y se encontro: (" + tipocad + "," + tipoInf + "," + tipoSup + ") | 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 SubCadena | Clase: " + clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
                Estatico.errores.Add(error);
                Estatico.ColocaError(error);
            }
            return(new Nulo());
        }
コード例 #18
0
        public static void LogText(string msg, string label, TError error, string prefix = null)
        {
            LogText(msg, label, prefix);

            /*switch (error.ErrorLevel)
             * {
             *      case EErrorLevel.CRITICAL:
             *              SendMail(error);
             *              break;
             * }*/
        }
コード例 #19
0
        public static void ColocaError(TError error)
        {
            String salida = "\n>> {{ERROR! : Tipo: " + error.Tipo + " | " + error.Mensaje + " | Linea: " + (error.Linea + 1) + " , Columna: " + error.Columna + "}}";

            consolaSalida.AppendText(salida);
            int index = consolaSalida.Text.IndexOf(salida);
            int tam   = salida.Length;

            consolaSalida.Select(index, tam);
            consolaSalida.SelectionColor = Color.Red;
        }
コード例 #20
0
        public object Ejecutar(Ambito ambito)
        {
            /// YA QUE LO VOY A TRATAR COMO UN OBJETO:
            /// 1) DEBO DE COLOCARLE UN CONSTRUCTOR AL CUAL ME VA A SERVIR PARA PODER MANDARLE LOS PARAMETROS CUANDO ESTA SE LLAME
            /// 2) AL MOMENTO DE LLAMAR LA PREGUNTA DEBO DE MANDARLE LOS MISMOS PARAMETROS PARA INSTANCIAR LA PREGUNTA QUE EN TEORIA DEBERIAN SER LOS MISMOS
            /// 3) LA PREGUNTA LA VOY A GUARDAR COMO UN OBJETO DENTRO DEL AMBITO DE LA CLASE LA CUAL VA A GUARDAR COMO UNA VARIABLE QUE A GUARDAR COMO VALOR OBJETO DE TIPO
            /// PREGUNTA
            try
            {
                if (!ambito.existeVariable(this.identificador.ToLower()))
                {
                    Ambito amPregunta = new Ambito(ambito, this.identificador.ToLower(), ambito.archivo);

                    /*CREO EL CONSTRUCTOR DE LA PREGUNTA QUE ME VA A SERVIR PARA PODER DECLARAR EN EL AMBITO LAS VARIABLES*/
                    Constructor c = new Constructor(this.parametros, new List <Instruccion>(), linea, columna, clase);

                    /*AGREGO EL CONSTRUCTOR DE LA PREGUNTA AL AMBITO*/
                    amPregunta.agregarConstructor(new ClaveFuncion(this.identificador.ToLower(), "vacio", parametros), c);

                    /*VOY A A GREGAR UNA VARIABLE TEMPORAL PARA QUE ENTONCES PUEDA GUARDAR LAS INSTRUCCIONES :) */
                    Variable v = new Variable("instr", "vale", Estatico.Vibililidad.PRIVADO, this.declaraciones);

                    /*LA AGREGO AL AMBITO DE ESTA PREGUNTA :)*/
                    amPregunta.agregarVariableAlAmbito("instr", v);

                    /*CREO EL OBJETO DE TIPO PREGUNTA*/
                    Objeto pregunta = new Objeto("pregunta", amPregunta);

                    /*AGREGO LA VARIABLE AL AMBITO ACTUAL PARA PODER ACCERDER A LA PREGUNTA EN UN LLAMADO A LA MISMA*/
                    Variable p = new Variable(this.identificador.ToLower(), "pregunta", Estatico.Vibililidad.PRIVADO, pregunta);

                    /*AGREGO LA VARIABLE EN EL AMBITO Y TERMINA*/
                    ambito.agregarVariableAlAmbito(this.identificador.ToLower(), p);

                    return(new Nulo());
                }
                else
                {
                    TError error = new TError("Semantico", "Ya existe una definicion de un simbolo: \"" + identificador + "\", las preguntas se tratan como objetos por lo que no pueden haber multiples definiciones de un objeto con el mismo nombre | Clase"
                                              + clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                    Estatico.ColocaError(error);
                    Estatico.errores.Add(error);
                }
            }
            catch (Exception e)
            {
                TError erro = new TError("Ejecucion", "Error al intentar ejecutar la declaracion de una pregunta | Clase: " + clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
                Estatico.errores.Add(erro);
                Estatico.ColocaError(erro);
            }
            return(new Nulo());
        }
コード例 #21
0
        /// <summary>
        /// 结束一次返回
        /// </summary>
        /// <param name="obj">obj</param>
        /// <param name="flag">flag</param>
        /// <param name="msg">msg</param>
        /// <returns></returns>
        public DefaultResult <TMt> End(TMt obj, TError flag = TError.RunGood, string msg = null)
        {
            var retData = new DefaultResult <TMt>();

            if (CanDebug)
            {
                debugBuilder.End();
                retData.Debug = DebugBuilder.DebugString;
            }
            retData.StatusCode = flag == TError.RunGood ? 200 : -200;
            retData.Data       = obj;
            retData.RunTime    = (DateTime.Now - _startTime).Milliseconds;
            return(retData);
        }
コード例 #22
0
 public object getValor(Ambito ambito)
 {
     try
     {
         return(Math.Round(Math.PI, 5));
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al ejecutar la funcion Pi() | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(0.0);
 }
コード例 #23
0
        public object getValor(Ambito ambito)
        {
            try
            {
                object basse = expresion.getValor(ambito);
                object pot   = potencia.getValor(ambito);

                if (basse is int && pot is int)
                {
                    int b = (int)basse;
                    int p = (int)pot;
                    this.valor = Math.Pow(b, p);
                    return(this.valor);
                }
                else if (basse is int && pot is double)
                {
                    int    b = (int)basse;
                    double p = (double)pot;
                    this.valor = Math.Pow(b, p);
                    return(this.valor);
                }
                else if (basse is double && pot is int)
                {
                    double b = (double)basse;
                    int    p = (int)pot;
                    this.valor = Math.Pow(b, p);
                    return(this.valor);
                }
                else if (basse is double && pot is double)
                {
                    double b = (double)basse;
                    double p = (double)pot;
                    this.valor = Math.Pow(b, p);
                    return(this.valor);
                }
                else
                {
                    TError error = new TError("Semantico", "La funcion Pow() no se encontro parametros validos, se esperan: Pow(entero/decimal, entero/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 Pow | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
                Estatico.errores.Add(error);
                Estatico.ColocaError(error);
            }
            return(0.0);
        }
コード例 #24
0
 private void declaracionVacia(Ambito ambito)
 {
     if (!ambito.existeVariable(this.idArr.ToLower()))
     {
         Arreglo arr = new Arreglo(new List <object>(), new List <object>(), new List <int>(), this.NumDim, this.idArr.ToLower(), true, this.visibilidad, this.tipo);
         ambito.agregarVariableAlAmbito(this.idArr.ToLower(), arr);
     }
     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);
     }
 }
コード例 #25
0
 public object Ejecutar(Ambito ambito)
 {
     try
     {
         Simbolo s = (Simbolo)ambito.getSimbolo(this.id.ToLower());
         if (s != null)
         {
             if (s is Variable && (s.Tipo.ToLower().Equals("entero") || s.Tipo.ToLower().Equals("decimal")))
             {
                 Variable v = (Variable)s;
                 if (v.valor is int)
                 {
                     int aux = (int)v.valor;
                     v.valor = aux - 1;
                 }
                 else if (v.valor is Double)
                 {
                     double aux = (double)v.valor;
                     v.valor = aux - 1;
                 }
                 else
                 {
                     TError error = new TError("Semantico", "El Simbolo: \"" + this.id.ToLower() + "\" Posiblemente no ha sido inicializada! | Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                     Estatico.errores.Add(error);
                     Estatico.ColocaError(error);
                 }
             }
             else
             {
                 TError error = new TError("Semantico", "El Simbolo: \"" + this.id.ToLower() + "\" No hace referencia a una variable que se pueda aplicar el decremento: \"" + s.Tipo + "\"| Clase: " + this.clase + " | Archivo: " + ambito.archivo, linea, columna, false);
                 Estatico.errores.Add(error);
                 Estatico.ColocaError(error);
             }
         }
         else
         {
             TError error = new TError("Semantico", "El Simbolo: \"" + this.id.ToLower() + "\" al cual se hace referencia no existe en este contexto | 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 ejecutar un decremento | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new Nulo());
 }
コード例 #26
0
 public object getValor(Ambito ambito)
 {
     try
     {
         DateTime ahora = DateTime.Now;
         return(ahora);
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al ejecutar la funcion ahora() | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new Nulo());
 }
コード例 #27
0
 object Instruccion.Ejecutar(Ambito ambito)
 {
     try
     {
         Object valor = expresion.getValor(ambito);
         Estatico.imprimeConsola(valor.ToString());
     }
     catch (Exception ex)
     {
         TError error = new TError("Ejecucion", "Error al Imprimir en Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | " + ex.Message, this.linea, this.columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(null);
 }
コード例 #28
0
 public object Ejecutar(Ambito ambito)
 {
     try
     {
         Object valor = this.valor.getValor(ambito);
         MessageBox.Show(valor.ToString(), "Mensajes");
     }
     catch (Exception e)
     {
         TError error = new TError("Ejecucion", "Error al ejecutar Mensajes: | Clase: " + this.clase + " | Archivo: " + ambito.archivo + " | Mensaje: " + e.Message, linea, columna, false);
         Estatico.errores.Add(error);
         Estatico.ColocaError(error);
     }
     return(new Nulo());
 }
コード例 #29
0
        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());
        }
コード例 #30
0
        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());
        }
コード例 #31
0
ファイル: Notifier.cs プロジェクト: mavencode01/tesla
 public AggregateError(TError error)
 {
     Error = error;
     Count = 1;
 }