From 0f295221cac3cfe507cafa6cbf012c51537ce1c8 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Wed, 1 Nov 2023 20:08:40 +0000 Subject: VM runtime now maintains a heap internally Now need to create some instructions which manage the heap --- vm/runtime.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'vm/runtime.c') diff --git a/vm/runtime.c b/vm/runtime.c index 622228f..0fbea05 100644 --- a/vm/runtime.c +++ b/vm/runtime.c @@ -326,11 +326,22 @@ void vm_load_registers(vm_t *vm, registers_t registers) vm->registers = registers; } +void vm_load_heap(vm_t *vm, heap_t heap) +{ + vm->heap = heap; +} + void vm_stop(vm_t *vm) { free(vm->registers.data); free(vm->program.instructions); free(vm->stack.data); + heap_stop(&vm->heap); + + vm->registers = (registers_t){0}; + vm->program = (struct Program){0}; + vm->stack = (struct Stack){0}; + vm->heap = (heap_t){0}; } void vm_print_registers(vm_t *vm, FILE *fp) -- cgit v1.2.3-13-gbd6f