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


PHP Variable::isTemporal方法代码示例

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


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

示例1: assign


//.........这里部分代码省略.........
             $tempVariable->setIdle(true);
             break;
         case 'string':
             $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext);
             switch ($statement['operator']) {
                 case 'concat-assign':
                     $codePrinter->output('zephir_concat_self_str(&' . $tempVariable->getName() . ', "' . $resolvedExpr->getCode() . '", sizeof("' . $resolvedExpr->getCode() . '")-1 TSRMLS_CC);');
                     break;
                 case 'assign':
                     $tempVariable->initNonReferenced($compilationContext);
                     $codePrinter->output('ZVAL_STRING(' . $tempVariable->getName() . ', "' . $resolvedExpr->getCode() . '", 1);');
                     break;
             }
             if ($variable == 'this') {
                 $codePrinter->output('zephir_update_property_this(this_ptr, SL("' . $propertyName . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             } else {
                 $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', SL("' . $propertyName . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             }
             $tempVariable->setIdle(true);
             break;
         case 'array':
             if ($variable == 'this') {
                 $codePrinter->output('zephir_update_property_this(this_ptr, SL("' . $propertyName . '"), ' . $resolvedExpr->getCode() . ' TSRMLS_CC);');
             } else {
                 $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', SL("' . $propertyName . '"), ' . $resolvedExpr->getCode() . ' TSRMLS_CC);');
             }
             break;
         case 'bool':
             if ($variable == 'this') {
                 $codePrinter->output('zephir_update_property_this(this_ptr, SL("' . $propertyName . '"), (' . $resolvedExpr->getBooleanCode() . ') ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);');
             } else {
                 $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', SL("' . $propertyName . '"), (' . $resolvedExpr->getBooleanCode() . ') ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);');
             }
             break;
         case 'empty-array':
             /* unreachable code */
             $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext);
             $codePrinter->output('array_init(' . $tempVariable->getName() . ');');
             if ($variable == 'this') {
                 $codePrinter->output('zephir_update_property_this(this_ptr, SL("' . $propertyName . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             } else {
                 $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', SL("' . $propertyName . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             }
             $tempVariable->setIdle(true);
             break;
         case 'variable':
             $variableVariable = $compilationContext->symbolTable->getVariableForRead($resolvedExpr->getCode(), $compilationContext, $statement);
             switch ($variableVariable->getType()) {
                 case 'int':
                 case 'uint':
                 case 'long':
                 case 'ulong':
                 case 'char':
                 case 'uchar':
                     $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext, true);
                     $codePrinter->output('ZVAL_LONG(' . $tempVariable->getName() . ', ' . $variableVariable->getName() . ');');
                     if ($variable == 'this') {
                         $codePrinter->output('zephir_update_property_this(this_ptr, SL("' . $propertyName . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
                     } else {
                         $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', SL("' . $propertyName . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
                     }
                     $tempVariable->setIdle(true);
                     break;
                 case 'double':
                     $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext, true);
                     $codePrinter->output('ZVAL_DOUBLE(' . $tempVariable->getName() . ', ' . $variableVariable->getName() . ');');
                     if ($variable == 'this') {
                         $codePrinter->output('zephir_update_property_this(this_ptr, SL("' . $propertyName . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
                     } else {
                         $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', SL("' . $propertyName . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
                     }
                     $tempVariable->setIdle(true);
                     break;
                 case 'bool':
                     if ($variable == 'this') {
                         $codePrinter->output('zephir_update_property_this(this_ptr, SL("' . $propertyName . '"), ' . $variableVariable->getName() . ' ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);');
                     } else {
                         $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', SL("' . $propertyName . '"), ' . $variableVariable->getName() . ' ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);');
                     }
                     break;
                 case 'array':
                 case 'string':
                 case 'variable':
                     if ($variable == 'this') {
                         $codePrinter->output('zephir_update_property_this(this_ptr, SL("' . $propertyName . '"), ' . $variableVariable->getName() . ' TSRMLS_CC);');
                     } else {
                         $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', SL("' . $propertyName . '"), ' . $variableVariable->getName() . ' TSRMLS_CC);');
                     }
                     if ($symbolVariable->isTemporal()) {
                         $symbolVariable->setIdle(true);
                     }
                     break;
                 default:
                     throw new CompilerException("Unknown type " . $variableVariable->getType(), $statement);
             }
             break;
         default:
             throw new CompilerException("Unknown type " . $resolvedExpr->getType(), $statement);
     }
 }
