/**
* 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);
$codePrinter->output($classEntryVariable->getName() . ' = zend_fetch_class(SL("' . str_replace('\\', '\\\\', $classDefinition->getName()) . '"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);');
//}
//$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);
}
/**
* 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);
}