blob: 8446d1d7c1a2c01b2caeb6451b0a672a6f681778 (
plain)
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
|
#include <stdlib.h>
#include "../src/util.h"
#include "int.h"
UwUVMValue uwuint_create(int value)
{
UwUVMValue vm_value = {
.type = &uwuint_type,
.data = malloc(sizeof(int))
};
*(int *) vm_value.data = value;
return vm_value;
}
int uwuint_get(UwUVMValue vm_value)
{
return *(int *) vm_value.data;
}
void *uwuint_clone(void *data)
{
int *copy = malloc(sizeof(*copy));
*copy = *(int *) data;
return copy;
}
char *uwuint_print(void *data)
{
return asprintf_wrapper("%d", *(int *) data);
}
UwUVMType uwuint_type = {
.clone = &uwuint_clone,
.delet = &free,
.print = &uwuint_print,
};
|