AS1/2 chained assignments decompilation

This commit is contained in:
Jindra Petk
2013-04-13 11:46:47 +02:00
parent 70476ef3c5
commit ab9a438ed5
2 changed files with 27 additions and 1 deletions

View File

@@ -23,6 +23,8 @@ import com.jpexs.decompiler.flash.action.parser.ParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.treemodel.DirectValueTreeItem;
import com.jpexs.decompiler.flash.action.treemodel.SetTypeTreeItem;
import com.jpexs.decompiler.flash.action.treemodel.StoreRegisterTreeItem;
import com.jpexs.decompiler.flash.graph.GraphSourceItem;
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
import com.jpexs.decompiler.flash.helpers.Helper;
@@ -249,7 +251,21 @@ public class ActionPush extends Action {
}
if (o instanceof RegisterNumber) {
if (regNames.containsKey(((RegisterNumber) o).number)) {
((RegisterNumber) o).name = regNames.get(((RegisterNumber) o).number);
((RegisterNumber) o).name = regNames.get(((RegisterNumber) o).number);
}else if(output.size()>=2){ //chained assignments:
GraphTargetItem last=output.get(output.size()-1);
GraphTargetItem prev=output.get(output.size()-2);
if(last instanceof SetTypeTreeItem ){
if(prev instanceof StoreRegisterTreeItem){
StoreRegisterTreeItem str=(StoreRegisterTreeItem)prev;
if(str.register.number==((RegisterNumber) o).number){
stack.push(output.remove(output.size()-1));
output.remove(output.size()-1);
pos++;
continue;
}
}
}
}
}
DirectValueTreeItem dvt = new DirectValueTreeItem(this, pos, o, constantPool);

View File

@@ -47,6 +47,16 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta
public List<String> constantPool;
private long hdrSize;
public ActionDefineFunction(String functionName, List<String> paramNames, int codeSize, int version) {
super(0x9B, 0);
this.functionName = functionName;
this.codeSize = codeSize;
this.version = version;
this.paramNames=paramNames;
}
public ActionDefineFunction(int actionLength, SWFInputStream sis, ReReadableInputStream rri, int version) throws IOException {
super(0x9B, actionLength);
this.version = version;