开发者ID:NumbDai,项目名称:zephir,代码行数:101,代码来源:ObjectProperty.php

示例2: assign


//.........这里部分代码省略.........
     if ($symbolVariable->hasAnyDynamicType('unknown')) {
         throw new CompilerException("Cannot use non-initialized variable as an object", $statement);
     }
     /**
      * Trying to use a non-object dynamic variable as object
      */
     if ($symbolVariable->hasDifferentDynamicType(array('undefined', 'object', 'null'))) {
         $compilationContext->logger->warning('Possible attempt to update property on non-object dynamic property', 'non-valid-objectupdate', $statement);
     }
     $codePrinter = $compilationContext->codePrinter;
     $compilationContext->headersManager->add('kernel/object');
     $propertyVariableName = $compilationContext->symbolTable->getVariable($propertyName);
     switch ($resolvedExpr->getType()) {
         case 'null':
             if ($variable == 'this') {
                 $codePrinter->output('zephir_update_property_this(this_ptr, Z_STRVAL_P(' . $propertyVariableName->getName() . '), Z_STRLEN_P(' . $propertyVariableName->getName() . '), ZEPHIR_GLOBAL(global_null) TSRMLS_CC);');
             } else {
                 $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', Z_STRVAL_P(' . $propertyVariableName->getName() . '), Z_STRLEN_P(' . $propertyVariableName->getName() . '), ZEPHIR_GLOBAL(global_null) TSRMLS_CC);');
             }
             break;
         case 'int':
         case 'long':
             $tempVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext);
             $codePrinter->output('ZVAL_LONG(' . $tempVariable->getName() . ', ' . $resolvedExpr->getBooleanCode() . ');');
             if ($variable == 'this') {
                 $codePrinter->output('zephir_update_property_this(this_ptr, Z_STRVAL_P(' . $propertyVariableName->getName() . '), Z_STRLEN_P(' . $propertyVariableName->getName() . '), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             } else {
                 $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', Z_STRVAL_P(' . $propertyVariableName->getName() . '), Z_STRLEN_P(' . $propertyVariableName->getName() . '), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             }
             break;
         case 'string':
             $tempVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext);
             $codePrinter->output('ZVAL_STRING(' . $tempVariable->getName() . ', "' . $resolvedExpr->getCode() . '", 1);');
             if ($variable == 'this') {
                 $codePrinter->output('zephir_update_property_this(this_ptr, Z_STRVAL_P(' . $propertyVariableName->getName() . '), Z_STRLEN_P(' . $propertyVariableName->getName() . '), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             } else {
                 $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', Z_STRVAL_P(' . $propertyVariableName->getName() . '), Z_STRLEN_P(' . $propertyVariableName->getName() . '), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             }
             break;
         case 'bool':
             if ($variable == 'this') {
                 if ($resolvedExpr->getBooleanCode() == '1') {
                     $codePrinter->output('zephir_update_property_this(this_ptr, Z_STRVAL_P(' . $propertyVariableName->getName() . '), Z_STRLEN_P(' . $propertyVariableName->getName() . '), ZEPHIR_GLOBAL(global_true) TSRMLS_CC);');
                 } else {
                     $codePrinter->output('zephir_update_property_this(this_ptr, Z_STRVAL_P(' . $propertyVariableName->getName() . '), Z_STRLEN_P(' . $propertyVariableName->getName() . '), ZEPHIR_GLOBAL(global_false) TSRMLS_CC);');
                 }
             } else {
                 if ($resolvedExpr->getBooleanCode() == '1') {
                     $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', Z_STRVAL_P(' . $propertyVariableName->getName() . '), Z_STRLEN_P(' . $propertyVariableName->getName() . '), ZEPHIR_GLOBAL(global_true) TSRMLS_CC);');
                 } else {
                     $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', Z_STRVAL_P(' . $propertyVariableName->getName() . '), Z_STRLEN_P(' . $propertyVariableName->getName() . '), ZEPHIR_GLOBAL(global_false) TSRMLS_CC);');
                 }
             }
             break;
         case 'empty-array':
             $tempVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext);
             $codePrinter->output('array_init(' . $tempVariable->getName() . ');');
             if ($variable == 'this') {
                 $codePrinter->output('zephir_update_property_this(this_ptr, Z_STRVAL_P(' . $propertyVariableName->getName() . '), Z_STRLEN_P(' . $propertyVariableName->getName() . '), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             } else {
                 $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', Z_STRVAL_P(' . $propertyVariableName->getName() . '), Z_STRLEN_P(' . $propertyVariableName->getName() . '), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             }
             break;
         case 'variable':
             $variableVariable = $compilationContext->symbolTable->getVariableForRead($resolvedExpr->getCode(), $compilationContext, $statement);
             switch ($variableVariable->getType()) {
                 case 'int':
                 case 'uint':
                 case 'long':
                 case 'ulong':
                 case 'char':
                 case 'uchar':
                     $tempVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext);
                     $codePrinter->output('ZVAL_LONG(' . $tempVariable->getName() . ', ' . $variableVariable->getName() . ');');
                     $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', Z_STRVAL_P(' . $propertyVariableName->getName() . '), Z_STRLEN_P(' . $propertyVariableName->getName() . '), ' . $tempVariable->getName() . ' TSRMLS_CC);');
                     break;
                 case 'bool':
                     $tempVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext);
                     $codePrinter->output('ZVAL_BOOL(' . $tempVariable->getName() . ', ' . $variableVariable->getName() . ');');
                     if ($variable == 'this') {
                         $codePrinter->output('zephir_update_property_this(this_ptr, Z_STRVAL_P(' . $propertyVariableName->getName() . '), Z_STRLEN_P(' . $propertyVariableName->getName() . '), ' . $tempVariable->getName() . ' TSRMLS_CC);');
                     } else {
                         $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', Z_STRVAL_P(' . $propertyVariableName->getName() . '), Z_STRLEN_P(' . $propertyVariableName->getName() . '), ' . $tempVariable->getName() . ' TSRMLS_CC);');
                     }
                     break;
                 case 'string':
                 case 'variable':
                     $codePrinter->output('zephir_update_property_zval_zval(' . $symbolVariable->getName() . ', ' . $propertyVariable->getName() . ', ' . $resolvedExpr->getCode() . ' TSRMLS_CC);');
                     if ($symbolVariable->isTemporal()) {
                         $symbolVariable->setIdle(true);
                     }
                     break;
                 default:
                     throw new CompilerException("Unknown type " . $variableVariable->getType(), $statement);
             }
             break;
         default:
             throw new CompilerException("Unknown type " . $resolvedExpr->getType(), $statement);
     }
 }
