Fixed: #2270 AS3 decompilation - unnnecessary local registers assignments as part of expressions when using optimization like dup, setlocal N instead of setlocal N, getlocal N

This commit is contained in:
Jindra Petřík
2024-08-12 17:50:16 +02:00
parent 02baf4baa6
commit 16ff10a890
31 changed files with 487 additions and 58 deletions

View File

@@ -2715,6 +2715,18 @@ public class Graph {
return printGraph(foundGotos, partCodes, partCodePos, visited, localData, stack, allParts, parent, part, stopPart, stopPartKind, loops, throwStates, null, staticOperation, path, 0);
}
/**
* Gets if expression from stack.
* Can be overriden for custom handling
* @param localData Local data
* @param stack Stack
* @param output Output
* @return Expression
*/
protected GraphTargetItem getIfExpression(BaseLocalData localData, TranslateStack stack, List<GraphTargetItem> output) {
return stack.pop();
}
/**
* Walks graph parts and converts them to target items.
*
@@ -3254,7 +3266,7 @@ public class Graph {
} //else
GraphPart nextOnePart = null;
if (getNextParts(localData, part).size() == 2 && !partIsSwitch(part)) {
GraphTargetItem expr = stack.pop();
GraphTargetItem expr = getIfExpression(localData, stack, currentRet);
if (nextOnePart == null) {