getResolvedParams() 공개 메소드

Resolve parameters getting aware that the target function/method could retain or change the parameters
public getResolvedParams ( array $parameters, zephir\CompilationContext $compilationContext, array $expression, array $calleeDefinition = null ) : array
$parameters array
$compilationContext zephir\CompilationContext
$expression array
$calleeDefinition array
리턴 array
예제 #1
0
 /**
  * @param array $expression
  * @param Call $call
  * @param CompilationContext $context
  * @return bool|CompiledExpression
  * @throws CompilerException
  */
 public function optimize(array $expression, Call $call, CompilationContext $context)
 {
     if (!isset($expression['parameters'])) {
         return false;
     }
     if (count($expression['parameters']) != 1) {
         throw new CompilerException("phalcon_get_uri only accepts three parameter", $expression);
     }
     /**
      * Process the expected symbol to be returned
      */
     $call->processExpectedReturn($context);
     $symbolVariable = $call->getSymbolVariable();
     if ($symbolVariable->getType() != 'variable') {
         throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
     }
     if ($call->mustInitSymbolVariable()) {
         $symbolVariable->initVariant($context);
     }
     $context->headersManager->add('phalcon/mvc/url/utils', HeadersManager::POSITION_LAST);
     $resolvedParams = $call->getResolvedParams($expression['parameters'], $context, $expression);
     $symbol = $context->backend->getVariableCode($symbolVariable);
     $context->codePrinter->output('phalcon_get_uri(' . $symbol . ', ' . $resolvedParams[0] . ');');
     return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
 }
 /**
  * @param array $expression
  * @param Call $call
  * @param CompilationContext $context
  * @return bool|CompiledExpression
  * @throws CompilerException
  */
 public function optimize(array $expression, Call $call, CompilationContext $context)
 {
     if (!isset($expression['parameters'])) {
         return false;
     }
     if (count($expression['parameters']) != 3) {
         throw new CompilerException("phannot_parse_annotations only accepts three parameter", $expression);
     }
     /**
      * Process the expected symbol to be returned
      */
     $call->processExpectedReturn($context);
     $symbolVariable = $call->getSymbolVariable();
     if ($symbolVariable->getType() != 'variable') {
         throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
     }
     if ($call->mustInitSymbolVariable()) {
         $symbolVariable->initVariant($context);
     }
     $context->headersManager->add('phalcon/annotations/scanner', HeadersManager::POSITION_LAST);
     $context->headersManager->add('phalcon/annotations/annot', HeadersManager::POSITION_LAST);
     $symbolVariable->setDynamicTypes('array');
     $resolvedParams = $call->getResolvedParams($expression['parameters'], $context, $expression);
     $call->addCallStatusFlag($context);
     $symbol = $context->backend->getVariableCode($symbolVariable);
     $context->codePrinter->output('ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(' . $symbol . ', ' . $resolvedParams[0] . ', ' . $resolvedParams[1] . ', ' . $resolvedParams[2] . ' TSRMLS_CC);');
     $call->checkTempParameters($context);
     $call->addCallStatusOrJump($context);
     return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
 }
예제 #3
0
 /**
  * @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) {
         throw new CompilerException("phalcon_jsmin only accepts one parameter", $expression);
     }
     /**
      * Process the expected symbol to be returned
      */
     $call->processExpectedReturn($context);
     $symbolVariable = $call->getSymbolVariable();
     if ($symbolVariable->getType() != 'variable') {
         throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
     }
     if ($call->mustInitSymbolVariable()) {
         $symbolVariable->initVariant($context);
     }
     $context->headersManager->add('phalcon/assets/filters/jsminifier');
     $symbolVariable->setDynamicTypes('string');
     $resolvedParams = $call->getResolvedParams($expression['parameters'], $context, $expression);
     $context->codePrinter->output('phalcon_jsmin(' . $symbolVariable->getName() . ', ' . $resolvedParams[0] . ' TSRMLS_CC);');
     return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
 }
예제 #4
0
 /**
  * @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;
     }
     /**
      * Process the expected symbol to be returned
      */
     $call->processExpectedReturn($context);
     $symbolVariable = $call->getSymbolVariable();
     if ($symbolVariable) {
         if ($symbolVariable->getType() != 'variable') {
             throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
         }
         if ($call->mustInitSymbolVariable()) {
             $symbolVariable->initVariant($context);
         }
     }
     $context->headersManager->add('kernel/variables');
     $resolvedParams = $call->getResolvedParams($expression['parameters'], $context, $expression);
     if ($symbolVariable) {
         $context->codePrinter->output('zephir_var_export_ex(' . $symbolVariable->getName() . ', &(' . $resolvedParams[0] . ') TSRMLS_CC);');
         return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
     }
     $context->codePrinter->output('zephir_var_export(&' . $resolvedParams[0] . ' TSRMLS_CC);');
     return new CompiledExpression('null', 'null', $expression);
 }
예제 #5
0
 /**
  * @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;
 }