From caf965b9ec19246dbd687c1f7bb81c24bbc2c3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Mon, 21 Apr 2014 09:44:17 +0200 Subject: [PATCH] AS1/2/3 direct editation - +- 1 as decrement/increment --- .../flash/abc/avm2/model/operations/AddAVM2Item.java | 10 ++++++++++ .../abc/avm2/model/operations/SubtractAVM2Item.java | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java index 381881b40..cd7d59f39 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java @@ -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 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]) ); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java index d1b84f1be..5d4546bac 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java @@ -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 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]) );