diff --git a/CHANGELOG.md b/CHANGELOG.md index 14e1a8301..3f5e53f62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Fixed +- [#1981] AS3 fully qualified (colliding) types in submethods ## [18.3.6] - 2023-02-25 ### Fixed @@ -2966,6 +2968,7 @@ All notable changes to this project will be documented in this file. [alpha 9]: https://github.com/jindrapetrik/jpexs-decompiler/compare/alpha8...alpha9 [alpha 8]: https://github.com/jindrapetrik/jpexs-decompiler/compare/alpha7...alpha8 [alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7 +[#1981]: https://www.free-decompiler.com/flash/issues/1981 [#1970]: https://www.free-decompiler.com/flash/issues/1970 [#1972]: https://www.free-decompiler.com/flash/issues/1972 [#1973]: https://www.free-decompiler.com/flash/issues/1973 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java index 25b9e9e0c..ba7241959 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java @@ -40,7 +40,7 @@ public class NewFunctionIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int methodIndex = ins.operands[0]; - NewFunctionAVM2Item function = new NewFunctionAVM2Item(ins, localData.lineStartInstruction, "", path, false, localData.scriptIndex, localData.classIndex, localData.abc, localData.fullyQualifiedNames, methodIndex, (ScopeStack) localData.scopeStack.clone()); + NewFunctionAVM2Item function = new NewFunctionAVM2Item(ins, localData.lineStartInstruction, "", path, false, localData.scriptIndex, localData.classIndex, localData.abc, methodIndex, (ScopeStack) localData.scopeStack.clone()); stack.push(function); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java index bb0ec5036..b03e63bcd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java @@ -51,14 +51,12 @@ public class NewFunctionAVM2Item extends AVM2Item { public int classIndex; public ABC abc; - - public List fullyQualifiedNames; - + public int methodIndex; public ScopeStack scopeStack; - public NewFunctionAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, String functionName, String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, List fullyQualifiedNames, int methodIndex, ScopeStack scopeStack) { + public NewFunctionAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, String functionName, String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, int methodIndex, ScopeStack scopeStack) { super(instruction, lineStartIns, PRECEDENCE_PRIMARY); this.functionName = functionName; this.path = path; @@ -66,7 +64,6 @@ public class NewFunctionAVM2Item extends AVM2Item { this.scriptIndex = scriptIndex; this.classIndex = classIndex; this.abc = abc; - this.fullyQualifiedNames = fullyQualifiedNames; this.methodIndex = methodIndex; this.scopeStack = scopeStack; } @@ -76,13 +73,12 @@ public class NewFunctionAVM2Item extends AVM2Item { if (localData.seenMethods.contains(methodIndex)) { return writer.append("§§method(").append(methodIndex).append(")"); } - //if (methodIndex == 9141) MethodBody body = abc.findBody(methodIndex); writer.append("function"); writer.startMethod(methodIndex); writer.append((!functionName.isEmpty() ? " " + functionName : "")); writer.appendNoHilight("("); - abc.method_info.get(methodIndex).getParamStr(writer, abc.constants, body, abc, fullyQualifiedNames); + abc.method_info.get(methodIndex).getParamStr(writer, abc.constants, body, abc, localData.fullyQualifiedNames); writer.appendNoHilight("):"); if (Configuration.showMethodBodyId.get()) { writer.appendNoHilight("// method body index: "); @@ -91,13 +87,13 @@ public class NewFunctionAVM2Item extends AVM2Item { writer.appendNoHilight(methodIndex); writer.newLine(); } - abc.method_info.get(methodIndex).getReturnTypeStr(writer, abc.constants, fullyQualifiedNames); + abc.method_info.get(methodIndex).getReturnTypeStr(writer, abc.constants, localData.fullyQualifiedNames); writer.startBlock(); if (body != null) { List callStack = new ArrayList<>(localData.callStack); callStack.add(body); - body.convert(callStack, localData.abcIndex, new ConvertData(), path + "/inner", ScriptExportMode.AS, isStatic, methodIndex, scriptIndex, classIndex, abc, null, new ScopeStack(), 0, new NulWriter(), fullyQualifiedNames, null, false, new HashSet<>(localData.seenMethods)); - body.toString(callStack, localData.abcIndex, path + "/inner", ScriptExportMode.AS, abc, null, writer, fullyQualifiedNames, new HashSet<>(localData.seenMethods)); + body.convert(callStack, localData.abcIndex, new ConvertData(), path + "/inner", ScriptExportMode.AS, isStatic, methodIndex, scriptIndex, classIndex, abc, null, new ScopeStack(), 0, new NulWriter(), localData.fullyQualifiedNames, null, false, new HashSet<>(localData.seenMethods)); + body.toString(callStack, localData.abcIndex, path + "/inner", ScriptExportMode.AS, abc, null, writer, localData.fullyQualifiedNames, new HashSet<>(localData.seenMethods)); } writer.endBlock(); writer.endMethod(); diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassTest.java index 3a4a7e11e..ee16d347d 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassTest.java @@ -86,6 +86,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase { + " public class TestClass implements tests_classes.mypackage1.TestInterface\n" + " {\n" + " \n" + + " \n" + " public function TestClass()\n" + " {\n" + " super();\n" @@ -112,6 +113,15 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase { + " var b:tests_classes.mypackage2.TestInterface = this;\n" + " b = new tests_classes.mypackage2.TestClass();\n" + " }\n" + + " \n" + + " public function testParam(p1:tests_classes.mypackage1.TestInterface, p2:tests_classes.mypackage2.TestInterface) : void\n" + + " {\n" + + " var m:Function = function(m1:tests_classes.mypackage1.TestInterface, m2:tests_classes.mypackage2.TestInterface):void\n" + + " {\n" + + " var v1:tests_classes.mypackage1.TestInterface = null;\n" + + " var v2:tests_classes.mypackage2.TestInterface = null;\n" + + " };\n" + + " }\n" + " }\n" + "}"); } diff --git a/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.air.swf b/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.air.swf index 3b0ad9933..87563de53 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.air.swf and b/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.air.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.flex.swf b/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.flex.swf index 07e29c542..e2102c58a 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.flex.swf and b/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.flex.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_new/src/tests_classes/mypackage1/TestClass.as b/libsrc/ffdec_lib/testdata/as3_new/src/tests_classes/mypackage1/TestClass.as index c39e16b6a..25fb02fbe 100644 --- a/libsrc/ffdec_lib/testdata/as3_new/src/tests_classes/mypackage1/TestClass.as +++ b/libsrc/ffdec_lib/testdata/as3_new/src/tests_classes/mypackage1/TestClass.as @@ -23,5 +23,12 @@ var b : tests_classes.mypackage2.TestInterface = this; b = new tests_classes.mypackage2.TestClass(); } + + public function testParam(p1:tests_classes.mypackage1.TestInterface, p2:tests_classes.mypackage2.TestInterface) : void { + var m:Function = function(m1:tests_classes.mypackage1.TestInterface, m2:tests_classes.mypackage2.TestInterface) : void { + var v1:tests_classes.mypackage1.TestInterface = null; + var v2:tests_classes.mypackage2.TestInterface = null; + }; + } } } \ No newline at end of file