Files
fz-lang/include/vm/fzl_vm.h
T
samsonium dce64e8b4d fix+ref: small objects rework
- Add nested objects escape on ESCAPE opcode
- Stabilize objects work in heap
2026-10-18 17:38:49 +03:00

51 lines
874 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>
#include <vm/fzl_vm_env.h>
#include <vm/fzl_vm_object.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
fzl_vm_env_t *estack[256];
size_t 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();
// Print opcodes sequence
void fzl_vm_print_ops(fzl_vm_t *vm);
// Free VM
void fzl_freevm(fzl_vm_t *vm);
#endif // FZL_VM_H