public void ReachingDefsIterTest() { 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 defs = new ReachingDefsIterAlg(cfg); cfg.InfoFunc = node => { var outs = string.Join(", ", defs.Out[node]); var ins = node.ParentsNodes.Count > 0 ? string.Join(", ", defs.In[node]) : ""; return($" In: {ins} \n\t\t\tOut: {outs}"); }; Console.WriteLine(cfg); }
public void ReachingDefsIterTest() { 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 defs = new ReachingDefsIterAlg(cfg); foreach (var block in cfg.graph.Vertices) { Console.Write(block); foreach (var labelValue in defs.Out[block]) { Console.Write(labelValue); Console.Write(", "); } Console.WriteLine(); Console.WriteLine("-----------------------"); } }