aboutsummaryrefslogtreecommitdiff
path: root/vm/runtime.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-11-01 20:08:40 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-11-01 20:08:40 +0000
commit0f295221cac3cfe507cafa6cbf012c51537ce1c8 (patch)
tree13e7aa6767a8774b4fcf1f5d2b3e7547fb5f551c /vm/runtime.c
parent525694bea7724d612a8b742943a0ed2aed5822f8 (diff)
downloadovm-0f295221cac3cfe507cafa6cbf012c51537ce1c8.tar.gz
ovm-0f295221cac3cfe507cafa6cbf012c51537ce1c8.tar.bz2
ovm-0f295221cac3cfe507cafa6cbf012c51537ce1c8.zip
VM runtime now maintains a heap internally
Now need to create some instructions which manage the heap
Diffstat (limited to 'vm/runtime.c')
-rw-r--r--vm/runtime.c11
1 files changed, 11 insertions, 0 deletions
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)