PHPCfg\Op\Phi::addOperand PHP Method

addOperand() public method

public addOperand ( Operand $op )
$op PHPCfg\Operand
    public function addOperand(Operand $op)
    {
        if ($op === $this->result) {
            return;
        }
        if (!$this->hasOperand($op)) {
            $this->vars[] = $this->addReadRef($op);
        }
    }

Usage Example

Beispiel #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;
 }