예제 #1
0
파일: Parser.php 프로젝트: bwoebi/recki-ct
 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);
         }
     }
 }
예제 #2
0
파일: Goto_.php 프로젝트: bwoebi/recki-ct
 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;
 }
예제 #3
0
파일: Label.php 프로젝트: bwoebi/recki-ct
 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);
         }
     }
 }
예제 #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;
 }