MCPcopy Create free account
hub / github.com/Hiro420/NikkeTools / Disassembler

Class Disassembler

UnLuac/src/unluac/decompile/Disassembler.java:10–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8import unluac.util.StringUtils;
9
10public class Disassembler {
11
12 private final LFunction function;
13 private final Code code;
14 private final String name;
15 private final String parent;
16
17 public Disassembler(LFunction function) {
18 this(function, "main", null);
19 }
20
21 private Disassembler(LFunction function, String name, String parent) {
22 this.function = function;
23 this.code = new Code(function);
24 this.name = name;
25 this.parent = parent;
26 }
27
28 public void disassemble(Output out) {
29 disassemble(out, 0, 0);
30 }
31
32 private void disassemble(Output out, int level, int index) {
33 if(parent == null) {
34 out.println(".version\t" + function.header.version.getName());
35 out.println();
36
37 for(Directive directive : function.header.lheader_type.get_directives()) {
38 directive.disassemble(out, function.header, function.header.lheader);
39 }
40 out.println();
41
42 if(function.header.opmap != function.header.version.getOpcodeMap()) {
43 OpcodeMap opmap = function.header.opmap;
44 for(int opcode = 0; opcode < opmap.size(); opcode++) {
45 Op op = opmap.get(opcode);
46 if(op != null) {
47 out.println(Directive.OP.token + "\t" + opcode + "\t" + op.name);
48 }
49 }
50 out.println();
51 }
52 }
53
54 String fullname;
55 if(parent == null) {
56 fullname = name;
57 } else {
58 fullname = parent + "/" + name;
59 }
60 out.println(".function\t" + fullname);
61 out.println();
62
63 for(Directive directive : function.header.function.get_directives()) {
64 directive.disassemble(out, function.header, function);
65 }
66 out.println();
67

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected