mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-31 11:44:36 +00:00
Fixed: #2322 More AS3 Assigment position when using dup
This commit is contained in:
@@ -116,6 +116,7 @@ import com.jpexs.decompiler.graph.model.NotItem;
|
||||
import com.jpexs.decompiler.graph.model.OrItem;
|
||||
import com.jpexs.decompiler.graph.model.PushItem;
|
||||
import com.jpexs.decompiler.graph.model.SwitchItem;
|
||||
import com.jpexs.decompiler.graph.model.TrueItem;
|
||||
import com.jpexs.decompiler.graph.model.WhileItem;
|
||||
import com.jpexs.helpers.Reference;
|
||||
import java.util.ArrayList;
|
||||
@@ -2424,17 +2425,8 @@ public class AVM2Graph extends Graph {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Final process.
|
||||
*
|
||||
* @param list List of GraphTargetItems
|
||||
* @param level Level
|
||||
* @param localData Local data
|
||||
* @param path Path
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
protected void finalProcess(List<GraphTargetItem> list, int level, FinalProcessLocalData localData, String path) throws InterruptedException {
|
||||
protected void finalProcess(GraphTargetItem parent, List<GraphTargetItem> list, int level, FinalProcessLocalData localData, String path) throws InterruptedException {
|
||||
if (debugDoNotProcess) {
|
||||
return;
|
||||
}
|
||||
@@ -2655,6 +2647,7 @@ public class AVM2Graph extends Graph {
|
||||
AVM2FinalProcessLocalData adata = (AVM2FinalProcessLocalData) localData;
|
||||
//if(false)
|
||||
if (!adata.bottomSetLocals.isEmpty()) {
|
||||
boolean modified = false;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
|
||||
if (list.get(i) instanceof LoopItem) {
|
||||
@@ -2664,7 +2657,7 @@ public class AVM2Graph extends Graph {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference<SetLocalAVM2Item> foundSetLoc = new Reference<>(null);
|
||||
List<SetLocalAVM2Item> foundSetLoc = new ArrayList<>();
|
||||
List<SetLocalAVM2Item> ignoredItems = new ArrayList<>();
|
||||
|
||||
//We need to ignore everything on the right side of && and ||,
|
||||
@@ -2706,26 +2699,45 @@ public class AVM2Graph extends Graph {
|
||||
GraphTargetItem parent = parentStack.get(s);
|
||||
boolean move = true;
|
||||
if (parent instanceof SetTypeAVM2Item) {
|
||||
SetTypeAVM2Item setType = (SetTypeAVM2Item) parent;
|
||||
if (setType.getValue().getNotCoerced() == item || setType.getObject() == item) { //chained assignment
|
||||
move = false;
|
||||
SetTypeAVM2Item setType = (SetTypeAVM2Item) parent;
|
||||
|
||||
if (setType.getValue().getNotCoerced() == item) { //chained assignment
|
||||
//if (!((parent instanceof SetLocalAVM2Item)
|
||||
// && ((SetLocalAVM2Item)parent).regIndex == ((SetLocalAVM2Item) item).regIndex)) { //no chain for the same localreg
|
||||
move = false;
|
||||
}
|
||||
}
|
||||
if (move) {
|
||||
foundSetLoc.setVal((SetLocalAVM2Item) item);
|
||||
foundSetLoc.add(0, (SetLocalAVM2Item) item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (foundSetLoc.getVal() != null) {
|
||||
SetLocalAVM2Item setLoc = foundSetLoc.getVal();
|
||||
for (SetLocalAVM2Item setLoc : foundSetLoc) {
|
||||
list.add(i, setLoc.clone());
|
||||
setLoc.hideValue = true;
|
||||
setLoc.hideValue = true;
|
||||
i++;
|
||||
modified = true;
|
||||
adata.bottomSetLocals.remove(setLoc);
|
||||
}
|
||||
}
|
||||
if (modified && (parent instanceof WhileItem)) {
|
||||
WhileItem wi = (WhileItem) parent;
|
||||
if (wi.expression == list && !list.isEmpty()) {
|
||||
GraphTargetItem lastExpr = list.remove(list.size() - 1);
|
||||
List<GraphTargetItem> onTrue = new ArrayList<>();
|
||||
BreakItem bi = new BreakItem(null, null, wi.loop.id);
|
||||
onTrue.add(bi);
|
||||
IfItem ifi = new IfItem(null, null, lastExpr.invert(null), onTrue, new ArrayList<>());
|
||||
list.add(ifi);
|
||||
wi.commands.addAll(0, list);
|
||||
list.clear();
|
||||
list.add(new TrueItem(null, null));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2859,7 +2871,7 @@ public class AVM2Graph extends Graph {
|
||||
}
|
||||
*/
|
||||
//Handle for loops at the end:
|
||||
super.finalProcess(list, level, localData, path);
|
||||
super.finalProcess(parent, list, level, localData, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -274,17 +274,8 @@ public class ActionGraph extends Graph {
|
||||
return !isSwitch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Final process.
|
||||
*
|
||||
* @param list List of GraphTargetItems
|
||||
* @param level Level
|
||||
* @param localData Local data
|
||||
* @param path Path
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
@Override
|
||||
protected void finalProcess(List<GraphTargetItem> list, int level, FinalProcessLocalData localData, String path) throws InterruptedException {
|
||||
protected void finalProcess(GraphTargetItem parent, List<GraphTargetItem> list, int level, FinalProcessLocalData localData, String path) throws InterruptedException {
|
||||
|
||||
if (level == 0) {
|
||||
List<GraphTargetItem> removed = new ArrayList<>();
|
||||
@@ -553,7 +544,7 @@ public class ActionGraph extends Graph {
|
||||
}
|
||||
}
|
||||
//Handle for loops at the end:
|
||||
super.finalProcess(list, level, localData, path);
|
||||
super.finalProcess(parent, list, level, localData, path);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1001,7 +1001,7 @@ public class Graph {
|
||||
processIfs(ret);
|
||||
finalProcessStack(stack, ret, path);
|
||||
makeAllCommands(ret, stack);
|
||||
finalProcessAll(ret, 0, getFinalData(localData, loops, throwStates), path);
|
||||
finalProcessAll(null, ret, 0, getFinalData(localData, loops, throwStates), path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1332,22 +1332,23 @@ public class Graph {
|
||||
/**
|
||||
* Final process all.
|
||||
*
|
||||
* @param parent Parent item
|
||||
* @param list List of GraphTargetItems
|
||||
* @param level Level
|
||||
* @param localData Local data
|
||||
* @param path Path
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
private void finalProcessAll(List<GraphTargetItem> list, int level, FinalProcessLocalData localData, String path) throws InterruptedException {
|
||||
private void finalProcessAll(GraphTargetItem parent, List<GraphTargetItem> list, int level, FinalProcessLocalData localData, String path) throws InterruptedException {
|
||||
if (debugDoNotProcess) {
|
||||
return;
|
||||
}
|
||||
finalProcess(list, level, localData, path);
|
||||
finalProcess(parent, list, level, localData, path);
|
||||
for (GraphTargetItem item : list) {
|
||||
if (item instanceof Block) {
|
||||
List<List<GraphTargetItem>> subs = ((Block) item).getSubs();
|
||||
for (List<GraphTargetItem> sub : subs) {
|
||||
finalProcessAll(sub, level + 1, localData, path);
|
||||
finalProcessAll(item, sub, level + 1, localData, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1428,13 +1429,14 @@ public class Graph {
|
||||
/**
|
||||
* Final process. Override this method to provide custom behavior.
|
||||
*
|
||||
* @param parent Paren item
|
||||
* @param list List of GraphTargetItems
|
||||
* @param level Level
|
||||
* @param localData Local data
|
||||
* @param path Path
|
||||
* @throws InterruptedException On interrupt
|
||||
*/
|
||||
protected void finalProcess(List<GraphTargetItem> list, int level, FinalProcessLocalData localData, String path) throws InterruptedException {
|
||||
protected void finalProcess(GraphTargetItem parent, List<GraphTargetItem> list, int level, FinalProcessLocalData localData, String path) throws InterruptedException {
|
||||
|
||||
//For detection based on debug line information
|
||||
boolean[] toDelete = new boolean[list.size()];
|
||||
|
||||
Reference in New Issue
Block a user