AS3: Fixed pre/post increments/decrements

This commit is contained in:
Jindra Petk
2013-04-20 15:28:01 +02:00
parent ab9275b53f
commit 9a728060bd
11 changed files with 28 additions and 15 deletions

View File

@@ -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))));
}

View File

@@ -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))));
}

View File

@@ -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))));
}

View File

@@ -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))));
}

View File

@@ -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);
}

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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();
}
}

View File

@@ -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 = "";
}
}

View File

@@ -141,4 +141,8 @@ public abstract class GraphTargetItem {
public boolean isEmpty() {
return false;
}
public GraphTargetItem getThroughNotCompilable() {
return this;
}
}

View File

@@ -154,8 +154,8 @@ public class ProxyFrame extends JFrame implements ActionListener, CatchedListene
}
});
java.util.List<Image> images = new ArrayList<Image>();
images.add(View.loadImage("proxy16"));
images.add(View.loadImage("proxy32"));
images.add(View.loadImage("proxy16"));
images.add(View.loadImage("proxy32"));
setIconImages(images);
}