34 lines
691 B
C
34 lines
691 B
C
#ifndef RZ_VM_H
|
|
#define RZ_VM_H
|
|
|
|
#include "commons.h"
|
|
#include "opcodes.h"
|
|
#include "mod.h"
|
|
#include "err.h"
|
|
#include "tysy.h"
|
|
|
|
typedef struct {
|
|
tysy_t* tysy;
|
|
param_t stack[RZ_STACK_LIMIT];
|
|
size_t pc;
|
|
size_t bp;
|
|
size_t sp;
|
|
|
|
err_t* err;
|
|
} vm_t;
|
|
|
|
void vm_init(vm_t* vm, tysy_t* tysy, err_t* err);
|
|
void vm_free(vm_t* vm);
|
|
|
|
void vm_push_value(vm_t* vm, mod_t* mod, value_t* value);
|
|
void vm_push(vm_t* vm, param_t param);
|
|
param_t vm_pop(vm_t* vm);
|
|
|
|
size_t vm_stack_str(vm_t* vm, char* buffer, size_t size);
|
|
|
|
int vm_exec_mod(vm_t* vm, mod_t* mod);
|
|
int vm_exec_instr(vm_t* vm, mod_t* mod, Opcode op, param_t param);
|
|
void vm_ensure_type(vm_t* vm, value_t* value, TypeKind want);
|
|
|
|
#endif
|