|
5 | 5 | #include "print.h" |
6 | 6 | #include "runtime.h" |
7 | 7 |
|
| 8 | +#include "types.h" |
| 9 | + |
8 | 10 | FILE* in; |
9 | 11 | FILE* out; |
10 | 12 | void (*error_handler)(); |
@@ -33,45 +35,10 @@ int main(int argc, char** argv) |
33 | 35 | result = entry(heap); |
34 | 36 |
|
35 | 37 | print_result(result); |
| 38 | + |
36 | 39 | if (val_typeof(result) != T_VOID) |
37 | | - putchar('\n'); |
| 40 | + putchar('\n'); |
38 | 41 |
|
39 | 42 | free(heap); |
40 | 43 | return 0; |
41 | 44 | } |
42 | | - |
43 | | -const char* val_typeof_string(int64_t t) { |
44 | | - switch (val_typeof(t)) { |
45 | | - case T_INT: return "INT"; |
46 | | - case T_BOOL: return "BOOL"; |
47 | | - case T_CHAR: return "CHAR"; |
48 | | - case T_EOF: return "EOF"; |
49 | | - case T_VOID: return "VOID"; |
50 | | - case T_EMPTY: return "EMPTY"; |
51 | | - case T_BOX: return "BOX"; |
52 | | - case T_CONS: return "CONS"; |
53 | | - case T_VECT: return "VECT"; |
54 | | - case T_STR: return "STR"; |
55 | | - default: return "UNKNOWN"; |
56 | | - } |
57 | | -} |
58 | | - |
59 | | - |
60 | | - |
61 | | -void print_memory(int64_t* rsp, int64_t rbp, int64_t rbx) { |
62 | | - int stack_count = (rbp-(int64_t)rsp) / 8; |
63 | | - int heap_count = (rbx-(int64_t)heap) / 8; |
64 | | - |
65 | | - printf("----------------------------------------------------------------\n"); |
66 | | - // printf("rsp: %" PRIx64 ", rbp: %" PRIx64 ", stack count: %d, heap count: %d\n", (int64_t)rsp, rbp, stack_count, heap_count); |
67 | | - int i; |
68 | | - |
69 | | - printf("STACK:\n"); |
70 | | - for (i = 0; i < stack_count; i++) { |
71 | | - printf("[%" PRIx64 "] = %016" PRIx64 ", %s\n", (int64_t)rsp + i, rsp[i], val_typeof_string(rsp[i])); |
72 | | - } |
73 | | - printf("HEAP:\n"); |
74 | | - for (i = 0; i < heap_count; i++) { |
75 | | - printf("[%" PRIx64 "] = %016" PRIx64 ", %s\n", (int64_t)heap + i, heap[i], val_typeof_string(heap[i])); |
76 | | - } |
77 | | -} |
0 commit comments