public override void OutABinopExp(ABinopExp node)
        {
            if (node.Parent() is ABinopExp || node.Parent() is AUnopExp)
            {
                AParenExp paren = new AParenExp();
                node.ReplaceBy(paren);
                paren.SetExp(node);

                finalTrans.data.ExpTypes[paren] = finalTrans.data.ExpTypes[node];
            }
            base.OutABinopExp(node);
        }
Пример #2
0
 public virtual void InAParenExp(AParenExp node)
 {
     DefaultIn(node);
 }
Пример #3
0
 public virtual void OutAParenExp(AParenExp node)
 {
     DefaultOut(node);
 }
Пример #4
0
 public virtual void CaseAParenExp(AParenExp node)
 {
     DefaultCase(node);
 }
Пример #5
0
 public override void CaseAParenExp(AParenExp node)
 {
     InAParenExp(node);
     if (node.GetExp() != null)
     {
         node.GetExp().Apply(this);
     }
     OutAParenExp(node);
 }
 public override void OutAParenExp(AParenExp node)
 {
     data.ExpTypes[node] = data.ExpTypes[node.GetExp()];
     base.OutAParenExp(node);
 }
Пример #7
0
 public override void CaseAParenExp(AParenExp node)
 {
     PExp replacer = node.GetExp();
     node.ReplaceBy(replacer);
     replacer.Apply(this);
 }
Пример #8
0
 ArrayList New590()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList5 = (ArrayList) Pop();
     ArrayList nodeArrayList4 = (ArrayList) Pop();
     ArrayList nodeArrayList3 = (ArrayList) Pop();
     ArrayList nodeArrayList2 = (ArrayList) Pop();
     ArrayList nodeArrayList1 = (ArrayList) Pop();
     PExp pexpNode3 = (PExp)nodeArrayList2[0];
     AParenExp pexpNode2 = new AParenExp (
       pexpNode3
     );
     TArrow tarrowNode5 = (TArrow)nodeArrayList4[0];
     AArrowDotType pdottypeNode4 = new AArrowDotType (
       tarrowNode5
     );
     TIdentifier tidentifierNode6 = (TIdentifier)nodeArrayList5[0];
     AStructLvalue plvalueNode1 = new AStructLvalue (
       pexpNode2,
       pdottypeNode4,
       tidentifierNode6
     );
     nodeList.Add(plvalueNode1);
     return nodeList;
 }
 public override void CaseAParenExp(AParenExp node)
 {
     Write("(");
     node.GetExp().Apply(this);
     Write(")");
 }
Пример #10
0
 ArrayList New429()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList3 = (ArrayList) Pop();
     ArrayList nodeArrayList2 = (ArrayList) Pop();
     ArrayList nodeArrayList1 = (ArrayList) Pop();
     PExp pexpNode2 = (PExp)nodeArrayList2[0];
     AParenExp pexpNode1 = new AParenExp (
       pexpNode2
     );
     nodeList.Add(pexpNode1);
     return nodeList;
 }
Пример #11
0
 ArrayList New395()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList8 = (ArrayList) Pop();
     ArrayList nodeArrayList7 = (ArrayList) Pop();
     ArrayList nodeArrayList6 = (ArrayList) Pop();
     ArrayList nodeArrayList5 = (ArrayList) Pop();
     ArrayList nodeArrayList4 = (ArrayList) Pop();
     ArrayList nodeArrayList3 = (ArrayList) Pop();
     ArrayList nodeArrayList2 = (ArrayList) Pop();
     ArrayList nodeArrayList1 = (ArrayList) Pop();
     TypedList listNode8 = new TypedList();
     PExp pexpNode3 = (PExp)nodeArrayList2[0];
     AParenExp pexpNode2 = new AParenExp (
       pexpNode3
     );
     TArrow tarrowNode5 = (TArrow)nodeArrayList4[0];
     AArrowDotType pdottypeNode4 = new AArrowDotType (
       tarrowNode5
     );
     TIdentifier tidentifierNode6 = (TIdentifier)nodeArrayList5[0];
     TypedList listNode7 = (TypedList)nodeArrayList7[0];
     if ( listNode7 != null )
     {
     listNode8.AddAll(listNode7);
     }
     ANonstaticInvokeExp pexpNode1 = new ANonstaticInvokeExp (
       pexpNode2,
       pdottypeNode4,
       tidentifierNode6,
       listNode8
     );
     nodeList.Add(pexpNode1);
     return nodeList;
 }
Пример #12
0
 ArrayList New343()
 {
     ArrayList nodeList = new ArrayList();
     ArrayList nodeArrayList6 = (ArrayList) Pop();
     ArrayList nodeArrayList5 = (ArrayList) Pop();
     ArrayList nodeArrayList4 = (ArrayList) Pop();
     ArrayList nodeArrayList3 = (ArrayList) Pop();
     ArrayList nodeArrayList2 = (ArrayList) Pop();
     ArrayList nodeArrayList1 = (ArrayList) Pop();
     TLBracket tlbracketNode2 = (TLBracket)nodeArrayList4[0];
     PExp pexpNode4 = (PExp)nodeArrayList2[0];
     AParenExp pexpNode3 = new AParenExp (
       pexpNode4
     );
     PExp pexpNode5 = (PExp)nodeArrayList5[0];
     AArrayLvalue plvalueNode1 = new AArrayLvalue (
       tlbracketNode2,
       pexpNode3,
       pexpNode5
     );
     nodeList.Add(plvalueNode1);
     return nodeList;
 }
Пример #13
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;
            }
 public override void CaseAParenExp(AParenExp node)
 {
     Value += "(";
     base.CaseAParenExp(node);
     Value += ")";
 }