本文整理汇总了PHP中Zephir\Call::getResolvedParamsAsExpr方法的典型用法代码示例。如果您正苦于以下问题:PHP Call::getResolvedParamsAsExpr方法的具体用法?PHP Call::getResolvedParamsAsExpr怎么用?PHP Call::getResolvedParamsAsExpr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zephir\Call
的用法示例。
在下文中一共展示了Call::getResolvedParamsAsExpr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: optimize
/**
* @param array $expression
* @param Call $call
* @param CompilationContext $context
* @return bool|CompiledExpression|mixed
*/
public function optimize(array $expression, Call $call, CompilationContext $context)
{
if (!isset($expression['parameters'])) {
return false;
}
$context->headersManager->add('kernel/variables');
$resolvedParams = $call->getResolvedParamsAsExpr($expression['parameters'], $context, $expression);
foreach ($resolvedParams as $resolvedParam) {
$variable = $context->symbolTable->getVariable($resolvedParam->getCode());
if (!$variable || !$variable->isVariable()) {
/**
* Complex expressions require a temporary variable
*/
switch ($resolvedParam->getType()) {
case 'array':
$type = 'array';
break;
default:
$type = 'variable';
break;
}
$variable = $context->symbolTable->addTemp($type, $context);
$variable->initVariant($context);
$statement = new LetStatement(array('type' => 'let', 'assignments' => array(array('assign-type' => $type, 'variable' => $variable->getName(), 'operator' => 'assign', 'expr' => array('type' => $resolvedParam->getType(), 'value' => $resolvedParam->getCode(), 'file' => $expression['file'], 'line' => $expression['line'], 'char' => $expression['char']), 'file' => $expression['file'], 'line' => $expression['line'], 'char' => $expression['char']))));
$statement->compile($context);
} else {
/**
* This mark the variable as used
*/
$variable = $context->symbolTable->getVariableForRead($resolvedParam->getCode(), $context, $expression);
}
$context->codePrinter->output('zephir_var_dump(&' . $variable->getName() . ' TSRMLS_CC);');
}
return new CompiledExpression('null', 'null', $expression);
}
示例2: optimize
/**
* @param array $expression
* @param Call $call
* @param CompilationContext $context
* @return mixed|CompiledExpression
* @throws CompilerException
*/
public function optimize(array $expression, Call $call, CompilationContext $context)
{
if (!isset($expression['parameters'])) {
return false;
}
/**
* Process the expected symbol to be returned
*/
$call->processExpectedReturn($context);
$symbolVariable = $call->getSymbolVariable();
if ($symbolVariable) {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}
}
$context->headersManager->add('kernel/variables');
$resolvedParams = $call->getResolvedParamsAsExpr($expression['parameters'], $context, $expression);
$resolvedParam = $resolvedParams[0];
if (!$symbolVariable || !$symbolVariable->isVariable()) {
/**
* Complex expressions require a temporary variable
*/
switch ($resolvedParam->getType()) {
case 'array':
$type = 'array';
break;
default:
$type = 'variable';
break;
}
$variable = $context->symbolTable->addTemp($type, $context);
$variable->initVariant($context);
$statement = new LetStatement(array('type' => 'let', 'assignments' => array(array('assign-type' => $type, 'variable' => $variable->getName(), 'operator' => 'assign', 'expr' => array('type' => $resolvedParam->getType(), 'value' => $resolvedParam->getCode(), 'file' => $expression['file'], 'line' => $expression['line'], 'char' => $expression['char']), 'file' => $expression['file'], 'line' => $expression['line'], 'char' => $expression['char']))));
$statement->compile($context);
} else {
/**
* This mark the variable as used
*/
$variable = $context->symbolTable->getVariableForRead($resolvedParam->getCode(), $context, $expression);
}
$variableSymbol = $context->backend->getVariableCodePointer($variable);
/**
* let a = var_export(val);
*/
if ($symbolVariable) {
if ($symbolVariable->getName() == 'return_value') {
$symbolVariable = $context->symbolTable->getTempVariableForWrite('variable', $context);
} else {
$symbolVariable->initVariant($context);
}
$symbol = $context->backend->getVariableCode($symbolVariable);
$context->codePrinter->output('zephir_var_export_ex(' . $symbol . ', ' . $variableSymbol . ' TSRMLS_CC);');
return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
}
$context->codePrinter->output('zephir_var_export(' . $variableSymbol . ' TSRMLS_CC);');
return new CompiledExpression('null', 'null', $expression);
}
示例3: optimize
/**
* @param array $expression
* @param Call $call
* @param CompilationContext $context
* @return bool|CompiledExpression|mixed
* @throws CompilerException
*/
public function optimize(array $expression, Call $call, CompilationContext $context)
{
if (!isset($expression['parameters'])) {
return false;
}
if (count($expression['parameters']) > 1) {
return false;
}
/**
* Resolve parameters as vars
*/
$call->getResolvedParams($expression['parameters'], $context, $expression);
/**
* Get CompiledExpression(s) for resolved var(s)
*/
$resolvedParams = $call->getResolvedParamsAsExpr($expression['parameters'], $context, $expression);
$compiledExpression = $resolvedParams[0];
switch ($compiledExpression->getType()) {
case 'int':
case 'float':
case 'long':
case 'ulong':
case 'double':
$context->headersManager->add('math');
return $this->passNativeFCall($compiledExpression, $expression);
break;
case 'variable':
$variable = $context->symbolTable->getVariable($compiledExpression->getCode());
switch ($variable->getType()) {
case 'int':
case 'float':
case 'long':
case 'ulong':
case 'double':
$context->headersManager->add('math');
return $this->passNativeFCall($compiledExpression, $expression);
break;
case 'variable':
$context->headersManager->add('kernel/math');
return new CompiledExpression('double', 'zephir_' . $this->getFunctionName() . '(' . $context->backend->getVariableCode($variable) . ' TSRMLS_CC)', $expression);
break;
}
break;
}
return false;
}