Exemplo n.º 1
0
    /*
     * Test the dominance set
     */
    private static void TestDomaintes(int index, SortedSet <int> expected)
    {
        IRGraph cfg = BuildSampleCFG();

        SortedSet <IRBlock> V      = cfg.GetSetOfAllBlocks();
        SortedSet <IRBlock> VSansR = new SortedSet <IRBlock>();

        VSansR.UnionWith(V);
        VSansR.Remove(cfg.GetGraphHead());

        SortedSet <IRBlock> result    = DominatorTree.CalculateDominatesSet(cfg, V, VSansR, cfg.GetBlock(index));
        SortedSet <int>     intResult = ConvertToIndexSet(result);

        if (!intResult.SetEquals(expected))
        {
            throw new Exception("Dominates blocks for block " + index + " is " + ConvertSetToString(intResult) + " should be " + ConvertSetToString(expected));
        }
    }