當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。