feat: implement vm

This commit is contained in:
samsonium
2026-10-10 05:38:16 +03:00
parent 96115b347e
commit cdf929dfc4
4 changed files with 315 additions and 3 deletions
+38
View File
@@ -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