public function addEndNode(State $state) { $end = $state->addVertex(new JitEnd()); foreach ($state->graph->vertices() as $vertex) { if ($vertex instanceof JitReturn) { $state->graph->ensureArc($vertex, $end); } } }
public function parse(Node $stmt, State $state) { $goto = $state->addVertex(new Jump()); $state->last = null; if (isset($state->labels[$stmt->name])) { $state->graph->ensureArc($goto, $state->labels[$stmt->name]); return; } if (!isset($state->gotolist[$stmt->name])) { $state->gotolist[$stmt->name] = array(); } $state->gotolist[$stmt->name][] = $goto; }
public function parse(Node $stmt, State $state) { if (isset($state->labels[$stmt->name])) { throw new \RuntimeException('Found label with duplicate name'); } $label = new NoOp(); $state->addVertex($label); $state->labels[$stmt->name] = $label; if (isset($state->gotolist[$stmt->name])) { foreach ($state->gotolist[$stmt->name] as $node) { $state->graph->ensureArc($node, $label); } } }
public function parse(Node $stmt, State $state) { $result = new Variable(new Type(Type::TYPE_BOOLEAN)); $false = new Constant(false); $state->addVertex(new Vertex\Assign($false, $result)); $end = new Vertex\NoOp(); $left = $state->parser->parseNode($stmt->left, $state); $jmp = $state->addVertex(new Vertex\JumpZ($end, $left)); $state->graph->ensureArc($jmp, $end); $right = $state->parser->parseNode($stmt->right, $state); $state->addVertex(new Vertex\Assign($right, $result)); $state->addVertex(new Vertex\Jump()); $state->addVertex($end); return $result; }