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


PHP Variable::getDefaultInitValue方法代码示例

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


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

示例1: generateInitCode

 public function generateInitCode(&$groupVariables, $type, $pointer, Variable $variable)
 {
     $isComplex = $type == 'variable' || $type == 'string' || $type == 'array' || $type == 'resource' || $type == 'callable' || $type == 'object';
     if ($isComplex && !$variable->isDoublePointer()) {
         /* && $variable->mustInitNull() */
         $groupVariables[] = $variable->getName();
         if ($variable->getRealname() == '__$null') {
             return "\t" . 'ZVAL_NULL(&' . $variable->getName() . ');';
         } else {
             if ($variable->getRealname() == '__$true') {
                 return "\t" . 'ZVAL_BOOL(&' . $variable->getName() . ', 1);';
             } else {
                 if ($variable->getRealname() == '__$false') {
                     return "\t" . 'ZVAL_BOOL(&' . $variable->getName() . ', 0);';
                 }
             }
         }
         return "\t" . 'ZVAL_UNDEF(&' . $variable->getName() . ');';
     }
     if ($variable->isLocalOnly()) {
         $groupVariables[] = $variable->getName();
         return;
     }
     if ($variable->isDoublePointer()) {
         /* Double pointers for ZE3 are used as zval * */
         $ptr = $isComplex ? $pointer : $pointer . $pointer;
         if ($variable->mustInitNull()) {
             $groupVariables[] = $ptr . $variable->getName() . ' = NULL';
         } else {
             $groupVariables[] = $ptr . $variable->getName();
         }
         return;
     }
     $defaultValue = $variable->getDefaultInitValue();
     if ($defaultValue !== null) {
         switch ($type) {
             case 'variable':
             case 'string':
             case 'array':
             case 'resource':
             case 'callable':
             case 'object':
                 $groupVariables[] = $pointer . $variable->getName();
                 break;
             case 'char':
                 if (strlen($defaultValue) > 4) {
                     if (strlen($defaultValue) > 10) {
                         throw new CompilerException("Invalid char literal: '" . substr($defaultValue, 0, 10) . "...'", $variable->getOriginal());
                     } else {
                         throw new CompilerException("Invalid char literal: '" . $defaultValue . "'", $variable->getOriginal());
                     }
                 }
                 /* no break */
             /* no break */
             default:
                 $groupVariables[] = $pointer . $variable->getName() . ' = ' . $defaultValue;
                 break;
         }
         return;
     }
     if ($variable->mustInitNull() && $pointer) {
         $groupVariables[] = $pointer . $variable->getName() . ' = NULL';
         return;
     }
     $groupVariables[] = $pointer . $variable->getName();
 }
开发者ID:Mrhjx2,项目名称:zephir,代码行数:66,代码来源:Backend.php

示例2: generateInitCode

 public function generateInitCode(&$groupVariables, $type, $pointer, Variable $variable)
 {
     $isComplex = $type == 'variable' || $type == 'string' || $type == 'array' || $type == 'resource' || $type == 'callable' || $type == 'object';
     if ($isComplex && $variable->mustInitNull()) {
         if ($variable->isLocalOnly()) {
             $groupVariables[] = $variable->getName() . ' = zval_used_for_init';
         } else {
             if ($variable->isDoublePointer()) {
                 $groupVariables[] = $pointer . $pointer . $variable->getName() . ' = NULL';
             } else {
                 $groupVariables[] = $pointer . $variable->getName() . ' = NULL';
             }
         }
         return;
     }
     if ($variable->isLocalOnly()) {
         $groupVariables[] = $variable->getName();
         return;
     }
     if ($variable->isDoublePointer()) {
         if ($variable->mustInitNull()) {
             $groupVariables[] = $pointer . $pointer . $variable->getName() . ' = NULL';
         } else {
             $groupVariables[] = $pointer . $pointer . $variable->getName();
         }
         return;
     }
     $defaultValue = $variable->getDefaultInitValue();
     if ($defaultValue !== null) {
         switch ($type) {
             case 'variable':
             case 'string':
             case 'array':
             case 'resource':
             case 'callable':
             case 'object':
                 $groupVariables[] = $pointer . $variable->getName();
                 break;
             case 'char':
                 if (strlen($defaultValue) > 4) {
                     if (strlen($defaultValue) > 10) {
                         throw new CompilerException("Invalid char literal: '" . substr($defaultValue, 0, 10) . "...'", $variable->getOriginal());
                     } else {
                         throw new CompilerException("Invalid char literal: '" . $defaultValue . "'", $variable->getOriginal());
                     }
                 }
                 /* no break */
             /* no break */
             default:
                 $groupVariables[] = $pointer . $variable->getName() . ' = ' . $defaultValue;
                 break;
         }
         return;
     }
     if ($variable->mustInitNull() && $pointer) {
         $groupVariables[] = $pointer . $variable->getName() . ' = NULL';
         return;
     }
     $groupVariables[] = $pointer . $variable->getName();
 }
开发者ID:chet0xhenry,项目名称:zephir,代码行数:60,代码来源:Backend.php


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