当前位置: 首页>>代码示例>>PHP>>正文


PHP Generator::compileCode方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:sebcode,项目名称:proust,代码行数:43,代码来源:Generator.php

示例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;
 }
开发者ID:sebcode,项目名称:proust,代码行数:14,代码来源:Proust.php


注:本文中的Generator::compileCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。