mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-05 20:37:32 +00:00
AS1/2 and AS3 now share common decompiling method
This commit is contained in:
64
trunk/src/com/jpexs/decompiler/flash/graph/GraphSource.java
Normal file
64
trunk/src/com/jpexs/decompiler/flash/graph/GraphSource.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package com.jpexs.decompiler.flash.graph;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public abstract class GraphSource {
|
||||
|
||||
public abstract int size();
|
||||
|
||||
public abstract GraphSourceItem get(int pos);
|
||||
|
||||
public abstract boolean isEmpty();
|
||||
|
||||
public abstract List<GraphTargetItem> translatePart(List localData, Stack<GraphTargetItem> stack, int start, int end);
|
||||
|
||||
private void visitCode(int ip, int lastIp, HashMap<Integer, List<Integer>> refs) {
|
||||
while (ip < size()) {
|
||||
refs.get(ip).add(lastIp);
|
||||
lastIp = ip;
|
||||
if (refs.get(ip).size() > 1) {
|
||||
break;
|
||||
}
|
||||
GraphSourceItem ins = get(ip);
|
||||
|
||||
|
||||
if (ins.isExit()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (ins.isBranch() || ins.isJump()) {
|
||||
List<Integer> branches = ins.getBranches(this);
|
||||
for (int b : branches) {
|
||||
visitCode(b, ip, refs);
|
||||
}
|
||||
break;
|
||||
}
|
||||
ip++;
|
||||
};
|
||||
}
|
||||
|
||||
public HashMap<Integer, List<Integer>> visitCode(List<Integer> alternateEntries) {
|
||||
HashMap<Integer, List<Integer>> refs = new HashMap<Integer, List<Integer>>();
|
||||
for (int i = 0; i < size(); i++) {
|
||||
refs.put(i, new ArrayList<Integer>());
|
||||
}
|
||||
visitCode(0, 0, refs);
|
||||
int pos = 0;
|
||||
for (int e : alternateEntries) {
|
||||
pos++;
|
||||
visitCode(e, -pos, refs);
|
||||
}
|
||||
return refs;
|
||||
}
|
||||
|
||||
public abstract int adr2pos(long adr);
|
||||
|
||||
public abstract long pos2adr(int pos);
|
||||
}
|
||||
Reference in New Issue
Block a user