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


PHP Expression::setNoisy方法代码示例

本文整理汇总了PHP中Zephir\Expression::setNoisy方法的典型用法代码示例。如果您正苦于以下问题:PHP Expression::setNoisy方法的具体用法?PHP Expression::setNoisy怎么用?PHP Expression::setNoisy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zephir\Expression的用法示例。


在下文中一共展示了Expression::setNoisy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compile

 /**
  * Compiles an 'isset' operator
  *
  * @param array $expression
  * @param CompilationContext $compilationContext
  * @return CompiledExpression
  * @throws CompilerException
  */
 public function compile(array $expression, CompilationContext $compilationContext)
 {
     if ($expression['left']['type'] == 'list') {
         $left = $expression['left']['left'];
     } else {
         $left = $expression['left'];
     }
     switch ($left['type']) {
         case 'array-access':
             $compilationContext->headersManager->add('kernel/array');
             $exprVariable = new Expression($left['left']);
             $exprVariable->setReadOnly(true);
             $exprVariable->setNoisy(false);
             $exprCompiledVariable = $exprVariable->compile($compilationContext);
             if ($exprCompiledVariable->getType() != 'variable' && $exprCompiledVariable->getType() != 'array') {
                 throw new CompilerException("Expression type: " . $exprCompiledVariable->getType() . " cannot be used as array", $left['left']);
             }
             $variable = $compilationContext->symbolTable->getVariableForRead($exprCompiledVariable->getCode(), $compilationContext, $left['left']);
             switch ($variable->getType()) {
                 case 'array':
                 case 'variable':
                     break;
                 default:
                     throw new CompilerException("Variable type: " . $variable->getType() . " cannot be used as array", $left['left']);
                     break;
             }
             if ($variable->getType() == 'variable') {
                 if ($variable->hasDifferentDynamicType(array('undefined', 'array', 'null'))) {
                     $compilationContext->logger->warning('Possible attempt to use non array in isset operator', 'non-valid-isset', $expression);
                 }
             }
             $expr = new Expression($left['right']);
             $expr->setReadOnly(true);
             $expr->setNoisy(false);
             $resolvedExpr = $expr->compile($compilationContext);
             switch ($resolvedExpr->getType()) {
                 case 'int':
                 case 'long':
                 case 'string':
                     return $compilationContext->backend->arrayIsset($variable, $resolvedExpr, $left['right'], $compilationContext);
                 case 'variable':
                     $indexVariable = $compilationContext->symbolTable->getVariableForRead($resolvedExpr->getCode(), $compilationContext, $left['right']);
                     return $compilationContext->backend->arrayIsset($variable, $indexVariable, $left['right'], $compilationContext);
                     break;
                 default:
                     throw new CompilerException('[' . $left['right']['type'] . ']', $expression);
             }
             break;
         case 'property-access':
         case 'property-dynamic-access':
             $compilationContext->headersManager->add('kernel/object');
             $exprVariable = new Expression($left['left']);
             $exprVariable->setReadOnly(true);
             $exprCompiledVariable = $exprVariable->compile($compilationContext);
             if ($exprCompiledVariable->getType() != 'variable') {
                 throw new CompilerException("Expression type: " . $exprCompiledVariable->getType() . " cannot be used as object", $left['left']);
             }
             $variable = $compilationContext->symbolTable->getVariableForRead($exprCompiledVariable->getCode(), $compilationContext, $left['left']);
             if ($variable->getType() != 'variable') {
                 throw new CompilerException("Variable type: " . $variable->getType() . " cannot be used as object", $left['left']);
             }
             if ($variable->hasDifferentDynamicType(array('undefined', 'object', 'null'))) {
                 $compilationContext->logger->warning('Possible attempt to use non object in isset operator', 'non-valid-isset', $expression);
             }
             $variableCode = $compilationContext->backend->getVariableCode($variable);
             if ($left['type'] == 'property-access') {
                 return $compilationContext->backend->propertyIsset($variable, $left['right']['value'], $compilationContext);
             }
             $expr = new Expression($left['right']);
             $expr->setReadOnly(true);
             $expr->setNoisy(false);
             $resolvedExpr = $expr->compile($compilationContext);
             switch ($resolvedExpr->getType()) {
                 case 'variable':
                     $indexVariable = $compilationContext->symbolTable->getVariableForRead($resolvedExpr->getCode(), $compilationContext, $left['right']);
                     switch ($indexVariable->getType()) {
                         case 'variable':
                         case 'string':
                             $indexVariableCode = $compilationContext->backend->getVariableCode($indexVariable);
                             return new CompiledExpression('bool', 'zephir_isset_property_zval(' . $variableCode . ', ' . $indexVariableCode . ' TSRMLS_CC)', $left['right']);
                         default:
                             throw new CompilerException('[' . $indexVariable->getType() . ']', $expression);
                     }
                     break;
                 default:
                     throw new CompilerException('[' . $expression['left']['right']['type'] . ']', $expression);
             }
             break;
         case 'property-string-access':
             return new CompiledExpression('bool', '(0 == 0)', $left);
         case 'static-property-access':
             return new CompiledExpression('bool', '(0 == 0)', $left);
//.........这里部分代码省略.........
开发者ID:gvanbeck,项目名称:zephir,代码行数:101,代码来源:IssetOperator.php

示例2: compile

 /**
  * @param array $expression
  * @param CompilationContext $compilationContext
  * @return CompiledExpression
  * @throws CompilerException
  */
 public function compile(array $expression, CompilationContext $compilationContext)
 {
     $compilationContext->headersManager->add('kernel/array');
     $variable = $compilationContext->symbolTable->getVariableForWrite($expression['left']['value'], $compilationContext, $expression['left']);
     if ($variable->getType() != 'variable') {
         throw new CompilerException('Cannot use variable type: ' . $variable->gettype() . ' in "fetch" operator', $expression);
     }
     /**
      * return_value must not be observed
      */
     if ($variable->getName() != 'return_value') {
         /*
          * @todo use a read detector here
          */
         $readOnly = false;
         $line = max($compilationContext->symbolTable->getLastCallLine(), $compilationContext->symbolTable->getLastUnsetLine());
         if ($line === false || $line > 0 && $line < $expression['line']) {
             $numberMutations = $compilationContext->symbolTable->getExpectedMutations($variable->getName());
             if ($numberMutations == 1) {
                 if ($variable->getNumberMutations() == 1) {
                     $variable->setIsInitialized(true, $compilationContext, $expression);
                     $variable->setMemoryTracked(false);
                     $variable->setDynamicTypes('undefined');
                     $readOnly = true;
                 }
             }
         }
         if (!$readOnly || $expression['right']['type'] != 'array-access') {
             $variable->setIsInitialized(true, $compilationContext, $expression);
             $variable->observeVariant($compilationContext);
             $variable->setDynamicTypes('undefined');
             $variable->setPossibleValue(new CompiledExpression('undefined', '', $expression), $compilationContext);
         }
     } else {
         $variable = $compilationContext->symbolTable->getTempVariableForObserve('variable', $compilationContext, $expression);
     }
     if ($readOnly) {
         $flags = '1';
     } else {
         $flags = '0';
     }
     switch ($expression['right']['type']) {
         case 'array-access':
             $exprVariable = new Expression($expression['right']['left']);
             $exprVariable->setReadOnly(true);
             $exprVariable->setNoisy(false);
             $exprCompiledVariable = $exprVariable->compile($compilationContext);
             if ($exprCompiledVariable->getType() != 'variable') {
                 throw new CompilerException("Expression type: " . $exprCompiledVariable->getType() . " cannot be used as array", $expression['right']['left']);
             }
             $evalVariable = $compilationContext->symbolTable->getVariableForRead($exprCompiledVariable->getCode(), $compilationContext, $expression['right']['left']);
             if ($evalVariable->getType() != 'variable' && $evalVariable->getType() != 'array') {
                 throw new CompilerException("Variable type: " . $variable->getType() . " cannot be used as array", $expression['right']['left']);
             }
             if ($evalVariable->getType() == 'variable') {
                 if ($evalVariable->hasDifferentDynamicType(array('undefined', 'array', 'null'))) {
                     $compilationContext->logger->warning('Possible attempt to use non array in fetch operator', 'non-valid-fetch', $expression['right']);
                 }
             }
             $expr = new Expression($expression['right']['right']);
             $expr->setReadOnly(true);
             $expr->setNoisy(false);
             $resolvedExpr = $expr->compile($compilationContext);
             return $compilationContext->backend->arrayIssetFetch($variable, $evalVariable, $resolvedExpr, $flags, $expression, $compilationContext);
             break;
         case 'property-access':
             $exprVariable = new Expression($expression['right']['left']);
             $exprVariable->setReadOnly(true);
             $exprVariable->setNoisy(false);
             $exprCompiledVariable = $exprVariable->compile($compilationContext);
             if ($exprCompiledVariable->getType() != 'variable') {
                 throw new CompilerException("Expression type: " . $exprCompiledVariable->getType() . " cannot be used as object", $expression['right']['left']);
             }
             $evalVariable = $compilationContext->symbolTable->getVariableForRead($exprCompiledVariable->getCode(), $compilationContext, $expression['right']['left']);
             if ($evalVariable->getType() != 'variable') {
                 throw new CompilerException("Variable type: " . $variable->getType() . " cannot be used as object", $expression['right']['left']);
             }
             if ($evalVariable->hasDifferentDynamicType(array('undefined', 'object', 'null'))) {
                 $compilationContext->logger->warning('Possible attempt to use non object in fetch operator', 'non-valid-fetch', $expression['right']);
             }
             $property = $expression['right']['right']['value'];
             $compilationContext->headersManager->add('kernel/object');
             $symbol = $compilationContext->backend->getVariableCodePointer($variable);
             $evalSymbol = $compilationContext->backend->getVariableCode($evalVariable);
             return new CompiledExpression('bool', 'zephir_fetch_property(' . $symbol . ', ' . $evalSymbol . ', SL("' . $property . '"), PH_SILENT_CC)', $expression);
         case 'property-dynamic-access':
             $exprVariable = new Expression($expression['right']['left']);
             $exprVariable->setReadOnly(true);
             $exprVariable->setNoisy(false);
             $exprCompiledVariable = $exprVariable->compile($compilationContext);
             if ($exprCompiledVariable->getType() != 'variable') {
                 throw new CompilerException("Expression type: " . $exprCompiledVariable->getType() . " cannot be used as object", $expression['right']['left']);
             }
             $evalVariable = $compilationContext->symbolTable->getVariableForRead($exprCompiledVariable->getCode(), $compilationContext, $expression['right']['left']);
//.........这里部分代码省略.........
开发者ID:phalcon,项目名称:zephir,代码行数:101,代码来源:FetchOperator.php


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