コード例 #1
0
ファイル: HasseDiagram.cs プロジェクト: luckysunda/hice-dt
        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;
        }
コード例 #2
0
ファイル: HasseDiagram.cs プロジェクト: Chenguang-Zhu/ICE-C5
        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;            
        }