diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-12-30 16:02:10 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-12-30 16:02:10 +0100 |
commit | 058d954e80f83c26deb209008f11d87a5b59418e (patch) | |
tree | ef7b5a95cfd1dbdba71041e1f0608d551adfa360 /api/bool.c | |
parent | 3ba311b0afdf9cc62d630687d171bee0b6435e4a (diff) | |
download | uwu-lang-058d954e80f83c26deb209008f11d87a5b59418e.tar.xz |
Unify value types
Diffstat (limited to 'api/bool.c')
-rw-r--r-- | api/bool.c | 23 |
1 files changed, 8 insertions, 15 deletions
@@ -7,27 +7,20 @@ UwUVMValue uwubool_create(bool value) { UwUVMValue vm_value = { - .type = VT_NAT, - .value = { - .nat_value = { - .type = &uwubool_type, - .data = malloc(sizeof(bool)) - }, - }, + .type = &uwubool_type, + .data = malloc(sizeof(bool)), }; - *(bool *) vm_value.value.nat_value.data = value; + *(bool *) vm_value.data = value; return vm_value; } bool uwubool_get(UwUVMValue vm_value) { - if (vm_value.type != VT_NAT) - return true; - else if (vm_value.value.nat_value.type == &uwunil_type) + if (vm_value.type == &uwunil_type) return false; - else if (vm_value.value.nat_value.type == &uwubool_type) - return *(bool *) vm_value.value.nat_value.data; + else if (vm_value.type == &uwubool_type) + return *(bool *) vm_value.data; else return true; } @@ -36,7 +29,7 @@ static void *uwubool_copy(void *data) { bool *copy = malloc(sizeof(*copy)); *copy = *(bool *) data; - return copy; + return copy; } static char *uwubool_print(void *data) @@ -44,7 +37,7 @@ static char *uwubool_print(void *data) return strdup(((bool *) data) ? "true" : "false"); } -UwUVMNativeType uwubool_type = { +UwUVMType uwubool_type = { .copy = &uwubool_copy, .delete = &free, .print = &uwubool_print, |