shouldBeLocal() public method

Asks the local context information whether a variable can be stored in the stack instead of the heap
public shouldBeLocal ( string $variable ) : boolean
$variable string
return boolean
コード例 #1
0
ファイル: SymbolTable.php プロジェクト: phalcon/zephir
 /**
  * Adds a variable to the symbol table
  *
  * @param int $type
  * @param string $name
  * @param CompilationContext $compilationContext
  * @param mixed $defaultValue
  * @return Variable
  */
 public function addVariable($type, $name, CompilationContext $compilationContext, $defaultValue = null)
 {
     $currentBranch = $compilationContext->branchManager->getCurrentBranch();
     $branchId = $currentBranch->getUniqueId();
     if ($this->isSuperGlobal($name) || $type == 'zephir_fcall_cache_entry') {
         $branchId = 1;
     }
     $varName = $name;
     if ($branchId > 1 && $currentBranch->getType() != Branch::TYPE_ROOT) {
         $varName = $name . Variable::BRANCH_MAGIC . $branchId;
     }
     $variable = new Variable($type, $varName, $compilationContext->currentBranch, $defaultValue);
     if ($type == 'variable') {
         if ($this->localContext) {
             /**
              * Checks whether a variable can be optimized to be static or not
              */
             if ($this->localContext->shouldBeLocal($name)) {
                 $variable->setLocalOnly(true);
             }
         }
     }
     if (!isset($this->branchVariables[$branchId])) {
         $this->branchVariables[$branchId] = array();
     }
     $this->branchVariables[$branchId][$name] = $variable;
     return $variable;
 }
コード例 #2
0
ファイル: SymbolTable.php プロジェクト: Jvbzephir/zephir
 /**
  * Adds a variable to the symbol table
  *
  * @param int $type
  * @param string $name
  * @param CompilationContext $compilationContext
  * @param mixed $defaultValue
  * @return Variable
  */
 public function addVariable($type, $name, CompilationContext $compilationContext, $defaultValue = null)
 {
     $variable = new Variable($type, $name, $compilationContext->currentBranch, $defaultValue);
     if ($type == 'variable') {
         if ($this->localContext) {
             /**
              * Checks whether a variable can be optimized to be static or not
              */
             if ($this->localContext->shouldBeLocal($name)) {
                 $variable->setLocalOnly(true);
             }
         }
     }
     $this->variables[$name] = $variable;
     return $variable;
 }