public IHolderCil Visit(CaseExprContext parserRule, IFunctionCil cilTree, IContextCil contextCil)
        {
            var value = new LocalCil($"_value{cilTree.LocalCils.Count}");

            cilTree.LocalCils.Add(value);
            var expr0 = Visit(parserRule.expresion, cilTree, contextCil);
            //is void
            var TypeValue   = new LocalCil($"_TypeValue{cilTree.LocalCils.Count}");
            var not_is_void = new LocalCil($"not_is_void{cilTree.LocalCils.Count}");

            cilTree.LocalCils.Add(TypeValue);
            cilTree.LocalCils.Add(not_is_void);
            cilTree.ThreeDirInses.Add(new TypeOf(TypeValue, expr0));
            cilTree.ThreeDirInses.Add(new NotEqualCil(not_is_void, TypeValue, CilAst.GetTypeCilByName("void")));

            //lanzamos el error

            Visit_Runtime_Error_whit_Cond(not_is_void, cilTree, $"\"({parserRule.Start.Line},{parserRule.Start.Column + 1}) -  Rutime Error: A case on void\"");

            //ejecucion del case
            var closestAncestor = new LocalCil($"_closestAncestor{cilTree.LocalCils.Count}");

            cilTree.LocalCils.Add(closestAncestor);

            //Inicializo el valor de numberType en 0 y closestAncestor con object
            var isNotConform = new LocalCil($"_isNotConform{cilTree.LocalCils.Count}");

            cilTree.LocalCils.Add(isNotConform);

            var branches = parserRule._branches.Concat(new List <BranchContext>()
            {
                parserRule.firstBranch
            }).OrderBy(t => - (CilAst.GetTypeCilByName(t.typeText).IndexOfPrecedence)).ToArray();
            //El tipo de la primera rama
            var End = cilTree.CreateLabel("End_");

            for (int i = 0; i < branches.Length; i++)
            {
                var branch    = branches[i];
                var nextLabel = cilTree.CreateLabel("Case_");
                //tipo de la rama
                var typeBranch = CilAst.GetTypeCilByName(branch.typeText, typeCil);
                cilTree.ThreeDirInses.Add(new IsNotConformCil(isNotConform, TypeValue, typeBranch));
                cilTree.ThreeDirInses.Add(new IfGoto(isNotConform, nextLabel));
                var valueBranch = new LocalCil(branch.idText);//preguntarle as zahuis
                cilTree.LocalCils.Add(valueBranch);
                cilTree.ThreeDirInses.Add(new AssigCil(valueBranch, expr0));
                var newContextCil = contextCil.CreateAChild();
                newContextCil.Define(branch.idText);
                var valueExpr = Visit(branch.expression, cilTree, newContextCil);
                cilTree.ThreeDirInses.Add(new AssigCil(value, valueExpr));
                cilTree.ThreeDirInses.Add(new GotoCil(End));
                cilTree.ThreeDirInses.Add(new Label(nextLabel));
            }
            Visit_Runtime_Error(cilTree, $"\"linea {parserRule.Start.Line} y columna {parserRule.Start.Column + 1} Execution of a case statement without a matching branch\"");
            cilTree.ThreeDirInses.Add(new Label(End));


            return(value);
        }
        public IHolderCil Visit(CondExprContext parserRule, IFunctionCil cilTree, IContextCil contextCil)
        {
            var value = new LocalCil($"_value{cilTree.LocalCils.Count}");

            cilTree.LocalCils.Add(value);
            var condValue = Visit(parserRule.ifExpr, cilTree, contextCil);

            condValue = GetValue(condValue, cilTree, CilAst.Bool);
            var labelElse = cilTree.CreateLabel("else");

            cilTree.ThreeDirInses.Add(new IfGoto(condValue, labelElse));
            //genero el codigo de elseValue
            var elseValue = Visit(parserRule.elseExpr, cilTree, contextCil);
            var labelEnd  = cilTree.CreateLabel("end");

            //El resultado lo almaceno en value
            cilTree.ThreeDirInses.Add(new AssigCil(value, elseValue));
            //Voy pa la etiquta end
            cilTree.ThreeDirInses.Add(new GotoCil(labelEnd));
            //Pongo la etiqueta de else
            cilTree.ThreeDirInses.Add(new Label(labelElse));
            //genero el codigo de thenValue
            var thenValue = Visit(parserRule.thenExpr, cilTree, contextCil);

            //Asigno el valor a esle value
            cilTree.ThreeDirInses.Add(new AssigCil(value, thenValue));
            //Pongo la etiqueta end
            cilTree.ThreeDirInses.Add(new Label(labelEnd));
            //retorno el valor
            return(value);
        }
        public IHolderCil Visit(WhileExprContext parserRule, IFunctionCil cilTree, IContextCil contextCil)
        {
            var whileElse = cilTree.CreateLabel("while");

            //Voy para esa etiqueta para evaluar la cod del while
            cilTree.ThreeDirInses.Add(new GotoCil(whileElse));
            var loop = cilTree.CreateLabel("loop");

            //Esta etiqueta indica evalua el cuerpo de while
            cilTree.ThreeDirInses.Add(new Label(loop));
            Visit(parserRule.loopExpr, cilTree, contextCil);
            //Pongo la etiqueta de while
            cilTree.ThreeDirInses.Add(new Label(whileElse));
            var condValue = Visit(parserRule.whileExpr, cilTree, contextCil);

            condValue = GetValue(condValue, cilTree, CilAst.Bool);
            cilTree.ThreeDirInses.Add(new IfGoto(condValue, loop));
            //retorno el valor
            var value = Visit_void(cilTree);

            return(value);
        }
        public void Visit_Runtime_Error_whit_Cond(IHolderCil valueCond, IFunctionCil cilTree, string sms)
        {
            var Continue = cilTree.CreateLabel($"Continue_");

            cilTree.ThreeDirInses.Add(new IfGoto(valueCond, Continue));
            var varStr = new LocalCil($"_value{cilTree.LocalCils.Count}");

            cilTree.LocalCils.Add(varStr);
            var varDataString = new VarCil($"s{CilAst.dataStringCils.Count}");

            CilAst.dataStringCils.Add(new DataStringCil(varDataString, new StringCil(sms)));
            cilTree.ThreeDirInses.Add(new LoadCil(varStr, varDataString));
            cilTree.ThreeDirInses.Add(new Out_strCil(varStr));
            cilTree.ThreeDirInses.Add(new Halt());
            cilTree.ThreeDirInses.Add(new Label(Continue));
        }