Exemplo n.º 1
0
        public void SetIntegerLiteral(TIntegerLiteral node)
        {
            if (_integer_literal_ != null)
            {
                _integer_literal_.Parent(null);
            }

            if (node != null)
            {
                if (node.Parent() != null)
                {
                    node.Parent().RemoveChild(node);
                }

                node.Parent(this);
            }

            _integer_literal_ = node;
        }
Exemplo n.º 2
0
 internal override void RemoveChild(Node child)
 {
     if (_integer_literal_ == child)
     {
         _integer_literal_ = null;
         return;
     }
 }
Exemplo n.º 3
0
 internal override void RemoveChild(Node child)
 {
     if (_token_ == child)
     {
         _token_ = null;
         return;
     }
     if (_dimention_ == child)
     {
         _dimention_ = null;
         return;
     }
     if (_int_dim_ == child)
     {
         _int_dim_ = null;
         return;
     }
     if (_end_token_ == child)
     {
         _end_token_ = null;
         return;
     }
     if (_type_ == child)
     {
         _type_ = null;
         return;
     }
     if (_decl_.Contains(child))
     {
         _decl_.Remove(child);
         return;
     }
 }
Exemplo n.º 4
0
 public AIntConstExp(
         TIntegerLiteral _integer_literal_
 )
 {
     SetIntegerLiteral(_integer_literal_);
 }
Exemplo n.º 5
0
 internal override void RemoveChild(Node child)
 {
     if (_token_ == child)
     {
         _token_ = null;
         return;
     }
     if (_type_ == child)
     {
         _type_ = null;
         return;
     }
     if (_dimention_ == child)
     {
         _dimention_ = null;
         return;
     }
     if (_int_dim_ == child)
     {
         _int_dim_ = null;
         return;
     }
 }
Exemplo n.º 6
0
 public AEnrichmentDecl(
         TEnrichment _token_,
         PExp _dimention_,
         TIntegerLiteral _int_dim_,
         TRBrace _end_token_,
         PType _type_,
         IList _decl_
 )
 {
     SetToken(_token_);
     SetDimention(_dimention_);
     SetIntDim(_int_dim_);
     SetEndToken(_end_token_);
     SetType(_type_);
     this._decl_ = new TypedList(new Decl_Cast(this));
     this._decl_.Clear();
     this._decl_.AddAll(_decl_);
 }
Exemplo n.º 7
0
 internal override void RemoveChild(Node child)
 {
     if (_visibility_modifier_ == child)
     {
         _visibility_modifier_ = null;
         return;
     }
     if (_class_token_ == child)
     {
         _class_token_ = null;
         return;
     }
     if (_dimention_ == child)
     {
         _dimention_ = null;
         return;
     }
     if (_int_dim_ == child)
     {
         _int_dim_ = null;
         return;
     }
     if (_end_token_ == child)
     {
         _end_token_ = null;
         return;
     }
     if (_name_ == child)
     {
         _name_ = null;
         return;
     }
     if (_generic_vars_.Contains(child))
     {
         _generic_vars_.Remove(child);
         return;
     }
     if (_base_ == child)
     {
         _base_ = null;
         return;
     }
     if (_locals_.Contains(child))
     {
         _locals_.Remove(child);
         return;
     }
 }
Exemplo n.º 8
0
 public AArrayTempType(
         TLBracket _token_,
         PType _type_,
         PExp _dimention_,
         TIntegerLiteral _int_dim_
 )
 {
     SetToken(_token_);
     SetType(_type_);
     SetDimention(_dimention_);
     SetIntDim(_int_dim_);
 }
Exemplo n.º 9
0
 public virtual void CaseTIntegerLiteral(TIntegerLiteral node)
 {
     DefaultCase(node);
 }
Exemplo n.º 10
0
 public AStructDecl(
         PVisibilityModifier _visibility_modifier_,
         TClassToken _class_token_,
         PExp _dimention_,
         TIntegerLiteral _int_dim_,
         TRBrace _end_token_,
         TIdentifier _name_,
         IList _generic_vars_,
         PType _base_,
         IList _locals_
 )
 {
     SetVisibilityModifier(_visibility_modifier_);
     SetClassToken(_class_token_);
     SetDimention(_dimention_);
     SetIntDim(_int_dim_);
     SetEndToken(_end_token_);
     SetName(_name_);
     this._generic_vars_ = new TypedList(new GenericVars_Cast(this));
     this._generic_vars_.Clear();
     this._generic_vars_.AddAll(_generic_vars_);
     SetBase(_base_);
     this._locals_ = new TypedList(new Locals_Cast(this));
     this._locals_.Clear();
     this._locals_.AddAll(_locals_);
 }
