-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvm.h
38 lines (29 loc) · 755 Bytes
/
vm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef VM_H
#define VM_H
#include <stdlib.h>
#include "value.h"
enum opcode {
#define X(name) opcode_ ## name,
# include "opcode.def"
#undef X
};
typedef struct compiled_func compiled_func_t;
typedef struct compiled_file compiled_file_t;
struct compiled_func {
char *param_name; // may be null
unsigned char *code;
value_t *consts;
struct bvalue *bconsts;
size_t const_count;
compiled_file_t *file;
};
struct compiled_file {
compiled_func_t *funcs;
size_t func_count;
};
value_t call_func(value_t func, value_t arg);
// The optional `<parent>` property of the scope must be set
value_t eval_func(value_t func, value_t scope);
// Returns -1 on error
enum opcode string_to_opcode(const char *s);
#endif /* VM_H */