本文整理汇总了PHP中Zephir\Variable::getOriginal方法的典型用法代码示例。如果您正苦于以下问题:PHP Variable::getOriginal方法的具体用法?PHP Variable::getOriginal怎么用?PHP Variable::getOriginal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zephir\Variable
的用法示例。
在下文中一共展示了Variable::getOriginal方法的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();
}
示例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();
}