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.

#101 AS 1/2 while + increment/decrement
Author:
pepka

Date created:
Type: bug
Visibility: Everybody
Assigned to:
Labels: AS1/2Decompilation
State: closed 

> What steps will reproduce the problem?
While loop that contains an increment or decrement in its condition part decompiles into
infinite loop (do ... while(true)).
> What is the expected output? What do you see instead?
while (a--)
{
b = a * 2;
}
vs
do
{
register4=register4-1;
if(register4)
{
register5=register4*2;
continue;
}
}
while(true);
> What version of the product are you using? On what operating system?
1.6.0u1


State: new→opened
version 1.6.1 was released. This issue should be fixed.
State: opened→upgraded
Hi,
the problem persists. Now the given example produces only
function init($start, $end)
{
var register4=$start;
var register5=$end;
register4++;
}
instead of what is in .as file.
State: upgraded→opened
Version 1.6.2 was released.
New loop detection algorithm should solve this, try it.
State: opened→upgraded
Hi,
still have 2 flaws:
1. For the given example it misses else clause in
if(register4>register5)
{
while(register4--)
{
register5=register4*2;
}
} <=== here other while should go to else clause
while(register4--<0)
{
register5=register4+2;
}
You can see it in source as well as in p-code:
If loc00ec
...
loc00e7:Jump loc011d
loc00ec:Push register4 register4
...
2. It works for decrement, but the same snippet with increment produces wrong code and
raises a few exceptions:
???? 10, 2013 2:53:40 PM com.jpexs.decompiler.flash.SWFInputStream readActionListAtPos
SEVERE: Disassembly exception
java.util.EmptyStackException
at java.util.Stack.peek(Unknown Source)
at java.util.Stack.pop(Unknown Source)
at com.jpexs.decompiler.flash.action.swf5.ActionLess2.translate(ActionLess2.java:40)
at com.jpexs.decompiler.flash.action.Action.translate(Action.java:668)
at
com.jpexs.decompiler.flash.SWFInputStream.readActionListAtPos(SWFInputStream.java:1011)
at
com.jpexs.decompiler.flash.SWFInputStream.readActionListAtPos(SWFInputStream.java:1095)
at
com.jpexs.decompiler.flash.SWFInputStream.readActionListAtPos(SWFInputStream.java:1060)
at com.jpexs.decompiler.flash.SWFInputStream.readActionList(SWFInputStream.java:736)
at com.jpexs.decompiler.flash.tags.DoInitActionTag.getActions(DoInitActionTag.java:122)
at com.jpexs.decompiler.flash.action.gui.ActionPanel.cacheScript(ActionPanel.java:119)
at com.jpexs.decompiler.flash.action.gui.ActionPanel.access$3(ActionPanel.java:117)
at com.jpexs.decompiler.flash.action.gui.ActionPanel$1.run(ActionPanel.java:252)


State: upgraded→opened
version 1.6.3 released,
loop detection was improved, increment fixed.
this issue should be fixed now, try it.
State: opened→upgraded
It's fixed. Thank you!
State: upgraded→closed