39 lines
714 B
C
39 lines
714 B
C
#pragma once
|
|
#include <stdint.h>
|
|
|
|
#include "vector.h"
|
|
|
|
#define MAXARG 12
|
|
#define MAXLOC 64
|
|
|
|
#define REF_NATIVE (1 << 0)
|
|
struct vm_ref_entry {
|
|
size_t unit_index;
|
|
int flags;
|
|
union {
|
|
size_t ref_index;
|
|
uintptr_t ref_native;
|
|
};
|
|
};
|
|
|
|
struct vm_func_entry {
|
|
size_t argc, local_count;
|
|
uint64_t local_regs[MAXLOC];
|
|
uint64_t arg_regs[MAXARG];
|
|
uint32_t *bytecode;
|
|
};
|
|
|
|
struct vm_unit {
|
|
struct vector ref_table;
|
|
struct vector functions;
|
|
|
|
uint64_t *global_pool;
|
|
size_t global_pool_size;
|
|
|
|
int is_loaded;
|
|
};
|
|
|
|
struct vm_func_entry *unit_add_function(struct vm_unit *u);
|
|
struct vm_ref_entry *unit_add_ref(struct vm_unit *u);
|
|
void unit_free(struct vm_unit *u);
|