Fixed: #2618 AS1/2 increment/decrement using PushDuplicate

This commit is contained in:
Jindra Petřík
2026-02-09 16:17:29 +01:00
parent f6224d6252
commit a2d10314a0
3 changed files with 22 additions and 3 deletions

View File

@@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file.
- HTML5 Canvas morphshape export
- Slovenian translation
- [#2626] AS1/2 direct editation - function calls inside `with` statement
- [#2618] AS1/2 increment/decrement using PushDuplicate
### Changed
- [#2610] Export as SWF - take SWF bounds from the exported item bounds
@@ -4108,6 +4109,7 @@ Major version of SWF to XML export changed to 2.
[#2610]: https://www.free-decompiler.com/flash/issues/2610
[#2603]: https://www.free-decompiler.com/flash/issues/2603
[#2626]: https://www.free-decompiler.com/flash/issues/2626
[#2618]: https://www.free-decompiler.com/flash/issues/2618
[#2581]: https://www.free-decompiler.com/flash/issues/2581
[#2592]: https://www.free-decompiler.com/flash/issues/2592
[#2154]: https://www.free-decompiler.com/flash/issues/2154

View File

@@ -105,8 +105,9 @@ public class ActionSetMember extends Action {
if (value instanceof IncrementActionItem) {
if (((IncrementActionItem) value).object instanceof GetMemberActionItem) {
if (((GetMemberActionItem) ((IncrementActionItem) value).object).object.equals(object)) {
if (((GetMemberActionItem) ((IncrementActionItem) value).object).object.getThroughDuplicate().equals(object)) {
if (((GetMemberActionItem) ((IncrementActionItem) value).object).memberName.equals(memberName)) {
((GetMemberActionItem) ((IncrementActionItem) value).object).object = ((GetMemberActionItem) ((IncrementActionItem) value).object).object.getThroughDuplicate();
output.add(new PostIncrementActionItem(this, lineStartAction, ((IncrementActionItem) value).object));
return;
}
@@ -115,9 +116,10 @@ public class ActionSetMember extends Action {
}
if (value instanceof DecrementActionItem) {
if (((DecrementActionItem) value).object instanceof GetMemberActionItem) {
if (((GetMemberActionItem) ((DecrementActionItem) value).object).object.valueEquals(object)) {
if (((GetMemberActionItem) ((DecrementActionItem) value).object).object.getThroughDuplicate().valueEquals(object)) {
if (((GetMemberActionItem) ((DecrementActionItem) value).object).memberName.equals(memberName)) {
output.add(new PostDecrementActionItem(this, lineStartAction, ((DecrementActionItem) value).object));
((GetMemberActionItem) ((DecrementActionItem) value).object).object = ((GetMemberActionItem) ((DecrementActionItem) value).object).object.getThroughDuplicate();
output.add(new PostDecrementActionItem(this, lineStartAction, ((DecrementActionItem) value).object.getThroughDuplicate()));
return;
}
}

View File

@@ -572,4 +572,19 @@ public class ActionScript2AssemblerTest extends ActionScript2TestBase {
+ "}\n"
+ "}");
}
@Test
public void testIncrementDup() {
String res = decompilePcode("Push \"this\"\n"
+ "GetVariable\n"
+ "PushDuplicate\n"
+ "Push \"myVar\"\n"
+ "GetMember\n"
+ "Increment\n"
+ "Push \"myVar\"\n"
+ "StackSwap\n"
+ "SetMember");
res = cleanPCode(res);
assertEquals(res, "this.myVar++;");
}
}