开发者ID:NumbDai,项目名称:zephir,代码行数:101,代码来源:ObjectDynamicProperty.php

示例3: get

 /**
  * Retrieves/Creates a function cache for a method call
  *
  * @param CompilationContext $compilationContext
  * @param ClassMethod $method
  * @param Variable $caller
  */
 public function get(CompilationContext $compilationContext, $methodName, Variable $caller)
 {
     $compiler = $compilationContext->compiler;
     $numberPoly = 0;
     if ($caller->getRealName() == 'this') {
         $classDefinition = $compilationContext->classDefinition;
         if ($classDefinition->hasMethod($methodName)) {
             $numberPoly++;
             $method = $classDefinition->getMethod($methodName);
         }
     } else {
         $classTypes = $caller->getClassTypes();
         foreach ($classTypes as $classType) {
             if ($compiler->isClass($classType) || $compiler->isInterface($classType) || $compiler->isBundledClass($classType) || $compiler->isBundledInterface($classType)) {
                 if ($compiler->isInterface($classType)) {
                     continue;
                 }
                 if ($compiler->isClass($classType)) {
                     $classDefinition = $compiler->getClassDefinition($classType);
                 } else {
                     $classDefinition = $compiler->getInternalClassDefinition($classType);
                 }
                 if (!$classDefinition) {
                     continue;
                 }
                 if ($classDefinition->hasMethod($methodName) && !$classDefinition->isInterface()) {
                     $numberPoly++;
                     $method = $classDefinition->getMethod($methodName);
                 }
             }
         }
     }
     if (!$numberPoly) {
         // Try to generate a cache based on the fact the variable is not modified within the loop block
         if ($compilationContext->insideCycle && !$caller->isTemporal()) {
             if (count($compilationContext->cycleBlocks) && $caller->getType() == 'variable') {
                 $currentBlock = $compilationContext->cycleBlocks[count($compilationContext->cycleBlocks) - 1];
                 if ($currentBlock->getMutateGatherer(true)->getNumberOfMutations($caller->getName()) == 0) {
                     $functionCache = $compilationContext->symbolTable->getTempVariableForWrite('zephir_fcall_cache_entry', $compilationContext);
                     $functionCache->setMustInitNull(true);
                     $functionCache->setReusable(false);
                     return '&' . $functionCache->getName() . ', 0';
                 }
             }
         }
         return 'NULL, 0';
     }
     if (!$method instanceof \ReflectionMethod) {
         if ($method->getClassDefinition()->isExternal()) {
             return 'NULL, 0';
         }
         $completeName = $method->getClassDefinition()->getCompleteName();
         if (isset($this->cache[$completeName][$method->getName()])) {
             return $this->cache[$completeName][$method->getName()] . ', ' . SlotsCache::getExistingMethodSlot($method);
         }
         $gatherer = $this->gatherer;
         if (is_object($gatherer)) {
             $number = $gatherer->getNumberOfMethodCalls($method->getClassDefinition()->getCompleteName(), $method->getName());
         } else {
             $number = 0;
         }
         $staticCacheable = !$method->getClassDefinition()->isInterface() && ($compilationContext->currentMethod == $method || $method->getClassDefinition()->isFinal() || $method->isFinal() || $method->isPrivate());
         if ($number > 1 || $compilationContext->insideCycle) {
             $cacheable = true;
         } else {
             $cacheable = false;
         }
     } else {
         $staticCacheable = false;
         $cacheable = false;
     }
     // Recursive methods require warm-up
     if ($compilationContext->currentMethod == $method) {
         if (!$compilationContext->methodWarmUp) {
             $compilationContext->methodWarmUp = new MethodCallWarmUp();
         }
     }
     $associatedClass = false;
     if ($caller->getName() != 'this_ptr') {
         $associatedClass = $caller->getAssociatedClass();
         if ($this->isClassCacheable($associatedClass)) {
             $staticCacheable = true;
         }
     }
     if ($staticCacheable) {
         $cacheSlot = SlotsCache::getMethodSlot($method);
     } else {
         $cacheSlot = '0';
     }
     if ($cacheable) {
         $functionCacheVar = $compilationContext->symbolTable->getTempVariableForWrite('zephir_fcall_cache_entry', $compilationContext);
         $functionCacheVar->setMustInitNull(true);
         $functionCacheVar->setReusable(false);
//.........这里部分代码省略.........
开发者ID:edin,项目名称:zephir,代码行数:101,代码来源:MethodCache.php


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