Exemplo n.º 11
0
 public override void CaseTIntegerLiteral(TIntegerLiteral node)
 {
     index = 94;
 }
Exemplo n.º 12
0
            private static AMethodDecl CreateNullCheckMethodP(Node node, TIntegerLiteral intLiteral, string prefix, GlobalStructVars vars, SharedData data)
            {
                /*
                 *
                            <<usedBits := floor(log2(42))+1>>
                            <<bitsLeft := 31 - usedBits>>
                            <<biggestIdentifier := 2^(bitsLeft + 1) - 1>>
                 *
                 *  bool prefix_IsNull(int pointer)
                 *  {
                 *      int identifier;
                 *      if (pointer == 0)
                 *      {
                 *          return true;
                 *      }
                 *      identifier = pointer & biggestIdentifier;
                 *      pointer = pointer >> bitsLeft;
                 *      return (Str_used[pointer / 31] & (1 << (pointer % 31))) == 0 || identifierArray[pointer] != identifier;
                 *  }
                 */
                int usedLimit = int.Parse(intLiteral.Text);
                int usedBits = usedLimit == 0 ? 0 : ((int)Math.Floor(Math.Log(usedLimit, 2)) + 1);
                int bitsLeft = 31 - usedBits;
                int biggestIdentifier = (1 << (bitsLeft + 1)) - 1;

                AALocalDecl pointerDecl = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
                                                          new ANamedType(new TIdentifier("int"), null),
                                                          new TIdentifier("pointer"), null);
                AALocalDecl identifierDecl = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
                                                             new ANamedType(new TIdentifier("int"), null),
                                                             new TIdentifier("identifier"), null);

                ALocalLvalue pointerRef1 = new ALocalLvalue(new TIdentifier("pointer"));
                ALocalLvalue pointerRef2 = new ALocalLvalue(new TIdentifier("pointer"));
                ALocalLvalue pointerRef3 = new ALocalLvalue(new TIdentifier("pointer"));
                ALocalLvalue pointerRef4 = new ALocalLvalue(new TIdentifier("pointer"));
                ALocalLvalue pointerRef5 = new ALocalLvalue(new TIdentifier("pointer"));
                ALocalLvalue pointerRef6 = new ALocalLvalue(new TIdentifier("pointer"));
                ALocalLvalue pointerRef7 = new ALocalLvalue(new TIdentifier("pointer"));
                ALvalueExp pointerRef1Exp = new ALvalueExp(pointerRef1);
                ALvalueExp pointerRef2Exp = new ALvalueExp(pointerRef2);
                ALvalueExp pointerRef4Exp = new ALvalueExp(pointerRef4);
                ALvalueExp pointerRef5Exp = new ALvalueExp(pointerRef5);
                ALvalueExp pointerRef6Exp = new ALvalueExp(pointerRef6);
                ALvalueExp pointerRef7Exp = new ALvalueExp(pointerRef7);

                ALocalLvalue identifierRef1 = new ALocalLvalue(new TIdentifier("identifier"));
                ALocalLvalue identifierRef2 = new ALocalLvalue(new TIdentifier("identifier"));
                ALvalueExp identifierRef2Exp = new ALvalueExp(identifierRef2);

                AFieldLvalue usedRef = new AFieldLvalue(new TIdentifier("used"));
                ALvalueExp usedRefExp = new ALvalueExp(usedRef);

                AFieldLvalue identifierArrayRef = new AFieldLvalue(new TIdentifier("identifierArray"));
                ALvalueExp identifierArrayRefExp = new ALvalueExp(identifierArrayRef);

                AIntConstExp intConst1 = new AIntConstExp(new TIntegerLiteral("0"));
                AIntConstExp intConst2 = new AIntConstExp(new TIntegerLiteral(biggestIdentifier.ToString()));
                AIntConstExp intConst3 = new AIntConstExp(new TIntegerLiteral(bitsLeft.ToString()));
                AIntConstExp intConst4 = new AIntConstExp(new TIntegerLiteral("31"));
                AIntConstExp intConst5 = new AIntConstExp(new TIntegerLiteral("1"));
                AIntConstExp intConst6 = new AIntConstExp(new TIntegerLiteral("31"));
                AIntConstExp intConst7 = new AIntConstExp(new TIntegerLiteral("0"));

                ABinopExp binop4 = new ABinopExp(pointerRef5Exp, new ADivideBinop(new TDiv("/")), intConst4);

                AArrayLvalue arrayLvalue1 = new AArrayLvalue(new TLBracket("["), usedRefExp, binop4);
                AArrayLvalue arrayLvalue2 = new AArrayLvalue(new TLBracket("["), identifierArrayRefExp, pointerRef7Exp);
                ALvalueExp arrayLvalue1Exp = new ALvalueExp(arrayLvalue1);
                ALvalueExp arrayLvalue2Exp = new ALvalueExp(arrayLvalue2);

                ABinopExp binop1 = new ABinopExp(pointerRef1Exp, new AEqBinop(new TEq("==")), intConst1);
                ABinopExp binop2 = new ABinopExp(pointerRef2Exp, new AAndBinop(new TAnd("&")), intConst2);
                ABinopExp binop3 = new ABinopExp(pointerRef4Exp, new ARBitShiftBinop(new TRBitShift(">>")), intConst3);
                ABinopExp binop5 = new ABinopExp(pointerRef6Exp, new AModuloBinop(new TMod("%")), intConst6);
                ABinopExp binop6 = new ABinopExp(intConst5, new ALBitShiftBinop(new TLBitShift("<<")), binop5);
                ABinopExp binop7 = new ABinopExp(arrayLvalue1Exp, new AAndBinop(new TAnd("&")), binop6);
                ABinopExp binop8 = new ABinopExp(binop7, new AEqBinop(new TEq("==")), intConst7);
                ABinopExp binop9 = new ABinopExp(arrayLvalue2Exp, new ANeBinop(new TNeq("!=")), identifierRef2Exp);
                ABinopExp binop10 = new ABinopExp(binop8, new ALazyOrBinop(new TOrOr("||")), binop9);

                AAssignmentExp assignment1 = new AAssignmentExp(new TAssign("="), identifierRef1, binop2);
                AAssignmentExp assignment2 = new AAssignmentExp(new TAssign("="), pointerRef3, binop3);

                ABooleanConstExp boolConst = new ABooleanConstExp(new ATrueBool());

                AMethodDecl method = new AMethodDecl(new APublicVisibilityModifier(), null, null, null, null, null,
                                                     new ANamedType(new TIdentifier("bool"), null),
                                                     new TIdentifier(prefix + "_IsNull"), new ArrayList() {pointerDecl},
                                                     new AABlock(
                                                         new ArrayList()
                                                             {
                                                                 new ALocalDeclStm(new TSemicolon(";"), identifierDecl),
                                                                 new AIfThenStm(new TLParen("("), binop1,
                                                                                new ABlockStm(new TLBrace("{"),
                                                                                              new AABlock(
                                                                                                  new ArrayList()
                                                                                                      {
                                                                                                          new AValueReturnStm
                                                                                                              (new TReturn(
                                                                                                                   "return"),
                                                                                                               boolConst)
                                                                                                      },
                                                                                                  new TRBrace("}")))),
                                                                 new AExpStm(new TSemicolon(";"), assignment1),
                                                                 new AExpStm(new TSemicolon(";"), assignment2),
                                                                 new AValueReturnStm(new TReturn("return"), binop10)
                                                             },
                                                         new TRBrace("}")));

                AASourceFile sourceFile = Util.GetAncestor<AASourceFile>(node);
                sourceFile.GetDecl().Add(method);

                data.LocalLinks[pointerRef1] =
                    data.LocalLinks[pointerRef2] =
                    data.LocalLinks[pointerRef3] =
                    data.LocalLinks[pointerRef4] =
                    data.LocalLinks[pointerRef5] =
                    data.LocalLinks[pointerRef6] =
                    data.LocalLinks[pointerRef7] = pointerDecl;

                data.LocalLinks[identifierRef1] =
                    data.LocalLinks[identifierRef2] = identifierDecl;

                data.FieldLinks[usedRef] = vars.Used;
                data.FieldLinks[identifierArrayRef] = vars.IdentifierArray;

                data.LvalueTypes[pointerRef1] =
                    data.LvalueTypes[pointerRef2] =
                    data.LvalueTypes[pointerRef3] =
                    data.LvalueTypes[pointerRef4] =
                    data.LvalueTypes[pointerRef5] =
                    data.LvalueTypes[pointerRef6] =
                    data.LvalueTypes[pointerRef7] =
                    data.ExpTypes[pointerRef1Exp] =
                    data.ExpTypes[pointerRef2Exp] =
                    data.ExpTypes[pointerRef4Exp] =
                    data.ExpTypes[pointerRef5Exp] =
                    data.ExpTypes[pointerRef6Exp] =
                    data.ExpTypes[pointerRef7Exp] =
                    data.LvalueTypes[identifierRef1] =
                    data.LvalueTypes[identifierRef2] =
                    data.ExpTypes[identifierRef2Exp] =
                    data.ExpTypes[intConst1] =
                    data.ExpTypes[intConst2] =
                    data.ExpTypes[intConst3] =
                    data.ExpTypes[intConst4] =
                    data.ExpTypes[intConst5] =
                    data.ExpTypes[intConst6] =
                    data.ExpTypes[intConst7] =
                    data.ExpTypes[intConst1] =
                    data.ExpTypes[binop2] =
                    data.ExpTypes[binop3] =
                    data.ExpTypes[binop4] =
                    data.ExpTypes[binop5] =
                    data.ExpTypes[binop6] =
                    data.ExpTypes[binop7] =
                    data.LvalueTypes[arrayLvalue1] =
                    data.LvalueTypes[arrayLvalue2] =
                    data.ExpTypes[arrayLvalue1Exp] =
                    data.ExpTypes[arrayLvalue2Exp] =
                    data.ExpTypes[assignment1] =
                    data.ExpTypes[assignment2] = new ANamedType(new TIdentifier("int"), null);

                data.ExpTypes[binop1] =
                    data.ExpTypes[binop8] =
                    data.ExpTypes[binop9] =
                    data.ExpTypes[binop10] =
                    data.ExpTypes[boolConst] = new ANamedType(new TIdentifier("bool"), null);

                data.LvalueTypes[usedRef] =
                    data.LvalueTypes[identifierArrayRef] =
                    data.ExpTypes[usedRefExp] =
                    data.ExpTypes[identifierArrayRefExp] = vars.IdentifierArray.GetType();

                return method;
            }
