JPEXS Free Flash Decompiler Issue Tracker

If you are looking for the decompiler itself, visit https://github.com/jindrapetrik/jpexs-decompiler

NEW : We have got a new blog where we post some interesting SWF internals info.

List of issuesList of issues

#10 Missing "default" code block when decompiling switch .. case sometimes
Date created:
Type: bug
Visibility: Everybody
Assigned to:
State: closed Help

Hi all. Thank you very much for your work, it's really cool thing. While using the prog i found a little error with decompiling switch .. case code blocks. The point is that the result code lines do not contain "default" case when there is not "break" statement at the end in the source code. Here is the example. The original source code: var jj:int = 1; switch(jj) { case 1: jj = 1; break; case 2: jj = 2; break; default: jj = 3; } The decompiled code: jj=1; switch(jj) { case 1: jj=1; break; case 2: jj=2; break; } If you place "break" statement after jj=3, the code is decompiled right way. I found the reason of that strange behavior. There is a little issue in AVM2Code.java within toSource method. Here is the code. if (evalTo == -1) subend--; List commands = toSource(isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, substart, subend).output; if ((evalTo == -1) && (casePos < code.get(switchPos).operands.length - 2)) { if (commands.size() == 1) { commands.remove(0); } if (commands.size() > 0) { //hasDefault=true; } } The error is that you compare zero based casePos variable with the count of case blocks of lookupswitch instruction (including the default one). So casePos < code.get(switchPos).operands.length - 2 will always true. I changed this line to if ((evalTo == -1) && (casePos + 1 < code.get(switchPos).operands.length - 2)) { ... After that the example code is decompiled properly
admin
Hi, thank you very much. I have implemented your change, it is in the repository.
admin
user
State: →closed
Title: Missing "default" code block when decompiling switch .. case sometimes→Missing "default" code block when decompiling switch .. case sometimes
Type: →bug
Visibility: →Everybody