summaryrefslogtreecommitdiff
path: root/dis.c
diff options
context:
space:
mode:
Diffstat (limited to 'dis.c')
-rw-r--r--dis.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/dis.c b/dis.c
index 2d7e9a2..530ad49 100644
--- a/dis.c
+++ b/dis.c
@@ -10,6 +10,41 @@ static void print_const(Chunk *ch, uint8_t ix) {
println_val(k);
}
+
+char *op_name(Op op) {
+ switch (op) {
+ case OP_RET: return "ret"; break;
+ case OP_LOADK: return "loadk"; break;
+ case OP_ADD: return "add"; break;
+ case OP_SUB: return "sub"; break;
+ case OP_MUL: return "mul"; break;
+ case OP_DIV: return "div"; break;
+ case OP_MOD: return "mod"; break;
+ case OP_EQU: return "equ"; break;
+ case OP_CMP: return "cmp"; break;
+ case OP_HALT: return "halt"; break;
+ case OP_DROP: return "drop"; break;
+ case OP_GETGLOBAL: return "getglobal"; break;
+ case OP_SETGLOBAL: return "setglobal"; break;
+ case OP_GETLOCAL: return "getlocal"; break;
+ case OP_SETLOCAL: return "setlocal"; break;
+ case OP_TRUE: return "true"; break;
+ case OP_FALSE: return "false"; break;
+ case OP_NIL: return "nil"; break;
+ case OP_0BRANCH: return "0branch"; break;
+ case OP_SKIP: return "skip"; break;
+ case OP_REDO: return "redo"; break;
+ case OP_CALL: return "call"; break;
+ case OP_TAILCALL: return "tailcall"; break;
+ case OP_ENDSCOPE: return "endscope"; break;
+ case OP_ARRNEW: return "arrnew"; break;
+ case OP_ARRAPPEND: return "arrappend"; break;
+ case OP_ARRLEN: return "arrlen"; break;
+ case OP_SETIDX: return "setidx"; break;
+ default: return "???"; break;
+ }
+}
+
static void disasm_chunk_h(Chunk *ch, int depth);
void disasm_chunk(Chunk *ch) {
disasm_chunk_h(ch, 0);