本文整理汇总了PHP中Generator::compileCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Generator::compileCode方法的具体用法?PHP Generator::compileCode怎么用?PHP Generator::compileCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Generator
的用法示例。
在下文中一共展示了Generator::compileCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: on_partial
public function on_partial($name, $indentation)
{
$ctx = $this->proust->getContext();
if ($this->compileClass) {
// use echo here because we already handled indentation in the partial itself
$str = "\$ctx->pushPartial('{$name}', '{$indentation}');\n" . "echo (\$this->" . self::functionName($name) . "());\n" . "\$ctx->popPartial('{$name}');\n" . "/* end partial include {$name} */\n";
} else {
$str = $this->outputFunction . "(\$ctx->partial('{$name}', '{$indentation}'));\n";
}
$m = $this->proust;
if (!$this->includeDynamicPartials && !$m->isPartialStatic($name)) {
$this->pushLine($str);
return;
}
if (!$this->includePartialCode) {
if ($this->compileClass) {
/* add partial to be compiled */
$code = $m->getPartial($name);
array_push($this->methodsToCompile, array($name, $code));
}
$this->pushLine($str);
return;
} else {
$ctx = $m->getContext();
if ($ctx->isPartialRecursion($name)) {
if ($this->compileClass) {
/* add partial to be compiled */
$code = $m->getPartial($name);
array_push($this->methodsToCompile, array($name, $code));
}
/* revert to normal partial call. */
$this->pushLine($str);
return;
}
$ctx->pushPartial($name, $indentation);
$code = $m->getPartial($name);
$c = new Generator($this->options);
$res = $c->compileCode($code, array("type" => "raw"));
$ctx->popPartial($name);
$str = "/* partial included code {$name} */\n" . "\$ctx->pushPartial('{$name}', '{$indentation}');\n" . $res . "\n" . "\$ctx->popPartial('{$name}');\n" . "/* end partial include {$name} */\n";
$this->pushLine($str);
}
}
示例2: compile
public function compile($code, $context = null, $options = array())
{
$name = $this->getCodeCacheKey($code, $context);
if (array_key_exists($name, $this->phpCache)) {
return $this->phpCache[$name];
}
$compilerOptions = $this->compilerOptions;
$compilerOptions["proust"] = $this;
$options = array_merge(array("type" => "variable", "name" => "f"), $options);
$generator = new Generator($compilerOptions);
$php = $generator->compileCode($code, $options);
$this->phpCache[$name] = $php;
return $php;
}