]> git.lizzy.rs Git - uwu-lang.git/blob - api/ref.c
Add :ref module and refactor type handling
[uwu-lang.git] / api / ref.c
1 #include "../src/util.h"
2 #include "ref.h"
3
4 UwUVMValue uwuref_create(UwUVMFunction *value)
5 {
6         return (UwUVMValue) {
7                 .type = &uwuref_type,
8                 .data = value,
9         };
10 }
11
12 UwUVMFunction *uwuref_get(UwUVMValue value)
13 {
14         return value.data;
15 }
16
17 static void *uwuref_clone(void *data)
18 {
19         return data;
20 }
21
22 static void uwuref_delet(void *data)
23 {
24         (void) data;
25 }
26
27 static char *uwuref_print(void *data)
28 {
29         return asprintf_wrapper("[Function reference: %p]", data);
30 }
31
32 UwUVMType uwuref_type = {
33         .clone = &uwuref_clone,
34         .delet = &uwuref_delet,
35         .print = &uwuref_print,
36 };