getClassEntry() public méthode

Returns the name of the zend_class_entry according to the class name
public getClassEntry ( zephir\CompilationContext $compilationContext = null ) : string
$compilationContext zephir\CompilationContext
Résultat string
Exemple #1
0
 /**
  * Calls static methods on the some class context
  *
  * @param string $methodName
  * @param array $expression
  * @param Variable $symbolVariable
  * @param boolean $mustInit
  * @param boolean $isExpecting
  * @param ClassDefinition $classDefinition
  * @param CompilationContext $compilationContext
  * @param ClassMethod $method
  */
 protected function callFromClass($methodName, array $expression, $symbolVariable, $mustInit, $isExpecting, ClassDefinition $classDefinition, CompilationContext $compilationContext, $method)
 {
     $codePrinter = $compilationContext->codePrinter;
     if ($classDefinition->isInternal()) {
         $variableName = str_replace('\\', '_', $classDefinition->getSCName('local'));
         if (!$compilationContext->symbolTable->hasVariable($variableName)) {
             $classEntryVariable = $compilationContext->symbolTable->addVariable('zend_class_entry', $variableName, $compilationContext);
             $codePrinter->output($classEntryVariable->getName() . ' = zend_fetch_class(SL("\\\\' . str_replace('\\', '\\\\', $classDefinition->getName()) . '"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);');
         }
         $classEntryVariable = $compilationContext->symbolTable->getVariableForWrite($variableName, 'zend_class_entry', $compilationContext);
         $classEntry = $classEntryVariable->getName();
     } else {
         $classEntry = $classDefinition->getClassEntry();
     }
     /**
      * Call static methods must grown the stack
      */
     $compilationContext->symbolTable->mustGrownStack(true);
     if ($mustInit) {
         $symbolVariable->setMustInitNull(true);
         $symbolVariable->trackVariant($compilationContext);
     }
     /**
      * Check if the  method call can have an inline cache
      */
     $methodCache = $compilationContext->cacheManager->getStaticMethodCache();
     $cachePointer = $methodCache->get($compilationContext, isset($method) ? $method : null);
     if (isset($expression['parameters']) && count($expression['parameters'])) {
         $params = $this->getResolvedParams($expression['parameters'], $compilationContext, $expression);
     } else {
         $params = array();
     }
     if (!count($params)) {
         if ($isExpecting) {
             if ($symbolVariable->getName() == 'return_value') {
                 $codePrinter->output('ZEPHIR_RETURN_CALL_CE_STATIC(' . $classEntry . ', "' . $methodName . '", ' . $cachePointer . ');');
             } else {
                 $codePrinter->output('ZEPHIR_CALL_CE_STATIC(&' . $symbolVariable->getName() . ', ' . $classEntry . ', "' . $methodName . '", ' . $cachePointer . ');');
             }
         } else {
             $codePrinter->output('ZEPHIR_CALL_CE_STATIC(NULL, ' . $classEntry . ', "' . $methodName . '", ' . $cachePointer . ');');
         }
     } else {
         if ($isExpecting) {
             if ($symbolVariable->getName() == 'return_value') {
                 $codePrinter->output('ZEPHIR_RETURN_CALL_CE_STATIC(' . $classEntry . ', "' . $methodName . '", ' . $cachePointer . ', ' . join(', ', $params) . ');');
             } else {
                 $codePrinter->output('ZEPHIR_CALL_CE_STATIC(&' . $symbolVariable->getName() . ', ' . $classEntry . ', "' . $methodName . '", ' . $cachePointer . ', ' . join(', ', $params) . ');');
             }
         } else {
             $codePrinter->output('ZEPHIR_CALL_CE_STATIC(NULL, ' . $classEntry . ', "' . $methodName . '", ' . $cachePointer . ', ' . join(', ', $params) . ');');
         }
     }
     /**
      * Temporary variables must be copied if they have more than one reference
      */
     foreach ($this->getMustCheckForCopyVariables() as $checkVariable) {
         $codePrinter->output('zephir_check_temp_parameter(' . $checkVariable . ');');
     }
     $this->addCallStatusOrJump($compilationContext);
 }
