getCurrentBranch() public method

public getCurrentBranch ( ) : integer
return integer
Ejemplo n.º 1
0
 /**
  * $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();
 }
Ejemplo n.º 2
0
 /**
  * @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);
 }
Ejemplo n.º 3
0
Archivo: Assign.php Proyecto: ovr/phpsa
 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();
 }