public override void CaseAStructDecl(AStructDecl node)
 {
     InAStructDecl(node);
     {
         Object[] temp = new Object[node.GetLocals().Count];
         node.GetLocals().CopyTo(temp, 0);
         for (int i = temp.Length - 1; i >= 0; i--)
         {
             ((PLocalDecl)temp[i]).Apply(this);
         }
     }
     if (node.GetBase() != null)
     {
         node.GetBase().Apply(this);
     }
     {
         Object[] temp = new Object[node.GetGenericVars().Count];
         node.GetGenericVars().CopyTo(temp, 0);
         for (int i = temp.Length - 1; i >= 0; i--)
         {
             ((TIdentifier)temp[i]).Apply(this);
         }
     }
     if (node.GetName() != null)
     {
         node.GetName().Apply(this);
     }
     if (node.GetEndToken() != null)
     {
         node.GetEndToken().Apply(this);
     }
     if (node.GetIntDim() != null)
     {
         node.GetIntDim().Apply(this);
     }
     if (node.GetDimention() != null)
     {
         node.GetDimention().Apply(this);
     }
     if (node.GetClassToken() != null)
     {
         node.GetClassToken().Apply(this);
     }
     if (node.GetVisibilityModifier() != null)
     {
         node.GetVisibilityModifier().Apply(this);
     }
     OutAStructDecl(node);
 }
 public override void OutAStructDecl(AStructDecl node)
 {
     if (node.GetClassToken() != null && node.GetIntDim() == null)
         node.Parent().RemoveChild(node);
     base.OutAStructDecl(node);
 }
            //+20
            public static GlobalStructVars CreateStructFields(Node node, AStructDecl structDecl, SharedData data)
            {
                if (structFields.ContainsKey(structDecl))
                    return structFields[structDecl];

                ANamedType structType = new ANamedType(new TIdentifier(structDecl.GetName().Text), null);
                data.StructTypeLinks[structType] = structDecl;

                structFields[structDecl] = CreatePointerFields(node, structDecl.GetIntDim(), structDecl.GetName().Text,
                                                               structType, data, structDecl.GetLocals().Count > 0);
                return structFields[structDecl];
                /*
                AASourceFile file = Util.GetAncestor<AASourceFile>(node);

                ANamedType structType = new ANamedType(new TIdentifier(structDecl.GetName().Text), null);
                data.StructTypeLinks[structType] = structDecl;
                AFieldDecl array = new AFieldDecl(new APublicVisibilityModifier(), null, null,
                                                  new AArrayTempType(new TLBracket("["), structType,
                                                                     new AIntConstExp(
                                                                         new TIntegerLiteral(structDecl.GetIntDim().Text)),
                                                                     new TIntegerLiteral(structDecl.GetIntDim().Text)),
                                                                     new TIdentifier(structDecl.GetName().Text + "_array", data.LineCounts[file] + 20, 0),
                                                                     null);
                int length = (int) Math.Ceiling(float.Parse(structDecl.GetIntDim().Text)/31);
                AFieldDecl used = new AFieldDecl(new APublicVisibilityModifier(), null, null,
                                                  new AArrayTempType(new TLBracket("["), new ANamedType(new TIdentifier("int"), null),
                                                                     new AIntConstExp(
                                                                         new TIntegerLiteral(length.ToString())),
                                                                     new TIntegerLiteral(length.ToString())),
                                                                     new TIdentifier(structDecl.GetName().Text + "_used", data.LineCounts[file] + 20, 0),
                                                                     null);
                AFieldDecl index = new AFieldDecl(new APublicVisibilityModifier(), null, null,  new ANamedType(new TIdentifier("int"), null),
                                                                     new TIdentifier(structDecl.GetName().Text + "_index", data.LineCounts[file] + 20, 0),
                                                                     null);
                file.GetDecl().Add(array);
                file.GetDecl().Add(used);
                file.GetDecl().Add(index);

                data.ExpTypes[((AArrayTempType) array.GetType()).GetDimention()] =
                    data.ExpTypes[((AArrayTempType) used.GetType()).GetDimention()] =
                    new ANamedType(new TIdentifier("int"), null);

                data.Fields.Add(new SharedData.DeclItem<AFieldDecl>(file, array));
                data.Fields.Add(new SharedData.DeclItem<AFieldDecl>(file, used));
                data.Fields.Add(new SharedData.DeclItem<AFieldDecl>(file, index));

                structFields[structDecl] = new GlobalStructVars(array, used, index);
                return structFields[structDecl];*/
            }
            //+19
            /*public static AMethodDecl CreatePower2Method(Node node, SharedData data)
            {
                if (power2Method != null)
                    return power2Method;

                /*
                    int Power2(int i)
                    {
                        int ret = 1;
                        while (i > 0)
                        {
                            ret = ret * 2;
                            i = i - 1;
                        }
                        return ret;
                    }
                 */
            /*
                AASourceFile file = Util.GetAncestor<AASourceFile>(node);

                AIntConstExp intConst1 = new AIntConstExp(new TIntegerLiteral("1"));
                AIntConstExp intConst2 = new AIntConstExp(new TIntegerLiteral("0"));
                AIntConstExp intConst3 = new AIntConstExp(new TIntegerLiteral("2"));
                AIntConstExp intConst4 = new AIntConstExp(new TIntegerLiteral("1"));

                AALocalDecl iDecl = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null, new ANamedType(new TIdentifier("int"), null),
                                                    new TIdentifier("i"), null);
                ALocalLvalue iRef1 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef2 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef3 = new ALocalLvalue(new TIdentifier("i"));
                ALvalueExp iRef1Exp = new ALvalueExp(iRef1);
                ALvalueExp iRef3Exp = new ALvalueExp(iRef3);

                AALocalDecl retDecl = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null, new ANamedType(new TIdentifier("int"), null),
                                                    new TIdentifier("ret"), intConst1);
                ALocalLvalue retRef1 = new ALocalLvalue(new TIdentifier("ret"));
                ALocalLvalue retRef2 = new ALocalLvalue(new TIdentifier("ret"));
                ALocalLvalue retRef3 = new ALocalLvalue(new TIdentifier("ret"));
                ALvalueExp retRef2Exp = new ALvalueExp(retRef2);
                ALvalueExp retRef3Exp = new ALvalueExp(retRef3);

                ABinopExp binop1 = new ABinopExp(iRef1Exp, new AGtBinop(new TGt(">")), intConst2);
                ABinopExp binop2 = new ABinopExp(retRef2Exp, new ATimesBinop(new TStar("*")), intConst3);
                ABinopExp binop3 = new ABinopExp(iRef3Exp, new AMinusBinop(new TMinus("-")), intConst4);

                AAssignmentExp assignment1 = new AAssignmentExp(new TAssign("="), retRef1, binop2);
                AAssignmentExp assignment2 = new AAssignmentExp(new TAssign("="), iRef2, binop3);

                power2Method = new AMethodDecl(new APublicVisibilityModifier(), null, null, null, null, null,
                                                     new ANamedType(new TIdentifier("int"), null),
                                                     new TIdentifier("Power2", data.LineCounts[file] + 19, 0),
                                                     new ArrayList() {iDecl},
                                                     new AABlock(
                                                         new ArrayList()
                                                             {
                                                                 new ALocalDeclStm(new TSemicolon(";"), retDecl),
                                                                 new AWhileStm(new TLParen("("), binop1,
                                                                               new ABlockStm(new TLBrace("{"),
                                                                                             new AABlock(
                                                                                                 new ArrayList()
                                                                                                     {
                                                                                                         new AExpStm(
                                                                                                             new TSemicolon
                                                                                                                 (";"),
                                                                                                             assignment1),
                                                                                                         new AExpStm(
                                                                                                             new TSemicolon
                                                                                                                 (";"),
                                                                                                             assignment2)
                                                                                                     },
                                                                                                 new TRBrace("}")))),
                                                                 new AValueReturnStm(new TReturn("return"), retRef3Exp)
                                                             },
                                                         new TRBrace("}")));

                file.GetDecl().Add(power2Method);
                data.Methods.Add(new SharedData.DeclItem<AMethodDecl>(file, power2Method));

                data.LocalLinks[iRef1] =
                    data.LocalLinks[iRef2] =
                    data.LocalLinks[iRef3] = iDecl;
                data.LocalLinks[retRef1] =
                    data.LocalLinks[retRef2] =
                    data.LocalLinks[retRef3] = retDecl;
                data.ExpTypes[intConst1] =
                    data.ExpTypes[intConst2] =
                    data.ExpTypes[intConst3] =
                    data.ExpTypes[intConst4] =
                    data.LvalueTypes[iRef1] =
                    data.LvalueTypes[iRef2] =
                    data.LvalueTypes[iRef3] =
                    data.ExpTypes[iRef1Exp] =
                    data.ExpTypes[iRef3Exp] =
                    data.LvalueTypes[retRef1] =
                    data.LvalueTypes[retRef2] =
                    data.LvalueTypes[retRef3] =
                    data.ExpTypes[retRef2Exp] =
                    data.ExpTypes[retRef3Exp] =
                    data.ExpTypes[binop2] =
                    data.ExpTypes[binop3] =
                    data.ExpTypes[assignment1] =
                    data.ExpTypes[assignment2] = new ANamedType(new TIdentifier("int"), null);
                data.ExpTypes[binop1] = new ANamedType(new TIdentifier("bool"), null);

                return power2Method;
            }*/
            //+18
            public static AMethodDecl CreateNewObjectMethod(Node node, AStructDecl structDecl, SharedData data)
            {
                /*if (structDecl.GetIntDim() == null)
                    return CreateNewObjectMethod(node, data);*/

                if (createStructMethod.ContainsKey(structDecl))
                    return createStructMethod[structDecl];

                createStructMethod[structDecl] = CreateNewObjectMethodP(node, structDecl.GetIntDim(), structDecl.GetName().Text,
                                       CreateStructFields(node, structDecl, data), data);

                return createStructMethod[structDecl];

                #region Comment

                /*
                    int CreateStr()
                    {
                        int i = Str_index;
                        while (Str_used[i / 31] & Power2(i % 31))
                        {
                            i = i + 1;
                            if (i >= 42)
                            {
                                i = 0;
                            }
                            if (i == Str_index)
                            {
                                UIDisplayMessage(PlayerGroupAll(), c_messageAreaDebug, StringToText("Error: Unable to allocate more than 42 dynamic Str types"));
                                IntToString(1/0);
                            }
                        }
                        Str_used[i / 31] = Str_used[i / 31] + Power2(i % 31);
                        Str_index = i;
                        return i;
                    }
                 */

                /*AASourceFile file = Util.GetAncestor<AASourceFile>(node);
                GlobalStructVars vars = CreateStructFields(node, structDecl, data);

                AIntConstExp intConst1 = new AIntConstExp(new TIntegerLiteral("31"));
                AIntConstExp intConst2 = new AIntConstExp(new TIntegerLiteral("31"));
                AIntConstExp intConst3 = new AIntConstExp(new TIntegerLiteral("1"));
                AIntConstExp intConst4 = new AIntConstExp(new TIntegerLiteral(structDecl.GetIntDim().Text));
                AIntConstExp intConst5 = new AIntConstExp(new TIntegerLiteral("0"));
                AIntConstExp intConst6 = new AIntConstExp(new TIntegerLiteral("1"));
                AIntConstExp intConst7 = new AIntConstExp(new TIntegerLiteral("0"));
                AIntConstExp intConst8 = new AIntConstExp(new TIntegerLiteral("31"));
                AIntConstExp intConst9 = new AIntConstExp(new TIntegerLiteral("31"));
                AIntConstExp intConst10 = new AIntConstExp(new TIntegerLiteral("31"));

                AFieldLvalue strIndexRef1 = new AFieldLvalue(new TIdentifier(vars.Index.GetName().Text));
                AFieldLvalue strIndexRef2 = new AFieldLvalue(new TIdentifier(vars.Index.GetName().Text));
                AFieldLvalue strIndexRef3 = new AFieldLvalue(new TIdentifier(vars.Index.GetName().Text));
                ALvalueExp strIndexRef1Exp = new ALvalueExp(strIndexRef1);
                ALvalueExp strIndexRef2Exp = new ALvalueExp(strIndexRef2);

                AFieldLvalue strUsedRef1 = new AFieldLvalue(new TIdentifier(vars.Used.GetName().Text));
                AFieldLvalue strUsedRef2 = new AFieldLvalue(new TIdentifier(vars.Used.GetName().Text));
                AFieldLvalue strUsedRef3 = new AFieldLvalue(new TIdentifier(vars.Used.GetName().Text));
                ALvalueExp strUsedRef1Exp = new ALvalueExp(strUsedRef1);
                ALvalueExp strUsedRef2Exp = new ALvalueExp(strUsedRef2);
                ALvalueExp strUsedRef3Exp = new ALvalueExp(strUsedRef3);

                AALocalDecl iDecl = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null, new ANamedType(new TIdentifier("int"), null),
                                                    new TIdentifier("i"), strIndexRef1Exp);
                ALocalLvalue iRef1 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef2 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef3 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef4 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef5 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef6 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef7 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef8 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef9 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef10 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef11 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef12 = new ALocalLvalue(new TIdentifier("i"));
                ALvalueExp iRef1Exp = new ALvalueExp(iRef1);
                ALvalueExp iRef2Exp = new ALvalueExp(iRef2);
                ALvalueExp iRef4Exp = new ALvalueExp(iRef4);
                ALvalueExp iRef5Exp = new ALvalueExp(iRef5);
                ALvalueExp iRef7Exp = new ALvalueExp(iRef7);
                ALvalueExp iRef8Exp = new ALvalueExp(iRef8);
                ALvalueExp iRef9Exp = new ALvalueExp(iRef9);
                ALvalueExp iRef10Exp = new ALvalueExp(iRef10);
                ALvalueExp iRef11Exp = new ALvalueExp(iRef11);
                ALvalueExp iRef12Exp = new ALvalueExp(iRef12);

                ABinopExp binop1 = new ABinopExp(iRef1Exp, new ADivideBinop(new TDiv("/")), intConst1);
                ABinopExp binop2 = new ABinopExp(iRef2Exp, new AModuloBinop(new TMod("%")), intConst2);
                ABinopExp binop3 = new ABinopExp(null, new AAndBinop(new TAnd("&")), null);
                ABinopExp binop4 = new ABinopExp(iRef4Exp, new APlusBinop(new TPlus("+")), intConst3);
                ABinopExp binop5 = new ABinopExp(iRef5Exp, new AGeBinop(new TGteq(">=")), intConst4);
                ABinopExp binop6 = new ABinopExp(iRef7Exp, new AEqBinop(new TEq("==")), strIndexRef2Exp);
                ABinopExp binop7 = new ABinopExp(intConst6, new ADivideBinop(new TDiv("/")), intConst7);
                ABinopExp binop8 = new ABinopExp(iRef8Exp, new ADivideBinop(new TDiv("/")), intConst8);
                ABinopExp binop9 = new ABinopExp(iRef9Exp, new ADivideBinop(new TDiv("/")), intConst9);
                ABinopExp binop10 = new ABinopExp(iRef10Exp, new AModuloBinop(new TMod("%")), intConst10);
                ABinopExp binop11 = new ABinopExp(null, new APlusBinop(new TPlus("+")), null);

                ASimpleInvokeExp power2Invoke1 = new ASimpleInvokeExp(new TIdentifier("Power2"), new ArrayList() { binop2 });
                ASimpleInvokeExp power2Invoke2 = new ASimpleInvokeExp(new TIdentifier("Power2"), new ArrayList() { binop10 });
                binop3.SetRight(power2Invoke1);
                binop11.SetRight(power2Invoke2);

                AArrayLvalue arrayIndex1 = new AArrayLvalue(new TLBracket("["), strUsedRef1Exp, binop1);
                AArrayLvalue arrayIndex2 = new AArrayLvalue(new TLBracket("["), strUsedRef2Exp, binop8);
                AArrayLvalue arrayIndex3 = new AArrayLvalue(new TLBracket("["), strUsedRef3Exp, binop9);
                ALvalueExp arrayIndex1Exp = new ALvalueExp(arrayIndex1);
                ALvalueExp arrayIndex3Exp = new ALvalueExp(arrayIndex3);
                binop3.SetLeft(arrayIndex1Exp);
                binop11.SetLeft(arrayIndex3Exp);

                AAssignmentExp assignement1 = new AAssignmentExp(new TAssign("="), iRef3, binop4);
                AAssignmentExp assignement2 = new AAssignmentExp(new TAssign("="), iRef6, intConst5);
                AAssignmentExp assignement3 = new AAssignmentExp(new TAssign("="), arrayIndex2, binop11);
                AAssignmentExp assignement4 = new AAssignmentExp(new TAssign("="), strIndexRef3, iRef11Exp);

                ASimpleInvokeExp playerGroupAllInvoke = new ASimpleInvokeExp(new TIdentifier("PlayerGroupAll"), new ArrayList());
                AFieldLvalue messageAreaDebugRef = new AFieldLvalue(new TIdentifier("c_messageAreaDebug"));
                ALvalueExp messageAreaDebugRefExp = new ALvalueExp(messageAreaDebugRef);
                AStringConstExp stringConst =
                    new AStringConstExp(
                        new TStringLiteral("\"Galaxy++ Error: Unable to allocate more than " + structDecl.GetIntDim().Text +
                                           " dynamic " + structDecl.GetName().Text + " types.\""));
                ASimpleInvokeExp stringToTextInvoke = new ASimpleInvokeExp(new TIdentifier("StringToText"), new ArrayList(){stringConst});
                ASimpleInvokeExp displayMessageInvoke = new ASimpleInvokeExp(new TIdentifier("UIDisplayMessage"),
                                                                             new ArrayList()
                                                                                 {
                                                                                     playerGroupAllInvoke,
                                                                                     messageAreaDebugRefExp,
                                                                                     stringToTextInvoke
                                                                                 });
                ASimpleInvokeExp intToStringInvoke = new ASimpleInvokeExp(new TIdentifier("IntToString"),
                                                                          new ArrayList() {binop7});

                createStructMethod[structDecl] = new AMethodDecl(new APublicVisibilityModifier(), null, null, null, null, null,
                                                                 new ANamedType(new TIdentifier("int"), null),
                                                                 new TIdentifier("Create" + structDecl.GetName().Text, data.LineCounts[file] + 18, 0),
                                                                 new ArrayList(),
                                                                 new AABlock(
                                                                     new ArrayList()
                                                                         {
                                                                             new ALocalDeclStm(new TSemicolon(";"), iDecl),
                                                                             new AWhileStm(new TLParen("("), binop3,
                                                                                           new ABlockStm(new TLBrace("{"),
                                                                                                         new AABlock(
                                                                                                             new ArrayList()
                                                                                                                 {
                                                                                                                     new AExpStm
                                                                                                                         (new TSemicolon
                                                                                                                              (";"),
                                                                                                                          assignement1),
                                                                                                                     new AIfThenStm
                                                                                                                         (new TLParen
                                                                                                                              ("("),
                                                                                                                          binop5,
                                                                                                                          new ABlockStm
                                                                                                                              (new TLBrace
                                                                                                                                   ("{"),
                                                                                                                               new AABlock
                                                                                                                                   (new ArrayList
                                                                                                                                        ()
                                                                                                                                        {
                                                                                                                                            new AExpStm
                                                                                                                                                (new TSemicolon
                                                                                                                                                     (";"),
                                                                                                                                                 assignement2)
                                                                                                                                        },
                                                                                                                                    new TRBrace
                                                                                                                                        ("}")))),
                                                                                                                     new AIfThenStm
                                                                                                                         (new TLParen
                                                                                                                              ("("),
                                                                                                                          binop6,
                                                                                                                          new ABlockStm
                                                                                                                              (new TLBrace
                                                                                                                                   ("{"),
                                                                                                                               new AABlock
                                                                                                                                   (new ArrayList
                                                                                                                                        ()
                                                                                                                                        {
                                                                                                                                            new AExpStm
                                                                                                                                                (new TSemicolon
                                                                                                                                                     (";"),
                                                                                                                                                 displayMessageInvoke),
                                                                                                                                            new AExpStm
                                                                                                                                                (new TSemicolon
                                                                                                                                                     (";"),
                                                                                                                                                 intToStringInvoke)
                                                                                                                                        },
                                                                                                                                    new TRBrace
                                                                                                                                        ("}"))))
                                                                                                                 },
                                                                                                             new TRBrace(
                                                                                                                 "}")))),
                                                                             new AExpStm(new TSemicolon(";"), assignement3),
                                                                             new AExpStm(new TSemicolon(";"), assignement4),
                                                                             new AValueReturnStm(new TReturn("return"),
                                                                                                 iRef12Exp)
                                                                         },
                                                                     new TRBrace("}")));//66 lines! YEAH! you can see what that statement did

                file.GetDecl().Add(createStructMethod[structDecl]);

                data.LocalLinks[iRef1] =
                    data.LocalLinks[iRef2] =
                    data.LocalLinks[iRef3] =
                    data.LocalLinks[iRef4] =
                    data.LocalLinks[iRef5] =
                    data.LocalLinks[iRef6] =
                    data.LocalLinks[iRef7] =
                    data.LocalLinks[iRef8] =
                    data.LocalLinks[iRef9] =
                    data.LocalLinks[iRef10] =
                    data.LocalLinks[iRef11] =
                    data.LocalLinks[iRef12] = iDecl;
                data.FieldLinks[strUsedRef1] =
                    data.FieldLinks[strUsedRef2] =
                    data.FieldLinks[strUsedRef3] = vars.Used;
                data.FieldLinks[strIndexRef1] =
                    data.FieldLinks[strIndexRef2] =
                    data.FieldLinks[strIndexRef3] = vars.Index;
                data.SimpleMethodLinks[power2Invoke1] =
                    data.SimpleMethodLinks[power2Invoke2] = CreatePower2Method(node, data);
                data.FieldLinks[messageAreaDebugRef] =
                    data.Libraries.Fields.First(f => f.GetName().Text == messageAreaDebugRef.GetName().Text);
                data.SimpleMethodLinks[displayMessageInvoke] =
                    data.Libraries.Methods.First(m => m.GetName().Text == displayMessageInvoke.GetName().Text);
                data.SimpleMethodLinks[playerGroupAllInvoke] =
                    data.Libraries.Methods.First(m => m.GetName().Text == playerGroupAllInvoke.GetName().Text);
                data.SimpleMethodLinks[stringToTextInvoke] =
                    data.Libraries.Methods.First(m => m.GetName().Text == stringToTextInvoke.GetName().Text);
                data.SimpleMethodLinks[intToStringInvoke] =
                    data.Libraries.Methods.First(m => m.GetName().Text == intToStringInvoke.GetName().Text);

                data.ExpTypes[intConst1] =
                    data.ExpTypes[intConst2] =
                    data.ExpTypes[intConst3] =
                    data.ExpTypes[intConst4] =
                    data.ExpTypes[intConst5] =
                    data.ExpTypes[intConst6] =
                    data.ExpTypes[intConst7] =
                    data.ExpTypes[intConst8] =
                    data.ExpTypes[intConst9] =
                    data.ExpTypes[intConst10] =
                    data.LvalueTypes[strIndexRef1] =
                    data.LvalueTypes[strIndexRef2] =
                    data.LvalueTypes[strIndexRef3] =
                    data.ExpTypes[strIndexRef1Exp] =
                    data.ExpTypes[strIndexRef2Exp] =
                    data.LvalueTypes[iRef1] =
                    data.LvalueTypes[iRef2] =
                    data.LvalueTypes[iRef3] =
                    data.LvalueTypes[iRef4] =
                    data.LvalueTypes[iRef5] =
                    data.LvalueTypes[iRef6] =
                    data.LvalueTypes[iRef7] =
                    data.LvalueTypes[iRef8] =
                    data.LvalueTypes[iRef9] =
                    data.LvalueTypes[iRef10] =
                    data.LvalueTypes[iRef11] =
                    data.LvalueTypes[iRef12] =
                    data.ExpTypes[iRef1Exp] =
                    data.ExpTypes[iRef2Exp] =
                    data.ExpTypes[iRef4Exp] =
                    data.ExpTypes[iRef5Exp] =
                    data.ExpTypes[iRef7Exp] =
                    data.ExpTypes[iRef8Exp] =
                    data.ExpTypes[iRef9Exp] =
                    data.ExpTypes[iRef10Exp] =
                    data.ExpTypes[iRef11Exp] =
                    data.ExpTypes[iRef12Exp] =
                    data.LvalueTypes[arrayIndex1] =
                    data.LvalueTypes[arrayIndex2] =
                    data.LvalueTypes[arrayIndex3] =
                    data.ExpTypes[arrayIndex1Exp] =
                    data.ExpTypes[arrayIndex3Exp] =
                    data.ExpTypes[binop1] =
                    data.ExpTypes[binop2] =
                    data.ExpTypes[binop3] =
                    data.ExpTypes[binop4] =
                    data.ExpTypes[binop7] =
                    data.ExpTypes[binop8] =
                    data.ExpTypes[binop9] =
                    data.ExpTypes[binop10] =
                    data.ExpTypes[binop11] =
                    data.ExpTypes[power2Invoke1] =
                    data.ExpTypes[power2Invoke2] =
                    data.ExpTypes[intToStringInvoke] =
                    data.ExpTypes[assignement1] =
                    data.ExpTypes[assignement2] =
                    data.ExpTypes[assignement3] =
                    data.ExpTypes[assignement4] =
                    data.LvalueTypes[messageAreaDebugRef] =
                    data.ExpTypes[messageAreaDebugRefExp] = new ANamedType(new TIdentifier("int"), null);

                data.LvalueTypes[strUsedRef1] =
                    data.LvalueTypes[strUsedRef2] =
                    data.LvalueTypes[strUsedRef3] =
                    data.ExpTypes[strUsedRef1Exp] =
                    data.ExpTypes[strUsedRef2Exp] =
                    data.ExpTypes[strUsedRef3Exp] = vars.Used.GetType();

                data.ExpTypes[binop5] =
                    data.ExpTypes[binop6] = new ANamedType(new TIdentifier("int"), null);

                data.ExpTypes[stringConst] =
                    data.ExpTypes[intToStringInvoke] = new ANamedType(new TIdentifier("string"), null);

                data.ExpTypes[stringToTextInvoke] = new ANamedType(new TIdentifier("text"), null);

                data.ExpTypes[playerGroupAllInvoke] = new ANamedType(new TIdentifier("playergroup"), null);

                data.ExpTypes[displayMessageInvoke] = new AVoidType(new TVoid("void"));

                return createStructMethod[structDecl];*/

                #endregion
            }
            public static AMethodDecl CreateDeleteStructMethodGlobalArray(Node node, AStructDecl structDecl, SharedData data)
            {
                deleteStructMethod[structDecl] = CreateDeleteStructMethodGlobalArrayP(node, structDecl.GetIntDim(),
                                                                                      structDecl.GetName().Text,
                                                                                      CreateStructFields(node,
                                                                                                         structDecl,
                                                                                                         data), data);
                return deleteStructMethod[structDecl];

                #region Comment

                /*
                GlobalStructVars vars = CreateStructFields(node, structDecl, data);
                AASourceFile file = Util.GetAncestor<AASourceFile>(node);

                AIntConstExp intConst1 = new AIntConstExp(new TIntegerLiteral("31"));
                AIntConstExp intConst2 = new AIntConstExp(new TIntegerLiteral("31"));
                AIntConstExp intConst3 = new AIntConstExp(new TIntegerLiteral("31"));
                AIntConstExp intConst4 = new AIntConstExp(new TIntegerLiteral("31"));
                AIntConstExp intConst5 = new AIntConstExp(new TIntegerLiteral("31"));
                AIntConstExp intConst6 = new AIntConstExp(new TIntegerLiteral("31"));
                AIntConstExp intConst7 = new AIntConstExp(new TIntegerLiteral("31"));
                AIntConstExp intConst8 = new AIntConstExp(new TIntegerLiteral("1"));
                AIntConstExp intConst9 = new AIntConstExp(new TIntegerLiteral("0"));
                AIntConstExp intConst10 = new AIntConstExp(new TIntegerLiteral((int.Parse(structDecl.GetIntDim().Text) - 1).ToString()));

                AFieldLvalue strUsedRef1 = new AFieldLvalue(new TIdentifier(vars.Used.GetName().Text));
                AFieldLvalue strUsedRef2 = new AFieldLvalue(new TIdentifier(vars.Used.GetName().Text));
                AFieldLvalue strUsedRef3 = new AFieldLvalue(new TIdentifier(vars.Used.GetName().Text));
                AFieldLvalue strUsedRef4 = new AFieldLvalue(new TIdentifier(vars.Used.GetName().Text));
                ALvalueExp strUsedRef1Exp = new ALvalueExp(strUsedRef1);
                ALvalueExp strUsedRef2Exp = new ALvalueExp(strUsedRef2);
                ALvalueExp strUsedRef3Exp = new ALvalueExp(strUsedRef3);
                ALvalueExp strUsedRef4Exp = new ALvalueExp(strUsedRef4);

                AFieldLvalue strIndexRef1 = new AFieldLvalue(new TIdentifier(vars.Index.GetName().Text));
                AFieldLvalue strIndexRef2 = new AFieldLvalue(new TIdentifier(vars.Index.GetName().Text));
                AFieldLvalue strIndexRef3 = new AFieldLvalue(new TIdentifier(vars.Index.GetName().Text));
                ALvalueExp strIndexRef1Exp = new ALvalueExp(strIndexRef1);
                ALvalueExp strIndexRef2Exp = new ALvalueExp(strIndexRef2);

                AALocalDecl iDecl = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null, new ANamedType(new TIdentifier("int"), null),
                                                    new TIdentifier("i"), null);
                ALocalLvalue iRef1 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef2 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef3 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef4 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef5 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef6 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef7 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef8 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef9 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef10 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef11 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef12 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef13 = new ALocalLvalue(new TIdentifier("i"));
                ALocalLvalue iRef14 = new ALocalLvalue(new TIdentifier("i"));
                ALvalueExp iRef1Exp = new ALvalueExp(iRef1);
                ALvalueExp iRef2Exp = new ALvalueExp(iRef2);
                ALvalueExp iRef3Exp = new ALvalueExp(iRef3);
                ALvalueExp iRef4Exp = new ALvalueExp(iRef4);
                ALvalueExp iRef5Exp = new ALvalueExp(iRef5);
                ALvalueExp iRef6Exp = new ALvalueExp(iRef6);
                ALvalueExp iRef7Exp = new ALvalueExp(iRef7);
                ALvalueExp iRef8Exp = new ALvalueExp(iRef8);
                ALvalueExp iRef10Exp = new ALvalueExp(iRef10);
                ALvalueExp iRef11Exp = new ALvalueExp(iRef11);
                ALvalueExp iRef13Exp = new ALvalueExp(iRef13);
                ALvalueExp iRef14Exp = new ALvalueExp(iRef14);

                ABinopExp binop1 = new ABinopExp(iRef1Exp, new ADivideBinop(new TDiv("/")), intConst1);
                ABinopExp binop2 = new ABinopExp(iRef2Exp, new AModuloBinop(new TMod("%")), intConst2);
                ABinopExp binop3 = new ABinopExp(null, new AAndBinop(new TAnd("&")), null);
                ABinopExp binop4 = new ABinopExp(iRef3Exp, new ADivideBinop(new TDiv("/")), intConst3);
                ABinopExp binop5 = new ABinopExp(iRef4Exp, new ADivideBinop(new TDiv("/")), intConst4);
                ABinopExp binop6 = new ABinopExp(iRef5Exp, new AModuloBinop(new TMod("%")), intConst5);
                ABinopExp binop7 = new ABinopExp(null, new AMinusBinop(new TMinus("-")), null);
                ABinopExp binop8 = new ABinopExp(iRef6Exp, new AEqBinop(new TEq("==")), strIndexRef1Exp);
                ABinopExp binop9 = new ABinopExp(iRef7Exp, new ADivideBinop(new TDiv("/")), intConst6);
                ABinopExp binop10 = new ABinopExp(iRef8Exp, new AModuloBinop(new TMod("%")), intConst7);
                ABinopExp binop11 = new ABinopExp(null, new AAndBinop(new TAnd("&")), null);
                ABinopExp binop12 = new ABinopExp(iRef10Exp, new AMinusBinop(new TMinus("-")), intConst8);
                ABinopExp binop13 = new ABinopExp(iRef11Exp, new ALtBinop(new TLt("<")), intConst9);
                ABinopExp binop14 = new ABinopExp(iRef13Exp, new AEqBinop(new TEq("==")), strIndexRef2Exp);

                AArrayLvalue arrayIndex1 = new AArrayLvalue(new TLBracket("["), strUsedRef1Exp, binop1);
                AArrayLvalue arrayIndex2 = new AArrayLvalue(new TLBracket("["), strUsedRef2Exp, binop4);
                AArrayLvalue arrayIndex3 = new AArrayLvalue(new TLBracket("["), strUsedRef3Exp, binop5);
                AArrayLvalue arrayIndex4 = new AArrayLvalue(new TLBracket("["), strUsedRef4Exp, binop9);
                ALvalueExp arrayIndex1Exp = new ALvalueExp(arrayIndex1);
                ALvalueExp arrayIndex3Exp = new ALvalueExp(arrayIndex3);
                ALvalueExp arrayIndex4Exp = new ALvalueExp(arrayIndex4);
                binop3.SetLeft(arrayIndex1Exp);
                binop7.SetLeft(arrayIndex3Exp);
                binop11.SetLeft(arrayIndex4Exp);

                ASimpleInvokeExp power2Invoke1 = new ASimpleInvokeExp(new TIdentifier("Power2"), new ArrayList() { binop2 });
                ASimpleInvokeExp power2Invoke2 = new ASimpleInvokeExp(new TIdentifier("Power2"), new ArrayList() { binop6 });
                ASimpleInvokeExp power2Invoke3 = new ASimpleInvokeExp(new TIdentifier("Power2"), new ArrayList() { binop10 });
                binop3.SetRight(power2Invoke1);
                binop7.SetRight(power2Invoke2);
                binop11.SetRight(power2Invoke3);

                AParenExp paren1 = new AParenExp(binop3);
                AParenExp paren2 = new AParenExp(binop11);

                AUnopExp unop1 = new AUnopExp(new AComplementUnop(new TComplement("!")), paren1);
                AUnopExp unop2 = new AUnopExp(new AComplementUnop(new TComplement("!")), paren2);

                AAssignmentExp assignment1 = new AAssignmentExp(new TAssign("="), arrayIndex2, binop7);
                AAssignmentExp assignment2 = new AAssignmentExp(new TAssign("="), iRef9, binop12);
                AAssignmentExp assignment3 = new AAssignmentExp(new TAssign("="), iRef12, intConst10);
                AAssignmentExp assignment4 = new AAssignmentExp(new TAssign("="), strIndexRef3, iRef14Exp);

                deleteStructMethod[structDecl] = new AMethodDecl(new APublicVisibilityModifier(), null, null, null, null, null,
                                                                 new AVoidType(new TVoid("void")),
                                                                 new TIdentifier("Delete" + structDecl.GetName().Text, data.LineCounts[file] + 18, 0),
                                                                 new ArrayList() {iDecl},
                                                                 new AABlock(
                                                                     new ArrayList()
                                                                         {
                                                                             new AIfThenStm(new TLParen("("), unop1,
                                                                                            new ABlockStm(
                                                                                                new TLBrace("{"),
                                                                                                new AABlock(
                                                                                                    new ArrayList()
                                                                                                        {
                                                                                                            new AVoidReturnStm
                                                                                                                (new TReturn
                                                                                                                     ("return"))
                                                                                                        },
                                                                                                    new TRBrace("}")))),
                                                                             new AExpStm(new TSemicolon(";"),
                                                                                         assignment1),
                                                                             new AIfThenStm(new TLParen("("), binop8,
                                                                                            new ABlockStm(
                                                                                                new TLBrace("{"),
                                                                                                new AABlock(
                                                                                                    new ArrayList()
                                                                                                        {
                                                                                                            new AWhileStm
                                                                                                                (new TLParen
                                                                                                                     ("("),
                                                                                                                 unop2,
                                                                                                                 new ABlockStm
                                                                                                                     (new TLBrace
                                                                                                                          ("{"),
                                                                                                                      new AABlock
                                                                                                                          (new ArrayList
                                                                                                                               ()
                                                                                                                               {
                                                                                                                                   new AExpStm
                                                                                                                                       (new TSemicolon
                                                                                                                                            (";"),
                                                                                                                                        assignment2),
                                                                                                                                   new AIfThenStm
                                                                                                                                       (new TLParen
                                                                                                                                            ("("),
                                                                                                                                        binop13,
                                                                                                                                        new ABlockStm
                                                                                                                                            (new TLBrace
                                                                                                                                                 ("{"),
                                                                                                                                             new AABlock
                                                                                                                                                 (new ArrayList
                                                                                                                                                      ()
                                                                                                                                                      {
                                                                                                                                                          new AExpStm
                                                                                                                                                              (new TSemicolon
                                                                                                                                                                   (";"),
                                                                                                                                                               assignment3)
                                                                                                                                                      },
                                                                                                                                                  new TRBrace
                                                                                                                                                      ("}")))),
                                                                                                                                   new AIfThenStm
                                                                                                                                       (new TLParen
                                                                                                                                            ("("),
                                                                                                                                        binop14,
                                                                                                                                        new ABlockStm
                                                                                                                                            (new TLBrace
                                                                                                                                                 ("{"),
                                                                                                                                             new AABlock
                                                                                                                                                 (new ArrayList
                                                                                                                                                      ()
                                                                                                                                                      {
                                                                                                                                                          new ABreakStm
                                                                                                                                                              (new TBreak
                                                                                                                                                                   ("break"))
                                                                                                                                                      },
                                                                                                                                                  new TRBrace
                                                                                                                                                      ("}"))))
                                                                                                                               },
                                                                                                                           new TRBrace
                                                                                                                               ("}")))),
                                                                                                            new AExpStm(
                                                                                                                new TSemicolon
                                                                                                                    (";"),
                                                                                                                assignment4)
                                                                                                        },
                                                                                                    new TRBrace("}"))))
                                                                         },
                                                                      new TRBrace("}")));

                file.GetDecl().Add(deleteStructMethod[structDecl]);

                data.FieldLinks[strUsedRef1] =
                    data.FieldLinks[strUsedRef2] =
                    data.FieldLinks[strUsedRef3] =
                    data.FieldLinks[strUsedRef4] = vars.Used;
                data.FieldLinks[strIndexRef1] =
                    data.FieldLinks[strIndexRef2] =
                    data.FieldLinks[strIndexRef3] = vars.Index;
                data.LocalLinks[iRef1] =
                    data.LocalLinks[iRef2] =
                    data.LocalLinks[iRef3] =
                    data.LocalLinks[iRef4] =
                    data.LocalLinks[iRef5] =
                    data.LocalLinks[iRef6] =
                    data.LocalLinks[iRef7] =
                    data.LocalLinks[iRef8] =
                    data.LocalLinks[iRef9] =
                    data.LocalLinks[iRef10] =
                    data.LocalLinks[iRef11] =
                    data.LocalLinks[iRef12] =
                    data.LocalLinks[iRef13] =
                    data.LocalLinks[iRef14] = iDecl;
                data.SimpleMethodLinks[power2Invoke1] =
                    data.SimpleMethodLinks[power2Invoke2] =
                    data.SimpleMethodLinks[power2Invoke3] = CreatePower2Method(node, data);

                data.ExpTypes[intConst1] =
                    data.ExpTypes[intConst2] =
                    data.ExpTypes[intConst3] =
                    data.ExpTypes[intConst4] =
                    data.ExpTypes[intConst5] =
                    data.ExpTypes[intConst6] =
                    data.ExpTypes[intConst7] =
                    data.ExpTypes[intConst8] =
                    data.ExpTypes[intConst9] =
                    data.ExpTypes[intConst10] =
                    data.LvalueTypes[iRef1] =
                    data.LvalueTypes[iRef2] =
                    data.LvalueTypes[iRef3] =
                    data.LvalueTypes[iRef4] =
                    data.LvalueTypes[iRef5] =
                    data.LvalueTypes[iRef6] =
                    data.LvalueTypes[iRef7] =
                    data.LvalueTypes[iRef8] =
                    data.LvalueTypes[iRef9] =
                    data.LvalueTypes[iRef10] =
                    data.LvalueTypes[iRef11] =
                    data.LvalueTypes[iRef12] =
                    data.LvalueTypes[iRef13] =
                    data.LvalueTypes[iRef14] =
                    data.ExpTypes[iRef1Exp] =
                    data.ExpTypes[iRef2Exp] =
                    data.ExpTypes[iRef3Exp] =
                    data.ExpTypes[iRef4Exp] =
                    data.ExpTypes[iRef5Exp] =
                    data.ExpTypes[iRef6Exp] =
                    data.ExpTypes[iRef7Exp] =
                    data.ExpTypes[iRef8Exp] =
                    data.ExpTypes[iRef10Exp] =
                    data.ExpTypes[iRef11Exp] =
                    data.ExpTypes[iRef13Exp] =
                    data.ExpTypes[iRef14Exp] =
                    data.LvalueTypes[arrayIndex1] =
                    data.LvalueTypes[arrayIndex2] =
                    data.LvalueTypes[arrayIndex3] =
                    data.LvalueTypes[arrayIndex4] =
                    data.ExpTypes[arrayIndex1Exp] =
                    data.ExpTypes[arrayIndex3Exp] =
                    data.ExpTypes[arrayIndex4Exp] =
                    data.ExpTypes[binop1] =
                    data.ExpTypes[binop2] =
                    data.ExpTypes[binop3] =
                    data.ExpTypes[binop4] =
                    data.ExpTypes[binop5] =
                    data.ExpTypes[binop6] =
                    data.ExpTypes[binop7] =
                    data.ExpTypes[binop9] =
                    data.ExpTypes[binop10] =
                    data.ExpTypes[binop11] =
                    data.ExpTypes[binop12] =
                    data.ExpTypes[paren1] =
                    data.ExpTypes[paren2] =
                    data.ExpTypes[power2Invoke1] =
                    data.ExpTypes[power2Invoke2] =
                    data.ExpTypes[power2Invoke3] = new ANamedType(new TIdentifier("int"), null);

                data.ExpTypes[binop8] =
                    data.ExpTypes[binop13] =
                    data.ExpTypes[binop14] =
                    data.ExpTypes[unop1] =
                    data.ExpTypes[unop2] = new ANamedType(new TIdentifier("bool"), null);

                return deleteStructMethod[structDecl];*/

                #endregion
            }
            public static AMethodDecl CreateDeleteStructMethod(Node node, AStructDecl structDecl, SharedData data)
            {
                if (deleteStructMethod.ContainsKey(structDecl))
                    return deleteStructMethod[structDecl];

                if (structDecl.GetIntDim() == null)
                    return CreateDeleteStructMethodDataTable(node, structDecl, data);
                return CreateDeleteStructMethodGlobalArray(node, structDecl, data);
            }