successorsOf() публичный Метод

public successorsOf ( $vertex )
Пример #1
0
 /**
  * @covers ::process
  * @covers ::implementSSA
  */
 public function testOperationLoopWithPhi()
 {
     $graph = new DirectedAdjacencyList();
     $a = new Variable();
     $func = new Function_([$a], new Type(0), $graph);
     $start = new NoOp();
     $noOp = new NoOp();
     $jumpz = new JumpZ($noOp, $a);
     $graph->ensureArc($func, $start);
     $graph->ensureArc($start, $jumpz);
     $graph->ensureArc($jumpz, $r = new Return_($a));
     $graph->ensureArc($r, new End());
     $graph->ensureArc($jumpz, $binary = new BinaryOp(BinaryOp::PLUS, $a, new Constant(2), $a));
     $graph->ensureArc($binary, $j = new Jump());
     $graph->ensureArc($j, $start);
     $state = new GraphState($func);
     $compiler = new SSACompiler();
     $compiler->process($state);
     $this->assertSame([$a], $func->getArguments());
     $i = 0;
     foreach ($graph->successorsOf($start) as $v) {
         $this->assertEquals(0, $i++, 'More then one adjacent node');
         $this->assertInstanceOf(Phi::class, $v);
         $this->assertContains($a, $v->getValues());
         $this->assertSame($r->getValue(), $v->getResult());
     }
 }