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


PHP Variable::getName方法代码示例

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


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

示例1: assign

 /**
  * Compiles {var} = {expr}
  *
  * @param string $variable
  * @param ZephirVariable $symbolVariable
  * @param CompiledExpression $resolvedExpr
  * @param CompilationContext $compilationContext,
  * @param array $statement
  */
 public function assign($variable, ZephirVariable $symbolVariable, CompiledExpression $resolvedExpr, CompilationContext $compilationContext, $statement)
 {
     $codePrinter = $compilationContext->codePrinter;
     $codePrinter->output('if (zephir_set_symbol(' . $symbolVariable->getName() . ', ' . $resolvedExpr->getCode() . ' TSRMLS_CC) == FAILURE){');
     $codePrinter->output('  return;');
     $codePrinter->output('}');
 }
开发者ID:NumbDai,项目名称:zephir,代码行数:16,代码来源:ExportSymbol.php

示例2: assign

 /**
  * Compiles obj->x++
  *
  * @param string $variable
  * @param string $property
  * @param ZephirVariable $symbolVariable
  * @param CompilationContext $compilationContext
  * @param array $statement
  */
 public function assign($variable, $property, ZephirVariable $symbolVariable, CompilationContext $compilationContext, $statement)
 {
     if (!$symbolVariable->isInitialized()) {
         throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is not initialized", $statement);
     }
     /**
      * Arrays must be stored in the HEAP
      */
     if ($symbolVariable->isLocalOnly()) {
         throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is local only", $statement);
     }
     if (!$symbolVariable->isInitialized()) {
         throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is not initialized", $statement);
     }
     /**
      * Only dynamic variables can be used as arrays
      */
     if ($symbolVariable->getType() != 'variable') {
         throw new CompilerException("Cannot use variable type: '" . $symbolVariable->getType() . "' as array", $statement);
     }
     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 increment non-object dynamic variable', 'non-object-update', $statement);
     }
     $compilationContext->headersManager->add('kernel/object');
     $compilationContext->codePrinter->output('RETURN_ON_FAILURE(zephir_property_incr(' . $symbolVariable->getName() . ', SL("' . $property . '") TSRMLS_CC));');
 }
开发者ID:NumbDai,项目名称:zephir,代码行数:41,代码来源:ObjectPropertyIncr.php

示例3: assign

 /**
  * Compiles {var} = {expr}
  *
  * @param string $variable
  * @param ZephirVariable $symbolVariable
  * @param CompiledExpression $resolvedExpr
  * @param CompilationContext $compilationContext,
  * @param array $statement
  */
 public function assign($variable, ZephirVariable $symbolVariable, CompiledExpression $resolvedExpr, CompilationContext $compilationContext, $statement)
 {
     $codePrinter = $compilationContext->codePrinter;
     $variable = $compilationContext->symbolTable->getTempVariable('variable', $compilationContext, $statement);
     $variable->setMustInitNull(true);
     $letStatement = new LetStatement(array('type' => 'let', 'assignments' => array(array('assign-type' => 'variable', 'variable' => $variable->getName(), 'operator' => 'assign', 'expr' => array('type' => $resolvedExpr->getType(), 'value' => $resolvedExpr->getCode(), 'file' => $statement['file'], 'line' => $statement['line'], 'char' => $statement['char']), 'file' => $statement['file'], 'line' => $statement['line'], 'char' => $statement['char']))));
     $letStatement->compile($compilationContext);
     $codePrinter->output('if (zephir_set_symbol(' . $symbolVariable->getName() . ', ' . $variable->getName() . ' TSRMLS_CC) == FAILURE){');
     $codePrinter->output("\t" . 'return;');
     $codePrinter->output('}');
 }
开发者ID:edin,项目名称:zephir,代码行数:20,代码来源:ExportSymbol.php