Exemplo n.º 13
0
            private static AMethodDecl CreateNewObjectMethodP(Node node, TIntegerLiteral intLiteral, string prefix, GlobalStructVars vars, SharedData data)
            {
                if (intLiteral == null)
                    return CreateNewObjectMethod(node, data);

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

                /*
                    int CreateStr()
                    {
                        int i = Str_index;
                        while (Str_used[i / 31] & 1 << (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;
                        <<if it is being compared with null at any point in time>>
                            <<usedBits := floor(log2(42))+1>>
                            <<bitsLeft := 31 - usedBits>>
                            <<biggestIdentifier := 2^(bitsLeft + 1) - 1>>
                            identifierArray[i] = identifierNext;
                            i = (i << bitsLeft) + identifierNext;
                            identifierNext = identifierNext%biggestIdentifier + 1;
                        return i;
                    }
                 */

                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("1"));
                AIntConstExp intConst4 = new AIntConstExp(new TIntegerLiteral(intLiteral.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"));

                AIntConstExp intConst11 = new AIntConstExp(new TIntegerLiteral("1"));
                AIntConstExp intConst12 = new AIntConstExp(new TIntegerLiteral("1"));

                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);

                ABinopExp binop12 = new ABinopExp(intConst11, new ALBitShiftBinop(new TLBitShift("<<")), binop2);
                ABinopExp binop13 = new ABinopExp(intConst12, new ALBitShiftBinop(new TLBitShift("<<")), binop10);
                binop3.SetRight(binop12);
                binop11.SetRight(binop13);

                //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 " + intLiteral.Text +
                                           " dynamic " + prefix + " 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 });

                AABlock methodBlock = 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 TRBrace("}"));

                if (vars.IdentifierArray != null)
                {
                    /*
                        <<if it is being compared with null at any point in time>>
                            <<usedBits := floor(log2(42))+1>>
                            <<bitsLeft := 31 - usedBits>>
                            <<biggestIdentifier := 2^(bitsLeft + 1) - 1>>
                            identifierArray[i] = identifierNext;
                            i = (i << bitsLeft) + identifierNext;
                            identifierNext = identifierNext%biggestIdentifier + 1;
                    */
                    int usedLimit = int.Parse(intLiteral.Text);
                    int usedBits = usedLimit == 0 ? 0 : ((int)Math.Floor(Math.Log(usedLimit, 2)) + 1);
                    int bitsLeft = 31 - usedBits;
                    int biggestIdentifier = (1 << (bitsLeft + 1)) - 1;

                    AIntConstExp bitsLeftConst = new AIntConstExp(new TIntegerLiteral(bitsLeft.ToString()));
                    AIntConstExp biggestIdentifierConst = new AIntConstExp(new TIntegerLiteral(biggestIdentifier.ToString()));
                    AIntConstExp oneIntConst = new AIntConstExp(new TIntegerLiteral("1"));
                    ALocalLvalue secondIRef1 = new ALocalLvalue(new TIdentifier("i"));
                    ALocalLvalue secondIRef2 = new ALocalLvalue(new TIdentifier("i"));
                    ALocalLvalue secondIRef3 = new ALocalLvalue(new TIdentifier("i"));
                    ALvalueExp secondIRef2Exp = new ALvalueExp(secondIRef2);
                    ALvalueExp secondIRef3Exp = new ALvalueExp(secondIRef3);
                    AFieldLvalue identierNExtRef1 = new AFieldLvalue(new TIdentifier("identiferNext"));
                    AFieldLvalue identierNExtRef2 = new AFieldLvalue(new TIdentifier("identiferNext"));
                    AFieldLvalue identierNExtRef3 = new AFieldLvalue(new TIdentifier("identiferNext"));
                    AFieldLvalue identierNExtRef4 = new AFieldLvalue(new TIdentifier("identiferNext"));
                    ALvalueExp identierNExtRef1Exp = new ALvalueExp(identierNExtRef1);
                    ALvalueExp identierNExtRef3Exp = new ALvalueExp(identierNExtRef3);
                    ALvalueExp identierNExtRef4Exp = new ALvalueExp(identierNExtRef4);
                    AFieldLvalue identifierArrayRef = new AFieldLvalue(new TIdentifier("identifierArray"));
                    ALvalueExp identifierArrayRefExp = new ALvalueExp(identifierArrayRef);

                    AArrayLvalue arrayLvalue = new AArrayLvalue(new TLBracket("["), identifierArrayRefExp, secondIRef3Exp);

                    AAssignmentExp secondAssignment3 = new AAssignmentExp(new TAssign("="), arrayLvalue, identierNExtRef4Exp);

                    methodBlock.GetStatements().Add(new AExpStm(new TSemicolon(";"), secondAssignment3));

                    ABinopExp secondBinop1 = new ABinopExp(secondIRef2Exp, new ALBitShiftBinop(new TLBitShift("<<")), bitsLeftConst);
                    ABinopExp secondBinop2 = new ABinopExp(secondBinop1, new APlusBinop(new TPlus("+")), identierNExtRef1Exp);

                    AAssignmentExp secondAssignment1 = new AAssignmentExp(new TAssign("="), secondIRef1, secondBinop2);

                    methodBlock.GetStatements().Add(new AExpStm(new TSemicolon(";"), secondAssignment1));

                    ABinopExp secondBinop3 = new ABinopExp(identierNExtRef3Exp, new AModuloBinop(new TMod("%")), biggestIdentifierConst);
                    ABinopExp secondBinop4 = new ABinopExp(secondBinop3, new APlusBinop(new TPlus("+")), oneIntConst);

                    AAssignmentExp secondAssignment2 = new AAssignmentExp(new TAssign("="), identierNExtRef2, secondBinop4);

                    methodBlock.GetStatements().Add(new AExpStm(new TSemicolon(";"), secondAssignment2));

                    data.LvalueTypes[secondIRef1] =
                        data.LvalueTypes[secondIRef2] =
                        data.ExpTypes[bitsLeftConst] =
                        data.ExpTypes[biggestIdentifierConst] =
                        data.ExpTypes[oneIntConst] =
                        data.ExpTypes[secondIRef2Exp] =
                        data.LvalueTypes[identierNExtRef1] =
                        data.LvalueTypes[identierNExtRef2] =
                        data.LvalueTypes[identierNExtRef3] =
                        data.ExpTypes[identierNExtRef1Exp] =
                        data.ExpTypes[identierNExtRef3Exp] =
                        data.ExpTypes[secondBinop1] =
                        data.ExpTypes[secondBinop2] =
                        data.ExpTypes[secondAssignment1] =
                        data.ExpTypes[secondBinop3] =
                        data.ExpTypes[secondBinop4] =
                        data.ExpTypes[secondAssignment2] =
                        data.LvalueTypes[secondIRef3] =
                        data.LvalueTypes[identierNExtRef4] =
                        data.ExpTypes[secondIRef3Exp] =
                        data.ExpTypes[identierNExtRef4Exp] =
                        data.LvalueTypes[arrayLvalue] =
                        data.ExpTypes[secondAssignment3] = new ANamedType(new TIdentifier("int"), null);

                    data.LvalueTypes[identifierArrayRef] =
                        data.ExpTypes[identifierArrayRefExp] = vars.IdentifierArray.GetType();

                    data.LocalLinks[secondIRef1] =
                        data.LocalLinks[secondIRef2] =
                        data.LocalLinks[secondIRef3] = iDecl;

                    data.FieldLinks[identierNExtRef1] =
                        data.FieldLinks[identierNExtRef2] =
                        data.FieldLinks[identierNExtRef3] =
                        data.FieldLinks[identierNExtRef4] = vars.IdentifierNext;

                    data.FieldLinks[identifierArrayRef] = vars.IdentifierArray;
                }

                methodBlock.GetStatements().Add(new AValueReturnStm(new TReturn("return"), iRef12Exp));

                AMethodDecl method = new AMethodDecl(new APublicVisibilityModifier(), null, null, null, null, null,
                                                                 new ANamedType(new TIdentifier("int"), null),
                                                                 new TIdentifier("Create" + prefix, data.LineCounts[file] + 18, 0),
                                                                 new ArrayList(),
                                                                 methodBlock);

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

                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.ExpTypes[intConst11] =
                    data.ExpTypes[intConst12] =
                    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[binop12] =
                    data.ExpTypes[binop13] =
                    //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 method;
            }
