public void DominatorTreeTest() { var root = Parser.ParseString(Samples.SampleProgramText.domSampleTrivial); var code = ProgramTreeToLinear.Build(root); var blocks = LYtest.BaseBlocks.LinearToBaseBlock.Build(code); var cfg = ListBlocksToCFG.Build(blocks); var dt = new LYtest.DominatorTree.DominatorTree(cfg); var node = dt.GetRoot(); Console.WriteLine(dt.ToString()); Console.WriteLine(cfg.ToString()); Assert.AreEqual(dt.NumberOfVertices(), 4); }
public void DominatorTreeDemo() { var root = Parser.ParseString(Samples.SampleProgramText.sample2); var code = ProgramTreeToLinear.Build(root); var blocks = LYtest.BaseBlocks.LinearToBaseBlock.Build(code); var cfg = ListBlocksToCFG.Build(blocks); var dt = new LYtest.DominatorTree.DominatorTree(cfg); var node = dt.GetRoot(); cfg.ShowCompact = true; Console.WriteLine(cfg); Console.WriteLine("\nDominator tree:"); Console.WriteLine(dt.ToString()); }