From 64f47c92b9421d6cba8b2b40d0a4b7568058290e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Tue, 20 Aug 2013 19:58:02 +0200 Subject: [PATCH] refactoring --- .../decompiler/flash/SWFInputStream.java | 4 ++-- .../decompiler/flash/abc/avm2/AVM2Code.java | 3 ++- .../localregs/GetLocalTypeIns.java | 4 ++-- .../model/operations/AddActionItem.java | 2 +- .../flash/action/swf4/ActionPush.java | 1 + .../NotCompileTimeItem.java} | 23 +++++++++++-------- 6 files changed, 21 insertions(+), 16 deletions(-) rename trunk/src/com/jpexs/decompiler/{flash/abc/avm2/model/NotCompileTimeAVM2Item.java => graph/NotCompileTimeItem.java} (69%) diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java index dc1afdd1e..b6113b653 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash; -import com.jpexs.decompiler.flash.abc.avm2.model.NotCompileTimeAVM2Item; +import com.jpexs.decompiler.graph.NotCompileTimeItem; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionGraphSource; import com.jpexs.decompiler.flash.action.StoreTypeAction; @@ -996,7 +996,7 @@ public class SWFInputStream extends InputStream { if (varname != null) { GraphTargetItem varval = vars.get(varname); if (varval != null && varval.isCompileTime() && indeterminate) { - vars.put(varname, new NotCompileTimeAVM2Item(null, varval)); + vars.put(varname, new NotCompileTimeItem(null, varval)); } } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 267381587..665a1a2ec 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.abc.avm2; +import com.jpexs.decompiler.graph.NotCompileTimeItem; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.ABCInputStream; import com.jpexs.decompiler.flash.abc.CopyOutputStream; @@ -2340,7 +2341,7 @@ public class AVM2Code implements Serializable { HashMap registers = (HashMap) localData.get(2); GraphTargetItem regVal = registers.get(regId); if (regVal.isCompileTime()) { - registers.put(regId, new NotCompileTimeAVM2Item(null, regVal)); + registers.put(regId, new NotCompileTimeItem(null, regVal)); } } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java index 6918094b8..9af074755 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java @@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.NotCompileTimeAVM2Item; +import com.jpexs.decompiler.graph.NotCompileTimeItem; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; import java.util.HashMap; @@ -44,7 +44,7 @@ public abstract class GetLocalTypeIns extends InstructionDefinition { assignCount = regAssignCount.get(regId); } if (assignCount > 5) { //Do not allow change register more than 5 - for deobfuscation - computedValue = new NotCompileTimeAVM2Item(ins, computedValue); + computedValue = new NotCompileTimeItem(ins, computedValue); } /*if (!isRegisterCompileTime(regId, ip, refs, code)) { computedValue = new NotCompileTimeAVM2Item(ins, computedValue); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AddActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AddActionItem.java index e48563294..8beabe878 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AddActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AddActionItem.java @@ -57,7 +57,7 @@ public class AddActionItem extends BinaryOpItem { public Object getResult() { if (version2) { if (EcmaScript.type(leftSide.getResult()) == EcmaType.STRING || EcmaScript.type(rightSide.getResult()) == EcmaType.STRING) { - return leftSide.getResult().toString() + rightSide.getResult().toString(); + return ""+leftSide.getResult() + rightSide.getResult(); } return EcmaScript.toNumber(leftSide.getResult()) + EcmaScript.toNumber(rightSide.getResult()); } else { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java index b4e28b261..fae666175 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.EndOfStreamException; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.graph.NotCompileTimeItem; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; import com.jpexs.decompiler.flash.action.model.TemporaryRegister; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NotCompileTimeAVM2Item.java b/trunk/src/com/jpexs/decompiler/graph/NotCompileTimeItem.java similarity index 69% rename from trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NotCompileTimeAVM2Item.java rename to trunk/src/com/jpexs/decompiler/graph/NotCompileTimeItem.java index d85761471..87e4a5026 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NotCompileTimeAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/graph/NotCompileTimeItem.java @@ -14,32 +14,25 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.jpexs.decompiler.flash.abc.avm2.model; +package com.jpexs.decompiler.graph; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; import java.util.List; /** * * @author JPEXS */ -public class NotCompileTimeAVM2Item extends AVM2Item { +public class NotCompileTimeItem extends GraphTargetItem { public GraphTargetItem object; - public NotCompileTimeAVM2Item(GraphSourceItem instruction, GraphTargetItem object) { + public NotCompileTimeItem(GraphSourceItem instruction, GraphTargetItem object) { super(instruction, NOPRECEDENCE); this.object = object; } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return object.toString(constants, localRegNames, fullyQualifiedNames); - } - @Override public boolean isCompileTime() { return false; @@ -52,4 +45,14 @@ public class NotCompileTimeAVM2Item extends AVM2Item { } return object.getThroughNotCompilable(); } + + @Override + public String toString(List localData) { + return object.toString(localData); + } + + @Override + public boolean hasReturnValue() { + return object.hasReturnValue(); + } }