Exemple #2
0
 /**
  * Calls static methods on the some class context
  *
  * @param string $methodName
  * @param array $expression
  * @param Variable $symbolVariable
  * @param boolean $mustInit
  * @param boolean $isExpecting
  * @param ClassDefinition $classDefinition
  * @param CompilationContext $compilationContext
  * @param ClassMethod $method
  */
 protected function callFromClass($methodName, array $expression, $symbolVariable, $mustInit, $isExpecting, ClassDefinition $classDefinition, CompilationContext $compilationContext, ClassMethod $method)
 {
     $codePrinter = $compilationContext->codePrinter;
     if ($classDefinition->isBundled()) {
         //if (!$compilationContext->symbolTable->hasVariable($variableName)) {
         $classEntryVariable = $compilationContext->symbolTable->addTemp('zend_class_entry', $compilationContext);
         $compilationContext->backend->fetchClass($classEntryVariable, 'SL("' . str_replace('\\', '\\\\', $classDefinition->getName()) . '")', false, $compilationContext);
         //}
         //$classEntryVariable = $compilationContext->symbolTable->getVariableForWrite($variableName, $compilationContext, $expression);
         $classEntry = $classEntryVariable->getName();
     } else {
         $classEntry = $classDefinition->getClassEntry($compilationContext);
     }
     /**
      * Call static methods must grown the stack
      */
     $compilationContext->symbolTable->mustGrownStack(true);
     if ($mustInit) {
         $symbolVariable->setMustInitNull(true);
         $symbolVariable->trackVariant($compilationContext);
     }
     if ($method) {
         $method = $method->getOptimizedMethod();
     }
     /**
      * Check if the  method call can have an inline cache
      */
     $methodCache = $compilationContext->cacheManager->getStaticMethodCache();
     $cachePointer = $methodCache->get($compilationContext, isset($method) ? $method : null);
     if (isset($expression['parameters']) && count($expression['parameters'])) {
         $params = $this->getResolvedParams($expression['parameters'], $compilationContext, $expression);
     } else {
         $params = array();
     }
     if ($symbolVariable) {
         $symbol = $compilationContext->backend->getVariableCodePointer($symbolVariable);
     }
     $paramCount = count($params);
     $paramsStr = $paramCount ? ', ' . join(', ', $params) : '';
     if ($method->isInternal()) {
         $ce = $classDefinition->getClassEntry($compilationContext);
         if ($isExpecting) {
             if ($symbolVariable->getName() == 'return_value') {
                 $macro = $compilationContext->backend->getFcallManager()->getMacro(true, true, $paramCount);
                 $codePrinter->output($macro . '(' . $ce . ', ' . $method->getInternalName() . $paramsStr . ');');
             } else {
                 $macro = $compilationContext->backend->getFcallManager()->getMacro(true, 2, $paramCount);
                 $codePrinter->output($macro . '(' . $symbol . ', ' . $ce . ', ' . $method->getInternalName() . $paramsStr . ');');
             }
         } else {
             $macro = $compilationContext->backend->getFcallManager()->getMacro(true, false, $paramCount);
             $codePrinter->output($macro . '(' . $ce . ', ' . $method->getInternalName() . $paramsStr . ');');
         }
     } else {
         if ($isExpecting) {
             if ($symbolVariable->getName() == 'return_value') {
                 $codePrinter->output('ZEPHIR_RETURN_CALL_CE_STATIC(' . $classEntry . ', "' . $methodName . '", ' . $cachePointer . $paramsStr . ');');
             } else {
                 $codePrinter->output('ZEPHIR_CALL_CE_STATIC(' . $symbol . ', ' . $classEntry . ', "' . $methodName . '", ' . $cachePointer . $paramsStr . ');');
             }
         } else {
             $codePrinter->output('ZEPHIR_CALL_CE_STATIC(NULL, ' . $classEntry . ', "' . $methodName . '", ' . $cachePointer . $paramsStr . ');');
         }
     }
     /**
      * Temporary variables must be copied if they have more than one reference
      */
     foreach ($this->getMustCheckForCopyVariables() as $checkVariable) {
         $codePrinter->output('zephir_check_temp_parameter(' . $checkVariable . ');');
     }
     $this->addCallStatusOrJump($compilationContext);
 }