public virtual void OutAEnumDecl(AEnumDecl node)
 {
     DefaultOut(node);
 }
 internal Values_Cast(AEnumDecl obj)
 {
     this.obj = obj;
 }
 public virtual void CaseAEnumDecl(AEnumDecl node)
 {
     DefaultCase(node);
 }
 public virtual void InAEnumDecl(AEnumDecl node)
 {
     DefaultIn(node);
 }
 public override void CaseAEnumDecl(AEnumDecl node)
 {
     InAEnumDecl(node);
     if (node.GetEndToken() != null)
     {
         node.GetEndToken().Apply(this);
     }
     {
         Object[] temp = new Object[node.GetValues().Count];
         node.GetValues().CopyTo(temp, 0);
         for (int i = temp.Length - 1; i >= 0; i--)
         {
             ((PEnumLocal)temp[i]).Apply(this);
         }
     }
     if (node.GetName() != null)
     {
         node.GetName().Apply(this);
     }
     if (node.GetToken() != null)
     {
         node.GetToken().Apply(this);
     }
     if (node.GetStatic() != null)
     {
         node.GetStatic().Apply(this);
     }
     if (node.GetVisibilityModifier() != null)
     {
         node.GetVisibilityModifier().Apply(this);
     }
     OutAEnumDecl(node);
 }
        public override void OutAEnumDecl(AEnumDecl node)
        {
            AStructDecl replacer = new AStructDecl(node.GetVisibilityModifier(), null, null, null, node.GetEndToken(),
                                                   node.GetName(), new ArrayList(), null, new ArrayList());

            TIdentifier typeIdentifier = new TIdentifier("byte");
            ASwitchStm switchStm = new ASwitchStm(new TSwitch("switch"),
                                                  new ALvalueExp(
                                                      new AAmbiguousNameLvalue(new AAName(new ArrayList() {new TIdentifier("enum")}))),
                                                  new ArrayList());
                ;
            AMethodDecl toStringMethod = new AMethodDecl(new APublicVisibilityModifier(), null, null, null, null, null,
                                                         new ANamedType(new TIdentifier("string"), null),
                                                         new TIdentifier("toString"),
                                                         new ArrayList()
                                                             {
                                                                 new AALocalDecl(new APublicVisibilityModifier(), null,
                                                                                 null, null, null,
                                                                                 new ANamedType(typeIdentifier, null),
                                                                                 new TIdentifier("enum"), null)
                                                             },
                                                         new AABlock(
                                                             new ArrayList()
                                                                 {
                                                                     switchStm,
                                                                     new AValueReturnStm(new TReturn("return"), new ANullExp())
                                                                 }, new TRBrace("}")));
            replacer.GetLocals().Add(new ADeclLocalDecl(toStringMethod));

            int intVal = 0;
            int min = int.MaxValue;
            int max = int.MinValue;
            List<TIdentifier> types = new List<TIdentifier>(){typeIdentifier};
            Dictionary<int, List<AALocalDecl>> usedValues = new Dictionary<int, List<AALocalDecl>>();
            foreach (AAEnumLocal value in node.GetValues())
            {
                AIntConstExp intConst;
                if (value.GetValue() != null)
                {
                    intConst = (AIntConstExp) value.GetValue();
                    intVal = int.Parse(intConst.GetIntegerLiteral().Text) + 1;
                }
                else
                {
                    intConst = new AIntConstExp(new TIntegerLiteral(intVal.ToString(), value.GetName().Line, value.GetName().Pos));
                    intVal++;
                }
                min = Math.Min(intVal - 1, min);
                max = Math.Max(intVal - 1, max);
                typeIdentifier = new TIdentifier("byte", value.GetName().Line, value.GetName().Pos);
                types.Add(typeIdentifier);
                switchStm.GetCases().Add(
                    new ASwitchCaseStm(new ACaseSwitchCaseType(new TCase("case"), (PExp) intConst.Clone()),
                                       new AABlock(
                                           new ArrayList()
                                               {
                                                   new AValueReturnStm(new TReturn("return"),
                                                                       new AStringConstExp(
                                                                           new TStringLiteral("\"" +
                                                                                              value.GetName().Text +
                                                                                              "\"")))
                                               }, new TRBrace("}"))));
                AALocalDecl localDecl = new AALocalDecl(new APublicVisibilityModifier(),
                                                        new TStatic("static", value.GetName().Line, value.GetName().Pos),
                                                        null, null,
                                                        new TConst("const", value.GetName().Line, value.GetName().Pos),
                                                        new ANamedType(typeIdentifier, null), value.GetName(), intConst);
                replacer.GetLocals().Add(localDecl);
                if (!usedValues.ContainsKey(intVal - 1))
                    usedValues[intVal - 1] = new List<AALocalDecl>();
                usedValues[intVal - 1].Add(localDecl);
            }
            if (min < 0 || max > 255)
                foreach (TIdentifier identifier in types)
                {
                    identifier.Text = "int";
                }
            node.ReplaceBy(replacer);
            foreach (KeyValuePair<int, List<AALocalDecl>> pair in usedValues)
            {
                if (pair.Value.Count <= 1)
                    continue;
                int value = pair.Key;
                List<ErrorCollection.Error> subErrors = new List<ErrorCollection.Error>();
                foreach (AALocalDecl decl in pair.Value)
                {
                    subErrors.Add(new ErrorCollection.Error(decl.GetName(), LocRM.GetString("ErrorText179")));
                }
                errors.Add(new ErrorCollection.Error(replacer.GetName(), LocRM.GetString("ErrorText180") + value + ".", false, subErrors.ToArray()));
            }
            replacer.Apply(this);
            data.Enums.Add(replacer, min < 0 || max > 255);
        }
 ArrayList New28()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList7 = (ArrayList) Pop();
     ArrayList nodeArrayList6 = (ArrayList) Pop();
     ArrayList nodeArrayList5 = (ArrayList) Pop();
     ArrayList nodeArrayList4 = (ArrayList) Pop();
     ArrayList nodeArrayList3 = (ArrayList) Pop();
     ArrayList nodeArrayList2 = (ArrayList) Pop();
     ArrayList nodeArrayList1 = (ArrayList) Pop();
     TypedList listNode7 = new TypedList();
     PVisibilityModifier pvisibilitymodifierNode2 = (PVisibilityModifier)nodeArrayList1[0];
     TStatic tstaticNode3 = (TStatic)nodeArrayList2[0];
     TEnum tenumNode4 = (TEnum)nodeArrayList3[0];
     TIdentifier tidentifierNode5 = (TIdentifier)nodeArrayList4[0];
     TypedList listNode6 = (TypedList)nodeArrayList6[0];
     if ( listNode6 != null )
     {
     listNode7.AddAll(listNode6);
     }
     TRBrace trbraceNode8 = (TRBrace)nodeArrayList7[0];
     AEnumDecl pdeclNode1 = new AEnumDecl (
       pvisibilitymodifierNode2,
       tstaticNode3,
       tenumNode4,
       tidentifierNode5,
       listNode7,
       trbraceNode8
     );
     nodeList.Add(pdeclNode1);
     return nodeList;
 }
 ArrayList New25()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList5 = (ArrayList) Pop();
     ArrayList nodeArrayList4 = (ArrayList) Pop();
     ArrayList nodeArrayList3 = (ArrayList) Pop();
     ArrayList nodeArrayList2 = (ArrayList) Pop();
     ArrayList nodeArrayList1 = (ArrayList) Pop();
     TypedList listNode6 = new TypedList();
     PVisibilityModifier pvisibilitymodifierNode2 = (PVisibilityModifier)nodeArrayList1[0];
     TEnum tenumNode4 = (TEnum)nodeArrayList2[0];
     TIdentifier tidentifierNode5 = (TIdentifier)nodeArrayList3[0];
     TRBrace trbraceNode7 = (TRBrace)nodeArrayList5[0];
     AEnumDecl pdeclNode1 = new AEnumDecl (
       pvisibilitymodifierNode2,
       null,
       tenumNode4,
       tidentifierNode5,
       listNode6,
       trbraceNode7
     );
     nodeList.Add(pdeclNode1);
     return nodeList;
 }
        public override void OutAEnumDecl(AEnumDecl node)
        {
            AStructDecl replacer = new AStructDecl(node.GetVisibilityModifier(), null, null, null, node.GetEndToken(),
                                                   node.GetName(), new ArrayList(), null, new ArrayList());

            int intVal = 0;
            //int min = int.MaxValue;
            //int max = int.MinValue;
            //List<TIdentifier> types = new List<TIdentifier>();
            foreach (AAEnumLocal value in node.GetValues())
            {
                AIntConstExp intConst;
                if (value.GetValue() != null)
                {
                    intConst = (AIntConstExp) value.GetValue();
                    intVal = int.Parse(intConst.GetIntegerLiteral().Text) + 1;
                }
                else
                {
                    intConst = new AIntConstExp(new TIntegerLiteral(intVal.ToString(), value.GetName().Line, value.GetName().Pos));
                    intVal++;
                }
            //    min = Math.Min(intVal - 1, min);
            //    max = Math.Max(intVal - 1, max);
                TIdentifier typeIdentifier = new TIdentifier(replacer.GetName().Text, value.GetName().Line, value.GetName().Pos);
               // types.Add(typeIdentifier);
                AALocalDecl localDecl = new AALocalDecl(new APublicVisibilityModifier(),
                                                        new TStatic("static", value.GetName().Line, value.GetName().Pos),
                                                        null, null,
                                                        new TConst("const", value.GetName().Line, value.GetName().Pos),
                                                        new ANamedType(typeIdentifier, null), value.GetName(), intConst);
                replacer.GetLocals().Add(localDecl);
            }
             /*   if (min < 0 || max > 255)
                foreach (TIdentifier identifier in types)
                {
                    identifier.Text = "int";
                }*/
            node.ReplaceBy(replacer);

            replacer.Apply(this);
            replacer.GetName().Text = "enum " + replacer.GetName().Text;
        }