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 f09750070..166c2d205 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -50,6 +50,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.graph.Graph; +import com.jpexs.decompiler.flash.graph.GraphPart; import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphSourceItemPos; import com.jpexs.decompiler.flash.graph.GraphTargetItem; @@ -1032,7 +1033,7 @@ public class AVM2Code implements Serializable { return pos2adr(fixIPAfterDebugLine(adr2pos(addr))); } - public ConvertOutput toSourceOutput(boolean processJumps, boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, int start, int end, HashMap localRegNames, List fullyQualifiedNames, boolean visited[]) throws ConvertException { + public ConvertOutput toSourceOutput(GraphPart part, boolean processJumps, boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, int start, int end, HashMap localRegNames, List fullyQualifiedNames, boolean visited[]) throws ConvertException { boolean debugMode = DEBUG_MODE; if (debugMode) { System.out.println("OPEN SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString()); @@ -1064,101 +1065,6 @@ public class AVM2Code implements Serializable { int ipfix = fixIPAfterDebugLine(ip); int addrfix = pos2adr(ipfix); int maxend = -1; - if (processTry) { - List catchedExceptions = new ArrayList(); - for (int e = 0; e < body.exceptions.length; e++) { - if (addrfix == fixAddrAfterDebugLine(body.exceptions[e].start)) { - if (!body.exceptions[e].isFinally()) { - if ((fixAddrAfterDebugLine(body.exceptions[e].end) > maxend) && (!parsedExceptions.contains(body.exceptions[e]))) { - catchedExceptions.clear(); - maxend = fixAddrAfterDebugLine(body.exceptions[e].end); - catchedExceptions.add(body.exceptions[e]); - } else if (fixAddrAfterDebugLine(body.exceptions[e].end) == maxend) { - catchedExceptions.add(body.exceptions[e]); - } - } - } - } - if (catchedExceptions.size() > 0) { - ip = ipfix; - addr = addrfix; - parsedExceptions.addAll(catchedExceptions); - int endpos = adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(0).end)); - - - List> catchedCommands = new ArrayList>(); - if (code.get(endpos).definition instanceof JumpIns) { - int afterCatchAddr = pos2adr(endpos + 1) + code.get(endpos).operands[0]; - int afterCatchPos = adr2pos(afterCatchAddr); - Collections.sort(catchedExceptions, new Comparator() { - @Override - public int compare(ABCException o1, ABCException o2) { - try { - return fixAddrAfterDebugLine(o1.target) - fixAddrAfterDebugLine(o2.target); - } catch (ConvertException ex) { - return 0; - } - } - }); - - - List finallyCommands = new ArrayList(); - int returnPos = afterCatchPos; - for (int e = 0; e < body.exceptions.length; e++) { - if (body.exceptions[e].isFinally()) { - if (addr == fixAddrAfterDebugLine(body.exceptions[e].start)) { - if (afterCatchPos + 1 == adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end))) { - AVM2Instruction jmpIns = code.get(adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end))); - if (jmpIns.definition instanceof JumpIns) { - int finStart = adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]); - finallyJumps.add(finStart); - if (unknownJumps.contains(finStart)) { - unknownJumps.remove((Integer) finStart); - } - for (int f = finStart; f <= end; f++) { - if (code.get(f).definition instanceof LookupSwitchIns) { - AVM2Instruction swins = code.get(f); - if (swins.operands.length >= 3) { - if (swins.operands[0] == swins.getBytes().length) { - if (adr2pos(pos2adr(f) + swins.operands[2]) < finStart) { - finallyCommands = toSourceOutput(processJumps, isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, finStart, f - 1, localRegNames, fullyQualifiedNames, visited).output; - returnPos = f + 1; - break; - } - } - } - } - } - - break; - } - } - } - } - } - - for (int e = 0; e < catchedExceptions.size(); e++) { - int eendpos; - if (e < catchedExceptions.size() - 1) { - eendpos = adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(e + 1).target)) - 2; - } else { - eendpos = afterCatchPos - 1; - } - Stack substack = new Stack(); - substack.add(new ExceptionTreeItem(catchedExceptions.get(e))); - catchedCommands.add(toSourceOutput(processJumps, isStatic, scriptIndex, classIndex, localRegs, substack, new Stack(), abc, constants, method_info, body, adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(e).target)), eendpos, localRegNames, fullyQualifiedNames, visited).output); - } - - List tryCommands = toSourceOutput(processJumps, isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip, endpos - 1, localRegNames, fullyQualifiedNames, visited).output; - - - output.add(new TryTreeItem(tryCommands, catchedExceptions, catchedCommands, finallyCommands)); - ip = returnPos; - addr = pos2adr(ip); - } - - } - } if (ip > end) { break; @@ -1277,8 +1183,10 @@ public class AVM2Code implements Serializable { if (((GetLocalTypeIns) code.get(t).definition).getRegisterId(code.get(t)) == reg) { if (code.get(t + 1).definition instanceof KillIns) { if (code.get(t + 1).operands[0] == reg) { - ConvertOutput assignment = toSourceOutput(processJumps, isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip + 2, t - 1, localRegNames, fullyQualifiedNames, visited); - stack.push(assignment.output.remove(assignment.output.size() - 1)); + ConvertOutput assignment = toSourceOutput(part, processJumps, isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip + 2, t - 1, localRegNames, fullyQualifiedNames, visited); + GraphTargetItem tar = assignment.output.remove(assignment.output.size() - 1); + tar.firstPart = part; + stack.push(tar); ip = t + 2; continue iploop; } 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 e47be8386..4c2618eca 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 @@ -4,6 +4,7 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.ConvertOutput; import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.graph.GraphPart; import com.jpexs.decompiler.flash.graph.GraphSource; import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; @@ -62,9 +63,9 @@ public class AVM2GraphSource extends GraphSource { } @Override - public List translatePart(List localData, Stack stack, int start, int end) { + public List translatePart(GraphPart part, List localData, Stack stack, int start, int end) { List ret = new ArrayList(); - ConvertOutput co = code.toSourceOutput(false, isStatic, scriptIndex, classIndex, localRegs, stack, (Stack) localData.get(AVM2Graph.DATA_SCOPESTACK), abc, abc.constants, abc.method_info, body, start, end, localRegNames, fullyQualifiedNames, new boolean[size()]); + ConvertOutput co = code.toSourceOutput(part, false, isStatic, scriptIndex, classIndex, localRegs, stack, (Stack) localData.get(AVM2Graph.DATA_SCOPESTACK), abc, abc.constants, abc.method_info, body, start, end, localRegNames, fullyQualifiedNames, new boolean[size()]); ret.addAll(co.output); return ret; } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CoerceTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CoerceTreeItem.java index 3572ce636..8e5463158 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CoerceTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CoerceTreeItem.java @@ -24,7 +24,7 @@ import java.util.List; public class CoerceTreeItem extends TreeItem { - public GraphTargetItem value; + //public GraphTargetItem value; public String type; public CoerceTreeItem(AVM2Instruction instruction, GraphTargetItem value, String type) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConvertTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConvertTreeItem.java index d4e267c9a..b97919107 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConvertTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConvertTreeItem.java @@ -24,7 +24,7 @@ import java.util.List; public class ConvertTreeItem extends TreeItem { - public GraphTargetItem value; + //public GraphTargetItem value; public String type; public ConvertTreeItem(AVM2Instruction instruction, GraphTargetItem value, String type) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/InitPropertyTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/InitPropertyTreeItem.java index e0ce28c64..24102075d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/InitPropertyTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/InitPropertyTreeItem.java @@ -27,7 +27,7 @@ public class InitPropertyTreeItem extends TreeItem implements SetTypeTreeItem, A public GraphTargetItem object; public FullMultinameTreeItem propertyName; - public GraphTargetItem value; + //public GraphTargetItem value; public InitPropertyTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem propertyName, GraphTargetItem value) { super(instruction, PRECEDENCE_ASSIGMENT); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NameValuePair.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NameValuePair.java index e63ab050a..847c1553a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NameValuePair.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NameValuePair.java @@ -24,7 +24,7 @@ import java.util.List; public class NameValuePair extends TreeItem { public GraphTargetItem name; - public GraphTargetItem value; + //public GraphTargetItem value; public NameValuePair(GraphTargetItem name, GraphTargetItem value) { super(name.src, NOPRECEDENCE); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ReturnValueTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ReturnValueTreeItem.java index fd34137e8..d8002735d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ReturnValueTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ReturnValueTreeItem.java @@ -25,8 +25,7 @@ import java.util.List; public class ReturnValueTreeItem extends TreeItem implements ExitItem { - public GraphTargetItem value; - + //public GraphTargetItem value; public ReturnValueTreeItem(AVM2Instruction instruction, GraphTargetItem value) { super(instruction, NOPRECEDENCE); this.value = value; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetGlobalSlotTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetGlobalSlotTreeItem.java index 99e5ae945..c1398fe9e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetGlobalSlotTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetGlobalSlotTreeItem.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.GraphPart; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.HashMap; import java.util.List; @@ -25,7 +26,12 @@ import java.util.List; public class SetGlobalSlotTreeItem extends TreeItem { public int slotId; - public GraphTargetItem value; + //public GraphTargetItem value; + + @Override + public GraphPart getFirstPart() { + return value.getFirstPart(); + } public SetGlobalSlotTreeItem(AVM2Instruction instruction, int slotId, GraphTargetItem value) { super(instruction, PRECEDENCE_ASSIGMENT); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetLocalTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetLocalTreeItem.java index 366cdbc35..28cff8fa8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetLocalTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetLocalTreeItem.java @@ -26,7 +26,7 @@ import java.util.List; public class SetLocalTreeItem extends TreeItem implements SetTypeTreeItem, AssignmentTreeItem { public int regIndex; - public GraphTargetItem value; + //public GraphTargetItem value; public SetLocalTreeItem(AVM2Instruction instruction, int regIndex, GraphTargetItem value) { super(instruction, PRECEDENCE_ASSIGMENT); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetPropertyTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetPropertyTreeItem.java index 23f6f3ad1..ac3fbaf3b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetPropertyTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetPropertyTreeItem.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.treemodel.clauses.AssignmentTreeItem; +import com.jpexs.decompiler.flash.graph.GraphPart; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.HashMap; import java.util.List; @@ -29,6 +30,11 @@ public class SetPropertyTreeItem extends TreeItem implements SetTypeTreeItem, As public FullMultinameTreeItem propertyName; public GraphTargetItem value; + @Override + public GraphPart getFirstPart() { + return value.getFirstPart(); + } + public SetPropertyTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem propertyName, GraphTargetItem value) { super(instruction, PRECEDENCE_ASSIGMENT); this.object = object; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetSlotTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetSlotTreeItem.java index 5ee51cc28..f9ceab1ed 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetSlotTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetSlotTreeItem.java @@ -20,6 +20,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.treemodel.clauses.AssignmentTreeItem; import com.jpexs.decompiler.flash.abc.types.Multiname; +import com.jpexs.decompiler.flash.graph.GraphPart; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.HashMap; import java.util.List; @@ -27,7 +28,7 @@ import java.util.List; public class SetSlotTreeItem extends TreeItem implements SetTypeTreeItem, AssignmentTreeItem { public Multiname slotName; - public GraphTargetItem value; + //public GraphTargetItem value; public GraphTargetItem scope; public SetSlotTreeItem(AVM2Instruction instruction, GraphTargetItem scope, Multiname slotName, GraphTargetItem value) { @@ -37,6 +38,11 @@ public class SetSlotTreeItem extends TreeItem implements SetTypeTreeItem, Assign this.scope = scope; } + @Override + public GraphPart getFirstPart() { + return value.getFirstPart(); + } + @Override public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetSuperTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetSuperTreeItem.java index 7e0a75ec4..f65fd0533 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetSuperTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetSuperTreeItem.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.treemodel; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.graph.GraphPart; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.helpers.Highlighting; import java.util.HashMap; @@ -25,10 +26,15 @@ import java.util.List; public class SetSuperTreeItem extends TreeItem { - public GraphTargetItem value; + //public GraphTargetItem value; public GraphTargetItem object; public FullMultinameTreeItem propertyName; + @Override + public GraphPart getFirstPart() { + return value.getFirstPart(); + } + public SetSuperTreeItem(AVM2Instruction instruction, GraphTargetItem value, GraphTargetItem object, FullMultinameTreeItem propertyName) { super(instruction, PRECEDENCE_ASSIGMENT); this.value = value; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ThrowTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ThrowTreeItem.java index 80f6ebad9..891b1c724 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ThrowTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ThrowTreeItem.java @@ -24,8 +24,7 @@ import java.util.List; public class ThrowTreeItem extends TreeItem { - public GraphTargetItem value; - + //public GraphTargetItem value; public ThrowTreeItem(AVM2Instruction instruction, GraphTargetItem value) { super(instruction, NOPRECEDENCE); this.value = value; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java index 35645fd9c..55b9abb53 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java @@ -1,5 +1,6 @@ package com.jpexs.decompiler.flash.action; +import com.jpexs.decompiler.flash.graph.GraphPart; import com.jpexs.decompiler.flash.graph.GraphSource; import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; @@ -55,7 +56,7 @@ public class ActionGraphSource extends GraphSource { } @Override - public List translatePart(List localData, Stack stack, int start, int end) { + public List translatePart(GraphPart part, List localData, Stack stack, int start, int end) { return (Action.actionsPartToTree(registerNames, variables, functions, stack, actions, start, end, version)); } private List posCache = null; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/DefineLocalTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/DefineLocalTreeItem.java index b375cb43b..3eaddf3b6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/DefineLocalTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/DefineLocalTreeItem.java @@ -23,7 +23,7 @@ import java.util.List; public class DefineLocalTreeItem extends TreeItem implements SetTypeTreeItem { public GraphTargetItem name; - public GraphTargetItem value; + //public GraphTargetItem value; private int tempRegister = -1; @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/MBStringExtractTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/MBStringExtractTreeItem.java index eee36cb26..f07b53c78 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/MBStringExtractTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/MBStringExtractTreeItem.java @@ -22,7 +22,7 @@ import java.util.List; public class MBStringExtractTreeItem extends TreeItem { - public GraphTargetItem value; + //public GraphTargetItem value; public GraphTargetItem index; public GraphTargetItem count; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/MBStringLengthTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/MBStringLengthTreeItem.java index 5100f56d5..40be92108 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/MBStringLengthTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/MBStringLengthTreeItem.java @@ -22,8 +22,7 @@ import java.util.List; public class MBStringLengthTreeItem extends TreeItem { - public GraphTargetItem value; - + //public GraphTargetItem value; public MBStringLengthTreeItem(GraphSourceItem instruction, GraphTargetItem value) { super(instruction, PRECEDENCE_PRIMARY); this.value = value; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/ReturnTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/ReturnTreeItem.java index 114f41314..78810f784 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/ReturnTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/ReturnTreeItem.java @@ -23,8 +23,7 @@ import java.util.List; public class ReturnTreeItem extends TreeItem implements ExitItem { - public GraphTargetItem value; - + //public GraphTargetItem value; public ReturnTreeItem(GraphSourceItem instruction, GraphTargetItem value) { super(instruction, PRECEDENCE_PRIMARY); this.value = value; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/SetMemberTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/SetMemberTreeItem.java index 17df7f2cc..28ff54cbe 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/SetMemberTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/SetMemberTreeItem.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.action.treemodel; +import com.jpexs.decompiler.flash.graph.GraphPart; import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import static com.jpexs.decompiler.flash.graph.GraphTargetItem.PRECEDENCE_ASSIGMENT; @@ -25,9 +26,14 @@ public class SetMemberTreeItem extends TreeItem implements SetTypeTreeItem { public GraphTargetItem object; public GraphTargetItem objectName; - public GraphTargetItem value; + //public GraphTargetItem value; private int tempRegister = -1; + @Override + public GraphPart getFirstPart() { + return value.getFirstPart(); + } + @Override public void setValue(GraphTargetItem value) { this.value = value; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/SetPropertyTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/SetPropertyTreeItem.java index e8eb0dbf7..656c35853 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/SetPropertyTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/SetPropertyTreeItem.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.action.treemodel; import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.graph.GraphPart; import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import static com.jpexs.decompiler.flash.graph.GraphTargetItem.PRECEDENCE_ASSIGMENT; @@ -26,7 +27,12 @@ public class SetPropertyTreeItem extends TreeItem implements SetTypeTreeItem { public GraphTargetItem target; public int propertyIndex; - public GraphTargetItem value; + //public GraphTargetItem value; + + @Override + public GraphPart getFirstPart() { + return value.getFirstPart(); + } @Override public void setValue(GraphTargetItem value) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/SetVariableTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/SetVariableTreeItem.java index c3d0dbbea..b0cdfaed6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/SetVariableTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/SetVariableTreeItem.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.action.treemodel; +import com.jpexs.decompiler.flash.graph.GraphPart; import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import static com.jpexs.decompiler.flash.graph.GraphTargetItem.PRECEDENCE_ASSIGMENT; @@ -24,9 +25,14 @@ import java.util.List; public class SetVariableTreeItem extends TreeItem implements SetTypeTreeItem { public GraphTargetItem name; - public GraphTargetItem value; + //public GraphTargetItem value; private int tempRegister = -1; + @Override + public GraphPart getFirstPart() { + return value.getFirstPart(); + } + @Override public void setValue(GraphTargetItem value) { this.value = value; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/StoreRegisterTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/StoreRegisterTreeItem.java index b911defb5..b6078b743 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/StoreRegisterTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/StoreRegisterTreeItem.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.action.treemodel; import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; +import com.jpexs.decompiler.flash.graph.GraphPart; import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.List; @@ -24,9 +25,14 @@ import java.util.List; public class StoreRegisterTreeItem extends TreeItem implements SetTypeTreeItem { public RegisterNumber register; - public GraphTargetItem value; + //public GraphTargetItem value; public boolean define = false; + @Override + public GraphPart getFirstPart() { + return value.getFirstPart(); + } + @Override public void setValue(GraphTargetItem value) { this.value = value; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/StringExtractTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/StringExtractTreeItem.java index dadf3194a..6bb355bb4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/StringExtractTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/StringExtractTreeItem.java @@ -22,7 +22,7 @@ import java.util.List; public class StringExtractTreeItem extends TreeItem { - public GraphTargetItem value; + //public GraphTargetItem value; public GraphTargetItem index; public GraphTargetItem count; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/operations/StringLengthTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/operations/StringLengthTreeItem.java index 2d2d95127..b5cfe97ef 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/operations/StringLengthTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/operations/StringLengthTreeItem.java @@ -23,8 +23,7 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class StringLengthTreeItem extends TreeItem { - public GraphTargetItem value; - + //public GraphTargetItem value; public StringLengthTreeItem(GraphSourceItem instruction, GraphTargetItem value) { super(instruction, PRECEDENCE_PRIMARY); this.value = value; diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/AndItem.java b/trunk/src/com/jpexs/decompiler/flash/graph/AndItem.java index 3de98b6ef..a685abc9f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/AndItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/AndItem.java @@ -20,18 +20,6 @@ import java.util.List; public class AndItem extends BinaryOpItem { - public GraphPart firstPart; - - public GraphPart getFirstPart() { - if (leftSide instanceof AndItem) { - return ((AndItem) leftSide).getFirstPart(); - } - if (leftSide instanceof OrItem) { - return ((OrItem) leftSide).getFirstPart(); - } - return firstPart; - } - @Override public List getNeededSources() { List ret = super.getNeededSources(); diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/BinaryOpItem.java b/trunk/src/com/jpexs/decompiler/flash/graph/BinaryOpItem.java index cf0d6c8ff..ab506abd5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/BinaryOpItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/BinaryOpItem.java @@ -24,6 +24,15 @@ public abstract class BinaryOpItem extends GraphTargetItem { public GraphTargetItem rightSide; protected String operator = ""; + @Override + public GraphPart getFirstPart() { + GraphPart fp = leftSide.getFirstPart(); + if (fp == null) { + return super.getFirstPart(); + } + return fp; + } + public BinaryOpItem(GraphSourceItem instruction, int precedence, GraphTargetItem leftSide, GraphTargetItem rightSide, String operator) { super(instruction, precedence); this.leftSide = leftSide; diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java b/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java index 5b46cb73b..52785d704 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java @@ -463,7 +463,7 @@ public class Graph { } end = p.end; int start = p.start; - ret.addAll(code.translatePart(localData, stack, start, end)); + ret.addAll(code.translatePart(part, localData, stack, start, end)); } return ret; } @@ -536,7 +536,7 @@ public class Graph { }*/ try { - output.addAll(code.translatePart(localData, stack, start, end)); + output.addAll(code.translatePart(p, localData, stack, start, end)); } catch (Exception ex) { Logger.getLogger(Graph.class.getName()).log(Level.SEVERE, "error during printgraph", ex); return ret; @@ -824,11 +824,9 @@ public class Graph { ret.addAll(output); } if (loop) { - if (expr instanceof AndItem) { - currentLoop.loopContinue = ((AndItem) expr).getFirstPart(); - } - if (expr instanceof OrItem) { - currentLoop.loopContinue = ((OrItem) expr).getFirstPart(); + GraphPart f = expr.getFirstPart(); + if (f != null) { + currentLoop.loopContinue = f; } } GraphPart loopBodyStart = null; diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/GraphSource.java b/trunk/src/com/jpexs/decompiler/flash/graph/GraphSource.java index cd7bd3d40..16c581f3b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/GraphSource.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/GraphSource.java @@ -18,7 +18,7 @@ public abstract class GraphSource { public abstract boolean isEmpty(); - public abstract List translatePart(List localData, Stack stack, int start, int end); + public abstract List translatePart(GraphPart part, List localData, Stack stack, int start, int end); private void visitCode(int ip, int lastIp, HashMap> refs, int endIp) { boolean debugMode = false; diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/GraphTargetItem.java b/trunk/src/com/jpexs/decompiler/flash/graph/GraphTargetItem.java index 4bf940698..96f25f0a2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/GraphTargetItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/GraphTargetItem.java @@ -31,6 +31,19 @@ public abstract class GraphTargetItem { public int pos = 0; public int precedence; public List moreSrc = new ArrayList(); + public GraphPart firstPart; + public GraphTargetItem value; + + public GraphPart getFirstPart() { + if (value == null) { + return firstPart; + } + GraphPart ret = value.getFirstPart(); + if (ret == null) { + return firstPart; + } + return ret; + } public GraphTargetItem(GraphSourceItem src, int precedence) { this.src = src; diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/OrItem.java b/trunk/src/com/jpexs/decompiler/flash/graph/OrItem.java index e127d20bf..08a75ee27 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/OrItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/OrItem.java @@ -20,18 +20,6 @@ import java.util.List; public class OrItem extends BinaryOpItem { - public GraphPart firstPart; - - public GraphPart getFirstPart() { - if (leftSide instanceof AndItem) { - return ((AndItem) leftSide).getFirstPart(); - } - if (leftSide instanceof OrItem) { - return ((OrItem) leftSide).getFirstPart(); - } - return firstPart; - } - public OrItem(GraphSourceItem src, GraphTargetItem leftSide, GraphTargetItem rightSide) { super(src, PRECEDENCE_LOGICALOR, leftSide, rightSide, "||"); this.leftSide = leftSide;