PHPCfg\FuncContext::addToIncompletePhis PHP Method

addToIncompletePhis() public method

public addToIncompletePhis ( Block $block, $name, Phi $phi )
$block Block
$phi PHPCfg\Op\Phi
    public function addToIncompletePhis(Block $block, $name, Op\Phi $phi)
    {
        if (!isset($this->incompletePhis[$block])) {
            $this->incompletePhis[$block] = [];
        }
        // Because PHP.
        $phis = $this->incompletePhis[$block];
        $phis[$name] = $phi;
        $this->incompletePhis[$block] = $phis;
    }

Usage Example

Example #1
0
 private function readVariableRecursive($name, Block $block)
 {
     if ($this->ctx->complete) {
         if (count($block->parents) === 1 && !$block->parents[0]->dead) {
             // Special case, just return the read var
             return $this->readVariableName($name, $block->parents[0]);
         }
         $var = new Operand\Temporary(new Variable(new Literal($name)));
         $phi = new Op\Phi($var, ["block" => $block]);
         $block->phi[] = $phi;
         // Prevent unbound recursion
         $this->writeVariableName($name, $var, $block);
         foreach ($block->parents as $parent) {
             if ($parent->dead) {
                 continue;
             }
             $phi->addOperand($this->readVariableName($name, $parent));
         }
         return $var;
     }
     $var = new Operand\Temporary(new Variable(new Literal($name)));
     $phi = new Op\Phi($var, ["block" => $block]);
     $this->ctx->addToIncompletePhis($block, $name, $phi);
     $this->writeVariableName($name, $var, $block);
     return $var;
 }