| 166 | | $op1 = foldToCode($this->op1, $indent); |
| 167 | | if (is_a($this->op1, 'Decompiler_Binop') && $this->op1->opc != $this->opc) { |
| 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) . ")"; |
| | 165 | if (is_a($this->op1, 'Decompiler_TriOp') || is_a($this->op1, 'Decompiler_Binop') && $this->op1->opc != $this->opc) { |
| | 166 | $op1 = "(" . str($this->op1, $indent) . ")"; |
| | 167 | } |
| | 168 | else { |
| | 169 | $op1 = $this->op1; |
| | 170 | } |
| | 171 | |
| | 172 | if (is_a($this->op2, 'Decompiler_TriOp') || is_a($this->op2, 'Decompiler_Binop') && $this->op2->opc != $this->opc && substr($opstr, -1) != '=') { |
| | 173 | $op2 = "(" . str($this->op2, $indent) . ")"; |
| | 174 | } |
| | 175 | else { |
| | 176 | $op2 = $this->op2; |
| 179 | | return str($op1) . ' ' . $opstr . ' ' . str($op2); |
| | 183 | return str($op1, $indent) . ' ' . $opstr . ' ' . str($op2, $indent); |
| | 184 | } |
| | 185 | } |
| | 186 | // }}} |
| | 187 | class Decompiler_TriOp extends Decompiler_Code // {{{ |
| | 188 | { |
| | 189 | var $condition; |
| | 190 | var $trueValue; |
| | 191 | var $falseValue; |
| | 192 | |
| | 193 | function Decompiler_TriOp($condition, $trueValue, $falseValue) |
| | 194 | { |
| | 195 | $this->condition = $condition; |
| | 196 | $this->trueValue = $trueValue; |
| | 197 | $this->falseValue = $falseValue; |
| | 198 | } |
| | 199 | |
| | 200 | function toCode($indent) |
| | 201 | { |
| | 202 | $trueValue = $this->trueValue; |
| | 203 | if (is_a($this->trueValue, 'Decompiler_TriOp')) { |
| | 204 | $trueValue = "(" . str($trueValue, $indent) . ")"; |
| | 205 | } |
| | 206 | $falseValue = $this->falseValue; |
| | 207 | if (is_a($this->falseValue, 'Decompiler_TriOp')) { |
| | 208 | $falseValue = "(" . str($falseValue, $indent) . ")"; |
| | 209 | } |
| | 210 | |
| | 211 | return str($this->condition) . ' ? ' . str($trueValue) . ' : ' . str($falseValue); |
| | 742 | // {{{ ?: excludign JMP_SET |
| | 743 | if ($firstOp['opcode'] == XC_JMPZ && !empty($firstOp['jmpouts']) |
| | 744 | && $last >= $first + 3 |
| | 745 | && $opcodes[$firstOp['jmpouts'][0] - 2]['opcode'] == XC_QM_ASSIGN |
| | 746 | && $opcodes[$firstOp['jmpouts'][0] - 1]['opcode'] == XC_JMP && $opcodes[$firstOp['jmpouts'][0] - 1]['jmpouts'][0] == $last + 1 |
| | 747 | && $lastOp['opcode'] == XC_QM_ASSIGN |
| | 748 | ) { |
| | 749 | $trueFirst = $first + 1; |
| | 750 | $trueLast = $firstOp['jmpouts'][0] - 2; |
| | 751 | $falseFirst = $firstOp['jmpouts'][0]; |
| | 752 | $falseLast = $last; |
| | 753 | $this->removeJmpInfo($EX, $first); |
| | 754 | |
| | 755 | $condition = $this->getOpVal($firstOp['op1'], $EX); |
| | 756 | $this->recognizeAndDecompileClosedBlocks($EX, $trueFirst, $trueLast, $indent . INDENT); |
| | 757 | $trueValue = $this->getOpVal($opcodes[$trueLast]['op1'], $EX, false, true); |
| | 758 | $this->recognizeAndDecompileClosedBlocks($EX, $falseFirst, $falseLast, $indent . INDENT); |
| | 759 | $falseValue = $this->getOpVal($opcodes[$falseLast]['op1'], $EX, false, true); |
| | 760 | $T[$opcodes[$trueLast]['result']['var']] = new Decompiler_TriOp($condition, $trueValue, $falseValue); |
| | 761 | return false; |
| | 762 | } |
| | 763 | // }}} |