1
0
Fork 0

Decompiler: fixes #318 (support for const in static array index/value)

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1374 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
This commit is contained in:
Xuefer 2013-09-16 15:48:48 +00:00
parent 0158af3733
commit 638209cbf9
3 changed files with 26 additions and 7 deletions

View File

@ -89,13 +89,14 @@ function foldToCode($src, $indent = '') // {{{ wrap or rewrap anything to Decomp
// }}}
function value($value, &$EX) // {{{
{
$spec = xcache_get_special_value($value);
if (isset($spec)) {
$value = $spec;
if (!is_array($value)) {
$originalValue = xcache_get_special_value($value);
if (isset($originalValue)) {
if ((xcache_get_type($value) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) {
// constant
return $GLOBALS['__xcache_decompiler']->stripNamespace($value);
return $GLOBALS['__xcache_decompiler']->stripNamespace($originalValue);
}
$value = $originalValue;
}
if (is_a($value, 'Decompiler_Object')) {

View File

@ -30,7 +30,18 @@ abstract class ClassName
1 => 'str',
CONST_VALUE => CONST_VALUE
);
static public $static2 = array(self::CONST_VALUE => self::CONST_VALUE);
static public $static_const1 = CONST_VALUE;
static public $static_const2 = self::CONST_VALUE;
static public $static_const3 = ClassName::CONST_VALUE;
static public $static_const4 = array(CONST_VALUE => 'test');
static public $static_const5 = array(self::CONST_VALUE => 'test');
static public $static_const6 = array(ClassName::CONST_VALUE => 'test');
static public $static_const7 = array('test' => CONST_VALUE);
static public $static_const8 = array('test' => self::CONST_VALUE);
static public $static_const9 = array('test' => ClassName::CONST_VALUE);
static public $static_const10 = array(CONST_VALUE => CONST_VALUE);
static public $static_const11 = array(self::CONST_VALUE => self::CONST_VALUE);
static public $static_const12 = array(ClassName::CONST_VALUE => ClassName::CONST_VALUE);
/** doc */
static public $public_static = array(2, 'str');
/** doc */

View File

@ -350,7 +350,14 @@ PHP_FUNCTION(xcache_get_special_value)
break;
default:
RETURN_NULL();
if ((Z_TYPE_P(value) & ~IS_CONSTANT_TYPE_MASK)) {
*return_value = *value;
zval_copy_ctor(return_value);
return_value->type &= IS_CONSTANT_TYPE_MASK;
}
else {
RETURN_NULL();
}
}
}
/* }}} */