Files
fz-lang/include/vm/fzl_vm.h
T

45 lines
750 B
C

#ifndef FZL_VM_H
#define FZL_VM_H
#include <common/fzl_value.h>
#include <compiler/utils/fzl_const_pool.h> // NOTE: move outside compiler scope to common
#include <stddef.h>
#include <stdint.h>
// VM descriptor
typedef struct
{
fzl_const_t *consts;
size_t consts_count;
uint64_t *ops;
size_t ops_count;
size_t ip;
// Data stack
fzl_value_t dstack[256];
size_t dtop;
// Call stack
size_t cstack[256];
size_t ctop;
// Environment stack
// TODO: implement `estack` and `etop`
} fzl_vm_t;
// Allocate FZL VM
fzl_vm_t *fzl_mkvm(const char *filepath);
// Load and run code
int fzl_vm_run(fzl_vm_t *vm);
// Get last VM error message
char *fzl_vm_geterror();
// Free VM
void fzl_freevm(fzl_vm_t *vm);
#endif // FZL_VM_H