本文整理匯總了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;
}