diff --git a/trunk/src/com/jpexs/decompiler/flash/BaseLocalData.java b/trunk/src/com/jpexs/decompiler/flash/BaseLocalData.java
new file mode 100644
index 000000000..455f3b4f8
--- /dev/null
+++ b/trunk/src/com/jpexs/decompiler/flash/BaseLocalData.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2010-2013 JPEXS
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package com.jpexs.decompiler.flash;
+
+/**
+ *
+ * @author JPEXS
+ */
+public abstract class BaseLocalData {
+
+}
diff --git a/trunk/src/com/jpexs/decompiler/flash/FinalProcessLocalData.java b/trunk/src/com/jpexs/decompiler/flash/FinalProcessLocalData.java
new file mode 100644
index 000000000..97b5a0110
--- /dev/null
+++ b/trunk/src/com/jpexs/decompiler/flash/FinalProcessLocalData.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010-2013 JPEXS
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package com.jpexs.decompiler.flash;
+
+import java.util.HashSet;
+
+/**
+ *
+ * @author JPEXS
+ */
+public class FinalProcessLocalData {
+
+ public final HashSet temporaryRegisters;
+
+ public FinalProcessLocalData() {
+ temporaryRegisters = new HashSet<>();
+ }
+}
diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java
index c2af251d0..03272dd0b 100644
--- a/trunk/src/com/jpexs/decompiler/flash/SWF.java
+++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java
@@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.abc.ScriptPack;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionDeobfuscation;
import com.jpexs.decompiler.flash.action.ActionGraphSource;
+import com.jpexs.decompiler.flash.action.ActionLocalData;
import com.jpexs.decompiler.flash.action.model.ConstantPool;
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
import com.jpexs.decompiler.flash.action.model.FunctionActionItem;
@@ -1552,7 +1553,7 @@ public final class SWF implements TreeItem {
private HashMap usageTypes = new HashMap<>();
private ActionDeobfuscation deobfuscation = new ActionDeobfuscation();
- private static void getVariables(ConstantPool constantPool, List localData, Stack stack, List output, ActionGraphSource code, int ip, List> variables, List functions, HashMap strings, List visited, HashMap usageTypes, String path) throws InterruptedException {
+ private static void getVariables(ConstantPool constantPool, BaseLocalData localData, Stack stack, List output, ActionGraphSource code, int ip, List> variables, List functions, HashMap strings, List visited, HashMap usageTypes, String path) throws InterruptedException {
boolean debugMode = false;
while ((ip > -1) && ip < code.size()) {
if (visited.contains(ip)) {
@@ -1717,7 +1718,7 @@ public final class SWF implements TreeItem {
}
private static void getVariables(List> variables, List functions, HashMap strings, HashMap usageType, ActionGraphSource code, int addr, String path) throws InterruptedException {
- List localData = Helper.toList(new HashMap(), new HashMap(), new HashMap());
+ ActionLocalData localData = new ActionLocalData();
getVariables(null, localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), variables, functions, strings, new ArrayList(), usageType, path);
}
diff --git a/trunk/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java b/trunk/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java
new file mode 100644
index 000000000..1f4425971
--- /dev/null
+++ b/trunk/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2010-2013 JPEXS
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package com.jpexs.decompiler.flash;
+
+import java.util.HashMap;
+
+/**
+ *
+ * @author JPEXS
+ */
+public class SourceGeneratorLocalData {
+
+ public HashMap registerVars;
+ public Boolean inFunction;
+ public Boolean inMethod;
+ public Integer forInLevel;
+
+ public SourceGeneratorLocalData(HashMap registerVars, Boolean inFunction, Boolean inMethod, Integer forInLevel) {
+ this.registerVars = registerVars;
+ this.inFunction = inFunction;
+ this.inMethod = inMethod;
+ this.forInLevel = forInLevel;
+ }
+}
diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/AVM2LocalData.java b/trunk/src/com/jpexs/decompiler/flash/abc/AVM2LocalData.java
new file mode 100644
index 000000000..75c031105
--- /dev/null
+++ b/trunk/src/com/jpexs/decompiler/flash/abc/AVM2LocalData.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2010-2013 JPEXS
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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;
+
+import com.jpexs.decompiler.flash.BaseLocalData;
+import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
+import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
+import com.jpexs.decompiler.flash.abc.types.ABCException;
+import com.jpexs.decompiler.flash.abc.types.MethodBody;
+import com.jpexs.decompiler.flash.abc.types.MethodInfo;
+import com.jpexs.decompiler.graph.GraphTargetItem;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Stack;
+
+/**
+ *
+ * @author JPEXS
+ */
+public class AVM2LocalData extends BaseLocalData {
+
+ public Boolean isStatic;
+ public Integer classIndex;
+ public HashMap localRegs;
+ public Stack scopeStack;
+ public ConstantPool constants;
+ public MethodInfo[] methodInfo;
+ public MethodBody methodBody;
+ public ABC abc;
+ public HashMap localRegNames;
+ public List fullyQualifiedNames;
+ public ArrayList parsedExceptions;
+ public ArrayList finallyJumps;
+ public ArrayList ignoredSwitches;
+ public Integer scriptIndex;
+ public HashMap localRegAssignmentIps;
+ public Integer ip;
+ public HashMap> refs;
+ public AVM2Code code;
+
+ public AVM2LocalData() {
+
+ }
+
+ public AVM2LocalData(AVM2LocalData localData) {
+ isStatic = localData.isStatic;
+ classIndex = localData.classIndex;
+ localRegs = localData.localRegs;
+ scopeStack = localData.scopeStack;
+ constants = localData.constants;
+ methodInfo = localData.methodInfo;
+ methodBody = localData.methodBody;
+ abc = localData.abc;
+ localRegNames = localData.localRegNames;
+ fullyQualifiedNames = localData.fullyQualifiedNames;
+ parsedExceptions = localData.parsedExceptions;
+ finallyJumps = localData.finallyJumps;
+ ignoredSwitches = localData.ignoredSwitches;
+ scriptIndex = localData.scriptIndex;
+ localRegAssignmentIps = localData.localRegAssignmentIps;
+ ip = localData.ip;
+ refs = localData.refs;
+ code = localData.code;
+ }
+}
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 32017a0fb..52d42e2fe 100644
--- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java
+++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.ABCInputStream;
+import com.jpexs.decompiler.flash.abc.AVM2LocalData;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2Graph;
import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2GraphSource;
@@ -1647,51 +1648,51 @@ public class AVM2Code implements Serializable {
}
@SuppressWarnings("unchecked")
- private static List prepareBranchLocalData(List localData) {
- List ret = new ArrayList<>();
- ret.add(localData.get(0)); //isStatic
- ret.add(localData.get(1)); //classIndex
- ret.add(new HashMap<>((HashMap) localData.get(2)));
- ret.add((Stack) ((Stack) localData.get(3)).clone());
- ret.add(localData.get(4)); //constants
- ret.add(localData.get(5)); //method_info
- ret.add(localData.get(6)); //body
- ret.add(localData.get(7)); //abc
- ret.add(localData.get(8)); //localgetNames
- ret.add(localData.get(9));
- ret.add(localData.get(10));
- ret.add(localData.get(11));
- ret.add(localData.get(12));
- ret.add(localData.get(13));
- ret.add(localData.get(14));
- ret.add(localData.get(15));
- ret.add(localData.get(16));
- ret.add(localData.get(17));
+ private static AVM2LocalData prepareBranchLocalData(AVM2LocalData localData) {
+ AVM2LocalData ret = new AVM2LocalData();
+ ret.isStatic = localData.isStatic;
+ ret.classIndex = localData.classIndex;
+ ret.localRegs = new HashMap<>(localData.localRegs);
+ ret.scopeStack = (Stack) (localData.scopeStack).clone();
+ ret.constants = localData.constants;
+ ret.methodInfo = localData.methodInfo;
+ ret.methodBody = localData.methodBody;
+ ret.abc = localData.abc;
+ ret.localRegNames = localData.localRegNames;
+ ret.fullyQualifiedNames = localData.fullyQualifiedNames;
+ ret.parsedExceptions = localData.parsedExceptions;
+ ret.finallyJumps = localData.finallyJumps;
+ ret.ignoredSwitches = localData.ignoredSwitches;
+ ret.scriptIndex = localData.scriptIndex;
+ ret.localRegAssignmentIps = localData.localRegAssignmentIps;
+ ret.ip = localData.ip;
+ ret.refs = localData.refs;
+ ret.code = localData.code;
return ret;
}
public int removeTraps(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, ABC abc, int scriptIndex, int classIndex, boolean isStatic, String path) throws InterruptedException {
removeDeadCode(constants, trait, info, body);
- List localData = new ArrayList<>();
- localData.add((Boolean) isStatic); //isStatic
- localData.add((Integer) (classIndex)); //classIndex
- localData.add(new HashMap());
- localData.add(new Stack());
- localData.add(abc.constants);
- localData.add(abc.method_info);
- localData.add(body);
- localData.add(abc);
- localData.add(body.getLocalRegNames(abc)); //localRegNames
- localData.add(new ArrayList()); //fullyQualifiedNames
- localData.add(new ArrayList());
- localData.add(new ArrayList());
- localData.add(new ArrayList());
- localData.add((Integer) (scriptIndex));
- localData.add(new HashMap()); //localRegAssignmentIps
- localData.add(Integer.valueOf(0));
+ AVM2LocalData localData = new AVM2LocalData();
+ localData.isStatic = isStatic;
+ localData.classIndex = classIndex;
+ localData.localRegs = new HashMap<>();
+ localData.scopeStack = new Stack<>();
+ localData.constants = abc.constants;
+ localData.methodInfo = abc.method_info;
+ localData.methodBody = body;
+ localData.abc = abc;
+ localData.localRegNames = body.getLocalRegNames(abc);
+ localData.fullyQualifiedNames = new ArrayList<>();
+ localData.parsedExceptions = new ArrayList<>();
+ localData.finallyJumps = new ArrayList<>();
+ localData.ignoredSwitches = new ArrayList<>();
+ localData.scriptIndex = scriptIndex;
+ localData.localRegAssignmentIps = new HashMap<>();
+ localData.ip = 0;
HashMap> refs = visitCode(body);
- localData.add(refs);
- localData.add(this);
+ localData.refs = refs;
+ localData.code = this;
int ret = 0;
ret += removeTraps(constants, trait, info, body, localData, new AVM2GraphSource(this, false, -1, -1, new HashMap(), new Stack(), abc, body, new HashMap(), new ArrayList(), new HashMap(), refs), 0, path, refs);
removeIgnored(constants, trait, info, body);
@@ -2379,7 +2380,7 @@ public class AVM2Code implements Serializable {
}
@SuppressWarnings("unchecked")
- private static int removeTraps(HashMap> refs, boolean secondPass, boolean indeterminate, List localData, Stack stack, List output, AVM2GraphSource code, int ip, HashMap visited, HashMap> visitedStates, HashMap decisions, String path, int recursionLevel) throws InterruptedException {
+ private static int removeTraps(HashMap> refs, boolean secondPass, boolean indeterminate, AVM2LocalData localData, Stack stack, List output, AVM2GraphSource code, int ip, HashMap visited, HashMap> visitedStates, HashMap decisions, String path, int recursionLevel) throws InterruptedException {
if (Thread.currentThread().isInterrupted()) {
throw new InterruptedException();
}
@@ -2401,7 +2402,7 @@ public class AVM2Code implements Serializable {
visited.put(ip, visited.get(ip) + 1);
}
} else {
- HashMap currentState = (HashMap) localData.get(2);
+ HashMap currentState = localData.localRegs;
if (visitedStates.containsKey(ip)) {
HashMap lastState = visitedStates.get(ip);
@@ -2451,7 +2452,7 @@ public class AVM2Code implements Serializable {
if (debugMode) {
System.out.println((indeterminate ? "useV " : "") + (secondPass ? "secondPass " : "") + "Visit " + ip + ": " + ins + " stack:" + stack.toString());
- HashMap registers = (HashMap) localData.get(2);
+ HashMap registers = localData.localRegs;
System.out.print("Registers:");
for (int reg : registers.keySet()) {
try {
@@ -2485,7 +2486,7 @@ public class AVM2Code implements Serializable {
if (((AVM2Instruction) ins).definition instanceof NewFunctionIns) {
stack.push(new BooleanAVM2Item(null, true));
} else {
- localData.set(15, ip);
+ localData.ip = ip;
ins.translate(localData, stack, output, Graph.SOP_USE_STATIC, path);
}
@@ -2494,7 +2495,7 @@ public class AVM2Code implements Serializable {
SetLocalTypeIns slt = (SetLocalTypeIns) ins.definition;
int regId = slt.getRegisterId(ins);
if (indeterminate) {
- HashMap registers = (HashMap) localData.get(2);
+ HashMap registers = localData.localRegs;
GraphTargetItem regVal = registers.get(regId);
if (regVal.isCompileTime()) {
registers.put(regId, new NotCompileTimeItem(null, regVal));
@@ -2577,7 +2578,7 @@ public class AVM2Code implements Serializable {
} else {
decisions.put(ins, dec);
}
- HashMap registers = (HashMap) localData.get(2);
+ HashMap registers = localData.localRegs;
boolean regChanged = false;
if (!dec.registers.isEmpty()) {
if (dec.registers.size() != registers.size()) {
@@ -2636,7 +2637,7 @@ public class AVM2Code implements Serializable {
return ret;
}
- public static int removeTraps(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, List localData, AVM2GraphSource code, int addr, String path, HashMap> refs) throws InterruptedException {
+ public static int removeTraps(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, AVM2LocalData localData, AVM2GraphSource code, int addr, String path, HashMap> refs) throws InterruptedException {
HashMap decisions = new HashMap<>();
removeTraps(refs, false, false, localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), new HashMap(), new HashMap>(), decisions, path, 0);
int cnt = 0;
@@ -2667,7 +2668,7 @@ public class AVM2Code implements Serializable {
code.getCode().removeIgnored(constants, trait, info, body);
return cnt;
}
- /*public static int removeTraps(List localData, AVM2GraphSource code, int addr) {
+ /*public static int removeTraps(AVM2LocalData localData, AVM2GraphSource code, int addr) {
AVM2Graph.translateViaGraph(localData, "", code, new ArrayList(), Graph.SOP_REMOVE_STATIC);
return 1;
}*/
diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java
index 0a2407fd1..4f7fe8782 100644
--- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java
+++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java
@@ -16,7 +16,10 @@
*/
package com.jpexs.decompiler.flash.abc.avm2.graph;
+import com.jpexs.decompiler.flash.BaseLocalData;
+import com.jpexs.decompiler.flash.FinalProcessLocalData;
import com.jpexs.decompiler.flash.abc.ABC;
+import com.jpexs.decompiler.flash.abc.AVM2LocalData;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictEqIns;
@@ -99,42 +102,29 @@ public class AVM2Graph extends Graph {
}*/
}
- public static final int DATA_ISSTATIC = 0;
- public static final int DATA_CLASSINDEX = 1;
- public static final int DATA_LOCALREGS = 2;
- public static final int DATA_SCOPESTACK = 3;
- public static final int DATA_CONSTANTS = 4;
- public static final int DATA_METHOD_INFO = 5;
- public static final int DATA_BODY = 6;
- public static final int DATA_ABC = 7;
- public static final int DATA_LOCALREGNAMES = 8;
- public static final int DATA_FQN = 9;
- public static final int DATA_PARSEDEXCEPTIONS = 10;
- public static final int DATA_FINALLYJUMPS = 11;
- public static final int DATA_IGNOREDSWITCHES = 12;
public static List translateViaGraph(String path, AVM2Code code, ABC abc, MethodBody body, boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack scopeStack, HashMap localRegNames, List fullyQualifiedNames, int staticOperation, HashMap localRegAssigmentIps, HashMap> refs) throws InterruptedException {
AVM2Graph g = new AVM2Graph(code, abc, body, isStatic, scriptIndex, classIndex, localRegs, scopeStack, localRegNames, fullyQualifiedNames, localRegAssigmentIps, refs);
- List localData = new ArrayList<>();
- localData.add((Boolean) isStatic);
- localData.add((Integer) classIndex);
- localData.add(localRegs);
- localData.add(scopeStack);
- localData.add(abc.constants);
- localData.add(abc.method_info);
- localData.add(body);
- localData.add(abc);
- localData.add(localRegNames);
- localData.add(fullyQualifiedNames);
- localData.add(new ArrayList());
- localData.add(new ArrayList()); //finallyJumps
- localData.add(new ArrayList());
- localData.add((Integer) scriptIndex);
- localData.add(new HashMap()); //localRegAssignmentIps
- localData.add(Integer.valueOf(0));
- localData.add(refs);
- localData.add(code);
+ AVM2LocalData localData = new AVM2LocalData();
+ localData.isStatic = isStatic;
+ localData.classIndex = classIndex;
+ localData.localRegs = localRegs;
+ localData.scopeStack = scopeStack;
+ localData.constants = abc.constants;
+ localData.methodInfo = abc.method_info;
+ localData.methodBody = body;
+ localData.abc = abc;
+ localData.localRegNames = localRegNames;
+ localData.fullyQualifiedNames = fullyQualifiedNames;
+ localData.parsedExceptions = new ArrayList<>();
+ localData.finallyJumps = new ArrayList<>();
+ localData.ignoredSwitches = new ArrayList<>();
+ localData.scriptIndex = scriptIndex;
+ localData.localRegAssignmentIps = new HashMap<>();
+ localData.ip = 0;
+ localData.refs = refs;
+ localData.code = code;
g.init(localData);
List allParts = new ArrayList<>();
for (GraphPart head : g.heads) {
@@ -186,15 +176,13 @@ public class AVM2Graph extends Graph {
}
@Override
- protected List check(GraphSource code, List localData, List allParts, Stack stack, GraphPart parent, GraphPart part, List stopPart, List loops, List output, Loop currentLoop, int staticOperation, String path) throws InterruptedException {
+ protected List check(GraphSource code, BaseLocalData localData, List allParts, Stack stack, GraphPart parent, GraphPart part, List stopPart, List loops, List output, Loop currentLoop, int staticOperation, String path) throws InterruptedException {
List ret = null;
- @SuppressWarnings("unchecked")
- List parsedExceptions = (List) localData.get(DATA_PARSEDEXCEPTIONS);
- @SuppressWarnings("unchecked")
- List finallyJumps = (List) localData.get(DATA_FINALLYJUMPS);
- @SuppressWarnings("unchecked")
- List ignoredSwitches = (List) localData.get(DATA_IGNOREDSWITCHES);
+ AVM2LocalData aLocalData = (AVM2LocalData) localData;
+ List parsedExceptions = aLocalData.parsedExceptions;
+ List finallyJumps = aLocalData.finallyJumps;
+ List ignoredSwitches = aLocalData.ignoredSwitches;
int ip = part.start;
int addr = this.avm2code.fixAddrAfterDebugLine(this.avm2code.pos2adr(part.start));
int maxend = -1;
@@ -331,9 +319,8 @@ public class AVM2Graph extends Graph {
}
}
stack.add(new ExceptionAVM2Item(catchedExceptions.get(e)));
- List localData2 = new ArrayList<>();
- localData2.addAll(localData);
- localData2.set(DATA_SCOPESTACK, new Stack());
+ AVM2LocalData localData2 = new AVM2LocalData(aLocalData);
+ localData2.scopeStack = new Stack<>();
List stopPart2 = new ArrayList<>(stopPart);
stopPart2.add(nepart);
if (retPart != null) {
@@ -619,11 +606,10 @@ public class AVM2Graph extends Graph {
}
@Override
- protected GraphPart checkPart(Stack stack, List localData, GraphPart next, List allParts) {
- @SuppressWarnings("unchecked")
- List finallyJumps = (List) localData.get(DATA_FINALLYJUMPS);
- @SuppressWarnings("unchecked")
- List ignoredSwitches = (List) localData.get(DATA_IGNOREDSWITCHES);
+ protected GraphPart checkPart(Stack stack, BaseLocalData localData, GraphPart next, List allParts) {
+ AVM2LocalData aLocalData = (AVM2LocalData) localData;
+ List finallyJumps = aLocalData.finallyJumps;
+ List ignoredSwitches = aLocalData.ignoredSwitches;
GraphPart ret = next;
for (int f = 0; f < finallyJumps.size(); f++) {
int fip = finallyJumps.get(f);
@@ -678,7 +664,8 @@ public class AVM2Graph extends Graph {
}
@Override
- protected GraphTargetItem checkLoop(LoopItem loopItem, List localData, List loops) {
+ protected GraphTargetItem checkLoop(LoopItem loopItem, BaseLocalData localData, List loops) {
+ AVM2LocalData aLocalData = (AVM2LocalData) localData;
if (loopItem instanceof WhileItem) {
WhileItem w = (WhileItem) loopItem;
@@ -703,8 +690,7 @@ public class AVM2Graph extends Graph {
if (spt.object instanceof LocalRegAVM2Item) {
int regIndex = ((LocalRegAVM2Item) spt.object).regIndex;
HasNextAVM2Item iti = (HasNextAVM2Item) w.expression.get(w.expression.size() - 1);
- @SuppressWarnings("unchecked")
- HashMap localRegs = (HashMap) localData.get(DATA_LOCALREGS);
+ HashMap localRegs = aLocalData.localRegs;
localRegs.put(regIndex, new FilterAVM2Item(null, iti.collection.getThroughRegister(), ift.expression));
return null;
}
@@ -731,7 +717,7 @@ public class AVM2Graph extends Graph {
}
@Override
- protected void finalProcess(List list, int level, List localData) {
+ protected void finalProcess(List list, int level, FinalProcessLocalData localData) {
if (level == 0) {
if (!list.isEmpty()) {
if (list.get(list.size() - 1) instanceof ReturnVoidAVM2Item) {
@@ -822,14 +808,12 @@ public class AVM2Graph extends Graph {
}
@Override
- public List prepareBranchLocalData(List localData) {
- List ret = new ArrayList<>();
- ret.addAll(localData);
- @SuppressWarnings("unchecked")
- Stack scopeStack = (Stack) ret.get(DATA_SCOPESTACK);
+ public AVM2LocalData prepareBranchLocalData(BaseLocalData localData) {
+ AVM2LocalData aLocalData = (AVM2LocalData) localData;
+ AVM2LocalData ret = new AVM2LocalData(aLocalData);
Stack copyScopeStack = new Stack<>();
- copyScopeStack.addAll(scopeStack);
- ret.set(DATA_SCOPESTACK, copyScopeStack);
+ copyScopeStack.addAll(ret.scopeStack);
+ ret.scopeStack = copyScopeStack;
return ret;
}
}
diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2GraphSource.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2GraphSource.java
index b0ce4403c..c1e2de79b 100644
--- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2GraphSource.java
+++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2GraphSource.java
@@ -16,7 +16,9 @@
*/
package com.jpexs.decompiler.flash.abc.avm2.graph;
+import com.jpexs.decompiler.flash.BaseLocalData;
import com.jpexs.decompiler.flash.abc.ABC;
+import com.jpexs.decompiler.flash.abc.AVM2LocalData;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.ConvertOutput;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
@@ -83,11 +85,9 @@ public class AVM2GraphSource extends GraphSource {
}
@Override
- @SuppressWarnings("unchecked")
- public List translatePart(GraphPart part, List localData, Stack stack, int start, int end, int staticOperation, String path) throws InterruptedException {
+ public List translatePart(GraphPart part, BaseLocalData localData, Stack stack, int start, int end, int staticOperation, String path) throws InterruptedException {
List ret = new ArrayList<>();
- Object o = localData.get(AVM2Graph.DATA_SCOPESTACK);
- Stack newstack = (Stack) o;
+ Stack newstack = ((AVM2LocalData) localData).scopeStack;
ConvertOutput co = code.toSourceOutput(path, part, false, isStatic, scriptIndex, classIndex, localRegs, stack, newstack, abc, abc.constants, abc.method_info, body, start, end, localRegNames, fullyQualifiedNames, new boolean[size()], localRegAssigmentIps, refs);
ret.addAll(co.output);
return ret;
diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java
index 723c1ec47..ecf94864f 100644
--- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java
+++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java
@@ -16,8 +16,9 @@
*/
package com.jpexs.decompiler.flash.abc.avm2.instructions;
-import com.jpexs.decompiler.flash.abc.ABC;
+import com.jpexs.decompiler.flash.BaseLocalData;
import com.jpexs.decompiler.flash.abc.ABCOutputStream;
+import com.jpexs.decompiler.flash.abc.AVM2LocalData;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns;
@@ -25,8 +26,6 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.LookupSwitchIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnValueIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ThrowIns;
-import com.jpexs.decompiler.flash.abc.types.MethodBody;
-import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphSource;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -37,7 +36,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Stack;
@@ -279,15 +277,15 @@ public class AVM2Instruction implements Serializable, GraphSourceItem {
public List replaceWith;
@Override
- @SuppressWarnings("unchecked")
- public void translate(List localData, Stack stack, List output, int staticOperation, String path) throws InterruptedException {
- definition.translate((Boolean) localData.get(0),
- (Integer) localData.get(13),
- (Integer) localData.get(1),
- (HashMap) localData.get(2),
+ public void translate(BaseLocalData localData, Stack stack, List output, int staticOperation, String path) throws InterruptedException {
+ AVM2LocalData aLocalData = (AVM2LocalData) localData;
+ definition.translate(aLocalData.isStatic,
+ aLocalData.scriptIndex,
+ aLocalData.classIndex,
+ aLocalData.localRegs,
stack,
- (Stack) localData.get(3),
- (ConstantPool) localData.get(4), this, (MethodInfo[]) localData.get(5), output, (MethodBody) localData.get(6), (ABC) localData.get(7), (HashMap) localData.get(8), (List) localData.get(9), null, (HashMap) localData.get(14), (int) (Integer) localData.get(15), (HashMap>) localData.get(16), (AVM2Code) localData.get(17));
+ aLocalData.scopeStack,
+ aLocalData.constants, this, aLocalData.methodInfo, output, aLocalData.methodBody, aLocalData.abc, aLocalData.localRegNames, aLocalData.fullyQualifiedNames, null, aLocalData.localRegAssignmentIps, aLocalData.ip, aLocalData.refs, aLocalData.code);
}
@Override
diff --git a/trunk/src/com/jpexs/decompiler/flash/action/Action.java b/trunk/src/com/jpexs/decompiler/flash/action/Action.java
index 8c79c4980..6b58d527a 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.AppStrings;
+import com.jpexs.decompiler.flash.BaseLocalData;
import com.jpexs.decompiler.flash.DisassemblyListener;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFInputStream;
@@ -757,9 +758,9 @@ public class Action implements GraphSourceItem {
}
@Override
- @SuppressWarnings("unchecked")
- public void translate(List localData, Stack stack, List output, int staticOperation, String path) throws InterruptedException {
- translate(stack, output, (HashMap) localData.get(0), (HashMap) localData.get(1), (HashMap) localData.get(2), staticOperation, path);
+ public void translate(BaseLocalData localData, Stack stack, List output, int staticOperation, String path) throws InterruptedException {
+ ActionLocalData aLocalData = (ActionLocalData) localData;
+ translate(stack, output, aLocalData.regNames, aLocalData.variables, aLocalData.functions, staticOperation, path);
}
@Override
@@ -823,10 +824,7 @@ public class Action implements GraphSourceItem {
if (start < actions.size() && (end > 0) && (start > 0)) {
log("Entering " + start + "-" + end + (actions.size() > 0 ? (" (" + actions.get(start).toString() + " - " + actions.get(end == actions.size() ? end - 1 : end) + ")") : ""));
}
- List localData = new ArrayList<>();
- localData.add(registerNames);
- localData.add(variables);
- localData.add(functions);
+ ActionLocalData localData = new ActionLocalData(registerNames, variables, functions);
List output = new ArrayList<>();
int ip = start;
boolean isWhile = false;
diff --git a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java
index 0e4b9c72d..beaf54898 100644
--- a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java
+++ b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java
@@ -16,6 +16,8 @@
*/
package com.jpexs.decompiler.flash.action;
+import com.jpexs.decompiler.flash.BaseLocalData;
+import com.jpexs.decompiler.flash.FinalProcessLocalData;
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
import com.jpexs.decompiler.flash.action.model.EnumerateActionItem;
import com.jpexs.decompiler.flash.action.model.FunctionActionItem;
@@ -48,9 +50,7 @@ import com.jpexs.decompiler.graph.model.SwitchItem;
import com.jpexs.decompiler.graph.model.WhileItem;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import java.util.Stack;
/**
@@ -72,8 +72,7 @@ public class ActionGraph extends Graph {
public static List translateViaGraph(HashMap registerNames, HashMap variables, HashMap functions, List code, int version, int staticOperation, String path) throws InterruptedException {
ActionGraph g = new ActionGraph(code, registerNames, variables, functions, version);
- List localData = new ArrayList<>();
- localData.add(registerNames);
+ ActionLocalData localData = new ActionLocalData(registerNames);
g.init(localData);
return g.translate(localData, staticOperation, path);
}
@@ -94,13 +93,8 @@ public class ActionGraph extends Graph {
}
@Override
- protected void finalProcess(List list, int level, List localData) {
+ protected void finalProcess(List list, int level, FinalProcessLocalData localData) {
- if (localData.isEmpty()) {
- localData.add(new HashSet()); //List of temporaryRegisters
- }
- @SuppressWarnings("unchecked")
- Set temporaryRegisters = (HashSet) localData.get(0);
List ret = Action.checkClass(list);
if (ret != list) {
list.clear();
@@ -253,7 +247,7 @@ public class ActionGraph extends Graph {
}
@Override
- protected List check(GraphSource code, List localData, List allParts, Stack stack, GraphPart parent, GraphPart part, List stopPart, List loops, List output, Loop currentLoop, int staticOperation, String path) throws InterruptedException {
+ protected List check(GraphSource code, BaseLocalData localData, List allParts, Stack stack, GraphPart parent, GraphPart part, List stopPart, List loops, List output, Loop currentLoop, int staticOperation, String path) throws InterruptedException {
if (!output.isEmpty()) {
if (output.get(output.size() - 1) instanceof StoreRegisterActionItem) {
StoreRegisterActionItem str = (StoreRegisterActionItem) output.get(output.size() - 1);
diff --git a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java
index f7082a2f2..ce0627438 100644
--- a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java
+++ b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java
@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.action;
+import com.jpexs.decompiler.flash.BaseLocalData;
import com.jpexs.decompiler.graph.GraphPart;
import com.jpexs.decompiler.graph.GraphSource;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -72,7 +73,7 @@ public class ActionGraphSource extends GraphSource {
}
@Override
- public List translatePart(GraphPart part, List localData, Stack stack, int start, int end, int staticOperation, String path) throws InterruptedException {
+ public List translatePart(GraphPart part, BaseLocalData localData, Stack stack, int start, int end, int staticOperation, String path) throws InterruptedException {
return (Action.actionsPartToTree(registerNames, variables, functions, stack, actions, start, end, version, staticOperation, path));
}
private List posCache = null;
diff --git a/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java b/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java
index a778c153d..a8942ff28 100644
--- a/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java
+++ b/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java
@@ -241,7 +241,7 @@ public class ActionListReader {
Stack stack = new Stack<>();
- List localData = Helper.toList(new HashMap(), new HashMap(), new HashMap());
+ ActionLocalData localData = new ActionLocalData();
int maxRecursionLevel = 0;
for (int i = 0; i < actions.size(); i++) {
@@ -256,7 +256,7 @@ public class ActionListReader {
}
}
- deobfustaceActionListAtPosRecursive(listeners, new ArrayList(), new HashMap>(), containerSWFOffset, localData, stack, cpool, actionMap, ip, ip, retdups, ip, endIp, path, new HashMap(), false, new HashMap>(), version, 0, maxRecursionLevel);
+ deobfustaceActionListAtPosRecursive(listeners, new ArrayList(), new HashMap>(), containerSWFOffset, localData, stack, cpool, actionMap, ip, retdups, ip, endIp, path, new HashMap(), false, new HashMap>(), version, 0, maxRecursionLevel);
if (!retdups.isEmpty()) {
for (int i = 0; i < ip; i++) {
@@ -585,7 +585,6 @@ public class ActionListReader {
return true;
}
- @SuppressWarnings("unchecked")
private static Action readActionListAtPos(List listeners, long containerSWFOffset, ConstantPool cpool,
SWFInputStream sis, List actions, List nextOffsets,
long ip, long startIp, long endIp, int version, String path, boolean indeterminate, List visitedContainers) throws IOException {
@@ -701,8 +700,7 @@ public class ActionListReader {
}
}
- @SuppressWarnings("unchecked")
- private static void deobfustaceActionListAtPosRecursive(List listeners, List output, HashMap> containers, long containerSWFOffset, List localData, Stack stack, ConstantPool cpool, List actions, int pos, int ip, List ret, int startIp, int endip, String path, Map visited, boolean indeterminate, Map> decisionStates, int version, int recursionLevel, int maxRecursionLevel) throws IOException, InterruptedException {
+ private static void deobfustaceActionListAtPosRecursive(List listeners, List output, HashMap> containers, long containerSWFOffset, ActionLocalData localData, Stack stack, ConstantPool cpool, List