Changeset 766 for branches/1.3/Decompiler.class.php
- Timestamp:
- 04/18/2011 06:29:25 AM (2 years ago)
- Location:
- branches/1.3
- Files:
-
- 2 modified
-
. (modified) (1 prop)
-
Decompiler.class.php (modified) (87 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3
-
branches/1.3/Decompiler.class.php
r739 r766 11 11 function str($code, $indent = '') // {{{ 12 12 { 13 if (is_array($code)) { 14 $array = array(); 15 foreach ($code as $key => $value) { 16 $array[$key] = str($value, $indent); 17 } 18 return $array; 19 } 13 20 if (is_object($code)) { 14 if (get_class($code) != 'Decompiler_Code') { 15 $code = toCode($code, $indent); 16 } 17 return $code->__toString(); 21 $code = foldToCode($code, $indent); 22 return $code->toCode($indent); 18 23 } 19 24 … … 21 26 } 22 27 // }}} 23 function toCode($src, $indent = '') // {{{28 function foldToCode($src, $indent = '') // {{{ wrap or rewrap anything to Decompiler_Code 24 29 { 25 30 if (is_array($indent)) { … … 27 32 } 28 33 29 if (is_object($src)) { 30 if (!method_exists($src, 'toCode')) { 31 var_dump($src); 32 exit('no toCode'); 33 } 34 return new Decompiler_Code($src->toCode($indent)); 35 } 36 37 return new Decompiler_Code($src); 34 if (!is_object($src)) { 35 return new Decompiler_Code($src); 36 } 37 38 if (!method_exists($src, 'toCode')) { 39 var_dump($src); 40 exit('no toCode'); 41 } 42 if (get_class($src) != 'Decompiler_Code') { 43 // rewrap it 44 $src = new Decompiler_Code($src->toCode($indent)); 45 } 46 47 return $src; 38 48 } 39 49 // }}} … … 61 71 } 62 72 // }}} 73 function unquoteName_($str, $asVariableName, $indent = '') // {{{ 74 { 75 $str = str($str, $indent); 76 if (preg_match("!^'[\\w_][\\w\\d_\\\\]*'\$!", $str)) { 77 return str_replace('\\\\', '\\', substr($str, 1, -1)); 78 } 79 else if ($asVariableName) { 80 return "{" . $str . "}"; 81 } 82 else { 83 return $str; 84 } 85 } 86 // }}} 87 function unquoteVariableName($str, $indent = '') // {{{ 88 { 89 return unquoteName_($str, true, $indent); 90 } 91 // }}} 92 function unquoteName($str, $indent = '') // {{{ 93 { 94 return unquoteName_($str, false, $indent); 95 } 96 // }}} 63 97 class Decompiler_Object // {{{ 64 98 { … … 76 110 function toCode($indent) 77 111 { 78 return var_export($this->value, true); 112 $code = var_export($this->value, true); 113 if (gettype($this->value) == 'string') { 114 switch ($this->value) { 115 case "\r": 116 return '"\\r"'; 117 case "\n": 118 return '"\\n"'; 119 case "\r\n": 120 return '"\\r\\n"'; 121 } 122 $code = str_replace("\r\n", '\' . "\\r\\n" . \'', $code); 123 $code = str_replace("\r", '\' . "\\r" . \'', $code); 124 $code = str_replace("\n", '\' . "\\n" . \'', $code); 125 } 126 return $code; 79 127 } 80 128 } … … 86 134 function Decompiler_Code($src) 87 135 { 136 assert('isset($src)'); 88 137 $this->src = $src; 89 138 } 90 139 91 140 function toCode($indent) 92 {93 return $this;94 }95 96 function __toString()97 141 { 98 142 return $this->src; … … 118 162 function toCode($indent) 119 163 { 120 $op1 = toCode($this->op1, $indent); 164 $opstr = $this->parent->binops[$this->opc]; 165 166 $op1 = foldToCode($this->op1, $indent); 121 167 if (is_a($this->op1, 'Decompiler_Binop') && $this->op1->opc != $this->opc) { 122 $op1 = "($op1)"; 123 } 124 $opstr = $this->parent->binops[$this->opc]; 125 if ($op1 == '0' && $this->opc == XC_SUB) { 126 return $opstr . toCode($this->op2, $indent); 127 } 128 return $op1 . ' ' . $opstr . ' ' . toCode($this->op2, $indent); 168 $op1 = "(" . str($op1, $indent) . ")"; 169 } 170 $op2 = foldToCode($this->op2, $indent); 171 if (is_a($this->op2, 'Decompiler_Binop') && $this->op2->opc != $this->opc && substr($opstr, -1) != '=') { 172 $op2 = "(" . str($op2, $indent) . ")"; 173 } 174 175 if (str($op1) == '0' && ($this->opc == XC_ADD || $this->opc == XC_SUB)) { 176 return $opstr . str($op2, $indent); 177 } 178 179 return str($op1) . ' ' . $opstr . ' ' . str($op2); 129 180 } 130 181 } … … 148 199 return '$' . substr($this->src, 1, -1); 149 200 case ZEND_FETCH_STATIC: 201 if (ZEND_ENGINE_2_3) { 202 // closure local variable? 203 return str($this->src); 204 } 150 205 die('static fetch cant to string'); 151 206 case ZEND_FETCH_GLOBAL: … … 178 233 var $offsets = array(); 179 234 var $isLast = false; 235 var $isObject = false; 180 236 var $assign = null; 181 237 … … 183 239 { 184 240 if (is_a($this->value, 'Decompiler_ListBox')) { 185 $exp = toCode($this->value->obj->src, $indent);241 $exp = str($this->value->obj->src, $indent); 186 242 } 187 243 else { 188 $exp = toCode($this->value, $indent); 189 } 190 foreach ($this->offsets as $dim) { 191 $exp .= '[' . toCode($dim, $indent) . ']'; 244 $exp = str($this->value, $indent); 245 } 246 $last = count($this->offsets) - 1; 247 foreach ($this->offsets as $i => $dim) { 248 if ($this->isObject && $i == $last) { 249 $exp .= '->' . unquoteVariableName($dim, $indent); 250 } 251 else { 252 $exp .= '[' . str($dim, $indent) . ']'; 253 } 192 254 } 193 255 return $exp; … … 212 274 $dim->value = $this->src; 213 275 if (!isset($dim->assign)) { 214 return toCode($dim, $indent);215 } 216 return toCode($this->dims[0]->assign, $indent) . ' = ' . toCode($dim, $indent);276 return str($dim, $indent); 277 } 278 return str($this->dims[0]->assign, $indent) . ' = ' . str($dim, $indent); 217 279 } 218 280 /* flatten dims */ … … 223 285 $assign = &$assign[$offset]; 224 286 } 225 $assign = toCode($dim->assign, $indent);226 } 227 return $this->toList($assigns) . ' = ' . toCode($this->src, $indent);287 $assign = foldToCode($dim->assign, $indent); 288 } 289 return str($this->toList($assigns)) . ' = ' . str($this->src, $indent); 228 290 } 229 291 … … 370 432 class Decompiler 371 433 { 372 var $ rName = '!^[\\w_][\\w\\d_]*$!';373 var $ rQuotedName = "!^'[\\w_][\\w\\d_]*'\$!";434 var $namespace; 435 var $namespaceDecided; 374 436 375 437 function Decompiler() 376 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 // }}} 377 453 // {{{ opinfo 378 454 $this->unaryops = array( … … 421 497 // }}} 422 498 } 499 function detectNamespace($name) // {{{ 500 { 501 if ($this->namespaceDecided) { 502 return; 503 } 504 505 if (strpos($name, '\\') !== false) { 506 $this->namespace = strtok($name, '\\'); 507 echo 'namespace ', $this->namespace, ";\n\n"; 508 } 509 510 $this->namespaceDecided = true; 511 } 512 // }}} 513 function stripNamespace($name) // {{{ 514 { 515 $len = strlen($this->namespace) + 1; 516 if (substr($name, 0, $len) == $this->namespace . '\\') { 517 return substr($name, $len); 518 } 519 else { 520 return $name; 521 } 522 } 523 // }}} 423 524 function outputPhp(&$opcodes, $opline, $last, $indent) // {{{ 424 525 { … … 428 529 $op = $opcodes[$i]; 429 530 if (isset($op['php'])) { 430 $toticks = isset($op['ticks']) ? $op['ticks']: 0;531 $toticks = isset($op['ticks']) ? (int) str($op['ticks']) : 0; 431 532 if ($curticks != $toticks) { 432 if (!$toticks) { 433 echo $origindent, "}\n"; 533 $oldticks = $curticks; 534 $curticks = $toticks; 535 if (!$curticks) { 536 echo $origindent, "}\n\n"; 434 537 $indent = $origindent; 435 538 } 436 539 else { 437 if ($ curticks) {438 echo $origindent, "}\n ";439 } 440 else if (!$ curticks) {540 if ($oldticks) { 541 echo $origindent, "}\n\n"; 542 } 543 else if (!$oldticks) { 441 544 $indent .= INDENT; 442 545 } 443 echo $origindent, "declare(ticks=$curticks) {\n"; 444 } 445 $curticks = $toticks; 446 } 447 echo $indent, toCode($op['php'], $indent), ";\n"; 546 echo $origindent, "declare (ticks=$curticks) {\n"; 547 } 548 } 549 echo $indent, str($op['php'], $indent), ";\n"; 448 550 } 449 551 } … … 457 559 switch ($op['op_type']) { 458 560 case XC_IS_CONST: 459 return toCode(value($op['constant']), $EX);561 return foldToCode(value($op['constant']), $EX); 460 562 461 563 case XC_IS_VAR: … … 464 566 $ret = $T[$op['var']]; 465 567 if ($tostr) { 466 $ret = toCode($ret, $EX);568 $ret = foldToCode($ret, $EX); 467 569 } 468 570 if ($free) { … … 531 633 $last = count($opcodes) - 1; 532 634 if ($opcodes[$last]['opcode'] == XC_HANDLE_EXCEPTION) { 533 unset($opcodes[$last]); 635 $this->usedOps[XC_HANDLE_EXCEPTION] = true; 636 $opcodes[$last]['opcode'] = XC_NOP; 534 637 --$last; 535 638 } … … 537 640 $op1 = $opcodes[$last]['op1']; 538 641 if ($op1['op_type'] == XC_IS_CONST && array_key_exists('constant', $op1) && $op1['constant'] === $defaultReturnValue) { 539 unset($opcodes[$last]);642 $opcodes[$last]['opcode'] = XC_NOP; 540 643 --$last; 541 644 } … … 562 665 $op['line'] = $i; 563 666 switch ($op['opcode']) { 667 case XC_CONT: 668 case XC_BRK: 669 $op['jmpouts'] = array(); 670 break; 671 672 case XC_GOTO: 564 673 case XC_JMP: 565 674 $target = $op['op1']['var']; … … 580 689 case XC_JMPZ_EX: 581 690 case XC_JMPNZ_EX: 691 case XC_JMP_SET: 582 692 // case XC_FE_RESET: 583 693 case XC_FE_FETCH: … … 678 788 $body = ob_get_clean(); 679 789 680 $as = toCode($op['fe_as'], $EX);790 $as = foldToCode($op['fe_as'], $EX); 681 791 if (isset($op['fe_key'])) { 682 $as = toCode($op['fe_key'], $EX) . ' => ' . $as;683 } 684 echo "{$indent}foreach (" . toCode($op['fe_src'], $EX) . " as $as) {\n";792 $as = str($op['fe_key'], $EX) . ' => ' . str($as); 793 } 794 echo "{$indent}foreach (" . str($op['fe_src'], $EX) . " as $as) {\n"; 685 795 echo $body; 686 796 echo "{$indent}}"; … … 711 821 return; 712 822 } 713 if ( !empty($op['jmpouts']) && isset($op['isjmp'])) {823 if (isset($op['jmpouts']) && isset($op['isjmp'])) { 714 824 if (isset($op['cond'])) { 715 echo "{$indent}check ( $op[cond]) {\n";825 echo "{$indent}check (" . str($op["cond"]) . ") {\n"; 716 826 echo INDENT; 717 827 } 718 echo $indent; 719 echo xcache_get_opcode($op['opcode']), ' line', $op['jmpouts'][0]; 720 if (isset($op['jmpouts'][1])) { 721 echo ', line', $op['jmpouts'][1]; 722 } 723 echo ";"; 724 // echo ' // <- line', $op['line']; 725 echo "\n"; 828 switch ($op['opcode']) { 829 case XC_CONT: 830 case XC_BRK: 831 break; 832 833 case XC_GOTO: 834 echo $indent, 'goto', ' line', $op['jmpouts'][0], ';', "\n"; 835 break; 836 837 default: 838 echo $indent; 839 echo xcache_get_opcode($op['opcode']), ' line', $op['jmpouts'][0]; 840 if (isset($op['jmpouts'][1])) { 841 echo ', line', $op['jmpouts'][1]; 842 } 843 echo ";"; 844 // echo ' // <- line', $op['line']; 845 echo "\n"; 846 } 726 847 if (isset($op['cond'])) echo "$indent}\n"; 727 848 } … … 751 872 // $this->dumpop($op, $EX); 752 873 // any true comes here, so it's a "or" 753 $cond = implode(' and ', $op['cond_false']);874 $cond = implode(' and ', str($op['cond_false'])); 754 875 // var_dump($op['cond'] = $cond); 755 876 /* … … 765 886 } 766 887 // }}} 767 function unquoteName($str) // {{{768 {769 if (preg_match($this->rQuotedName, $str)) {770 $str = substr($str, 1, -1);771 }772 return $str;773 }774 // }}}775 888 function dasmBasicBlock(&$EX, $opline, $last) // {{{ 776 889 { … … 784 897 $opc = $op['opcode']; 785 898 if ($opc == XC_NOP) { 899 $this->usedOps[$opc] = true; 786 900 continue; 787 901 } … … 799 913 continue; 800 914 } 801 // $this->dumpop($op, $EX); //var_dump($op);915 // echo $i, ' '; $this->dumpop($op, $EX); //var_dump($op); 802 916 803 917 $resvar = null; … … 813 927 $call = array(&$this, $opname); 814 928 if (is_callable($call)) { 929 $this->usedOps[$opc] = true; 815 930 $this->{$opname}($op, $EX); 816 931 } 817 932 else if (isset($this->binops[$opc])) { // {{{ 933 $this->usedOps[$opc] = true; 818 934 $op1val = $this->getOpVal($op1, $EX, false); 819 935 $op2val = $this->getOpVal($op2, $EX, false); … … 823 939 } 824 940 else if (isset($this->unaryops[$opc])) { // {{{ 941 $this->usedOps[$opc] = true; 825 942 $op1val = $this->getOpVal($op1, $EX); 826 943 $myop = $this->unaryops[$opc]; 827 $rvalue = "$myop$op1val";944 $rvalue = $myop . str($op1val); 828 945 $resvar = $rvalue; 829 946 // }}} 830 947 } 831 948 else { 949 $covered = true; 832 950 switch ($opc) { 833 951 case XC_NEW: // {{{ … … 835 953 $EX['object'] = (int) $res['var']; 836 954 $EX['called_scope'] = null; 837 $EX['fbc'] = 'new ' . $this->unquoteName($this->getOpVal($op1, $EX));955 $EX['fbc'] = 'new ' . unquoteName($this->getOpVal($op1, $EX), $EX); 838 956 if (!ZEND_ENGINE_2) { 839 957 $resvar = '$new object$'; 840 958 } 959 break; 960 // }}} 961 case XC_THROW: // {{{ 962 $resvar = 'throw ' . str($this->getOpVal($op1, $EX)); 963 break; 964 // }}} 965 case XC_CLONE: // {{{ 966 $resvar = 'clone ' . str($this->getOpVal($op1, $EX)); 967 break; 968 // }}} 969 case XC_CATCH: // {{{ 970 $resvar = 'catch (' . str($this->getOpVal($op1, $EX)) . ' ' . str($this->getOpVal($op2, $EX)) . ')'; 971 break; 972 // }}} 973 case XC_INSTANCEOF: // {{{ 974 $resvar = str($this->getOpVal($op1, $EX)) . ' instanceof ' . str($this->getOpVal($op2, $EX)); 841 975 break; 842 976 // }}} … … 857 991 } 858 992 else { 859 $class = $ op2['constant'];860 if (is _object($class)) {861 $class = get_class($class);993 $class = $this->getOpVal($op2, $EX); 994 if (isset($op2['constant'])) { 995 $class = $this->stripNamespace(unquoteName($class)); 862 996 } 863 997 } … … 866 1000 // }}} 867 1001 case XC_FETCH_CONSTANT: // {{{ 1002 if ($op1['op_type'] == XC_IS_UNUSED) { 1003 $resvar = $this->stripNamespace($op2['constant']); 1004 break; 1005 } 1006 868 1007 if ($op1['op_type'] == XC_IS_CONST) { 869 $resvar = $op1['constant']; 870 } 871 else if ($op1['op_type'] == XC_IS_UNUSED) { 872 $resvar = $op2['constant']; 1008 $resvar = $this->stripNamespace($op1['constant']); 873 1009 } 874 1010 else { 875 $ class = $T[$op1['var']];876 assert($class[0] == 'class');877 $resvar = $class[1] . '::' . $op2['constant']; 878 }1011 $resvar = $this->getOpVal($op1, $EX); 1012 } 1013 1014 $resvar = str($resvar) . '::' . unquoteName($this->getOpVal($op2, $EX)); 879 1015 break; 880 1016 // }}} … … 897 1033 case ZEND_FETCH_STATIC_MEMBER: 898 1034 $class = $this->getOpVal($op2, $EX); 899 $rvalue = $class . '::$' . $this->unquoteName($rvalue);1035 $rvalue = str($class) . '::$' . unquoteName($rvalue, $EX); 900 1036 break; 901 1037 default: 902 $name = $this->unquoteName($rvalue);903 $globalname = xcache_is_autoglobal($name) ? "\$$name" : "\$GLOBALS[ $rvalue]";1038 $name = unquoteName($rvalue, $EX); 1039 $globalname = xcache_is_autoglobal($name) ? "\$$name" : "\$GLOBALS[" . str($rvalue) . "]"; 904 1040 $rvalue = new Decompiler_Fetch($rvalue, $fetchtype, $globalname); 905 1041 break; 906 1042 } 907 1043 if ($opc == XC_UNSET_VAR) { 908 $op['php'] = "unset(" . toCode($rvalue, $EX) . ")";1044 $op['php'] = "unset(" . str($rvalue, $EX) . ")"; 909 1045 $lastphpop = &$op; 910 1046 } … … 923 1059 case XC_FETCH_DIM_IS: 924 1060 case XC_ASSIGN_DIM: 1061 case XC_UNSET_DIM_OBJ: // PHP 4 only 925 1062 case XC_UNSET_DIM: 926 case XC_UNSET_ DIM_OBJ:1063 case XC_UNSET_OBJ: 927 1064 $src = $this->getOpVal($op1, $EX, false); 928 1065 if (is_a($src, "Decompiler_ForeachBox")) { … … 931 1068 break; 932 1069 } 933 else if (is_a($src, "Decompiler_DimBox")) { 1070 1071 if (is_a($src, "Decompiler_DimBox")) { 934 1072 $dimbox = $src; 935 1073 } 936 1074 else { 937 1075 if (!is_a($src, "Decompiler_ListBox")) { 938 $list = new Decompiler_List($this->getOpVal($op1, $EX, false)); 1076 $op1val = $this->getOpVal($op1, $EX, false); 1077 $list = new Decompiler_List(isset($op1val) ? $op1val : '$this'); 939 1078 940 1079 $src = new Decompiler_ListBox($list); … … 960 1099 $dim->isLast = true; 961 1100 } 1101 if ($opc == XC_UNSET_OBJ) { 1102 $dim->isObject = true; 1103 } 962 1104 unset($dim); 963 1105 $rvalue = $dimbox; 1106 unset($dimbox); 964 1107 965 1108 if ($opc == XC_ASSIGN_DIM) { … … 967 1110 ++ $i; 968 1111 $rvalue = $this->getOpVal($opcodes[$i]['op1'], $EX); 969 $resvar = toCode($lvalue, $EX) . ' = ' . $rvalue;970 } 971 else if ($opc == XC_UNSET_DIM ) {972 $op['php'] = "unset(" . toCode($rvalue, $EX) . ")";1112 $resvar = str($lvalue, $EX) . ' = ' . str($rvalue); 1113 } 1114 else if ($opc == XC_UNSET_DIM || $opc == XC_UNSET_OBJ) { 1115 $op['php'] = "unset(" . str($rvalue, $EX) . ")"; 973 1116 $lastphpop = &$op; 974 1117 } … … 991 1134 $dim->assign = $lvalue; 992 1135 if ($dim->isLast) { 993 $resvar = toCode($dim->value, $EX);1136 $resvar = foldToCode($dim->value, $EX); 994 1137 } 995 1138 unset($dim); 996 1139 break; 997 1140 } 998 $resvar = "$lvalue = " . toCode($rvalue, $EX);1141 $resvar = "$lvalue = " . str($rvalue, $EX); 999 1142 break; 1000 1143 // }}} … … 1003 1146 $rvalue = $this->getOpVal($op2, $EX, false); 1004 1147 if (is_a($rvalue, 'Decompiler_Fetch')) { 1005 $src = toCode($rvalue->src, $EX);1006 if ( substr($src, 1, -1) == substr($lvalue, 1)) {1148 $src = str($rvalue->src, $EX); 1149 if ('$' . unquoteName($src) == $lvalue) { 1007 1150 switch ($rvalue->fetchType) { 1008 1151 case ZEND_FETCH_GLOBAL: … … 1013 1156 $statics = &$EX['op_array']['static_variables']; 1014 1157 $resvar = 'static ' . $lvalue; 1015 $name = substr($src, 1, -1);1158 $name = unquoteName($src); 1016 1159 if (isset($statics[$name])) { 1017 1160 $var = $statics[$name]; 1018 1161 $resvar .= ' = '; 1019 $resvar .= toCode(value($var), $EX);1162 $resvar .= str(value($var), $EX); 1020 1163 } 1021 1164 unset($statics); … … 1026 1169 } 1027 1170 // TODO: PHP_6 global 1028 $rvalue = toCode($rvalue, $EX);1171 $rvalue = str($rvalue, $EX); 1029 1172 $resvar = "$lvalue = &$rvalue"; 1030 1173 break; … … 1042 1185 $obj = '$this'; 1043 1186 } 1044 $prop = $this->getOpVal($op2, $EX); 1045 if (preg_match($this->rQuotedName, $prop)) { 1046 $prop = substr($prop, 1, -1);; 1047 $rvalue = "{$obj}->$prop"; 1048 } 1049 else { 1050 $rvalue = "{$obj}->{" . "$prop}"; 1051 } 1187 $rvalue = str($obj) . "->" . unquoteVariableName($this->getOpVal($op2, $EX), $EX); 1052 1188 if ($res['op_type'] != XC_IS_UNUSED) { 1053 1189 $resvar = $rvalue; … … 1057 1193 $lvalue = $rvalue; 1058 1194 $rvalue = $this->getOpVal($opcodes[$i]['op1'], $EX); 1059 $resvar = "$lvalue = $rvalue";1195 $resvar = "$lvalue = " . str($rvalue); 1060 1196 } 1061 1197 break; … … 1066 1202 case XC_ISSET_ISEMPTY_VAR: // {{{ 1067 1203 if ($opc == XC_ISSET_ISEMPTY_VAR) { 1068 $rvalue = $this->getOpVal($op1, $EX);; 1069 if (preg_match($this->rQuotedName, $rvalue)) { 1070 $rvalue = '$' . substr($rvalue, 1, -1); 1071 } 1072 else { 1073 $rvalue = '${' . $rvalue . '}'; 1074 } 1204 $rvalue = $this->getOpVal($op1, $EX); 1075 1205 if ($op2['EA.type'] == ZEND_FETCH_STATIC_MEMBER) { 1076 1206 $class = $this->getOpVal($op2, $EX); … … 1085 1215 $dim = $this->getOpVal($op2, $EX); 1086 1216 if ($opc == XC_ISSET_ISEMPTY_PROP_OBJ) { 1087 if ( preg_match($this->rQuotedName, $dim)) {1088 $ rvalue = $container . "->" . substr($dim, 1, -1);1217 if (!isset($container)) { 1218 $container = '$this'; 1089 1219 } 1090 else { 1091 $rvalue = $container . "->{" . $dim . "}"; 1092 } 1220 $rvalue = $container . "->" . unquoteVariableName($dim); 1093 1221 } 1094 1222 else { 1095 $rvalue = $container . "[$dim]";1223 $rvalue = $container . '[' . str($dim) .']'; 1096 1224 } 1097 1225 } … … 1113 1241 case XC_SEND_VAR: // {{{ 1114 1242 $ref = ($opc == XC_SEND_REF ? '&' : ''); 1115 $EX['argstack'][] = $ref . $this->getOpVal($op1, $EX);1243 $EX['argstack'][] = $ref . str($this->getOpVal($op1, $EX)); 1116 1244 break; 1117 1245 // }}} 1118 1246 case XC_INIT_STATIC_METHOD_CALL: 1119 case XC_INIT_METHOD_CALL: 1120 case XC_INIT_FCALL_BY_FUNC: 1121 case XC_INIT_FCALL_BY_NAME: // {{{ 1122 if (($ext & ZEND_CTOR_CALL)) { 1123 break; 1124 } 1247 case XC_INIT_METHOD_CALL: // {{{ 1125 1248 array_push($EX['arg_types_stack'], array($EX['fbc'], $EX['object'], $EX['called_scope'])); 1126 1249 if ($opc == XC_INIT_STATIC_METHOD_CALL || $opc == XC_INIT_METHOD_CALL || $op1['op_type'] != XC_IS_UNUSED) { … … 1131 1254 if ($opc == XC_INIT_STATIC_METHOD_CALL || /* PHP4 */ isset($op1['constant'])) { 1132 1255 $EX['object'] = null; 1133 $EX['called_scope'] = $this-> unquoteName($obj);1256 $EX['called_scope'] = $this->stripNamespace(unquoteName($obj, $EX)); 1134 1257 } 1135 1258 else { … … 1146 1269 } 1147 1270 1148 if ($opc == XC_INIT_FCALL_BY_FUNC) { 1149 $which = $op1['var']; 1150 $EX['fbc'] = $EX['op_array']['funcs'][$which]['name']; 1151 } 1152 else { 1153 $EX['fbc'] = $this->getOpVal($op2, $EX, false); 1154 } 1271 $EX['fbc'] = $this->getOpVal($op2, $EX, false); 1272 if (($opc == XC_INIT_STATIC_METHOD_CALL || $opc == XC_INIT_METHOD_CALL) && !isset($EX['fbc'])) { 1273 $EX['fbc'] = '__construct'; 1274 } 1275 break; 1276 // }}} 1277 case XC_INIT_NS_FCALL_BY_NAME: 1278 case XC_INIT_FCALL_BY_NAME: // {{{ 1279 array_push($EX['arg_types_stack'], array($EX['fbc'], $EX['object'], $EX['called_scope'])); 1280 if (!ZEND_ENGINE_2 && ($ext & ZEND_CTOR_CALL)) { 1281 break; 1282 } 1283 $EX['object'] = null; 1284 $EX['called_scope'] = null; 1285 $EX['fbc'] = $this->getOpVal($op2, $EX); 1286 break; 1287 // }}} 1288 case XC_INIT_FCALL_BY_FUNC: // {{{ deprecated even in PHP 4? 1289 $EX['object'] = null; 1290 $EX['called_scope'] = null; 1291 $which = $op1['var']; 1292 $EX['fbc'] = $EX['op_array']['funcs'][$which]['name']; 1155 1293 break; 1156 1294 // }}} … … 1162 1300 break; 1163 1301 case XC_DO_FCALL: 1164 $fname = $this->unquoteName($this->getOpVal($op1, $EX, false));1302 $fname = unquoteName($this->getOpVal($op1, $EX, false), $EX); 1165 1303 $args = $this->popargs($EX, $ext); 1166 1304 $resvar = $fname . "($args)"; … … 1169 1307 $object = null; 1170 1308 1171 $fname = $this->unquoteName($EX['fbc']);1309 $fname = unquoteName($EX['fbc'], $EX); 1172 1310 if (!is_int($EX['object'])) { 1173 1311 $object = $EX['object']; … … 1176 1314 $args = $this->popargs($EX, $ext); 1177 1315 1178 $resvar = 1179 (isset($object) ? $object . '->' : '' ) 1180 . (isset($EX['called_scope']) ? $EX['called_scope'] . '::' : '' ) 1181 . $fname . "($args)"; 1316 $prefix = (isset($object) ? $object . '->' : '' ) 1317 . (isset($EX['called_scope']) ? $EX['called_scope'] . '::' : '' ); 1318 $resvar = $prefix 1319 . (!$prefix ? $this->stripNamespace($fname) : $fname) 1320 . "($args)"; 1182 1321 unset($args); 1183 1322 … … 1203 1342 } 1204 1343 $class = &$this->dc['class_table'][$key]; 1205 $class['name'] = $this->unquoteName($this->getOpVal($op2, $EX)); 1344 if (!isset($class['name'])) { 1345 $class['name'] = unquoteName($this->getOpVal($op2, $EX), $EX); 1346 } 1206 1347 if ($opc == XC_DECLARE_INHERITED_CLASS || $opc == XC_DECLARE_INHERITED_CLASS_DELAYED) { 1207 1348 $ext /= XC_SIZEOF_TEMP_VARIABLE; … … 1213 1354 } 1214 1355 1215 while ($i + 2 < $ic 1216 && $opcodes[$i + 2]['opcode'] == XC_ADD_INTERFACE 1217 && $opcodes[$i + 2]['op1']['var'] == $res['var'] 1218 && $opcodes[$i + 1]['opcode'] == XC_FETCH_CLASS) { 1356 for (;;) { 1357 if ($i + 1 < $ic 1358 && $opcodes[$i + 1]['opcode'] == XC_ADD_INTERFACE 1359 && $opcodes[$i + 1]['op1']['var'] == $res['var']) { 1360 // continue 1361 } 1362 else if ($i + 2 < $ic 1363 && $opcodes[$i + 2]['opcode'] == XC_ADD_INTERFACE 1364 && $opcodes[$i + 2]['op1']['var'] == $res['var'] 1365 && $opcodes[$i + 1]['opcode'] == XC_FETCH_CLASS) { 1366 // continue 1367 } 1368 else { 1369 break; 1370 } 1371 $this->usedOps[XC_ADD_INTERFACE] = true; 1372 1219 1373 $fetchop = &$opcodes[$i + 1]; 1220 $i mpl = $this->unquoteName($this->getOpVal($fetchop['op2'], $EX));1374 $interface = $this->stripNamespace(unquoteName($this->getOpVal($fetchop['op2'], $EX), $EX)); 1221 1375 $addop = &$opcodes[$i + 2]; 1222 $class['interfaces'][$addop['extended_value']] = $i mpl;1376 $class['interfaces'][$addop['extended_value']] = $interface; 1223 1377 unset($fetchop, $addop); 1224 1378 $i += 2; 1225 1379 } 1226 1380 $this->dclass($class); 1381 echo "\n"; 1227 1382 unset($class); 1228 1383 break; … … 1239 1394 switch ($opc) { 1240 1395 case XC_ADD_CHAR: 1241 $op2val = toCode(chr($op2val), $EX);1396 $op2val = value(chr(str($op2val))); 1242 1397 break; 1243 1398 case XC_ADD_STRING: 1244 $op2val = toCode($op2val, $EX);1245 1399 break; 1246 1400 case XC_ADD_VAR: 1247 1401 break; 1248 1402 } 1249 if ( $op1val== "''") {1403 if (str($op1val) == "''") { 1250 1404 $rvalue = $op2val; 1251 1405 } 1252 else if ( $op2val== "''") {1406 else if (str($op2val) == "''") { 1253 1407 $rvalue = $op1val; 1254 1408 } 1255 1409 else { 1256 $rvalue = $op1val . ' . ' . $op2val;1410 $rvalue = str($op1val) . ' . ' . str($op2val); 1257 1411 } 1258 1412 $resvar = $rvalue; … … 1261 1415 case XC_PRINT: // {{{ 1262 1416 $op1val = $this->getOpVal($op1, $EX); 1263 $resvar = "print( $op1val)";1417 $resvar = "print(" . str($op1val) . ")"; 1264 1418 break; 1265 1419 // }}} 1266 1420 case XC_ECHO: // {{{ 1267 1421 $op1val = $this->getOpVal($op1, $EX); 1268 $resvar = "echo $op1val";1422 $resvar = "echo " . str($op1val); 1269 1423 break; 1270 1424 // }}} … … 1314 1468 // }}} 1315 1469 case XC_RETURN: // {{{ 1316 $resvar = "return " . $this->getOpVal($op1, $EX);1470 $resvar = "return " . str($this->getOpVal($op1, $EX)); 1317 1471 break; 1318 1472 // }}} … … 1320 1474 $type = $op2['var']; // hack 1321 1475 $keyword = $this->includeTypes[$type]; 1322 $resvar = "$keyword (" . $this->getOpVal($op1, $EX) . ")";1476 $resvar = "$keyword " . str($this->getOpVal($op1, $EX)); 1323 1477 break; 1324 1478 // }}} … … 1357 1511 // }}} 1358 1512 case XC_JMP_NO_CTOR: 1513 break; 1514 case XC_JMP_SET: // ?: 1515 $resvar = $this->getOpVal($op1, $EX); 1516 $op['cond'] = $resvar; 1517 $op['isjmp'] = true; 1359 1518 break; 1360 1519 case XC_JMPNZ: // while … … 1379 1538 var_dump($op);// exit; 1380 1539 } 1381 if ($opc == XC_JMPZ_EX || $opc == XC_JMPNZ_EX || $opc == XC_JMPZ) {1540 if ($opc == XC_JMPZ_EX || $opc == XC_JMPNZ_EX) { 1382 1541 $targetop = &$EX['opcodes'][$op2['opline_num']]; 1383 1542 if ($opc == XC_JMPNZ_EX) { 1384 $targetop['cond_true'][] = toCode($rvalue, $EX);1543 $targetop['cond_true'][] = foldToCode($rvalue, $EX); 1385 1544 } 1386 1545 else { 1387 $targetop['cond_false'][] = toCode($rvalue, $EX);1546 $targetop['cond_false'][] = foldToCode($rvalue, $EX); 1388 1547 } 1389 1548 unset($targetop); … … 1395 1554 break; 1396 1555 // }}} 1556 case XC_CONT: 1557 case XC_BRK: 1558 $op['cond'] = null; 1559 $op['isjmp'] = true; 1560 $resvar = $opc == XC_CONT ? 'continue' : 'break'; 1561 $count = str($this->getOpVal($op2, $EX)); 1562 if ($count != '1') { 1563 $resvar .= ' ' . $count; 1564 } 1565 break; 1566 case XC_GOTO: 1397 1567 case XC_JMP: // {{{ 1398 1568 $op['cond'] = null; … … 1401 1571 // }}} 1402 1572 case XC_CASE: 1403 case XC_BRK: 1573 $switchValue = $this->getOpVal($op1, $EX); 1574 $caseValue = $this->getOpVal($op2, $EX); 1575 $resvar = str($switchValue) . ' == ' . str($caseValue); 1404 1576 break; 1405 1577 case XC_RECV_INIT: … … 1425 1597 $flags = array_flip(explode('_', $opname)); 1426 1598 if (isset($flags['OBJ'])) { 1427 $resvar = $this->getOpVal($op1, $EX); 1428 $prop = $this->unquoteName($this->getOpVal($op2, $EX)); 1429 if ($prop{0} == '$') { 1430 $resvar = $resvar . "{" . $prop . "}"; 1431 } 1432 else { 1433 $resvar = $resvar . "->" . $prop; 1434 } 1599 $resvar = $this->getOpVal($op1, $EX) . '->' . unquoteVariableName($this->getOpVal($op2, $EX), $EX); 1435 1600 } 1436 1601 else { … … 1439 1604 $opstr = isset($flags['DEC']) ? '--' : '++'; 1440 1605 if (isset($flags['POST'])) { 1441 $resvar .= ' ' .$opstr;1606 $resvar .= $opstr; 1442 1607 } 1443 1608 else { 1444 $resvar = "$opstr $resvar";1609 $resvar = "$opstr$resvar"; 1445 1610 } 1446 1611 break; … … 1453 1618 case XC_END_SILENCE: // {{{ 1454 1619 $EX['silence'] --; 1455 $lastresvar = '@' . toCode($lastresvar, $EX); 1456 break; 1457 // }}} 1458 case XC_CONT: // {{{ 1620 $lastresvar = '@' . str($lastresvar, $EX); 1459 1621 break; 1460 1622 // }}} … … 1480 1642 case XC_EXT_NOP: 1481 1643 break; 1644 case XC_DECLARE_FUNCTION: 1645 $this->dfunction($this->dc['function_table'][$op1['constant']], $EX['indent']); 1646 break; 1647 case XC_DECLARE_LAMBDA_FUNCTION: // {{{ 1648 ob_start(); 1649 $this->dfunction($this->dc['function_table'][$op1['constant']], $EX['indent']); 1650 $resvar = ob_get_clean(); 1651 $istmpres = true; 1652 break; 1653 // }}} 1654 case XC_DECLARE_CONST: 1655 $name = $this->stripNamespace(unquoteName($this->getOpVal($op1, $EX), $EX)); 1656 $value = str($this->getOpVal($op2, $EX)); 1657 $resvar = 'const ' . $name . ' = ' . $value; 1658 break; 1482 1659 case XC_DECLARE_FUNCTION_OR_CLASS: 1483 1660 /* always removed by compiler */ … … 1487 1664 // $EX['tickschanged'] = true; 1488 1665 break; 1666 case XC_RAISE_ABSTRACT_ERROR: 1667 // abstract function body is empty, don't need this code 1668 break; 1669 case XC_USER_OPCODE: 1670 echo '// ZEND_USER_OPCODE, impossible to decompile'; 1671 break; 1672 case XC_OP_DATA: 1673 break; 1489 1674 default: // {{{ 1490 1675 echo "\x1B[31m * TODO ", $opname, "\x1B[0m\n"; 1491 // }}} 1676 $covered = false; 1677 // }}} 1678 } 1679 if ($covered) { 1680 $this->usedOps[$opc] = true; 1492 1681 } 1493 1682 } … … 1523 1712 $a = array_pop($EX['argstack']); 1524 1713 if (is_array($a)) { 1525 array_unshift($args, toCode($a, $EX));1714 array_unshift($args, foldToCode($a, $EX)); 1526 1715 } 1527 1716 else { … … 1536 1725 $op1 = $op['op1']; 1537 1726 $op2 = $op['op2']; 1538 $d = array( 'opname' => xcache_get_opcode($op['opcode']), 'opcode' =>$op['opcode']);1539 1540 foreach (array('op1' => ' op1', 'op2' => 'op2', 'result' => 'res') as $k => $kk) {1727 $d = array(xcache_get_opcode($op['opcode']), $op['opcode']); 1728 1729 foreach (array('op1' => '1:', 'op2' => '2:', 'result' => '>') as $k => $kk) { 1541 1730 switch ($op[$k]['op_type']) { 1542 1731 case XC_IS_UNUSED: 1543 $d[$kk] = ' *UNUSED*' . $op[$k]['opline_num'];1732 $d[$kk] = 'U:' . $op[$k]['opline_num']; 1544 1733 break; 1545 1734 1546 1735 case XC_IS_VAR: 1547 1736 $d[$kk] = '$' . $op[$k]['var']; 1548 if ($k k != 'res') {1549 $d[$kk] .= ':' . $this->getOpVal($op[$k], $EX);1737 if ($k != 'result') { 1738 $d[$kk] .= ':' . str($this->getOpVal($op[$k], $EX)); 1550 1739 } 1551 1740 break; … … 1553 1742 case XC_IS_TMP_VAR: 1554 1743 $d[$kk] = '#' . $op[$k]['var']; 1555 if ($k k != 'res') {1556 $d[$kk] .= ':' . $this->getOpVal($op[$k], $EX);1744 if ($k != 'result') { 1745 $d[$kk] .= ':' . str($this->getOpVal($op[$k], $EX)); 1557 1746 } 1558 1747 break; … … 1563 1752 1564 1753 default: 1565 if ($k k == 'res') {1754 if ($k == 'result') { 1566 1755 var_dump($op); 1567 1756 exit; … … 1573 1762 } 1574 1763 } 1575 $d['ext'] = $op['extended_value']; 1576 1577 var_dump($d); 1764 $d[';'] = $op['extended_value']; 1765 1766 foreach ($d as $k => $v) { 1767 echo is_int($k) ? '' : $k, str($v), "\t"; 1768 } 1769 echo PHP_EOL; 1578 1770 } 1579 1771 // }}} … … 1602 1794 $ai = $op_array['arg_info'][$i]; 1603 1795 if (!empty($ai['class_name'])) { 1604 echo $ ai['class_name'], ' ';1796 echo $this->stripNamespace($ai['class_name']), ' '; 1605 1797 if (!ZEND_ENGINE_2_2 && $ai['allow_null']) { 1606 1798 echo 'or NULL '; … … 1638 1830 } 1639 1831 } 1640 echo toCode($arg[0], $indent);1832 echo str($arg[0], $indent); 1641 1833 } 1642 1834 if (isset($arg[1])) { 1643 echo ' = ', toCode($arg[1], $indent);1835 echo ' = ', str($arg[1], $indent); 1644 1836 } 1645 1837 } … … 1648 1840 function dfunction($func, $indent = '', $nobody = false) // {{{ 1649 1841 { 1842 $this->detectNamespace($func['op_array']['function_name']); 1843 1650 1844 if ($nobody) { 1651 $body = ";\n";1652 1845 $EX = array(); 1653 1846 $EX['op_array'] = &$func['op_array']; … … 1664 1857 } 1665 1858 1666 echo 'function ', $func['op_array']['function_name'], '('; 1859 $functionName = $this->stripNamespace($func['op_array']['function_name']); 1860 if ($functionName == '{closure}') { 1861 $functionName = ''; 1862 } 1863 echo 'function ', $functionName, '('; 1667 1864 $this->dargs($EX, $indent); 1668 echo ")\n"; 1669 echo $indent, "{\n"; 1670 echo $body; 1671 echo "$indent}\n"; 1865 echo ")"; 1866 if ($nobody) { 1867 echo ";\n"; 1868 } 1869 else { 1870 if ($functionName !== '') { 1871 echo "\n"; 1872 echo $indent, "{\n"; 1873 } 1874 else { 1875 echo " {\n"; 1876 } 1877 1878 echo $body; 1879 echo "$indent}"; 1880 if ($functionName !== '') { 1881 echo "\n"; 1882 } 1883 } 1672 1884 } 1673 1885 // }}} 1674 1886 function dclass($class, $indent = '') // {{{ 1675 1887 { 1888 $this->detectNamespace($class['name']); 1889 1676 1890 // {{{ class decl 1677 1891 if (!empty($class['doc_comment'])) { … … 1683 1897 if (!empty($class['ce_flags'])) { 1684 1898 if ($class['ce_flags'] & ZEND_ACC_INTERFACE) { 1685 echo 'interface ';1686 1899 $isinterface = true; 1687 1900 } 1688 1901 else { 1689 if ($class['ce_flags'] & ZEND_ACC_IMPLICIT_ABSTRACT ) {1902 if ($class['ce_flags'] & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) { 1690 1903 echo "abstract "; 1691 1904 } 1692 if ($class['ce_flags'] & ZEND_ACC_FINAL ) {1905 if ($class['ce_flags'] & ZEND_ACC_FINAL_CLASS) { 1693 1906 echo "final "; 1694 1907 } 1695 1908 } 1696 1909 } 1697 echo 'class ', $class['name'];1910 echo $isinterface ? 'interface ' : 'class ', $this->stripNamespace($class['name']); 1698 1911 if ($class['parent']) { 1699 1912 echo ' extends ', $class['parent']; … … 1717 1930 echo $newindent; 1718 1931 echo $prefix, $name, ' = '; 1719 echo toCode(value($v), $newindent);1932 echo str(value($v), $newindent); 1720 1933 echo ";\n"; 1721 1934 } … … 1791 2004 if (isset($value)) { 1792 2005 echo ' = '; 1793 echo toCode(value($value), $newindent);2006 echo str(value($value), $newindent); 1794 2007 } 1795 2008 echo ";\n"; … … 1810 2023 } 1811 2024 echo $newindent; 2025 $isAbstractMethod = false; 1812 2026 if (isset($opa['fn_flags'])) { 1813 if ( $opa['fn_flags'] & ZEND_ACC_ABSTRACT) {2027 if (($opa['fn_flags'] & ZEND_ACC_ABSTRACT) && !$isinterface) { 1814 2028 echo "abstract "; 2029 $isAbstractMethod = true; 1815 2030 } 1816 2031 if ($opa['fn_flags'] & ZEND_ACC_FINAL) { … … 1836 2051 } 1837 2052 } 1838 $this->dfunction($func, $newindent, $isinterface );2053 $this->dfunction($func, $newindent, $isinterface || $isAbstractMethod); 1839 2054 if ($opa['function_name'] == 'Decompiler') { 1840 2055 //exit; … … 1867 2082 function output() // {{{ 1868 2083 { 1869 echo "<?". "php\n ";2084 echo "<?". "php\n\n"; 1870 2085 foreach ($this->dc['class_table'] as $key => $class) { 1871 2086 if ($key{0} != "\0") { 2087 $this->dclass($class); 1872 2088 echo "\n"; 1873 $this->dclass($class);1874 2089 } 1875 2090 } … … 1877 2092 foreach ($this->dc['function_table'] as $key => $func) { 1878 2093 if ($key{0} != "\0") { 2094 $this->dfunction($func); 1879 2095 echo "\n"; 1880 $this->dfunction($func); 1881 } 1882 } 1883 1884 echo "\n"; 2096 } 2097 } 2098 1885 2099 $this->dop_array($this->dc['op_array']); 1886 2100 echo "\n?" . ">\n"; 2101 2102 if (!empty($this->test)) { 2103 $this->outputUnusedOp(); 2104 } 1887 2105 return true; 1888 2106 } 1889 2107 // }}} 2108 function outputUnusedOp() // {{{ 2109 { 2110 for ($i = 0; $opname = xcache_get_opcode($i); $i ++) { 2111 if ($opname == 'UNDEF') { 2112 continue; 2113 } 2114 2115 if (!isset($this->usedOps[$i])) { 2116 echo "not covered opcode ", $opname, "\n"; 2117 } 2118 } 2119 } 2120 // }}} 1890 2121 } 1891 2122 1892 2123 // {{{ defines 1893 define('ZEND_ACC_STATIC', 0x01);1894 define('ZEND_ACC_ABSTRACT', 0x02);1895 define('ZEND_ACC_FINAL', 0x04);1896 define('ZEND_ACC_IMPLEMENTED_ABSTRACT', 0x08);1897 1898 define('ZEND_ACC_IMPLICIT_ABSTRACT_CLASS', 0x10);1899 define('ZEND_ACC_EXPLICIT_ABSTRACT_CLASS', 0x20);1900 define('ZEND_ACC_FINAL_CLASS', 0x40);1901 define('ZEND_ACC_INTERFACE', 0x80);1902 define('ZEND_ACC_PUBLIC', 0x100);1903 define('ZEND_ACC_PROTECTED', 0x200);1904 define('ZEND_ACC_PRIVATE', 0x400);1905 define('ZEND_ACC_PPP_MASK', (ZEND_ACC_PUBLIC | ZEND_ACC_PROTECTED | ZEND_ACC_PRIVATE));1906 1907 define('ZEND_ACC_CHANGED', 0x800);1908 define('ZEND_ACC_IMPLICIT_PUBLIC', 0x1000);1909 1910 define('ZEND_ACC_CTOR', 0x2000);1911 define('ZEND_ACC_DTOR', 0x4000);1912 define('ZEND_ACC_CLONE', 0x8000);1913 1914 define('ZEND_ACC_ALLOW_STATIC', 0x10000);1915 1916 define('ZEND_ACC_SHADOW', 0x2000);1917 1918 2124 define('ZEND_ENGINE_2_4', PHP_VERSION >= "5.3.99"); 1919 2125 define('ZEND_ENGINE_2_3', ZEND_ENGINE_2_4 || PHP_VERSION >= "5.3."); … … 1921 2127 define('ZEND_ENGINE_2_1', ZEND_ENGINE_2_2 || PHP_VERSION >= "5.1."); 1922 2128 define('ZEND_ENGINE_2', ZEND_ENGINE_2_1 || PHP_VERSION >= "5.0."); 2129 2130 define('ZEND_ACC_STATIC', 0x01); 2131 define('ZEND_ACC_ABSTRACT', 0x02); 2132 define('ZEND_ACC_FINAL', 0x04); 2133 define('ZEND_ACC_IMPLEMENTED_ABSTRACT', 0x08); 2134 2135 define('ZEND_ACC_IMPLICIT_ABSTRACT_CLASS', 0x10); 2136 define('ZEND_ACC_EXPLICIT_ABSTRACT_CLASS', 0x20); 2137 define('ZEND_ACC_FINAL_CLASS', 0x40); 2138 define('ZEND_ACC_INTERFACE', 0x80); 2139 if (ZEND_ENGINE_2_4) { 2140 define('ZEND_ACC_TRAIT', 0x120); 2141 } 2142 define('ZEND_ACC_PUBLIC', 0x100); 2143 define('ZEND_ACC_PROTECTED', 0x200); 2144 define('ZEND_ACC_PRIVATE', 0x400); 2145 define('ZEND_ACC_PPP_MASK', (ZEND_ACC_PUBLIC | ZEND_ACC_PROTECTED | ZEND_ACC_PRIVATE)); 2146 2147 define('ZEND_ACC_CHANGED', 0x800); 2148 define('ZEND_ACC_IMPLICIT_PUBLIC', 0x1000); 2149 2150 define('ZEND_ACC_CTOR', 0x2000); 2151 define('ZEND_ACC_DTOR', 0x4000); 2152 define('ZEND_ACC_CLONE', 0x8000); 2153 2154 define('ZEND_ACC_ALLOW_STATIC', 0x10000); 2155 2156 define('ZEND_ACC_SHADOW', 0x2000); 1923 2157 1924 2158 if (ZEND_ENGINE_2_4) { … … 1990 2224 define('IS_LONG', 1); 1991 2225 define('IS_DOUBLE', 2); 1992 define('IS_ STRING', 3);2226 define('IS_BOOL', ZEND_ENGINE_2 ? 3 : 6); 1993 2227 define('IS_ARRAY', 4); 1994 2228 define('IS_OBJECT', 5); 1995 define('IS_ BOOL', 6);2229 define('IS_STRING', ZEND_ENGINE_2 ? 6 : 3); 1996 2230 define('IS_RESOURCE', 7); 1997 2231 define('IS_CONSTANT', 8); … … 2019 2253 'XC_ASSIGN_DIM' => -1, 2020 2254 'XC_UNSET_DIM' => -1, 2021 'XC_ FETCH_OBJ_' => -1,2255 'XC_UNSET_OBJ' => -1, 2022 2256 'XC_ASSIGN_OBJ' => -1, 2023 2257 'XC_ISSET_ISEMPTY_DIM_OBJ' => -1, … … 2040 2274 'XC_FETCH_DIM_' => -1, 2041 2275 'XC_UNSET_DIM_OBJ' => -1, 2042 'XC_FETCH_OBJ_' => -1,2043 2276 'XC_ISSET_ISEMPTY' => -1, 2044 2277 'XC_INIT_FCALL_BY_FUNC' => -1, 2045 2278 'XC_DO_FCALL_BY_FUNC' => -1, 2046 2279 'XC_DECLARE_FUNCTION_OR_CLASS' => -1, 2280 'XC_INIT_NS_FCALL_BY_NAME' => -1, 2281 'XC_GOTO' => -1, 2282 'XC_CATCH' => -1, 2283 'XC_THROW' => -1, 2284 'XC_INSTANCEOF' => -1, 2285 'XC_DECLARE_FUNCTION' => -1, 2286 'XC_RAISE_ABSTRACT_ERROR' => -1, 2287 'XC_DECLARE_CONST' => -1, 2288 'XC_USER_OPCODE' => -1, 2289 'XC_JMP_SET' => -1, 2290 'XC_DECLARE_LAMBDA_FUNCTION' => -1, 2047 2291 ) as $k => $v) { 2048 2292 if (!defined($k)) { … … 2050 2294 } 2051 2295 } 2052 2053 /* XC_UNDEF XC_OP_DATA2054 $content = file_get_contents(__FILE__);2055 for ($i = 0; $opname = xcache_get_opcode($i); $i ++) {2056 if (!preg_match("/\\bXC_" . $opname . "\\b(?!')/", $content)) {2057 echo "not done ", $opname, "\n";2058 }2059 }2060 // */2061 2296 // }}} 2062 2297

