Exemplo n.º 1
0
 private void GetBPAddrRange(FuncBlock fblock)
 {
     if (fblock.IsBreakpoint)
     {
         bpaddrmin = Math.Max(bpaddrmin, fblock.BPAddress);
         bpaddrmax = Math.Max(bpaddrmax, fblock.BPAddress);
     }
     if (fblock is FuncBlock_ForHeader)
     {
         FuncBlock_ForHeader fblockfh = (FuncBlock_ForHeader)fblock;
         GetBPAddrRange(fblockfh.Start);
         GetBPAddrRange(fblockfh.Cond);
         GetBPAddrRange(fblockfh.Next);
     }
     if (fblock is FuncBlock_WhileHeader)
     {
         FuncBlock_WhileHeader fblockwh = (FuncBlock_WhileHeader)fblock;
         GetBPAddrRange(fblockwh.Cond);
     }
     if (fblock is FuncBlock_IfHeader)
     {
         FuncBlock_IfHeader fblockih = (FuncBlock_IfHeader)fblock;
         GetBPAddrRange(fblockih.Cond);
     }
     if (fblock is FuncBlock_WhileEnd)
     {
         FuncBlock_WhileEnd fblockwe = (FuncBlock_WhileEnd)fblock;
         GetBPAddrRange(fblockwe.Cond);
     }
     foreach (FuncBlock child in fblock.Childrens)
     {
         GetBPAddrRange(child);
     }
 }
Exemplo n.º 2
0
 private void InitBP(FuncBlock fblock)
 {
     fblock.IsBreakpoint = false;
     if (fblock is FuncBlock_ForHeader)
     {
         FuncBlock_ForHeader fblockfh = (FuncBlock_ForHeader)fblock;
         InitBP(fblockfh.Start);
         InitBP(fblockfh.Cond);
         InitBP(fblockfh.Next);
     }
     if (fblock is FuncBlock_WhileHeader)
     {
         FuncBlock_WhileHeader fblockwh = (FuncBlock_WhileHeader)fblock;
         InitBP(fblockwh.Cond);
     }
     if (fblock is FuncBlock_IfHeader)
     {
         FuncBlock_IfHeader fblockih = (FuncBlock_IfHeader)fblock;
         InitBP(fblockih.Cond);
     }
     if (fblock is FuncBlock_WhileEnd)
     {
         FuncBlock_WhileEnd fblockwe = (FuncBlock_WhileEnd)fblock;
         InitBP(fblockwe.Cond);
     }
     foreach (FuncBlock child in fblock.Childrens)
     {
         InitBP(child);
     }
 }
Exemplo n.º 3
0
        static private void FuncToCCode(
            StreamWriter sw,
            FuncBlock fblock,
            string code)
        {
            string text = String.Empty;
            string divi = String.Empty;
            int    bp   = 0;
            int    prev = fblock.IndexStart;

            if (fblock is FuncBlock_Root ||
                fblock is FuncBlock_Local)
            {
                if (fblock is FuncBlock_Local)
                {
                    sw.Write("{\n");
                }
                foreach (FuncBlock child in fblock.Childrens)
                {
                    if (prev < child.IndexStart)
                    {
                        sw.Write(code.Substring(prev, child.IndexStart - prev));
                    }
                    if (child is FuncBlock_Local)
                    {
                        FuncToCCode(sw, child, code);
                    }
                }
                BreakPointManager.Register(fblock);
                bp = fblock.BPAddress;
                sw.Write("bpcycle({0});\n", bp);
                if (fblock is FuncBlock_Local)
                {
                    sw.Write("}\n");
                }
            }
            else if (fblock is FuncBlock_ForHeader)
            {
                FuncBlock_ForHeader fblockfh = (FuncBlock_ForHeader)fblock;
                sw.Write("for (");
                if (fblockfh.Start != null)
                {
                    BreakPointManager.Register(fblockfh.Start);
                    bp = fblockfh.Start.BPAddress;
                    sw.Write("bpcycle({0}),{1}",
                             bp, ReplaceType(code, fblockfh.Start.IndexStart, fblockfh.Start.Length));
                }
                //sw.Write(";");
                if (fblockfh.Cond != null)
                {
                    BreakPointManager.Register(fblockfh.Cond);
                    bp = fblockfh.Cond.BPAddress;
                    sw.Write("bpcycle({0}),{1}",
                             bp, ReplaceType(code, fblockfh.Cond.IndexStart, fblockfh.Cond.Length));
                }
                //sw.Write(";");
                if (fblockfh.Next != null)
                {
                    BreakPointManager.Register(fblockfh.Next);
                    bp = fblockfh.Next.BPAddress;
                    sw.Write("bpcycle({0}),{1}",
                             bp, ReplaceType(code, fblockfh.Next.IndexStart, fblockfh.Next.Length));
                }
                sw.Write(")");
            }
            else if (fblock is FuncBlock_WhileHeader)
            {
                FuncBlock_WhileHeader fblockwh = (FuncBlock_WhileHeader)fblock;
                sw.Write("while (");
                if (fblockwh.Cond != null)
                {
                    BreakPointManager.Register(fblockwh.Cond);
                    bp = fblockwh.Cond.BPAddress;
                    sw.Write("bpcycle({0}),{1}",
                             bp, ReplaceType(code, fblockwh.Cond.IndexStart, fblockwh.Cond.Length));
                }
                sw.Write(")");
            }
            else
            {
                if (!(fblock is FuncBlock_Root))
                {
                    BreakPointManager.Register(fblock);
                    bp = fblock.BPAddress;
                    sw.Write("bpcycle({0});\n", bp);
                }
                sw.Write("{0}\n", ReplaceType(code, fblock.IndexStart, fblock.Length));
            }
        }