diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java index b96bebc12..484e66820 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -1021,7 +1021,14 @@ public class SWFInputStream extends InputStream { if ((a instanceof ActionStoreRegister) && stack.isEmpty()) { stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList())); } - a.translate(localData, stack, output, Graph.SOP_USE_STATIC/*Graph.SOP_SKIP_STATIC*/, path); + List localData2 = (List) Helper.deepCopy(localData); + HashMap vars = (HashMap) localData.get(1); + for (int r = 0; r < 256; r++) { + if (vars.containsKey("__register" + r)) { + vars.remove("__register" + r); + } + } + a.translate(localData2, stack, output, Graph.SOP_USE_STATIC/*Graph.SOP_SKIP_STATIC*/, path); } } } catch (RuntimeException ex) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java index 83ae483d5..efd739b02 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java @@ -22,6 +22,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.flash.helpers.Helper; import com.jpexs.decompiler.flash.helpers.Highlighting; +import java.io.Serializable; import java.util.HashMap; import java.util.List; @@ -55,24 +56,6 @@ public abstract class AVM2Item extends GraphTargetItem { return true; } - /*public String hilight(String str) { - if (instruction == null) { - return str; - } - if (instruction.mappedOffset >= 0) { - return Highlighting.hilighOffset(str, instruction.mappedOffset); - } else { - return Highlighting.hilighOffset(str, instruction.offset); - } - }*/ - public boolean isFalse() { - return false; - } - - public boolean isTrue() { - return false; - } - protected String formatProperty(ConstantPool constants, GraphTargetItem object, GraphTargetItem propertyName, HashMap localRegNames, List fullyQualifiedNames) { String obStr = object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); if (object.precedence > PRECEDENCE_PRIMARY) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java index 2aace08cf..ef16aff93 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java @@ -35,16 +35,6 @@ public class BooleanAVM2Item extends AVM2Item { return value.toString(); } - @Override - public boolean isFalse() { - return value == false; - } - - @Override - public boolean isTrue() { - return value == true; - } - @Override public Object getResult() { return value; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/Action.java b/trunk/src/com/jpexs/decompiler/flash/action/Action.java index e8b49ff98..74c97f7a8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/Action.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/Action.java @@ -131,6 +131,9 @@ public class Action implements GraphSourceItem { this.actionLength = actionLength; } + public Action() { + } + /** * Returns address of this action * @@ -853,6 +856,12 @@ public class Action implements GraphSourceItem { long endAddr = action.getAddress() + cnt.getHeaderSize(); String cntName = cnt.getName(); List> outs = new ArrayList<>(); + HashMap variables2 = (HashMap) Helper.deepCopy(variables); + for (int r = 0; r < 256; r++) { + if (variables2.containsKey("__register" + r)) { + variables2.remove("__register" + r); + } + } for (long size : cnt.getContainerSizes()) { if (size == 0) { outs.add(new ArrayList()); @@ -860,7 +869,7 @@ public class Action implements GraphSourceItem { } List out; try { - out = ActionGraph.translateViaGraph(cnt.getRegNames(), variables, functions, actions.subList(adr2ip(actions, endAddr, version), adr2ip(actions, endAddr + size, version)), version, staticOperation, path + (cntName == null ? "" : "/" + cntName)); + out = ActionGraph.translateViaGraph(cnt.getRegNames(), variables2, functions, actions.subList(adr2ip(actions, endAddr, version), adr2ip(actions, endAddr + size, version)), version, staticOperation, path + (cntName == null ? "" : "/" + cntName)); } catch (Exception | OutOfMemoryError | StackOverflowError ex2) { Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error", ex2); if (ex2 instanceof OutOfMemoryError) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/ActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/ActionItem.java index c0d90efae..20a84fa13 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/ActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/ActionItem.java @@ -20,11 +20,17 @@ import com.jpexs.decompiler.flash.action.swf4.ActionPop; import com.jpexs.decompiler.flash.action.swf4.ActionPush; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; +import static com.jpexs.decompiler.graph.GraphTargetItem.PRECEDENCE_PRIMARY; import com.jpexs.decompiler.graph.SourceGenerator; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; -public abstract class ActionItem extends GraphTargetItem { +public abstract class ActionItem extends GraphTargetItem implements Serializable { + + public ActionItem() { + super(null, NOPRECEDENCE); + } public ActionItem(GraphSourceItem instruction, int precedence) { super(instruction, precedence); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java index 97e92a356..088f584be 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java @@ -143,6 +143,9 @@ public class DirectValueActionItem extends ActionItem { if (value instanceof ConstantIndex) { return hilight("\"" + Helper.escapeString(this.constants.get(((ConstantIndex) value).index)) + "\""); } + if (value instanceof RegisterNumber) { + return hilight(((RegisterNumber) value).translate()); + } return hilight(value.toString()); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java index 67c3c5ba0..9661eda8f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java @@ -49,6 +49,10 @@ public class FunctionActionItem extends ActionItem { public static final int REGISTER_PARENT = 5; public static final int REGISTER_GLOBAL = 6; + public FunctionActionItem() { + super(null, PRECEDENCE_PRIMARY); + } + public FunctionActionItem(GraphSourceItem instruction, String functionName, List paramNames, List actions, List constants, int regStart) { super(instruction, PRECEDENCE_PRIMARY); this.actions = actions; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java index f6320cb78..eacdae1b9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java @@ -65,7 +65,7 @@ public class StoreRegisterActionItem extends ActionItem implements SetTypeAction @Override public String toString(ConstantPool constants) { - return (define ? hilight("var ") : "") + hilight(register.toString() + "=") + value.toString(constants); + return (define ? hilight("var ") : "") + hilight(register.translate() + "=") + value.toString(constants); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ConstantIndex.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ConstantIndex.java index ff7ae79fa..1191d4f1f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ConstantIndex.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ConstantIndex.java @@ -18,10 +18,11 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.Configuration; import com.jpexs.decompiler.flash.helpers.Helper; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; -public class ConstantIndex { +public class ConstantIndex implements Serializable { public int index; public List constantPool; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/RegisterNumber.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/RegisterNumber.java index fb023c3d1..258be8d07 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/RegisterNumber.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/RegisterNumber.java @@ -16,7 +16,9 @@ */ package com.jpexs.decompiler.flash.action.swf4; -public class RegisterNumber { +import java.io.Serializable; + +public class RegisterNumber implements Serializable { public int number; public String name = null; @@ -58,4 +60,11 @@ public class RegisterNumber { public String toStringNoName() { return "register" + number; } + + public String translate() { + if (name == null || name.trim().equals("")) { + return "_loc" + number + "_"; + } + return name; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java index b2b9b4f69..50e56d4a8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java @@ -81,6 +81,9 @@ public class ActionStoreRegister extends Action { } value.moreSrc.add(new GraphSourceItemPos(this, 0)); boolean define = !variables.containsKey("__register" + registerNumber); + if (regNames.containsKey(registerNumber)) { + define = false; + } variables.put("__register" + registerNumber, value); if (value instanceof DirectValueActionItem) { if (((DirectValueActionItem) value).value instanceof RegisterNumber) { diff --git a/trunk/src/com/jpexs/decompiler/flash/ecma/Null.java b/trunk/src/com/jpexs/decompiler/flash/ecma/Null.java index 0aad7af44..181deb283 100644 --- a/trunk/src/com/jpexs/decompiler/flash/ecma/Null.java +++ b/trunk/src/com/jpexs/decompiler/flash/ecma/Null.java @@ -16,7 +16,9 @@ */ package com.jpexs.decompiler.flash.ecma; -public class Null { +import java.io.Serializable; + +public class Null implements Serializable { @Override public String toString() { diff --git a/trunk/src/com/jpexs/decompiler/flash/ecma/Undefined.java b/trunk/src/com/jpexs/decompiler/flash/ecma/Undefined.java index 541130a09..a29aa31de 100644 --- a/trunk/src/com/jpexs/decompiler/flash/ecma/Undefined.java +++ b/trunk/src/com/jpexs/decompiler/flash/ecma/Undefined.java @@ -16,7 +16,9 @@ */ package com.jpexs.decompiler.flash.ecma; -public class Undefined { +import java.io.Serializable; + +public class Undefined implements Serializable { @Override public String toString() { diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java b/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java index 29a9b187e..3aaa014d8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java +++ b/trunk/src/com/jpexs/decompiler/flash/helpers/Helper.java @@ -310,6 +310,7 @@ public class Helper { } return copy; } catch (Exception ex) { + Logger.getLogger(Helper.class.getName()).log(Level.SEVERE, "Copy error", ex); return null; } } diff --git a/trunk/src/com/jpexs/decompiler/graph/Block.java b/trunk/src/com/jpexs/decompiler/graph/Block.java index f6454c402..c329347fc 100644 --- a/trunk/src/com/jpexs/decompiler/graph/Block.java +++ b/trunk/src/com/jpexs/decompiler/graph/Block.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.graph; import com.jpexs.decompiler.graph.model.ContinueItem; +import java.io.Serializable; import java.util.List; public interface Block { diff --git a/trunk/src/com/jpexs/decompiler/graph/GraphPart.java b/trunk/src/com/jpexs/decompiler/graph/GraphPart.java index d596fda28..6013fc433 100644 --- a/trunk/src/com/jpexs/decompiler/graph/GraphPart.java +++ b/trunk/src/com/jpexs/decompiler/graph/GraphPart.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.graph; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -23,7 +24,7 @@ import java.util.List; * * @author JPEXS */ -public class GraphPart { +public class GraphPart implements Serializable { public int start = 0; public int end = 0; diff --git a/trunk/src/com/jpexs/decompiler/graph/GraphPath.java b/trunk/src/com/jpexs/decompiler/graph/GraphPath.java index 9feda02be..fbd46175c 100644 --- a/trunk/src/com/jpexs/decompiler/graph/GraphPath.java +++ b/trunk/src/com/jpexs/decompiler/graph/GraphPath.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.graph; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -23,7 +24,7 @@ import java.util.List; * * @author JPEXS */ -public class GraphPath { +public class GraphPath implements Serializable { private List keys = new ArrayList<>(); private List vals = new ArrayList<>(); diff --git a/trunk/src/com/jpexs/decompiler/graph/GraphSource.java b/trunk/src/com/jpexs/decompiler/graph/GraphSource.java index 7f9ca28e4..ee5e3eb38 100644 --- a/trunk/src/com/jpexs/decompiler/graph/GraphSource.java +++ b/trunk/src/com/jpexs/decompiler/graph/GraphSource.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.graph; import com.jpexs.decompiler.flash.action.Action; +import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -26,7 +27,7 @@ import java.util.Stack; * * @author JPEXS */ -public abstract class GraphSource { +public abstract class GraphSource implements Serializable { public abstract int size(); diff --git a/trunk/src/com/jpexs/decompiler/graph/GraphSourceItem.java b/trunk/src/com/jpexs/decompiler/graph/GraphSourceItem.java index 250179680..024b9f51d 100644 --- a/trunk/src/com/jpexs/decompiler/graph/GraphSourceItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/GraphSourceItem.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.graph; +import java.io.Serializable; import java.util.List; import java.util.Stack; @@ -23,7 +24,7 @@ import java.util.Stack; * * @author JPEXS */ -public interface GraphSourceItem { +public interface GraphSourceItem extends Serializable { public void translate(List localData, Stack stack, List output, int staticOperation, String path); diff --git a/trunk/src/com/jpexs/decompiler/graph/GraphSourceItemPos.java b/trunk/src/com/jpexs/decompiler/graph/GraphSourceItemPos.java index 0d5826a1d..06caf3539 100644 --- a/trunk/src/com/jpexs/decompiler/graph/GraphSourceItemPos.java +++ b/trunk/src/com/jpexs/decompiler/graph/GraphSourceItemPos.java @@ -16,11 +16,13 @@ */ package com.jpexs.decompiler.graph; +import java.io.Serializable; + /** * * @author JPEXS */ -public class GraphSourceItemPos { +public class GraphSourceItemPos implements Serializable { public GraphSourceItem item; public int pos; diff --git a/trunk/src/com/jpexs/decompiler/graph/GraphTargetItem.java b/trunk/src/com/jpexs/decompiler/graph/GraphTargetItem.java index bf16e3c69..f08013df8 100644 --- a/trunk/src/com/jpexs/decompiler/graph/GraphTargetItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/GraphTargetItem.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.graph; import com.jpexs.decompiler.graph.model.BinaryOp; import com.jpexs.decompiler.flash.helpers.Highlighting; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -25,7 +26,7 @@ import java.util.List; * * @author JPEXS */ -public abstract class GraphTargetItem { +public abstract class GraphTargetItem implements Serializable { public static final int PRECEDENCE_PRIMARY = 0; public static final int PRECEDENCE_POSTFIX = 1; @@ -62,6 +63,10 @@ public abstract class GraphTargetItem { return ret; } + public GraphTargetItem() { + this(null, NOPRECEDENCE); + } + public GraphTargetItem(GraphSourceItem src, int precedence) { this.src = src; this.precedence = precedence; diff --git a/trunk/src/com/jpexs/decompiler/graph/Loop.java b/trunk/src/com/jpexs/decompiler/graph/Loop.java index e2e01ef83..94176216c 100644 --- a/trunk/src/com/jpexs/decompiler/graph/Loop.java +++ b/trunk/src/com/jpexs/decompiler/graph/Loop.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.graph; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -23,7 +24,7 @@ import java.util.List; * * @author JPEXS */ -public class Loop { +public class Loop implements Serializable { public GraphPart loopContinue; public GraphPart loopBreak;