More AS1/2 increment,decrement,compound using PushDuplicate

This commit is contained in:
Jindra Petřík
2026-02-09 17:19:11 +01:00
parent a2d10314a0
commit bfc9ab13d4
3 changed files with 68 additions and 2 deletions

View File

@@ -574,7 +574,7 @@ public class ActionScript2AssemblerTest extends ActionScript2TestBase {
}
@Test
public void testIncrementDup() {
public void testMemberIncrementDup() {
String res = decompilePcode("Push \"this\"\n"
+ "GetVariable\n"
+ "PushDuplicate\n"
@@ -587,4 +587,45 @@ public class ActionScript2AssemblerTest extends ActionScript2TestBase {
res = cleanPCode(res);
assertEquals(res, "this.myVar++;");
}
@Test
public void testMemberCompoundDup() {
String res = decompilePcode("Push \"this\"\n"
+ "GetVariable\n"
+ "PushDuplicate\n"
+ "Push \"myVar\"\n"
+ "GetMember\n"
+ "Push 1\n"
+ "Add2\n"
+ "Push \"myVar\"\n"
+ "StackSwap\n"
+ "SetMember");
res = cleanPCode(res);
assertEquals(res, "this.myVar += 1;");
}
@Test
public void testVariableIncrementDup() {
String res = decompilePcode("Push \"c\"\n"
+ "PushDuplicate\n"
+ "GetVariable\n"
+ "Increment\n"
+ "SetVariable");
res = cleanPCode(res);
assertEquals(res, "c++;");
}
@Test
public void testVariableCompoundDup() {
String res = decompilePcode("Push \"c\"\n"
+ "PushDuplicate\n"
+ "GetVariable\n"
+ "Push 1\n"
+ "Add2\n"
+ "SetVariable");
res = cleanPCode(res);
assertEquals(res, "c += 1;");
}
}