示例4: compileHashTraverse

 /**
  * Compiles traversing of hash values
  * - Evaluated expression must be a zval
  * - Every key must be a zval
  * - Every value must be a zval
  *
  * @param array $expression
  * @param CompilationContext $compilationContext
  * @param Variable $exprVariable
  */
 public function compileHashTraverse($expression, $compilationContext, $exprVariable)
 {
     $codePrinter = $compilationContext->codePrinter;
     /**
      * Initialize 'key' variable
      */
     if (isset($this->_statement['key'])) {
         $keyVariable = $compilationContext->symbolTable->getVariableForWrite($this->_statement['key'], $compilationContext, $this->_statement['expr']);
         if ($keyVariable->getType() != 'variable') {
             throw new CompilerException("Cannot use variable: " . $this->_statement['key'] . " type: " . $keyVariable->getType() . " as key in hash traversal", $this->_statement['expr']);
         }
         $keyVariable->setMustInitNull(true);
         $keyVariable->setIsInitialized(true, $compilationContext, $this->_statement);
         $keyVariable->setDynamicTypes('undefined');
     }
     /**
      * Initialize 'value' variable
      */
     if (isset($this->_statement['value'])) {
         $variable = $compilationContext->symbolTable->getVariableForWrite($this->_statement['value'], $compilationContext, $this->_statement['expr']);
         if ($variable->getType() != 'variable') {
             throw new CompilerException("Cannot use variable: " . $this->_statement['value'] . " type: " . $variable->getType() . " as value in hash traversal", $this->_statement['expr']);
         }
         $variable->setMustInitNull(true);
         $variable->setIsInitialized(true, $compilationContext, $this->_statement);
         $variable->setDynamicTypes('undefined');
     }
     /**
      * Variables are initialized in a different way inside cycle
      */
     $compilationContext->insideCycle++;
     /**
      * Create a hash table and hash pointer temporary variables
      */
     $arrayPointer = $compilationContext->symbolTable->addTemp('HashPosition', $compilationContext);
     $arrayHash = $compilationContext->symbolTable->addTemp('HashTable', $compilationContext);
     /**
      * Create a temporary zval to fetch the items from the hash
      */
     $tempVariable = $compilationContext->symbolTable->addTemp('variable', $compilationContext);
     $tempVariable->setIsDoublePointer(true);
     $compilationContext->headersManager->add('kernel/hash');
     /**
      * We have to check if hashes are modified within the for's block
      */
     $duplicateHash = '0';
     if (isset($this->_statement['statements'])) {
         $detector = new ForValueUseDetector();
         if ($detector->detect($exprVariable->getName(), $this->_statement['statements'])) {
             $duplicateHash = '1';
         }
     }
     $codePrinter->output('zephir_is_iterable(' . $expression->getCode() . ', &' . $arrayHash->getName() . ', &' . $arrayPointer->getName() . ', ' . $duplicateHash . ', ' . $this->_statement['reverse'] . ', "' . Compiler::getShortUserPath($this->_statement['file']) . '", ' . $this->_statement['line'] . ');');
     $codePrinter->output('for (');
     $codePrinter->output('  ; zephir_hash_get_current_data_ex(' . $arrayHash->getName() . ', (void**) &' . $tempVariable->getName() . ', &' . $arrayPointer->getName() . ') == SUCCESS');
     if ($this->_statement['reverse']) {
         $codePrinter->output('  ; zephir_hash_move_backwards_ex(' . $arrayHash->getName() . ', &' . $arrayPointer->getName() . ')');
     } else {
         $codePrinter->output('  ; zephir_hash_move_forward_ex(' . $arrayHash->getName() . ', &' . $arrayPointer->getName() . ')');
     }
     $codePrinter->output(') {');
     if (isset($this->_statement['key'])) {
         $compilationContext->symbolTable->mustGrownStack(true);
         $codePrinter->output("\t" . 'ZEPHIR_GET_HMKEY(' . $this->_statement['key'] . ', ' . $arrayHash->getName() . ', ' . $arrayPointer->getName() . ');');
     }
     if (isset($this->_statement['value'])) {
         $compilationContext->symbolTable->mustGrownStack(true);
         $codePrinter->output("\t" . 'ZEPHIR_GET_HVALUE(' . $this->_statement['value'] . ', ' . $tempVariable->getName() . ');');
     }
     /**
      * Compile statements in the 'for' block
      */
     if (isset($this->_statement['statements'])) {
         $st = new StatementsBlock($this->_statement['statements']);
         $st->compile($compilationContext);
     }
     /**
      * Restore the cycle counter
      */
     $compilationContext->insideCycle--;
     $codePrinter->output('}');
 }
开发者ID:NumbDai,项目名称:zephir,代码行数:92,代码来源:ForStatement.php

示例5: destroyIterator

 public function destroyIterator(Variable $iteratorVariable, CompilationContext $context)
 {
     $context->codePrinter->output('zend_iterator_dtor(' . $iteratorVariable->getName() . ');');
 }
开发者ID:zhao5908,项目名称:zephir,代码行数:4,代码来源:Backend.php

