当前位置: 首页>>代码示例>>PHP>>正文


PHP Call::getResolvedParamsAsExpr方法代码示例

本文整理汇总了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);
 }
开发者ID:edin,项目名称:zephir,代码行数:41,代码来源:VarDumpOptimizer.php

示例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);
 }
开发者ID:chet0xhenry,项目名称:zephir,代码行数:64,代码来源:VarExportOptimizer.php

示例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;
 }
开发者ID:WalterShe,项目名称:zephir,代码行数:53,代码来源:MathOptimizer.php


注:本文中的Zephir\Call::getResolvedParamsAsExpr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。