From 9a728060bd968104a2f08c960f4d6178ff71a5ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sat, 20 Apr 2013 15:28:01 +0200 Subject: [PATCH] AS3: Fixed pre/post increments/decrements --- .../abc/avm2/instructions/localregs/DecLocalIIns.java | 2 +- .../abc/avm2/instructions/localregs/DecLocalIns.java | 2 +- .../abc/avm2/instructions/localregs/IncLocalIIns.java | 2 +- .../abc/avm2/instructions/localregs/IncLocalIns.java | 2 +- .../avm2/instructions/localregs/SetLocalTypeIns.java | 2 +- .../abc/avm2/instructions/other/SetPropertyIns.java | 4 ++-- .../abc/avm2/treemodel/FullMultinameTreeItem.java | 8 ++++---- .../abc/avm2/treemodel/NotCompileTimeTreeItem.java | 11 ++++++++++- .../decompiler/flash/abc/avm2/treemodel/TreeItem.java | 2 +- .../jpexs/decompiler/flash/graph/GraphTargetItem.java | 4 ++++ .../jpexs/decompiler/flash/gui/proxy/ProxyFrame.java | 4 ++-- 11 files changed, 28 insertions(+), 15 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java index f8267a20e..eb2bd90dc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java @@ -61,7 +61,7 @@ public class DecLocalIIns extends InstructionDefinition { int regIndex = ins.operands[0]; output.add(new DecLocalTreeItem(ins, regIndex)); if (localRegs.containsKey(regIndex)) { - localRegs.put(regIndex, new NotCompileTimeTreeItem(ins)); + localRegs.put(regIndex, new NotCompileTimeTreeItem(ins, new SubtractTreeItem(ins, localRegs.get(regIndex), new IntegerValueTreeItem(ins, new Long(1))))); } else { localRegs.put(regIndex, new SubtractTreeItem(ins, localRegs.get(regIndex), new IntegerValueTreeItem(ins, new Long(1)))); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java index d45cdf689..dd37a0a81 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java @@ -61,7 +61,7 @@ public class DecLocalIns extends InstructionDefinition { int regIndex = ins.operands[0]; output.add(new DecLocalTreeItem(ins, regIndex)); if (localRegs.containsKey(regIndex)) { - localRegs.put(regIndex, new NotCompileTimeTreeItem(ins)); + localRegs.put(regIndex, new NotCompileTimeTreeItem(ins, new SubtractTreeItem(ins, localRegs.get(regIndex), new IntegerValueTreeItem(ins, new Long(1))))); } else { localRegs.put(regIndex, new SubtractTreeItem(ins, localRegs.get(regIndex), new IntegerValueTreeItem(ins, new Long(1)))); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java index 99b3fde4e..c318bcbf5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java @@ -41,7 +41,7 @@ public class IncLocalIIns extends InstructionDefinition { int regIndex = ins.operands[0]; output.add(new IncLocalTreeItem(ins, regIndex)); if (localRegs.containsKey(regIndex)) { - localRegs.put(regIndex, new NotCompileTimeTreeItem(ins)); + localRegs.put(regIndex, new NotCompileTimeTreeItem(ins, new AddTreeItem(ins, localRegs.get(regIndex), new IntegerValueTreeItem(ins, new Long(1))))); } else { localRegs.put(regIndex, new AddTreeItem(ins, localRegs.get(regIndex), new IntegerValueTreeItem(ins, new Long(1)))); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java index 542ddd131..99ad3982c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java @@ -41,7 +41,7 @@ public class IncLocalIns extends InstructionDefinition { int regIndex = ins.operands[0]; output.add(new IncLocalTreeItem(ins, regIndex)); if (localRegs.containsKey(regIndex)) { - localRegs.put(regIndex, new NotCompileTimeTreeItem(ins)); + localRegs.put(regIndex, new NotCompileTimeTreeItem(ins, new AddTreeItem(ins, localRegs.get(regIndex), new IntegerValueTreeItem(ins, new Long(1))))); } else { localRegs.put(regIndex, new AddTreeItem(ins, localRegs.get(regIndex), new IntegerValueTreeItem(ins, new Long(1)))); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java index 4dfdcb269..5973f7e01 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java @@ -50,7 +50,7 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S int regId = getRegisterId(ins); GraphTargetItem value = (GraphTargetItem) stack.pop(); if (localRegs.containsKey(regId)) { - localRegs.put(regId, new NotCompileTimeTreeItem(ins)); + localRegs.put(regId, new NotCompileTimeTreeItem(ins, value)); } else { localRegs.put(regId, value); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java index 77cf6d8f6..45d75bea8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java @@ -58,7 +58,7 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns if (insideProp.propertyName.compareSame(multiname)) { GraphTargetItem insideObj = obj; if (insideObj instanceof LocalRegTreeItem) { - insideObj = ((LocalRegTreeItem) insideObj).computedValue; + insideObj = ((LocalRegTreeItem) insideObj).computedValue.getThroughNotCompilable(); } if (insideProp.object == insideObj) { if (stack.size() > 0) { @@ -88,7 +88,7 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns if (insideProp.propertyName.compareSame(multiname)) { GraphTargetItem insideObj = obj; if (insideObj instanceof LocalRegTreeItem) { - insideObj = ((LocalRegTreeItem) insideObj).computedValue; + insideObj = ((LocalRegTreeItem) insideObj).computedValue.getThroughNotCompilable(); } if (insideProp.object == insideObj) { if (stack.size() > 0) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FullMultinameTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FullMultinameTreeItem.java index 6cbe0d12c..13df70855 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FullMultinameTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FullMultinameTreeItem.java @@ -98,12 +98,12 @@ public class FullMultinameTreeItem extends TreeItem { } GraphTargetItem tiName = name; while (tiName instanceof LocalRegTreeItem) { - tiName = ((LocalRegTreeItem) tiName).computedValue; + tiName = ((LocalRegTreeItem) tiName).computedValue.getThroughNotCompilable(); } GraphTargetItem tiName2 = other.name; while (tiName2 instanceof LocalRegTreeItem) { - tiName2 = ((LocalRegTreeItem) tiName2).computedValue; + tiName2 = ((LocalRegTreeItem) tiName2).computedValue.getThroughNotCompilable(); } if (tiName != tiName2) { return false; @@ -111,12 +111,12 @@ public class FullMultinameTreeItem extends TreeItem { GraphTargetItem tiNameSpace = namespace; while (tiNameSpace instanceof LocalRegTreeItem) { - tiNameSpace = ((LocalRegTreeItem) tiNameSpace).computedValue; + tiNameSpace = ((LocalRegTreeItem) tiNameSpace).computedValue.getThroughNotCompilable(); } GraphTargetItem tiNameSpace2 = other.namespace; while (tiNameSpace2 instanceof LocalRegTreeItem) { - tiNameSpace2 = ((LocalRegTreeItem) tiNameSpace2).computedValue; + tiNameSpace2 = ((LocalRegTreeItem) tiNameSpace2).computedValue.getThroughNotCompilable(); } if (tiNameSpace != tiNameSpace2) { return false; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NotCompileTimeTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NotCompileTimeTreeItem.java index c78ecca19..743367936 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NotCompileTimeTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NotCompileTimeTreeItem.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.graph.GraphSourceItem; +import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.HashMap; import java.util.List; @@ -27,8 +28,11 @@ import java.util.List; */ public class NotCompileTimeTreeItem extends TreeItem { - public NotCompileTimeTreeItem(GraphSourceItem instruction) { + public GraphTargetItem object; + + public NotCompileTimeTreeItem(GraphSourceItem instruction, GraphTargetItem object) { super(instruction, NOPRECEDENCE); + this.object = object; } @Override @@ -40,4 +44,9 @@ public class NotCompileTimeTreeItem extends TreeItem { public boolean isCompileTime() { return false; } + + @Override + public GraphTargetItem getThroughNotCompilable() { + return object.getThroughNotCompilable(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/TreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/TreeItem.java index 609f3843e..b6bfc1cbd 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/TreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/TreeItem.java @@ -78,7 +78,7 @@ public abstract class TreeItem extends GraphTargetItem { obStr = "(" + obStr + ")"; } if (object instanceof LocalRegTreeItem) { - if (((LocalRegTreeItem) object).computedValue instanceof FindPropertyTreeItem) { + if (((LocalRegTreeItem) object).computedValue.getThroughNotCompilable() instanceof FindPropertyTreeItem) { obStr = ""; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/GraphTargetItem.java b/trunk/src/com/jpexs/decompiler/flash/graph/GraphTargetItem.java index fa1b82f85..4bf940698 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/GraphTargetItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/GraphTargetItem.java @@ -141,4 +141,8 @@ public abstract class GraphTargetItem { public boolean isEmpty() { return false; } + + public GraphTargetItem getThroughNotCompilable() { + return this; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java index ea0bea0f3..3876d2579 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java @@ -154,8 +154,8 @@ public class ProxyFrame extends JFrame implements ActionListener, CatchedListene } }); java.util.List images = new ArrayList(); - images.add(View.loadImage("proxy16")); - images.add(View.loadImage("proxy32")); + images.add(View.loadImage("proxy16")); + images.add(View.loadImage("proxy32")); setIconImages(images); }