JPEXS Free Flash Decompiler Issue Tracker

If you are looking for the decompiler itself, visit

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

List of issuesList of issues

#842 Recover for loops
Author: user henke37
Date created:
Type: feature
Visibility: Everybody
Assigned to: admin JPEXS
Labels: AS1/2AS3
State: opened Help

Attempt to recover for loops. For loops can be trivially detected with 100 % accuracy if line mapping data is included. They can be estimated in many common code patterns, especially the classical simple counter setup.
What is the problem with the current for loop decompiling? We will accept pull request if you can improve it.
The problem is that they end up as while loops instead.
"line mapping data is included" - you probably mean those in debug instruction (line number) That is interesting idea we might use. But these data may be compromised by obfuscators so we must be careful...
Sometimes they are recoveder, so it is alreay implemented, but sometimes they rea not recognized. For example this script: public function testWhileTry2() { for (var i=0; i < 100; i++) { try { for (var j=0; j < 20; j++) { trace("a") } } catch (e:EOFError) { continue; } catch (e:Error) { continue; } trace("after_try"); } trace("end"); } decompiles as: public function testWhileTry2() : * { var j:* = undefined; var i:* = 0; for(;i < 100;i++) { try { j = 0; while(j < 20) { trace("a"); j++; } } catch(e:EOFError) { continue; } trace("after_try"); } trace("end"); } So the outer for is recovered.
In nightly 459 or later, the for loops should be recovered when debugline info present. Also note that when direct editing AS3, we do not insert debugline instructions at this time so the information about for loop is lost this way. I leave this issue open as I think inserting debugline info during direct editation is a good idea.
State: new→opened
Assigned:admin JPEXS