start working on runtime

This commit is contained in:
2025-06-20 02:50:05 +01:00
parent e5e4f22481
commit bddfb59886
7 changed files with 55 additions and 10 deletions

23
src/runtime/runtime.c Normal file
View File

@@ -0,0 +1,23 @@
#include "runtime.h"
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
uint64_t pop_bytecode(Translated *translated, RuntimeState *state) {
uint64_t *instruction = darray_get(&translated->bytecode, state->head++);
return *instruction;
}
void run_instruction(Translated *translated, RuntimeState *state) {
uint64_t opcode = pop_bytecode(translated, state);
switch (opcode) { case OP_LOAD_NULL: }
}
void runtime(Translated translated) {
RuntimeState state = {
checked_malloc(translated.registerCount * sizeof(size_t)), 0};
while (state.head < translated.bytecode.size)
run_instruction(&translated, &state);
free(state.registers);
}