diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DefineLocalActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DefineLocalActionItem.java index a7ccec9fa..35c2f6d8f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DefineLocalActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DefineLocalActionItem.java @@ -156,4 +156,23 @@ public class DefineLocalActionItem extends ActionItem implements SetTypeActionIt return true; } + @Override + public GraphTargetItem getCompoundValue() { + throw new UnsupportedOperationException("Not supported."); + } + + @Override + public void setCompoundValue(GraphTargetItem value) { + throw new UnsupportedOperationException("Not supported."); + } + + @Override + public void setCompoundOperator(String operator) { + throw new UnsupportedOperationException("Not supported."); + } + + @Override + public String getCompoundOperator() { + throw new UnsupportedOperationException("Not supported."); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java index 2f8f47787..9c85ad59b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java @@ -239,9 +239,10 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue { if (!Objects.equals(this.constants, other.constants)) { return false; } - if (other.pos != this.pos) { + //?? + /*if (other.pos != this.pos) { return false; - } + }*/ return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/PostDecrementActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/PostDecrementActionItem.java index 87316c319..c34902ee1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/PostDecrementActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/PostDecrementActionItem.java @@ -174,4 +174,23 @@ public class PostDecrementActionItem extends ActionItem implements SetTypeAction return true; } + @Override + public GraphTargetItem getCompoundValue() { + throw new UnsupportedOperationException("Not supported."); + } + + @Override + public void setCompoundValue(GraphTargetItem value) { + throw new UnsupportedOperationException("Not supported."); + } + + @Override + public void setCompoundOperator(String operator) { + throw new UnsupportedOperationException("Not supported."); + } + + @Override + public String getCompoundOperator() { + throw new UnsupportedOperationException("Not supported."); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/PostIncrementActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/PostIncrementActionItem.java index c0fd56ea5..a2f13a473 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/PostIncrementActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/PostIncrementActionItem.java @@ -174,4 +174,23 @@ public class PostIncrementActionItem extends ActionItem implements SetTypeAction return true; } + @Override + public GraphTargetItem getCompoundValue() { + throw new UnsupportedOperationException("Not supported."); + } + + @Override + public void setCompoundValue(GraphTargetItem value) { + throw new UnsupportedOperationException("Not supported."); + } + + @Override + public void setCompoundOperator(String operator) { + throw new UnsupportedOperationException("Not supported."); + } + + @Override + public String getCompoundOperator() { + throw new UnsupportedOperationException("Not supported."); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetMemberActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetMemberActionItem.java index ee335dc48..7be5d80ca 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetMemberActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetMemberActionItem.java @@ -47,6 +47,10 @@ public class SetMemberActionItem extends ActionItem implements SetTypeActionItem private int tempRegister = -1; + public GraphTargetItem compoundValue; + + public String compoundOperator; + @Override public void visit(GraphTargetVisitorInterface visitor) { visitor.visit(object); @@ -97,6 +101,12 @@ public class SetMemberActionItem extends ActionItem implements SetTypeActionItem writer.append("."); stripQuotes(objectName, localData, writer); } + if (compoundOperator != null) { + writer.append(" "); + writer.append(compoundOperator); + writer.append("= "); + return compoundValue.toString(writer, localData); + } writer.append(" = "); return value.toString(writer, localData); @@ -174,4 +184,24 @@ public class SetMemberActionItem extends ActionItem implements SetTypeActionItem return true; } + @Override + public GraphTargetItem getCompoundValue() { + return compoundValue; + } + + @Override + public void setCompoundValue(GraphTargetItem value) { + this.compoundValue = value; + } + + @Override + public void setCompoundOperator(String operator) { + this.compoundOperator = operator; + } + + @Override + public String getCompoundOperator() { + return compoundOperator; + } + } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetPropertyActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetPropertyActionItem.java index 60e7c2af0..f76bd2bb7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetPropertyActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetPropertyActionItem.java @@ -167,4 +167,24 @@ public class SetPropertyActionItem extends ActionItem implements SetTypeActionIt return true; } + @Override + public GraphTargetItem getCompoundValue() { + throw new UnsupportedOperationException("Not supported."); + } + + @Override + public void setCompoundValue(GraphTargetItem value) { + throw new UnsupportedOperationException("Not supported."); + } + + @Override + public void setCompoundOperator(String operator) { + throw new UnsupportedOperationException("Not supported."); + } + + @Override + public String getCompoundOperator() { + throw new UnsupportedOperationException("Not supported."); + } + } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetTypeActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetTypeActionItem.java index ef6b33487..717c05a13 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetTypeActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetTypeActionItem.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -32,4 +33,12 @@ public interface SetTypeActionItem { public int getTempRegister(); public void setValue(GraphTargetItem value); + + public GraphTargetItem getCompoundValue(); + + public void setCompoundValue(GraphTargetItem value); + + public void setCompoundOperator(String operator); + + public String getCompoundOperator(); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetVariableActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetVariableActionItem.java index 899a90021..8b03061cb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetVariableActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetVariableActionItem.java @@ -46,6 +46,10 @@ public class SetVariableActionItem extends ActionItem implements SetTypeActionIt private int tempRegister = -1; + public GraphTargetItem compoundValue; + + public String compoundOperator; + @Override public GraphPart getFirstPart() { return value.getFirstPart(); @@ -84,6 +88,12 @@ public class SetVariableActionItem extends ActionItem implements SetTypeActionIt HighlightData srcData = getSrcData(); srcData.localName = name.toStringNoQuotes(localData); stripQuotes(name, localData, writer); + if (compoundOperator != null) { + writer.append(" "); + writer.append(compoundOperator); + writer.append("= "); + return compoundValue.toString(writer, localData); + } writer.append(" = "); return value.toString(writer, localData); } else { @@ -174,4 +184,23 @@ public class SetVariableActionItem extends ActionItem implements SetTypeActionIt return true; } + @Override + public GraphTargetItem getCompoundValue() { + return compoundValue; + } + + @Override + public void setCompoundValue(GraphTargetItem value) { + this.compoundValue = value; + } + + @Override + public void setCompoundOperator(String operator) { + this.compoundOperator = operator; + } + + @Override + public String getCompoundOperator() { + return compoundOperator; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java index bd6d5dd62..992ef8a04 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java @@ -45,6 +45,10 @@ public class StoreRegisterActionItem extends ActionItem implements SetTypeAction public boolean temporary = false; + public GraphTargetItem compoundValue; + + public String compoundOperator; + @Override public GraphPart getFirstPart() { return value.getFirstPart(); @@ -92,7 +96,15 @@ public class StoreRegisterActionItem extends ActionItem implements SetTypeAction srcData.declaredType = DottedChain.ALL; writer.append("var "); } - writer.append(register.translate()).append(" = "); + writer.append(register.translate()); + + if (compoundOperator != null) { + writer.append(" "); + writer.append(compoundOperator); + writer.append("= "); + return compoundValue.toString(writer, localData); + } + writer.append(" = "); value.toString(writer, localData); } return writer; @@ -166,4 +178,24 @@ public class StoreRegisterActionItem extends ActionItem implements SetTypeAction public boolean hasSideEffect() { return true; } + + @Override + public GraphTargetItem getCompoundValue() { + return compoundValue; + } + + @Override + public void setCompoundValue(GraphTargetItem value) { + this.compoundValue = value; + } + + @Override + public void setCompoundOperator(String operator) { + this.compoundOperator = operator; + } + + @Override + public String getCompoundOperator() { + return compoundOperator; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java index 90efdedbe..2c60b3636 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.BaseLocalData; @@ -36,9 +37,11 @@ import com.jpexs.decompiler.flash.types.annotations.SWFVersion; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; +import com.jpexs.decompiler.graph.model.CompoundableBinaryOp; import com.jpexs.decompiler.graph.model.LocalData; import java.util.HashMap; import java.util.List; +import java.util.Objects; /** * @@ -111,7 +114,21 @@ public class ActionSetVariable extends Action implements StoreTypeAction { } } - GraphTargetItem ret = new SetVariableActionItem(this, lineStartAction, name, value); + SetVariableActionItem setVar = new SetVariableActionItem(this, lineStartAction, name, value); + GraphTargetItem ret = setVar; + + if (value.getNotCoercedNoDup() instanceof CompoundableBinaryOp) { + if (!name.hasSideEffect()) { + CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) value.getNotCoercedNoDup(); + if (binaryOp.getLeftSide() instanceof GetVariableActionItem) { + GetVariableActionItem getVar = (GetVariableActionItem) binaryOp.getLeftSide(); + if (Objects.equals(name, getVar.name)) { + setVar.setCompoundValue(binaryOp.getRightSide()); + setVar.setCompoundOperator(binaryOp.getOperator()); + } + } + } + } if (value instanceof StoreRegisterActionItem) { StoreRegisterActionItem sr = (StoreRegisterActionItem) value; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java index e3fc5d1fd..892a5d45e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.BaseLocalData; @@ -33,8 +34,10 @@ import com.jpexs.decompiler.flash.types.annotations.SWFVersion; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; +import com.jpexs.decompiler.graph.model.CompoundableBinaryOp; import java.util.HashMap; import java.util.List; +import java.util.Objects; /** * @@ -110,7 +113,23 @@ public class ActionSetMember extends Action { } } } - GraphTargetItem ret = new SetMemberActionItem(this, lineStartAction, object, memberName, value); + + SetMemberActionItem setMem = new SetMemberActionItem(this, lineStartAction, object, memberName, value); + + if (value.getNotCoercedNoDup() instanceof CompoundableBinaryOp) { + if (!object.hasSideEffect() && !memberName.hasSideEffect()) { + CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) value.getNotCoercedNoDup(); + if (binaryOp.getLeftSide() instanceof GetMemberActionItem) { + GetMemberActionItem getMember = (GetMemberActionItem) binaryOp.getLeftSide(); + if (Objects.equals(object, getMember.object.getThroughDuplicate()) && Objects.equals(memberName, getMember.memberName)) { + setMem.setCompoundValue(binaryOp.getRightSide()); + setMem.setCompoundOperator(binaryOp.getOperator()); + } + } + } + } + + GraphTargetItem ret = setMem; if (value instanceof StoreRegisterActionItem) { StoreRegisterActionItem sr = (StoreRegisterActionItem) value; if (sr.define) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java index b9d8131a3..ad7a52cb6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; import com.jpexs.decompiler.flash.BaseLocalData; @@ -26,6 +27,7 @@ import com.jpexs.decompiler.flash.action.model.DecrementActionItem; import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; import com.jpexs.decompiler.flash.action.model.EnumeratedValueActionItem; import com.jpexs.decompiler.flash.action.model.EnumerationAssignmentValueActionItem; +import com.jpexs.decompiler.flash.action.model.GetMemberActionItem; import com.jpexs.decompiler.flash.action.model.IncrementActionItem; import com.jpexs.decompiler.flash.action.model.PostDecrementActionItem; import com.jpexs.decompiler.flash.action.model.PostIncrementActionItem; @@ -39,9 +41,11 @@ import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; +import com.jpexs.decompiler.graph.model.CompoundableBinaryOp; import java.io.IOException; import java.util.HashMap; import java.util.List; +import java.util.Objects; /** * @@ -160,7 +164,21 @@ public class ActionStoreRegister extends Action implements StoreTypeAction { if ((value instanceof EnumeratedValueActionItem)) { variables.put("__register" + registerNumber, new TemporaryRegister(registerNumber, new EnumerationAssignmentValueActionItem())); } - stack.push(new StoreRegisterActionItem(this, lineStartAction, rn, value, define)); + StoreRegisterActionItem ret = new StoreRegisterActionItem(this, lineStartAction, rn, value, define); + if (value.getNotCoercedNoDup() instanceof CompoundableBinaryOp) { + CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) value.getNotCoercedNoDup(); + if (binaryOp.getLeftSide() instanceof DirectValueActionItem) { + DirectValueActionItem directValue = (DirectValueActionItem) binaryOp.getLeftSide(); + if (directValue.value instanceof RegisterNumber) { + if (((RegisterNumber) directValue.value).number == registerNumber) { + ret.setCompoundValue(binaryOp.getRightSide()); + ret.setCompoundOperator(binaryOp.getOperator()); + } + } + } + } + + stack.push(ret); } @Override