Exemple #1
0
        protected List <Block> m_GetErrorTraceFromCE(DoomErrorHandler cb)
        {
            BlockHierachyNode tn         = null;
            List <Block>      errortrace = new List <Block>();

            foreach (Block b in cb.TraceNodes)
            {
                if (errortrace.Contains(b))
                {
                    continue;
                }
                if (m_BlockH.BlockToHierachyMap.TryGetValue(b, out tn))
                {
                    foreach (Block b_ in tn.Unavoidable)
                    {
                        if (!errortrace.Contains(b_))
                        {
                            errortrace.Add(b_);
                        }
                    }
                    foreach (Block b_ in tn.Content)
                    {
                        if (!errortrace.Contains(b_))
                        {
                            errortrace.Add(b_);
                        }
                    }
                }
            }
            return(errortrace);
        }
Exemple #2
0
 // Compare the unavoidable blocks of two BlockHierachyNodes. 
 // returns 0 if sets have the same size, -1 if l2 has an element 
 // that is not in l1, otherwise the size of the intersection.
 public static int Compare(BlockHierachyNode l1, BlockHierachyNode l2)
 {
     List<Block> tmp = new List<Block>();
     tmp.AddRange(l2.Unavoidable);
     foreach (Block b in l1.Unavoidable)
     {
         if (tmp.Contains(b)) tmp.Remove(b);
         else return -1;
     }
     return tmp.Count;
 }
Exemple #3
0
        public List <Block> GetOtherDoomedBlocks(List <Block> doomedblocks)
        {
            List <Block>             alsoDoomed = new List <Block>();
            List <BlockHierachyNode> todo       = new List <BlockHierachyNode>();

            foreach (Block b in doomedblocks)
            {
                BlockToHierachyMap[b].Doomed = true;
                todo.Add(BlockToHierachyMap[b]);
            }

            while (todo.Count > 0)
            {
                BlockHierachyNode current = todo[0];
                todo.Remove(current);
                if (!current.Doomed && current.Children.Count > 0)
                {
                    bool childrenDoomed = true;
                    foreach (BlockHierachyNode c in current.Children)
                    {
                        if (!c.Doomed)
                        {
                            childrenDoomed = false; break;
                        }
                    }
                    if (childrenDoomed)
                    {
                        current.Doomed = true;
                    }
                }

                if (current.Doomed)
                {
                    foreach (BlockHierachyNode p in current.Parents)
                    {
                        if (!todo.Contains(p))
                        {
                            todo.Add(p);
                        }
                    }
                    foreach (Block b in current.Content)
                    {
                        if (!alsoDoomed.Contains(b))
                        {
                            alsoDoomed.Add(b);
                        }
                    }
                }
            }

            return(alsoDoomed);
        }
Exemple #4
0
        // Compare the unavoidable blocks of two BlockHierachyNodes.
        // returns 0 if sets have the same size, -1 if l2 has an element
        // that is not in l1, otherwise the size of the intersection.
        public static int Compare(BlockHierachyNode l1, BlockHierachyNode l2)
        {
            List <Block> tmp = new List <Block>();

            tmp.AddRange(l2.Unavoidable);
            foreach (Block b in l1.Unavoidable)
            {
                if (tmp.Contains(b))
                {
                    tmp.Remove(b);
                }
                else
                {
                    return(-1);
                }
            }
            return(tmp.Count);
        }
Exemple #5
0
        public BlockHierachy(Implementation impl, Block unifiedExit)
        {
            m_Impl = impl;
            List <Block>                      blocks      = impl.Blocks;
            List <BlockHierachyNode>          tmp_hnodes  = new List <BlockHierachyNode>();
            Dictionary <Block, List <Block> > unavoidable = new Dictionary <Block, List <Block> >();

            BfsTraverser(blocks[0], true, Dominators);
            BfsTraverser(unifiedExit, false, PostDominators);

            foreach (Block b in blocks)
            {
                List <Block> l1 = Dominators[b];
                List <Block> l2 = PostDominators[b];
                unavoidable[b] = m_MergeLists(l1, l2);

                BlockHierachyNode bhn = new BlockHierachyNode(b, unavoidable[b]);
                bool found            = false;
                foreach (KeyValuePair <Block, BlockHierachyNode> kvp in BlockToHierachyMap)
                {
                    if (BlockHierachyNode.Compare(kvp.Value, bhn) == 0) // using the overloaded compare operator
                    {
                        kvp.Value.Content.AddRange(bhn.Content);
                        BlockToHierachyMap[b] = kvp.Value;
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    BlockToHierachyMap[b] = bhn;
                    tmp_hnodes.Add(bhn);
                }
            }

            HasseDiagram hd = new HasseDiagram(tmp_hnodes);

            Leaves = hd.Leaves;
        }
Exemple #6
0
        public BlockHierachy(Implementation impl, Block unifiedExit)
        {
            m_Impl = impl;
            List<Block> blocks = impl.Blocks;
            List<BlockHierachyNode> tmp_hnodes = new List<BlockHierachyNode>();
            Dictionary<Block, List<Block>> unavoidable = new Dictionary<Block, List<Block>>();

            BfsTraverser(blocks[0], true, Dominators);
            BfsTraverser(unifiedExit, false, PostDominators);

            foreach (Block b in blocks)
            {
                List<Block> l1 = Dominators[b];
                List<Block> l2 = PostDominators[b];
                unavoidable[b] = m_MergeLists(l1, l2);

                BlockHierachyNode bhn = new BlockHierachyNode(b, unavoidable[b]);
                bool found = false;
                foreach (KeyValuePair<Block, BlockHierachyNode> kvp in BlockToHierachyMap)
                {
                    if (BlockHierachyNode.Compare(kvp.Value, bhn) == 0) // using the overloaded compare operator
                    {
                        kvp.Value.Content.AddRange(bhn.Content);
                        BlockToHierachyMap[b] = kvp.Value;
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    BlockToHierachyMap[b] = bhn;
                    tmp_hnodes.Add(bhn);
                }
            }

            HasseDiagram hd = new HasseDiagram(tmp_hnodes);
            Leaves = hd.Leaves;            
        }