Exemplo n.º 14
0
            //Removed check on top, and get type
            public static GlobalStructVars CreatePointerFields(Node node, TIntegerLiteral literal, string prefix, PType type, SharedData data, bool createArray = true)
            {
                AASourceFile file = Util.GetAncestor<AASourceFile>(node);

                AFieldDecl array = new AFieldDecl(new APublicVisibilityModifier(), null, null,
                                                  new AArrayTempType(new TLBracket("["), type,
                                                                     new AIntConstExp(
                                                                         new TIntegerLiteral(literal.Text)),
                                                                     new TIntegerLiteral(literal.Text)),
                                                                     new TIdentifier(prefix + "_array", data.LineCounts[file] + 20, 0),
                                                                     null);
                int length = (int)Math.Ceiling(float.Parse(literal.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(prefix + "_used", data.LineCounts[file] + 20, 0),
                                                                     null);
                AFieldDecl index = new AFieldDecl(new APublicVisibilityModifier(), null, null, new ANamedType(new TIdentifier("int"), null),
                                                                     new TIdentifier(prefix + "_index", data.LineCounts[file] + 20, 0),
                                                                     null);
                bool addIdentiferArray = false;
                foreach (PType t in intPointersWithCmp)
                {
                    if (Util.TypesEqual(type, t, data))
                    {
                        addIdentiferArray = true;
                        break;
                    }
                }
                AFieldDecl identiferCount = null;
                AFieldDecl identiferArray = null;
                if (addIdentiferArray)
                {
                    identiferArray = new AFieldDecl(new APublicVisibilityModifier(), null, null,
                                                 new AArrayTempType(new TLBracket("["), new ANamedType(new TIdentifier("int"), null),
                                                                    new AIntConstExp(
                                                                        new TIntegerLiteral(literal.Text)),
                                                                    new TIntegerLiteral(literal.Text)),
                                                                    new TIdentifier(prefix + "_identifierArray", data.LineCounts[file] + 20, 0),
                                                                    null);
                    identiferCount = new AFieldDecl(new APublicVisibilityModifier(), null, null, new ANamedType(new TIdentifier("int"), null),
                                                                         new TIdentifier(prefix + "_identiferNext", data.LineCounts[file] + 20, 0),
                                                                         new AIntConstExp(new TIntegerLiteral("1")));
                    file.GetDecl().Add(identiferArray);
                    file.GetDecl().Add(identiferCount);

                    data.Fields.Add(new SharedData.DeclItem<AFieldDecl>(file, identiferArray));
                    data.Fields.Add(new SharedData.DeclItem<AFieldDecl>(file, identiferCount));

                    data.ExpTypes[((AArrayTempType)identiferArray.GetType()).GetDimention()] =
                        data.ExpTypes[identiferCount.GetInit()] =
                        new ANamedType(new TIdentifier("int"), null);
                }
                if (createArray)
                    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);

                if (createArray)
                    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));

                return new GlobalStructVars(createArray ? array : null, used, index, identiferArray, identiferCount);
            }
