Changeset 789
- Timestamp:
- 2011-04-25T12:42:11+02:00 (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
Decompiler.class.php (modified) (8 diffs)
-
decompilesample.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Decompiler.class.php
r788 r789 524 524 function outputPhp(&$EX, $opline, $last, $indent) // {{{ 525 525 { 526 $needBlankline = isset($EX['lastBlock']); 526 527 $origindent = $indent; 527 528 $curticks = 0; … … 529 530 $op = $EX['opcodes'][$i]; 530 531 if (isset($op['gofrom'])) { 532 if ($needBlankline) { 533 $needBlankline = false; 534 echo PHP_EOL; 535 } 531 536 echo 'label' . $i, ":\n"; 532 537 } … … 547 552 $indent .= INDENT; 548 553 } 554 if ($needBlankline) { 555 $needBlankline = false; 556 echo PHP_EOL; 557 } 549 558 echo $origindent, "declare (ticks=$curticks) {\n"; 550 559 } 560 } 561 if ($needBlankline) { 562 $needBlankline = false; 563 echo PHP_EOL; 551 564 } 552 565 echo $indent, str($op['php'], $indent), ";\n"; … … 653 666 function decompileBasicBlock(&$EX, $first, $last, $indent) // {{{ 654 667 { 655 if (isset($EX['lastBlock'])) {656 echo PHP_EOL;657 }658 668 $this->dasmBasicBlock($EX, $first, $last); 659 669 // $this->dumpRange($EX, $first, $last); … … 670 680 $jmpins = array_keys($jmpins); 671 681 } 672 $opcodes[$line]['opcode'] = XC_NOP;682 // $opcodes[$line]['opcode'] = XC_NOP; 673 683 unset($opcodes[$line]['jmpouts']); 674 684 } … … 694 704 $lastOp = &$opcodes[$last]; 695 705 696 if ($lastOp['opcode'] == XC_JMPNZ 706 if ($lastOp['opcode'] == XC_JMPNZ && !empty($lastOp['jmpouts']) 697 707 && $lastOp['jmpouts'][0] == $first) { 698 708 $this->removeJmpInfo($EX, $last); 699 709 $this->beginComplexBlock($EX); 710 700 711 echo $indent, 'do {', PHP_EOL; 701 712 $this->recognizeAndDecompileClosedBlocks($EX, $first, $last, $indent . INDENT); 702 713 echo $indent, '} while (', str($this->getOpVal($lastOp['op1'], $EX)), ');', PHP_EOL; 714 703 715 $this->endComplexBlock($EX); 704 716 return; … … 717 729 if (isset($firstJmpOp) 718 730 && $firstJmpOp['opcode'] == XC_JMPZ 719 && $lastOp['opcode'] == XC_JMP 731 && $firstJmpOp['jmpouts'][0] > $last 732 && $lastOp['opcode'] == XC_JMP && !empty($lastOp['jmpouts']) 720 733 && $lastOp['jmpouts'][0] == $first) { 721 734 $this->removeJmpInfo($EX, $firstJmp); 722 735 $this->removeJmpInfo($EX, $last); 723 724 736 $this->beginComplexBlock($EX); 737 725 738 ob_start(); 726 739 $this->recognizeAndDecompileClosedBlocks($EX, $first, $last, $indent . INDENT); 727 $code = ob_get_clean(); 740 $body = ob_get_clean(); 741 728 742 echo $indent, 'while (', str($this->getOpVal($firstJmpOp['op1'], $EX)), ') {', PHP_EOL; 729 echo $ code;743 echo $body; 730 744 echo $indent, '}', PHP_EOL; 745 746 $this->endComplexBlock($EX); 747 return; 748 } 749 750 if (isset($firstJmpOp) 751 && $firstJmpOp['opcode'] == XC_FE_FETCH 752 && $firstJmpOp['jmpouts'][0] > $last 753 && $lastOp['opcode'] == XC_JMP && !empty($lastOp['jmpouts']) 754 && $lastOp['jmpouts'][0] == $firstJmp) { 755 $this->removeJmpInfo($EX, $firstJmp); 756 $this->removeJmpInfo($EX, $last); 757 $this->beginComplexBlock($EX); 758 759 ob_start(); 760 $this->recognizeAndDecompileClosedBlocks($EX, $first, $last, $indent . INDENT); 761 $body = ob_get_clean(); 762 763 $as = foldToCode($firstJmpOp['fe_as'], $EX); 764 if (isset($firstJmpOp['fe_key'])) { 765 $as = str($firstJmpOp['fe_key'], $EX) . ' => ' . str($as); 766 } 767 768 echo $indent, 'foreach (', str($firstJmpOp['fe_src'], $EX), " as $as) {", PHP_EOL; 769 echo $body; 770 echo $indent, '}', PHP_EOL; 771 731 772 $this->endComplexBlock($EX); 732 773 return; … … 910 951 else { 911 952 $next = null; 912 }913 if ($op['opcode'] == XC_FE_FETCH) {914 $opline = $next;915 $next = $op['op2']['opline_num'];916 $end = $next - 1;917 918 ob_start();919 $this->outputCode($EX, $opline, $end /* - 1 skip last jmp */, $indent . INDENT);920 $body = ob_get_clean();921 922 $as = foldToCode($op['fe_as'], $EX);923 if (isset($op['fe_key'])) {924 $as = str($op['fe_key'], $EX) . ' => ' . str($as);925 }926 echo "{$indent}foreach (" . str($op['fe_src'], $EX) . " as $as) {\n";927 echo $body;928 echo "{$indent}}";929 // $this->outputCode($EX, $next, $last, $indent);930 // return;931 953 } 932 954 /* -
trunk/decompilesample.php
r786 r789 295 295 296 296 foreach ($array as $key => $value) { 297 foreach ($ arrayas $key => $value) {297 foreach ($value as $key => $value) { 298 298 echo $key . ' = ' . $value . "\n"; 299 299 break 2;
Note: See TracChangeset
for help on using the changeset viewer.

