Browse Source

disassembler: refix previous partial

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@713 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 11 years ago
parent
commit
7471acdf96
  1. 55
      Decompiler.class.php
  2. 8
      processor/processor.m4
  3. 15
      xcache.c

55
Decompiler.class.php

@ -28,7 +28,7 @@ function str($src, $indent = '') // {{{
if (is_array($src)) {
die_error('array str');
$src = new Decompiler_Array($src, false, $indent);
$src = new Decompiler_Array($src, $indent);
return $src->__toString();
}
@ -37,7 +37,7 @@ function str($src, $indent = '') // {{{
var_dump($src);
die_error('no __toString');
}
return $src->__toString($indent);
return $src->__toString();
}
return $src;
@ -55,10 +55,10 @@ function value($value) // {{{
}
if (is_array($value)) {
$value = new Decompiler_Array($value, true);
$value = new Decompiler_Array($value);
}
else {
$value = new Decompiler_Value($value, true);
$value = new Decompiler_Value($value);
}
return $value;
}
@ -256,13 +256,11 @@ class Decompiler_ListBox extends Decompiler_Box // {{{
// }}}
class Decompiler_Array extends Decompiler_Value // {{{
{
var $needExport = false;
var $indent = '';
function Decompiler_Array($value = array(), $needexport = false, $indent = '')
function Decompiler_Array($value = array(), $indent = '')
{
$this->value = $value;
$this->needExport = $needexport;
$this->indent = $indent;
}
@ -285,7 +283,7 @@ class Decompiler_Array extends Decompiler_Value // {{{
}
++ $i;
}
if ($assoclen && $this->needExport) {
if ($assoclen) {
$assoclen += 2;
}
@ -305,9 +303,7 @@ class Decompiler_Array extends Decompiler_Value // {{{
}
}
if ($this->needExport) {
$k = var_export($k, true);
}
$k = var_export($k, true);
if ($multiline) {
$exp .= sprintf("%{$assoclen}s => ", $k);
}
@ -315,10 +311,7 @@ class Decompiler_Array extends Decompiler_Value // {{{
$exp .= $k . ' => ';
}
if (is_array($v)) {
$v = new Decompiler_Array($v, $this->needExport);
}
$exp .= str($v, $subindent);
$exp .= str(value($v), $subindent);
$i ++;
}
@ -1607,8 +1600,8 @@ class Decompiler
// {{{ properties
if (!empty($class['default_properties'])) {
echo "\n";
$infos = empty($class['properties_info']) ? null : $class['properties_info'];
foreach ($class['default_properties'] as $name => $v) {
$infos = !empty($class['properties_info']) ? $class['properties_info'] : null;
foreach (!empty($class['properties_info']) ? $class['properties_info'] : ($class['default_static_members'] + $class['default_properties']) as $name => $dummy) {
$info = (isset($infos) && isset($infos[$name])) ? $infos[$name] : null;
if (isset($info)) {
if (!empty($info['doc_comment'])) {
@ -1619,6 +1612,21 @@ class Decompiler
}
echo $newindent;
$static = false;
if (isset($info)) {
if ($info['flags'] & ZEND_ACC_STATIC) {
$static = true;
}
}
else if (isset($class['default_static_members'][$name])) {
$static = true;
}
if ($static) {
echo "static ";
}
$mangled = false;
if (PHP_VERSION < 5) {
echo 'var ';
}
@ -1635,20 +1643,23 @@ class Decompiler
break;
case ZEND_ACC_PRIVATE:
echo "private ";
$mangled = true;
break;
case ZEND_ACC_PROTECTED:
echo "protected ";
$mangled = true;
break;
}
if ($info['flags'] & ZEND_ACC_STATIC) {
echo "static ";
}
}
echo '$', $name;
if (isset($v)) {
$key = isset($info) ? $info['name'] . ($mangled ? "\000" : "") : $name;
$value = $class[$static ? 'default_static_members' : 'default_properties'][$key];
if (isset($value)) {
echo ' = ';
echo str(value($v));
echo str(value($value));
}
echo ";\n";
}

8
processor/processor.m4

@ -74,14 +74,6 @@ DEF_STRUCT_P_FUNC(`zval', , `dnl {{{
*dst = *src;
zval_copy_ctor(dst);
Z_SET_REFCOUNT(*dst, 1);
switch ((Z_TYPE_P(src) & IS_CONSTANT_TYPE_MASK)) {
case IS_CONSTANT:
dst->type = UNISW(IS_STRING, UG(unicode) ? IS_UNICODE : IS_STRING);
break;
case IS_CONSTANT_ARRAY:
dst->type = IS_ARRAY;
break;
}
DONE(value)
DONE(type)
#ifdef ZEND_ENGINE_2_3

15
xcache.c

@ -3012,21 +3012,22 @@ PHP_FUNCTION(xcache_get_special_value)
return;
}
if (value->type == IS_CONSTANT) {
switch ((Z_TYPE_P(value) & IS_CONSTANT_TYPE_MASK)) {
case IS_CONSTANT:
*return_value = *value;
zval_copy_ctor(return_value);
return_value->type = UNISW(IS_STRING, UG(unicode) ? IS_UNICODE : IS_STRING);
return;
}
break;
if (value->type == IS_CONSTANT_ARRAY) {
case IS_CONSTANT_ARRAY:
*return_value = *value;
zval_copy_ctor(return_value);
return_value->type = IS_ARRAY;
return;
}
break;
RETURN_NULL();
default:
RETURN_NULL();
}
}
/* }}} */
/* {{{ proto string xcache_coredump(int op_type) */

Loading…
Cancel
Save