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

#20 Static variables
Date created:
Type: bug
Visibility: Everybody
Assigned to:
State: closed Help

Hi, thanks for your work. I am already testing new release. I've found an error, that fails to decompile code containing calls to static variables. Here is example. Flex code. public static var staticVariable:String = "blablabla"; public function testStatic():void{ var testFunction:Function = function(name:String):*{ return TestAsdec[name]; }; trace(testFunction("staticVariable")); } Decompiled code looks like this (asv) public function testStatic():void{ @1 getlocal 0 @2 pushscope @3 newactivation @4 dup @5 setlocal 1 @6 pushscope @7 getscopeobject 1 @8 newfunction function (_arg1:String){ @1 getglobalscope @2 getslot 1 @3 getlocal 1 @4 getproperty @5 returnvalue } @9 coerce Function @10 setslot 1 @11 returnvoid } Firs instruction is reference to class itself, but asdec fails to decompile it because of empty stack; This is part of GetGlobalScopeIns class. public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap<Integer,String> localRegNames) { stack.push(scopeStack.get(0)); } At this moment scopeStack is empty, so that code causes decompilation error. To fix this we might to use ClassTreeItem to show proper class reference, like this. public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap<Integer,String> localRegNames) { //Adding reference to containing class if scopeStack is empty if (scopeStack.empty()){ stack.push(new ClassTreeItem(abc.instance_info[classIndex].getName(constants).getName(constants))); return; } //to here stack.push(scopeStack.get(0)); } This works for me. I think this might be useful
Hi, thank you for reporting. What kind of compiler do you use? I have compiled the code via Flex SDK (mxmlc) and the inner function looks like this to me: getlex m[16]"classes.TestClass3" //Like your TestAsdec getlocal_1 getproperty m[90]" <NS:PrivateNamespace, PackageNamespace, PrivateNamespace, PackageNamespace classes, PackageInternalNamespace classes, Namespace http://adobe.com/AS3/2006/builtin, ProtectedNamespace classes:Test, StaticProtectedNamespace classes:Test>" returnvalue There is no getglobalscope instruction. TestAsdec is class name, right? I can fix it, but I would like to test it on some files I can compile.
Hi again, I have successfully reproduced this. The problem only occurs in the main class of the application. I will soon fix it.
Please download version 1.0.1, it should be fixed.
Hi. Sorry, i could not answer yesterday. Yes, it was flex application class. I tried to reproduce the code with getglobalscope instruction because i saw the same inner function in compiler generated code of flex application with bindings. Both asv and sothink decompilers also decompiled this wrong. Thank you very much.
State: →closed
Title: Static variables→Static variables
Type: →bug
Visibility: →Everybody