Browse Source

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
3.1
Xuefer 8 years ago
parent
commit
638209cbf9
  1. 11
      lib/Decompiler.class.php
  2. 13
      mod_disassembler/sample.cpp.php
  3. 9
      xcache.c

11
lib/Decompiler.class.php

@ -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')) {

13
mod_disassembler/sample.cpp.php

@ -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 */

9
xcache.c

@ -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();
}
}
}
/* }}} */

Loading…
Cancel
Save