Example #1
0
        public override object Ejecutar(Entorno e, bool funcion, bool ciclo, bool sw, bool tc, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            if (!Else)
            {
                object valCond = Cond.GetValor(e, log, errores);

                if (valCond != null)
                {
                    if (valCond is Throw)
                    {
                        return(valCond);
                    }

                    if (Cond.Tipo.IsBoolean())
                    {
                        Entra = (bool)valCond;
                    }
                    else
                    {
                        errores.AddLast(new Error("Semántico", "Se esperaba un booleano en condicion if.", Linea, Columna));
                        return(null);
                    }
                }
            }

            if (Else || Entra)
            {
                Entorno local = new Entorno(e);
                return(Bloque.Ejecutar(local, funcion, ciclo, sw, tc, log, errores));
            }

            return(null);
        }
Example #2
0
        public override object Ejecutar(Entorno e, bool funcion, bool ciclo, bool sw, bool tc, LinkedList <Salida> log, LinkedList <Error> errores)
        {
            if (!Default)
            {
                if (!Continuar)
                {
                    object valExpr = Expr.GetValor(e, log, errores);

                    if (valExpr != null)
                    {
                        if (valExpr is Throw)
                        {
                            return(valExpr);
                        }

                        Relacional rel    = new Relacional(ExprSwitch, new Literal(Expr.Tipo, valExpr, Linea, Columna), Operador.IGUAL, Linea, Columna);
                        object     valRel = rel.GetValor(e, log, errores);

                        if (valRel != null)
                        {
                            if ((bool)valRel)
                            {
                                Continuar = true;
                            }
                        }
                    }
                }
            }
            else
            {
                Continuar = true;
            }

            if (Continuar)
            {
                Entorno local = new Entorno(e);
                return(Bloque.Ejecutar(local, funcion, ciclo, sw, tc, log, errores));
            }

            return(null);
        }