Changeset 761 for trunk/Decompiler.class.php
- Timestamp:
- 2011-04-17T13:03:00+02:00 (2 years ago)
- File:
-
- 1 edited
-
trunk/Decompiler.class.php (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Decompiler.class.php
r760 r761 71 71 } 72 72 // }}} 73 function unquoteName_($str, $as Property, $indent = '') // {{{73 function unquoteName_($str, $asVariableName, $indent = '') // {{{ 74 74 { 75 75 $str = str($str, $indent); … … 77 77 return str_replace('\\\\', '\\', substr($str, 1, -1)); 78 78 } 79 else if ($as Property) {79 else if ($asVariableName) { 80 80 return "{" . $str . "}"; 81 81 } … … 85 85 } 86 86 // }}} 87 function unquote Property($str, $indent = '') // {{{87 function unquoteVariableName($str, $indent = '') // {{{ 88 88 { 89 89 return unquoteName_($str, true, $indent); … … 247 247 foreach ($this->offsets as $i => $dim) { 248 248 if ($this->isObject && $i == $last) { 249 $exp .= '->' . unquote Property($dim, $indent);249 $exp .= '->' . unquoteVariableName($dim, $indent); 250 250 } 251 251 else { … … 437 437 function Decompiler() 438 438 { 439 // {{{ testing 440 // XC_UNDEF XC_OP_DATA 441 $this->test = !empty($_ENV['XCACHE_DECOMPILER_TEST']); 442 $this->usedOps = array(); 443 444 if ($this->test) { 445 $content = file_get_contents(__FILE__); 446 for ($i = 0; $opname = xcache_get_opcode($i); $i ++) { 447 if (!preg_match("/\\bXC_" . $opname . "\\b(?!')/", $content)) { 448 echo "not recognized opcode ", $opname, "\n"; 449 } 450 } 451 } 452 // }}} 439 453 // {{{ opinfo 440 454 $this->unaryops = array( … … 619 633 $last = count($opcodes) - 1; 620 634 if ($opcodes[$last]['opcode'] == XC_HANDLE_EXCEPTION) { 635 $this->usedOps[XC_HANDLE_EXCEPTION] = true; 621 636 unset($opcodes[$last]); 622 637 --$last; … … 882 897 $opc = $op['opcode']; 883 898 if ($opc == XC_NOP) { 899 $this->usedOps[$opc] = true; 884 900 continue; 885 901 } … … 911 927 $call = array(&$this, $opname); 912 928 if (is_callable($call)) { 929 $this->usedOps[$opc] = true; 913 930 $this->{$opname}($op, $EX); 914 931 } 915 932 else if (isset($this->binops[$opc])) { // {{{ 933 $this->usedOps[$opc] = true; 916 934 $op1val = $this->getOpVal($op1, $EX, false); 917 935 $op2val = $this->getOpVal($op2, $EX, false); … … 921 939 } 922 940 else if (isset($this->unaryops[$opc])) { // {{{ 941 $this->usedOps[$opc] = true; 923 942 $op1val = $this->getOpVal($op1, $EX); 924 943 $myop = $this->unaryops[$opc]; … … 928 947 } 929 948 else { 949 $covered = true; 930 950 switch ($opc) { 931 951 case XC_NEW: // {{{ … … 1165 1185 $obj = '$this'; 1166 1186 } 1167 $rvalue = str($obj) . "->" . unquote Property($this->getOpVal($op2, $EX), $EX);1187 $rvalue = str($obj) . "->" . unquoteVariableName($this->getOpVal($op2, $EX), $EX); 1168 1188 if ($res['op_type'] != XC_IS_UNUSED) { 1169 1189 $resvar = $rvalue; … … 1182 1202 case XC_ISSET_ISEMPTY_VAR: // {{{ 1183 1203 if ($opc == XC_ISSET_ISEMPTY_VAR) { 1184 $rvalue = $this->getOpVal($op1, $EX);; 1185 if (preg_match($this->rQuotedName, $rvalue)) { 1186 $rvalue = '$' . substr($rvalue, 1, -1); 1187 } 1188 else { 1189 $rvalue = '${' . $rvalue . '}'; 1190 } 1204 $rvalue = $this->getOpVal($op1, $EX); 1191 1205 if ($op2['EA.type'] == ZEND_FETCH_STATIC_MEMBER) { 1192 1206 $class = $this->getOpVal($op2, $EX); … … 1201 1215 $dim = $this->getOpVal($op2, $EX); 1202 1216 if ($opc == XC_ISSET_ISEMPTY_PROP_OBJ) { 1203 if ( preg_match($this->rQuotedName, $dim)) {1204 $ rvalue = $container . "->" . substr($dim, 1, -1);1217 if (!isset($container)) { 1218 $container = '$this'; 1205 1219 } 1206 else { 1207 $rvalue = $container . "->{" . $dim . "}"; 1208 } 1220 $rvalue = $container . "->" . unquoteVariableName($dim); 1209 1221 } 1210 1222 else { 1211 $rvalue = $container . "[$dim]";1223 $rvalue = $container . '[' . str($dim) .']'; 1212 1224 } 1213 1225 } … … 1357 1369 break; 1358 1370 } 1371 $this->usedOps[XC_ADD_INTERFACE] = true; 1359 1372 1360 1373 $fetchop = &$opcodes[$i + 1]; … … 1402 1415 case XC_PRINT: // {{{ 1403 1416 $op1val = $this->getOpVal($op1, $EX); 1404 $resvar = "print( $op1val)";1417 $resvar = "print(" . str($op1val) . ")"; 1405 1418 break; 1406 1419 // }}} … … 1584 1597 $flags = array_flip(explode('_', $opname)); 1585 1598 if (isset($flags['OBJ'])) { 1586 $resvar = $this->getOpVal($op1, $EX) . '->' . unquote Property($this->getOpVal($op2, $EX), $EX);1599 $resvar = $this->getOpVal($op1, $EX) . '->' . unquoteVariableName($this->getOpVal($op2, $EX), $EX); 1587 1600 } 1588 1601 else { … … 1661 1674 default: // {{{ 1662 1675 echo "\x1B[31m * TODO ", $opname, "\x1B[0m\n"; 1663 // }}} 1676 $covered = false; 1677 // }}} 1678 } 1679 if ($covered) { 1680 $this->usedOps[$opc] = true; 1664 1681 } 1665 1682 } … … 2079 2096 $this->dop_array($this->dc['op_array']); 2080 2097 echo "\n?" . ">\n"; 2098 2099 if (!empty($this->test)) { 2100 $this->outputUnusedOp(); 2101 } 2081 2102 return true; 2103 } 2104 // }}} 2105 function outputUnusedOp() // {{{ 2106 { 2107 for ($i = 0; $opname = xcache_get_opcode($i); $i ++) { 2108 if ($opname == 'UNDEF') { 2109 continue; 2110 } 2111 2112 if (!isset($this->usedOps[$i])) { 2113 echo "not covered opcode ", $opname, "\n"; 2114 } 2115 } 2082 2116 } 2083 2117 // }}} … … 2187 2221 define('IS_LONG', 1); 2188 2222 define('IS_DOUBLE', 2); 2189 define('IS_ STRING', 3);2223 define('IS_BOOL', ZEND_ENGINE_2 ? 3 : 6); 2190 2224 define('IS_ARRAY', 4); 2191 2225 define('IS_OBJECT', 5); 2192 define('IS_ BOOL', 6);2226 define('IS_STRING', ZEND_ENGINE_2 ? 6 : 3); 2193 2227 define('IS_RESOURCE', 7); 2194 2228 define('IS_CONSTANT', 8); … … 2257 2291 } 2258 2292 } 2259 2260 //* XC_UNDEF XC_OP_DATA2261 $content = file_get_contents(__FILE__);2262 for ($i = 0; $opname = xcache_get_opcode($i); $i ++) {2263 if (!preg_match("/\\bXC_" . $opname . "\\b(?!')/", $content)) {2264 echo "not done ", $opname, "\n";2265 }2266 }2267 // */2268 2293 // }}} 2269 2294
Note: See TracChangeset
for help on using the changeset viewer.

