當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Context::getCurrentBranch方法代碼示例

本文整理匯總了PHP中PHPSA\Context::getCurrentBranch方法的典型用法代碼示例。如果您正苦於以下問題:PHP Context::getCurrentBranch方法的具體用法?PHP Context::getCurrentBranch怎麽用?PHP Context::getCurrentBranch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PHPSA\Context的用法示例。


在下文中一共展示了Context::getCurrentBranch方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: compile

 /**
  * $a &= $b;
  *
  * @param \PhpParser\Node\Expr\AssignRef $expr
  * @param Context $context
  * @return CompiledExpression
  */
 protected function compile($expr, Context $context)
 {
     $compiler = $context->getExpressionCompiler();
     if ($expr->var instanceof VariableNode) {
         $name = $expr->var->name;
         $compiledExpression = $compiler->compile($expr->expr);
         $symbol = $context->getSymbol($name);
         if ($symbol) {
             $symbol->modify($compiledExpression->getType(), $compiledExpression->getValue());
         } else {
             $symbol = new \PHPSA\Variable($name, $compiledExpression->getValue(), $compiledExpression->getType(), $context->getCurrentBranch());
             $context->addVariable($symbol);
         }
         if ($expr->expr instanceof VariableNode) {
             $rightVarName = $expr->expr->name;
             $rightSymbol = $context->getSymbol($rightVarName);
             if ($rightSymbol) {
                 $rightSymbol->incUse();
                 $symbol->setReferencedTo($rightSymbol);
             } else {
                 $context->debug('Cannot fetch variable by name: ' . $rightVarName);
             }
         }
         $symbol->incSets();
         return $compiledExpression;
     }
     $context->debug('Unknown how to pass symbol by ref');
     return new CompiledExpression();
 }
開發者ID:ovr,項目名稱:phpsa,代碼行數:36,代碼來源:AssignRef.php

示例2: declareVariable

 /**
  * @param Node\Expr\Variable $expr
  * @param mixed $value
  * @param int $type
  * @return CompiledExpression
  */
 public function declareVariable(Node\Expr\Variable $expr, $value = null, $type = CompiledExpression::UNKNOWN)
 {
     $variable = $this->context->getSymbol($expr->name);
     if (!$variable) {
         $variable = new Variable($expr->name, $value, $type, $this->context->getCurrentBranch());
         $this->context->addVariable($variable);
     }
     return new CompiledExpression($variable->getType(), $variable->getValue(), $variable);
 }
開發者ID:ovr,項目名稱:phpsa,代碼行數:15,代碼來源:Expression.php

示例3: compileVariableDeclaration

 protected function compileVariableDeclaration(CompiledExpression $variableName, CompiledExpression $value, Context $context)
 {
     switch ($variableName->getType()) {
         case CompiledExpression::STRING:
             break;
         default:
             $context->debug('Unexpected type of Variable name after compile');
             return new CompiledExpression();
     }
     $symbol = $context->getSymbol($variableName->getValue());
     if ($symbol) {
         $symbol->modify($value->getType(), $value->getValue());
         $context->modifyReferencedVariables($symbol, $value->getType(), $value->getValue());
     } else {
         $symbol = new \PHPSA\Variable($variableName->getValue(), $value->getValue(), $value->getType(), $context->getCurrentBranch());
         $context->addVariable($symbol);
     }
     $symbol->incSets();
 }
開發者ID:ovr,項目名稱:phpsa,代碼行數:19,代碼來源:Assign.php


注:本文中的PHPSA\Context::getCurrentBranch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。