From e6269303166d96b178ab48dd8aa1c46f7a51f9cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Tue, 9 Jul 2013 17:00:10 +0200 Subject: [PATCH] Issue #216 AS2 field order fix --- trunk/src/com/jpexs/decompiler/flash/SWF.java | 8 ++++++-- .../com/jpexs/decompiler/flash/action/Action.java | 9 +++++---- .../action/treemodel/clauses/ClassTreeItem.java | 15 ++++++++------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index eb7fc9b28..be12d363a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -1846,8 +1846,12 @@ public class SWF { List vars = new ArrayList<>(); - vars.addAll(cti.vars.keySet()); - vars.addAll(cti.staticVars.keySet()); + for (KeyValue item : cti.vars) { + vars.add(item.key); + } + for (KeyValue item : cti.staticVars) { + vars.add(item.key); + } for (GraphTargetItem gti : vars) { if (gti instanceof DirectValueTreeItem) { DirectValueTreeItem dvf = (DirectValueTreeItem) gti; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/Action.java b/trunk/src/com/jpexs/decompiler/flash/action/Action.java index 5cc0b56d4..855759f0f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/Action.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/Action.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.action; import com.jpexs.decompiler.flash.DisassemblyListener; +import com.jpexs.decompiler.flash.KeyValue; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; @@ -985,8 +986,8 @@ public class Action implements GraphSourceItem { List ret = new ArrayList<>(); List functions = new ArrayList<>(); List staticFunctions = new ArrayList<>(); - HashMap vars = new HashMap<>(); - HashMap staticVars = new HashMap<>(); + List> vars = new ArrayList<>(); + List> staticVars = new ArrayList<>(); GraphTargetItem className; GraphTargetItem extendsOp = null; List implementsOp = new ArrayList<>(); @@ -1143,14 +1144,14 @@ public class Action implements GraphSourceItem { ((FunctionTreeItem) smt.value).calculatedFunctionName = smt.objectName; functions.add((FunctionTreeItem) smt.value); } else { - vars.put(smt.objectName, smt.value); + vars.add(new KeyValue<>(smt.objectName, smt.value)); } } else if (((RegisterNumber) ((DirectValueTreeItem) smt.object).value).number == classReg) { if (smt.value instanceof FunctionTreeItem) { ((FunctionTreeItem) smt.value).calculatedFunctionName = smt.objectName; staticFunctions.add((FunctionTreeItem) smt.value); } else { - staticVars.put(smt.objectName, smt.value); + staticVars.add(new KeyValue<>(smt.objectName, smt.value)); } } else { ok = false; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/clauses/ClassTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/clauses/ClassTreeItem.java index fe7fcae14..46194f4c9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/clauses/ClassTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/clauses/ClassTreeItem.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.action.treemodel.clauses; +import com.jpexs.decompiler.flash.KeyValue; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.treemodel.ConstantPool; import com.jpexs.decompiler.flash.action.treemodel.TreeItem; @@ -34,8 +35,8 @@ public class ClassTreeItem extends TreeItem implements Block { public GraphTargetItem extendsOp; public List implementsOp; public GraphTargetItem className; - public HashMap vars; - public HashMap staticVars; + public List> vars; + public List> staticVars; @Override public List> getSubs() { @@ -45,7 +46,7 @@ public class ClassTreeItem extends TreeItem implements Block { return ret; } - public ClassTreeItem(GraphTargetItem className, GraphTargetItem extendsOp, List implementsOp, List functions, HashMap vars, List staticFunctions, HashMap staticVars) { + public ClassTreeItem(GraphTargetItem className, GraphTargetItem extendsOp, List implementsOp, List functions, List> vars, List staticFunctions, List> staticVars) { super(null, NOPRECEDENCE); this.className = className; this.functions = functions; @@ -81,11 +82,11 @@ public class ClassTreeItem extends TreeItem implements Block { for (GraphTargetItem f : staticFunctions) { ret += "static " + f.toString(constants) + "\r\n"; } - for (GraphTargetItem v : vars.keySet()) { - ret += "var " + v.toStringNoQuotes(constants) + " = " + vars.get(v).toStringNoQuotes(constants) + ";\r\n"; + for (KeyValue item : vars) { + ret += "var " + item.key.toStringNoQuotes(constants) + " = " + item.value.toStringNoQuotes(constants) + ";\r\n"; } - for (GraphTargetItem v : staticVars.keySet()) { - ret += "static var " + v.toStringNoQuotes(constants) + " = " + staticVars.get(v).toStringNoQuotes(constants) + ";\r\n"; + for (KeyValue item : staticVars) { + ret += "static var " + item.key.toStringNoQuotes(constants) + " = " + item.value.toStringNoQuotes(constants) + ";\r\n"; } ret += "}\r\n"; return ret;