예제 #1
0
 def testMergeOneVariable(self):
     p = cfg.Program()
     n0 = p.NewCFGNode("n0")
     u = p.NewVariable([0], [], n0)
     self.assertIs(cfg_utils.MergeVariables(p, n0, [u]), u)
     self.assertIs(cfg_utils.MergeVariables(p, n0, [u, u]), u)
     self.assertIs(cfg_utils.MergeVariables(p, n0, [u, u, u]), u)
예제 #2
0
 def testMergeVariables(self):
     p = cfg.Program()
     n0, n1, n2 = p.NewCFGNode("n0"), p.NewCFGNode("n1"), p.NewCFGNode("n2")
     u = p.NewVariable()
     u1 = u.AddBinding(0, source_set=[], where=n0)
     v = p.NewVariable()
     v.AddBinding(1, source_set=[], where=n1)
     v.AddBinding(2, source_set=[], where=n1)
     w = p.NewVariable()
     w.AddBinding(1, source_set=[u1], where=n1)
     w.AddBinding(3, source_set=[], where=n1)
     vw = cfg_utils.MergeVariables(p, n2, [v, w])
     self.assertItemsEqual(vw.data, [1, 2, 3])
     val1, = [v for v in vw.bindings if v.data == 1]
     self.assertTrue(val1.HasSource(u1))
예제 #3
0
 def testMergeZeroVariables(self):
     p = cfg.Program()
     n0 = p.NewCFGNode("n0")
     self.assertIsInstance(cfg_utils.MergeVariables(p, n0, []),
                           cfg.Variable)