roza/lib/vm.h

29 lines
484 B
C
Raw Normal View History

2023-12-09 17:24:41 +00:00
#ifndef RZ_VM_H
#define RZ_VM_H
#include "commons.h"
#include "opcodes.h"
#include "mod.h"
2023-12-11 17:01:22 +00:00
#include "err.h"
2023-12-09 17:24:41 +00:00
typedef struct {
param_t stack[RZ_STACK_LIMIT];
size_t pc;
size_t bp;
size_t sp;
2023-12-11 17:01:22 +00:00
err_t* err;
2023-12-09 17:24:41 +00:00
} vm_t;
2023-12-11 17:01:22 +00:00
void vm_init(vm_t* vm, err_t* err);
2023-12-09 17:24:41 +00:00
void vm_free(vm_t* vm);
2023-12-11 17:01:22 +00:00
param_t vm_pop(vm_t* vm);
2023-12-09 17:24:41 +00:00
size_t vm_stack_str(vm_t* vm, char* buffer, size_t size);
int vm_exec_mod(vm_t* vm, mod_t* mod);
2023-12-11 17:01:22 +00:00
int vm_exec_instr(vm_t* vm, mod_t* mod, Opcode op, param_t param);
2023-12-09 17:24:41 +00:00
#endif