1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #ifndef L2_VM_H
- #define L2_VM_H
-
- #include <stdlib.h>
-
- #include "bytecode.h"
- #include "bitset.h"
-
- struct l2_vm_value {
- enum l2_value_flags {
- L2_VAL_TYPE_NONE,
- L2_VAL_TYPE_INTEGER,
- L2_VAL_TYPE_REAL,
- L2_VAL_TYPE_ARRAY,
- L2_VAL_TYPE_BUFFER,
- L2_VAL_MARKED = 1 << 7,
- L2_VAL_CONST = 1 << 8,
- } flags;
- union {
- int64_t integer;
- double real;
- void *data;
- };
- };
-
- struct l2_vm_buffer {
- struct l2_vm_value val;
- size_t len;
- };
-
- struct l2_vm_array {
- struct l2_vm_value val;
- size_t len;
- size_t size;
- };
-
- struct l2_vm {
- l2_word *ops;
- size_t opcount;
-
- struct l2_vm_value *values;
- size_t valuessize;
- struct l2_bitset valueset;
-
- l2_word stack[1024];
- unsigned char stackflags[1024];
- l2_word iptr;
- l2_word sptr;
- };
-
- void l2_vm_init(struct l2_vm *vm, l2_word *ops, size_t opcount);
- void l2_vm_step(struct l2_vm *vm);
- void l2_vm_run(struct l2_vm *vm);
- size_t l2_vm_gc(struct l2_vm *vm);
-
- #endif
|