Changeset b6c6620 in git
- Timestamp:
- 2013-07-13T04:24:58Z (6 years ago)
- Branches:
- 3.1, 3.2, master, trunk
- Children:
- 742ae69
- Parents:
- fea6008
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/Decompiler.class.php
rfea6008 rb6c6620 567 567 XC_ASSIGN_REF => "= &", 568 568 XC_JMP_SET => "?:", 569 XC_JMP_SET_VAR => "?:", 569 570 XC_JMPZ_EX => "&&", 570 571 XC_JMPNZ_EX => "||", … … 596 597 function stripNamespace($name) // {{{ 597 598 { 599 $name = str($name); 598 600 $len = strlen($this->namespace) + 1; 599 601 if (substr($name, 0, $len) == $this->namespace . '\\') { … … 664 666 case XC_IS_TMP_VAR: 665 667 $T = &$EX['Ts']; 668 if (!isset($T[$op['var']])) { 669 printBacktrace(); 670 } 666 671 $ret = $T[$op['var']]; 667 672 if ($free && empty($this->keepTs)) { … … 834 839 } 835 840 // }}} 836 // {{{ ?: excluding JMP_SET 841 // {{{ ?: excluding JMP_SET/JMP_SET_VAR 837 842 if ($firstOp['opcode'] == XC_JMPZ && !empty($firstOp['jmpouts']) 838 843 && $range[1] >= $range[0] + 3 839 && $opcodes[$firstOp['jmpouts'][0] - 2]['opcode'] == XC_QM_ASSIGN844 && ($opcodes[$firstOp['jmpouts'][0] - 2]['opcode'] == XC_QM_ASSIGN || $opcodes[$firstOp['jmpouts'][0] - 2]['opcode'] == XC_QM_ASSIGN_VAR) 840 845 && $opcodes[$firstOp['jmpouts'][0] - 1]['opcode'] == XC_JMP && $opcodes[$firstOp['jmpouts'][0] - 1]['jmpouts'][0] == $range[1] + 1 841 && $lastOp['opcode'] == XC_QM_ASSIGN846 && ($lastOp['opcode'] == XC_QM_ASSIGN || $lastOp['opcode'] == XC_QM_ASSIGN_VAR) 842 847 ) { 843 848 $trueRange = array($range[0] + 1, $firstOp['jmpouts'][0] - 2); … … 1014 1019 $catchOp = &$opcodes[$catchOpLine]; 1015 1020 echo $indent, 'catch (' 1016 , isset($catchOp['op1']['constant']) ? $catchOp['op1']['constant'] : str($this->getOpVal($catchOp['op1'], $EX))1021 , $this->stripNamespace(isset($catchOp['op1']['constant']) ? $catchOp['op1']['constant'] : str($this->getOpVal($catchOp['op1'], $EX))) 1017 1022 , ' ' 1018 , str($this->getOpVal($catchOp['op2'], $EX))1023 , isset($catchOp['op2']['constant']) ? '$' . $catchOp['op2']['constant'] : str($this->getOpVal($catchOp['op2'], $EX)) 1019 1024 , ") {", PHP_EOL; 1020 1025 unset($catchOp); … … 1315 1320 case XC_JMPNZ_EX: 1316 1321 // case XC_JMP_SET: 1322 // case XC_JMP_SET_VAR: 1317 1323 // case XC_FE_RESET: 1318 1324 case XC_FE_FETCH: … … 1475 1481 $EX['object'] = (int) $res['var']; 1476 1482 $EX['called_scope'] = null; 1477 $EX['fbc'] = 'new ' . unquoteName($this->getOpVal($op1, $EX), $EX);1483 $EX['fbc'] = 'new ' . $this->stripNamespace($this->getOpVal($op1, $EX)); 1478 1484 break; 1479 1485 // }}} … … 1490 1496 // }}} 1491 1497 case XC_INSTANCEOF: // {{{ 1492 $resvar = str($this->getOpVal($op1, $EX)) . ' instanceof ' . str($this->getOpVal($op2, $EX));1498 $resvar = str($this->getOpVal($op1, $EX)) . ' instanceof ' . $this->stripNamespace($this->getOpVal($op2, $EX)); 1493 1499 break; 1494 1500 // }}} … … 1537 1543 case XC_FETCH_UNSET: 1538 1544 case XC_FETCH_IS: 1539 case XC_UNSET_VAR:1540 $ rvalue = $this->getOpVal($op1, $EX);1541 $fetchtype = defined('ZEND_FETCH_TYPE_MASK') ? ($ext & ZEND_FETCH_TYPE_MASK) : $op2['EA.type'];1542 if ($fetchtype == ZEND_FETCH_STATIC_MEMBER) {1543 $rvalue = $this->stripNamespace($ op2['constant']) . '::$' . unquoteName($rvalue, $EX);1544 } 1545 else if ($opc != XC_UNSET_VAR){1546 $ name = unquoteName($rvalue, $EX);1545 $fetchType = defined('ZEND_FETCH_TYPE_MASK') ? ($ext & ZEND_FETCH_TYPE_MASK) : $op2['EA.type']; 1546 $name = isset($op1['constant']) ? $op1['constant'] : unquoteName($this->getOpVal($op1, $EX), $EX); 1547 if ($fetchType == ZEND_FETCH_STATIC_MEMBER) { 1548 $class = isset($op2['constant']) ? $op2['constant'] : $this->getOpVal($op2, $EX); 1549 $rvalue = $this->stripNamespace($class) . '::$' . $name; 1550 } 1551 else { 1552 $rvalue = $this->getOpVal($op1, $EX); 1547 1553 $globalname = xcache_is_autoglobal($name) ? "\$$name" : "\$GLOBALS[" . str($rvalue) . "]"; 1548 $rvalue = new Decompiler_Fetch($rvalue, $fetchtype, $globalname); 1549 } 1550 1551 if ($opc == XC_UNSET_VAR) { 1552 $op['php'] = "unset(" . str($rvalue, $EX) . ")"; 1553 $lastphpop = &$op; 1554 } 1555 else if ($res['op_type'] != XC_IS_UNUSED) { 1554 $rvalue = new Decompiler_Fetch($rvalue, $fetchType, $globalname); 1555 } 1556 1557 if ($res['op_type'] != XC_IS_UNUSED) { 1556 1558 $resvar = $rvalue; 1557 1559 } 1560 break; 1561 // }}} 1562 case XC_UNSET_VAR: // {{{ 1563 $fetchType = defined('ZEND_FETCH_TYPE_MASK') ? ($ext & ZEND_FETCH_TYPE_MASK) : $op2['EA.type']; 1564 if ($fetchType == ZEND_FETCH_STATIC_MEMBER) { 1565 $class = isset($op2['constant']) ? $op2['constant'] /* PHP5.3- */ : $this->getOpVal($op2, $EX); 1566 $rvalue = $this->stripNamespace($class) . '::$' . $op1['constant']; 1567 } 1568 else { 1569 $rvalue = $this->getOpVal($op1, $EX); 1570 } 1571 1572 $op['php'] = "unset(" . str($rvalue, $EX) . ")"; 1573 $lastphpop = &$op; 1558 1574 break; 1559 1575 // }}} … … 1738 1754 $fetchtype = defined('ZEND_FETCH_TYPE_MASK') ? ($ext & ZEND_FETCH_TYPE_MASK) : $op2['EA.type']; 1739 1755 if ($fetchtype == ZEND_FETCH_STATIC_MEMBER) { 1740 $rvalue = $this->stripNamespace($op2['constant']) . '::' . unquoteName($rvalue, $EX); 1756 $class = isset($op2['constant']) ? $op2['constant'] : $this->getOpVal($op2, $EX); 1757 $rvalue = $this->stripNamespace($class) . '::' . unquoteName($rvalue, $EX); 1741 1758 } 1742 1759 } … … 2049 2066 // }}} 2050 2067 case XC_JMP_NO_CTOR: 2051 break;2052 case XC_JMP_SET: // ?:2053 $resvar = new Decompiler_Binop($this, $this->getOpVal($op1, $EX), XC_JMP_SET, null);2054 2068 break; 2055 2069 case XC_JMPZ_EX: // and … … 2469 2483 echo $isInterface ? 'interface ' : 'class ', $this->stripNamespace($class['name']); 2470 2484 if ($class['parent']) { 2471 echo ' extends ', $ class['parent'];2485 echo ' extends ', $this->stripNamespace($class['parent']); 2472 2486 } 2473 2487 /* TODO */ … … 2857 2871 'XC_JMP_NO_CTOR' => -1, 2858 2872 'XC_JMP_SET' => -1, 2873 'XC_JMP_SET_VAR' => -1, 2859 2874 'XC_QM_ASSIGN_VAR' => -1, 2860 2875 'XC_UNSET_DIM_OBJ' => -1, -
mod_disassembler/sample.php
rfea6008 rb6c6620 37 37 echo CONST_VALUE; 38 38 echo ClassName::CONST_VALUE; 39 unset(ClassName::$classProp1); 39 empty(ClassName::$classProp); 40 isset(ClassName::$classProp); 41 unset(ClassName::$classProp); 42 ClassName::$classProp = 1; 43 echo ClassName::$classProp; 44 empty($obj->objProp); 45 isset($obj->objProp); 40 46 unset($obj->objProp); 47 $obj->objProp = 1; 48 echo $obj->objProp; 49 empty($this->thisProp); 50 isset($this->thisProp); 41 51 unset($this->thisProp); 52 $this->thisProp = 1; 53 echo $this->thisProp; 42 54 unset($array['index']->valueProp); 43 55 unset($obj->array['index']); 44 56 unset($this->array['index']); 45 isset($GLOBALS['a']); 46 empty($GLOBALS['a']); 47 unset($GLOBALS['a']); 48 isset(ClassName::$a); 49 empty(ClassName::$a); 50 unset(ClassName::$a); 51 echo $GLOBALS['a']; 52 $obj->objProp = 1; 53 $this->thisProp = 1; 54 $array['index']->valueProp = 1; 57 empty($_GET['get']); 58 isset($_GET['get']); 59 unset($_GET['get']); 60 $_GET['get'] = 1; 61 echo $_GET['get']; 62 isset($GLOBALS['global']); 63 empty($GLOBALS['global']); 64 unset($GLOBALS['global']); 65 $GLOBALS['global'] = 1; 66 echo $GLOBALS['global']; 67 empty($array['index']); 68 isset($array['index']); 69 unset($array['index']); 55 70 $array['index'] = 1; 56 $array[1] = 1; 71 echo $array['index']; 72 empty($array['index']->indexProp); 73 isset($array['index']->indexProp); 74 unset($array['index']->indexProp); 75 $array['index']->indexProp = 1; 76 echo $array['index']->indexProp; 77 empty($GLOBALS['var']->indexProp); 78 isset($GLOBALS['var']->indexProp); 79 unset($GLOBALS['var']->indexProp); 80 $GLOBALS['var']->indexProp = 1; 81 echo $GLOBALS['var']->indexProp; 57 82 } 58 83 … … 438 463 $a = ($b ?: $d) + $c; 439 464 $a = f1() ?: f2(); 465 $a = C::f1() ?: C::f2(); 440 466 $a = ($b ? $c : $d); 441 467 $a = ($b ? $c : $d) + $c; -
xcache/xc_opcode_spec.c
rc7492e6 rb6c6620 6 6 #define OPSPEC(ext, op1, op2, res) { OPSPEC_##ext, OPSPEC_##op1, OPSPEC_##op2, OPSPEC_##res }, 7 7 #define OPSPEC_VAR_2 OPSPEC_STD 8 #ifdef ZEND_ENGINE_2_4 9 #undef OPSPEC_FETCH 10 #define OPSPEC_FETCH OPSPEC_STD 11 #endif 8 12 #include "xc_opcode_spec_def.h" 9 13 -
xcache/xc_opcode_spec_def.h
rb2ad347 rb6c6620 80 80 #ifdef ZEND_ENGINE_2_1 81 81 /* php 5.1 and up */ 82 # ifdef ZEND_ENGINE_2_483 OPSPEC( UNUSED, STD, STD, UNUSED) /* 74 UNSET_VAR */84 # else85 82 OPSPEC( UNUSED, STD, FETCH, UNUSED) /* 74 UNSET_VAR */ 86 # endif87 83 OPSPEC( STD, STD, STD, UNUSED) /* 75 UNSET_DIM */ 88 84 OPSPEC( STD, STD, STD, UNUSED) /* 76 UNSET_OBJ */ … … 154 150 OPSPEC( UNUSED, UCLASS, STD, UNUSED) /* 113 INIT_STATIC_METHOD_CALL */ 155 151 #endif 156 #ifdef ZEND_ENGINE_2_4157 OPSPEC( ISSET, STD, STD, TMP) /* 114 ISSET_ISEMPTY_VAR */158 #else159 152 OPSPEC( ISSET, STD, FETCH, TMP) /* 114 ISSET_ISEMPTY_VAR */ 160 #endif161 153 OPSPEC( ISSET, STD, STD, TMP) /* 115 ISSET_ISEMPTY_DIM_OBJ */ 162 154
Note: See TracChangeset
for help on using the changeset viewer.