Esempio n. 1
0
 /**
  * @covers ::__construct
  * @covers ::getType
  * @covers ::setType
  */
 public function testSetType()
 {
     $variable = new Variable();
     $this->assertEquals(new Type(Type::TYPE_UNKNOWN), $variable->getType());
     $variable->setType(new Type(Type::TYPE_LONG));
     $this->assertEquals(new Type(Type::TYPE_LONG), $variable->getType());
 }
Esempio n. 2
0
 /**
  * @covers ::process
  */
 public function testWithoutChange()
 {
     $rule = new BitwiseNot();
     $vertex = new JitBitwiseNot($a = new Variable(new Type(Type::TYPE_LONG)), $r = new Variable(new Type(Type::TYPE_DOUBLE)));
     $this->assertFalse($rule->process($vertex, $this->getMock(DirectedAdjacencyList::class)));
     $this->assertEquals(Type::TYPE_DOUBLE, $r->getType()->getType());
 }
Esempio n. 3
0
 /**
  * @covers ::process
  */
 public function testInValidKind()
 {
     $rule = new BinaryOp();
     $vertex = new JitBinaryOp(-1, $a = new Variable(), $b = new Variable(), $r = new Variable());
     $this->assertFalse($rule->process($vertex, $this->getMock(DirectedAdjacencyList::class)));
     $this->assertEquals(Type::TYPE_UNKNOWN, $r->getType()->getType());
 }
Esempio n. 4
0
 /**
  * @covers ::process
  */
 public function testAssignWithoutChange()
 {
     $rule = new Assign();
     $vertex = new JitAssign($a = new Variable(new Type(Type::TYPE_LONG)), $r = new Variable(new Type(Type::TYPE_DOUBLE)));
     $this->assertFalse($rule->process($vertex, $this->getMock(DirectedAdjacencyList::class)));
     $this->assertEquals('double', (string) $r->getType());
 }
Esempio n. 5
0
 public function implementSSA(Variable $old, Variable $new, Vertex $vertex, Digraph $graph, \SplObjectStorage $phiNodes, array $args)
 {
     if ($this->stack->contains($vertex)) {
         if (isset($phiNodes[$vertex])) {
             // we've visited, so it **must** have a node implemented
             $phiNodes[$vertex]->addValue($new);
         }
         return;
     }
     $this->stack->attach($vertex);
     if ($old !== $new && !$vertex instanceof Phi) {
         $vertex->replaceVariable($old, $new);
     }
     if ($vertex instanceof JitAssignment && $vertex->getResult() === $old) {
         $new = new Variable($new->getType());
         $vertex->setResult($new);
     }
     if (isset($phiNodes[$vertex])) {
         if ($phiNodes[$vertex] === true) {
             // insert phiNode
             $next = new Variable();
             $phi = new Phi($next);
             $phiNodes[$vertex] = $phi;
             if ($old !== $new || in_array($old, $args, true)) {
                 $phiNodes[$vertex]->addValue($new);
             }
             Helper::insertAfter($vertex, $phiNodes[$vertex], $graph);
             $new = $next;
         } else {
             $phiNodes[$vertex]->addValue($new);
         }
     }
     foreach ($graph->successorsOf($vertex) as $sub) {
         // Depth first search
         $this->implementSSA($old, $new, $sub, $graph, $phiNodes, $args);
     }
 }