Changeset d441951 in git
- Timestamp:
- 2011-04-10T09:07:58Z (9 years ago)
- Branches:
- 3.0, 3.1, 3.2, master, trunk
- Children:
- 9d6ca98
- Parents:
- d7a969e
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Decompiler.class.php
rd7a969e rd441951 282 282 } 283 283 } 284 if (is_array( $v)) {284 if (is_array(value($v))) { 285 285 $multiline ++; 286 286 } … … 466 466 } 467 467 // }}} 468 function & dop_array($op_array, $indent = '') // {{{469 { 470 $opcodes = &$op_array['opcodes'];471 $last = count($opcodes) - 1;472 if ($opcodes[$last]['opcode'] == XC_HANDLE_EXCEPTION) {473 unset($opcodes[$last]);474 }475 $EX['indent'] = '';468 function &fixOpcode($opcodes, $removeTailing = false) // {{{ 469 { 470 if ($removeTailing) { 471 $last = count($opcodes) - 1; 472 if ($opcodes[$last]['opcode'] == XC_HANDLE_EXCEPTION) { 473 unset($opcodes[$last]); 474 } 475 } 476 476 for ($i = 0, $cnt = count($opcodes); $i < $cnt; $i ++) { 477 477 if (function_exists('xcache_get_fixed_opcode')) { … … 505 505 } 506 506 } 507 return $opcodes; 508 } 509 // }}} 510 function &dop_array($op_array, $indent = '') // {{{ 511 { 512 $op_array['opcodes'] = $this->fixOpcode($op_array['opcodes'], true); 513 $opcodes = &$op_array['opcodes']; 514 $EX['indent'] = ''; 507 515 // {{{ build jmp array 508 516 for ($i = 0, $cnt = count($opcodes); $i < $cnt; $i ++) { … … 757 765 758 766 $resvar = null; 759 if ( isset($res['EA.type']) && ($res['EA.type'] & EXT_TYPE_UNUSED) || $res['op_type'] == XC_IS_UNUSED) {767 if ((ZEND_ENGINE_2_4 ? ($res['op_type'] & EXT_TYPE_UNUSED) : ($res['EA.type'] & EXT_TYPE_UNUSED)) || $res['op_type'] == XC_IS_UNUSED) { 760 768 $istmpres = false; 761 769 } … … 791 799 $EX['called_scope'] = null; 792 800 $EX['fbc'] = 'new ' . $this->unquoteName($this->getOpVal($op1, $EX)); 793 if ( PHP_VERSION < 5) {801 if (!ZEND_ENGINE_2) { 794 802 $resvar = '$new object$'; 795 803 } … … 798 806 case XC_FETCH_CLASS: // {{{ 799 807 if ($op2['op_type'] == XC_IS_UNUSED) { 800 switch ( $ext) {808 switch (($ext & (defined('ZEND_FETCH_CLASS_MASK') ? ZEND_FETCH_CLASS_MASK : 0xFF))) { 801 809 case ZEND_FETCH_CLASS_SELF: 802 810 $class = 'self'; … … 843 851 case XC_UNSET_VAR: 844 852 $rvalue = $this->getOpVal($op1, $EX); 845 $fetchtype = $op2[PHP_VERSION < 5 ? 'fetch_type' : 'EA.type']; 853 if (defined('ZEND_FETCH_TYPE_MASK')) { 854 $fetchtype = ($ext & ZEND_FETCH_TYPE_MASK); 855 } 856 else { 857 $fetchtype = $op2[!ZEND_ENGINE_2 ? 'fetch_type' : 'EA.type']; 858 } 846 859 switch ($fetchtype) { 847 860 case ZEND_FETCH_STATIC_MEMBER: … … 957 970 switch ($rvalue->fetchType) { 958 971 case ZEND_FETCH_GLOBAL: 972 case ZEND_FETCH_GLOBAL_LOCK: 959 973 $resvar = 'global ' . $lvalue; 960 974 break 2; … … 970 984 unset($statics); 971 985 break 2; 986 default: 972 987 } 973 988 } 974 989 } 990 // TODO: PHP_6 global 975 991 $rvalue = str($rvalue); 976 992 $resvar = "$lvalue = &$rvalue"; … … 1044 1060 } 1045 1061 1046 switch (( PHP_VERSION < 5? $op['op2']['var'] /* constant */ : $ext) & (ZEND_ISSET|ZEND_ISEMPTY)) {1062 switch ((!ZEND_ENGINE_2 ? $op['op2']['var'] /* constant */ : $ext) & (ZEND_ISSET|ZEND_ISEMPTY)) { 1047 1063 case ZEND_ISSET: 1048 1064 $rvalue = "isset($rvalue)"; … … 1511 1527 default: 1512 1528 if ($kk == 'res') { 1529 var_dump($op); 1530 exit; 1513 1531 assert(0); 1514 1532 } … … 1700 1718 1701 1719 $mangled = false; 1702 if ( PHP_VERSION < 5) {1720 if (!ZEND_ENGINE_2) { 1703 1721 echo 'var '; 1704 1722 } … … 1862 1880 define('ZEND_ACC_SHADOW', 0x2000); 1863 1881 1864 define('ZEND_FETCH_GLOBAL', 0); 1865 define('ZEND_FETCH_LOCAL', 1); 1866 define('ZEND_FETCH_STATIC', 2); 1867 define('ZEND_FETCH_STATIC_MEMBER', 3); 1868 define('ZEND_FETCH_GLOBAL_LOCK', 4); 1882 define('ZEND_ENGINE_2_4', PHP_VERSION >= "5.3.99"); 1883 define('ZEND_ENGINE_2_3', ZEND_ENGINE_2_4 || PHP_VERSION >= "5.3."); 1884 define('ZEND_ENGINE_2_2', ZEND_ENGINE_2_3 || PHP_VERSION >= "5.2."); 1885 define('ZEND_ENGINE_2_1', ZEND_ENGINE_2_2 || PHP_VERSION >= "5.1."); 1886 define('ZEND_ENGINE_2', ZEND_ENGINE_2_1 || PHP_VERSION >= "5.0."); 1887 1888 if (ZEND_ENGINE_2_4) { 1889 define('ZEND_FETCH_GLOBAL', 0x00000000); 1890 define('ZEND_FETCH_LOCAL', 0x10000000); 1891 define('ZEND_FETCH_STATIC', 0x20000000); 1892 define('ZEND_FETCH_STATIC_MEMBER', 0x30000000); 1893 define('ZEND_FETCH_GLOBAL_LOCK', 0x40000000); 1894 define('ZEND_FETCH_LEXICAL', 0x50000000); 1895 1896 define('ZEND_FETCH_TYPE_MASK', 0x70000000); 1897 } 1898 else { 1899 define('ZEND_FETCH_GLOBAL', 0); 1900 define('ZEND_FETCH_LOCAL', 1); 1901 define('ZEND_FETCH_STATIC', 2); 1902 define('ZEND_FETCH_STATIC_MEMBER', 3); 1903 define('ZEND_FETCH_GLOBAL_LOCK', 4); 1904 } 1869 1905 1870 1906 define('ZEND_FETCH_CLASS_DEFAULT', 0); … … 1876 1912 define('ZEND_FETCH_CLASS_INTERFACE', 6); 1877 1913 define('ZEND_FETCH_CLASS_STATIC', 7); 1914 if (ZEND_ENGINE_2_4) { 1915 define('ZEND_FETCH_CLASS_TRAIT', 14); 1916 } 1917 if (ZEND_ENGINE_2_3) { 1918 define('ZEND_FETCH_CLASS_MASK', 0xF); 1919 } 1878 1920 1879 1921 define('ZEND_EVAL', (1<<0)); … … 1885 1927 define('ZEND_ISSET', (1<<0)); 1886 1928 define('ZEND_ISEMPTY', (1<<1)); 1887 define('EXT_TYPE_UNUSED', (1<<0)); 1929 if (ZEND_ENGINE_2_4) { 1930 define('EXT_TYPE_UNUSED', (1<<5)); 1931 } 1932 else { 1933 define('EXT_TYPE_UNUSED', (1<<0)); 1934 } 1888 1935 1889 1936 define('ZEND_FETCH_STANDARD', 0); -
phpdop.phpr
r7081e28 rd441951 3 3 4 4 $srcdir = dirname(__FILE__); 5 require_once("$srcdir/Decompiler.class.php"); 5 6 if (file_exists("$srcdir/phpdc.debug.php")) { 6 7 include("$srcdir/phpdc.debug.php"); … … 11 12 switch ($op['op_type']) { 12 13 case 1: // CONST 13 return var_export($op[' u.constant'], true);14 return var_export($op['constant'], true); 14 15 15 16 case 2: // IS_TMP_VAR 16 return 't@' . $op[' u.var'];17 return 't@' . $op['var']; 17 18 18 19 case 4: 19 return 'v$' . $op[' u.var'];20 return 'v$' . $op['var']; 20 21 21 22 case 8: // UNUSED 22 if (isset($op[' u.opline_num'])) {23 return 'l#' . $op[' u.opline_num'];23 if (isset($op['opline_num'])) { 24 return 'l#' . $op['opline_num']; 24 25 } 25 26 else { … … 28 29 29 30 default: 30 return $op['op_type'] . $op[' u.var'];31 return $op['op_type'] . $op['var']; 31 32 } 32 33 } 33 34 34 function dump_opcodes($op _array, $indent = '')35 function dump_opcodes($opcodes, $indent = '') 35 36 { 37 global $decompiler; 38 36 39 $types = array('result' => 5, 'op1' => 20, 'op2' => 20); 37 foreach ($ op_arrayas $line => $op) {40 foreach ($decompiler->fixOpcode($opcodes) as $line => $op) { 38 41 echo $indent; 39 42 echo sprintf("%3d ", $op['lineno']); … … 91 94 die("Usage: $argv[0] <file>\n"); 92 95 } 96 $decompiler = new Decompiler(); 93 97 $pk = xcache_dasm_file($argv[1]); 94 98 $op_array = $funcs = $classes = null;
Note: See TracChangeset
for help on using the changeset viewer.