| 37 | import unluac.util.Stack; |
| 38 | |
| 39 | public class ControlFlowHandler { |
| 40 | |
| 41 | public static boolean verbose = false; |
| 42 | |
| 43 | private static class Branch implements Comparable<Branch> { |
| 44 | |
| 45 | private static enum Type { |
| 46 | comparison, |
| 47 | test, |
| 48 | testset, |
| 49 | finalset, |
| 50 | jump; |
| 51 | } |
| 52 | |
| 53 | public Branch previous; |
| 54 | public Branch next; |
| 55 | public int line; |
| 56 | public int line2; |
| 57 | public int target; |
| 58 | public Type type; |
| 59 | public Condition cond; |
| 60 | public int targetFirst; |
| 61 | public int targetSecond; |
| 62 | public boolean inverseValue; |
| 63 | public FinalSetCondition finalset; |
| 64 | |
| 65 | public Branch(int line, int line2, Type type, Condition cond, int targetFirst, int targetSecond, FinalSetCondition finalset) { |
| 66 | this.line = line; |
| 67 | this.line2 = line2; |
| 68 | this.type = type; |
| 69 | this.cond = cond; |
| 70 | this.targetFirst = targetFirst; |
| 71 | this.targetSecond = targetSecond; |
| 72 | this.inverseValue = false; |
| 73 | this.target = -1; |
| 74 | this.finalset = finalset; |
| 75 | } |
| 76 | |
| 77 | @Override |
| 78 | public int compareTo(Branch other) { |
| 79 | return this.line - other.line; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | private static class State { |
| 84 | public Decompiler d; |
| 85 | public LFunction function; |
| 86 | public Registers r; |
| 87 | public Code code; |
| 88 | public Branch begin_branch; |
| 89 | public Branch end_branch; |
| 90 | public Branch[] branches; |
| 91 | public Branch[] setbranches; |
| 92 | public ArrayList<List<Branch>> finalsetbranches; |
| 93 | public boolean[] reverse_targets; |
| 94 | public int[] resolved; |
| 95 | public boolean[] labels; |
| 96 | public List<Block> blocks; |
nothing calls this directly
no outgoing calls
no test coverage detected