mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 19:00:43 +00:00
usinig sets for known addresses, some deepcopy call modified to clone() call
This commit is contained in:
@@ -81,7 +81,9 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EmptyStackException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -164,7 +166,7 @@ public class Action implements GraphSourceItem {
|
||||
*
|
||||
* @param refs list of addresses
|
||||
*/
|
||||
public void getRef(List<Long> refs) {
|
||||
public void getRef(Set<Long> refs) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,8 +175,8 @@ public class Action implements GraphSourceItem {
|
||||
* @param list List of actions
|
||||
* @return List of addresses
|
||||
*/
|
||||
public static List<Long> getActionsAllRefs(List<Action> list) {
|
||||
List<Long> ret = new ArrayList<>();
|
||||
public static Set<Long> getActionsAllRefs(List<Action> list) {
|
||||
Set<Long> ret = new HashSet<>();
|
||||
for (Action a : list) {
|
||||
a.getRef(ret);
|
||||
}
|
||||
@@ -403,7 +405,7 @@ public class Action implements GraphSourceItem {
|
||||
*/
|
||||
public static GraphTextWriter actionsToString(List<DisassemblyListener> listeners, long address, ActionList list, int version, ScriptExportMode exportMode, GraphTextWriter writer) {
|
||||
long offset;
|
||||
List<Long> importantOffsets = getActionsAllRefs(list);
|
||||
Set<Long> importantOffsets = getActionsAllRefs(list);
|
||||
/*List<ConstantPool> cps = SWFInputStream.getConstantPool(new ArrayList<DisassemblyListener>(), new ActionGraphSource(list, version, new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(), new HashMap<String, GraphTargetItem>()), 0, version, path);
|
||||
if (!cps.isEmpty()) {
|
||||
setConstantPool(list, cps.get(cps.size() - 1));
|
||||
@@ -583,7 +585,7 @@ public class Action implements GraphSourceItem {
|
||||
* @param exportMode PCode or hex?
|
||||
* @return String of P-code source
|
||||
*/
|
||||
public String getASMSource(ActionList container, List<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
public String getASMSource(ActionList container, Set<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
return toString();
|
||||
}
|
||||
|
||||
@@ -1220,7 +1222,7 @@ public class Action implements GraphSourceItem {
|
||||
}
|
||||
}
|
||||
|
||||
public GraphTextWriter getASMSourceReplaced(ActionList container, List<Long> knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) {
|
||||
public GraphTextWriter getASMSourceReplaced(ActionList container, Set<Long> knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) {
|
||||
writer.appendNoHilight(getASMSource(container, knownAddreses, exportMode));
|
||||
return writer;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.jpexs.helpers.Helper;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -806,7 +807,7 @@ public class ActionListReader {
|
||||
}
|
||||
|
||||
if (debugMode) {
|
||||
String atos = a.getASMSource(new ActionList(), new ArrayList<Long>(), ScriptExportMode.PCODE);
|
||||
String atos = a.getASMSource(new ActionList(), new HashSet<Long>(), ScriptExportMode.PCODE);
|
||||
if (a instanceof GraphSourceItemContainer) {
|
||||
atos = a.toString();
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ActionWaitForFrame extends Action implements ActionStore {
|
||||
|
||||
@@ -56,7 +57,7 @@ public class ActionWaitForFrame extends Action implements ActionStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getASMSource(ActionList container, List<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
public String getASMSource(ActionList container, Set<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
String ret = "WaitForFrame " + frame + " " + skipCount;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.jpexs.helpers.Helper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -57,7 +58,7 @@ public class ActionIf extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRef(List<Long> refs) {
|
||||
public void getRef(Set<Long> refs) {
|
||||
refs.add(getAddress() + getTotalActionLength() + offset);
|
||||
}
|
||||
|
||||
@@ -75,7 +76,7 @@ public class ActionIf extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getASMSource(ActionList container, List<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
public String getASMSource(ActionList container, Set<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
long address = getAddress() + getTotalActionLength() + offset;
|
||||
String ofsStr = Helper.formatAddress(address);
|
||||
return "If loc" + ofsStr + (!jumpUsed ? " ;compileTimeIgnore" : (!ignoreUsed ? " ;compileTimeJump" : ""));
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.jpexs.helpers.Helper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -58,7 +59,7 @@ public class ActionJump extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRef(List<Long> refs) {
|
||||
public void getRef(Set<Long> refs) {
|
||||
refs.add(getAddress() + getTotalActionLength() + offset);
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ public class ActionJump extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getASMSource(ActionList container, List<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
public String getASMSource(ActionList container, Set<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
long address = getAddress() + getTotalActionLength() + offset;
|
||||
String ofsStr = Helper.formatAddress(address);
|
||||
return "Jump loc" + ofsStr;
|
||||
|
||||
@@ -43,6 +43,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ActionPush extends Action {
|
||||
|
||||
@@ -232,7 +233,7 @@ public class ActionPush extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter getASMSourceReplaced(ActionList container, List<Long> knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) {
|
||||
public GraphTextWriter getASMSourceReplaced(ActionList container, Set<Long> knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) {
|
||||
if (replacement == null || replacement.size() < values.size()) {
|
||||
return toString(writer);
|
||||
}
|
||||
@@ -243,7 +244,7 @@ public class ActionPush extends Action {
|
||||
return writer;
|
||||
}
|
||||
|
||||
public GraphTextWriter paramsToStringReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) {
|
||||
public GraphTextWriter paramsToStringReplaced(List<? extends GraphSourceItem> container, Set<Long> knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) {
|
||||
if (replacement == null || replacement.size() < values.size()) {
|
||||
return paramsToString(writer);
|
||||
}
|
||||
|
||||
+2
-1
@@ -35,6 +35,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ActionWaitForFrame2 extends Action implements ActionStore {
|
||||
|
||||
@@ -117,7 +118,7 @@ public class ActionWaitForFrame2 extends Action implements ActionStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getASMSource(ActionList container, List<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
public String getASMSource(ActionList container, Set<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
String ret = "WaitForFrame2 " + skipCount;
|
||||
/*for (int i = 0; i < skipped.size(); i++) {
|
||||
if (skipped.get(i) instanceof ActionEnd) {
|
||||
|
||||
+3
-2
@@ -35,6 +35,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ActionDefineFunction extends Action implements GraphSourceItemContainer {
|
||||
|
||||
@@ -103,7 +104,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getASMSource(ActionList container, List<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
public String getASMSource(ActionList container, Set<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
StringBuilder paramStr = new StringBuilder();
|
||||
for (int i = 0; i < paramNames.size(); i++) {
|
||||
paramStr.append("\"").append(Helper.escapeString(paramNames.get(i))).append("\" ");
|
||||
@@ -113,7 +114,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter getASMSourceReplaced(ActionList container, List<Long> knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) {
|
||||
public GraphTextWriter getASMSourceReplaced(ActionList container, Set<Long> knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) {
|
||||
List<String> oldParamNames = paramNames;
|
||||
if (replacedParamNames != null) {
|
||||
paramNames = replacedParamNames;
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ActionWith extends Action implements GraphSourceItemContainer {
|
||||
|
||||
@@ -76,7 +77,7 @@ public class ActionWith extends Action implements GraphSourceItemContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getASMSource(ActionList container, List<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
public String getASMSource(ActionList container, Set<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
return "With {";
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -35,6 +35,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ActionDefineFunction2 extends Action implements GraphSourceItemContainer {
|
||||
|
||||
@@ -160,7 +161,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter getASMSourceReplaced(ActionList container, List<Long> knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) {
|
||||
public GraphTextWriter getASMSourceReplaced(ActionList container, Set<Long> knownAddreses, ScriptExportMode exportMode, GraphTextWriter writer) {
|
||||
List<String> oldParamNames = paramNames;
|
||||
if (replacedParamNames != null) {
|
||||
paramNames = replacedParamNames;
|
||||
@@ -178,7 +179,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getASMSource(ActionList container, List<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
public String getASMSource(ActionList container, Set<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
StringBuilder paramStr = new StringBuilder();
|
||||
for (int i = 0; i < paramNames.size(); i++) {
|
||||
paramStr.append(paramRegisters.get(i)).append(" \"").append(Helper.escapeString(paramNames.get(i))).append("\" ");
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ActionTry extends Action implements GraphSourceItemContainer {
|
||||
|
||||
@@ -149,7 +150,7 @@ public class ActionTry extends Action implements GraphSourceItemContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getASMSource(ActionList container, List<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
public String getASMSource(ActionList container, Set<Long> knownAddreses, ScriptExportMode exportMode) {
|
||||
StringBuilder ret = new StringBuilder();
|
||||
ret.append("Try ");
|
||||
if (catchBlockFlag) {
|
||||
|
||||
Reference in New Issue
Block a user