コード例 #1
0
        public override void Ejecutar()
        {
            Lista valoresDeLaExpresion = (Lista)expresion.ejecutar();

            tablaDeSimbolos.AbrirBloque();
            salida.AbrirFor();
            for (int i = 0; i < valoresDeLaExpresion.Count(); i++)
            {
                tablaDeSimbolos.GuardarVariable(variable, Nulo.NULO);
                salida.InicioMoveNextDelFor();
                tablaDeSimbolos.GuardarVariable(variable, valoresDeLaExpresion.getObjeto(i));
                cuerpo.Ejecutar();
                salida.FinMoveNextDelFor();
            }
            salida.CerrarFor(variable);
            tablaDeSimbolos.CerrarBloque();
        }
コード例 #2
0
 public override Objeto ejecutar()
 {
     if (tablaDeSimbolos.ExisteLaDeclaracion(clase_Renamed))
     {
         DeclaracionProcedure procedimiento = tablaDeSimbolos.Procedure(clase_Renamed);
         Objeto[]             resultados    = new Objeto[argumentos.Length];
         bool cantidadDeArguemtosEsLaMisma  = argumentos.Length == procedimiento.cantidadDeParametros();
         if (!cantidadDeArguemtosEsLaMisma)
         {
             throw new LanguageException(string.Format("La cantidad de argumentos No coincide con la cantidad de parametros del procedimiento"));
         }
         int i = 0;
         foreach (Expresion argumento in argumentos)
         {
             Type tipoDelArgumento = argumento.calcularTipo();
             Type tipoDelParametro = procedimiento.calcularTipoDelParametro(i);
             if (tipoDelParametro != tipoDelArgumento)
             {
                 throw new LanguageException(string.Format("Se esperaba un argumento de tipo '" + tipoDelParametro.Name + "' pero se encontro '" + tipoDelArgumento.Name + "'"));
             }
             i++;
         }
         i = 0;
         tablaDeSimbolos.AbrirBloque();
         foreach (Expresion argumento in argumentos)
         {
             resultados[i] = argumento.ejecutar();
             tablaDeSimbolos.GuardarVariable(procedimiento.nombreDelParametro(i), resultados[i]);
             i++;
         }
         procedimiento.ejecutar();
         tablaDeSimbolos.CerrarBloque();
     }
     else
     {
         if (instancia == null)
         {
             instancia = InstanciarElObjeto();
         }
         return(instancia);
     }
     return(instancia);
 }
コード例 #3
0
        public override void Ejecutar()
        {
            if (lValue is IdConPunto)
            {
                IdConPunto referencia = (IdConPunto)lValue;

                string instancia = referencia.instancia();
                if (!tablaDeSimbolos.ExisteLaVariable(instancia))
                {
                    throw new LanguageException(string.Format("No se ha definido la variable {0}. Verifique el nombre", instancia));
                }
                Objeto objeto = tablaDeSimbolos.Valor(instancia);
                Objeto valorDeLaExpresionDerecha = rValue.ejecutar();

                FieldInfo fieldInfo = ObtenerElFieldDelObjetoSiExiste();
                if (fieldInfo != null)
                {
                    fieldInfo.SetValue(objeto, ImplicitCast(UnBoxing(valorDeLaExpresionDerecha), fieldInfo.FieldType));
                    return;
                }

                PropertyInfo propertyInfo = ObtenerElPropertyDelObjetoSiExiste();
                if (propertyInfo != null)
                {
                    propertyInfo.SetValue(objeto, ImplicitCast(UnBoxing(valorDeLaExpresionDerecha), propertyInfo.PropertyType));
                    return;
                }
                else
                {
                    objeto.setAtributo(referencia.Propiedad(), valorDeLaExpresionDerecha);
                }
            }
            else if (lValue is PuntoConPunto)
            {
            }
            else
            {
                string nuevaVariable             = ((Id)lValue).Valor;
                Objeto valorDeLaExpresionDerecha = rValue.ejecutar();
                tablaDeSimbolos.GuardarVariable(nuevaVariable, valorDeLaExpresionDerecha);
            }
        }
コード例 #4
0
ファイル: Actor.cs プロジェクト: NcuboIdeas/EventSourcing
        internal string Perform(string script, Libraries.FechaHora ahora)
        {
            if (script == null)
            {
                throw new ArgumentNullException(nameof(script));
            }

            tablaDeSimbolos.GuardarVariable("Now", ahora);

            parser.EstablecerComando(script);
            Programa programa  = parser.Procesar();
            string   resultado = programa.Ejecutar();

            if (eventStorage != null)
            {
                string formatedScript = programa.Write();
                eventStorage.EscribirEnDairy(formatedScript);
            }
            return(resultado == "{}" ? "" : resultado);
        }