protected function render(Func $func)
{
if (null !== $func->cfg) {
$this->enqueueBlock($func->cfg);
}
$renderedOps = new \SplObjectStorage();
$renderedBlocks = new \SplObjectStorage();
while ($this->blockQueue->count() > 0) {
$block = $this->blockQueue->dequeue();
$ops = [];
if ($block === $func->cfg) {
foreach ($func->params as $param) {
$renderedOps[$param] = $ops[] = $this->renderOp($param);
}
}
foreach ($block->phi as $phi) {
$result = $this->indent($this->renderOperand($phi->result) . " = Phi(");
$result .= implode(', ', array_map([$this, 'renderOperand'], $phi->vars));
$result .= ')';
$renderedOps[$phi] = $ops[] = ["op" => $phi, "label" => $result, "childBlocks" => []];
}
foreach ($block->children as $child) {
$renderedOps[$child] = $ops[] = $this->renderOp($child);
}
$renderedBlocks[$block] = $ops;
}
$varIds = $this->varIds;
$blockIds = $this->blocks;
$this->reset();
return ["blocks" => $renderedBlocks, "ops" => $renderedOps, "varIds" => $varIds, "blockIds" => $blockIds];
}