Exemplo n.º 15
0
            public static AMethodDecl CreateDeleteStructMethodGlobalArrayP(Node node, TIntegerLiteral intDim, string prefix, GlobalStructVars vars, SharedData data)
            {
                /*
                    void DeleteStr(int i)
                    {
                        if (!(Str_used[i / 31] & Power2(i % 31)))
                        {
                            return;
                        }
                        Str_used[i / 31] = Str_used[i / 31] - Power2(i % 31);
                        stack[freeCount] = i;
                        freeCount += 1;
                        /*if (i == Str_index)
                        {
                            while (!(Str_used[i / 31] & Power2(i % 31)))
                            {
                                i = i - 1;
                                if (i < 0)
                                {
                                    i = 41;
                                }
                                if (i == Str_index)
                                {
                                    //Everything is free
                                    break;
                                }
                            }
                            Str_index = i;
                        }* /
                    }
                 */

                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(intDim.Text) - 1).ToString()));
                AIntConstExp intConst11 = new AIntConstExp(new TIntegerLiteral("1"));
                AIntConstExp intConst12 = new AIntConstExp(new TIntegerLiteral("1"));
                AIntConstExp intConst13 = new AIntConstExp(new TIntegerLiteral("1"));

                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);

                ABinopExp binop15 = new ABinopExp(intConst11, new ALBitShiftBinop(new TLBitShift("<<")), binop2);
                ABinopExp binop16 = new ABinopExp(intConst12, new ALBitShiftBinop(new TLBitShift("<<")), binop6);
                ABinopExp binop17 = new ABinopExp(intConst13, new ALBitShiftBinop(new TLBitShift("<<")), binop10);
                binop3.SetRight(binop15);
                binop7.SetRight(binop16);
                binop11.SetRight(binop17);
                /*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);

                AMethodDecl method = new AMethodDecl(new APublicVisibilityModifier(), null, null, null, null, null,
                                                                 new AVoidType(new TVoid("void")),
                                                                 new TIdentifier("Delete" + prefix, 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(method);
                data.Methods.Add(new SharedData.DeclItem<AMethodDecl>(file, method));

                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.ExpTypes[intConst11] =
                    data.ExpTypes[intConst12] =
                    data.ExpTypes[intConst13] =
                    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[binop15] =
                    data.ExpTypes[binop16] =
                    data.ExpTypes[binop17] =
                    data.ExpTypes[paren1] =
                    data.ExpTypes[paren2] =
                    data.ExpTypes[assignment1] =
                    data.ExpTypes[assignment2] =
                    data.ExpTypes[assignment3] =
                    data.ExpTypes[assignment4] =
                    /*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 method;
            }