mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-05 18:34:45 +00:00
fix: as1/2 maintain push order, temp variables usage
This commit is contained in:
@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2;
|
||||
import com.jpexs.decompiler.flash.EndOfStreamException;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.ABCInputStream;
|
||||
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
|
||||
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorGetSet;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorJumps;
|
||||
@@ -309,6 +310,7 @@ import com.jpexs.decompiler.graph.SecondPassException;
|
||||
import com.jpexs.decompiler.graph.SimpleValue;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.decompiler.graph.model.ScriptEndItem;
|
||||
import com.jpexs.helpers.CancellableWorker;
|
||||
import com.jpexs.helpers.Helper;
|
||||
@@ -2023,11 +2025,30 @@ public class AVM2Code implements Cloneable {
|
||||
ip++;
|
||||
} else {
|
||||
try {
|
||||
/*System.err.println("executing ins " + ins);
|
||||
System.err.println("::::::::::::::::::::::::");
|
||||
*/
|
||||
ins.definition.translate(maxTempIndex, usedDeobfuscations, swfVersion, callStack, abcIndex, setLocalPosToGetLocalPos, lineStartItem, isStatic, scriptIndex, classIndex, localRegs, stack, scopeStack, localScopeStack, ins, output, body, abc, localRegNames, localRegTypes, fullyQualifiedNames, path, localRegAssignmentIps, ip, this, thisHasDefaultToPrimitive, bottomStackSetLocals);
|
||||
|
||||
/*System.err.println("output:");
|
||||
for (GraphTargetItem ti : output) {
|
||||
System.err.println("" + ti.toString(LocalData.create(new ArrayList<MethodBody>(), abcIndex, abc, localRegNames, new ArrayList<DottedChain>(), new HashSet<Integer>(), ScriptExportMode.AS, swfVersion, new HashSet<String>(), classIndex)));
|
||||
}
|
||||
|
||||
System.err.println("stack output queue:");
|
||||
for (GraphTargetItem ti : stack.outputQueue) {
|
||||
System.err.println("" + ti.toString(LocalData.create(new ArrayList<MethodBody>(), abcIndex, abc, localRegNames, new ArrayList<DottedChain>(), new HashSet<Integer>(), ScriptExportMode.AS, swfVersion, new HashSet<String>(), classIndex)));
|
||||
}
|
||||
|
||||
System.err.println("stack after:");
|
||||
for (GraphTargetItem ti : stack) {
|
||||
System.err.println("" + ti.toString(LocalData.create(new ArrayList<MethodBody>(), abcIndex, abc, localRegNames, new ArrayList<DottedChain>(), new HashSet<Integer>(), ScriptExportMode.AS, swfVersion, new HashSet<String>(), classIndex)));
|
||||
}
|
||||
System.err.println("/---------------");
|
||||
*/
|
||||
if (stack.size() == 1 && (stack.peek() instanceof SetLocalAVM2Item)) {
|
||||
bottomStackSetLocals.add((SetLocalAVM2Item) stack.peek());
|
||||
}
|
||||
|
||||
} catch (RuntimeException re) {
|
||||
/*String last="";
|
||||
int len=5;
|
||||
|
||||
@@ -1447,7 +1447,7 @@ public class AVM2Graph extends Graph {
|
||||
}
|
||||
|
||||
List<GraphTargetItem> currentCatchCommands = printGraph(foundGotos, partCodes, partCodePos, visited, localData2, st2, allParts, null, catchPart, stopPart2, stopPartKind2, loops, throwStates, staticOperation, path);
|
||||
st2.finishBlock(currentCatchCommands);
|
||||
st2.finishBlock(currentCatchCommands, true);
|
||||
int tempExceptionPos = 0;
|
||||
if (!currentCatchCommands.isEmpty() && currentCatchCommands.get(0) instanceof WithAVM2Item) {
|
||||
tempExceptionPos++;
|
||||
|
||||
@@ -633,6 +633,11 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
|
||||
return definition.getStackPopCount(this, aLocalData.abc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(BaseLocalData localData, TranslateStack stack) {
|
||||
return getStackPushCount(localData, stack) - getStackPopCount(localData, stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of stack items that are pushed by this item.
|
||||
*
|
||||
|
||||
@@ -31,11 +31,7 @@ import com.jpexs.decompiler.graph.SimpleValue;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.model.DuplicateItem;
|
||||
import com.jpexs.decompiler.graph.model.DuplicateSourceItem;
|
||||
import com.jpexs.decompiler.graph.model.HasTempIndex;
|
||||
import com.jpexs.decompiler.graph.model.PopItem;
|
||||
import com.jpexs.decompiler.graph.model.PushItem;
|
||||
import com.jpexs.decompiler.graph.model.SetTemporaryItem;
|
||||
import com.jpexs.decompiler.graph.model.SwapItem;
|
||||
import com.jpexs.decompiler.graph.model.TemporaryItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -67,15 +63,7 @@ public class SwapIns extends InstructionDefinition {
|
||||
|
||||
GraphTargetItem o1 = stack.pop();
|
||||
GraphTargetItem o2 = stack.pop();
|
||||
|
||||
|
||||
/*if (true) {
|
||||
stack.push(o1);
|
||||
stack.push(o2);
|
||||
o1.getMoreSrc().add(new GraphSourceItemPos(ins, 0));
|
||||
o2.getMoreSrc().add(new GraphSourceItemPos(ins, 0));
|
||||
return;
|
||||
}*/
|
||||
|
||||
if (((o1 instanceof ExceptionAVM2Item) && (o2 instanceof ExceptionAVM2Item))
|
||||
||
|
||||
(
|
||||
@@ -99,45 +87,6 @@ public class SwapIns extends InstructionDefinition {
|
||||
o2.getMoreSrc().add(new GraphSourceItemPos(ins, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
stack.finishBlock(output);
|
||||
if (!(o2 instanceof PopItem)) {
|
||||
output.add(new PushItem(o2));
|
||||
}
|
||||
if (!(o2 instanceof PopItem && o1 instanceof PopItem)) {
|
||||
output.add(new PushItem(o1));
|
||||
}
|
||||
output.add(new SwapItem(AVM2GraphTargetDialect.INSTANCE, ins, localData.lineStartInstruction));
|
||||
*/
|
||||
/*if (o2 instanceof HasTempIndex) {
|
||||
stack.push(o1);
|
||||
stack.push(o2);
|
||||
return;
|
||||
}*/
|
||||
/*
|
||||
if (o2 instanceof SetTemporaryItem || o2 instanceof DuplicateSourceItem) {
|
||||
HasTempIndex ti = (HasTempIndex) o2;
|
||||
stack.addToOutput(new SetTemporaryItem(AVM2GraphTargetDialect.INSTANCE, ins, localData.lineStartInstruction, o2.value, ti.getTempIndex(), "swap"));
|
||||
stack.push(o1);
|
||||
stack.push(new TemporaryItem(AVM2GraphTargetDialect.INSTANCE, ins, localData.lineStartInstruction, o2, ti.getTempIndex()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (o2 instanceof TemporaryItem || o2 instanceof DuplicateItem) {
|
||||
stack.push(o1);
|
||||
stack.push(o2);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
/*int temp = localData.maxTempIndex.getVal() + 1;
|
||||
localData.maxTempIndex.setVal(temp);
|
||||
stack.finishBlock(output);
|
||||
stack.addToOutput(new SetTemporaryItem(AVM2GraphTargetDialect.INSTANCE, ins, localData.lineStartInstruction, o2, temp, "swap"));
|
||||
stack.finishBlock(output);
|
||||
stack.push(o1);
|
||||
stack.push(new TemporaryItem(AVM2GraphTargetDialect.INSTANCE, ins, localData.lineStartInstruction, o2, temp)); */
|
||||
|
||||
if (o2 instanceof TemporaryItem) {
|
||||
stack.push(o1);
|
||||
stack.push(o2);
|
||||
|
||||
@@ -1383,8 +1383,9 @@ public abstract class Action implements GraphSourceItem {
|
||||
}
|
||||
|
||||
action.translate(localData, stack, output, staticOperation, path);
|
||||
|
||||
|
||||
if (((action instanceof ActionSetTarget) || (action instanceof ActionSetTarget2)) && (!stack.isEmpty())) {
|
||||
stack.finishBlock(output);
|
||||
GraphTargetItem lastItem = output.remove(output.size() - 1);
|
||||
graph.makeAllCommands(output, stack);
|
||||
output.add(lastItem);
|
||||
@@ -1597,4 +1598,9 @@ public abstract class Action implements GraphSourceItem {
|
||||
public void setVirtualAddress(long virtualAddress) {
|
||||
this.virtualAddress = virtualAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStackDelta(BaseLocalData localData, TranslateStack stack) {
|
||||
return getStackPushCount(localData, stack) - getStackPopCount(localData, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,18 +260,7 @@ public class ActionGraph extends Graph {
|
||||
* @param path Path
|
||||
*/
|
||||
@Override
|
||||
public void finalProcessStack(TranslateStack stack, List<GraphTargetItem> output, String path) {
|
||||
if (stack.size() > 0) {
|
||||
for (int i = stack.size() - 1; i >= 0; i--) {
|
||||
//System.err.println(stack.get(i));
|
||||
if (stack.get(i) instanceof FunctionActionItem) {
|
||||
FunctionActionItem f = (FunctionActionItem) stack.remove(i);
|
||||
if (!output.contains(f)) {
|
||||
output.add(0, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void finalProcessStack(TranslateStack stack, List<GraphTargetItem> output, String path) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -343,6 +332,10 @@ public class ActionGraph extends Graph {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (pi.value instanceof FunctionActionItem) {
|
||||
list.set(t, pi.value);
|
||||
}
|
||||
}
|
||||
if (it instanceof SetTemporaryItem) {
|
||||
SetTemporaryItem st = (SetTemporaryItem) it;
|
||||
@@ -546,7 +539,7 @@ public class ActionGraph extends Graph {
|
||||
|
||||
if ((sti.getValue() instanceof DirectValueActionItem) && (((DirectValueActionItem) sti.getValue()).value instanceof RegisterNumber)) {
|
||||
if ((comparisonOp.rightSide instanceof DirectValueActionItem) && (((DirectValueActionItem) comparisonOp.rightSide).value instanceof Null)) {
|
||||
if (comparisonOp.leftSide.value instanceof EnumeratedValueActionItem) {
|
||||
if (comparisonOp.leftSide.value.getThroughDuplicate() instanceof EnumeratedValueActionItem) {
|
||||
if (((StoreRegisterActionItem) comparisonOp.leftSide).register.number == ((RegisterNumber) (((DirectValueActionItem) sti.getValue()).value)).number) {
|
||||
list.remove(t);
|
||||
checkedBody.remove(0);
|
||||
@@ -559,6 +552,20 @@ public class ActionGraph extends Graph {
|
||||
//sti.getObject()
|
||||
list.remove(t - 1);
|
||||
t--;
|
||||
|
||||
if (comparisonOp.leftSide.value instanceof TemporaryItem) {
|
||||
TemporaryItem ti = (TemporaryItem) comparisonOp.leftSide.value;
|
||||
if (t > 0) {
|
||||
if (list.get(t - 1) instanceof SetTemporaryItem) {
|
||||
SetTemporaryItem sti2 = (SetTemporaryItem) list.get(t - 1);
|
||||
if (sti2.tempIndex == ti.tempIndex) {
|
||||
list.remove(t - 1);
|
||||
t--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -587,6 +594,19 @@ public class ActionGraph extends Graph {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int t = 0; t < list.size(); t++) {
|
||||
GraphTargetItem it = list.get(t);
|
||||
if (it instanceof PushItem) {
|
||||
it = it.value;
|
||||
}
|
||||
if (it instanceof EnumeratedValueActionItem) {
|
||||
list.remove(t);
|
||||
t--;
|
||||
}
|
||||
}
|
||||
|
||||
//Handle for loops at the end:
|
||||
super.finalProcess(parent, list, level, localData, path);
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ import java.util.Set;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class FunctionActionItem extends ActionItem implements BranchStackResistant {
|
||||
public class FunctionActionItem extends ActionItem {
|
||||
|
||||
/**
|
||||
* Decompile get/set functions
|
||||
|
||||
@@ -63,6 +63,6 @@ public class ActionEnd extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
//output.add(new SimpleActionTreeItem(this, "end()"));
|
||||
//stack.addToOutput(new SimpleActionTreeItem(this, "end()"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,6 @@ public class ActionNop extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
//output.add(new SimpleActionTreeItem(this, "nop();"));
|
||||
//stack.addToOutput(new SimpleActionTreeItem(this, "nop();"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class ActionGetURL extends Action {
|
||||
String fsCommandPrefix = "FSCommand:";
|
||||
if (urlString.startsWith(fsCommandPrefix)) {
|
||||
String command = urlString.substring(fsCommandPrefix.length());
|
||||
output.add(new FSCommandActionItem(this, lineStartAction, new DirectValueActionItem(command), targetString.isEmpty() ? null : new DirectValueActionItem(targetString)));
|
||||
stack.addToOutput(new FSCommandActionItem(this, lineStartAction, new DirectValueActionItem(command), targetString.isEmpty() ? null : new DirectValueActionItem(targetString)));
|
||||
return;
|
||||
}
|
||||
String levelPrefix = "_level";
|
||||
@@ -142,10 +142,10 @@ public class ActionGetURL extends Action {
|
||||
try {
|
||||
int num = Integer.valueOf(targetString.substring(levelPrefix.length()));
|
||||
if (urlString.isEmpty()) {
|
||||
output.add(new UnLoadMovieNumActionItem(this, lineStartAction, new DirectValueActionItem((Long) (long) (int) num)));
|
||||
stack.addToOutput(new UnLoadMovieNumActionItem(this, lineStartAction, new DirectValueActionItem((Long) (long) (int) num)));
|
||||
} else {
|
||||
DirectValueActionItem urlStringDi = new DirectValueActionItem(null, null, 0, urlString, new ArrayList<>());
|
||||
output.add(new LoadMovieNumActionItem(this, lineStartAction, urlStringDi, new DirectValueActionItem((Long) (long) (int) num), 1/*GET*/));
|
||||
stack.addToOutput(new LoadMovieNumActionItem(this, lineStartAction, urlStringDi, new DirectValueActionItem((Long) (long) (int) num), 1/*GET*/));
|
||||
}
|
||||
return;
|
||||
} catch (NumberFormatException nfe) {
|
||||
@@ -156,9 +156,9 @@ public class ActionGetURL extends Action {
|
||||
|
||||
if (urlString.isEmpty()) {
|
||||
DirectValueActionItem targetStringDi = new DirectValueActionItem(null, null, 0, targetString, new ArrayList<>());
|
||||
output.add(new UnLoadMovieActionItem(this, lineStartAction, targetStringDi));
|
||||
stack.addToOutput(new UnLoadMovieActionItem(this, lineStartAction, targetStringDi));
|
||||
} else {
|
||||
output.add(new GetURLActionItem(this, lineStartAction, urlString, targetString));
|
||||
stack.addToOutput(new GetURLActionItem(this, lineStartAction, urlString, targetString));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -111,6 +111,6 @@ public class ActionGotoFrame extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
output.add(new GotoFrameActionItem(this, lineStartAction, frame));
|
||||
stack.addToOutput(new GotoFrameActionItem(this, lineStartAction, frame));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,6 @@ public class ActionNextFrame extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
output.add(new NextFrameActionItem(this, lineStartAction));
|
||||
stack.addToOutput(new NextFrameActionItem(this, lineStartAction));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,11 +63,14 @@ public class ActionPlay extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
stack.finishBlock(output);
|
||||
if (!output.isEmpty() && (output.get(output.size() - 1) instanceof GotoFrameActionItem)) {
|
||||
GotoFrameActionItem gta = (GotoFrameActionItem) output.remove(output.size() - 1);
|
||||
output.add(new GotoFrame2ActionItem(this, lineStartAction, new DirectValueActionItem(gta.frame + 1), false, true, 0));
|
||||
stack.moveToStack(output);
|
||||
stack.addToOutput(new GotoFrame2ActionItem(this, lineStartAction, new DirectValueActionItem(gta.frame + 1), false, true, 0));
|
||||
} else {
|
||||
output.add(new PlayActionItem(this, lineStartAction));
|
||||
stack.moveToStack(output);
|
||||
stack.addToOutput(new PlayActionItem(this, lineStartAction));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,6 @@ public class ActionPrevFrame extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
output.add(new PrevFrameActionItem(this, lineStartAction));
|
||||
stack.addToOutput(new PrevFrameActionItem(this, lineStartAction));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,6 @@ public class ActionStop extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
output.add(new StopActionItem(this, lineStartAction));
|
||||
stack.addToOutput(new StopActionItem(this, lineStartAction));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,6 @@ public class ActionToggleQuality extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
output.add(new ToggleHighQualityActionItem(this, lineStartAction));
|
||||
stack.addToOutput(new ToggleHighQualityActionItem(this, lineStartAction));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,6 @@ public class ActionStopSounds extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
output.add(new StopAllSoundsActionItem(this, lineStartAction));
|
||||
stack.addToOutput(new StopAllSoundsActionItem(this, lineStartAction));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,6 @@ public class ActionGoToLabel extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
output.add(new GotoLabelActionItem(this, lineStartAction, label));
|
||||
stack.addToOutput(new GotoLabelActionItem(this, lineStartAction, label));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,6 @@ public class ActionSetTarget extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
output.add(new SetTargetActionItem(this, lineStartAction, targetName));
|
||||
stack.addToOutput(new SetTargetActionItem(this, lineStartAction, targetName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public class ActionWaitForFrame extends Action implements ActionStore {
|
||||
functions.putAll(functionsBackup);
|
||||
body = ActionGraph.translateViaGraph(usedDeobfuscations, false, uninitializedClassTraits, spe.getData(), insideDoInitAction, true, regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path, getCharset(), 0);
|
||||
}
|
||||
output.add(new IfFrameLoadedActionItem(frameTi, body, this, lineStartAction));
|
||||
stack.addToOutput(new IfFrameLoadedActionItem(frameTi, body, this, lineStartAction));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ActionCall extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
output.add(new CallActionItem(this, lineStartAction, stack.pop()));
|
||||
stack.addToOutput(new CallActionItem(this, lineStartAction, stack.pop()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ActionCloneSprite extends Action {
|
||||
GraphTargetItem depth = stack.pop();
|
||||
GraphTargetItem source = stack.pop();
|
||||
GraphTargetItem target = stack.pop();
|
||||
output.add(new CloneSpriteActionItem(this, lineStartAction, source, target, depth));
|
||||
stack.addToOutput(new CloneSpriteActionItem(this, lineStartAction, source, target, depth));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -63,6 +63,6 @@ public class ActionEndDrag extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
output.add(new StopDragActionItem(this, lineStartAction));
|
||||
stack.addToOutput(new StopDragActionItem(this, lineStartAction));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,15 +225,15 @@ public class ActionGetURL2 extends Action {
|
||||
|
||||
if (loadVariablesFlag) {
|
||||
if (num != null) {
|
||||
output.add(new LoadVariablesNumActionItem(this, lineStartAction, urlString, num, sendVarsMethod));
|
||||
stack.addToOutput(new LoadVariablesNumActionItem(this, lineStartAction, urlString, num, sendVarsMethod));
|
||||
} else {
|
||||
output.add(new LoadVariablesActionItem(this, lineStartAction, urlString, targetString, sendVarsMethod));
|
||||
stack.addToOutput(new LoadVariablesActionItem(this, lineStartAction, urlString, targetString, sendVarsMethod));
|
||||
}
|
||||
} else if (loadTargetFlag) {
|
||||
if ((urlString instanceof DirectValueActionItem) && ("".equals(urlString.getResult()))) {
|
||||
output.add(new UnLoadMovieActionItem(this, lineStartAction, targetString));
|
||||
stack.addToOutput(new UnLoadMovieActionItem(this, lineStartAction, targetString));
|
||||
} else {
|
||||
output.add(new LoadMovieActionItem(this, lineStartAction, urlString, targetString, sendVarsMethod));
|
||||
stack.addToOutput(new LoadMovieActionItem(this, lineStartAction, urlString, targetString, sendVarsMethod));
|
||||
}
|
||||
} else {
|
||||
final String printPrefix = "print:#";
|
||||
@@ -293,22 +293,22 @@ public class ActionGetURL2 extends Action {
|
||||
|
||||
if (num != null) {
|
||||
if (doUnload) {
|
||||
output.add(new UnLoadMovieNumActionItem(this, lineStartAction, num));
|
||||
stack.addToOutput(new UnLoadMovieNumActionItem(this, lineStartAction, num));
|
||||
} else if (doPrint) {
|
||||
output.add(new PrintNumActionItem(this, lineStartAction, num, printType));
|
||||
stack.addToOutput(new PrintNumActionItem(this, lineStartAction, num, printType));
|
||||
} else if (doPrintAsBitmap) {
|
||||
output.add(new PrintAsBitmapNumActionItem(this, lineStartAction, num, printType));
|
||||
stack.addToOutput(new PrintAsBitmapNumActionItem(this, lineStartAction, num, printType));
|
||||
} else {
|
||||
output.add(new LoadMovieNumActionItem(this, lineStartAction, urlString, num, sendVarsMethod));
|
||||
stack.addToOutput(new LoadMovieNumActionItem(this, lineStartAction, urlString, num, sendVarsMethod));
|
||||
}
|
||||
} else if (doPrint) {
|
||||
output.add(new PrintActionItem(this, lineStartAction, targetString, printType));
|
||||
stack.addToOutput(new PrintActionItem(this, lineStartAction, targetString, printType));
|
||||
} else if (doPrintAsBitmap) {
|
||||
output.add(new PrintAsBitmapActionItem(this, lineStartAction, targetString, printType));
|
||||
stack.addToOutput(new PrintAsBitmapActionItem(this, lineStartAction, targetString, printType));
|
||||
} else if (doFSCommand) {
|
||||
output.add(new FSCommandActionItem(this, lineStartAction, urlString, targetString));
|
||||
stack.addToOutput(new FSCommandActionItem(this, lineStartAction, urlString, targetString));
|
||||
} else {
|
||||
output.add(new GetURL2ActionItem(this, lineStartAction, urlString, targetString, sendVarsMethod));
|
||||
stack.addToOutput(new GetURL2ActionItem(this, lineStartAction, urlString, targetString, sendVarsMethod));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ public class ActionGotoFrame2 extends Action {
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
GraphTargetItem frame = stack.pop();
|
||||
output.add(new GotoFrame2ActionItem(this, lineStartAction, frame, sceneBiasFlag, playFlag, sceneBias));
|
||||
stack.addToOutput(new GotoFrame2ActionItem(this, lineStartAction, frame, sceneBiasFlag, playFlag, sceneBias));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ActionPop extends Action {
|
||||
if (val instanceof AnyItem) {
|
||||
return;
|
||||
}
|
||||
output.add(val);
|
||||
stack.addToOutput(val);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -534,6 +534,7 @@ public class ActionPush extends Action {
|
||||
}
|
||||
if (dvt.computedRegValue instanceof TemporaryRegister) {
|
||||
((TemporaryRegister) dvt.computedRegValue).used = true;
|
||||
stack.finishBlock(output);
|
||||
for (int i = 0; i < output.size(); i++) {
|
||||
if (output.get(i) instanceof TemporaryRegisterMark) {
|
||||
TemporaryRegisterMark trm = (TemporaryRegisterMark) output.get(i);
|
||||
@@ -543,6 +544,7 @@ public class ActionPush extends Action {
|
||||
}
|
||||
}
|
||||
}
|
||||
stack.moveToStack(output);
|
||||
toPush = new TemporaryRegister(((RegisterNumber) o).number, ((TemporaryRegister) dvt.computedRegValue).value);
|
||||
} else {
|
||||
toPush = dvt;
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ActionRemoveSprite extends Action {
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
GraphTargetItem target = stack.pop();
|
||||
output.add(new RemoveSpriteActionItem(this, lineStartAction, target));
|
||||
stack.addToOutput(new RemoveSpriteActionItem(this, lineStartAction, target));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -120,7 +120,7 @@ public class ActionSetProperty extends Action {
|
||||
if (dec.object instanceof GetPropertyActionItem) {
|
||||
GetPropertyActionItem gp = (GetPropertyActionItem) dec.object;
|
||||
if (gp.target.valueEquals(target) && gp.propertyIndex == indexInt) {
|
||||
output.add(new PostIncrementActionItem(this, lineStartAction, gp));
|
||||
stack.addToOutput(new PostIncrementActionItem(this, lineStartAction, gp));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,7 @@ public class ActionSetProperty extends Action {
|
||||
if (dec.object instanceof GetPropertyActionItem) {
|
||||
GetPropertyActionItem gp = (GetPropertyActionItem) dec.object;
|
||||
if (gp.target.valueEquals(target) && gp.propertyIndex == indexInt) {
|
||||
output.add(new PostDecrementActionItem(this, lineStartAction, gp));
|
||||
stack.addToOutput(new PostDecrementActionItem(this, lineStartAction, gp));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -174,11 +174,11 @@ public class ActionSetProperty extends Action {
|
||||
}
|
||||
TemporaryRegister tr = new TemporaryRegister(sr.register.number, ret);
|
||||
variables.put("__register" + sr.register.number, tr);
|
||||
output.add(new TemporaryRegisterMark(tr));
|
||||
stack.addToOutput(new TemporaryRegisterMark(tr));
|
||||
return;
|
||||
}
|
||||
}
|
||||
output.add(ret);
|
||||
stack.addToOutput(ret);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ActionSetTarget2 extends Action {
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
GraphTargetItem target = stack.pop();
|
||||
output.add(new SetTarget2ActionItem(this, lineStartAction, target));
|
||||
stack.addToOutput(new SetTarget2ActionItem(this, lineStartAction, target));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -123,14 +123,14 @@ public class ActionSetVariable extends Action implements StoreTypeAction {
|
||||
if (((IncrementActionItem) value).object instanceof GetVariableActionItem) {
|
||||
((GetVariableActionItem) ((IncrementActionItem) value).object).printObfuscatedName = true;
|
||||
}
|
||||
output.add(new PostIncrementActionItem(this, lineStartAction, ((IncrementActionItem) value).object));
|
||||
stack.addToOutput(new PostIncrementActionItem(this, lineStartAction, ((IncrementActionItem) value).object));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (((IncrementActionItem) value).object instanceof EvalActionItem) {
|
||||
if (((IncrementActionItem) value).object.value instanceof DuplicateItem) {
|
||||
if (((IncrementActionItem) value).object.value.value == name) {
|
||||
output.add(new PostIncrementActionItem(this, lineStartAction, new GetVariableActionItem(null, null, name)));
|
||||
stack.addToOutput(new PostIncrementActionItem(this, lineStartAction, new GetVariableActionItem(null, null, name)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -142,14 +142,14 @@ public class ActionSetVariable extends Action implements StoreTypeAction {
|
||||
if (((DecrementActionItem) value).object instanceof GetVariableActionItem) {
|
||||
((GetVariableActionItem) ((DecrementActionItem) value).object).printObfuscatedName = true;
|
||||
}
|
||||
output.add(new PostDecrementActionItem(this, lineStartAction, ((DecrementActionItem) value).object));
|
||||
stack.addToOutput(new PostDecrementActionItem(this, lineStartAction, ((DecrementActionItem) value).object));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (((DecrementActionItem) value).object instanceof EvalActionItem) {
|
||||
if (((DecrementActionItem) value).object.value instanceof DuplicateItem) {
|
||||
if (((DecrementActionItem) value).object.value.value == name) {
|
||||
output.add(new PostDecrementActionItem(this, lineStartAction, new GetVariableActionItem(null, null, name)));
|
||||
stack.addToOutput(new PostDecrementActionItem(this, lineStartAction, new GetVariableActionItem(null, null, name)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -209,12 +209,12 @@ public class ActionSetVariable extends Action implements StoreTypeAction {
|
||||
|
||||
TemporaryRegister tr = new TemporaryRegister(sr.register.number, ret);
|
||||
variables.put("__register" + sr.register.number, tr);
|
||||
output.add(new TemporaryRegisterMark(tr));
|
||||
stack.addToOutput(new TemporaryRegisterMark(tr));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
output.add(ret);
|
||||
stack.addToOutput(ret);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -89,7 +89,7 @@ public class ActionStartDrag extends Action {
|
||||
x1 = stack.pop();
|
||||
}
|
||||
|
||||
output.add(new StartDragActionItem(this, lineStartAction, target, lockCenter, constrain, x1, y1, x2, y2));
|
||||
stack.addToOutput(new StartDragActionItem(this, lineStartAction, target, lockCenter, constrain, x1, y1, x2, y2));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -65,7 +65,7 @@ public class ActionTrace extends Action {
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
GraphTargetItem value = stack.pop();
|
||||
output.add(new TraceActionItem(this, lineStartAction, value));
|
||||
stack.addToOutput(new TraceActionItem(this, lineStartAction, value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -193,7 +193,7 @@ public class ActionWaitForFrame2 extends Action implements ActionStore {
|
||||
functions.putAll(functionsBackup);
|
||||
body = ActionGraph.translateViaGraph(usedDeobfuscations, false, uninitializedClassTraits, spe.getData(), insideDoInitAction, true, regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path, getCharset(), 0);
|
||||
}
|
||||
output.add(new IfFrameLoadedActionItem(frame, body, this, lineStartAction));
|
||||
stack.addToOutput(new IfFrameLoadedActionItem(frame, body, this, lineStartAction));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -68,6 +68,7 @@ public class ActionDefineLocal extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
stack.allowSwap(output);
|
||||
GraphTargetItem value = stack.pop();
|
||||
GraphTargetItem name = stack.pop();
|
||||
String nameStr;
|
||||
@@ -77,7 +78,7 @@ public class ActionDefineLocal extends Action {
|
||||
nameStr = EcmaScript.toString(name.getResult());
|
||||
}
|
||||
variables.put(nameStr, value);
|
||||
output.add(new DefineLocalActionItem(this, lineStartAction, name, value));
|
||||
stack.addToOutput(new DefineLocalActionItem(this, lineStartAction, name, value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ActionDefineLocal2 extends Action {
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
GraphTargetItem name = stack.pop();
|
||||
output.add(new DefineLocalActionItem(this, lineStartAction, name, null));
|
||||
stack.addToOutput(new DefineLocalActionItem(this, lineStartAction, name, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ActionEnumerate extends Action {
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
GraphTargetItem object = stack.pop();
|
||||
stack.push(new EnumeratedValueActionItem());
|
||||
output.add(new EnumerateActionItem(this, lineStartAction, object));
|
||||
stack.addToOutput(new EnumerateActionItem(this, lineStartAction, object));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,19 +20,16 @@ import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.ActionGraphTargetDialect;
|
||||
import com.jpexs.decompiler.flash.action.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.action.as2.Trait;
|
||||
import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SecondPassData;
|
||||
import com.jpexs.decompiler.graph.SimpleValue;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.model.DuplicateItem;
|
||||
import com.jpexs.decompiler.graph.model.DuplicateSourceItem;
|
||||
import com.jpexs.decompiler.graph.model.HasTempIndex;
|
||||
import com.jpexs.decompiler.graph.model.SetTemporaryItem;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* PushDuplicate action - Push duplicate of top stack value.
|
||||
@@ -66,11 +63,36 @@ public class ActionPushDuplicate extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
GraphTargetItem value = stack.peek();
|
||||
//TODO: implement logic similar to Avm2
|
||||
stack.push(new DuplicateItem(ActionGraphTargetDialect.INSTANCE, this, lineStartAction, value, 0));
|
||||
value.getMoreSrc().add(new GraphSourceItemPos(this, 0));
|
||||
public void translate(BaseLocalData localData, TranslateStack stack, List<GraphTargetItem> output, int staticOperation, String path) throws InterruptedException {
|
||||
GraphTargetItem v = stack.pop();
|
||||
int temp;
|
||||
|
||||
if (v instanceof SimpleValue) {
|
||||
SimpleValue sv = (SimpleValue) v;
|
||||
if (sv.isSimpleValue()) {
|
||||
stack.push(v);
|
||||
stack.push(v);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (v instanceof HasTempIndex) {
|
||||
temp = ((HasTempIndex) v).getTempIndex();
|
||||
stack.push(v);
|
||||
} else {
|
||||
temp = localData.maxTempIndex.getVal() + 1;
|
||||
localData.maxTempIndex.setVal(temp);
|
||||
stack.finishBlock(output);
|
||||
stack.addToOutput(new SetTemporaryItem(ActionGraphTargetDialect.INSTANCE, this, localData.lineStartInstruction, v, temp, "dup", 2));
|
||||
stack.finishBlock(output);
|
||||
|
||||
stack.push(new DuplicateSourceItem(ActionGraphTargetDialect.INSTANCE, this, localData.lineStartInstruction, v, temp));
|
||||
}
|
||||
|
||||
//stack.push(v);
|
||||
stack.push(new DuplicateItem(ActionGraphTargetDialect.INSTANCE, this, localData.lineStartInstruction, v, temp));
|
||||
//v.moreSrc.add(new GraphSourceItemPos(ins, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ActionReturn extends Action {
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
GraphTargetItem value = stack.pop();
|
||||
output.add(new ReturnActionItem(this, lineStartAction, value));
|
||||
stack.addToOutput(new ReturnActionItem(this, lineStartAction, value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,7 +40,10 @@ import com.jpexs.decompiler.graph.SecondPassData;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.model.AnyItem;
|
||||
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
|
||||
import com.jpexs.decompiler.graph.model.HasTempIndex;
|
||||
import com.jpexs.decompiler.graph.model.SetTemporaryItem;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -84,12 +87,41 @@ public class ActionSetMember extends Action {
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
stack.finishBlock(output);
|
||||
stack.allowSwap(output);
|
||||
stack.moveToStack(output);
|
||||
|
||||
|
||||
GraphTargetItem value = stack.pop().getThroughDuplicate();
|
||||
GraphTargetItem memberName = stack.pop();
|
||||
GraphTargetItem object = stack.pop();
|
||||
handleSetMember(false, value, memberName, object, this, usedDeobfuscations, uninitializedClassTraits, secondPassData, insideDoInitAction, lineStartAction, stack, output, regNames, variables, functions, staticOperation, path);
|
||||
}
|
||||
|
||||
private static void cleanupTemp(GraphTargetItem dup1, GraphTargetItem dup2, List<GraphTargetItem> output, TranslateStack stack) {
|
||||
int index1 = -1;
|
||||
int index2 = -1;
|
||||
if (dup1 instanceof HasTempIndex) {
|
||||
index1 = ((HasTempIndex) dup1).getTempIndex();
|
||||
}
|
||||
if (dup2 instanceof HasTempIndex) {
|
||||
index2 = ((HasTempIndex) dup2).getTempIndex();
|
||||
}
|
||||
|
||||
if (index1 > -1 && index2 > -1 && index1 != index2) {
|
||||
return;
|
||||
}
|
||||
int index = index1 < 0 ? index2 : index1;
|
||||
|
||||
stack.finishBlock(output);
|
||||
if (!output.isEmpty() && output.get(output.size() - 1) instanceof SetTemporaryItem) {
|
||||
SetTemporaryItem sti = (SetTemporaryItem) output.get(output.size() - 1);
|
||||
if (sti.tempIndex == index) {
|
||||
output.remove(output.size() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleSetMember(
|
||||
boolean setter,
|
||||
GraphTargetItem value,
|
||||
@@ -135,13 +167,14 @@ public class ActionSetMember extends Action {
|
||||
try {
|
||||
if (value instanceof IncrementActionItem) {
|
||||
if (((IncrementActionItem) value).object instanceof GetMemberActionItem) {
|
||||
if (((GetMemberActionItem) ((IncrementActionItem) value).object).object.getThroughDuplicate().equals(object)) {
|
||||
if (((GetMemberActionItem) ((IncrementActionItem) value).object).object.getThroughDuplicate().valueEquals(object.getThroughDuplicate())) {
|
||||
if (((GetMemberActionItem) ((IncrementActionItem) value).object).memberName.equals(memberName)) {
|
||||
((GetMemberActionItem) ((IncrementActionItem) value).object).object = ((GetMemberActionItem) ((IncrementActionItem) value).object).object.getThroughDuplicate();
|
||||
cleanupTemp(((GetMemberActionItem) ((IncrementActionItem) value).object).object, object, output, stack);
|
||||
if (setter) {
|
||||
output.add(new PreIncrementActionItem(action, lineStartAction, ((IncrementActionItem) value).object.getThroughDuplicate()));
|
||||
stack.addToOutput(new PreIncrementActionItem(action, lineStartAction, ((IncrementActionItem) value).object.getThroughDuplicate()));
|
||||
} else {
|
||||
output.add(new PostIncrementActionItem(action, lineStartAction, ((IncrementActionItem) value).object.getThroughDuplicate()));
|
||||
stack.addToOutput(new PostIncrementActionItem(action, lineStartAction, ((IncrementActionItem) value).object.getThroughDuplicate()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -150,13 +183,14 @@ public class ActionSetMember extends Action {
|
||||
}
|
||||
if (value instanceof DecrementActionItem) {
|
||||
if (((DecrementActionItem) value).object instanceof GetMemberActionItem) {
|
||||
if (((GetMemberActionItem) ((DecrementActionItem) value).object).object.getThroughDuplicate().valueEquals(object)) {
|
||||
if (((GetMemberActionItem) ((DecrementActionItem) value).object).object.getThroughDuplicate().valueEquals(object.getThroughDuplicate())) {
|
||||
if (((GetMemberActionItem) ((DecrementActionItem) value).object).memberName.equals(memberName)) {
|
||||
((GetMemberActionItem) ((DecrementActionItem) value).object).object = ((GetMemberActionItem) ((DecrementActionItem) value).object).object.getThroughDuplicate();
|
||||
cleanupTemp(((GetMemberActionItem) ((IncrementActionItem) value).object).object, object, output, stack);
|
||||
if (setter) {
|
||||
output.add(new PreDecrementActionItem(action, lineStartAction, ((IncrementActionItem) value).object.getThroughDuplicate()));
|
||||
stack.addToOutput(new PreDecrementActionItem(action, lineStartAction, ((IncrementActionItem) value).object.getThroughDuplicate()));
|
||||
} else {
|
||||
output.add(new PostDecrementActionItem(action, lineStartAction, ((DecrementActionItem) value).object.getThroughDuplicate()));
|
||||
stack.addToOutput(new PostDecrementActionItem(action, lineStartAction, ((DecrementActionItem) value).object.getThroughDuplicate()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -176,9 +210,11 @@ public class ActionSetMember extends Action {
|
||||
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) inside;
|
||||
if (binaryOp.getLeftSide() instanceof GetMemberActionItem) {
|
||||
GetMemberActionItem getMember = (GetMemberActionItem) binaryOp.getLeftSide();
|
||||
if (GraphTargetItem.objectsValueEquals(object, getMember.object.getThroughDuplicate()) && GraphTargetItem.objectsValueEquals(memberName, getMember.memberName)) {
|
||||
if (GraphTargetItem.objectsValueEquals(object.getThroughDuplicate(), getMember.object.getThroughDuplicate()) && GraphTargetItem.objectsValueEquals(memberName, getMember.memberName)) {
|
||||
cleanupTemp(object, getMember.object, output, stack);
|
||||
setMem.setCompoundValue(binaryOp.getRightSide());
|
||||
setMem.setCompoundOperator(binaryOp.getOperator());
|
||||
setMem.object = object.getThroughDuplicate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,14 +244,16 @@ public class ActionSetMember extends Action {
|
||||
}
|
||||
TemporaryRegister tr = new TemporaryRegister(sr.register.number, ret);
|
||||
variables.put("__register" + sr.register.number, tr);
|
||||
output.add(new TemporaryRegisterMark(tr));
|
||||
stack.addToOutput(new TemporaryRegisterMark(tr));
|
||||
return;
|
||||
}
|
||||
}
|
||||
output.add(ret);
|
||||
stack.addToOutput(ret);
|
||||
} finally {
|
||||
if (setter) {
|
||||
stack.finishBlock(output);
|
||||
stack.push(output.remove(output.size() - 1));
|
||||
stack.moveToStack(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.swf5;
|
||||
|
||||
import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.ActionGraphTargetDialect;
|
||||
import com.jpexs.decompiler.flash.action.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.action.as2.Trait;
|
||||
import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
|
||||
@@ -25,7 +26,12 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SecondPassData;
|
||||
import com.jpexs.decompiler.graph.SimpleValue;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.model.DuplicateItem;
|
||||
import com.jpexs.decompiler.graph.model.DuplicateSourceItem;
|
||||
import com.jpexs.decompiler.graph.model.SetTemporaryItem;
|
||||
import com.jpexs.decompiler.graph.model.TemporaryItem;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -67,13 +73,42 @@ public class ActionStackSwap extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
GraphTargetItem a = stack.pop();
|
||||
GraphTargetItem b = stack.pop();
|
||||
stack.push(a);
|
||||
stack.push(b);
|
||||
a.getMoreSrc().add(new GraphSourceItemPos(this, 0));
|
||||
b.getMoreSrc().add(new GraphSourceItemPos(this, 0));
|
||||
public void translate(BaseLocalData localData, TranslateStack stack, List<GraphTargetItem> output, int staticOperation, String path) throws InterruptedException {
|
||||
GraphTargetItem o1 = stack.pop();
|
||||
GraphTargetItem o2 = stack.pop();
|
||||
|
||||
if ((((o1 instanceof SimpleValue) && ((SimpleValue) o1).isSimpleValue() && !(o1 instanceof DuplicateItem)))
|
||||
&& (((o2 instanceof SimpleValue) && ((SimpleValue) o2).isSimpleValue() && !(o2 instanceof DuplicateItem)))) {
|
||||
stack.push(o1);
|
||||
stack.push(o2);
|
||||
o1.getMoreSrc().add(new GraphSourceItemPos(this, 0));
|
||||
o2.getMoreSrc().add(new GraphSourceItemPos(this, 0));
|
||||
return;
|
||||
}
|
||||
if (o2 instanceof TemporaryItem) {
|
||||
stack.push(o1);
|
||||
stack.push(o2);
|
||||
return;
|
||||
}
|
||||
if (o2 instanceof DuplicateItem) {
|
||||
stack.push(o1);
|
||||
stack.push(o2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (o2 instanceof DuplicateSourceItem) {
|
||||
stack.push(o1);
|
||||
stack.push(o2);
|
||||
return;
|
||||
}
|
||||
|
||||
int temp = localData.maxTempIndex.getVal() + 1;
|
||||
localData.maxTempIndex.setVal(temp);
|
||||
stack.finishBlock(output);
|
||||
stack.addToOutput(new SetTemporaryItem(ActionGraphTargetDialect.INSTANCE, this, localData.lineStartInstruction, o2, temp, "swap", 1));
|
||||
stack.push(o1);
|
||||
stack.push(new TemporaryItem(ActionGraphTargetDialect.INSTANCE, this, localData.lineStartInstruction, o2, temp));
|
||||
stack.finishBlock(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -134,7 +134,7 @@ public class ActionWith extends Action implements GraphSourceItemContainer {
|
||||
|
||||
@Override
|
||||
public void translateContainer(List<List<GraphTargetItem>> content, GraphSourceItem lineStartItem, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
|
||||
output.add(new WithActionItem(this, lineStartItem, stack.pop(), content.get(0)));
|
||||
stack.addToOutput(new WithActionItem(this, lineStartItem, stack.pop(), content.get(0)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -60,7 +60,7 @@ public class ActionEnumerate2 extends Action {
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
GraphTargetItem object = stack.pop();
|
||||
stack.push(new EnumeratedValueActionItem());
|
||||
output.add(new EnumerateActionItem(this, lineStartAction, object));
|
||||
stack.addToOutput(new EnumerateActionItem(this, lineStartAction, object));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ActionExtends extends Action {
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
GraphTargetItem superclass = stack.pop();
|
||||
GraphTargetItem subclass = stack.pop();
|
||||
output.add(new ExtendsActionItem(this, lineStartAction, subclass, superclass));
|
||||
stack.addToOutput(new ExtendsActionItem(this, lineStartAction, subclass, superclass));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -85,7 +85,7 @@ public class ActionImplementsOp extends Action {
|
||||
for (long l = 0; l < inCount; l++) {
|
||||
superclasses.add(stack.pop());
|
||||
}
|
||||
output.add(new ImplementsOpActionItem(this, lineStartAction, subclass, superclasses));
|
||||
stack.addToOutput(new ImplementsOpActionItem(this, lineStartAction, subclass, superclasses));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ActionThrow extends Action {
|
||||
@Override
|
||||
public void translate(Set<String> usedDeobfuscations, Map<String, Map<String, Trait>> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
|
||||
GraphTargetItem object = stack.pop();
|
||||
output.add(new ThrowActionItem(this, lineStartAction, object));
|
||||
stack.addToOutput(new ThrowActionItem(this, lineStartAction, object));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,10 +39,12 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.model.BreakItem;
|
||||
import com.jpexs.decompiler.graph.model.ContinueItem;
|
||||
import com.jpexs.decompiler.graph.model.DuplicateSourceItem;
|
||||
import com.jpexs.decompiler.graph.model.ExitItem;
|
||||
import com.jpexs.decompiler.graph.model.IfItem;
|
||||
import com.jpexs.decompiler.graph.model.PopItem;
|
||||
import com.jpexs.decompiler.graph.model.PushItem;
|
||||
import com.jpexs.decompiler.graph.model.SetTemporaryItem;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.IOException;
|
||||
@@ -358,6 +360,8 @@ public class ActionTry extends Action implements GraphSourceItemContainer {
|
||||
return false;
|
||||
}
|
||||
|
||||
static int errNum = 1;
|
||||
|
||||
@Override
|
||||
public void translateContainer(List<List<GraphTargetItem>> contents, GraphSourceItem lineStartItem, TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions) {
|
||||
List<GraphTargetItem> tryCommands = contents.get(0);
|
||||
@@ -373,6 +377,114 @@ public class ActionTry extends Action implements GraphSourceItemContainer {
|
||||
if (catchInRegisterFlag) {
|
||||
if (body.size() >= 2) {
|
||||
int pos = 0;
|
||||
|
||||
loopex:
|
||||
while (body.get(pos) instanceof SetTemporaryItem) {
|
||||
SetTemporaryItem sti = (SetTemporaryItem) body.get(pos);
|
||||
if (pos + 1 >= body.size()) {
|
||||
break;
|
||||
}
|
||||
if (!(body.get(pos + 1) instanceof PushItem)) {
|
||||
break;
|
||||
}
|
||||
PushItem pi = (PushItem) body.get(pos + 1);
|
||||
if (!(pi.value instanceof DuplicateSourceItem)) {
|
||||
break;
|
||||
}
|
||||
DuplicateSourceItem ds = (DuplicateSourceItem) pi.value;
|
||||
if (ds.tempIndex != sti.tempIndex) {
|
||||
break;
|
||||
}
|
||||
if (!(sti.value instanceof CastOpActionItem)) {
|
||||
break;
|
||||
}
|
||||
CastOpActionItem co = (CastOpActionItem) sti.value;
|
||||
int regNumber;
|
||||
if (co.object instanceof DirectValueActionItem) {
|
||||
DirectValueActionItem dv = (DirectValueActionItem) co.object;
|
||||
if (!(dv.value instanceof RegisterNumber)) {
|
||||
break;
|
||||
}
|
||||
RegisterNumber rn = (RegisterNumber) dv.value;
|
||||
regNumber = rn.number;
|
||||
} else if (co.object instanceof TemporaryRegister) {
|
||||
TemporaryRegister tr = (TemporaryRegister) co.object;
|
||||
regNumber = tr.getRegId();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
if (regNumber != catchRegister) {
|
||||
break;
|
||||
}
|
||||
|
||||
catchExceptionTypes.add(co.constructor);
|
||||
if (pos + 2 >= body.size()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(body.get(pos + 2) instanceof IfItem)) {
|
||||
break;
|
||||
}
|
||||
IfItem ifi = (IfItem) body.get(pos + 2);
|
||||
List<GraphTargetItem> onFalse = ifi.onFalse;
|
||||
int onFalsePos = 0;
|
||||
if (ifi.onFalse.isEmpty() && !ifi.onTrue.isEmpty() && ((ifi.onTrue.get(ifi.onTrue.size() - 1) instanceof ExitItem)
|
||||
|| (ifi.onTrue.get(ifi.onTrue.size() - 1) instanceof BreakItem)
|
||||
|| (ifi.onTrue.get(ifi.onTrue.size() - 1) instanceof ContinueItem))) {
|
||||
onFalse = body;
|
||||
onFalsePos = pos + 3;
|
||||
}
|
||||
|
||||
if (!ifi.onTrue.isEmpty() && (ifi.onTrue.get(0) instanceof DefineLocalActionItem)) {
|
||||
DefineLocalActionItem dl = (DefineLocalActionItem) ifi.onTrue.get(0);
|
||||
catchExceptionNames.add(dl.name);
|
||||
List<GraphTargetItem> catchBody = new ArrayList<>(ifi.onTrue);
|
||||
catchBody.remove(0);
|
||||
catchCommands.add(catchBody);
|
||||
if (onFalse.size() <= onFalsePos) {
|
||||
break;
|
||||
}
|
||||
if (!(onFalse.get(onFalsePos) instanceof PopItem)) {
|
||||
break;
|
||||
}
|
||||
pos = onFalsePos + 1;
|
||||
body = onFalse;
|
||||
//continue loopex;
|
||||
} else if (onFalse.size() > onFalsePos && (onFalse.get(onFalsePos) instanceof DefineLocalActionItem)) {
|
||||
DefineLocalActionItem dl = (DefineLocalActionItem) onFalse.get(onFalsePos);
|
||||
catchExceptionNames.add(dl.name);
|
||||
|
||||
List<GraphTargetItem> catchBody = new ArrayList<>();
|
||||
for (int i = onFalsePos; i < onFalse.size(); i++) {
|
||||
catchBody.add(onFalse.get(i));
|
||||
}
|
||||
catchBody.remove(0);
|
||||
catchCommands.add(catchBody);
|
||||
if (!ifi.onTrue.isEmpty()) {
|
||||
if (ifi.onTrue.get(0) instanceof PopItem) {
|
||||
pos = 1;
|
||||
body = ifi.onTrue;
|
||||
//continue loopex;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (body.get(pos) instanceof DefineLocalActionItem) {
|
||||
DefineLocalActionItem dl = (DefineLocalActionItem) body.get(pos);
|
||||
catchExceptionNames.add(dl.name);
|
||||
catchExceptionTypes.add(null);
|
||||
List<GraphTargetItem> catchBody = new ArrayList<>(body);
|
||||
catchBody.remove(0); //pop
|
||||
catchBody.remove(0); //definelocal
|
||||
catchCommands.add(catchBody);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
loopex:
|
||||
while (body.get(pos) instanceof PushItem) {
|
||||
PushItem pi = (PushItem) body.get(pos);
|
||||
@@ -459,7 +571,7 @@ public class ActionTry extends Action implements GraphSourceItemContainer {
|
||||
catchBody.remove(0); //pop
|
||||
catchBody.remove(0); //definelocal
|
||||
catchCommands.add(catchBody);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
} else {
|
||||
catchExceptionNames.add(new DirectValueActionItem(this, lineStartItem, -1, this.catchName, new ArrayList<>()));
|
||||
@@ -474,7 +586,7 @@ public class ActionTry extends Action implements GraphSourceItemContainer {
|
||||
p++;
|
||||
finallyCommands = contents.get(p);
|
||||
}
|
||||
output.add(new TryActionItem(tryCommands, catchExceptionNames, catchExceptionTypes, catchCommands, finallyCommands));
|
||||
stack.addToOutput(new TryActionItem(tryCommands, catchExceptionNames, catchExceptionTypes, catchCommands, finallyCommands));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4767,7 +4767,7 @@ public class Graph {
|
||||
* @param stack Stack
|
||||
*/
|
||||
public void makeAllCommands(List<GraphTargetItem> commands, TranslateStack stack) {
|
||||
stack.finishBlock(commands);
|
||||
stack.finishBlock(commands, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4959,7 +4959,7 @@ public class Graph {
|
||||
}
|
||||
}
|
||||
}
|
||||
subStack.finishBlock(currentCaseCommands);
|
||||
subStack.finishBlock(currentCaseCommands, true);
|
||||
caseCommands.add(currentCaseCommands);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,15 @@ public interface GraphSourceItem extends Serializable, Cloneable {
|
||||
*/
|
||||
public int getStackPushCount(BaseLocalData localData, TranslateStack stack);
|
||||
|
||||
/**
|
||||
* Gets stack delta. Stack push count - stack pop count.
|
||||
*
|
||||
* @param localData Local data
|
||||
* @param stack Stack
|
||||
* @return Stack delta
|
||||
*/
|
||||
public int getStackDelta(BaseLocalData localData, TranslateStack stack);
|
||||
|
||||
/**
|
||||
* Gets file offset.
|
||||
*
|
||||
|
||||
@@ -17,12 +17,10 @@
|
||||
package com.jpexs.decompiler.graph;
|
||||
|
||||
import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item;
|
||||
import com.jpexs.decompiler.graph.model.BranchStackResistant;
|
||||
import com.jpexs.decompiler.graph.model.BreakItem;
|
||||
import com.jpexs.decompiler.graph.model.CommaExpressionItem;
|
||||
import com.jpexs.decompiler.graph.model.ContinueItem;
|
||||
import com.jpexs.decompiler.graph.model.DuplicateItem;
|
||||
import com.jpexs.decompiler.graph.model.DuplicateSourceItem;
|
||||
@@ -88,15 +86,19 @@ public class TranslateStack extends Stack<GraphTargetItem> {
|
||||
|
||||
@Override
|
||||
public GraphTargetItem push(GraphTargetItem item) {
|
||||
if (!outputQueue.isEmpty()) {
|
||||
List<GraphTargetItem> myl = outputQueue;
|
||||
if (!outputQueue.isEmpty() && !myl.isEmpty()) {
|
||||
finishBlock(connectedOutput);
|
||||
/*
|
||||
if ((item instanceof FindPropertyAVM2Item) || isDupsOnly()) {
|
||||
finishBlock(connectedOutput);
|
||||
} else {
|
||||
outputQueue.add(item);
|
||||
item = new CommaExpressionItem(item.dialect, null, item.lineStartItem, outputQueue);
|
||||
outputQueue = new ArrayList<>();
|
||||
outputQueue = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
if (connectedOutput != null && item != null) {
|
||||
item.outputPos = prevOutputSize + connectedOutput.size();
|
||||
}
|
||||
@@ -304,10 +306,11 @@ public class TranslateStack extends Stack<GraphTargetItem> {
|
||||
return super.pop();
|
||||
}
|
||||
|
||||
public void moveToStack(List<GraphTargetItem> output) {
|
||||
public void moveToStack(List<GraphTargetItem> output) {
|
||||
List<GraphTargetItem> itemsBefore = new ArrayList<>();
|
||||
if (!isEmpty()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
int i = output.size() - 1;
|
||||
for (; i >= 0; i--) {
|
||||
if (!(output.get(i) instanceof PushItem)) {
|
||||
@@ -346,10 +349,14 @@ public class TranslateStack extends Stack<GraphTargetItem> {
|
||||
outputQueue.add(item);
|
||||
if (item instanceof ExitItem) {
|
||||
finishBlock(connectedOutput);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void finishBlock(List<GraphTargetItem> output) {
|
||||
finishBlock(output, false);
|
||||
}
|
||||
|
||||
public void finishBlock(List<GraphTargetItem> output, boolean makeBranch) {
|
||||
if (connectedOutput == null) {
|
||||
return;
|
||||
}
|
||||
@@ -403,7 +410,7 @@ public class TranslateStack extends Stack<GraphTargetItem> {
|
||||
}
|
||||
for (int i = size() - 1; i >= 0; i--) {
|
||||
GraphTargetItem p = get(i);
|
||||
if (p instanceof BranchStackResistant) {
|
||||
if (makeBranch && p instanceof BranchStackResistant) {
|
||||
continue;
|
||||
}
|
||||
remove(i);
|
||||
|
||||
Reference in New Issue
Block a user