示例#1
0
文件: Demos.cs 项目: koyre/b8
        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);
        }
示例#2
0
文件: UnitTest1.cs 项目: nikki161/b8
        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("-----------------------");
            }
        }