mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-19 11:48:08 +00:00
AS1/2 better handling chained assignments/preincrement
This commit is contained in:
@@ -193,7 +193,7 @@ public class ActionPush extends Action {
|
||||
case ASMParsedSymbol.TYPE_COMMENT:
|
||||
break;
|
||||
default:
|
||||
throw new ParseException("Arguments expected", lexer.yyline());
|
||||
throw new ParseException("Arguments expected, "+symb.type+" "+symb.value+" found", lexer.yyline());
|
||||
|
||||
|
||||
}
|
||||
@@ -289,7 +289,7 @@ public class ActionPush extends Action {
|
||||
o = constantPool.get(((ConstantIndex) o).index);
|
||||
}
|
||||
}
|
||||
if (o instanceof RegisterNumber) {
|
||||
/*if (o instanceof RegisterNumber) {
|
||||
if (regNames.containsKey(((RegisterNumber) o).number)) {
|
||||
((RegisterNumber) o).name = regNames.get(((RegisterNumber) o).number);
|
||||
} else if (output.size() >= 2) { //chained assignments:, ignore for class prototype assignment
|
||||
@@ -306,7 +306,8 @@ public class ActionPush extends Action {
|
||||
} else if ((stt.getValue() instanceof DecrementTreeItem) && (((DecrementTreeItem) stt.getValue()).object.equals(stt.getObject()))) {
|
||||
stack.push(new PreDecrementTreeItem(this, stt.getObject()));
|
||||
} else {
|
||||
stack.push(last);
|
||||
//stack.push(last);
|
||||
continue;
|
||||
}
|
||||
output.remove(output.size() - 1);
|
||||
output.remove(output.size() - 1);
|
||||
@@ -316,7 +317,7 @@ public class ActionPush extends Action {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
DirectValueTreeItem dvt = new DirectValueTreeItem(this, pos, o, constantPool);
|
||||
stack.push(dvt);
|
||||
if (o instanceof RegisterNumber) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.action.treemodel.IncrementTreeItem;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.PostDecrementTreeItem;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.PostIncrementTreeItem;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.SetPropertyTreeItem;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.StoreRegisterTreeItem;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -70,6 +71,9 @@ public class ActionSetProperty extends Action {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(value instanceof StoreRegisterTreeItem){
|
||||
((StoreRegisterTreeItem)value).define=false;
|
||||
}
|
||||
output.add(new SetPropertyTreeItem(this, target, indexInt, value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.action.treemodel.IncrementTreeItem;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.PostDecrementTreeItem;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.PostIncrementTreeItem;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.SetVariableTreeItem;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.StoreRegisterTreeItem;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.flash.helpers.Highlighting;
|
||||
import java.util.HashMap;
|
||||
@@ -82,6 +83,9 @@ public class ActionSetVariable extends Action {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(value instanceof StoreRegisterTreeItem){
|
||||
((StoreRegisterTreeItem)value).define=false;
|
||||
}
|
||||
SetVariableTreeItem svt = new SetVariableTreeItem(this, name, value);
|
||||
output.add(svt);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.action.treemodel.IncrementTreeItem;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.PostDecrementTreeItem;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.PostIncrementTreeItem;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.SetMemberTreeItem;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.StoreRegisterTreeItem;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -85,6 +86,9 @@ public class ActionSetMember extends Action {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(value instanceof StoreRegisterTreeItem){
|
||||
((StoreRegisterTreeItem)value).define=false;
|
||||
}
|
||||
output.add(new SetMemberTreeItem(this, object, memberName, value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.parser.ParseException;
|
||||
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
|
||||
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.DirectValueTreeItem;
|
||||
import com.jpexs.decompiler.flash.action.treemodel.StoreRegisterTreeItem;
|
||||
import com.jpexs.decompiler.flash.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.flash.graph.GraphTargetItem;
|
||||
@@ -69,7 +70,7 @@ public class ActionStoreRegister extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Stack<GraphTargetItem> stack, List<GraphTargetItem> output, java.util.HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
|
||||
GraphTargetItem item = stack.peek();
|
||||
GraphTargetItem item = stack.pop();
|
||||
RegisterNumber rn = new RegisterNumber(registerNumber);
|
||||
if (regNames.containsKey(registerNumber)) {
|
||||
rn.name = regNames.get(registerNumber);
|
||||
@@ -77,6 +78,20 @@ public class ActionStoreRegister extends Action {
|
||||
item.moreSrc.add(new GraphSourceItemPos(this, 0));
|
||||
boolean define = !variables.containsKey("__register" + registerNumber);
|
||||
variables.put("__register" + registerNumber, item);
|
||||
output.add(new StoreRegisterTreeItem(this, rn, item, define));
|
||||
if(item instanceof DirectValueTreeItem){
|
||||
if(((DirectValueTreeItem)item).value instanceof RegisterNumber){
|
||||
if(((RegisterNumber)((DirectValueTreeItem)item).value).number==registerNumber){
|
||||
stack.push(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(item instanceof StoreRegisterTreeItem){
|
||||
if(((StoreRegisterTreeItem)item).register.number==registerNumber){
|
||||
stack.push(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
stack.push(new StoreRegisterTreeItem(this, rn, item, define));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user