Index: /trunk/Decompiler.class.php
===================================================================
--- /trunk/Decompiler.class.php	(revision 730)
+++ /trunk/Decompiler.class.php	(revision 731)
@@ -282,5 +282,5 @@
 				}
 			}
-			if (is_array($v)) {
+			if (is_array(value($v))) {
 				$multiline ++;
 			}
@@ -466,12 +466,12 @@
 	}
 	// }}}
-	function &dop_array($op_array, $indent = '') // {{{
-	{
-		$opcodes = &$op_array['opcodes'];
-		$last = count($opcodes) - 1;
-		if ($opcodes[$last]['opcode'] == XC_HANDLE_EXCEPTION) {
-			unset($opcodes[$last]);
-		}
-		$EX['indent'] = '';
+	function &fixOpcode($opcodes, $removeTailing = false) // {{{
+	{
+		if ($removeTailing) {
+			$last = count($opcodes) - 1;
+			if ($opcodes[$last]['opcode'] == XC_HANDLE_EXCEPTION) {
+				unset($opcodes[$last]);
+			}
+		}
 		for ($i = 0, $cnt = count($opcodes); $i < $cnt; $i ++) {
 			if (function_exists('xcache_get_fixed_opcode')) {
@@ -505,4 +505,12 @@
 			}
 		}
+		return $opcodes;
+	}
+	// }}}
+	function &dop_array($op_array, $indent = '') // {{{
+	{
+		$op_array['opcodes'] = $this->fixOpcode($op_array['opcodes'], true);
+		$opcodes = &$op_array['opcodes'];
+		$EX['indent'] = '';
 		// {{{ build jmp array
 		for ($i = 0, $cnt = count($opcodes); $i < $cnt; $i ++) {
@@ -757,5 +765,5 @@
 
 			$resvar = null;
-			if (isset($res['EA.type']) && ($res['EA.type'] & EXT_TYPE_UNUSED) || $res['op_type'] == XC_IS_UNUSED) {
+			if ((ZEND_ENGINE_2_4 ? ($res['op_type'] & EXT_TYPE_UNUSED) : ($res['EA.type'] & EXT_TYPE_UNUSED)) || $res['op_type'] == XC_IS_UNUSED) {
 				$istmpres = false;
 			}
@@ -791,5 +799,5 @@
 					$EX['called_scope'] = null;
 					$EX['fbc'] = 'new ' . $this->unquoteName($this->getOpVal($op1, $EX));
-					if (PHP_VERSION < 5) {
+					if (!ZEND_ENGINE_2) {
 						$resvar = '$new object$';
 					}
@@ -798,5 +806,5 @@
 				case XC_FETCH_CLASS: // {{{
 					if ($op2['op_type'] == XC_IS_UNUSED) {
-						switch ($ext) {
+						switch (($ext & (defined('ZEND_FETCH_CLASS_MASK') ? ZEND_FETCH_CLASS_MASK : 0xFF))) {
 						case ZEND_FETCH_CLASS_SELF:
 							$class = 'self';
@@ -843,5 +851,10 @@
 				case XC_UNSET_VAR:
 					$rvalue = $this->getOpVal($op1, $EX);
-					$fetchtype = $op2[PHP_VERSION < 5 ? 'fetch_type' : 'EA.type'];
+					if (defined('ZEND_FETCH_TYPE_MASK')) {
+						$fetchtype = ($ext & ZEND_FETCH_TYPE_MASK);
+					}
+					else {
+						$fetchtype = $op2[!ZEND_ENGINE_2 ? 'fetch_type' : 'EA.type'];
+					}
 					switch ($fetchtype) {
 					case ZEND_FETCH_STATIC_MEMBER:
@@ -957,4 +970,5 @@
 							switch ($rvalue->fetchType) {
 							case ZEND_FETCH_GLOBAL:
+							case ZEND_FETCH_GLOBAL_LOCK:
 								$resvar = 'global ' . $lvalue;
 								break 2;
@@ -970,7 +984,9 @@
 								unset($statics);
 								break 2;
+							default:
 							}
 						}
 					}
+					// TODO: PHP_6 global
 					$rvalue = str($rvalue);
 					$resvar = "$lvalue = &$rvalue";
@@ -1044,5 +1060,5 @@
 					}
 
-					switch ((PHP_VERSION < 5 ? $op['op2']['var'] /* constant */ : $ext) & (ZEND_ISSET|ZEND_ISEMPTY)) {
+					switch ((!ZEND_ENGINE_2 ? $op['op2']['var'] /* constant */ : $ext) & (ZEND_ISSET|ZEND_ISEMPTY)) {
 					case ZEND_ISSET:
 						$rvalue = "isset($rvalue)";
@@ -1511,4 +1527,6 @@
 			default:
 				if ($kk == 'res') {
+					var_dump($op);
+					exit;
 					assert(0);
 				}
@@ -1700,5 +1718,5 @@
 
 				$mangled = false;
-				if (PHP_VERSION < 5) {
+				if (!ZEND_ENGINE_2) {
 					echo 'var ';
 				}
@@ -1862,9 +1880,27 @@
 define('ZEND_ACC_SHADOW', 0x2000);
 
-define('ZEND_FETCH_GLOBAL',           0);
-define('ZEND_FETCH_LOCAL',            1);
-define('ZEND_FETCH_STATIC',           2);
-define('ZEND_FETCH_STATIC_MEMBER',    3);
-define('ZEND_FETCH_GLOBAL_LOCK',      4);
+define('ZEND_ENGINE_2_4', PHP_VERSION >= "5.3.99");
+define('ZEND_ENGINE_2_3', ZEND_ENGINE_2_4 || PHP_VERSION >= "5.3.");
+define('ZEND_ENGINE_2_2', ZEND_ENGINE_2_3 || PHP_VERSION >= "5.2.");
+define('ZEND_ENGINE_2_1', ZEND_ENGINE_2_2 || PHP_VERSION >= "5.1.");
+define('ZEND_ENGINE_2',   ZEND_ENGINE_2_1 || PHP_VERSION >= "5.0.");
+
+if (ZEND_ENGINE_2_4) {
+	define('ZEND_FETCH_GLOBAL',           0x00000000);
+	define('ZEND_FETCH_LOCAL',            0x10000000);
+	define('ZEND_FETCH_STATIC',           0x20000000);
+	define('ZEND_FETCH_STATIC_MEMBER',    0x30000000);
+	define('ZEND_FETCH_GLOBAL_LOCK',      0x40000000);
+	define('ZEND_FETCH_LEXICAL',          0x50000000);
+
+	define('ZEND_FETCH_TYPE_MASK',        0x70000000);
+}
+else {
+	define('ZEND_FETCH_GLOBAL',           0);
+	define('ZEND_FETCH_LOCAL',            1);
+	define('ZEND_FETCH_STATIC',           2);
+	define('ZEND_FETCH_STATIC_MEMBER',    3);
+	define('ZEND_FETCH_GLOBAL_LOCK',      4);
+}
 
 define('ZEND_FETCH_CLASS_DEFAULT',    0);
@@ -1876,4 +1912,10 @@
 define('ZEND_FETCH_CLASS_INTERFACE',  6);
 define('ZEND_FETCH_CLASS_STATIC',     7);
+if (ZEND_ENGINE_2_4) {
+	define('ZEND_FETCH_CLASS_TRAIT',     14);
+}
+if (ZEND_ENGINE_2_3) {
+	define('ZEND_FETCH_CLASS_MASK',     0xF);
+}
 
 define('ZEND_EVAL',               (1<<0));
@@ -1885,5 +1927,10 @@
 define('ZEND_ISSET',              (1<<0));
 define('ZEND_ISEMPTY',            (1<<1));
-define('EXT_TYPE_UNUSED',         (1<<0));
+if (ZEND_ENGINE_2_4) {
+	define('EXT_TYPE_UNUSED',     (1<<5));
+}
+else {
+	define('EXT_TYPE_UNUSED',     (1<<0));
+}
 
 define('ZEND_FETCH_STANDARD',     0);
Index: /trunk/phpdop.phpr
===================================================================
--- /trunk/phpdop.phpr	(revision 730)
+++ /trunk/phpdop.phpr	(revision 731)
@@ -3,4 +3,5 @@
 
 $srcdir = dirname(__FILE__);
+require_once("$srcdir/Decompiler.class.php");
 if (file_exists("$srcdir/phpdc.debug.php")) {
 	include("$srcdir/phpdc.debug.php");
@@ -11,15 +12,15 @@
 	switch ($op['op_type']) {
 	case 1: // CONST
-		return var_export($op['u.constant'], true);
+		return var_export($op['constant'], true);
 
 	case 2: // IS_TMP_VAR
-		return 't@' . $op['u.var'];
+		return 't@' . $op['var'];
 
 	case 4:
-		return 'v$' . $op['u.var'];
+		return 'v$' . $op['var'];
 
 	case 8: // UNUSED
-		if (isset($op['u.opline_num'])) {
-			return 'l#' . $op['u.opline_num'];
+		if (isset($op['opline_num'])) {
+			return 'l#' . $op['opline_num'];
 		}
 		else {
@@ -28,12 +29,14 @@
 
 	default:
-		return $op['op_type'] . $op['u.var'];
+		return $op['op_type'] . $op['var'];
 	}
 }
 
-function dump_opcodes($op_array, $indent = '')
+function dump_opcodes($opcodes, $indent = '')
 {
+	global $decompiler;
+
 	$types = array('result' => 5, 'op1' => 20, 'op2' => 20);
-	foreach ($op_array as $line => $op) {
+	foreach ($decompiler->fixOpcode($opcodes) as $line => $op) {
 		echo $indent;
 		echo sprintf("%3d ", $op['lineno']);
@@ -91,4 +94,5 @@
 	die("Usage: $argv[0] <file>\n");
 }
+$decompiler = new Decompiler();
 $pk = xcache_dasm_file($argv[1]);
 $op_array = $funcs = $classes = null;
