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

#2270 Value assignment and if checking
Author: user shadow
Date created:
Type: bug
Visibility: Everybody
Assigned to:
State: closed Help

> What steps will reproduce the problem? code is here; var _loc5_:Boolean; if(_loc5_ = _loc6_.stack(param2)) { stack_Cleanup(_loc6_,param2,param1); } pcode is here; getlocal 6 getlocal2 callproperty QName(PackageNamespace(""),"stack"), 1 convert_b dup setlocal 5 iffalse ofs00f7 findpropstrict QName(PackageNamespace(""),"stack_Cleanup") getlocal 6 getlocal2 getlocal1 callpropvoid QName(PackageNamespace(""),"stack_Cleanup"), 3 ofs00f7: > What is the expected output? What do you see instead? var _loc5_:Boolean = _loc6_.stack(param2); if(_loc5_) { stack_Cleanup(_loc6_,param2,param1); } > What version of the product are you using? Is it "nightly build"? Which operating system do you have? 21.0.1 > Please provide any additional information below. If the problem is related to a SWF file, attach it here, otherwise we can't help you. Wouldn't it be more correct to export the code in this way? I exported all the codes of a game and there are errors in about 160 files in this way. it is impossible to fix them all one by one :) Your work is incredible. You are doing a great job.
admin
Could you please provide sample SWF file? I know I don't need it necessarily, but I'd like to investigate further more how it was compiled. It is clearly some kind of optimization.
user
Of course. here it is.
Downloadtrial.swf (1 KiB)
admin
How did you create such file? I says "Adobe Flash Professional CS6 - build 481" in metadata. I use the same build 481 and tried to compile such SWF but my result is: convert_b setlocal1 getlocal1 iffalse ofsXXX instead of your: convert_b dup setlocal1 iffalse ofsXXX Did you turned on some optimization? How? Or you modified the p-code it by hand? Can it be compiled this way using the Flash CS6?
user
Yes I edited the file in cs6 and then changed the code with JPEXs. The game is normally developed with FlashDevelop. The game is about 14MB and has a lot of code in it. Instead of throwing away the whole game file I chose to include a smaller test file. I can upload the full game if you want.
admin
Yes please, that would be great. Sorry for asking for that, but I'd like to see real world example. I still did not manage to compile it that way, even in FlashDevelop. There must be some optimizer used.
user
You can find many examples in the screen_Level file in code.sndgames.ptd3.base. Like line 487, line 920, line 1498
DownloadPTD3.swf (31,711 KiB)
admin
Thank you for providing a SWF. Also thank you for reporting this, I find this bug pretty crucial. Now I know the reasons for this. It is caused by optimization, this optimization is done on local registers starting from number 4 and on. It is because instruction "getlocal N" has more bytes than dup instruction and dup instruction has same length as getlocal0,1,2,3. The optimizer just changes: setlocal N getlocal N to: dup setlocal N which does the same, but with fewer bytes used. Sample AS3 code to compile to reproduce this: ---------- var a:int = 1; var b:int = 2; var c:int = 3; var d:int = 4; var e:int = d + 5; ---------- (there must be more than 3 variables, that's why it did not work for single variable examples) FFDec was not prepared for this. Luckily, in nightly 2852, I fixed it (or at least tried). It should work now.
State: new→upgraded
user
I understood the logic now that you explained it to me. No matter how much I thought about it, I wouldn't have thought of it :D Thank you for the quick solution. Many people benefit from your work. You are awesome :)
admin
Thanks :-). It's now released as 21.0.2
State: upgraded→closed