]> git.lizzy.rs Git - uwu-lang.git/blob - api/ref.c
Unify value types
[uwu-lang.git] / api / ref.c
1 #include "../src/util.h"
2 #include "ref.h"
3
4 UwUVMValue uwuref_create(UwUVMFunction *function)
5 {
6         return (UwUVMValue) {
7                 .type = &uwuref_type,
8                 .data = function,
9         };
10 }
11
12 static void *uwuref_copy(void *data)
13 {
14         return data;
15 }
16
17 static void uwuref_delete(void *data)
18 {
19         (void) data;
20 }
21
22 static char *uwuref_print(void *data)
23 {
24         return asprintf_wrapper("[Function reference: %p]", data);
25 }
26
27 UwUVMType uwuref_type = {
28         .copy = &uwuref_copy,
29         .delete = &uwuref_delete,
30         .print = &uwuref_print,
31 };