Ejemplo n.º 1
0
 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);
         }
     }
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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);
         }
     }
 }
Ejemplo n.º 4
0
 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;
 }