-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patheval.h
More file actions
74 lines (60 loc) · 1.44 KB
/
eval.h
File metadata and controls
74 lines (60 loc) · 1.44 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef cb_eval_h
#define cb_eval_h
#include <stddef.h>
#include "code.h"
#include "compiler.h"
#include "gc.h"
#include "hashmap.h"
#include "value.h"
struct cb_upvalue {
size_t refcount;
int is_closed;
union {
size_t idx;
struct cb_value value;
} v;
};
struct cb_frame {
struct cb_frame *parent;
size_t module_id;
int is_function, is_native;
unsigned num_args;
struct cb_code *code;
size_t bp;
/* A pointer to the sp variable for the GC */
struct cb_value *const *sp;
};
union cb_inline_cache {
struct cb_load_struct_cache {
const struct cb_struct_spec *spec;
ssize_t index;
} load_struct;
struct cb_load_global_cache {
size_t version;
size_t index;
} load_global;
struct cb_load_from_module_cache {
size_t version;
size_t index;
} load_from_module;
};
struct cb_vm_state {
struct cb_frame *frame;
struct cb_value *stack;
size_t stack_size;
struct cb_upvalue **upvalues;
size_t upvalues_idx, upvalues_size;
/* size of this array is based on number of modspecs in agent */
struct cb_module *modules;
struct cb_error *error;
};
extern struct cb_vm_state cb_vm_state;
void cb_vm_init(void);
void cb_vm_deinit(void);
void cb_vm_grow_modules_array();
int cb_run(struct cb_code *code);
int cb_vm_call(struct cb_value fn, struct cb_value *args, size_t args_len,
struct cb_value *result);
struct cb_value cb_load_upvalue(struct cb_upvalue *uv);
void cb_store_upvalue(struct cb_upvalue *uv, struct cb_value val);
#endif