diff --git a/CHANGELOG.md b/CHANGELOG.md index 4092da664..31f70cc85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ All notable changes to this project will be documented in this file. - [#1842] AS1/2 use parenthesis when initObject has nonstring keys - [#1842] AS - Do not display §§dup when the value has no sideeffect - Deobfuscation icon on script toolbar did not match the deobfuscation status +- [#1938] AS3 Direct editation - implied this instead of findprop ## [18.3.2] - 2023-01-10 ### Removed @@ -2898,6 +2899,7 @@ All notable changes to this project will be documented in this file. [#1937]: https://www.free-decompiler.com/flash/issues/1937 [#1458]: https://www.free-decompiler.com/flash/issues/1458 [#1842]: https://www.free-decompiler.com/flash/issues/1842 +[#1938]: https://www.free-decompiler.com/flash/issues/1938 [#1935]: https://www.free-decompiler.com/flash/issues/1935 [#1931]: https://www.free-decompiler.com/flash/issues/1931 [#1934]: https://www.free-decompiler.com/flash/issues/1934 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java index 2d5cbd6a5..250d4a888 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java @@ -97,11 +97,12 @@ public class CallAVM2Item extends AVM2Item { otherNs.add(on.getCpoolIndex(g.abcIndex)); } } - if (cname != null && AVM2SourceGenerator.searchPrototypeChain(null, otherNs, localData.privateNs, localData.protectedNs, true, g.abcIndex, pkgName, cname, n.getVariableName(), outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueABC, isType)) { + //For using this when appropriate: (Non ASC2 approach) + /*if (cname != null && AVM2SourceGenerator.searchPrototypeChain(null, otherNs, localData.privateNs, localData.protectedNs, true, g.abcIndex, pkgName, cname, n.getVariableName(), outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueABC, isType)) { NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), n.line, false, "this", "", null, false, n.openedNamespaces, abcIndex); nobj.setRegNumber(0); obj = nobj; - } + }*/ PropertyAVM2Item p = new PropertyAVM2Item(obj, n.isAttribute(), n.getVariableName(), n.getNamespaceSuffix(), g.abcIndex, n.openedNamespaces, new ArrayList<>()); p.setAssignedValue(n.getAssignedValue()); callable = p; @@ -118,7 +119,8 @@ public class CallAVM2Item extends AVM2Item { if (callable instanceof PropertyAVM2Item) { PropertyAVM2Item prop = (PropertyAVM2Item) callable; obj = prop.object; - if (obj == null) { + //For using this when appropriate: (Non ASC2 approach) + /*if (obj == null) { String cname = localData.currentClass; DottedChain pkgName = localData.pkg; Reference outName = new Reference<>(""); @@ -142,7 +144,7 @@ public class CallAVM2Item extends AVM2Item { nobj.setRegNumber(0); obj = nobj; } - } + }*/ propIndex = prop.resolveProperty(localData); } @@ -168,7 +170,7 @@ public class CallAVM2Item extends AVM2Item { return ((NamespacedAVM2Item) callable).toSource(localData, generator, needsReturn, true, arguments, false, false); } - return toSourceMerge(localData, generator, callable, ins(AVM2Instructions.GetGlobalScope), arguments, ins(AVM2Instructions.Call, arguments.size()), needsReturn ? null : ins(AVM2Instructions.Pop)); + return toSourceMerge(localData, generator, callable, ins(AVM2Instructions.GetGlobalScope) /*ASC2 uses getlocal0 here*/, arguments, ins(AVM2Instructions.Call, arguments.size()), needsReturn ? null : ins(AVM2Instructions.Pop)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java index 8868122ba..b82786f52 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java @@ -482,11 +482,12 @@ public class PropertyAVM2Item extends AssignableAVM2Item { namespaceSuffixInt = Integer.parseInt(namespaceSuffix.substring(1)); } - if (!localData.subMethod && cname != null && AVM2SourceGenerator.searchPrototypeChain(namespaceSuffixInt, otherNs, localData.privateNs, localData.protectedNs, true, abcIndex, pkgName, cname, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType) && (localData.getFullClass().equals(outNs.getVal().addWithSuffix(outName.getVal()).toRawString()))) { + //For using this when appropriate (Non ASC2 approach): + /*if (!localData.subMethod && cname != null && AVM2SourceGenerator.searchPrototypeChain(namespaceSuffixInt, otherNs, localData.privateNs, localData.protectedNs, true, abcIndex, pkgName, cname, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType) && (localData.getFullClass().equals(outNs.getVal().addWithSuffix(outName.getVal()).toRawString()))) { NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), 0, false, "this", "", null, false, openedNamespaces, abcIndex); nobj.setRegNumber(0); obj = nobj; - } else { + } else {*/ Reference objType = new Reference<>(null); Reference propType = new Reference<>(null); Reference propIndex = new Reference<>(0); @@ -495,7 +496,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { resolve(false, localData, isType, objType, propType, propIndex, outPropValue, propValueAbc); obj = ins(AVM2Instructions.FindPropertyStrict, propIndex.getVal()); - } + //} } return obj; } diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicAirDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicAirDecompileTest.java index f182d7a8c..d1858232d 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicAirDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicAirDecompileTest.java @@ -1438,6 +1438,22 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile false); } + @Test + public void testNames2() { + decompileMethod("classic_air", "testNames2", "var j:int = 0;\r\n" + + "var g:Function = null;\r\n" + + "this.i = 0;\r\n" + + "i = 1;\r\n" + + "j = 2;\r\n" + + "trace(this.i);\r\n" + + "trace(i);\r\n" + + "trace(j);\r\n" + + "f();\r\n" + + "this.f();\r\n" + + "g();\r\n", + false); + } + @Test public void testNegate() { decompileMethod("classic_air", "testNegate", "var a:int = 5;\r\n" diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java index 455014c0e..7c0a50c8a 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java @@ -1430,6 +1430,22 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes false); } + @Test + public void testNames2() { + decompileMethod("classic", "testNames2", "var j:int = 0;\r\n" + + "var g:Function = null;\r\n" + + "this.i = 0;\r\n" + + "this.i = 1;\r\n" + + "j = 2;\r\n" + + "trace(this.i);\r\n" + + "trace(this.i);\r\n" + + "trace(j);\r\n" + + "this.f();\r\n" + + "this.f();\r\n" + + "g();\r\n", + false); + } + @Test public void testNegate() { decompileMethod("classic", "testNegate", "var a:int = 5;\r\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 d1ccde029..5abb0a1ec 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 b39b6b7b1..1063b8eb5 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/Main.as b/libsrc/ffdec_lib/testdata/as3_new/src/Main.as index 0811295d2..cfb979104 100644 --- a/libsrc/ffdec_lib/testdata/as3_new/src/Main.as +++ b/libsrc/ffdec_lib/testdata/as3_new/src/Main.as @@ -85,6 +85,7 @@ package TestMultipleCondition; TestNamedAnonFunctions; TestNames; + TestNames2; TestNegate; TestNumberCall; TestOptionalParameters; diff --git a/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestNames2.as b/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestNames2.as new file mode 100644 index 000000000..d9b646bc1 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestNames2.as @@ -0,0 +1,26 @@ +package tests +{ + + public class TestNames2 + { + public var i:int = 0; + + public function run():void + { + var j:int = 0; + var g:Function = null; + this.i = 0; + i = 1; + j = 2; + trace(this.i); + trace(i); + trace(j); + f(); + this.f(); + g(); + } + + public function f(): void { + } + } +} \ No newline at end of file