Browse Source

Decompiler: fix switch with expression as case value

master
Xuefer 5 years ago
parent
commit
8207e0771c
2 changed files with 18 additions and 0 deletions
  1. +12
    -0
      devel/sample.cpp.php
  2. +6
    -0
      lib/Decompiler.class.php

+ 12
- 0
devel/sample.cpp.php View File

@ -605,6 +605,18 @@ function codeSwitch()
break;
}
switch (functionCall()) {
case func1():
echo 'case1';
break;
case func2():
case func3():
case 1 + 1:
echo 'case2';
break;
}
switch ('emptySwitch()') {
}


+ 6
- 0
lib/Decompiler.class.php View File

@ -1328,7 +1328,13 @@ class Decompiler
echo $this->EX['indent'], 'switch (', str($this->getOpVal($caseOp['op1'], true), $this->EX), ") {", PHP_EOL;
$caseIsOut = false;
$caseExpressionBegin = $range[0];
foreach ($cases as $caseFirst => $caseLast) {
if ($caseExpressionBegin < $caseFirst) {
$this->recognizeAndDecompileClosedBlocks(array($caseExpressionBegin, $caseFirst - 1));
}
$caseExpressionBegin = $caseLast + 1;
if ($caseIsOut && empty($lastCaseFall)) {
echo PHP_EOL;
}


Loading…
Cancel
Save