Browse Source

Decompiler: fix switch with expression as case value

master
Xuefer 6 years ago
parent
commit
8207e0771c
  1. 12
      devel/sample.cpp.php
  2. 6
      lib/Decompiler.class.php

12
devel/sample.cpp.php

@ -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
lib/Decompiler.class.php

@ -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