aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bytecode/main.c')
-rwxr-xr-xsrc/bytecode/main.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/bytecode/main.c b/src/bytecode/main.c
index d1fbac2..e4cf643 100755
--- a/src/bytecode/main.c
+++ b/src/bytecode/main.c
@@ -45,22 +45,27 @@ process_source(const StringView *source) {
45 } 45 }
46 46
47 // Compile chunk. 47 // Compile chunk.
48 Chunk *chunk = compile(tokens); 48 Object main = compile(tokens);
49 if (errors_n != 0) { 49 if (errors_n != 0) {
50 chunk_free(chunk); 50 object_free(main);
51 array_free(tokens); 51 array_free(tokens);
52 return; 52 return;
53 } 53 }
54 54
55#ifdef DEBUG 55#ifdef DEBUG
56 disassemble_chunk(chunk); 56 disassemble_chunk(main.chunk);
57#endif 57#endif
58 58
59 // Interpret chunk. 59 // Interpret chunk.
60 vm_interpret(&vm, chunk); 60 CallFrame frame = (CallFrame){
61 .procedure = main,
62 .pc = main.chunk->code,
63 };
64 array_push(vm.frames, frame);
65 vm_interpret(&vm);
61 66
62 // Free resources. 67 // Free resources.
63 chunk_free(chunk); 68 object_free(main);
64 array_free(tokens); 69 array_free(tokens);
65} 70}
66 71