示例6: assign

 /**
  * Compiles foo->x = {expr}
  *
  * @param string $variable
  * @param ZephirVariable $symbolVariable
  * @param CompiledExpression $resolvedExpr
  * @param CompilationContext $compilationContext
  * @param array $statement
  */
 public function assign($variable, ZephirVariable $symbolVariable, CompiledExpression $resolvedExpr, CompilationContext $compilationContext, $statement)
 {
     if (!$symbolVariable->isInitialized()) {
         throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is not initialized", $statement);
     }
     if ($symbolVariable->getType() != 'variable') {
         throw new CompilerException("Variable type '" . $symbolVariable->getType() . "' cannot be used as object", $statement);
     }
     $propertyName = $statement['property'];
     $className = $compilationContext->classDefinition->getCompleteName();
     if (!$symbolVariable->isInitialized()) {
         throw new CompilerException("Cannot mutate static property '" . $className . "::" . $propertyName . "' because it is not initialized", $statement);
     }
     if ($symbolVariable->getType() != 'variable') {
         throw new CompilerException("Cannot use variable type: " . $symbolVariable->getType() . " as an object", $statement);
     }
     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'))) {
         $compilationContext->logger->warning('Possible attempt to update property on non-object dynamic property', 'non-valid-objectupdate', $statement);
     }
     /**
      * Try to check if property is implemented on related object
      */
     if ($variable == 'this') {
         if (!$compilationContext->classDefinition->hasProperty($propertyName)) {
             throw new CompilerException("Property '" . $propertyName . "' is not defined on class '" . $className . "'", $statement);
         }
     }
     $codePrinter = $compilationContext->codePrinter;
     $compilationContext->headersManager->add('kernel/object');
     switch ($resolvedExpr->getType()) {
         case 'null':
             if ($variable == 'this') {
                 $codePrinter->output('zephir_update_property_this(this_ptr, SL("' . $propertyName . '"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC);');
             } else {
                 $codePrinter->output('zephir_update_property_zval(' . $symbolVariable->getName() . ', SL("' . $propertyName . '"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC);');
             }
             break;
         case 'int':
         case 'long':
         case 'uint':
             $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext);
             switch ($statement['operator']) {
                 case 'mul-assign':
                 case 'sub-assign':
                 case 'add-assign':
                     switch ($statement['operator']) {
                         case 'mul-assign':
                             $functionName = 'ZEPHIR_MUL_ASSIGN';
                             break;
                         case 'sub-assign':
                             $functionName = 'ZEPHIR_SUB_ASSIGN';
                             break;
                         case 'add-assign':
                             $functionName = 'ZEPHIR_ADD_ASSIGN';
                             break;
                     }
                     $resolvedVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext);
                     $codePrinter->output('ZVAL_LONG(' . $resolvedVariable->getName() . ', ' . $resolvedExpr->getBooleanCode() . ');');
                     $codePrinter->output($functionName . '(' . $tempVariable->getName() . ', ' . $resolvedVariable->getName() . ')');
                     break;
                 case 'assign':
                     $tempVariable->initNonReferenced($compilationContext);
                     $codePrinter->output('ZVAL_LONG(' . $tempVariable->getName() . ', ' . $resolvedExpr->getBooleanCode() . ');');
                     break;
                 default:
                     throw new CompilerException("Operator '" . $statement['operator'] . "' is not supported for object property: " . $tempVariable->getType(), $statement);
             }
             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 'char':
             $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext);
             switch ($statement['operator']) {
                 case 'assign':
                     $tempVariable->initNonReferenced($compilationContext);
                     $codePrinter->output('ZVAL_LONG(' . $tempVariable->getName() . ', \'' . $resolvedExpr->getBooleanCode() . '\');');
                     break;
                 default:
                     throw new CompilerException("Operator '" . $statement['operator'] . "' is not supported for object property: " . $tempVariable->getType(), $statement);
             }
             if ($variable == 'this') {
//.........这里部分代码省略.........
开发者ID:NumbDai,项目名称:zephir,代码行数:101,代码来源:ObjectProperty.php

示例7: _assignPropertyArrayMultipleIndex

 /**
  * Compiles x->y[a][b][] = {expr} (multiple offset assignment)
  *
  * @param string $variable
  * @param Variable $symbolVariable
  * @param CompiledExpression $resolvedExpr
  * @param CompilationContext $compilationContext,
  * @param array $statement
  */
 protected function _assignPropertyArrayMultipleIndex($variable, ZephirVariable $symbolVariable, CompiledExpression $resolvedExpr, CompilationContext $compilationContext, $statement)
 {
     $codePrinter = $compilationContext->codePrinter;
     $property = $statement['property'];
     $compilationContext->headersManager->add('kernel/object');
     /**
      * Create a temporal zval (if needed)
      */
     $variableExpr = $this->_getResolvedArrayItem($resolvedExpr, $compilationContext);
     /**
      * Only string/variable/int
      */
     $offsetExprs = array();
     foreach ($statement['index-expr'] as $indexExpr) {
         $indexExpression = new Expression($indexExpr);
         $resolvedIndex = $indexExpression->compile($compilationContext);
         switch ($resolvedIndex->getType()) {
             case 'string':
             case 'int':
             case 'uint':
             case 'ulong':
             case 'long':
             case 'variable':
                 break;
             default:
                 throw new CompilerException("Expression: " . $resolvedIndex->getType() . " cannot be used as index without cast", $statement['index-expr']);
         }
         $offsetExprs[] = $resolvedIndex;
     }
     $keys = '';
     $numberParams = 0;
     $offsetItems = array();
     foreach ($offsetExprs as $offsetExpr) {
         switch ($offsetExpr->getType()) {
             case 'int':
             case 'uint':
             case 'long':
             case 'ulong':
                 $keys .= 'l';
                 $offsetItems[] = $offsetExpr->getCode();
                 $numberParams++;
                 break;
             case 'string':
                 $keys .= 's';
                 $offsetItems[] = 'SL("' . $offsetExpr->getCode() . '")';
                 $numberParams += 2;
                 break;
             case 'variable':
                 $variableIndex = $compilationContext->symbolTable->getVariableForRead($offsetExpr->getCode(), $compilationContext, $statement);
                 switch ($variableIndex->getType()) {
                     case 'int':
                     case 'uint':
                     case 'long':
                     case 'ulong':
                         $keys .= 'l';
                         $offsetItems[] = $variableIndex->getName();
                         $numberParams++;
                         break;
                     case 'string':
                     case 'variable':
                         $keys .= 'z';
                         $offsetItems[] = $variableIndex->getName();
                         $numberParams++;
                         break;
                     default:
                         throw new CompilerException("Variable: " . $variableIndex->getType() . " cannot be used as array index", $statement);
                 }
                 break;
             default:
                 throw new CompilerException("Value: " . $offsetExpr->getType() . " cannot be used as array index", $statement);
         }
     }
     $codePrinter->output('zephir_update_property_array_multi(' . $symbolVariable->getName() . ', SL("' . $property . '"), &' . $variableExpr->getName() . ' TSRMLS_CC, SL("' . $keys . 'a"), ' . $numberParams . ', ' . join(', ', $offsetItems) . ');');
 }
开发者ID:NumbDai,项目名称:zephir,代码行数:83,代码来源:ObjectPropertyArrayIndexAppend.php

示例8: _assignPropertyArrayMultipleIndex

 /**
  * Compiles x->y[a][b][] = {expr} (multiple offset assignment)
  *
  * @param string $variable
  * @param ZephirVariable $symbolVariable
  * @param CompiledExpression $resolvedExpr
  * @param CompilationContext $compilationContext
  * @param array $statement
  * @throws CompilerException
  */
 protected function _assignPropertyArrayMultipleIndex($variable, ZephirVariable $symbolVariable, CompiledExpression $resolvedExpr, CompilationContext $compilationContext, array $statement)
 {
     $codePrinter = $compilationContext->codePrinter;
     $property = $statement['property'];
     $compilationContext->headersManager->add('kernel/object');
     /**
      * Create a temporal zval (if needed)
      */
     $variableExpr = $this->_getResolvedArrayItem($resolvedExpr, $compilationContext);
     if (count($statement['index-expr']) > 16) {
         throw new CompilerException("Too many array indexes", $statement);
     }
     /**
      * Only string/variable/int
      */
     $offsetExprs = array();
     foreach ($statement['index-expr'] as $indexExpr) {
         $indexExpression = new Expression($indexExpr);
         $resolvedIndex = $indexExpression->compile($compilationContext);
         switch ($resolvedIndex->getType()) {
             case 'string':
             case 'int':
             case 'uint':
             case 'ulong':
             case 'long':
             case 'variable':
                 break;
             default:
                 throw new CompilerException("Expression: " . $resolvedIndex->getType() . " cannot be used as index without cast", $statement);
         }
         $offsetExprs[] = $resolvedIndex;
     }
     /**
      * Check if the property to update is defined
      */
     if ($symbolVariable->getRealName() == 'this') {
         $classDefinition = $compilationContext->classDefinition;
         if (!$classDefinition->hasProperty($property)) {
             throw new CompilerException("Class '" . $classDefinition->getCompleteName() . "' does not have a property called: '" . $property . "'", $statement);
         }
         $propertyDefinition = $classDefinition->getProperty($property);
     } else {
         /**
          * If we know the class related to a variable we could check if the property
          * is defined on that class
          */
         if ($symbolVariable->hasAnyDynamicType('object')) {
             $classType = current($symbolVariable->getClassTypes());
             $compiler = $compilationContext->compiler;
             if ($compiler->isClass($classType)) {
                 $classDefinition = $compiler->getClassDefinition($classType);
                 if (!$classDefinition) {
                     throw new CompilerException("Cannot locate class definition for class: " . $classType, $statement);
                 }
                 if (!$classDefinition->hasProperty($property)) {
                     throw new CompilerException("Class '" . $classType . "' does not have a property called: '" . $property . "'", $statement);
                 }
             }
         }
     }
     $keys = '';
     $numberParams = 0;
     $offsetItems = array();
     foreach ($offsetExprs as $offsetExpr) {
         switch ($offsetExpr->getType()) {
             case 'int':
             case 'uint':
             case 'long':
             case 'ulong':
                 $keys .= 'l';
                 $offsetItems[] = $offsetExpr->getCode();
                 $numberParams++;
                 break;
             case 'string':
                 $keys .= 's';
                 $offsetItems[] = 'SL("' . $offsetExpr->getCode() . '")';
                 $numberParams += 2;
                 break;
             case 'variable':
                 $variableIndex = $compilationContext->symbolTable->getVariableForRead($offsetExpr->getCode(), $compilationContext, $statement);
                 switch ($variableIndex->getType()) {
                     case 'int':
                     case 'uint':
                     case 'long':
                     case 'ulong':
                         $keys .= 'l';
                         $offsetItems[] = $variableIndex->getName();
                         $numberParams++;
                         break;
                     case 'string':
//.........这里部分代码省略.........
开发者ID:edin,项目名称:zephir,代码行数:101,代码来源:ObjectPropertyArrayIndexAppend.php

示例9: forStatementIterator

 public function forStatementIterator(Variable $iteratorVariable, Variable $targetVariable, CompilationContext $compilationContext)
 {
     $compilationContext->codePrinter->output('zval *ZEPHIR_TMP_ITERATOR_PTR;');
     $compilationContext->codePrinter->output('ZEPHIR_TMP_ITERATOR_PTR = ' . $iteratorVariable->getName() . '->funcs->get_current_data(' . $iteratorVariable->getName() . ' TSRMLS_CC);');
     $compilationContext->codePrinter->output('ZVAL_COPY(' . $this->getVariableCode($targetVariable) . ', ZEPHIR_TMP_ITERATOR_PTR);');
 }
开发者ID:Mrhjx2,项目名称:zephir,代码行数:6,代码来源:Backend.php

示例10: assign

 /**
  * Compiles x->y[] = foo
  *
  * @param string $variable
  * @param ZephirVariable $symbolVariable
  * @param CompiledExpression $resolvedExpr
  * @param CompilationContext $compilationContext
  * @param array $statement
  * @throws CompilerException
  */
 public function assign($variable, ZephirVariable $symbolVariable, CompiledExpression $resolvedExpr, CompilationContext $compilationContext, array $statement)
 {
     if (!$symbolVariable->isInitialized()) {
         throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is not initialized", $statement);
     }
     if (!$symbolVariable->isVariable()) {
         throw new CompilerException("Attempt to use variable type: " . $symbolVariable->getType() . " as object", $statement);
     }
     $codePrinter = $compilationContext->codePrinter;
     $property = $statement['property'];
     $compilationContext->headersManager->add('kernel/object');
     /**
      * Check if the variable to update is defined
      */
     if ($symbolVariable->getRealName() == 'this') {
         $classDefinition = $compilationContext->classDefinition;
         if (!$classDefinition->hasProperty($property)) {
             throw new CompilerException("Class '" . $classDefinition->getCompleteName() . "' does not have a property called: '" . $property . "'", $statement);
         }
         $propertyDefinition = $classDefinition->getProperty($property);
     } else {
         /**
          * If we know the class related to a variable we could check if the property
          * is defined on that class
          */
         if ($symbolVariable->hasAnyDynamicType('object')) {
             $classType = current($symbolVariable->getClassTypes());
             $compiler = $compilationContext->compiler;
             if ($compiler->isClass($classType)) {
                 $classDefinition = $compiler->getClassDefinition($classType);
                 if (!$classDefinition) {
                     throw new CompilerException("Cannot locate class definition for class: " . $classType, $statement);
                 }
                 if (!$classDefinition->hasProperty($property)) {
                     throw new CompilerException("Class '" . $classType . "' does not have a property called: '" . $property . "'", $statement);
                 }
             }
         }
     }
     switch ($resolvedExpr->getType()) {
         case 'null':
             $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC);');
             break;
         case 'bool':
             $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), (' . $resolvedExpr->getBooleanCode() . ') ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);');
             break;
         case 'char':
             $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext, true);
             $codePrinter->output('ZVAL_LONG(' . $tempVariable->getName() . ', \'' . $resolvedExpr->getCode() . '\');');
             $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             if ($tempVariable->isTemporal()) {
                 $tempVariable->setIdle(true);
             }
             break;
         case 'int':
         case 'long':
         case 'uint':
             $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext, true);
             $codePrinter->output('ZVAL_LONG(' . $tempVariable->getName() . ', ' . $resolvedExpr->getCode() . ');');
             $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             if ($tempVariable->isTemporal()) {
                 $tempVariable->setIdle(true);
             }
             break;
         case 'double':
             $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext, true);
             $codePrinter->output('ZVAL_DOUBLE(' . $tempVariable->getName() . ', ' . $resolvedExpr->getCode() . ');');
             $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             if ($tempVariable->isTemporal()) {
                 $tempVariable->setIdle(true);
             }
             break;
         case 'string':
             $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext, true);
             $codePrinter->output('ZVAL_STRING(' . $tempVariable->getName() . ', "' . $resolvedExpr->getCode() . '", 1);');
             $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             if ($tempVariable->isTemporal()) {
                 $tempVariable->setIdle(true);
             }
             break;
         case 'array':
             $variableExpr = $compilationContext->symbolTable->getVariableForRead($resolvedExpr->getCode(), $compilationContext, $statement);
             $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), ' . $variableExpr->getName() . ' TSRMLS_CC);');
             break;
         case 'variable':
             $variableExpr = $compilationContext->symbolTable->getVariableForRead($resolvedExpr->getCode(), $compilationContext, $statement);
             switch ($variableExpr->getType()) {
                 case 'int':
                 case 'long':
                 case 'uint':
//.........这里部分代码省略.........
开发者ID:Jvbzephir,项目名称:zephir,代码行数:101,代码来源:ObjectPropertyAppend.php

示例11: callParent

 /**
  * Calls static methods on the 'parent' context
  *
  * @param string $methodName
  * @param array $expression
  * @param Variable $symbolVariable
  * @param boolean $mustInit
  * @param boolean $isExpecting
  * @param ClassDefinition $classDefinition
  * @param CompilationContext $compilationContext
  * @param ClassMethod $method
  */
 protected function callParent($methodName, array $expression, $symbolVariable, $mustInit, $isExpecting, ClassDefinition $classDefinition, CompilationContext $compilationContext, ClassMethod $method)
 {
     $codePrinter = $compilationContext->codePrinter;
     $classCe = $classDefinition->getClassEntry($compilationContext);
     //$className = str_replace('\\', '\\\\', $classDefinition->getCompleteName());
     /**
      * Call static methods must grown the stack
      */
     $compilationContext->symbolTable->mustGrownStack(true);
     if ($mustInit) {
         $symbolVariable->setMustInitNull(true);
         $symbolVariable->trackVariant($compilationContext);
     }
     /**
      * Check if the  method call can have an inline cache
      */
     $methodCache = $compilationContext->cacheManager->getStaticMethodCache();
     $cachePointer = $methodCache->get($compilationContext, isset($method) ? $method : null);
     if (isset($expression['parameters']) && count($expression['parameters'])) {
         $params = $this->getResolvedParams($expression['parameters'], $compilationContext, $expression);
     } else {
         $params = array();
     }
     if (!count($params)) {
         if ($isExpecting) {
             if ($symbolVariable->getName() == 'return_value') {
                 $codePrinter->output('ZEPHIR_RETURN_CALL_PARENT(' . $classCe . ', this_ptr, "' . $methodName . '", ' . $cachePointer . ');');
             } else {
                 $codePrinter->output('ZEPHIR_CALL_PARENT(&' . $symbolVariable->getName() . ', ' . $classCe . ', this_ptr, "' . $methodName . '", ' . $cachePointer . ');');
             }
         } else {
             $codePrinter->output('ZEPHIR_CALL_PARENT(NULL, ' . $classCe . ', this_ptr, "' . $methodName . '", ' . $cachePointer . ');');
         }
     } else {
         if ($isExpecting) {
             if ($symbolVariable->getName() == 'return_value') {
                 $codePrinter->output('ZEPHIR_RETURN_CALL_PARENT(' . $classCe . ', this_ptr, "' . $methodName . '", ' . $cachePointer . ', ' . join(', ', $params) . ');');
             } else {
                 $codePrinter->output('ZEPHIR_CALL_PARENT(&' . $symbolVariable->getName() . ', ' . $classCe . ', this_ptr, "' . $methodName . '", ' . $cachePointer . ', ' . join(', ', $params) . ');');
             }
         } else {
             $codePrinter->output('ZEPHIR_CALL_PARENT(NULL, ' . $classCe . ', this_ptr, "' . $methodName . '", ' . $cachePointer . ', ' . join(', ', $params) . ');');
         }
     }
     /**
      * Temporary variables must be copied if they have more than one reference
      */
     foreach ($this->getMustCheckForCopyVariables() as $checkVariable) {
         $codePrinter->output('zephir_check_temp_parameter(' . $checkVariable . ');');
     }
     $this->addCallStatusOrJump($compilationContext);
 }
开发者ID:chet0xhenry,项目名称:zephir,代码行数:64,代码来源:StaticCall.php

示例12: addRawVariable

 /**
  * Adds a raw variable to the symbol table (root branch)
  *
  * @param Variable $variable
  * @return Variable
  */
 public function addRawVariable(Variable $variable)
 {
     if (!isset($this->branchVariables[1])) {
         $this->branchVariables[1] = array();
     }
     $this->branchVariables[1][$variable->getName()] = $variable;
     return $variable;
 }
开发者ID:phalcon,项目名称:zephir,代码行数:14,代码来源:SymbolTable.php

示例13: assign

 /**
  * Compiles obj->x++
  *
  * @param string $variable
  * @param string $property
  * @param ZephirVariable $symbolVariable
  * @param CompilationContext $compilationContext
  * @param array $statement
  */
 public function assign($variable, $property, ZephirVariable $symbolVariable, CompilationContext $compilationContext, $statement)
 {
     if (!$symbolVariable->isInitialized()) {
         throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is not initialized", $statement);
     }
     /**
      * Arrays must be stored in the HEAP
      */
     if ($symbolVariable->isLocalOnly()) {
         throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is local only", $statement);
     }
     if (!$symbolVariable->isInitialized()) {
         throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is not initialized", $statement);
     }
     /**
      * Only dynamic variables can be used as arrays
      */
     if (!$symbolVariable->isVariable()) {
         throw new CompilerException("Cannot use variable type: '" . $symbolVariable->getType() . "' as array", $statement);
     }
     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 increment non-object dynamic variable', 'non-object-update', $statement);
     }
     /**
      * Check if the variable to update is defined
      */
     if ($symbolVariable->getRealName() == 'this') {
         $classDefinition = $compilationContext->classDefinition;
         if (!$classDefinition->hasProperty($property)) {
             throw new CompilerException("Class '" . $classDefinition->getCompleteName() . "' does not have a property called: '" . $property . "'", $statement);
         }
         $propertyDefinition = $classDefinition->getProperty($property);
     } else {
         /**
          * If we know the class related to a variable we could check if the property
          * is defined on that class
          */
         if ($symbolVariable->hasAnyDynamicType('object')) {
             $classType = current($symbolVariable->getClassTypes());
             $compiler = $compilationContext->compiler;
             if ($compiler->isClass($classType)) {
                 $classDefinition = $compiler->getClassDefinition($classType);
                 if (!$classDefinition) {
                     throw new CompilerException("Cannot locate class definition for class: " . $classType, $statement);
                 }
                 if (!$classDefinition->hasProperty($property)) {
                     throw new CompilerException("Class '" . $classType . "' does not have a property called: '" . $property . "'", $statement);
                 }
             }
         }
     }
     $compilationContext->headersManager->add('kernel/object');
     $compilationContext->codePrinter->output('RETURN_ON_FAILURE(zephir_property_incr(' . $symbolVariable->getName() . ', SL("' . $property . '") TSRMLS_CC));');
 }
