feat: implement vm
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#ifndef FZL_VM_H
|
||||
#define FZL_VM_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;
|
||||
|
||||
fzl_const_t stack[256];
|
||||
size_t stack_top;
|
||||
|
||||
fzl_const_t arg_stack[256];
|
||||
size_t arg_top;
|
||||
} 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
|
||||
Reference in New Issue
Block a user