mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-18 01:31:52 +00:00
More AS1/2 increment,decrement,compound using PushDuplicate
This commit is contained in:
@@ -20,7 +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
|
||||
- [#2618] AS1/2 increment/decrement/compound using PushDuplicate
|
||||
|
||||
### Changed
|
||||
- [#2610] Export as SWF - take SWF bounds from the exported item bounds
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12;
|
||||
import com.jpexs.decompiler.flash.action.model.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.action.model.DecrementActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.EvalActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.GetVariableActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.IncrementActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.PostDecrementActionItem;
|
||||
@@ -43,6 +44,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SecondPassData;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
|
||||
import com.jpexs.decompiler.graph.model.DuplicateItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.util.HashMap;
|
||||
@@ -125,6 +127,14 @@ public class ActionSetVariable extends Action implements StoreTypeAction {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (((IncrementActionItem) value).object instanceof EvalActionItem) {
|
||||
if (((IncrementActionItem) value).object.value instanceof DuplicateItem) {
|
||||
if (((IncrementActionItem) value).object.value.value == name) {
|
||||
output.add(new PostIncrementActionItem(this, lineStartAction, new GetVariableActionItem(null, null, name)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (value instanceof DecrementActionItem) {
|
||||
if (((DecrementActionItem) value).object instanceof GetVariableActionItem) {
|
||||
@@ -136,6 +146,14 @@ public class ActionSetVariable extends Action implements StoreTypeAction {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (((DecrementActionItem) value).object instanceof EvalActionItem) {
|
||||
if (((DecrementActionItem) value).object.value instanceof DuplicateItem) {
|
||||
if (((DecrementActionItem) value).object.value.value == name) {
|
||||
output.add(new PostDecrementActionItem(this, lineStartAction, new GetVariableActionItem(null, null, name)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetVariableActionItem setVar = new SetVariableActionItem(this, lineStartAction, name, value);
|
||||
@@ -154,6 +172,13 @@ public class ActionSetVariable extends Action implements StoreTypeAction {
|
||||
setVar.setCompoundValue(binaryOp.getRightSide());
|
||||
setVar.setCompoundOperator(binaryOp.getOperator());
|
||||
}
|
||||
} else if (
|
||||
binaryOp.getLeftSide() instanceof EvalActionItem
|
||||
&& binaryOp.getLeftSide().value instanceof DuplicateItem
|
||||
&& binaryOp.getLeftSide().value.value == name
|
||||
) {
|
||||
setVar.setCompoundValue(binaryOp.getRightSide());
|
||||
setVar.setCompoundOperator(binaryOp.getOperator());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user