public override ISet <string> GetKill(BasicBlock block)
        {
            //Kill = Def
            DefUseBlockCalculator DefUseCalc = new DefUseBlockCalculator();

            return(DefUseCalc.GetDefUseSetsByBlock(block).Item1);
        }
        public override ISet <string> GetGen(BasicBlock block)
        {
            //Gen == Use
            DefUseBlockCalculator DefUseCalc = new DefUseBlockCalculator();

            return(DefUseCalc.GetDefUseSetsByBlock(block).Item2);
        }
        public void TestDefUse()
        {
            string programText = @"
                                a = 4;
                                b = 4;
                                c = a + b;
                                if 1 
                                    a = 3;
                                else
                                    b = 2;
                                print(c);
                                ";

            SyntaxNode      root             = ParserWrap.Parse(programText);
            var             threeAddressCode = ThreeAddressCodeGenerator.CreateAndVisit(root).Program;
            BasicBlocksList basicBlocks      = BasicBlocksGenerator.CreateBasicBlocks(threeAddressCode);

            DefUseBlockCalculator defUse = new DefUseBlockCalculator();

            var defUseList = new List <KeyValuePair <int, Tuple <ISet <string>, ISet <string> > > >();

            foreach (var block in basicBlocks)
            {
                defUseList.Add(new KeyValuePair <int, Tuple <ISet <string>, ISet <string> > >(block.BlockId, defUse.GetDefUseSetsByBlock(block)));
            }

            Assert.IsTrue(defUseList[0].Value.Item1
                          .SetEquals(
                              new HashSet <string>(new string[]
            {
                "a",
                "t0",
                "b",
                "c"
            })));
            Assert.IsTrue(defUseList[0].Value.Item2.Count == 0);

            Assert.IsTrue(defUseList[1].Value.Item1
                          .SetEquals(
                              new HashSet <string>(new string[]
            {
                "a"
            })));
            Assert.IsTrue(defUseList[1].Value.Item2.Count == 0);

            Assert.IsTrue(defUseList[2].Value.Item1
                          .SetEquals(
                              new HashSet <string>(new string[]
            {
                "b"
            })));
            Assert.IsTrue(defUseList[2].Value.Item2.Count == 0);

            Assert.IsTrue(defUseList[3].Value.Item2
                          .SetEquals(
                              new HashSet <string>(new string[]
            {
                "c"
            })));
            Assert.IsTrue(defUseList[3].Value.Item1.Count == 0);
        }