本文整理汇总了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();
}
示例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);
}
示例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();
}