Beispiel #1
0
        public Loop getLoopInformation(List <int> loop)
        {
            List <LoopPart> b      = new List <LoopPart>();
            LoopPart        h      = new LoopPart(loop[0], true);
            List <int>      childs = getChildren(loop[0]);
            List <int>      exits  = new List <int>();

            foreach (int c in childs)
            {
                if (!loop.Contains(c))
                {
                    h.isBreak = true;
                    if (!exits.Contains(c))
                    {
                        exits.Add(c);
                    }
                }
            }
            for (int i = 1; i < loop.Count; i++)
            {
                childs = getChildren(loop[i]);
                bool isContinue = false;
                bool isBreak    = false;
                bool isTail     = true;
                foreach (int c in childs)
                {
                    if (c == h.index)
                    {
                        isContinue = true;
                    }
                    else if (loop.Contains(c))
                    {
                        isTail = false;
                    }
                    else
                    {
                        isBreak = true;
                        if (!exits.Contains(c))
                        {
                            exits.Add(c);
                        }
                    }
                }
                bool       hasOutsideEntry = false;
                List <int> parents         = getParents(loop[i]);
                foreach (int p in parents)
                {
                    if (!loop.Contains(p))
                    {
                        hasOutsideEntry = true;
                    }
                }
                b.Add(new LoopPart(loop[i], false, isTail, isBreak, isContinue, hasOutsideEntry));
            }
            return(new Loop(h, b, exits.Count > 1));
        }
Beispiel #2
0
 public Loop(LoopPart h, List <LoopPart> b, bool multi)
 {
     header      = h;
     body        = b;
     isMultiExit = multi;
 }