コード例 #1
0
ファイル: Generator.php プロジェクト: qs9816/recki-ct
 public function generateFunction($name, Vertex\Function_ $func)
 {
     $state = (object) ['scope' => new \SplObjectStorage(), 'labels' => new \SplObjectStorage(), 'varidx' => 0, 'labelidx' => 0, 'seen' => new \SplObjectStorage(), 'graph' => $func->getGraph(), 'constants' => []];
     $body = $this->generate($func, $state);
     $replace = "";
     if ($state->constants) {
         $replace = implode("\n", $state->constants) . "\n";
     }
     $body = str_replace("--constants--\n", $replace, $body);
     return 'function ' . $name . ' ' . $func->getReturnType() . "\n" . $body . "end";
 }
コード例 #2
0
ファイル: Parser.php プロジェクト: qs9816/recki-ct
 public function parseFunction(AstFunction $ast)
 {
     $args = array();
     foreach ($ast->params as $param) {
         $args[$param->name] = new JitVariable($param->jitType);
     }
     $func = new JitFunction($args, $ast->jitType, new DirectedAdjacencyList());
     $state = new State($this, $func->getGraph());
     $state->scope = $args;
     $state->last = $func;
     $this->parseStmtList($ast->stmts, $state);
     $this->addEndNode($state);
     return $func;
 }
コード例 #3
0
ファイル: Generator.php プロジェクト: bwoebi/recki-ct
 public function generateFunction($name, Vertex\Function_ $func)
 {
     $state = (object) ['scope' => new \SplObjectStorage(), 'labels' => new \SplObjectStorage(), 'varidx' => 0, 'labelidx' => 0, 'seen' => new \SplObjectStorage(), 'graph' => $func->getGraph()];
     return 'function ' . $name . ' ' . $func->getReturnType() . "\n" . $this->generate($func, $state) . "end";
 }
コード例 #4
0
ファイル: GraphState.php プロジェクト: bwoebi/recki-ct
 public function __construct(JitFunction $func)
 {
     $this->function = $func;
     $this->graph = $func->getGraph();
 }
コード例 #5
0
ファイル: FunctionTest.php プロジェクト: bwoebi/recki-ct
 /**
  * @covers ::getVariables
  * @covers ::replaceVariable
  */
 public function testGetVariablesNone()
 {
     $vertex = new Function_([$a = new Variable()], new Type(Type::TYPE_LONG), new DirectedAdjacencyList());
     $vertex->replaceVariable(new Variable(), new Variable());
     $this->assertSame([$a], $vertex->getVariables());
 }