aboutsummaryrefslogtreecommitdiff
path: root/src/tilde_const.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-07-25 14:37:19 +0100
committergingerBill <bill@gingerbill.org>2023-07-25 14:37:19 +0100
commitc4033c215e01343709a0d7928c277a6425f53524 (patch)
tree9010d0f0f6df92383102f12a719ab3d84c20054c /src/tilde_const.cpp
parente914d551e7c4a89dfddeca5dd42f24716968c4e5 (diff)
Support non-constant global slices
Diffstat (limited to 'src/tilde_const.cpp')
-rw-r--r--src/tilde_const.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/tilde_const.cpp b/src/tilde_const.cpp
index d37edb89a..5b34480f4 100644
--- a/src/tilde_const.cpp
+++ b/src/tilde_const.cpp
@@ -555,11 +555,11 @@ gb_internal bool cg_global_const_add_region(cgModule *m, ExactValue const &value
return true;
}
- GB_ASSERT(!is_type_array_like(bt));
switch (value.kind) {
case ExactValue_Bool:
{
+ GB_ASSERT_MSG(!is_type_array_like(bt), "%s", type_to_string(type));
bool *res = cast(bool *)tb_global_add_region(m->mod, global, offset, size);
*res = !!value.value_bool;
}
@@ -567,6 +567,7 @@ gb_internal bool cg_global_const_add_region(cgModule *m, ExactValue const &value
case ExactValue_Integer:
{
+ GB_ASSERT_MSG(!is_type_array_like(bt), "%s", type_to_string(type));
void *res = tb_global_add_region(m->mod, global, offset, size);
cg_write_big_int_at_ptr(res, &value.value_integer, type);
}
@@ -574,6 +575,7 @@ gb_internal bool cg_global_const_add_region(cgModule *m, ExactValue const &value
case ExactValue_Float:
{
+ GB_ASSERT_MSG(!is_type_array_like(bt), "%s", type_to_string(type));
f64 f = exact_value_to_f64(value);
void *res = tb_global_add_region(m->mod, global, offset, size);
switch (size) {
@@ -586,6 +588,7 @@ gb_internal bool cg_global_const_add_region(cgModule *m, ExactValue const &value
case ExactValue_Pointer:
{
+ GB_ASSERT_MSG(!is_type_array_like(bt), "%s", type_to_string(type));
void *res = tb_global_add_region(m->mod, global, offset, size);
*(u64 *)res = exact_value_to_u64(value);
}
@@ -603,6 +606,7 @@ gb_internal bool cg_global_const_add_region(cgModule *m, ExactValue const &value
case ExactValue_Typeid:
{
+ GB_ASSERT_MSG(!is_type_array_like(bt), "%s", type_to_string(type));
void *dst = tb_global_add_region(m->mod, global, offset, size);
u64 id = cg_typeid_as_u64(m, value.value_typeid);
cg_write_uint_at_ptr(dst, id, t_typeid);
@@ -621,6 +625,7 @@ gb_internal bool cg_global_const_add_region(cgModule *m, ExactValue const &value
break;
case ExactValue_Complex:
{
+ GB_ASSERT_MSG(!is_type_array_like(bt), "%s", type_to_string(type));
Complex128 c = {};
if (value.value_complex) {
c = *value.value_complex;
@@ -644,6 +649,7 @@ gb_internal bool cg_global_const_add_region(cgModule *m, ExactValue const &value
break;
case ExactValue_Quaternion:
{
+ GB_ASSERT_MSG(!is_type_array_like(bt), "%s", type_to_string(type));
// @QuaternionLayout
Quaternion256 q = {};
if (value.value_quaternion) {