-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
47 lines (33 loc) · 927 Bytes
/
main.c
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
#include "vm.h"
#include "values/values.h"
#include "values/process.h"
#include <stdio.h>
int main(int argc, char *argv[]) {
vm_t *v = vm_create();
value_t const *nil = value_create_nil();
value_t *proc = value_create_process();
value_t const *val = process_create_symbol(proc, "val");
value_t const *val2 = process_create_symbol(proc, "val");
printf("val: %p =? val2: %p\n", val, val2);
bytecode_t bt[] = {
// Those are symbols
// Binding assigns them to something
{OP_PUSH, val},
{OP_PUSH, nil},
{OP_CONS, nil},
{OP_ISATOM, nil},
{OP_DUMP, nil},
{OP_RET, nil}
};
int bc_len = 17;
value_t const *bc = value_create_bytecode(bt, bc_len);
printf("bc: %p len: %d\n", bc, bc_len);
process_attach_bytecode(proc, bc);
printf("proc: %p\n", proc);
process_print_symbols(proc);
vm_attach_process(v, proc);
vm_exec(v);
process_print_symbols(proc);
// debug_print_stack(&v);
return 0;
}