diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index bda6b3af5..67c4a3070 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -1207,15 +1207,15 @@ public class AVM2Code implements Cloneable { private List ignoredIns; boolean isCatched = false; + /** + * Test for killed register. CalcKilledStats must be called before + * @param regName + * @param start + * @param end + * @return + */ public boolean isKilled(int regName, int start, int end) { - for (int k = start; k <= end; k++) { - if (code.get(k).definition instanceof KillIns) { - if (code.get(k).operands[0] == regName) { - return true; - } - } - } - return false; + return killedRegs.contains(regName); } private int toSourceCount = 0; @@ -1231,8 +1231,27 @@ public class AVM2Code implements Cloneable { return localRegNames; } - public List clearTemporaryRegisters(List output) { - for (int i = 0; i < output.size(); i++) { + private Set killedRegs=new HashSet(); + + public void calcKilledStats(MethodBody body){ + try { + HashMap> vis=visitCode(body); + for(int k=0;k clearTemporaryRegisters(List output) { + for (int i = 0; i < output.size(); i++) { if (output.get(i) instanceof SetLocalAVM2Item) { if (isKilled(((SetLocalAVM2Item) output.get(i)).regIndex, 0, code.size() - 1)) { SetLocalAVM2Item lsi = (SetLocalAVM2Item) output.get(i); @@ -1275,6 +1294,7 @@ public class AVM2Code implements Cloneable { } public ConvertOutput toSourceOutput(String path, GraphPart part, boolean processJumps, boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, TranslateStack stack, ScopeStack scopeStack, ABC abc, AVM2ConstantPool constants, List method_info, MethodBody body, int start, int end, HashMap localRegNames, List fullyQualifiedNames, boolean[] visited, HashMap localRegAssigmentIps, HashMap> refs) throws ConvertException, InterruptedException { + calcKilledStats(body); boolean debugMode = DEBUG_MODE; if (debugMode) { System.out.println("OPEN SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString()); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java index 1185059b7..bfca9af94 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.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.graph; import com.jpexs.decompiler.flash.BaseLocalData;