开发者ID:zhao5908,项目名称:zephir,代码行数:69,代码来源:ObjectPropertyIncr.php

示例14: 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

示例15: assign

 /**
  * Compiles x->y[] = foo
  *
  * @param string $variable
  * @param Variable $symbolVariable
  * @param CompiledExpression $resolvedExpr
  * @param CompilationContext $compilationContext,
  * @param array $statement
  */
 public function assign($variable, ZephirVariable $symbolVariable, CompiledExpression $resolvedExpr, CompilationContext $compilationContext, $statement)
 {
     if (!$symbolVariable->isInitialized()) {
         throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is not initialized", $statement);
     }
     if ($symbolVariable->getType() != 'variable') {
         throw new CompilerException("Attempt to use variable type: " . $symbolVariable->getType() . " as object", $statement);
     }
     $codePrinter = $compilationContext->codePrinter;
     $property = $statement['property'];
     $compilationContext->headersManager->add('kernel/object');
     /* @todo check whether property really does exist */
     switch ($resolvedExpr->getType()) {
         case 'null':
             $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC);');
             break;
         case 'bool':
             $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), (' . $resolvedExpr->getBooleanCode() . ') ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);');
             break;
         case 'char':
             $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext, true);
             $codePrinter->output('ZVAL_LONG(' . $tempVariable->getName() . ', \'' . $resolvedExpr->getCode() . '\');');
             $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             if ($tempVariable->isTemporal()) {
                 $tempVariable->setIdle(true);
             }
             break;
         case 'int':
         case 'long':
         case 'uint':
             $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext, true);
             $codePrinter->output('ZVAL_LONG(' . $tempVariable->getName() . ', ' . $resolvedExpr->getCode() . ');');
             $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             if ($tempVariable->isTemporal()) {
                 $tempVariable->setIdle(true);
             }
             break;
         case 'double':
             $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext, true);
             $codePrinter->output('ZVAL_DOUBLE(' . $tempVariable->getName() . ', ' . $resolvedExpr->getCode() . ');');
             $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             if ($tempVariable->isTemporal()) {
                 $tempVariable->setIdle(true);
             }
             break;
         case 'string':
             $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext, true);
             $codePrinter->output('ZVAL_STRING(' . $tempVariable->getName() . ', "' . $resolvedExpr->getCode() . '", 1);');
             $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
             if ($tempVariable->isTemporal()) {
                 $tempVariable->setIdle(true);
             }
             break;
         case 'array':
             $variableExpr = $compilationContext->symbolTable->getVariableForRead($resolvedExpr->getCode(), $compilationContext, $statement);
             $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), ' . $variableExpr->getName() . ' TSRMLS_CC);');
             break;
         case 'variable':
             $variableExpr = $compilationContext->symbolTable->getVariableForRead($resolvedExpr->getCode(), $compilationContext, $statement);
             switch ($variableExpr->getType()) {
                 case 'int':
                 case 'long':
                 case 'uint':
                 case 'char':
                     $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext, true);
                     $codePrinter->output('ZVAL_LONG(' . $tempVariable->getName() . ', ' . $variableExpr->getName() . ');');
                     $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
                     if ($tempVariable->isTemporal()) {
                         $tempVariable->setIdle(true);
                     }
                     break;
                 case 'double':
                     $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext, true);
                     $codePrinter->output('ZVAL_DOUBLE(' . $tempVariable->getName() . ', ' . $variableExpr->getName() . ');');
                     $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
                     if ($tempVariable->isTemporal()) {
                         $tempVariable->setIdle(true);
                     }
                     break;
                 case 'bool':
                     $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext, true);
                     $codePrinter->output('ZVAL_BOOL(' . $tempVariable->getName() . ', ' . $variableExpr->getName() . ');');
                     $codePrinter->output('zephir_update_property_array_append(' . $symbolVariable->getName() . ', SL("' . $property . '"), ' . $tempVariable->getName() . ' TSRMLS_CC);');
                     if ($tempVariable->isTemporal()) {
                         $tempVariable->setIdle(true);
                     }
                     break;
                 case 'variable':
                 case 'string':
                 case 'array':
                 case 'resource':
//.........这里部分代码省略.........
开发者ID:NumbDai,项目名称:zephir,代码行数:101,代码来源:ObjectPropertyAppend.php


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