mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-18 11:08:13 +00:00
AS1/2/3 direct editation - +- 1 as decrement/increment
This commit is contained in:
@@ -19,6 +19,8 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations;
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.AddIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaType;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
@@ -69,6 +71,14 @@ public class AddAVM2Item extends BinaryOpItem {
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
if (rightSide instanceof IntegerValueAVM2Item) {
|
||||
IntegerValueAVM2Item iv = (IntegerValueAVM2Item) rightSide;
|
||||
if (iv.value == 1) {
|
||||
return toSourceMerge(localData, generator, leftSide,
|
||||
new AVM2Instruction(0, new IncrementIns(), new int[]{}, new byte[0])
|
||||
);
|
||||
}
|
||||
}
|
||||
return toSourceMerge(localData, generator, leftSide, rightSide,
|
||||
new AVM2Instruction(0, new AddIns(), new int[]{}, new byte[0])
|
||||
);
|
||||
|
||||
@@ -18,12 +18,16 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.DecrementIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.IncrementIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic.SubtractIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import static com.jpexs.decompiler.graph.GraphTargetItem.toSourceMerge;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.model.BinaryOpItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
@@ -65,6 +69,14 @@ public class SubtractAVM2Item extends BinaryOpItem {
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
if (rightSide instanceof IntegerValueAVM2Item) {
|
||||
IntegerValueAVM2Item iv = (IntegerValueAVM2Item) rightSide;
|
||||
if (iv.value == 1) {
|
||||
return toSourceMerge(localData, generator, leftSide,
|
||||
new AVM2Instruction(0, new DecrementIns(), new int[]{}, new byte[0])
|
||||
);
|
||||
}
|
||||
}
|
||||
return toSourceMerge(localData, generator, leftSide, rightSide,
|
||||
new AVM2Instruction(0, new SubtractIns(), new int[]{}, new byte[0])
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user